<template>
  <div class="search-box">
    <el-form :model="form" :inline="true" ref="create">
      <el-form-item
        v-for="item in searchData"
        :key="item.props"
        :label="item.name"
        :prop="item.props"
      >
        <el-input
          v-model="form[item.props]"
          style="width: 170px; margin-right: 2px"
          :placeholder="item.placeholder"
          clearable
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
        <el-button @click="resetForm('create')">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { searchInputData } from "./searchData";
export default {
  name: "searchView",
  data() {
    return {
      form: {
        docNo: "",
        genName: "",
        prodId: "",
        prodEntp: "",
      },
      searchData: searchInputData,
    };
  },
  methods: {
    onSubmit() {
      this.$refs["create"].validate((valid) => {
        if (valid) {
          console.log(this.form, "搜索传递的参数这是什么东西啊");
          this.$emit("searchSuses", this.form);
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
      this.$emit("searchSuses", this.form);
    },
  },
};
</script>
<style scoped lang="scss">
.search-box {
  padding: 0;
}
</style>
