Przeglądaj źródła

fix:【ibps_party_employee】表中的 positions_ 更新

liujiayin 2 lat temu
rodzic
commit
5ab3da0cd2

+ 22 - 0
src/utils/util.js

@@ -276,6 +276,28 @@ const util = {
             }
         }
         return result
+    },
+    /**
+     * 在字符串oldIds里增加或者剔除fixId
+     * @param {*} type
+     * @param {*} oldIds
+     * @param {*} fixId
+     * @returns
+     */
+    addOrDelString (type, oldIds, fixId) {
+        const oldIdsArr = oldIds.split(',')
+        if (type === 'remove') {
+            oldIdsArr.splice(oldIdsArr.indexOf(fixId), 1)
+            oldIds = oldIdsArr.join(',')
+        } else {
+            if (oldIds && oldIds.indexOf(fixId) < 0) {
+                oldIdsArr.push(fixId)
+                oldIds = oldIdsArr.join(',')
+            } else if (!oldIds) {
+                oldIds = fixId
+            }
+        }
+        return oldIds
     }
 }
 

+ 12 - 1
src/views/platform/org/employee/edit/index.vue

@@ -288,7 +288,17 @@ export default {
                 this.dialogLoading = false
                 return
             }
-
+            // 部门信息
+            if (vo.positionVoList.length > 0) {
+                const list = []
+                vo.positionVoList.forEach(item => {
+                    list.push(item.id)
+                })
+                vo.user.positions = list.join(',')
+            } else {
+                vo.user.positions = ''
+            }
+            // 角色信息
             if (vo.roleVoList.length > 0) {
                 const list = []
                 vo.roleVoList.forEach(item => {
@@ -307,6 +317,7 @@ export default {
                             id_: vo.user.id
                         },
                         param: {
+                            positions_: vo.user.positions,
                             job_: vo.user.job
                         }
                     }

+ 36 - 1
src/views/platform/org/position/detail/position-employee.vue

@@ -34,6 +34,7 @@
 import IbpsEmployeeSelectorDialog from '@/business/platform/org/employee/dialog'
 import { queryWithOrg as queryPageList, addPositionUser, removePositionUser } from '@/api/platform/org/employee'
 import ActionUtils from '@/utils/action'
+import AtilUtils from '@/utils/util'
 import { statusOptions, genderOptions } from '../../employee/constants'
 import { queryPageList as queryUserList } from '@/api/platform/org/employee'
 
@@ -228,15 +229,17 @@ export default {
             }
         },
         handleConfirm (data) {
+            const userIdsStr = data.map((d) => { return d.id }).join(',')
             this.selectorVisible = false
             addPositionUser({
                 positionId: this.id,
-                userIds: data.map((d) => { return d.id }).join(',')
+                userIds: userIdsStr
             }).then(response => {
                 this.selectorVisible = false
                 ActionUtils.success('加入人员成功!')
                 this.search()
             })
+            this.handleUpemployee('add', userIdsStr)
         },
         handleRemove (ids) {
             removePositionUser({
@@ -246,6 +249,7 @@ export default {
                 ActionUtils.removeSuccessMessage()
                 this.search()
             })
+            this.handleUpemployee('remove', ids)
         },
         // 获取组织的数据
         getOrg () {
@@ -261,6 +265,37 @@ export default {
                     resolve()
                 })
             })
+        },
+        /**
+         * 根据所选择的人员信息,修改对应人员的job_信息
+         */
+        handleUpemployee (type, ids) {
+            const tableName = 'ibps_party_employee'
+            // 更新ibps_party_employee里job_信息
+            const sql = `select ID_, POSITIONS_ from ${tableName} where find_in_set(id_,'${ids}')`
+            this.$common.request('sql', sql).then((res) => {
+                const resDatas = res.variables.data
+                const updListDatas = []
+                for (const i of resDatas) {
+                    const updListData = {
+                        where: {
+                            id_: i.ID_
+                        },
+                        param: {
+                            positions_: AtilUtils.addOrDelString(type, i.POSITIONS_, this.id)
+                        }
+                    }
+
+                    updListDatas.push(updListData)
+                }
+                const updateParams = {
+                    tableName,
+                    updList: updListDatas
+                }
+                this.$common.request('update', updateParams).then(() => {
+                    console.log('更新数据成功')
+                })
+            })
         }
     }
 }

+ 2 - 19
src/views/platform/org/role/user-list.vue

@@ -44,6 +44,7 @@ import { queryByRoleId as queryPageList, addRoleUser, removeRoleUser } from '@/a
 import { statusOptions, genderOptions } from '../employee/constants'
 import { sourceOptions } from './constants'
 import ActionUtils from '@/utils/action'
+import AtilUtils from '@/utils/util'
 export default {
     components: {
         IbpsEmployeeSelectorDialog
@@ -261,7 +262,7 @@ export default {
                             id_: i.ID_
                         },
                         param: {
-                            JOB_: this.fixAddJob(type, i.JOB_, this.id)
+                            JOB_: AtilUtils.addOrDelString(type, i.JOB_, this.id)
                         }
                     }
 
@@ -275,24 +276,6 @@ export default {
                     console.log('更新数据成功')
                 })
             })
-        },
-        /**
-         * 在oldIds里剔除fixId,或者增加fixId
-         */
-        fixAddJob (type, oldIds, fixId) {
-            const oldIdsArr = oldIds.split(',')
-            if (type === 'remove') {
-                oldIdsArr.splice(oldIdsArr.indexOf(fixId), 1)
-                oldIds = oldIdsArr.join(',')
-            } else {
-                if (oldIds && oldIds.indexOf(fixId) < 0) {
-                    oldIdsArr.push(fixId)
-                    oldIds = oldIdsArr.join(',')
-                } else if (!oldIds) {
-                    oldIds = fixId
-                }
-            }
-            return oldIds
         }
     }
 }