From cca8d423c4805665bbd48a47e4d9218b16d14ebb Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期五, 28 三月 2025 17:42:35 +0800
Subject: [PATCH] 新增自动评估监测数据上传功能(待完成)

---
 src/views/fysp/task/TaskManage.vue |  104 +++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 87 insertions(+), 17 deletions(-)

diff --git a/src/views/fysp/task/TaskManage.vue b/src/views/fysp/task/TaskManage.vue
index 68efe34..f844b5e 100644
--- a/src/views/fysp/task/TaskManage.vue
+++ b/src/views/fysp/task/TaskManage.vue
@@ -39,24 +39,29 @@
           <el-tabs model-value="first">
             <el-tab-pane label="鐩戠璁″垝" name="first">
               <el-row>
-                <el-col :span="curSubTaskList.length > 0 ? 16 : 24">
+                <el-col :span="curSubTaskList ? 16 : 24">
                   <CompMonitorPlan
+                    ref="planRef"
                     :task="curTask.data"
                     @date-change="onDateChange"
                   ></CompMonitorPlan>
                 </el-col>
-                <el-col v-if="curSubTaskList.length > 0" :span="8">
+                <el-col v-if="curSubTaskList" :span="8">
                   <CompSubTaskList
-                    :data="curSubTaskList"
+                    create
+                    v-model="curSubTaskList"
+                    :loading="subTaskLoading"
+                    :create-loading="daytaskLoading"
                     height="56vh"
-                    @add="subTaskDrawer = true"
+                    @add="handleAddSubtask"
+                    @submit="handleSubtaskSubmit"
                   ></CompSubTaskList>
                 </el-col>
               </el-row>
             </el-tab-pane>
-            <el-tab-pane label="鐩戠鍦板浘" name="second">
+            <!-- <el-tab-pane label="鐩戠鍦板浘" name="second">
               <CompTaskMap></CompTaskMap>
-            </el-tab-pane>
+            </el-tab-pane> -->
           </el-tabs>
         </el-row>
         <el-divider></el-divider>
@@ -91,6 +96,7 @@
     <CompDayTask
       :day-task="curDayTask"
       :mObjList="curMonitorObjList"
+      @submit="handleSubtaskSubmit"
     ></CompDayTask>
   </el-drawer>
   <el-dialog
@@ -110,6 +116,9 @@
 </template>
 
 <script>
+import { unref } from 'vue';
+import { useCloned } from '@vueuse/core';
+import dayjs from 'dayjs';
 import taskApi from '@/api/fysp/taskApi';
 import CompMonitorObj from './components/CompMonitorObj.vue';
 import CompMonitorPlan from './components/CompMonitorPlan.vue';
@@ -176,10 +185,18 @@
       subTaskDrawer: false,
       // 褰撳墠閫夋嫨鐨勬棩浠诲姟
       curDayTask: {},
+      curDay: undefined,
+      daytaskLoading: false,
       // 褰撳墠閫夋嫨鐨勬棩浠诲姟涓嬬殑瀛愪换鍔�
-      curSubTaskList: [],
+      curSubTaskList: undefined,
+      subTaskLoading: false,
       // 鎬讳换鍔℃柊澧炲脊鍑烘
       topTaskAddVisible: false
+    };
+  },
+  provide() {
+    return {
+      topTask: this.curTask
     };
   },
   computed: {
@@ -223,10 +240,10 @@
           type = 0;
           break;
         case '姝e湪鎵ц':
-          type = 1;
+          type = 5;
           break;
         case '宸茬粨鏉�':
-          type = 2;
+          type = 6;
           break;
         default:
           type = 0;
@@ -238,12 +255,12 @@
       this.task = task;
       this.sideLoading = false;
       this.mainLoading = true;
-      this.curSubTaskList = []
+      this.curSubTaskList = undefined;
+      this.curTask = task;
       taskApi
         .fetchMonitorObjectVersion(task.data.tguid)
         .then((res) => {
           this.curMonitorObjList = res;
-          this.curTask = task;
         })
         .finally(() => {
           this.mainLoading = false;
@@ -267,12 +284,22 @@
         }
       });
     },
-    onDateChange(dayTask) {
-      // this.subTaskDrawer = true;
-      this.curDayTask = dayTask;
-      taskApi.fetchSubtaskByDayTask(dayTask.guid).then((res) => {
-        this.curSubTaskList = res;
-      });
+    onDateChange(dayTask, day) {
+      this.curDay = day;
+      if (dayTask) {
+        this.subTaskLoading = true;
+        // this.subTaskDrawer = true;
+        this.curDayTask = dayTask;
+        taskApi
+          .fetchSubtaskByDayTask(dayTask.guid)
+          .then((res) => {
+            this.curSubTaskList = res;
+          })
+          .finally(() => (this.subTaskLoading = false));
+      } else {
+        this.curSubTaskList = [];
+        this.curDayTask = {};
+      }
     },
     navToTaskCreate(value) {
       this.topTaskAddVisible = false;
@@ -282,6 +309,49 @@
           task: encodeURIComponent(JSON.stringify(value))
         }
       });
+    },
+    handleSubtaskSubmit() {
+      this.subTaskLoading = true;
+      this.$refs.planRef
+        .fetchDayTasks()
+        .finally(() => (this.subTaskLoading = false));
+    },
+    handleAddSubtask() {
+      // 鍒ゆ柇褰撴棩鏄惁鏈夋棩浠诲姟锛岃嫢娌℃湁锛屽厛鍒涘缓鍦ㄨ烦杞瓙浠诲姟鍒涘缓鐣岄潰
+      if (this.curDayTask.guid) {
+        this.subTaskDrawer = true;
+      } else {
+        const _dayTask = useCloned(this.curTask.data).cloned.value;
+        const taskDate = dayjs(this.curDay);
+        _dayTask.tsguid = _dayTask.tguid;
+        _dayTask.tguid = null;
+        _dayTask.levelnum = null;
+        _dayTask.name = `${taskDate.format('YYYY骞碝M鏈圖D鏃�')}${
+          _dayTask.cityname
+        }${_dayTask.districtname}${_dayTask.typename}浠诲姟`;
+        _dayTask.starttime = taskDate.startOf('day').toDate();
+        _dayTask.endtime = taskDate.endOf('day').millisecond(0).toDate();
+        _dayTask.settime = dayjs().toDate();
+        _dayTask.t1stverifytime = dayjs().toDate();
+        _dayTask.runingstatus = '鏈墽琛�';
+        this.daytaskLoading = true;
+        taskApi
+          .putTask(_dayTask)
+          .then((res) => {
+            this.curDayTask = {
+              guid: res.data.tguid,
+              tsGuid: res.data.tsguid,
+              changedTaskNum: 0,
+              check: true,
+              completeTaskNum: 0,
+              date: res.data.starttime,
+              totalTaskNum: 0
+            };
+            this.subTaskDrawer = true;
+            this.handleSubtaskSubmit();
+          })
+          .finally(() => (this.daytaskLoading = false));
+      }
     }
   },
   mounted() {

--
Gitblit v1.9.3