hcong
2024-10-11 cf5d5ffc8350d86daaca952c24452b16e368c127
src/components/search-option/FYOptionScene.vue
@@ -6,12 +6,7 @@
      placeholder="场景类型"
      style="width: 150px"
    >
      <el-option
        v-for="s in sceneTypes"
        :key="s.value"
        :label="s.label"
        :value="s"
      />
      <el-option v-for="s in sceneTypes" :key="s.value" :label="s.label" :value="s" />
    </el-select>
  </el-form-item>
</template>
@@ -24,30 +19,45 @@
    // 是否在首选项处添加“全部”选项
    allOption: {
      type: Boolean,
      default: true,
      default: true
    },
    // 1:飞羽环境系统;2:飞羽监管系统;
    type: {
      type: Number,
      default: 1,
      type: Number || String,
      default: 1
    },
    // 返回结果
    value: Object,
    // 是否默认返回初始选项
    initValue: {
      type: Boolean,
      default: true,
      default: true
    },
    // form表单绑定属性名
    prop: {
      type: String,
      default: '_scenetype'
    },
    // 切换 type 后,当前选项是否清空
    sourceInit: {
      type: Boolean,
      default: true
    }
  },
  emits: ['update:value'],
  data() {
    return {
      sceneTypes: enumScene(this.type, this.allOption),
      // sceneTypes: enumScene(this.type, this.allOption),
    };
  },
  computed: {
    sceneTypes() {
      if (this.sourceInit) {
        // 当因为type或者allOption参数变化引起选项变更时,清空当前选项
        this.handleChange();
      }
      return enumScene(this.type, this.allOption);
    }
  },
  methods: {
    handleChange(value) {
@@ -58,6 +68,6 @@
    if (this.initValue) {
      this.handleChange(this.sceneTypes[0]);
    }
  },
  }
};
</script>