From 0db5b7d7779c0ef677c3f20072f275fec6a99da5 Mon Sep 17 00:00:00 2001 From: WXL (wul) <wl_5969728@163.com> Date: 星期一, 18 八月 2025 16:32:14 +0800 Subject: [PATCH] 测试完成 --- src/views/index.vue | 148 ++++++++++++++++++++++++++++++++++--------------- 1 files changed, 102 insertions(+), 46 deletions(-) diff --git a/src/views/index.vue b/src/views/index.vue index f589df9..9bc65bb 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -20,7 +20,8 @@ <el-row :gutter="20"> <el-col :span="10"> <div class="home-user-task-stats"> - <p>{{ OutpatientData.rs }}</p> + <p>{{ OutpatientData.rc }}</p> + <p>{{ OutpatientData.rc }}</p> <div class="text-color2"> <p>闂ㄨ瘖灏辫瘖閲忥紙浜烘锛�</p> </div> @@ -28,7 +29,7 @@ </el-col> <el-col :span="10"> <div class="home-user-task-stats"> - <p>{{ OutpatientData.rc }}</p> + <p>{{ OutpatientData.rs }}</p> <div class="text-color2"> <p>闂ㄨ瘖鏈嶅姟閲忥紙浜烘锛�</p> </div> @@ -62,7 +63,7 @@ <el-row :gutter="20"> <el-col :span="10"> <div class="home-user-task-stats"> - <p style="color: red">{{ DischargeData.rs }}</p> + <p style="color: red">{{ DischargeData.rc }}</p> </div> <div class="text-color2"> <p>鍑洪櫌灏辫瘖閲忥紙浜烘锛�</p> @@ -70,7 +71,7 @@ </el-col> <el-col :span="10"> <div class="home-user-task-stats"> - <p style="color: red">{{ DischargeData.rc }}</p> + <p style="color: red">{{ DischargeData.rs }}</p> <div class="text-color2"> <p>鍑洪櫌鏈嶅姟閲忥紙浜烘锛�</p> </div> @@ -94,15 +95,30 @@ style="margin-left: 390px" @change="changes" > - <el-radio-button label="鍛�" @click="dyat = 7"></el-radio-button> <el-radio-button - label="鏈�" - @click="dyat = 30" + label="杩戜竴鍛�" + @click="dyat = 7" ></el-radio-button> <el-radio-button - label="骞�" - @click="dyat = 360" + label="杩戜竴鏈�" + @click="dyat = 31" ></el-radio-button> + <el-radio-button + label="杩戜竴骞�" + @click="dyat = 365" + ></el-radio-button> + <el-radio-button label="鑷畾涔�"> + <el-date-picker + v-if="radio1 === '鑷畾涔�'" + v-model="customDateRange" + type="daterange" + range-separator="鑷�" + start-placeholder="寮�濮嬫棩鏈�" + end-placeholder="缁撴潫鏃ユ湡" + value-format="yyyy-MM-dd" + @change="handleCustomDateChange" + ></el-date-picker> + </el-radio-button> </el-radio-group> </div> <!-- 涓儴绾挎�ф煴鐘跺浘 --> @@ -306,7 +322,7 @@ mypPieCharts: null, lastWidth: window.innerWidth, lastHeight: window.innerHeight, - radio1: "鍛�", + radio1: "杩戜竴鍛�", ticketStatistics: {}, timeTypeMap: { 鍛�: "day", @@ -330,7 +346,8 @@ SkuTop: [], cylinderSeries: [], cylinderXAxis: [], - dyat: 30, + customDateRange: [], // 鑷畾涔夋棩鏈熻寖鍥� + dyat: 6, intervalId: null, }; }, @@ -343,17 +360,23 @@ atd() { return dayjs().subtract(this.dyat, "day").format("YYYY-MM-DD HH:mm:ss"); }, - statd() { + statd() { + if (this.radio1 === "鑷畾涔�" && this.customDateRange.length > 0) { + return this.customDateRange[1]; + } return dayjs().format("YYYY-MM-DD"); }, endatd() { + if (this.radio1 === "鑷畾涔�" && this.customDateRange.length > 0) { + return this.customDateRange[0]; + } return dayjs().subtract(this.dyat, "day").format("YYYY-MM-DD"); }, }, created() { this.getTopdata(); this.getgraphdata(); - this.getranking(); + // this.getranking(); this.$nextTick(function () { this.myEcharts2(); this.getnodeCollect(); @@ -372,15 +395,35 @@ methods: { // 鏀瑰彉鏃堕棿浜嬩欢 changes() { - if (this.radio1 == "鍛�") { - this.dyat = 7; - } else if (this.radio1 == "鏈�") { - this.dyat = 30; - } else { - this.dyat = 360; + switch (this.radio1) { + case "杩戜竴鍛�": + this.dyat = 7; + break; + case "杩戜竴鏈�": + this.dyat = 30; + break; + case "杩戜竴骞�": + this.dyat = 365; + break; + case "鑷畾涔�": + // 鑷畾涔夋棩鏈熷鐞嗗湪handleCustomDateChange鏂规硶涓� + return; } + this.refreshData(); + }, + + // 澶勭悊鑷畾涔夋棩鏈熷彉鍖� + handleCustomDateChange(range) { + if (!range || range.length !== 2) return; + + this.customDateRange = range; + this.refreshData(); + }, + + // 缁熶竴鍒锋柊鏁版嵁鐨勬柟娉� + refreshData() { this.getgraphdata(); - this.getranking(); + // this.getranking(); this.getTopdata(); this.myEcharts2(); this.getnodeCollect(); @@ -461,12 +504,7 @@ let params = { startDate: this.endatd, endDate: this.statd, - timeType: - this.radio1 === "鍛�" - ? "day" - : this.radio1 === "鏈�" - ? "month" - : "year", + timeType: this.getTimeType() }; try { @@ -477,6 +515,28 @@ } catch (error) { console.error("鑾峰彇鍥捐〃鏁版嵁澶辫触:", error); } + }, + + // 鑾峰彇鏃堕棿绫诲瀷 + getTimeType() { + if (this.radio1 === "杩戜竴鍛�" || this.radio1 === "杩戜竴鏈�") { + return "day"; + } + + if (this.radio1 === "杩戜竴骞�") { + return "month"; + } + + // 鑷畾涔夋棩鏈熻寖鍥� + if (this.radio1 === "鑷畾涔�" && this.customDateRange.length === 2) { + const start = dayjs(this.customDateRange[0]); + const end = dayjs(this.customDateRange[1]); + const diffDays = end.diff(start, 'day'); + + return diffDays > 60 ? "month" : "day"; + } + + return "day"; // 榛樿杩斿洖day绫诲瀷 }, processChartData(data) { // 鎸夋椂闂存帓搴忕‘淇濇暟鎹『搴忔纭� @@ -491,22 +551,18 @@ const pmoData = []; sortedData.forEach((item) => { - // 鏍规嵁鏃堕棿绫诲瀷鏍煎紡鍖栨樉绀� - let timeLabel = item.timePeriod; - if (this.radio1 === "鍛�") { - timeLabel = dayjs(item.timePeriod).format("MM-DD"); - } else if (this.radio1 === "鏈�") { - timeLabel = item.timePeriod.split("-")[1] + "鏈�"; - } else { - timeLabel = item.timePeriod.split("-")[0] + "骞�"; - } + // 鏍规嵁鏃堕棿绫诲瀷鏍煎紡鍖栨樉绀� + const timeType = this.getTimeType(); + const timeLabel = timeType === "day" + ? dayjs(item.timePeriod).format("MM-DD") + : dayjs(item.timePeriod).format("YYYY-MM"); - xAxisData.push(timeLabel); - dischargeFollowData.push(item.dischargeFollowCount); - outpatientFollowData.push(item.outpatientFollowCount); - pmiData.push(item.pmiCount); - pmoData.push(item.pmoCount); - }); + xAxisData.push(timeLabel); + dischargeFollowData.push(item.dischargeFollowCount); + outpatientFollowData.push(item.outpatientFollowCount); + pmiData.push(item.pmiCount); + pmoData.push(item.pmoCount); +}); // 鏇存柊鍥捐〃 this.updateChart( @@ -623,7 +679,7 @@ }, }, legend: { - data: ["鍑洪櫌闅忚閲�", "闂ㄨ瘖闅忚閲�", "鍑洪櫌鏈嶅姟浜烘", "闂ㄨ瘖鏈嶅姟浜烘"], + data: ["鍑洪櫌鏈嶅姟閲�", "闂ㄨ瘖鏈嶅姟閲�", "鍑洪櫌灏辫瘖浜烘", "闂ㄨ瘖灏辫瘖浜烘"], }, xAxis: [ { @@ -655,7 +711,7 @@ grid: { top: "35%" }, series: [ { - name: "鍑洪櫌闅忚閲�", + name: "鍑洪櫌鏈嶅姟閲�", type: "bar", tooltip: { valueFormatter: function (value) { @@ -665,7 +721,7 @@ data: [], // 鍒濆涓虹┖锛屽皢閫氳繃API鏁版嵁濉厖 }, { - name: "闂ㄨ瘖闅忚閲�", + name: "闂ㄨ瘖鏈嶅姟閲�", type: "bar", tooltip: { valueFormatter: function (value) { @@ -675,7 +731,7 @@ data: [], // 鍒濆涓虹┖锛屽皢閫氳繃API鏁版嵁濉厖 }, { - name: "鍑洪櫌鏈嶅姟浜烘", + name: "鍑洪櫌灏辫瘖浜烘", type: "line", smooth: 0.3, yAxisIndex: 1, @@ -687,7 +743,7 @@ data: [], // 鍒濆涓虹┖锛屽皢閫氳繃API鏁版嵁濉厖 }, { - name: "闂ㄨ瘖鏈嶅姟浜烘", + name: "闂ㄨ瘖灏辫瘖浜烘", type: "line", smooth: 0.3, yAxisIndex: 1, -- Gitblit v1.9.3