assets.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <div id="cascaderMap">
  3. <span class="buildFloor">设备族:</span>
  4. <el-cascader
  5. placeholder="请选择"
  6. :options="options"
  7. v-model="value"
  8. :props="props"
  9. filterable
  10. :style="isWidth ? '' : 'width:160px;'"
  11. size="small"
  12. @change="changeVal"
  13. change-on-select
  14. ></el-cascader>
  15. </div>
  16. </template>
  17. <script>
  18. import { getEquipmentFamily } from "@/api/scan/request";
  19. export default {
  20. name: "getCode",
  21. props: {
  22. isWidth: {
  23. type: Boolean,
  24. default: true
  25. }
  26. },
  27. data() {
  28. return {
  29. value: [],
  30. options: [],
  31. props: {
  32. value: "code",
  33. label: "facility"
  34. },
  35. falg: true,
  36. content: []
  37. };
  38. },
  39. created() {
  40. this.getData();
  41. },
  42. mounted() { },
  43. methods: {
  44. setValue(val) {
  45. this.value = val
  46. },
  47. //修改val
  48. changeVal(val) {
  49. let value = {}
  50. this.options.map(item => {
  51. if (item.code == val) {
  52. value = item
  53. }
  54. })
  55. this.value = val
  56. this.$emit("change", value)
  57. },
  58. async getData() {
  59. let _this = this
  60. await getEquipmentFamily(res => {
  61. _this.options = _this.changeArr(res.Content)
  62. if (!!this.value && this.value.length) {
  63. let value = {}
  64. this.options.map(item => {
  65. if (item.code == this.value[0]) {
  66. value = item
  67. }
  68. })
  69. this.$emit("change", value)
  70. }
  71. if (!_this.falg) {
  72. _this.changeList()
  73. }
  74. })
  75. },
  76. changeArr(arr) {
  77. let data = [];
  78. arr.map(item => {
  79. data.push({ code: item.code, facility: item.name, disabled: false })
  80. });
  81. return data;
  82. },
  83. pushData(content) {
  84. this.content = content
  85. if (this.options.length) {
  86. this.falg = true
  87. this.changeList()
  88. } else {
  89. this.falg = false
  90. }
  91. },
  92. changeList() {
  93. this.options.map(item => {
  94. item.disabled = true
  95. this.content.map(child => {
  96. if (item.code == child) {
  97. item.disabled = false
  98. }
  99. })
  100. })
  101. }
  102. }
  103. };
  104. </script>
  105. <style lang="less" scoped>
  106. #cascaderMap {
  107. float: left;
  108. margin-left: 10px;
  109. .buildFloor {
  110. color: #999999;
  111. font-size: 14px;
  112. }
  113. }
  114. </style>