| | |
| | | default: 'multiple', |
| | | required: true |
| | | }, |
| | | num: { |
| | | required: true, |
| | | type: Number |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | |
| | | }, |
| | | 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; |
| | |
| | | }, |
| | | // 单选框选中数据 |
| | | handleSingleUserSelect(selection) { |
| | | this.radioSelected = selection.userId;//点击当前行时,radio同样有选中效果 |
| | | // this.radioSelected = selection.userId;//点击当前行时,radio同样有选中效果 |
| | | this.$emit('handleUserSelect', selection); |
| | | }, |
| | | /** 搜索按钮操作 */ |