| | |
| | | children: 'children', |
| | | label: 'name', |
| | | value: 'code' |
| | | } |
| | | }, |
| | | PCTrue: false, // 是否展示 |
| | | APPTrue: false// 是否展示 |
| | | } |
| | | }, |
| | | created() { |
| | |
| | | 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// 回显等待是否放行 |
| | | |
| | | if (this.PCTrue && this.APPTrue) { |
| | | // 1.第一种情况PC和APP都一次都没选中时 PC未选中,APP未选中 |
| | | if (rightPCArrFlag === 'N' && rightAPPArrFlag === 'N') { |
| | | pcIsSelected1 = true |
| | | this.dialogFormRight.rightCurrentCode = this.dialogFormRight.rightPCArr[0].code |
| | | } |
| | | |
| | | // 2.第二种情况PC已选中,APP未选中 |
| | | if (rightPCArrFlag === 'Y' && rightAPPArrFlag === 'N') { |
| | | pcIsSelected1 = true |
| | |
| | | |
| | | this.dialogFormRight.rightCurrentCode = this.dialogFormRight.rightPCArr[0].code |
| | | } |
| | | |
| | | // 3.第三种情况PC未选中,APP已选中 |
| | | if (rightPCArrFlag === 'N' && rightAPPArrFlag === 'Y') { |
| | | appIsSelected1 = true |
| | |
| | | |
| | | 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 => { |
| | |
| | | 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 => { |
| | |
| | | this.dialogFormRight.rightAPPArrSelected.push(item.code) |
| | | } |
| | | }) |
| | | } |
| | | this.$nextTick(() => { |
| | | if (this.$refs.rightPCRef) { |
| | | this.$refs.rightPCRef.setCheckedKeys(this.dialogFormRight.rightPCArrSelected) |
| | |
| | | if (this.$refs.rightAPPRef) { |
| | | this.$refs.rightAPPRef.setCheckedKeys([]) |
| | | } |
| | | this.PCTrue = false |
| | | this.APPTrue = false |
| | | }, |
| | | // 权限对话框取消事件 |
| | | rightDialogVisibleCancel() { |
| | |
| | | async rightDialogVisibleConfirm() { |
| | | const rightPCArrSelected = []// 保存提交树选中 PC |
| | | const rightAPPArrSelected = []// 保存提交树选中 APP |
| | | |
| | | if (this.PCTrue) { |
| | | this.dialogFormRight.rightPCArr[0].children.forEach(item => { |
| | | if (item.children && item.children.length > 0) { |
| | | const children = [] |
| | |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (this.APPTrue) { |
| | | this.dialogFormRight.rightAPPArr[0].children.forEach(item => { |
| | | if (item.children && item.children.length > 0) { |
| | | const children = [] |
| | |
| | | } |
| | | } |
| | | }) |
| | | |
| | | } |
| | | // 最终要提交的数据 |
| | | let rightSubmit = [] |
| | | |