From b023f522f3ba2740ebf98e3a602c4b428380fe03 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期五, 06 九月 2024 00:34:56 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/views/system/check/result/index.vue |  223 +++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 180 insertions(+), 43 deletions(-)

diff --git a/src/views/system/check/result/index.vue b/src/views/system/check/result/index.vue
index 090956a..3428663 100644
--- a/src/views/system/check/result/index.vue
+++ b/src/views/system/check/result/index.vue
@@ -1,13 +1,68 @@
 <template>
   <div id="warp">
-    <div>
-      <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect"
-        style="margin-bottom: 10px">
-        <el-menu-item index="0">鐪佸巺鑰冩牳</el-menu-item>
-        <el-menu-item index="1">甯傚眬鑰冩牳</el-menu-item>
-      </el-menu>
-    </div>
+    <div style="display: flex;position: relative">
+      <div style="width: 100%">
+        <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect"
+                 style="margin-bottom: 10px">
+          <el-menu-item index="0">鐪佸巺鏈堝害</el-menu-item>
+          <el-menu-item index="2">鐪佸巺瀛e害</el-menu-item>
+          <el-menu-item index="1">鍖哄幙鏈堝害</el-menu-item>
+          <el-menu-item index="3">鍖哄幙瀛e害</el-menu-item>
+        </el-menu>
+      </div>
+      <!-- 瀵煎嚭鎸夐挳 -->
+      <div style="position: absolute;top:10px; right: 5px;z-index: 2" v-hasPermi="['check:result:export']">
+        <el-popover
+          placement="left"
+          width="300px"
+          trigger="click">
+          <span style="font-weight: bold;font-size: 16px">瀵煎嚭</span>
 
+          <el-form ref="exportForm" :model="exportForm" :rules="exportRules" label-width="100px">
+            <el-form-item label="鑰冩牳鏃堕棿" prop="quarter" required>
+              <el-date-picker
+                :clearable="false"
+                v-model="exportForm.quarter"
+                type="monthrange"
+                format="yyyy-MM"
+                value-format="yyyy-MM"
+                unlink-panels
+                range-separator="鑷�"
+                start-placeholder="寮�濮嬫湀浠�"
+                end-placeholder="缁撴潫鏈堜唤"
+                :picker-options="pickerOptions">
+              </el-date-picker>
+            </el-form-item>
+            <el-form-item label="鍖哄幙" prop="deptIds">
+              <el-select v-model="exportForm.deptIds" multiple clearable>
+                <el-option v-for="dept in areaList"
+                           :value="dept.id"
+                           :key="dept.value"
+                           :label="dept.value"/>
+              </el-select>
+            </el-form-item>
+            <el-form-item label="鑰冩牳鏍囩" prop="examineTags">
+              <el-checkbox-group v-model="exportForm.examineTags">
+                <el-checkbox
+                  v-for="item in tagOptions"
+                  :key="item.value"
+                  :label="item.value"
+                >{{ item.label }}
+                </el-checkbox>
+              </el-checkbox-group>
+            </el-form-item>
+            <el-form-item label="璁$畻骞冲潎鍊�" prop="average">
+              <el-switch
+                v-model="exportForm.average"
+              >
+              </el-switch>
+            </el-form-item>
+            <el-button type="primary" size="small" style="width: 400px" @click="handleExport">瀵煎嚭</el-button>
+          </el-form>
+          <el-button slot="reference" type="primary" size="mini" plain>瀵煎嚭</el-button>
+        </el-popover>
+      </div>
+    </div>
     <div class="data-chart-container">
       <el-card class="data-card" :body-style="{ height: '100%' }">
         <div class="card-content">
@@ -31,9 +86,9 @@
               </div>
               <div class="score-warp">
                 <div class="score-item">
-                  <div style="font-size: 15px; margin-bottom: 15px">{{ formatCreateDate(city[0].createTime) }}</div>
+                  <div style="font-size: 15px; margin-bottom: 15px">{{ formatCreateDate(city[0]) }}</div>
                 </div>
-                <div v-for="(score, scoreIndex) in city" :key="scoreIndex">
+                <div v-for="(score, scoreIndex) in filterRepeat(city)" :key="scoreIndex">
                   <div class="score-item">
                     <div v-if="score.examineCategory == 2">杞﹁締锛�</div>
                     <div v-else-if="score.examineCategory == 3">浜鸿劯锛�</div>
@@ -43,10 +98,11 @@
                 </div>
               </div>
               <div class="bottom-publish">
-                <el-button size="medium" :type="isAnyUnpublished(city) ? 'success' : 'danger'" @click="publish(city)">
+                <el-button v-hasPermi="['check:score:publish']" size="medium"
+                           :type="isAnyUnpublished(city) ? 'success' : 'danger'" @click="publish(city)">
                   {{ isAnyUnpublished(city) ? '鍙戝竷' : '鍙栨秷' }}
                 </el-button>
-                <el-button size="medium" @click="jumpDetail(index)" type="info">璇︽儏</el-button>
+                <el-button size="medium" @click="jumpDetail(index)" type="primary">璇︽儏</el-button>
               </div>
             </div>
           </div>
@@ -58,29 +114,68 @@
 </template>
 
 <script>
-import { areaSelect } from '@/api/system/dept';
-import { listScore, getScore, delScore, addScore, updateScore, publishScore } from "@/api/platform/check-score";
+import {areaSelect} from '@/api/system/dept';
+import {listScore, publishScore} from "@/api/platform/check-score";
 import * as echarts from 'echarts';
+
 let observer = null;
 let chart = null;
 export default {
   name: 'index',
   data() {
     return {
+      tagOptions: [
+        {value: 0, label: '鐪佸巺'},
+        {value: 1, label: '鍖哄幙'}
+      ],
+      pickerOptions: {
+        shortcuts: [{
+          text: '绗竴瀛e害',
+          onClick(picker) {
+            picker.$emit('pick', [new Date(new Date().getFullYear() + "-01"), new Date(new Date().getFullYear() + "-03")]);
+          }
+        },
+          {
+            text: '绗簩瀛e害',
+            onClick(picker) {
+              picker.$emit('pick', [new Date(new Date().getFullYear() + "-04"), new Date(new Date().getFullYear() + "-06")]);
+            }
+          },
+          {
+            text: '绗笁瀛e害',
+            onClick(picker) {
+              picker.$emit('pick', [new Date(new Date().getFullYear() + "-07"), new Date(new Date().getFullYear() + "-09")])
+            }
+          },
+          {
+            text: '绗洓瀛e害',
+            onClick(picker) {
+              picker.$emit('pick', [new Date(new Date().getFullYear() + "-10"), new Date(new Date().getFullYear() + "-12")])
+            }
+          }]
+      },
       province: {
         id: [],
         publish: null,
+      },
+      // 瀵煎嚭琛ㄥ崟楠岃瘉
+      exportRules: {
+        quarter: [
+          { type: 'array', required: true, message: '璇烽�夋嫨鏃堕棿', trigger: 'change' }
+        ],
       },
       checkScoreList: [],
       areaList: [],
       activeIndex: '0',
       date: '',
       company: '',
-      dataList: {
-        name: ['瀵岄『鍘�', '鑽e幙', '楂樻柊鍖�', '鑷祦浜曞尯', '璐′簳鍖�', '澶у畨鍖�', '娌挎哗鍖�'],
-        data1: [95, 96, 97, 95, 94.5, 93.6, 94.5],
-        data2: [93.7, 93.5, 94.3, 96.5, 95.3, 94.2, 93.3],
-        data3: [98.3, 94.3, 93.3, 95.5, 96.8, 96.1, 95.8],
+      // 瀵煎嚭
+      exportForm: {
+        quarter: [],
+        deptIds: [],
+        examineTags: [],
+        examineCategories: [],
+        average: null,
       },
       // 鏌ヨ鍙傛暟
       queryParams: {
@@ -90,13 +185,13 @@
     }
   },
   created() {
+  },
+  mounted() {
     this.queryParams.examineTag = this.activeIndex
     this.getList();
     this.areaSelect();
-  },
-  mounted() {
     chart = echarts.init(this.$refs.barChart);
-    this.initEchart();
+    this.setChartOption(this.checkScoreList);
   },
   methods: {
     jumpDetail(index) {
@@ -126,8 +221,7 @@
         tooltip: {},
         xAxis: {
           type: 'category',
-          axisLabel: {
-          },
+          axisLabel: {},
           data: this.dataList.name
         },
         yAxis: {
@@ -138,6 +232,7 @@
             type: 'bar',
             name: '瑙嗛鑰冩牳',
             data: this.dataList.data1,
+            barWidth: '40',
             itemStyle: {
               color: 'rgba(255, 165, 0, 1)'
             }
@@ -146,6 +241,7 @@
             type: 'bar',
             name: '浜鸿劯鑰冩牳',
             data: this.dataList.data2,
+            barWidth: '40',
             itemStyle: {
               color: 'rgba(85, 192, 191, 1)'
             }
@@ -154,6 +250,7 @@
             type: 'bar',
             name: '杞﹁締鑰冩牳',
             data: this.dataList.data3,
+            barWidth: '40',
             itemStyle: {
               color: 'rgba(62, 144, 247, 1)'
             }
@@ -193,53 +290,61 @@
         tooltip: {},
         xAxis: {
           type: 'category',
-          axisLabel: {
-          },
+          axisLabel: {},
           data: nameArray
+
         },
         yAxis: {
-          min: 90,
+          min: 0
         },
         series: [
           {
             type: 'bar',
             name: '瑙嗛鑰冩牳',
             data: data1,
+            barWidth: '40',
             itemStyle: {
-              color: 'rgba(255, 165, 0, 1)'
+              color: 'rgba(255, 165, 0, 1)',
             }
           },
           {
             type: 'bar',
             name: '浜鸿劯鑰冩牳',
             data: data2,
+            barWidth: '40',
             itemStyle: {
-              color: 'rgba(85, 192, 191, 1)'
+              color: 'rgba(85, 192, 191, 1)',
             }
           },
           {
             type: 'bar',
             name: '杞﹁締鑰冩牳',
             data: data3,
+            barWidth: '40',
             itemStyle: {
-              color: 'rgba(62, 144, 247, 1)'
+              color: 'rgba(62, 144, 247, 1)',
             }
           },
         ]
       }
       chart.setOption(option, true);
     },
-    filterData(data, tag) {
-      if (!data) return;
-      if(!Array.isArray(data)) return;
+    filterData(mapData, tag) {
+      if (!mapData) return;
+      if (!Array.isArray(mapData)) return;
       const tempArray = [];
-      data.forEach((item) => {
-        if(item.data.length) {
+      mapData.forEach((item) => {
+        if (item.data.length) {
+          let flag = false;
           item.data.forEach((examine) => {
-            if(examine.examineCategory === tag) {
+            if (examine.examineCategory === tag) {
+              flag = true
               tempArray.push(examine.score);
             }
           })
+          if (!flag) {
+            tempArray.push(0);
+          }
         }
       })
       return tempArray;
@@ -259,8 +364,8 @@
       // 妫�鏌� city 鐨� score 鏁扮粍涓槸鍚︽湁浠讳綍涓�涓殑 publish 灞炴�т负 'UNPUBLISHED'
       return city.some(score => score.publish === 'UNPUBLISHED');
     },
-    formatCreateDate(dateString) {
-      const date = new Date(dateString);
+    formatCreateDate(item) {
+      const date = new Date(item.createTime);
       const year = date.getFullYear();
       const month = date.getMonth() + 1; // getMonth() 杩斿洖鐨勬湀浠芥槸浠� 0 寮�濮嬬殑锛屾墍浠ヨ鍔� 1
       const day = date.getDate();
@@ -270,6 +375,17 @@
       const formattedDay = day.toString().padStart(2, '0');
 
       return `${year}骞�${formattedMonth}鏈�${formattedDay}鍙穈;
+    },
+    filterRepeat(city) {
+      let list = [];
+      let examineCategorys = [];
+      city.forEach(item => {
+        if (examineCategorys.indexOf(item.examineCategory) === -1) {
+          examineCategorys.push(item.examineCategory);
+          list.push(item);
+        }
+      });
+      return list;
     },
     /** 瀵艰埅鍒囨崲 */
     handleSelect(key) {
@@ -283,19 +399,23 @@
       // 鑾峰彇褰撳墠鏃ユ湡
       const today = new Date();
 
-      // 璁$畻鏄ㄥぉ鐨勬棩鏈�
-      const yesterday = new Date(today);
-      yesterday.setDate(today.getDate() - 1);
+      // 灏嗘棩鏈熷噺鍘讳竴澶�
+      const yesterday = new Date(today.getTime() - 24 * 60 * 60 * 1000);
 
-      // 灏嗘槰澶╃殑鏃ユ湡鏍煎紡鍖栦负瀛楃涓诧紝杩欓噷鍋囪鍚庣鏈熸湜鐨勬槸ISO 8601鏍煎紡
-      this.queryParams.createTime = yesterday.toISOString().split('T')[0];
+      // 鑾峰彇骞淬�佹湀銆佹棩
+      const year = yesterday.getFullYear();
+      let month = (yesterday.getMonth() + 1).toString().padStart(2, '0'); // 鏈堜唤鏄粠0寮�濮嬬殑锛屾墍浠ュ姞1
+      let day = yesterday.getDate().toString().padStart(2, '0');
+
+      // 鎷兼帴鎴� yyyy-MM-dd 鏍煎紡
+      this.queryParams.createTime = `${year}-${month}-${day}`
 
       console.log(this.queryParams);
       listScore(this.queryParams).then(response => {
         this.checkScoreList = response.data;
         console.log(this.checkScoreList);
-        this.loading = false;
         this.setChartOption(this.checkScoreList);
+        this.loading = false;
       });
     },
     publish(city) {
@@ -315,6 +435,23 @@
           // 閿欒澶勭悊閫昏緫
         });
     },
+    // clickItem(value) {
+    //   value === this.exportForm.examineTag ? this.exportForm.examineTag = null : this.exportForm.examineTag = value
+    // },
+    /** 瀵煎嚭鎸夐挳鎿嶄綔 */
+    handleExport() {
+      this.$refs['exportForm'].validate((valid) => {
+        if (valid) {
+          this.download(
+            "/check/score/export",
+            {
+              ...this.exportForm,
+            },
+            `鑰冩牳鎸囨爣_${new Date().getTime()}.xlsx`
+          );
+        }
+      })
+    },
   },
 }
 </script>

--
Gitblit v1.8.0