This commit is contained in:
yangduo 2024-09-23 11:12:26 +08:00
parent 3dfeadd2f5
commit c3881eb2a1

View File

@ -99,6 +99,13 @@
<el-input v-model="form.remark" :readonly="true" />
</el-form-item>
<el-form-item label="服务器列表" prop="serverList">
<el-checkbox
v-model="checkAll"
:indeterminate="isInterminate"
@change="CheckAllChange"
>
全选
</el-checkbox>
<template>
<el-checkbox-group v-model="form.serverList" @change="handleCheckServersChange">
<el-checkbox v-for="server in servers" :key="server.key" :label="server.key">{{ server.label }}</el-checkbox>
@ -174,6 +181,8 @@ export default {
audit_is_open: 0,
serverList: []
},
isInterminate: false,
checkAll: false,
dialogFormVisible: false,
dialogStatus: '',
listLoading: true,
@ -208,6 +217,9 @@ export default {
this.dialogStatus = 'update'
this.dialogTitle = '编辑'
this.dialogFormVisible = true
const checkedcount = this.form.serverList.length
this.checkAll = this.servers.length === checkedcount
this.isInterminate = checkedcount > 0 && checkedcount < this.servers.length
this.$nextTick(() => {
this.$refs['form'].clearValidate()
})
@ -316,8 +328,19 @@ export default {
}
})
},
handleCheckServersChange() {
return
handleCheckServersChange(value) {
const checkedCount = value.length
this.checkAll = checkedCount > 0 && checkedCount === this.form.serverList.length
this.isInterminate = checkedCount > 0 && checkedCount < this.servers.length
},
CheckAllChange(value) {
this.form.serverList = []
if (value) {
this.servers.forEach((item, index) => {
this.form.serverList.push(item.key)
})
}
this.isInterminate = false
}
}
}