106 lines
3.0 KiB
Vue
106 lines
3.0 KiB
Vue
<template>
|
||
<div style="width:100%">
|
||
<!-- indeterminate 属性 用以表示checkbox的不确定状态,一般用于实现全选的效果 只负责样式的控制 -->
|
||
<!-- <el-checkbox
|
||
:indeterminate="isIndeterminate"
|
||
v-model="checkAll"
|
||
@change="checkAllChange"
|
||
>全选</el-checkbox
|
||
> -->
|
||
<!-- <el-checkbox-group v-model="checkCity" @change="getCheckAll">
|
||
<el-checkbox
|
||
v-for="item in optionItems"
|
||
:key="item.regionCode"
|
||
:label="item.regionName"
|
||
></el-checkbox>
|
||
</el-checkbox-group> -->
|
||
|
||
<!-- <el-tag v-for="item in optionItems" :key="item.regionCode">{{ item.regionName }}</el-tag> -->
|
||
|
||
<!-- <el-tag type="success" v-for="item in optionItems" :key="item.regionCode">{{ item.regionName }}</el-tag> -->
|
||
<span v-for="item in optionItems" :key="item.regionCode"> {{ item.regionName }},</span>
|
||
</div>
|
||
</template>
|
||
<script>
|
||
import { listSimpleEmisRegion } from "@/api/emis/emisRegion";
|
||
export default {
|
||
name: "CountryAreaRegionPanel",
|
||
props: {
|
||
value: {
|
||
type: [String,Number,Array],
|
||
required: false
|
||
},
|
||
areaId: {
|
||
type: [String,Number,Array],
|
||
required: false
|
||
},
|
||
size: {
|
||
type: String,
|
||
required: false
|
||
},
|
||
},
|
||
data() {
|
||
return {
|
||
checked: true,
|
||
checkList:[],
|
||
checkAll: false,
|
||
isIndeterminate: true,
|
||
// checkCity: ["a", "c"],
|
||
optionItems: [],
|
||
svalue: this.value,
|
||
};
|
||
},
|
||
watch: {
|
||
value(newVal) {
|
||
this.svalue = newVal;
|
||
},
|
||
svalue(newVal, oldVal) {
|
||
if (newVal !== oldVal) {
|
||
this.$emit("input", this.svalue);
|
||
}
|
||
},
|
||
areaId(newVal) {
|
||
this.initData();
|
||
}
|
||
},
|
||
created() {
|
||
this.initData();
|
||
},
|
||
methods: {
|
||
onChange() {
|
||
// this.$emit("input", this.svalue);
|
||
// this.$emit("onChange",itemData);
|
||
},
|
||
|
||
initData() {
|
||
if(this.areaId==null ||this.areaId==''){
|
||
return;
|
||
}
|
||
let queryParams = {areaId:this.areaId,regionType:1,status:1};
|
||
listSimpleEmisRegion(queryParams).then(response => {
|
||
this.optionItems = response.rows;
|
||
});
|
||
},
|
||
getCheck() {
|
||
console.log("checkList", this.checkList);
|
||
},
|
||
checkAllChange(value) {
|
||
// console.log("quanxuan", value);
|
||
this.checkCity = value ? this.cityOption : [];
|
||
// 点击全选的时候,控制的样式只有 不选和全选√ 所以isIndeterminate控制的样式不出现
|
||
this.isIndeterminate = false;
|
||
},
|
||
getCheckAll(value) {
|
||
// console.log("选择", value, this.checkCity.length);
|
||
let checkedCount = value.length;
|
||
this.checkAll = checkedCount === this.checkCity.length;
|
||
// 当选择的选项大于0小于所有的数据的时候 isIndeterminate控制的样式出现
|
||
this.isIndeterminate =
|
||
checkedCount > 0 && checkedCount < this.cityOption.length;
|
||
},
|
||
|
||
|
||
}
|
||
};
|
||
</script>
|