partsDieList.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <div id="cascaderMap">
  3. <span class="buildFloor" style="margin-right: 12px;">设备类</span>
  4. <el-cascader placeholder="请选择" :options="options" v-model="value" :props="props" filterable :style="isWidth ? '' : 'width:160px;'" size="small"
  5. @change="changeVal" change-on-select></el-cascader>
  6. </div>
  7. </template>
  8. <script>
  9. import { mapGetters } from 'vuex';
  10. import { getEqCode, getEquipBelongs, queryPartsDie } from "@/api/scan/request";
  11. export default {
  12. name: "getCode",
  13. props: {
  14. isWidth: {
  15. type: Boolean,
  16. default: true
  17. },
  18. Family: {
  19. type: String,
  20. default: '',
  21. }
  22. },
  23. computed: {
  24. ...mapGetters("layout", ["projectId"])
  25. },
  26. data() {
  27. return {
  28. value: [""],
  29. options: [],
  30. props: {
  31. value: "code",
  32. label: "facility"
  33. },
  34. falg: true,
  35. content: []
  36. };
  37. },
  38. created() { },
  39. watch: {
  40. projectId() {
  41. this.value = [''];
  42. this.getAllData()
  43. },
  44. Family(val) {
  45. if(val != "") {
  46. this.getAllData();
  47. }
  48. }
  49. },
  50. methods: {
  51. setValue(val) {
  52. this.value = val
  53. },
  54. //修改val
  55. changeVal(val) {
  56. let value = {}
  57. this.options.map(item => {
  58. if (item.code == val) {
  59. value = item
  60. }
  61. })
  62. this.value = val
  63. this.$emit("change", value)
  64. },
  65. //获取当前项目下的设备类型(只拿到编码-需要过滤)
  66. getData() {
  67. let param = {
  68. Distinct: true,
  69. PageNumber: 1,
  70. PageSize: 500,
  71. Projection: [
  72. "Category"
  73. ]
  74. }
  75. queryPartsDie(param, res => {
  76. this.content = res.Content
  77. this.filterForOptions()
  78. let val = this.options.length?[this.options[0].code]:[""]
  79. this.changeVal(val)
  80. })
  81. },
  82. //获取物理世界所有设备类型
  83. getAllData() {
  84. let param = {
  85. data: {
  86. Filters: `Family='${this.Family}'`,
  87. Distinct: true,
  88. Orders: "EquipName asc",
  89. PageNumber: 1,
  90. PageSize: 500,
  91. Projection: [
  92. "EquipCode", "EquipName"
  93. ]
  94. }
  95. }
  96. getEquipBelongs(param, res => {
  97. this.options = this.formatOptions(res.Content)
  98. this.getData()
  99. })
  100. },
  101. //格式化options数据
  102. formatOptions(arr) {
  103. let data = [];
  104. arr.map(t => {
  105. let temp = {};
  106. temp.code = t.EquipCode;
  107. temp.facility = t.EquipName;
  108. data.push(temp)
  109. })
  110. return data;
  111. },
  112. //过滤
  113. filterForOptions() {
  114. this.options = this.options.filter(item => {
  115. if (this.content.find(value => value.Category == item.code)) {
  116. return item
  117. }
  118. })
  119. }
  120. }
  121. };
  122. </script>
  123. <style lang="less" scoped>
  124. #cascaderMap {
  125. float: left;
  126. margin-left: 10px;
  127. .buildFloor {
  128. color: #999999;
  129. font-size: 14px;
  130. }
  131. }
  132. </style>