elementUI 全选 多选

	<el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
		<el-checkbox-group v-model="checkList">
	<el-checkbox v-for="(item,index) in AllDepartment" @change="handleCheckedDepartmentChange(item.enterpriseDepartmentId,index)" :label="item.enterpriseDepartmentId" :key="index">{{item.enterpriseDepartmentName}}</el-checkbox>
</el-checkbox-group>
data() {
			return {
				bmName: '',
				dialogTableVisible: false,
				dialogFormVisible: false,
				checkAll: false,
				checkList: [], //多选部门
				AllDepartment: '',
				isIndeterminate: true,
				enterpriseId: '55648c7fdc344351ab567f8e289dcf15',
			}
		},
			//全选
		handleCheckAllChange(val) {

				if(this.checkAll) {
					this.AllDepartment.forEach(item => {
						this.checkList.push(item.enterpriseDepartmentId)
						console.log("全选")
						console.log(this.checkList)

					})
			} else {
					this.checkList = []
				}

		},
			//多选
			handleCheckedDepartmentChange(val, index) {
		
				if(this.checkList.length == this.AllDepartment.length) {
					this.checkAll = true;
					this.del();
				} else {
					this.checkAll = false
				}

			},

你可能感兴趣的:(elementUI 全选 多选)