Jelajahi Sumber

测试组织结构

ZaiZai 2 tahun lalu
induk
melakukan
86cef63453
1 mengubah file dengan 31 tambahan dan 13 penghapusan
  1. 31 13
      src/views/system/user.vue

+ 31 - 13
src/views/system/user.vue

@@ -67,15 +67,15 @@
                         <el-row :gutter="10">
                             <el-col :span="7">
                                 <el-form-item prop="deptId">
-                                    <el-select v-model="item.deptId" placeholder="选择部门" @change="initPostData(item.deptId)">
+                                    <el-select v-model="item.deptId" placeholder="选择部门" @change="initPostData($event, index)">
                                         <el-option v-for="item in sectionData" :label="item.deptName" :value="item.id"/>
                                     </el-select>
                                 </el-form-item>
                             </el-col>
                             <el-col :span="7">
-                                <el-form-item prop="postId" :getInit="initPostData(item.deptId)">
+                                <el-form-item prop="postId">
                                     <el-select v-model="item.postId" placeholder="选择岗位">
-                                        <el-option label="暂无接口" :value="1"/>
+                                        <el-option v-for="item in postData[index]" :label="item.deptName" :value="item.id"/>
                                     </el-select>
                                 </el-form-item>
                             </el-col>
@@ -103,8 +103,8 @@
                     <div class="hac-card-title">详细信息</div>
                 </template>
                 <el-form ref="formRef1" :model="formModel" :rules="formRules" label-position="left" label-width="auto" size="large">
-                    <el-form-item label="用户姓名:" prop="real_name">
-                        <el-input v-model="formModel.real_name"/>
+                    <el-form-item label="用户姓名:" prop="realName">
+                        <el-input v-model="formModel.realName"/>
                     </el-form-item>
                     <el-form-item prop="phone" label="手机号码:">
                         <el-input v-model="formModel.phone" placeholder="请输入绑定手机"/>
@@ -113,7 +113,7 @@
                         <el-input v-model="formModel.idNumber"/>
                     </el-form-item>
                     <el-form-item label="日单价:">
-                        <el-input v-model="formModel.roleName"/>
+                        <el-input v-model="formModel.key2"/>
                     </el-form-item>
                     <el-form-item label="启用状态:">
                         <el-select v-model="formModel.status" class="block">
@@ -283,14 +283,24 @@ const addUserClick = () => {
     formModel.value = {
         organization: [{}],
     }
+    postData.value = [{}]
     formModal.value = true
     getSectionData()
 }
 
 //编辑用户信息
 const rowEidtClick = (row) => {
-    row.organization = row.organization ?? [{}]
     row.password = ''
+    const organization = getArrValue(row.organization)
+    row.organization = organization
+    if (organization.length > 0){
+        organization.forEach(() => {
+            postData.value.push({})
+        })
+    } else {
+        row.organization = [{}]
+        postData.value = [{}]
+    }
     formModel.value = row
     formModal.value = true
     getSectionData()
@@ -299,9 +309,7 @@ const rowEidtClick = (row) => {
 //部门下拉数据
 const sectionData = ref([])
 const getSectionData = async () => {
-    const { error, code, data } = await organizationApi.getList({
-        deptType: 2
-    })
+    const { error, code, data } = await organizationApi.getList({deptType: 2})
     if (!error && code === 200) {
         sectionData.value = getArrValue(data)
     } else {
@@ -310,25 +318,35 @@ const getSectionData = async () => {
 }
 
 //获取岗位数据
-const initPostData = () => {
-
+const postData = ref([])
+const initPostData = async (id, index) => {
+    if (id) {
+        const { error, code, data } = await organizationApi.getList({parentId: id})
+        if (!error && code === 200) {
+            postData.value[index] = getArrValue(data)
+        } else {
+            postData.value[index] = []
+        }
+    }
 }
 
 
 //新增组织
 const addOrganizationClick = (row) => {
     formModel.value.organization.push({})
+    postData.value.push({})
 }
 
 //删除组织
 const delOrganizationClick = (index) => {
     formModel.value.organization.splice(index, 1)
+    postData.value.splice(index, 1)
 }
 
 
 //保存
 const formModalSave = () => {
-
+    console.log(formModel.value)
 }
 
 //关闭用户信息弹窗