123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <template>
- <div id="buildFloor">
- <span class="buildFloor">建筑楼层</span>
- <el-cascader ref="floorCascader" placeholder="请选择建筑楼层" :options="options" v-model="value" filterable size="small" :style="isWidth ? '' : 'width:160px;'" @change="changeCascader"></el-cascader>
- </div>
- </template>
- <script>
- import tools from "@/utils/scan/tools"
- import { floorQuery, buildingQuery } from '@/api/scan/request'
- import { mapGetters, mapActions } from "vuex"
- export default {
- props: {
- isWidth: {
- type: Boolean,
- default: true
- },
- type: {
- type: String,
- default: "yes"
- }
- },
- computed: {
- ...mapGetters("layout", [
- "projectId",
- "secret",
- "userId"
- ])
- },
- data() {
- return {
- options: [],
- param: {
- ProjId: '',
- secret: ''
- },
- value: ['all']
- };
- },
- created() {
- this.param.ProjId = this.projectId
- this.param.secret = this.secret
- this.getData()
- },
- watch: {
- projectId() {
- this.value = ['all'];
- this.options = [];
- this.param.ProjId = this.projectId
- this.param.secret = this.secret
- this.getData()
- this.changeCascader(['all'])
- }
- },
- methods: {
- //设置默认选项
- setValue(val) {
- if (val && val.length) {
- this.value = val
- }
- },
- //获取数据
- getData() {
- let data, buildParams = {
- PageNumber: 1,
- PageSize: 1000,
- Orders: "BuildLocalName asc",
- Projection: [
- "BuildID",
- "BuildLocalName"
- ]
- }, floorParams = {
- Orders: "FloorSequenceID desc",
- PageNumber: 1,
- PageSize: 1000,
- Projection: [
- "BuildID",
- "FloorID",
- "FloorLocalName",
- "FloorSequenceID",
- "StructureInfo",
- "Outline",
- "Properties"
- ]
- }
- let promise1 = new Promise((resolve, reject) => {
- buildingQuery(buildParams, res => {
- resolve(res)
- })
- })
- let promise2 = new Promise((resolve, reject) => {
- floorQuery(floorParams, res => {
- resolve(res)
- })
- })
- Promise.all([promise1, promise2]).then(values => {
- let builData = values[0].Content, floorData = values[1].Content
- data = builData.map(build => {
- return {
- value: build.BuildID,
- label: build.BuildLocalName
- }
- })
- data.unshift({
- value: "all",
- label: "全部"
- }, {
- value: "noKnow",
- label: "未明确建筑"
- })
- data.forEach(build => {
- floorData.forEach(floor => {
- if (build.value == floor.BuildID && floor.FloorID && floor.FloorLocalName && this.type == "yes") {
- if (build.children) {
- build.children.push({
- value: floor.FloorID,
- label: floor.FloorLocalName,
- FloorSequenceID: floor.FloorSequenceID,
- StructureInfo: floor.StructureInfo || {},
- Outline: floor.Outline || null,
- Properties: floor.Properties || null
- })
- } else {
- build.children = []
- build.children.push({
- value: "all",
- label: "全部"
- },{
- value: 'noKnow',
- label: "未明确楼层"
- },{
- value: floor.FloorID,
- label: floor.FloorLocalName,
- FloorSequenceID: floor.FloorSequenceID,
- StructureInfo: floor.StructureInfo || {},
- Outline: floor.Outline || null,
- Properties: floor.Properties || null
- })
- }
- }
- })
- })
- this.options = data
- })
- },
- //改变item
- changeCascader(value) {
- let node = this.$refs.floorCascader.getCheckedNodes();
- this.$emit("change", value, node[0].data);
- }
- }
- };
- </script>
- <style lang="less">
- .el-cascader .el-input .el-input__inner {
- vertical-align: bottom;
- }
- </style>
- <style lang="less" scoped>
- #buildFloor {
- margin-left: 10px;
- float: left;
- }
- .buildFloor {
- color: #999999;
- font-size: 14px;
- margin-right: 12px;
- }
- </style>
|