src/views/system/user/index.vue
@@ -6,7 +6,7 @@
            <pane size="16">
               <el-col style="padding: 10px">
                  <div class="head-container">
                     <el-input v-model="deptName" placeholder="请输入部门名称" clearable prefix-icon="Search" style="margin-bottom: 20px" />
                     <el-input v-model="deptNames" placeholder="请输入部门名称" clearable prefix-icon="Search" style="margin-bottom: 20px" />
                  </div>
                  <div class="head-container">
                     <el-tree :data="deptOptions" :props="{ label: 'label', children: 'children' }" :expand-on-click-node="false" :filter-node-method="filterNode" ref="deptTreeRef" node-key="id" highlight-current default-expand-all @node-click="handleNodeClick" />
@@ -61,7 +61,7 @@
                     <el-table-column label="用户编号" align="center" key="userId" prop="userId" v-if="columns[0].visible" />
                     <el-table-column label="登录账号" align="center" key="userName" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" />
                     <el-table-column label="用户昵称" align="center" key="nickName" prop="nickName" v-if="columns[2].visible" :show-overflow-tooltip="true" />
                     <el-table-column label="部门" align="center" key="deptName" prop="dept.deptName" v-if="columns[3].visible" :show-overflow-tooltip="true" />
                     <el-table-column label="部门" align="center" key="deptNames" prop="deptNames" v-if="columns[3].visible" :show-overflow-tooltip="true" />
                     <el-table-column label="手机号码" align="center" key="phonenumber" prop="phonenumber" v-if="columns[4].visible" width="120" />
                     <el-table-column label="状态" align="center" key="status" v-if="columns[5].visible">
                        <template #default="scope">
@@ -235,7 +235,7 @@
const total = ref(0)
const title = ref("")
const dateRange = ref([])
const deptName = ref("")
const deptNames = ref("")
const deptOptions = ref(undefined)
const enabledDeptOptions = ref(undefined)
const initPassword = ref(undefined)
@@ -298,7 +298,7 @@
}
/** 根据名称筛选部门树 */
watch(deptName, val => {
watch(deptNames, val => {
   proxy.$refs["deptTreeRef"].filter(val)
})
@@ -519,14 +519,19 @@
function submitForm() {
   proxy.$refs["userRef"].validate(valid => {
      if (valid) {
         // 归属部门虽然是单选,但后端需要传数组字段 deptIds
         const payload = {
            ...form.value,
            deptIds: form.value.deptId ? [form.value.deptId] : []
         }
         if (form.value.userId != undefined) {
            updateUser(form.value).then(response => {
            updateUser(payload).then(response => {
               proxy.$modal.msgSuccess("修改成功")
               open.value = false
               getList()
            })
         } else {
            addUser(form.value).then(response => {
            addUser(payload).then(response => {
               proxy.$modal.msgSuccess("新增成功")
               open.value = false
               getList()