| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <template>
- <el-cascader v-model="value" :options="options" :props="props" clearable ref="elCascader" @remove-tag="removeTag"></el-cascader>
- </template>
- <script>
- // import { buildingQuery } from "@/api/scan/request";
- import { buildingQuery } from '@/api/object/build';
- export default {
- data() {
- return {
- value: [],
- props: {
- multiple: true,
- checkStrictly: true,
- value: 'id',
- label: 'localName',
- children: 'floor'
- },
- options: []
- }
- },
- props: {
- SysID: {
- default: ''
- }
- },
- methods: {
- getCascader() {
- let param = {
- cascade: [
- { name: "floor", orders: "floorSequenceID desc" }
- ],
- orders: "localName asc",
- pageNumber: 1,
- pageSize: 50
- }
- buildingQuery(param, res => {
- res.content.map(t => {
- if (t.floor && t.floor.length) {
- t.floor = t.floor.map(item => {
- if (item.id == this.FloorID) return
- item.BuildID = item.id
- item.BuildLocalName = item.localName || item.name
- return item
- }).filter(it => it)
- }
- })
- this.options = res.content
- })
- },
- getSelectedNodes() {
- let nodes = this.$refs.elCascader.getCheckedNodes();
- let arr = [], flag = false, brr = [];
- if (nodes.length) {
- nodes.map(t => {
- let obj = {
- BuildName: t.pathLabels[0],
- BuildID: t.path[0]
- }
- if (t.path.length > 1) {
- obj.FloorName = t.pathLabels[1]
- obj.FloorID = t.path[1]
- } else {
- flag = true;
- }
- arr.push(obj);
- })
- if (flag) {
- for (let i = 0; i < arr.length; i++) {
- for (let j = 0; j < arr.length; j++) {
- if (!arr[i].FloorID && arr[j].FloorID && arr[i].BuildID == arr[j].BuildID) {
- brr.push(i)
- }
- }
- }
- arr = arr.map((t, i) => {
- if (brr.indexOf(i) > -1) {
- return undefined;
- }
- return t;
- }).filter(item => item);
- }
- }
- return arr;
- },
- removeTag(){
- console.log(arguments)
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .el-cascader {
- width: 100%;
- }
- </style>
|