|
|
@@ -0,0 +1,154 @@
|
|
|
+<template>
|
|
|
+ <div class="flex items-center xt-form">
|
|
|
+ <XTForm :form-data="formData" @change="callForm" />
|
|
|
+ <Button type="default" @click="handleDownload"
|
|
|
+ ><Icon icon="icon-xt-download-download_default|iconfont" :size="14" />
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ <div class="mb-4">
|
|
|
+ <XTTitle :title="title" :go-back="false" />
|
|
|
+ </div>
|
|
|
+ <Row style="max-height: 400px">
|
|
|
+ <Col :span="16">
|
|
|
+ <Pie :data="pieData" />
|
|
|
+ </Col>
|
|
|
+ <Col :span="8">
|
|
|
+ <BasicTable @register="registerTable">
|
|
|
+ <template #bodyCell="{ column, record }">
|
|
|
+ <template v-if="column.key === 'type'">
|
|
|
+ <span> {{ formatDictValue(durgTypeOptions, record.type) }}</span>
|
|
|
+ </template>
|
|
|
+ <template v-if="column.key === 'sum'">
|
|
|
+ <a @click="handleDetail(record)">{{ record.sum }}</a>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </BasicTable>
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
+ <Row style="max-height: 200px">
|
|
|
+ <Col :span="24">
|
|
|
+ <BasicTable @register="registerDetailTable">
|
|
|
+ <template #headerCell="{ column }">
|
|
|
+ <template v-if="column.key === 'type'"> {{ detailName }} </template>
|
|
|
+ <template v-if="column.key === 'sum'"> 数量 </template>
|
|
|
+ <template v-if="column.key === 'proportion'"> 占比 </template>
|
|
|
+ </template>
|
|
|
+ </BasicTable>
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+ import { onMounted, ref } from 'vue';
|
|
|
+ import { Row, Col, Button } from 'ant-design-vue';
|
|
|
+ import { XTForm } from '/@/components/XTForm/index';
|
|
|
+ import { XTTitle } from '/@/components/XTTitle/index';
|
|
|
+ import { getDrugStats } from '/@/api/biz/stats/suppliesStatsApi';
|
|
|
+ import { BasicTable, useTable } from '@/components/Table';
|
|
|
+ import { columns, detailColumns } from './data';
|
|
|
+ import { Icon } from '/@/components/Icon';
|
|
|
+ import { formatDictValue } from '/@/utils';
|
|
|
+ import { listDictModel } from '/@/api/common';
|
|
|
+ import Pie from '../../chart/pie.vue';
|
|
|
+ // formdata
|
|
|
+ const title = ref('药品用量统计');
|
|
|
+ const pieData = ref({} as any); // Echart图表组件赋值变量
|
|
|
+ const tableData = ref([]); // 药品类型统计数据
|
|
|
+ const detailTableData = ref([]);
|
|
|
+ const patrolTime = ref([]); // 时间查询参数
|
|
|
+ const detailName = ref('');
|
|
|
+ const formData = [
|
|
|
+ {
|
|
|
+ name: 'patrolTime',
|
|
|
+ componentType: 'RangePicker',
|
|
|
+ placeholder: '请选择维修时间',
|
|
|
+ format: 'YYYY-MM-DD',
|
|
|
+ valueFormat: 'YYYY-MM-DD',
|
|
|
+ },
|
|
|
+ {},
|
|
|
+ ];
|
|
|
+ // 药品类型统计表格配置
|
|
|
+ const [registerTable, { setTableData }] = useTable({
|
|
|
+ showIndexColumn: false,
|
|
|
+ bordered: true,
|
|
|
+ striped: false,
|
|
|
+ pagination: false,
|
|
|
+ maxHeight: 200,
|
|
|
+ dataSource: tableData.value,
|
|
|
+ columns: columns,
|
|
|
+ });
|
|
|
+
|
|
|
+ const [registerDetailTable, { setTableData: setDetailTableData }] = useTable({
|
|
|
+ showIndexColumn: false,
|
|
|
+ bordered: true,
|
|
|
+ striped: false,
|
|
|
+ pagination: false,
|
|
|
+ maxHeight: 200,
|
|
|
+ dataSource: detailTableData.value,
|
|
|
+ columns: detailColumns,
|
|
|
+ });
|
|
|
+
|
|
|
+ const durgTypeOptions = ref();
|
|
|
+ onMounted(async () => {
|
|
|
+ durgTypeOptions.value = await listDictModel({ dictCode: 'pht' }); // 查询药品类型字典数据
|
|
|
+ getDatas(); // 执行获取统计数据方法
|
|
|
+ });
|
|
|
+
|
|
|
+ // 查询组件回调
|
|
|
+ async function callForm(data) {
|
|
|
+ patrolTime.value = data.patrolTime || [];
|
|
|
+ getDatas();
|
|
|
+ }
|
|
|
+ // 获取统计数据
|
|
|
+ async function getDatas() {
|
|
|
+ const params = {
|
|
|
+ statsTime: patrolTime.value,
|
|
|
+ };
|
|
|
+ const res = await getDrugStats(params); // 请求药品统计接口
|
|
|
+ tableData.value = res.data;
|
|
|
+ await setTableData(res.data); // 右侧统计数据表格赋值
|
|
|
+ // 组合Echart图表数据格式
|
|
|
+ const dataList = {
|
|
|
+ content: [],
|
|
|
+ description: title.value,
|
|
|
+ };
|
|
|
+ res.data.forEach(item => {
|
|
|
+ dataList.content.push({
|
|
|
+ name: formatDictValue(durgTypeOptions.value, item.type),
|
|
|
+ value: item.sum,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ pieData.value = dataList; // Echart图表赋值
|
|
|
+ handleDetail(tableData.value[0]);
|
|
|
+ }
|
|
|
+ // 统计下载事件
|
|
|
+ function handleDownload() {
|
|
|
+ console.log('下载按钮');
|
|
|
+ }
|
|
|
+ // 点击表格中数字
|
|
|
+ async function handleDetail(record) {
|
|
|
+ const params = {
|
|
|
+ statsTime: patrolTime.value,
|
|
|
+ drugType: record.type,
|
|
|
+ };
|
|
|
+ const res = await getDrugStats(params); // 请求药品统计接口
|
|
|
+ detailName.value = formatDictValue(durgTypeOptions.value, record.type);
|
|
|
+ await setDetailTableData(res.data);
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+ ::v-deep(.xt-title) {
|
|
|
+ padding-left: 40px;
|
|
|
+ background-color: #f6f8fa;
|
|
|
+ }
|
|
|
+
|
|
|
+ .xt-form {
|
|
|
+ justify-content: flex-end;
|
|
|
+ margin-right: 20px;
|
|
|
+ }
|
|
|
+
|
|
|
+ ::v-deep(.ant-row) {
|
|
|
+ max-height: 460px;
|
|
|
+ }
|
|
|
+</style>
|