modelCascader.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <div id="cascaderMap">
  3. <span class="buildFloor" style="margin-right: 12px;">设备类别</span>
  4. <el-select v-model="value" placeholder="请选择" clearable filterable :style="isWidth ? '' : 'width:160px;'" size="small" @change="changeVal">
  5. <el-option v-for="item in options" :key="item.Code" :label="item.Name" :value="item.Code"></el-option>
  6. </el-select>
  7. </div>
  8. </template>
  9. <script>
  10. import { mapGetters } from 'vuex';
  11. import { queryModelCategory } from "@/api/data_admin/buildTaskApi"
  12. export default {
  13. props: {
  14. isWidth: {
  15. type: Boolean,
  16. default: true
  17. }
  18. },
  19. computed: {
  20. ...mapGetters("layout", ["projectId"])
  21. },
  22. data() {
  23. return {
  24. value: "",
  25. options: []
  26. };
  27. },
  28. created() {
  29. this.getData();
  30. },
  31. watch: {
  32. projectId() {
  33. this.value = '';
  34. this.getData();
  35. }
  36. },
  37. methods: {
  38. setValue(val) {
  39. this.value = val
  40. },
  41. //修改val
  42. changeVal(val) {
  43. let value = {}
  44. this.options.map(item => {
  45. if (item.Code == val) {
  46. value = item
  47. }
  48. })
  49. this.value = val
  50. this.$emit("change", value)
  51. },
  52. //获取当前项目下的模型任务-设备类型
  53. getData() {
  54. queryModelCategory('', res => {
  55. this.options = res.Content
  56. })
  57. }
  58. }
  59. };
  60. </script>
  61. <style lang="less" scoped>
  62. #cascaderMap {
  63. float: left;
  64. margin-left: 10px;
  65. .buildFloor {
  66. color: #999999;
  67. font-size: 14px;
  68. }
  69. }
  70. </style>