riku
2024-08-01 59b6bafdf03464ad5d89a74623ec8941dec415c7
src/components/search-option/base/FYOptionText.vue
@@ -1,40 +1,42 @@
<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:' + width + ';'"
    />
  </el-form-item>
</template>
<script>
export default {
  props: {
    width:{
      type: String,
      default: '150px'
    },
    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>