assets.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <div id="cascaderMap">
  3. <span class="buildFloor" style="padding-right: 12px;">设备族</span>
  4. <el-select v-model="value" placeholder="请选择" clearable :props="props" filterable :style="isWidth ? '' : 'width:160px;'" size="small" @change="changeVal">
  5. <el-option v-for="item in options" :key="item.code" :label="item.facility" :value="item.code"></el-option>
  6. </el-select>
  7. <!-- <el-cascader
  8. placeholder="请选择"
  9. :options="options"
  10. v-model="value"
  11. :props="props"
  12. filterable
  13. :style="isWidth ? '' : 'width:160px;'"
  14. size="small"
  15. @change="changeVal"
  16. change-on-select
  17. ></el-cascader> -->
  18. </div>
  19. </template>
  20. <script>
  21. import {mapGetters} from 'vuex';
  22. import { getEquipBelongs, queryProperty } from "@/api/scan/request";
  23. export default {
  24. name: "getCode",
  25. props: {
  26. isWidth: {
  27. type: Boolean,
  28. default: true
  29. },
  30. all: {
  31. type: Boolean,
  32. default: false,
  33. }
  34. },
  35. computed: {
  36. ...mapGetters("layout", [
  37. "projectId",
  38. ])
  39. },
  40. data() {
  41. return {
  42. value: [],
  43. options: [],
  44. props: {
  45. value: "code",
  46. label: "facility"
  47. },
  48. falg: true,
  49. content: []
  50. };
  51. },
  52. created() {
  53. this.getData();
  54. },
  55. watch: {
  56. projectId() {
  57. this.value = ['']
  58. }
  59. },
  60. methods: {
  61. setValue(val) {
  62. this.value = val
  63. },
  64. //修改val
  65. changeVal(val) {
  66. let value = {}
  67. this.options.map(item => {
  68. if (item.code == val) {
  69. value = item
  70. }
  71. })
  72. this.value = val
  73. this.$emit("change", value)
  74. },
  75. getData() {
  76. let param1 = {
  77. data:{
  78. Distinct: true,
  79. PageNumber: 1,
  80. PageSize: 500,
  81. Projection:["Family","FamilyName"]
  82. }
  83. }, param2 = {
  84. Distinct: true,
  85. PageNumber: 1,
  86. PageSize: 500,
  87. Projection: [
  88. "Family"
  89. ]
  90. }
  91. let promise1 = new Promise((resolve, reject) => {
  92. getEquipBelongs(param1, res => {
  93. resolve(res)
  94. })
  95. })
  96. let promise2 = new Promise((resolve, reject) => {
  97. queryProperty(param2, res => {
  98. resolve(res)
  99. })
  100. })
  101. Promise.all([promise1,promise2]).then((res) => {
  102. let allData = res[0], data = res[1]
  103. this.options = this.changeArr(allData.Content)
  104. if (this.value) {
  105. this.changeVal(this.value)
  106. }
  107. if(!this.all) {
  108. this.content = data.Content.map(item => {
  109. return item.Family
  110. });
  111. this.changeList();
  112. if (this.value) {
  113. this.changeVal(this.value)
  114. }
  115. }
  116. })
  117. // getEquipBelongs(params, res => {
  118. // this.options = this.changeArr(res.Content)
  119. // if (!!this.value && this.value.length) {
  120. // let value = {}
  121. // this.options.map(item => {
  122. // if (item.code == this.value[0]) {
  123. // value = item
  124. // }
  125. // })
  126. // this.$emit("change", value)
  127. // }
  128. // if (!this.falg) {
  129. // this.changeList()
  130. // }
  131. // })
  132. },
  133. changeArr(arr) {
  134. let data = [];
  135. arr.map(item => {
  136. data.push({ code: item.Family, facility: item.FamilyName, disabled: false })
  137. });
  138. return data;
  139. },
  140. pushData(content) {
  141. this.content = content
  142. if (this.options.length) {
  143. this.falg = true
  144. this.changeList()
  145. } else {
  146. this.falg = false
  147. }
  148. },
  149. changeList() {
  150. this.options = this.options.filter(item => {
  151. if (this.content.indexOf(item.code) > -1) {
  152. return item
  153. }
  154. })
  155. }
  156. }
  157. };
  158. </script>
  159. <style lang="less" scoped>
  160. #cascaderMap {
  161. float: left;
  162. margin-left: 10px;
  163. .buildFloor {
  164. color: #999999;
  165. font-size: 14px;
  166. }
  167. }
  168. </style>