|
|
|
|
@ -28,6 +28,8 @@
|
|
|
|
|
:column-config="{ resizable: true }"
|
|
|
|
|
:checkbox-config="{ trigger: 'row', highlight: true, reserve: true }"
|
|
|
|
|
:data="tableData"
|
|
|
|
|
@checkbox-change="checkboxChange"
|
|
|
|
|
@checkbox-all="checkAll"
|
|
|
|
|
>
|
|
|
|
|
<vxe-column type="checkbox" width="60" fixed="left" />
|
|
|
|
|
<vxe-column type="seq" width="58" align="center" />
|
|
|
|
|
@ -104,9 +106,12 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
computed: {},
|
|
|
|
|
watch: {
|
|
|
|
|
'form.user_ids': function(val, oldVal) {
|
|
|
|
|
'form.user_ids': {
|
|
|
|
|
handler() {
|
|
|
|
|
this.setSelectRow()
|
|
|
|
|
},
|
|
|
|
|
deep: true
|
|
|
|
|
},
|
|
|
|
|
isShow(newVal) {
|
|
|
|
|
if (newVal) {
|
|
|
|
|
this.zIndex = PopupManager.nextZIndex()
|
|
|
|
|
@ -140,6 +145,31 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
checkboxChange({ checked, row }) {
|
|
|
|
|
if (!checked) {
|
|
|
|
|
const index = this.form.user_ids.indexOf(row.id)
|
|
|
|
|
if (index !== -1) {
|
|
|
|
|
this.form.user_ids.splice(index, 1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.setFormUserIds()
|
|
|
|
|
},
|
|
|
|
|
checkAll({ checked }) {
|
|
|
|
|
if (!checked) {
|
|
|
|
|
const ids = this.tableData.map(i => i.id)
|
|
|
|
|
ids.forEach(id => {
|
|
|
|
|
const index = this.form.user_ids.indexOf(id)
|
|
|
|
|
if (index !== -1) {
|
|
|
|
|
this.form.user_ids.splice(index, 1)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
this.setFormUserIds()
|
|
|
|
|
},
|
|
|
|
|
setFormUserIds() {
|
|
|
|
|
const selectRecords = this.$refs['table'].getCheckboxRecords()
|
|
|
|
|
this.form.user_ids = Array.from(new Set([...selectRecords.map(row => row.id), ...this.form.user_ids])).filter(i => !!i)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async getUsers() {
|
|
|
|
|
this.tableLoading = true
|
|
|
|
|
@ -148,6 +178,7 @@ export default {
|
|
|
|
|
this.tableData = res.data
|
|
|
|
|
this.total = res.total
|
|
|
|
|
this.tableLoading = false
|
|
|
|
|
this.setSelectRow()
|
|
|
|
|
} catch (err) {
|
|
|
|
|
this.tableLoading = false
|
|
|
|
|
}
|
|
|
|
|
@ -169,12 +200,11 @@ export default {
|
|
|
|
|
async submit() {
|
|
|
|
|
if (this.$refs['table']) {
|
|
|
|
|
this.loading = true
|
|
|
|
|
const selectRecords = this.$refs['table'].getCheckboxRecords()
|
|
|
|
|
try {
|
|
|
|
|
batchRoles({
|
|
|
|
|
...this.form,
|
|
|
|
|
module_id: this.moduleId,
|
|
|
|
|
user_ids: Array.from(new Set([...selectRecords.map(row => row.id), ...this.form.user_ids])).filter(i => !!i)
|
|
|
|
|
user_ids: this.form.user_ids
|
|
|
|
|
})
|
|
|
|
|
// 接口中角色信息有延迟
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|