system.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <div id="cascaderMap">
  3. <span class="buildFloor" style="padding-right: 12px;">所属专业系统类型</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 { getEqCode } 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.$emit("change", value)
  56. },
  57. getData() {
  58. getEqCode().then(res => {
  59. console.log(res.data)
  60. this.options = this.changeArr(res.data.Content);
  61. if (!!this.value && this.value.length) {
  62. let value = {}
  63. this.options.map(item => {
  64. if (item.code == this.value[0]) {
  65. value = item
  66. }
  67. })
  68. this.$emit("change", value)
  69. }
  70. if (!this.falg) {
  71. this.changeList()
  72. }
  73. });
  74. },
  75. changeArr(arr) {
  76. let data = [];
  77. arr.map(item => {
  78. if (item.content && item.content.length) {
  79. return item.content.map(children => {
  80. data.push({ code: children.code, facility: children.system });
  81. });
  82. }
  83. });
  84. return data;
  85. },
  86. //上级页面传入content
  87. pushData(content) {
  88. this.content = content
  89. if (this.options.length) {
  90. this.falg = true
  91. this.changeList()
  92. } else {
  93. this.falg = false
  94. }
  95. },
  96. //修改list
  97. changeList() {
  98. this.options.map(item => {
  99. item.disabled = true
  100. this.content.map(child => {
  101. if (item.code == child) {
  102. item.disabled = false
  103. }
  104. })
  105. })
  106. }
  107. }
  108. };
  109. </script>
  110. <style lang="less" scoped>
  111. #cascaderMap {
  112. float: left;
  113. margin-left: 10px;
  114. .buildFloor {
  115. color: #999999;
  116. font-size: 14px;
  117. }
  118. }
  119. </style>