Pārlūkot izejas kodu

修复 月份选择问题

liling 3 mēneši atpakaļ
vecāks
revīzija
f601bea3aa
1 mainītis faili ar 24 papildinājumiem un 5 dzēšanām
  1. 24 5
      src/views/emp/stat/index.vue

+ 24 - 5
src/views/emp/stat/index.vue

@@ -4,7 +4,7 @@
             <el-form-item label="时间" prop="empDate" style="margin-top: 18px;">
                 <el-date-picker clearable
                                 v-model="queryParams.empDate"
-                                type="date"
+                                type="month"
                                 value-format="YYYY-MM"
                                 placeholder="请选择月份">
                 </el-date-picker>
@@ -104,11 +104,11 @@
     }
 </style>
 <script setup name="Emp">
-    import {ref} from "vue";    
+    import {ref,reactive} from "vue";    
     import { ElMessage } from 'element-plus';
     import {monthCalc} from "@/api/emp/empCalc";
     import * as echarts from 'echarts';
-    const queryParams=ref({});
+    let queryParams=reactive({empDate:''});
     const price_echarts_line=ref(null);
     const efficiency_echarts_line=ref(null);
     const lenght_echarts_line=ref(null);
@@ -118,17 +118,30 @@
     let empToplist =ref([]);
 
     function init(){
-        queryParams.value={empDate:new Date().Format('yyyy-MM')}
+        queryParams.empDate=new Date().Format('yyyy-MM');
+        getData();
+    }
+
+    /** 搜索按钮操作 */
+    function handleQuery() {
         getData();
     }
 
     function getData(){
+        if(queryParams.empDate==null || queryParams.empDate==''){
+            let msg = ElMessage({
+                message: "请选择月份!",
+                type: "error",
+            })
+            return;
+        }
         let msg = ElMessage({
                     message: "正在查询数据中...",
                     type: "info",
                     duration:0,
         })
-        monthCalc(queryParams.value.empDate).then((res)=>{
+        console.log('queryParams.value.empDate:',queryParams.empDate)
+        monthCalc(queryParams.empDate).then((res)=>{
             msg.close();
             if(res.code!=200){
                 ElMessage({
@@ -151,6 +164,12 @@
             empToplist.value = tmpLst;
             loadLine(res.data.trend);
             load4(res.data.trend);
+        }).catch(()=>{
+            msg.close();
+            ElMessage({
+                    message: "数据查询时发生错误!",
+                    type: "error"
+            })
         })
     }