<template>
  <div class="app-container">
    <el-form
      v-show="showSearch"
      ref="queryRef"
      :model="queryParams"
      :inline="true"
      label-width="100px"
    >
      <el-form-item
        label="开始时间"
        prop="startTime"
      >
        <el-date-picker
          v-model="queryParams.startTime"
          type="date"
          placeholder="请选择"
          value-format="yyyy-MM-dd"
          clearable
        />
      </el-form-item>
      <el-form-item
        label="结束时间"
        prop="startTime"
      >
        <el-date-picker
          v-model="queryParams.endTime"
          type="date"
          placeholder="请选择"
          value-format="yyyy-MM-dd"
          clearable
        />
      </el-form-item>
      <el-form-item
        label="药房名称"
        prop="pharmacyId"
        label-width="100px"
      >
        <el-select
          v-model="queryParams.pharmacyId"
          placeholder="请输入"
          clearable
          filterable
          style="width: 150px"
        >
          <el-option
            v-for="item in [
              { id: '1', name: '药房1' },
              { id: '2', name: '药房2' },
            ]"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item
        label="药品名称"
        prop="medicineName"
        label-width="100px"
      >
        <el-input
          v-model="queryParams.medicineName"
          placeholder="请输入"
          clearable
        />
      </el-form-item>
      <el-form-item
        label="药品类型"
        prop="medicineType"
      >
        <el-select
          v-model="queryParams.medicineType"
          placeholder="请选择"
          clearable
          filterable
          style="width: 150px"
        >
          <el-option
            v-for="item in [
              { id: '1', name: '药品1' },
              { id: '2', name: '药品2' },
              { id: '3', name: '药品3' },
              { id: '4', name: '药品4' },
              { id: '5', name: '药品5' },
              { id: '6', name: '药品6' },
              { id: '7', name: '药品7' },
              { id: '8', name: '药品8' },
            ]"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="Search"
          @click="handleQuery"
        >
          搜索
        </el-button>
        <el-button
          icon="Refresh"
          @click="resetQuery"
        >
          重置
        </el-button>
      </el-form-item>
    </el-form>
    <el-row
      :gutter="10"
      class="mb8"
    >
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="Plus"
          @click="handleAdd"
        >
          新增
        </el-button>
      </el-col>
    </el-row>
    <el-table
      v-if="refreshTable"
      v-loading="loading"
      min-height="200"
      max-height="500"
      :data="tableData"
      style="width: 100%"
      lab
    >
      <el-table-column
        prop="name"
        label="库房名称"
        align="center"
      />
      <el-table-column
        prop="age"
        label="药品名称"
        align="center"
      />
      <el-table-column
        prop="address"
        label="包装规格"
        align="center"
      />
      <el-table-column
        prop="address"
        label="包装单位"
        align="center"
      />
      <el-table-column
        prop="address"
        label="最小包装单位"
        align="center"
        width="150px"
      />
      <el-table-column
        prop="address"
        label="厂家"
        align="center"
      />
      <el-table-column
        prop="address"
        label="类型"
        align="center"
      />
      <el-table-column
        prop="address"
        label="单位数量"
        align="center"
      />
      <el-table-column
        prop="address"
        label="最小单位数量"
        align="center"
        width="150px"
      />
      <el-table-column
        prop="address"
        label="原批发价"
        align="center"
      />
      <el-table-column
        prop="address"
        label="现批发价"
        align="center"
      />
      <el-table-column
        prop="address"
        label="原批发拆分价"
        align="center"
        width="150px"
      />
      <el-table-column
        prop="address"
        label="现批发拆分价"
        align="center"
        width="150px"
      />
      <el-table-column
        prop="address"
        label="批价盈亏"
        align="center"
      />
      <el-table-column
        prop="address"
        label="原售价"
        align="center"
      />
      <el-table-column
        prop="address"
        label="现售价"
        align="center"
      />
      <el-table-column
        prop="address"
        label="原零售价"
        align="center"
      />
      <el-table-column
        prop="address"
        label="现零售价"
        align="center"
      />
      <el-table-column
        prop="address"
        label="零价盈亏"
        align="center"
      />
      <el-table-column
        prop="address"
        label="执行时间"
        align="center"
      />
    </el-table>
    <pagination
      v-show="total > 0"
      v-model:page="queryParams.pageNo"
      v-model:limit="queryParams.pageSize"
      :total="total"
      @pagination="getList"
    />
  </div>
</template>

<script setup>
import {ref} from 'vue';

const { proxy } = getCurrentInstance();
const queryParams = ref({
  pageNo: 1,
  pageSize: 10,
  startTime: undefined,
  endTime: undefined,
});
const refreshTable = ref(true);
const loading = ref(false);
const tableData = ref([]);

const getList = () => {
  console.log(queryParams.value);
};
const showSearch = ref(true);
const reset = () => {
  queryParams.value = {
    pageNo: 1,
    pageSize: 10,
  };
};
const handleQuery = () => {
  queryParams.value.pageNo = 1;
  console.log(queryParams.value, 'queryParams');
  getList();
};
const resetQuery = () => {
  reset();
  handleQuery();
};

onMounted(() => {
  getList();
});
</script>

<style>
</style>