|
@@ -0,0 +1,184 @@
|
|
|
+<template>
|
|
|
+ <div class="layout_container">
|
|
|
+ <header>
|
|
|
+ <el-date-picker v-model="month" type="month" format="YYYY-MM" value-format="YYYY-MM" placeholder="请选择月份"/>
|
|
|
+ <el-select v-model="reportTL" placeholder="请选择报表类别" multiple collapse-tags collapse-tags-tooltip
|
|
|
+ clearable :max-collapse-tags="3" style="width: 320px">
|
|
|
+ <el-option v-for="item in reportTypeList" :key="item.reportType" :label="item.reportLabel" :value="item.reportType"/>
|
|
|
+ </el-select>
|
|
|
+ <el-autocomplete v-model="dept" value-key="name" :fetch-suggestions="querySearchDept"
|
|
|
+ clearable class="inline-input w-50 m-2" style="width: 270px"
|
|
|
+ @select="handleSelect" placeholder="请输入关键字">
|
|
|
+ <template #prepend>科室</template>
|
|
|
+ </el-autocomplete>
|
|
|
+ <el-divider direction="vertical" />
|
|
|
+ <el-button type="primary" icon="Search" @click="query" style="margin-left: 2px">查询</el-button>
|
|
|
+ </header>
|
|
|
+ <div class="layout_main layout_el-table">
|
|
|
+ <el-row :gutter="2">
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-card style="max-width: 800px">
|
|
|
+ <el-table :data="deptLeftData" style="width: 100%" border :span-method="objectSpanMethodLeft">
|
|
|
+ <el-table-column prop="name" label="" width="80" />
|
|
|
+ <el-table-column prop="reportName" label="项目" width="180" />
|
|
|
+ <el-table-column prop="baseMonth" label="本月" width="80" />
|
|
|
+ <el-table-column prop="lastMonth" label="上月" width="80" />
|
|
|
+ <el-table-column prop="fastMonth" label="去年同期" width="80" />
|
|
|
+ <el-table-column prop="tb" label="同比(%)"/>
|
|
|
+ <el-table-column prop="hb" label="环比(%)"/>
|
|
|
+ </el-table>
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-card style="max-width: 800px">
|
|
|
+ <el-table :data="deptRightData" style="width: 100%" border :span-method="objectSpanMethodRight">
|
|
|
+ <el-table-column prop="name" label="" width="80" />
|
|
|
+ <el-table-column prop="reportName" label="项目" width="180" />
|
|
|
+ <el-table-column prop="baseMonth" label="本月" width="80" />
|
|
|
+ <el-table-column prop="lastMonth" label="上月" width="80" />
|
|
|
+ <el-table-column prop="fastMonth" label="去年同期" width="80" />
|
|
|
+ <el-table-column prop="tb" label="同比(%)"/>
|
|
|
+ <el-table-column prop="hb" label="环比(%)"/>
|
|
|
+ </el-table>
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script setup name="DeptBusinessMonthReport">
|
|
|
+import { ref } from 'vue'
|
|
|
+import {selectDeptReportList, selectReportTypeList} from '@/api/reports/dept-business-month-report'
|
|
|
+import {selectQxSmallDept} from "@/api/medical-insurance/si-yb-util.js";
|
|
|
+import {ElMessage} from "element-plus";
|
|
|
+
|
|
|
+const now = new Date()
|
|
|
+let yf
|
|
|
+if (now.getMonth() < 9) {
|
|
|
+ yf = now.getFullYear() + '-0' + (now.getMonth() + 1)
|
|
|
+} else {
|
|
|
+ yf = now.getFullYear() + '-' + (now.getMonth() + 1)
|
|
|
+}
|
|
|
+
|
|
|
+const month = ref(yf)
|
|
|
+const qx = ref(0)
|
|
|
+const reportTL = ref('')
|
|
|
+const dept = ref('')
|
|
|
+const reportTypeList = ref([])
|
|
|
+const deptLeftData = ref([])
|
|
|
+const deptRightData = ref([])
|
|
|
+const queryData = ref({
|
|
|
+ startTime: '',
|
|
|
+ endTime: '',
|
|
|
+ dept: '',
|
|
|
+ reportTypeList: [],
|
|
|
+ type: '',
|
|
|
+ ybbFlag: '1',
|
|
|
+})
|
|
|
+const query = () => {
|
|
|
+ if (qx.value === 0 && !dept.value) {
|
|
|
+ ElMessage({
|
|
|
+ type: "warning",
|
|
|
+ message: '请选择一个科室',
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let days = getLastDayOfMonth(month.value)
|
|
|
+ queryData.value.startTime = month.value + '-01 00:00:00'
|
|
|
+ queryData.value.endTime = month.value + '-' + days + ' 23:59:59'
|
|
|
+ queryData.value.reportTypeList = reportTL.value
|
|
|
+ queryDeptReportList()
|
|
|
+}
|
|
|
+const querySearchDept = async (str, cb) => {
|
|
|
+ let qxData = {
|
|
|
+ str: str,
|
|
|
+ code: 'ybbQx'
|
|
|
+ }
|
|
|
+ let results = await selectQxSmallDept(qxData)
|
|
|
+ if (results) {
|
|
|
+ // 调用 callback 返回建议列表的数据
|
|
|
+ cb(results)
|
|
|
+ }
|
|
|
+}
|
|
|
+const handleSelect = (item) => {
|
|
|
+ queryData.value.dept = item.code
|
|
|
+}
|
|
|
+onMounted(() => {
|
|
|
+ queryReportTypeList()
|
|
|
+});
|
|
|
+const queryReportTypeList = () => {
|
|
|
+ selectReportTypeList('1').then(res => {
|
|
|
+ reportTypeList.value = res.reportTypeList
|
|
|
+ qx.value = res.qx
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const queryDeptReportList = () => {
|
|
|
+ selectDeptReportList(queryData.value).then(res => {
|
|
|
+ deptLeftData.value = res.deptLeft
|
|
|
+ deptRightData.value = res.deptRight
|
|
|
+ })
|
|
|
+}
|
|
|
+// 单元格合并同类
|
|
|
+const objectSpanMethodLeft = (data) => {
|
|
|
+ if(data.columnIndex === 0){
|
|
|
+ // 当前列为0的时候不进行操作单元格
|
|
|
+ const name = data.row[data.column.property];
|
|
|
+ const preRow = deptLeftData.value[data.rowIndex - 1];
|
|
|
+ const preValue = preRow ? preRow[data.column.property] : null;
|
|
|
+ // 当前行的数据对象的name 是否和 上一行列的 name 是否相等 相等就不合并单元格
|
|
|
+ if (name === preValue) {
|
|
|
+ return {rowspan: 0, colspan: 0}; // 不生成单元格
|
|
|
+ } else {
|
|
|
+ let rowspan = 1;
|
|
|
+ for (let i = data.rowIndex + 1; i < deptLeftData.value.length; i++) {
|
|
|
+ const nextRow = deptLeftData.value[i];
|
|
|
+ const nextValue = nextRow[data.column.property];
|
|
|
+ if (nextValue === name) {
|
|
|
+ rowspan++;
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {rowspan, colspan: 1};
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const objectSpanMethodRight = (data) => {
|
|
|
+ if(data.columnIndex === 0){
|
|
|
+ // 当前列为0的时候不进行操作单元格
|
|
|
+ const name = data.row[data.column.property];
|
|
|
+ const preRow = deptRightData.value[data.rowIndex - 1];
|
|
|
+ const preValue = preRow ? preRow[data.column.property] : null;
|
|
|
+ // 当前行的数据对象的name 是否和 上一行列的 name 是否相等 相等就不合并单元格
|
|
|
+ if (name === preValue) {
|
|
|
+ return {rowspan: 0, colspan: 0}; // 不生成单元格
|
|
|
+ } else {
|
|
|
+ let rowspan = 1;
|
|
|
+ for (let i = data.rowIndex + 1; i < deptRightData.value.length; i++) {
|
|
|
+ const nextRow = deptRightData.value[i];
|
|
|
+ const nextValue = nextRow[data.column.property];
|
|
|
+ if (nextValue === name) {
|
|
|
+ rowspan++;
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {rowspan, colspan: 1};
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 获取指定年月(格式是 yyyy-MM)的最后一天日期(例如 2023-04 的最后一天是 30)
|
|
|
+function getLastDayOfMonth(yearMonth) {
|
|
|
+ // yearMonth是"yyyy-MM"格式
|
|
|
+ const [year, month] = yearMonth.split('-').map(Number);
|
|
|
+ // 设置月份为下个月,然后再设置为0,会自动调整到上个月的最后一天
|
|
|
+ const lastDayOfMonth = new Date(year, month, 0);
|
|
|
+ return lastDayOfMonth.getDate(); // 获取日份
|
|
|
+}
|
|
|
+
|
|
|
+</script>
|