From d3d7dcf919eda40a415b6dc744fb0b347d4293a8 Mon Sep 17 00:00:00 2001 From: zmc <zmc_li@foxmail.com> Date: 星期三, 30 八月 2023 16:10:29 +0800 Subject: [PATCH] 扬尘Vue代码 --- src/sfc/ExceptionType.vue | 57 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 43 insertions(+), 14 deletions(-) diff --git a/src/sfc/ExceptionType.vue b/src/sfc/ExceptionType.vue index 60b42e7..c11f5d4 100644 --- a/src/sfc/ExceptionType.vue +++ b/src/sfc/ExceptionType.vue @@ -16,7 +16,10 @@ // 杩斿洖鐨勬墍鏈夊紓甯哥被鍨� exceptionType:[], //宸插嬀閫夌殑寮傚父 - checkedList: [] + checkedList: [], + // 鍏ㄩ�� + checkAll:false, + isIndeterminate:false, } }, mounted() { @@ -26,9 +29,24 @@ // 鑾峰彇涓嶅悓鐨勫紓甯稿悕绉� getExceptionType(){ this.$http.get('/dust/exceptiontype').then(response=>{ - this.exceptionType = response.data.data + // this.exceptionType = response.data.data + response.data.data.forEach(item => { + this.exceptionType.push(item.exceptionType) + }); + console.log(this.exceptionType); }) - } + }, + handleCheckAllChange (val) { + this.checkedList = val ? this.exceptionType : [] + this.isIndeterminate = false + this.$emit('submitValue',this.checkedList) + }, + handleCheckedExceptionChange (value) { + const checkedCount = value.length + this.checkAll = checkedCount === this.exceptionType.length + this.isIndeterminate = checkedCount > 0 && checkedCount < this.exceptionType.length + this.$emit('submitValue',this.checkedList) +} } } </script> @@ -36,17 +54,24 @@ <template> <div class="excption"> <span class="exception-text">寮傚父绫诲瀷锛�</span> - <el-checkbox-group v-model="checkedList" @change="$emit('submitValue',checkedList)"> - <el-checkbox :label="item.exceptionType" v-for="item in exceptionType" :key="item"> + <el-checkbox + v-model="checkAll" + :indeterminate="isIndeterminate" + @change="handleCheckAllChange" + class="select-text" + >鍏ㄩ��</el-checkbox + > + <el-checkbox-group v-model="checkedList" @change="handleCheckedExceptionChange"> + <el-checkbox :label="item" v-for="item in exceptionType" :key="item"> <template #default> - <span v-if="item.exceptionType == '0'">鏂數鎴栨柇缃�</span> - <span v-else-if="item.exceptionType == '1'">鏁版嵁瓒呬綆</span> - <span v-else-if="item.exceptionType == '2'">瓒呮爣</span> - <span v-else-if="item.exceptionType == '3'">鏁版嵁闀挎椂娈垫棤娉㈠姩</span> - <span v-else-if="item.exceptionType == '4'">閲忕骇绐佸彉寮傚父</span> - <span v-else-if="item.exceptionType == '5'">涓磋繎瓒呮爣寮傚父</span> - <span v-else-if="item.exceptionType == '6'">鍗曟棩瓒呮爣娆℃暟涓寸晫寮傚父</span> - <span v-else-if="item.exceptionType == '7'">婊戝姩骞冲潎鍊肩獊鍙�</span> + <span v-if="item == '0'">鏂數鎴栨柇缃�</span> + <span v-else-if="item == '1'">鏁版嵁瓒呬綆</span> + <span v-else-if="item == '2'">瓒呮爣</span> + <span v-else-if="item == '3'">鏁版嵁闀挎椂娈垫棤娉㈠姩</span> + <span v-else-if="item == '4'">閲忕骇绐佸彉寮傚父</span> + <span v-else-if="item == '5'">涓磋繎瓒呮爣寮傚父</span> + <span v-else-if="item == '6'">鍗曟棩瓒呮爣娆℃暟涓寸晫寮傚父</span> + <span v-else-if="item == '7'">婊戝姩骞冲潎鍊肩獊鍙�</span> </template> </el-checkbox> </el-checkbox-group> @@ -55,7 +80,7 @@ <style lang="scss" scoped> .excption { - display: flex; + display: flex; } .exception-text { font-weight: bold; @@ -65,4 +90,8 @@ .el-checkbox-group { margin-top: 5px; } +.select-text { + margin-top: 5px; + margin-right: 5px; +} </style> \ No newline at end of file -- Gitblit v1.9.3