Bläddra i källkod

修复主部门设置产生多条问题

cyy 1 år sedan
förälder
incheckning
e54d10065c

+ 21 - 13
src/layout/header-aside/components/header-user/index.vue

@@ -266,20 +266,28 @@ export default {
             this.updateMainPosition(this.mainPosition.id, item.id)
             this.updateMainPosition(this.mainPosition.id, item.id)
         },
         },
         setMainPosition (mid) {
         setMainPosition (mid) {
-            request({
-                url: '/platform/v3/rel/save',
-                method: 'post',
-                isLoading: true,
-                data: {
-                    biz: 'mainPost',
-                    mainType: 'position',
-                    subType: 'employee',
-                    mainPid: mid,
-                    subPid: this.userId
+            let sql = `select * from ibps_party_rel where biz_ = 'mainPost' and SUB_PID_ = '${this.userId}'`
+            this.$common.request('sql', sql).then((r)=>{
+                if(r.variables.data.length===0){
+                    request({
+                        url: '/platform/v3/rel/save',
+                        method: 'post',
+                        isLoading: true,
+                        data: {
+                            biz: 'mainPost',
+                            mainType: 'position',
+                            subType: 'employee',
+                            mainPid: mid,
+                            subPid: this.userId
+                        }
+                    }).then(res => {
+                        this.$message.success('设置主部门成功!')
+                        location.reload()
+                    })
+                }else{
+                    this.$message.warning('部门信息更新,请在刷新后重新选择!')
+                    location.reload()
                 }
                 }
-            }).then(res => {
-                this.$message.success('设置主部门成功!')
-                location.reload()
             })
             })
         },
         },
         updateMainPosition (oldId, newId) {
         updateMainPosition (oldId, newId) {

+ 39 - 2
src/views/platform/org/employee/edit/index.vue

@@ -181,6 +181,7 @@ export default {
                 jiNengZhiCheng: 'inside'
                 jiNengZhiCheng: 'inside'
             },
             },
             employee: {},
             employee: {},
+            oldEmployee: {},//未更改前全部信息
             qrcodeVisible: false,
             qrcodeVisible: false,
             personalInfo: '',
             personalInfo: '',
             toolbars: [
             toolbars: [
@@ -390,8 +391,41 @@ export default {
                     if (this.wxyhId) {
                     if (this.wxyhId) {
                         this.updateWxyh()
                         this.updateWxyh()
                     }
                     }
-                    // 更新部门、岗位数据
-                    this.$common.request('update', updateParams)
+                    //防止主部门多条起
+                    console.log(this.employee,this.oldEmployee,'2222')
+                    let obj = this.employee.posItemList.find(t=>t.isMainPost==="Y")
+                    let sql = `select * from ibps_party_rel where biz_ = 'mainPost' and SUB_PID_ = '${this.employee.id}'`
+                    this.$common.request('sql', sql).then((r)=>{
+                        let res = r.variables.data
+                        let old = false
+                        let oldArr = []
+                        if(res.length>0){
+                            old = true
+                            res.forEach((e,i)=>{
+                                if(i+1!==res.length){
+                                    oldArr.push(e.MAIN_PID_)
+                                }
+                            })
+                        }
+                        if(typeof obj === "undefined"){
+                            const delParams = {
+                                tableName: 'ibps_party_rel',
+                                paramWhere: { SUB_PID_: this.employee.id }
+                            }
+                            this.$common.request('delete', delParams)
+                        }else if(typeof obj !== "undefined"&&old){
+                            const delParams = {
+                                tableName: 'ibps_party_rel',
+                                paramWhere: { SUB_PID_: this.employee.id,MAIN_PID_:oldArr.join(',') }
+                            }
+                            this.$common.request('delete', delParams)
+                        }
+                        // 更新部门、岗位数据
+                        this.$common.request('update', updateParams)
+                    })
+                    //防止主部门多条止
+
+                    
                     // 启动培训
                     // 启动培训
                     this.createTrain(response.variables.id)
                     this.createTrain(response.variables.id)
                     this.$emit('dialog-callback', this)
                     this.$emit('dialog-callback', this)
@@ -495,6 +529,9 @@ export default {
                     })
                     })
                     this.employee.attrItemList = list
                     this.employee.attrItemList = list
                 }
                 }
+                //保存更改前全部信息
+                this.oldEmployee = structuredClone(this.employee)
+
 
 
                 // 添加更新 t_wxyh 用于扫码签到
                 // 添加更新 t_wxyh 用于扫码签到
                 // if()
                 // if()