From b33517d527aff48ff30eb78d341bbce53d0ed3bb Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期六, 30 十一月 2024 06:42:42 +0800 Subject: [PATCH] 部门、人。回显bug --- src/components/flow/User/index.vue | 102 ++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 88 insertions(+), 14 deletions(-) diff --git a/src/components/flow/User/index.vue b/src/components/flow/User/index.vue index 31ce534..33dcb57 100644 --- a/src/components/flow/User/index.vue +++ b/src/components/flow/User/index.vue @@ -102,6 +102,10 @@ default: 'multiple', required: true }, + num: { + required: true, + type: Number + } }, data() { return { @@ -163,36 +167,106 @@ }, selectValues: { handler(newVal) { - if (StrUtil.isNotBlank(newVal)) { - if (newVal instanceof Number) { - this.radioSelected = newVal + if (newVal) { + if (this.checkType === 'multiple') { + this.selectUserList = newVal.map(item => parseInt(item)) } else { - this.selectUserList = newVal; + this.radioSelected = parseInt(newVal) } } }, immediate: true }, userList: { + deep: true, handler(newVal) { - if (StrUtil.isNotBlank(newVal) && this.selectUserList.length > 0) { + console.log(newVal, "鏁板瓧") + console.log(this.selectValues, "浼犲叆鐨勫�兼槸") + if (this.checkType !== 'multiple') { + console.log(this.userList, "浼犲叆鐨勫�兼槸") + if (this.radioSelected && this.userList.length > 0) { this.$nextTick(() => { this.$refs.dataTable.clearSelection(); - this.selectUserList?.split(',').forEach(key => { - this.$refs.dataTable.toggleRowSelection(newVal.find( - item => key == item.userId - ), true) - }); + newVal.forEach(item => { + console.log(this.radioSelected === item.userId, 123) + if (this.radioSelected === item.userId) { + this.$refs.dataTable.toggleRowSelection(item) + } + }) }); + } + } else { + this.$nextTick(() => { + this.$refs.dataTable.clearSelection(); + this.selectUserList.forEach(key => { + newVal.forEach(item => { + if (key === item.userId) { + this.$refs.dataTable.toggleRowSelection(item) + } + }) + }); + }); } - } - } + + // if (StrUtil.isNotBlank(newVal)) { + // + // if (typeof newVal == "number" || typeof newVal == "string") { + // console.log("杩涜繖") + // + // } else { + // console.log("涓嶅簲璇ヨ繘鐫�") + // + // console.log("鐢ㄦ埛鍥炴樉", this.selectUserList) + // } + // } + }, + // immediate: true + }, + // userList: { + // // handler(newVal) { + // // console.log(this.radioSelected, "鍗曢�夊��") + // // if (this.checkType !== 'multiple') { + // // + // // } else { + // // console.log("this.selectUserList",this.selectUserList ,typeof this.selectUserList) + // // + // // } + // // } + // } }, - created() { + mounted() { this.getList(); this.getDeptTree(); }, methods: { + setChecked() { + if (this.checkType !== 'multiple') { + this.radioSelected = this.selectValues + this.$nextTick(() => { + this.$refs.dataTable.clearSelection(); + this.userList.forEach(item => { + console.log("鍗曢�夊�硷細", this.radioSelected) + console.log(parseInt(this.radioSelected) === item.userId) + if (parseInt(this.radioSelected) === item.userId) { + this.$refs.dataTable.toggleRowSelection(item) + } + }) + }); + } else { + this.selectUserList = this.selectValues; + this.$nextTick(() => { + this.$refs.dataTable.clearSelection(); + this.selectUserList.forEach(key => { + this.userList.forEach(item => { + if (parseInt(key) === item.userId) { + this.$refs.dataTable.toggleRowSelection(item) + } + }) + }); + }); + } + + }, /** 鏌ヨ鐢ㄦ埛鍒楄〃 */ getList() { this.loading = true; @@ -229,7 +303,7 @@ }, // 鍗曢�夋閫変腑鏁版嵁 handleSingleUserSelect(selection) { - this.radioSelected = selection.userId;//鐐瑰嚮褰撳墠琛屾椂,radio鍚屾牱鏈夐�変腑鏁堟灉 + // this.radioSelected = selection.userId;//鐐瑰嚮褰撳墠琛屾椂,radio鍚屾牱鏈夐�変腑鏁堟灉 this.$emit('handleUserSelect', selection); }, /** 鎼滅储鎸夐挳鎿嶄綔 */ -- Gitblit v1.8.0