spaceSelect.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <div id="spaceSelect">
  3. <span class="buildFloor" style="padding-right:12px">空间类型</span>
  4. <el-cascader
  5. v-model="value"
  6. placeholder="请选择空间类型"
  7. clearable
  8. :style="isWidth ? '' : 'width:160px;'" size="small"
  9. :props="{value:'Code',label:'Name',children:'ZoneType'}"
  10. :options="options"
  11. @change="changeVal">
  12. </el-cascader>
  13. </div>
  14. </template>
  15. <script>
  16. import { queryDictionaryHead, queryAllZoneType } from '@/api/scan/request';
  17. import { mapGetters } from 'vuex'
  18. export default {
  19. computed: {
  20. ...mapGetters("layout", ["projectId"])
  21. },
  22. props: {
  23. isWidth: {
  24. type: Boolean,
  25. default: true
  26. }
  27. },
  28. data() {
  29. return {
  30. value:[null],
  31. spaceVal: null,//值
  32. options: [],
  33. props: {
  34. isWidth:false
  35. }
  36. }
  37. },
  38. methods: {
  39. //获取下拉框数据
  40. getOptionData() {
  41. let params1 = {Cascade: [{ Name: 'zoneType', Filters: `ProjectId='${this.projectId}'` }]}
  42. queryAllZoneType(params1, res => {
  43. this.options = res.Content;
  44. })
  45. },
  46. //改变空间
  47. changeVal(value) {
  48. let val = value[value.length - 1];
  49. let space = {};
  50. this.options.forEach(item => {
  51. if (item.ZoneType) {
  52. item.ZoneType.forEach(other => {
  53. if (other.Code == val) {
  54. space = other
  55. }
  56. })
  57. } else {
  58. if (item.Code == val) {
  59. space = item
  60. }
  61. }
  62. })
  63. this.$emit('change', val, space)
  64. }
  65. },
  66. created() {
  67. this.getOptionData();
  68. }
  69. }
  70. </script>
  71. <style lang="less" scoped>
  72. #spaceSelect {
  73. float: left;
  74. margin-left: 10px;
  75. .buildFloor {
  76. color: #999999;
  77. font-size: 14px;
  78. }
  79. }
  80. </style>