
const field = (params = {}) => ({
  // props: {
  //   initForm: {
  //     type: Object,
  //     default: () => ({})
  //   }
  // },

  data() {
    return {
      form: {},
      apiForm: {}
    }
  },

  created() {
    Object.assign(this, params)
  },

  mounted() {
    this.handleSearch()
  },

  // watch: {
  //   initForm: {
  //     handle(val) {
  //       Object.assign(this.form, this.initForm)
  //     },
  //     immediate: true
  //   }
  // },

  methods: {
    handleSearch() {
      const result = {}
      for (const i in this.form) {
        result[this.apiForm[i]] = this.form[i]
      }
      this.$emit('onSearch', result)
    }
  }
})
export default field
