123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <template>
- <div id="cascaderMap">
- <span class="buildFloor" style="margin-right: 12px;">设备类</span>
- <el-cascader placeholder="请选择" :options="options" v-model="value" :props="props" filterable :style="isWidth ? '' : 'width:160px;'" size="small"
- @change="changeVal" change-on-select></el-cascader>
- </div>
- </template>
- <script>
- import { mapGetters } from 'vuex';
- import { getEqCode, getEquipBelongs, queryPartsDie } from "@/api/scan/request";
- export default {
- name: "getCode",
- props: {
- isWidth: {
- type: Boolean,
- default: true
- },
- Family: {
- type: String,
- default: '',
- }
- },
- computed: {
- ...mapGetters("layout", ["projectId"])
- },
- data() {
- return {
- value: [""],
- options: [],
- props: {
- value: "code",
- label: "facility"
- },
- falg: true,
- content: []
- };
- },
- mounted() {
- if(this.Family != "") {
- this.getAllData()
- }
- },
- watch: {
- projectId() {
- this.value = [''];
- this.getAllData()
- }
- // Family: {
- // handler: function (val) {
- // if(val != "") {
- // this.getAllData()
- // }
- // },
- // immediate: true
- // }
- },
- methods: {
- setValue(val) {
- if (val && val.length) {
- this.value = val
- }
- },
- //修改val
- changeVal(val) {
- let value = {}
- this.options.map(item => {
- if (item.code == val) {
- value = item
- }
- })
- this.value = val
- this.$emit("change", value)
- },
- //获取当前项目下的设备类型(只拿到编码-需要过滤)
- getData() {
- let param = {
- Distinct: true,
- PageNumber: 1,
- PageSize: 500,
- Projection: [
- "Category"
- ]
- }
- queryPartsDie(param, res => {
- this.content = res.Content
- this.filterForOptions()
- let val = this.options.length?[this.options[0].code]:[""]
- this.changeVal(val)
- })
- },
- //获取物理世界所有设备类型
- getAllData() {
- let param = {
- data: {
- Filters: `Family='${this.Family}'`,
- Distinct: true,
- Orders: "EquipName asc",
- PageNumber: 1,
- PageSize: 500,
- Projection: [
- "EquipCode", "EquipName"
- ]
- }
- }
- getEquipBelongs(param, res => {
- this.options = this.formatOptions(res.Content)
- this.getData()
- })
- },
- //格式化options数据
- formatOptions(arr) {
- let data = [];
- arr.map(t => {
- let temp = {};
- temp.code = t.EquipCode;
- temp.facility = t.EquipName;
- data.push(temp)
- })
- return data;
- },
- //过滤
- filterForOptions() {
- this.options = this.options.filter(item => {
- if (this.content.find(value => value.Category == item.code)) {
- return item
- }
- })
- }
- }
- };
- </script>
- <style lang="less" scoped>
- #cascaderMap {
- float: left;
- margin-left: 10px;
- .buildFloor {
- color: #999999;
- font-size: 14px;
- }
- }
- </style>
|