兰宝车间质量管理系统-前端
疯狂的狮子Li
2023-10-16 6fe269efc7fb469aa536b123ef8be6da5085001d
src/views/system/user/index.vue
@@ -154,7 +154,7 @@
    </el-row>
    <!-- 添加或修改用户配置对话框 -->
    <el-dialog :title="dialog.title" v-model="dialog.visible" width="600px" append-to-body @close="closeDialog">
    <el-dialog ref="formDialogRef" :title="dialog.title" v-model="dialog.visible" width="600px" append-to-body @close="closeDialog">
      <el-form :model="form" :rules="rules" ref="userFormRef" label-width="80px">
        <el-row>
          <el-col :span="12">
@@ -299,12 +299,12 @@
<script setup name="User" lang="ts">
import api from "@/api/system/user"
import { UserForm, UserQuery, UserVO } from '@/api/system/user/types';
import { getToken } from "@/utils/auth";
import { treeselect } from "@/api/system/dept";
import { DeptVO } from "@/api/system/dept/types";
import { RoleVO } from "@/api/system/role/types";
import { PostVO } from "@/api/system/post/types";
import { to } from "await-to-js";
import { globalHeaders } from "@/utils/request";
const router = useRouter();
const { proxy } = getCurrentInstance() as ComponentInternalInstance
@@ -320,7 +320,7 @@
const dateRange = ref<[DateModelType, DateModelType]>(['', '']);
const deptName = ref('');
const deptOptions = ref<DeptVO[]>([]);
const initPassword = ref('123456');
const initPassword = ref<String>('');
const postOptions = ref<PostVO[]>([]);
const roleOptions = ref<RoleVO[]>([]);
/*** 用户导入参数 */
@@ -334,19 +334,19 @@
  // 是否更新已经存在的用户数据
  updateSupport: 0,
  // 设置上传的请求头部
  headers: { Authorization: "Bearer " + getToken() },
  headers: globalHeaders(),
  // 上传的地址
  url: import.meta.env.VITE_APP_BASE_API + "/system/user/importData"
})
// 列显隐信息
const columns = ref<FieldOption[]>([
  { key: 0, label: `用户编号`, visible: false },
  { key: 1, label: `用户名称`, visible: true },
  { key: 2, label: `用户昵称`, visible: true },
  { key: 3, label: `部门`, visible: true },
  { key: 4, label: `手机号码`, visible: true },
  { key: 5, label: `状态`, visible: true },
  { key: 6, label: `创建时间`, visible: true }
  { key: 0, label: `用户编号`, visible: false,children: [] },
  { key: 1, label: `用户名称`, visible: true,children: [] },
  { key: 2, label: `用户昵称`, visible: true,children: [] },
  { key: 3, label: `部门`, visible: true,children: [] },
  { key: 4, label: `手机号码`, visible: true,children: [] },
  { key: 5, label: `状态`, visible: true,children: [] },
  { key: 6, label: `创建时间`, visible: true,children: [] }
])
@@ -354,6 +354,7 @@
const queryFormRef = ref<ElFormInstance>();
const userFormRef = ref<ElFormInstance>();
const uploadRef = ref<ElUploadInstance>();
const formDialogRef = ref<ElDialogInstance>();
const dialog = reactive<DialogOption>({
  visible: false,
@@ -547,40 +548,35 @@
}
/** 取消按钮 */
const cancel = () => {
  reset();
  dialog.visible = false;
  reset();
}
/** 新增按钮操作 */
const handleAdd = () => {
const handleAdd = async () => {
  reset();
  const { data } = await api.getUser();
  dialog.visible = true;
  dialog.title = "新增用户";
  nextTick(async () => {
    reset();
    await initTreeData();
    const { data } = await api.getUser();
    postOptions.value = data.posts;
    roleOptions.value = data.roles;
    form.value.password = initPassword.value;
  })
  await initTreeData();
  postOptions.value = data.posts;
  roleOptions.value = data.roles;
  form.value.password = initPassword.value.toString();
}
/** 修改按钮操作 */
const handleUpdate = (row?: UserForm) => {
const handleUpdate = async (row?: UserForm) => {
  reset();
  const userId = row?.userId || ids.value[0]
  const { data } = await api.getUser(userId)
  dialog.visible = true;
  dialog.title = "修改用户";
  nextTick(async () => {
    reset();
    await initTreeData();
    const userId = row?.userId || ids.value[0]
    const { data } = await api.getUser(userId)
    Object.assign(form.value, data.user);
    postOptions.value = data.posts;
    roleOptions.value = data.roles;
    form.value.postIds = data.postIds;
    form.value.roleIds = data.roleIds;
    form.value.password = "";
  })
  await initTreeData();
  Object.assign(form.value, data.user);
  postOptions.value = data.posts;
  roleOptions.value = data.roles;
  form.value.postIds = data.postIds;
  form.value.roleIds = data.roleIds;
  form.value.password = "";
}
/** 提交按钮 */
@@ -617,6 +613,9 @@
onMounted(() => {
  getTreeSelect() // 初始化部门数据
  getList() // 初始化列表数据
  proxy?.getConfigKey("sys.user.initPassword").then(response => {
    initPassword.value = response.data;
  });
});
</script>