餐饮油烟智能监测与监管一体化平台
riku
2026-03-18 8e8d00477b1f30183d0d09cd7ec744067595dc46
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<template>
  <el-form-item :label="label" :prop="prop">
    <el-select
      :model-value="value"
      @change="handleChange"
      :placeholder="label"
      :loading="loading"
      style="width: 150px"
    >
      <el-option
        v-for="s in subTaskTypes"
        :key="s.value"
        :label="s.label"
        :value="s"
      />
    </el-select>
  </el-form-item>
</template>
<script>
import domainApi from '@/api/fysp/domainApi';
 
export default {
  props: {
    // 是否在首选项处添加“全部”选项
    allOption: {
      type: Boolean,
      default: true
    },
    label: {
      type: String,
      default: '任务类型'
    },
    // 返回结果
    value: Object,
    // 是否默认返回初始选项
    initValue: {
      type: Boolean,
      default: true
    },
    // form表单绑定属性名
    prop: {
      type: String,
      default: '_subtasktype'
    }
  },
  emits: ['update:value'],
  data() {
    return {
      subTaskTypes: [],
      loading: false
    };
  },
 
  methods: {
    handleChange(value) {
      this.$emit('update:value', value);
    }
  },
  mounted() {
    this.loading = true;
    domainApi
      .fetchItemByCatalogId('qASRIAjgSfCuvJOi')
      .then((res) => {
        this.subTaskTypes = res.data.map((item) => ({
          value: item.value,
          label: item.text
        }));
        if (this.allOption) {
          this.subTaskTypes.unshift({
            value: null,
            label: '全部'
          });
        }
        if (this.initValue) {
          this.handleChange(this.subTaskTypes[0]);
        }
      })
      .finally(() => {
        this.loading = false;
      });
  }
};
</script>