123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <template>
- <div id="spaceSelect">
- <span class="buildFloor" style="padding-right:12px">空间类型</span>
- <el-cascader
- v-model="value"
- placeholder="请选择空间类型"
- clearable
- :style="isWidth ? '' : 'width:160px;'" size="small"
- :props="{value:'code',label:'name',children:'ZoneType'}"
- :options="options"
- @change="changeVal">
- </el-cascader>
- </div>
- </template>
- <script>
- import { queryAllZoneType } from '@/api/scan/request';
- import { mapGetters } from 'vuex'
- export default {
- computed: {
- ...mapGetters("layout", ["projectId"])
- },
- props: {
- isWidth: {
- type: Boolean,
- default: true
- },
- isAll: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- value:[null],
- options: [],
- props: {
- isWidth:false
- }
- }
- },
- methods: {
- setValue(val) {
- this.value = val;
- this.changeVal(val);
- },
- //获取下拉框数据
- getOptionData() {
- let params1 = {}
- //Cascade: [{ Name: 'zoneType', Filters: `ProjectId='${this.projectId}'` }]
- queryAllZoneType(params1, res => {
- this.options = res.content;
- if (this.isAll) {
- this.options.unshift({
- code: "",
- name: "全部"
- });
- this.value = [''];
- }
- this.changeVal(this.value);
- })
- },
- //改变空间
- changeVal(value) {
- let val = value[value.length - 1];
- let space = {};
- this.options.forEach(item => {
- // if (item.ZoneType) {
- // zoneType级联其他分区, 新版已删除
- // item.ZoneType.forEach(other => {
- // if (other.code == val) {
- // space = other
- // }
- // })
- // } else {
- if (item.code == val) {
- space = item
- }
- // }
- })
- this.$emit('change', val, space, value)
- }
- },
- created() {
- this.getOptionData();
- }
- }
- </script>
- <style lang="less" scoped>
- #spaceSelect {
- float: left;
- margin-left: 10px;
- .buildFloor {
- color: #999999;
- font-size: 14px;
- }
- }
- </style>
|