From f35da7050efeaff1fd442c233008fdc00b10851f Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期一, 18 七月 2022 18:04:33 +0800
Subject: [PATCH] 1.优化项目修改bug2.实现缺陷前端页面

---
 src/views/jcsz/jsqd.vue |  399 ++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 255 insertions(+), 144 deletions(-)

diff --git a/src/views/jcsz/jsqd.vue b/src/views/jcsz/jsqd.vue
index 4a554be..bfb4baa 100644
--- a/src/views/jcsz/jsqd.vue
+++ b/src/views/jcsz/jsqd.vue
@@ -633,7 +633,9 @@
         children: 'children',
         label: 'name',
         value: 'code'
-      }
+      },
+      PCTrue: false, // 鏄惁灞曠ず
+      APPTrue: false// 鏄惁灞曠ず
     }
   },
   created() {
@@ -973,125 +975,229 @@
         type: ''
       }
       const { data: res } = await RoleAssociationRight(data)// 鎺ュ彛鑾峰彇鏁版嵁
-      this.dialogFormRight.rightPCArr = res[0]
-      this.dialogFormRight.rightAPPArr = res[1]
+      // '0'鏄剧ず  '1' 涓嶆樉绀�
+      this.dialogFormRight.rightPCArr = res[0][0].is_delete === '0' ? res[0] : []
+      this.dialogFormRight.rightAPPArr = res[1][0].is_delete === '0' ? res[1] : []
+
+      this.PCTrue = res[0][0].is_delete === '0'
+      this.APPTrue = res[1][0].is_delete === '0'
+
+      if (this.PCTrue) {
+        this.dialogFormRight.rightPCArr[0].children.forEach((item, index) => {
+          if (item.is_delete === '1') {
+            this.dialogFormRight.rightPCArr[0].children.splice(index, 1)
+          } else {
+            if (item.children.length > 0 && item.children) {
+              item.children.forEach((it, ind) => {
+                if (it.is_delete === '1') {
+                  item.children.splice(ind, 1)
+                }
+              })
+            }
+            if (item.children.length === 0) {
+              this.dialogFormRight.rightPCArr[0].children.splice(index, 1)
+            }
+          }
+        })
+      }
+      if (this.APPTrue) {
+        this.dialogFormRight.rightAPPArr[0].children.forEach((item, index) => {
+          if (item.is_delete === '1') {
+            this.dialogFormRight.rightAPPArr[0].children.splice(index, 1)
+          } else {
+            if (item.children.length > 0 && item.children) {
+              item.children.forEach((it, ind) => {
+                if (it.is_delete === '1') {
+                  item.children.splice(ind, 1)
+                }
+              })
+            }
+            if (item.children.length === 0) {
+              this.dialogFormRight.rightAPPArr[0].children.splice(index, 1)
+            }
+          }
+        })
+      }
 
       // 鍒ゆ柇鍝釜鏄珮浜�
       let pcIsSelected1 = false
       let pcIsSelected2 = false
       let appIsSelected1 = false
       let appIsSelected2 = false
-      const rightPCArrFlag = res[0][0].flag
-      const rightAPPArrFlag = res[1][0].flag
+      let rightPCArrFlag
+      let rightAPPArrFlag
+
+      if (this.PCTrue) {
+        rightPCArrFlag = this.dialogFormRight.rightPCArr[0].flag
+      }
+      if (this.APPTrue) {
+        rightAPPArrFlag = this.dialogFormRight.rightAPPArr[0].flag
+      }
 
       let waitFlag = false// 鍥炴樉绛夊緟鏄惁鏀捐
 
-      // 1.绗竴绉嶆儏鍐礟C鍜孉PP閮戒竴娆¢兘娌¢�変腑鏃�    PC鏈�変腑锛孉PP鏈�変腑
-      if (rightPCArrFlag === 'N' && rightAPPArrFlag === 'N') {
-        pcIsSelected1 = true
-        this.dialogFormRight.rightCurrentCode = this.dialogFormRight.rightPCArr[0].code
-      }
-
-      // 2.绗簩绉嶆儏鍐礟C宸查�変腑锛孉PP鏈�変腑
-      if (rightPCArrFlag === 'Y' && rightAPPArrFlag === 'N') {
-        pcIsSelected1 = true
-        pcIsSelected2 = true
-
-        const interval = setInterval(() => {
-          if ($("input[name='PC']").length > 0) {
-            waitFlag = true
-          }
-          if (waitFlag) {
-            clearInterval(interval)
-            this.$nextTick(() => {
-              $("input[name='PC']").eq(0).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
-            })
-          }
-        }, 100)
-
-        this.dialogFormRight.rightCurrentCode = this.dialogFormRight.rightPCArr[0].code
-      }
-
-      // 3.绗笁绉嶆儏鍐礟C鏈�変腑锛孉PP宸查�変腑
-      if (rightPCArrFlag === 'N' && rightAPPArrFlag === 'Y') {
-        appIsSelected1 = true
-        appIsSelected2 = true
-
-        const interval = setInterval(() => {
-          if ($("input[name='APP']").length > 0) {
-            waitFlag = true
-          }
-          if (waitFlag) {
-            clearInterval(interval)
-            this.$nextTick(() => {
-              $("input[name='APP']").eq(0).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
-            })
-          }
-        }, 100)
-
-        this.dialogFormRight.rightCurrentCode = this.dialogFormRight.rightAPPArr[0].code
-      }
-      // 4.绗洓绉嶆儏鍐礟C宸查�変腑锛孉PP宸查�変腑
-      if (rightPCArrFlag === 'Y' && rightAPPArrFlag === 'Y') {
-        pcIsSelected1 = true
-        pcIsSelected2 = true
-        appIsSelected1 = false
-        appIsSelected2 = true
-
-        const interval = setInterval(() => {
-          if ($("input[name='PC']").length > 0) {
-            waitFlag = true
-          }
-          if (waitFlag) {
-            clearInterval(interval)
-            this.$nextTick(() => {
-              $("input[name='PC']").eq(0).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
-              $("input[name='APP']").eq(0).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
-            })
-          }
-        }, 100)
-
-        this.dialogFormRight.rightCurrentCode = this.dialogFormRight.rightPCArr[0].code
-      }
-      this.dialogFormRight.rightOperationArr.push({
-        isSelected1: pcIsSelected1,
-        isSelected2: pcIsSelected2,
-        code: this.dialogFormRight.rightPCArr[0].code,
-        flag: rightPCArrFlag,
-        name: this.dialogFormRight.rightPCArr[0].name
-      }, {
-        isSelected1: appIsSelected1,
-        isSelected2: appIsSelected2,
-        code: this.dialogFormRight.rightAPPArr[0].code,
-        flag: rightAPPArrFlag,
-        name: this.dialogFormRight.rightAPPArr[0].name
-      })
-
-      this.dialogFormRight.rightPCArr[0].name = '鍏ㄩ儴'
-      this.dialogFormRight.rightAPPArr[0].name = '鍏ㄩ儴'
-
-      this.dialogFormRight.rightPCArr[0].children.forEach(item => {
-        if (item.children && item.children.length > 0 && item.flag === 'Y') {
-          item.children.forEach(it => {
-            if (it.flag === 'Y') {
-              this.dialogFormRight.rightPCArrSelected.push(it.code)
-            }
-          })
-        } else if (item.children && item.children.length === 0 && item.flag === 'Y') {
-          this.dialogFormRight.rightPCArrSelected.push(item.code)
+      if (this.PCTrue && this.APPTrue) {
+        // 1.绗竴绉嶆儏鍐礟C鍜孉PP閮戒竴娆¢兘娌¢�変腑鏃�    PC鏈�変腑锛孉PP鏈�変腑
+        if (rightPCArrFlag === 'N' && rightAPPArrFlag === 'N') {
+          pcIsSelected1 = true
+          this.dialogFormRight.rightCurrentCode = this.dialogFormRight.rightPCArr[0].code
         }
-      })
-      this.dialogFormRight.rightAPPArr[0].children.forEach(item => {
-        if (item.children && item.children.length > 0 && item.flag === 'Y') {
-          item.children.forEach(it => {
-            if (it.flag === 'Y') {
-              this.dialogFormRight.rightAPPArrSelected.push(it.code)
+        // 2.绗簩绉嶆儏鍐礟C宸查�変腑锛孉PP鏈�変腑
+        if (rightPCArrFlag === 'Y' && rightAPPArrFlag === 'N') {
+          pcIsSelected1 = true
+          pcIsSelected2 = true
+
+          const interval = setInterval(() => {
+            if ($("input[name='PC']").length > 0) {
+              waitFlag = true
             }
-          })
-        } else if (item.children && item.children.length === 0 && item.flag === 'Y') {
-          this.dialogFormRight.rightAPPArrSelected.push(item.code)
+            if (waitFlag) {
+              clearInterval(interval)
+              this.$nextTick(() => {
+                $("input[name='PC']").eq(0).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
+              })
+            }
+          }, 100)
+
+          this.dialogFormRight.rightCurrentCode = this.dialogFormRight.rightPCArr[0].code
         }
-      })
+        // 3.绗笁绉嶆儏鍐礟C鏈�変腑锛孉PP宸查�変腑
+        if (rightPCArrFlag === 'N' && rightAPPArrFlag === 'Y') {
+          appIsSelected1 = true
+          appIsSelected2 = true
+
+          const interval = setInterval(() => {
+            if ($("input[name='APP']").length > 0) {
+              waitFlag = true
+            }
+            if (waitFlag) {
+              clearInterval(interval)
+              this.$nextTick(() => {
+                $("input[name='APP']").eq(0).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
+              })
+            }
+          }, 100)
+
+          this.dialogFormRight.rightCurrentCode = this.dialogFormRight.rightAPPArr[0].code
+        }
+        // 4.绗洓绉嶆儏鍐礟C宸查�変腑锛孉PP宸查�変腑
+        if (rightPCArrFlag === 'Y' && rightAPPArrFlag === 'Y') {
+          pcIsSelected1 = true
+          pcIsSelected2 = true
+          appIsSelected1 = false
+          appIsSelected2 = true
+
+          const interval = setInterval(() => {
+            if ($("input[name='PC']").length > 0) {
+              waitFlag = true
+            }
+            if (waitFlag) {
+              clearInterval(interval)
+              this.$nextTick(() => {
+                $("input[name='PC']").eq(0).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
+                $("input[name='APP']").eq(0).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
+              })
+            }
+          }, 100)
+
+          this.dialogFormRight.rightCurrentCode = this.dialogFormRight.rightPCArr[0].code
+        }
+      }
+
+      if (this.PCTrue && !this.APPTrue) {
+        if (rightPCArrFlag === 'Y') {
+          pcIsSelected1 = true
+          pcIsSelected2 = true
+
+          const interval = setInterval(() => {
+            if ($("input[name='PC']").length > 0) {
+              waitFlag = true
+            }
+            if (waitFlag) {
+              clearInterval(interval)
+              this.$nextTick(() => {
+                $("input[name='PC']").eq(0).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
+              })
+            }
+          }, 100)
+
+          this.dialogFormRight.rightCurrentCode = this.dialogFormRight.rightPCArr[0].code
+        }
+      }
+
+      if (!this.PCTrue && this.APPTrue) {
+        if (rightAPPArrFlag === 'Y') {
+          appIsSelected1 = true
+          appIsSelected2 = true
+
+          const interval = setInterval(() => {
+            if ($("input[name='APP']").length > 0) {
+              waitFlag = true
+            }
+            if (waitFlag) {
+              clearInterval(interval)
+              this.$nextTick(() => {
+                $("input[name='APP']").eq(0).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
+              })
+            }
+          }, 100)
+
+          this.dialogFormRight.rightCurrentCode = this.dialogFormRight.rightAPPArr[0].code
+        }
+      }
+
+      if (this.PCTrue) {
+        this.dialogFormRight.rightOperationArr.push({
+          isSelected1: pcIsSelected1,
+          isSelected2: pcIsSelected2,
+          code: this.dialogFormRight.rightPCArr[0].code,
+          flag: rightPCArrFlag,
+          name: this.dialogFormRight.rightPCArr[0].name
+        })
+      }
+      if (this.APPTrue) {
+        this.dialogFormRight.rightOperationArr.push({
+          isSelected1: appIsSelected1,
+          isSelected2: appIsSelected2,
+          code: this.dialogFormRight.rightAPPArr[0].code,
+          flag: rightAPPArrFlag,
+          name: this.dialogFormRight.rightAPPArr[0].name
+        })
+      }
+      if (this.PCTrue) {
+        this.dialogFormRight.rightPCArr[0].name = '鍏ㄩ儴'
+      }
+      if (this.APPTrue) {
+        this.dialogFormRight.rightAPPArr[0].name = '鍏ㄩ儴'
+      }
+
+      // 鏍戝舰鍥炴樉閮ㄥ垎
+      if (this.PCTrue) {
+        this.dialogFormRight.rightPCArr[0].children.forEach(item => {
+          if (item.children && item.children.length > 0 && item.flag === 'Y') {
+            item.children.forEach(it => {
+              if (it.flag === 'Y') {
+                this.dialogFormRight.rightPCArrSelected.push(it.code)
+              }
+            })
+          } else if (item.children && item.children.length === 0 && item.flag === 'Y') {
+            this.dialogFormRight.rightPCArrSelected.push(item.code)
+          }
+        })
+      }
+      if (this.APPTrue) {
+        this.dialogFormRight.rightAPPArr[0].children.forEach(item => {
+          if (item.children && item.children.length > 0 && item.flag === 'Y') {
+            item.children.forEach(it => {
+              if (it.flag === 'Y') {
+                this.dialogFormRight.rightAPPArrSelected.push(it.code)
+              }
+            })
+          } else if (item.children && item.children.length === 0 && item.flag === 'Y') {
+            this.dialogFormRight.rightAPPArrSelected.push(item.code)
+          }
+        })
+      }
       this.$nextTick(() => {
         if (this.$refs.rightPCRef) {
           this.$refs.rightPCRef.setCheckedKeys(this.dialogFormRight.rightPCArrSelected)
@@ -1114,6 +1220,8 @@
       if (this.$refs.rightAPPRef) {
         this.$refs.rightAPPRef.setCheckedKeys([])
       }
+      this.PCTrue = false
+      this.APPTrue = false
     },
     // 鏉冮檺瀵硅瘽妗嗗彇娑堜簨浠�
     rightDialogVisibleCancel() {
@@ -1123,46 +1231,49 @@
     async rightDialogVisibleConfirm() {
       const rightPCArrSelected = []// 淇濆瓨鎻愪氦鏍戦�変腑 PC
       const rightAPPArrSelected = []// 淇濆瓨鎻愪氦鏍戦�変腑 APP
-
-      this.dialogFormRight.rightPCArr[0].children.forEach(item => {
-        if (item.children && item.children.length > 0) {
-          const children = []
-          let flag = false // 琛ㄧずchildren閲屾湁鍊紁ush杩涘幓浜�
-          item.children.forEach(it => {
-            if (this.dialogFormRight.rightPCArrSelected.includes(it.code) || this.dialogFormRight.rightPCArrSelected.includes('PC')) {
-              flag = true
-              children.push(
-                { code: it.code, name: it.name, flag: 'Y' }
-              )
-            }
-          })
-          if (flag) {
-            rightPCArrSelected.push({
-              code: item.code, name: item.name, flag: 'Y', children: children
+      if (this.PCTrue) {
+        this.dialogFormRight.rightPCArr[0].children.forEach(item => {
+          if (item.children && item.children.length > 0) {
+            const children = []
+            let flag = false // 琛ㄧずchildren閲屾湁鍊紁ush杩涘幓浜�
+            item.children.forEach(it => {
+              if (this.dialogFormRight.rightPCArrSelected.includes(it.code) || this.dialogFormRight.rightPCArrSelected.includes('PC')) {
+                flag = true
+                children.push(
+                  { code: it.code, name: it.name, flag: 'Y' }
+                )
+              }
             })
-          }
-        }
-      })
-      this.dialogFormRight.rightAPPArr[0].children.forEach(item => {
-        if (item.children && item.children.length > 0) {
-          const children = []
-          let flag = false // 琛ㄧずchildren閲屾湁鍊紁ush杩涘幓浜�
-          item.children.forEach(it => {
-            if (this.dialogFormRight.rightAPPArrSelected.includes(it.code) || this.dialogFormRight.rightAPPArrSelected.includes('APP')) {
-              flag = true
-              children.push(
-                { code: it.code, name: it.name, flag: 'Y' }
-              )
+            if (flag) {
+              rightPCArrSelected.push({
+                code: item.code, name: item.name, flag: 'Y', children: children
+              })
             }
-          })
-          if (flag) {
-            rightAPPArrSelected.push({
-              code: item.code, name: item.name, flag: 'Y', children: children
-            })
           }
-        }
-      })
+        })
+      }
 
+      if (this.APPTrue) {
+        this.dialogFormRight.rightAPPArr[0].children.forEach(item => {
+          if (item.children && item.children.length > 0) {
+            const children = []
+            let flag = false // 琛ㄧずchildren閲屾湁鍊紁ush杩涘幓浜�
+            item.children.forEach(it => {
+              if (this.dialogFormRight.rightAPPArrSelected.includes(it.code) || this.dialogFormRight.rightAPPArrSelected.includes('APP')) {
+                flag = true
+                children.push(
+                  { code: it.code, name: it.name, flag: 'Y' }
+                )
+              }
+            })
+            if (flag) {
+              rightAPPArrSelected.push({
+                code: item.code, name: item.name, flag: 'Y', children: children
+              })
+            }
+          }
+        })
+      }
       // 鏈�缁堣鎻愪氦鐨勬暟鎹�
       let rightSubmit = []
 

--
Gitblit v1.9.3