system.vue 2.3 KB

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