system.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div id="cascaderMap">
  3. <span class="buildFloor" style="padding-right: 12px;">所属专业系统类型</span>
  4. <el-select v-model="value" placeholder="请选择" :props="props" filterable :style="isWidth ? '' : 'width:160px;'" size="small" @change="changeVal">
  5. <el-option v-for="item in options" :key="item.Category" :label="item.CategoryName" :value="item.Category"></el-option>
  6. </el-select>
  7. <!-- <el-cascader placeholder="请选择" :options="options" v-model="value" :props="props" filterable :style="isWidth ? '' : 'width:160px;'" size="small"
  8. @change="changeVal" change-on-select></el-cascader> -->
  9. </div>
  10. </template>
  11. <script>
  12. import { mapGetters } from 'vuex';
  13. import { queryLinkSys, getEqCode } from "@/api/scan/request";
  14. export default {
  15. name: "getCode",
  16. props: {
  17. isWidth: {
  18. type: Boolean,
  19. default: true
  20. },
  21. all: {
  22. default: false
  23. }
  24. },
  25. computed: {
  26. ...mapGetters("layout", ["projectId"])
  27. },
  28. data() {
  29. return {
  30. value: [],
  31. options: [],
  32. props: {
  33. value: "Category",
  34. label: "CategoryName"
  35. }
  36. };
  37. },
  38. created() {
  39. this.init()
  40. },
  41. watch: {
  42. projectId() {
  43. this.value = ''
  44. this.init()
  45. }
  46. },
  47. methods: {
  48. init() {
  49. if (this.all) {
  50. //物理世界所有系统
  51. this.getAllData();
  52. } else {
  53. //当前项目下已有的系统
  54. this.getData();
  55. }
  56. },
  57. setValue(val) {
  58. this.value = val
  59. },
  60. //修改val
  61. changeVal(val) {
  62. let value = {}
  63. this.options.map(item => {
  64. if (item.Category == val) {
  65. value = item
  66. }
  67. })
  68. this.value = val
  69. this.$emit("change", value)
  70. },
  71. getData() {
  72. let param = {
  73. Distinct: true,
  74. PageNumber: 1,
  75. PageSize: 500,
  76. Projection: [
  77. "Category", "CategoryName"
  78. ]
  79. }
  80. queryLinkSys(param, res => {
  81. this.options = res.Content;
  82. if (this.value) {
  83. this.changeVal(this.value)
  84. }
  85. })
  86. },
  87. getAllData() {
  88. getEqCode().then(res => {
  89. this.options = this.changeArr(res.data.Content)
  90. if (this.value) {
  91. this.changeVal(this.value)
  92. }
  93. })
  94. },
  95. changeArr(arr) {
  96. let data = [];
  97. arr.map(item => {
  98. if (item.content && item.content.length) {
  99. return item.content.map(children => {
  100. data.push({ Category: children.code, CategoryName: children.system });
  101. });
  102. }
  103. });
  104. return data;
  105. }
  106. }
  107. };
  108. </script>
  109. <style lang="less" scoped>
  110. #cascaderMap {
  111. float: left;
  112. margin-left: 10px;
  113. .buildFloor {
  114. color: #999999;
  115. font-size: 14px;
  116. }
  117. }
  118. </style>