<template>
  <div class="app-container">
    <el-table
      v-loading="loading"
      :data="medicationUsageList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="50" align="center" />
      <el-table-column
        label="医疗机构代码"
        align="center"
        key="orgId"
        prop="orgId"
        width="200"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="组织机构名称"
        align="center"
        key="orgName"
        prop="orgName"
         width="200"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="国家药品编码(YPID)"
        align="center"
        key="nationalDrugCode"
        prop="ypCode"
        width="200"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="院内药品唯一码"
        align="center"
        key="busNo"
        prop="busNo"
        width="200"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="省级药品集中采购平台药品编码"
        align="center"
        key="provincialDrugCode"
        prop="provincialDrugCode"
        width="220"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="产品名称"
        align="center"
        key="itemName"
        prop="itemName"
         width="200"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="销售总金额(元)"
        align="center"
        key="totalSalesPrice"
        prop="totalSalesPrice"
        width="200"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="销售数量(最小销售包装单位)"
        align="center"
        key="packageSalesQuantity"
        prop="packageSalesQuantity"
        width="200"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="销售数量(最小制剂单位)"
        align="center"
        key="dosageSalesQuantity"
        prop="dosageSalesQuantity"
        width="200"
        :show-overflow-tooltip="true"
      />
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNo"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script setup name="medicationUsageDetails">
import {
  getReportMedicationUsage
} from './statisticalManagent';


const medicationUsageList = ref([]);
const loading = ref(true);
const ids = ref([]);
const total = ref(0);

const queryParams = ref({
    pageNo: 1,
    pageSize: 10,
});

/** 查询调拨管理项目列表 */
function getList() {
  loading.value = true;
  getReportMedicationUsage(queryParams.value).then((res) => {
    loading.value = false;
    medicationUsageList.value = res.data.records;
    total.value = res.data.total;
  })
}

/** 选择条数  */
function handleSelectionChange(selection) {
  ids.value = selection.map((item) => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

// 页面加载时获取数据
onMounted(() => {
  getList();
});

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

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