<template>
  <div class="search-box">
    <el-form :model="form" :inline="true" ref="create">
      <el-form-item
        label="医疗机构"
        prop="hospName"
        v-if="userType == 'SUP' || userType == 'YBJ'"
      >
        <el-input
          v-model="form.hospName"
          style="width: 170px; margin-right: 2px"
          placeholder="请输入医疗机构"
          clearable
        />
      </el-form-item>
      <el-form-item
        label="配送企业"
        prop="splerName"
        v-if="userType == 'HOS' || userType == 'YBJ'"
      >
        <el-input
          v-model="form.splerName"
          style="width: 170px; margin-right: 2px"
          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: {
        hospName: "",
        splerName: "",
      },
      userType: "", //判断用户是医疗机构还是配送企业
      searchData: [],
    };
  },
  mounted() {
    let { orgType, userID } = this.$store.state.user;
    this.userType = orgType;
  },
  methods: {
    onSubmit() {
      this.$refs["create"].validate((valid) => {
        if (valid) {
          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>
