riku
2023-12-21 3d7bf6dff3d1e2f12c4ecd0120ee110348ccdf49
src/components/search-option/base/FYOptionText.vue
@@ -1,6 +1,12 @@
<template>
  <el-form-item :label="label">
    <el-input clearable v-model="searchText" :placeholder="placeholder" />
  <el-form-item :label="label" :prop="prop">
    <el-input
      clearable
      :model-value="value"
      :placeholder="placeholder"
      @input="handleInput"
      style="width: 150px"
    />
  </el-form-item>
</template>
@@ -9,32 +15,24 @@
  props: {
    label: {
      type: String,
      default: '查询项',
      default: '查询项'
    },
    placeholder: {
      type: String,
      default: '输入搜索内容',
      default: '输入搜索内容'
    },
    // 返回结果
    value: String,
    prop: String
  },
  emits: ['update:value'],
  data() {
    return {
      searchText: '',
    };
    return {};
  },
  watch: {
    searchText(nVal, oVal) {
      if (nVal != oVal) {
        this.$emit('update:value', nVal);
      }
    },
    value(nVal, oVal) {
      if (nVal != oVal) {
        this.searchText = nVal;
      }
    },
  },
  methods: {
    handleInput(value) {
      this.$emit('update:value', value);
    }
  }
};
</script>