From 0dac7ba33f77342d2a9a1392c820d10d3b72d76c Mon Sep 17 00:00:00 2001
From: Your Name <123456>
Date: 星期三, 28 九月 2022 16:02:47 +0800
Subject: [PATCH] '修改'

---
 src/views/intellectInspect/inspectTaskManage/inspectTask/index.vue |   60 +++++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/src/views/intellectInspect/inspectTaskManage/inspectTask/index.vue b/src/views/intellectInspect/inspectTaskManage/inspectTask/index.vue
index 9dc80c7..d897b89 100644
--- a/src/views/intellectInspect/inspectTaskManage/inspectTask/index.vue
+++ b/src/views/intellectInspect/inspectTaskManage/inspectTask/index.vue
@@ -23,7 +23,7 @@
                 <div class="main-card">
                     <el-row class="cardTop">
                         <el-col :span="12" class="mainCardBtn">
-                            <el-button type="primary" :icon="Plus" size="default" @click="openInspectTaskDialog('新增', {})">新建</el-button>
+                            <el-button type="primary" :icon="Plus" size="default" @click="openInspectTaskDialog('新增', {})">新增</el-button>
                             <!--                            <el-button type="danger" :icon="Delete" size="default" plain>删除</el-button>-->
                         </el-col>
                         <el-button type="primary" :icon="Refresh" size="default" />
@@ -80,12 +80,27 @@
                         <el-table-column prop="gmtCreate" label="创建时间" show-overflow-tooltip></el-table-column>
                         <el-table-column prop="lastEditUserName" label="最后修改人" show-overflow-tooltip></el-table-column>
                         <el-table-column prop="gmtModitify" label="最后修改时间" show-overflow-tooltip></el-table-column>
-                        <el-table-column property="status" label="状态" width="60" />
+                        <el-table-column property="taskUnitStatus" label="状态" width="60">
+                            <template #default="scope">
+                                <div>
+                                    <div v-if="scope.row.taskUnitStatus === 1">
+                                        <el-tag :type="''">
+                                            {{ '开启' }}
+                                        </el-tag>
+                                    </div>
+                                    <div v-if="scope.row.taskUnitStatus === 2">
+                                        <el-tag :type="'danger'">
+                                            {{ '关闭' }}
+                                        </el-tag>
+                                    </div>
+                                </div>
+                            </template>
+                        </el-table-column>
                         <el-table-column fixed="right" label="操作" align="center" width="300">
                             <template #default="scope">
                                 <el-button link type="primary" size="small" :icon="View" @click="openInspectTaskDialog('查看', scope.row)">查看</el-button>
                                 <el-button link type="primary" size="small" :icon="Edit" @click="openInspectTaskDialog('修改', scope.row)">修改</el-button>
-                                <el-button link type="danger" size="small" :icon="Delete" @click="deleteInspectTask(scope.$index)">删除</el-button>
+                                <el-button link type="danger" size="small" :icon="Delete" v-if="scope.row.taskUnitStatus === 2" @click="deleteInspectTask(scope.row)">删除</el-button>
                                 <div @click="changeStatus(scope.row)">
                                     <el-switch v-model="scope.row.taskUnitStatus" inline-prompt active-text="开" inactive-text="关" :active-value="1" :inactive-value="2" style="margin: 0 10px" />
                                 </div>
@@ -175,8 +190,8 @@
                 }
             },
             workTypeList: [
-                { id: 1, name: '日常任务' },
-                { id: 2, name: '周期任务' }
+                { id: 1, name: '周期任务' },
+                { id: 2, name: '单次任务' }
             ],
             quotaList: [],
             departmentList: [],
@@ -295,6 +310,7 @@
                     .then(async () => {
                         let res = await inspectTaskApi().openOrCloseInspectTask({ id: value.id, taskUnitStatus: 2 });
                         if (res.data.code === '200') {
+                            await getInspectionTask();
                             ElMessage({
                                 type: 'success',
                                 duration: 2000,
@@ -307,9 +323,7 @@
                             });
                         }
                     })
-                    .catch((error) => {
-                        debugger;
-                    });
+                    .catch((error) => {});
             } else {
                 ElMessageBox.confirm(`此操作将开启该巡检任务”,是否继续?`, '提示', {
                     confirmButtonText: '确认',
@@ -319,6 +333,7 @@
                     .then(async () => {
                         let res = await inspectTaskApi().openOrCloseInspectTask({ id: value.id, taskUnitStatus: 1 });
                         if (res.data.code === '200') {
+                            await getInspectionTask();
                             ElMessage({
                                 type: 'success',
                                 duration: 2000,
@@ -334,6 +349,32 @@
                     .catch((error) => {});
             }
             await getInspectionTask();
+        };
+
+        // 删除
+        const deleteInspectTask = (row: any) => {
+            ElMessageBox.confirm(`此操作将永久删除该任务:“${row.unitName}”,是否继续?`, '提示', {
+                confirmButtonText: '确认',
+                cancelButtonText: '取消',
+                type: 'warning'
+            })
+                .then(async () => {
+                    let res = await inspectTaskApi().deleteInspectTask({ id: row.id });
+                    if (res.data.code === '200') {
+                        ElMessage({
+                            type: 'success',
+                            duration: 2000,
+                            message: '删除成功'
+                        });
+                        await getInspectionTask();
+                    } else {
+                        ElMessage({
+                            type: 'warning',
+                            message: res.data.msg
+                        });
+                    }
+                })
+                .catch(() => {});
         };
 
         const openInspectTaskDialog = (type: string, value: {}) => {
@@ -394,6 +435,7 @@
             reset,
             changeStatus,
             parseNumber,
+            deleteInspectTask,
             getInspectionTask,
             onHandleSizeChange,
             onHandleCurrentChange,
@@ -408,7 +450,7 @@
 <style scoped lang="scss">
 $homeNavLengh: 8;
 .home-container {
-    height: calc(100vh - 114px);
+    height: calc(100vh - 144px);
     box-sizing: border-box;
     overflow: hidden;
     .homeCard {

--
Gitblit v1.9.2