<template>
  <div class="app-container">
    <el-form
      ref="queryRef"
      :model="queryParams"
      :inline="true"
      label-width="100px"
    />

    <el-table
      v-loading="loading"
      :data="stockOutDetailList"
      height="calc(100vh - 300px)"
      @selection-change="handleSelectionChange"
    >
      <el-table-column
        type="selection"
        width="50"
        align="center"
      />
      <el-table-column
        key="supplyBusno"
        label="单据号"
        align="center"
        prop="supplyBusno"
        width="200"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        key="type"
        label="出库类型"
        align="center"
        prop="type"
        width="140"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        key="medName"
        label="药品名称"
        align="center"
        prop="medName"
        width="140"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        key="busNo"
        label="院内药品唯一码"
        align="center"
        prop="busNo"
        width="140"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        key="itemTableText"
        label="药品类型"
        align="center"
        prop="itemTableText"
        width="140"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        key="lotNumber"
        label="批次号"
        align="center"
        prop="lotNumber"
        width="140px"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        key="locationName"
        label="存放仓库"
        align="center"
        prop="locationName"
        width="140"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        key="locationStoreName"
        label="货位"
        align="center"
        prop="locationStoreName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        key="unitCode_dictText"
        label="计量单位"
        align="center"
        prop="unitCode_dictText"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        key="quantity"
        label="采购数量"
        align="center"
        prop="quantity"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        key="price"
        label="采购单价"
        align="center"
        prop="price"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        key="totalPrice"
        label="采购金额"
        align="center"
        prop="totalPrice"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        key="salePrice"
        label="售价"
        align="center"
        prop="salePrice"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        key="totalSalePrice"
        label="售价金额"
        align="center"
        prop="totalSalePrice"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        key="orgId_dictText"
        label="出库科室"
        align="center"
        prop="orgId_dictText"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        key="supplier"
        label="供应商"
        align="center"
        prop="supplier"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        key="approverId_dictText"
        label="审核人"
        align="center"
        prop="approverId_dictText"
        :show-overflow-tooltip="true"
      />

      <el-table-column
        key="approvalTime"
        label="审批日期"
        align="center"
        prop="approvalTime"
        width="160"
        :show-overflow-tooltip="true"
      >
        <template #default="scope">
          <span>{{ parseTime(scope.row.approvalTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column
        key="reason"
        label="出库原因"
        align="center"
        prop="reason"
        :show-overflow-tooltip="true"
      />
    </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 name="getStockOutDetail">
import {getStockOutDetail,} from './statisticalManagent';

const { proxy } = getCurrentInstance();
const route = useRoute();

const stockOutDetailList = ref([]);
const loading = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const approvalTime = ref([]);
const supplierListOptions = ref([]);
const locationIdList = ref([]);

const data = reactive({
  form: {},
  queryParams: {
    pageNo: 1,
    pageSize: 10,
    searchKey: undefined,
    occurrenceTimeSTime: undefined,
    occurrenceTimeETime: undefined,
  },
  rules: {},
});

const { queryParams, form, rules } = toRefs(data);

/** 药剂科报表_常规报表:出库明细表的查询 */
function getList() {
  loading.value = true;
  getStockOutDetail(queryParams.value).then((res) => {
    loading.value = false;
    stockOutDetailList.value = res.data.records;
    total.value = res.data.total;
  });
}

getList();
</script>
<style scoped>
.custom-tree-node {
  display: flex;
  align-items: center;
}

.title {
  font-weight: bold;
  font-size: large;
  margin-bottom: 10px;
}
</style>
