123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <template>
- <div id="cascaderMap">
- <span class="buildFloor">设备族:</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 { getEquipmentFamily } from "@/api/scan/request";
- export default {
- name: "getCode",
- props: {
- isWidth: {
- type: Boolean,
- default: true
- }
- },
- data() {
- return {
- value: [],
- options: [],
- props: {
- value: "code",
- label: "facility"
- },
- falg: true,
- content: []
- };
- },
- created() {
- this.getData();
- },
- mounted() { },
- methods: {
- setValue(val) {
- 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)
- },
- async getData() {
- let _this = this
- await getEquipmentFamily(res => {
- _this.options = _this.changeArr(res.Content)
- if (!!this.value && this.value.length) {
- let value = {}
- this.options.map(item => {
- if (item.code == this.value[0]) {
- value = item
- }
- })
- this.$emit("change", value)
- }
- if (!_this.falg) {
- _this.changeList()
- }
- })
- },
- changeArr(arr) {
- let data = [];
- arr.map(item => {
- data.push({ code: item.code, facility: item.name, disabled: false })
- });
- return data;
- },
- pushData(content) {
- this.content = content
- if (this.options.length) {
- this.falg = true
- this.changeList()
- } else {
- this.falg = false
- }
- },
- changeList() {
- this.options.map(item => {
- item.disabled = true
- this.content.map(child => {
- if (item.code == child) {
- item.disabled = false
- }
- })
- })
- }
- }
- };
- </script>
- <style lang="less" scoped>
- #cascaderMap {
- float: left;
- margin-left: 10px;
- .buildFloor {
- color: #999999;
- font-size: 14px;
- }
- }
- </style>
|