riku
2023-12-20 f58f07875461b7cc8205978cf4f0fac86564df72
src/components/search-option/FYOptionUserType.vue
@@ -1,7 +1,8 @@
<template>
  <el-form-item label="用户类型" :prop="prop">
    <el-select
      v-model="selectedOptions"
      :model-value="value"
      @change="handleChange"
      placeholder="用户类型"
      style="width: 150px"
    >
@@ -38,31 +39,16 @@
  data() {
    return {
      userTypes: enumUser(this.allOption),
      selectedOptions: {},
    };
  },
  watch: {
    selectedOptions: {
      handler(nVal, oVal) {
        if (nVal != oVal) {
          this.$emit('update:value', nVal);
        }
      },
      deep: true,
    },
    value: {
      handler(nVal, oVal) {
        if (nVal != oVal) {
          this.selectedOptions = nVal;
        }
      },
      deep: true,
      immediate: true
    },
  methods: {
    handleChange(value) {
      this.$emit('update:value', value);
    }
  },
  mounted() {
    if (this.initValue) {
      this.selectedOptions = this.userTypes[0];
      this.handleChange(this.userTypes[0]);
    }
  },
};