<template>
  <div class="search-box">
    <el-form :model="data" class="demo-form-inline" label-suffix=":" label-width="74px">
      <el-row :gutter="20">
        <el-col :span="9">
          <el-form-item label="出院时间">
            <div class="selects">
              <el-date-picker v-model="data.time[0]" type="date" format="yyyy 年 MM 月 dd 日" value-format="yyyyMMdd" placeholder="开始日期"></el-date-picker>
              <el-date-picker v-model="data.time[1]" type="date" style="margin-left: 10px" format="yyyy 年 MM 月 dd 日" value-format="yyyyMMdd" placeholder="结束日期"></el-date-picker>
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="医师姓名">
            <el-select v-model="data.doctor_code" multiple collapse-tags filterable clearable placeholder="全部" style="width: 100%;">
              <el-option v-for="(item, index) of doctors" :key="index" :label="item.name" :value="item.code"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="出院科室">
            <el-select v-model="data.AAC11N" filterable clearable placeholder="全部" style="width: 100%;">
              <el-option v-for="(item, index) in departmentList" :key="index" :label="item.dep_name" :value="item.dep_name"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <el-form-item label="病历等级">
            <el-select v-model="data.level" filterable clearable placeholder="全部" style="width: 100%;">
              <el-option v-for="item of levels" :key="item" :label="item" :value="item"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6" :offset="18">
          <el-form-item style="text-align: right;">
            <el-button plain @click="onReset" icon="el-icon-refresh">重置</el-button>
            <el-button type="primary" @click="onSubmit" class="export-btn" icon="el-icon-search">查询</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import { data } from 'autoprefixer';

export default {
  props: {
    data: {
      type: Object,
      default() {
        return {
          time: [],
          level: '',
          doctor_code: [],
          AAC11N: ''
        }
      }
    }
  },
  data() {
    return {
      levels: ['优', '良', '中', '差'],
      doctors: [],
      departmentList: []
    }
  },
  created() {
    if (this.data.doctor_code) {
      this.$set(this.data, 'doctor_code', this.data.doctor_code);
    }
    this.getDoctors()
    this.getDepartment()
  },
  methods: {
    // 获取医生选线
    getDoctors() {
      this.$axios2.post('/case-quality/doctor_list').then(res => {
        this.doctors = res.data;
      });
    },
    getDepartment() {
      this.$axios.post('/bmy/getAllDepartment').then(res => {
        // 不要全部选项
        this.departmentList = res.data;
      })
    },
    onSubmit() {

      this.$emit('search')
    },
    onReset() {
      this.$emit('reset')
    }
  }
}
</script>

<style>

</style>
