From 2cf2125ae1fc6dc89dc0f35a960e1e45c63ae181 Mon Sep 17 00:00:00 2001
From: rjg <746338628@qq.com>
Date: Wed, 16 Apr 2025 17:57:31 +0800
Subject: [PATCH] 优化工单

---
 src/views/tickets/orderLog.vue |  117 ++++++++++++++++++++++++---------------
 src/api/tickets/orderLog.js    |   29 +++++++++
 2 files changed, 101 insertions(+), 45 deletions(-)

diff --git a/src/api/tickets/orderLog.js b/src/api/tickets/orderLog.js
index 9ccc471..4f496c2 100644
--- a/src/api/tickets/orderLog.js
+++ b/src/api/tickets/orderLog.js
@@ -50,6 +50,7 @@
   });
 };
 
+
 // 导出
 export const orderLogExport = (data) => {
   return request({
@@ -60,3 +61,31 @@
   });
 };
 
+export const jobStatusNum = () => {
+  return request({
+    url: '/drone-device-core/wayline/orderLog/jobStatusNum',
+    method: 'get'
+  });
+};
+
+
+// 草稿转发布
+export const userPublish = (id) => {
+  return request({
+    url: '/drone-device-core/wayline/orderLog/userPublish',
+    method: 'get',
+    params: { id }, 
+  });
+};
+//删除
+export const deleteOrderLog = (id) => {
+  return request({
+    url: '/drone-device-core/wayline/orderLog/deleteOrderLog',
+    method: 'get',
+    params: { id }, 
+  });
+};
+
+
+
+
diff --git a/src/views/tickets/orderLog.vue b/src/views/tickets/orderLog.vue
index 9ff71c5..bfd1c17 100644
--- a/src/views/tickets/orderLog.vue
+++ b/src/views/tickets/orderLog.vue
@@ -74,20 +74,30 @@
                         <template #menu="{ row }">
                             <div v-if="row.status == 1 && userInfo.user_id != row.create_user">
                                 <el-button type="text" icon="el-icon-view" @click="handleViewDetail(row)">审核</el-button>
+                                   <el-button type="text" icon="el-icon-view" @click="handleViewDetail(row)">详情</el-button>
                             </div>
 
                             <div v-if="userInfo.user_id == row.create_user">
                                 <!--待审核状态-->
                                 <div v-if="row.status == 1">
-                                    <el-button type="text" icon="el-icon-view"
+                                    <el-button type="text" icon="el-icon-warning-outline"
                                         @click="orderLogRecall(row.id)">撤回</el-button>
+                                    <el-button type="text" icon="el-icon-view" @click="handleViewDetail(row)">详情</el-button>
                                 </div>
                                 <!--已驳回-->
                                 <div v-if="row.status == 2">
-                                    <el-button type="text" icon="el-icon-view"
+                                    <el-button type="text" icon="el-icon-warning-outline"
                                         @click="rejectDetail(row.id)">驳回原因</el-button>
+                                        <el-button type="text" icon="el-icon-view" @click="handleViewDetail(row)">详情</el-button>
                                 </div>
-                                <el-button type="text" icon="el-icon-view" @click="handleViewDetail(row)">详情</el-button>
+                                <!--草稿-->
+                                <div v-if="row.status == 0 && userInfo.user_id == row.create_user">
+                                    <el-button type="text" icon="el-icon-edit-outline"
+                                        @click="handleViewDetail(row)">编辑</el-button>
+                                         <el-button type="text" icon="el-icon-position" @click="userPublishPush(row.id)">发布</el-button>
+                                             <el-button type="text" icon="el-icon-delete" @click="deleteOrderLog(row.id)">删除</el-button>
+                                </div>
+                             
                             </div>
                         </template>
                         <template #status="{ row }">
@@ -105,7 +115,7 @@
 
         <!-- 新建工单对话框 -->
         <el-dialog v-model="dialogVisible" title="新建工单" width="70%" :close-on-click-modal="false" @close="resetForm">
-            <el-form :model="form" :rules="rules" ref="form" label-width="100px">
+            <el-form :model="form" :rules="rules" ref="testform" label-width="100px">
                 <el-row :gutter="20">
                     <el-col :span="12">
                         <el-form-item label="工单名称" prop="name">
@@ -271,6 +281,10 @@
                         <el-button type="danger"
                             v-if="form.status == 0 || (form.status == 2 && userInfo.user_id == form.create_user)"
                             @click="submitForm(1)">发布</el-button>
+                          <el-button type="primary"
+                            v-if="form.status == 0 ||  userInfo.user_id == form.create_user"
+                            @click="submitForm(0)">保存</el-button>
+
                         <el-button type="primary" v-if="form.status == 1 && userInfo.user_id != form.create_user"
                             @click="orderLogPass(form.id)">通过</el-button>
                         <el-button type="danger" v-if="form.status == 1 && userInfo.user_id != form.create_user"
@@ -311,6 +325,9 @@
     orderLogReject,
     orderLogPass,
     orderLogExport,
+    jobStatusNum,
+    userPublish,
+    deleteOrderLog
 } from '@/api/tickets/orderLog'
 import { getTicketInfo } from '@/api/tickets/ticket'
 import { getDictionary } from '@/api/system/dictbiz'
@@ -331,10 +348,10 @@
 
             tabs: [
                 { label: '全部工单', name: 'all', value: null, count: 0 },
-                { label: '待审核', name: 'pending', value: 1, count: 0 },
-                { label: '已驳回', name: 'processing', value: 2, count: 0 },
-                { label: '已通过', name: 'inProgress', value: 3, count: 0 },
-                { label: '草稿', name: 'completed', value: 0, count: 0 },
+                { label: '待审核', name: 'WAIT_AUDIT', value: 1, count: 0 },
+                { label: '已驳回', name: 'REJECTED', value: 2, count: 0 },
+                { label: '已通过', name: 'PASS', value: 3, count: 0 },
+                { label: '草稿', name: 'DRAFT', value: 0, count: 0 },
             ],
             filters: {
                 key_word: '',
@@ -508,12 +525,10 @@
                     return item
                 })
 
-                if (this.activeTab === 'all') {
-                    this.updateGlobalCounts(records, total)
-                }
+          
 
                 this.page.total = total || 0
-                this.updateTabCounts()
+                this.updateGlobalCounts()
             } catch (error) {
                 console.error('获取数据失败:', error)
                 this.$message.error(error.message || '获取数据失败')
@@ -567,7 +582,9 @@
             this.page.pageSize = pageSize
         },
         async submitForm (status) {
-            this.$refs.form.validate(async valid => {
+            console.log(this.$refs.testform, '111111')
+            this.$refs.testform.validate(async valid => {
+                
                 if (valid) {
                     let dateRange = this.form.date_range
                     console.log('dateRange' + dateRange)
@@ -665,42 +682,26 @@
             this.page.currentPage = currentPage
         },
 
-        updateGlobalCounts (records, total) {
+        async updateGlobalCounts () {
             const counts = {
-                all: total,
-                pending: 0,
-                processing: 0,
-                inProgress: 0,
-                completed: 0,
-                closed: 0,
-                myTickets: 0,
+                all: 0,
+                DRAFT: 0,
+                WAIT_AUDIT: 0,
+                REJECTED: 0,
+                PASS: 0,
+          
             }
-
-            records.forEach(item => {
-                const tab = this.tabs.find(t => t.value === Number(item.status))
+         var reponse= await jobStatusNum(); 
+         console.log("统计"+reponse.data.data);
+            reponse.data.data.forEach(item => {
+                 const tab = this.tabs.find(t => t.name === item.dict_key);
                 if (tab) {
-                    counts[tab.name] = (counts[tab.name] || 0) + 1
+                    tab.count=item.num;
                 }
-            })
+            });
 
-            this.globalCounts = counts
         },
 
-        updateTabCounts () {
-            if (this.activeTab === 'all') {
-                this.tabs.forEach(tab => {
-                    tab.count = this.globalCounts[tab.name] || 0
-                })
-            } else {
-                this.tabs.forEach(tab => {
-                    if (tab.name === this.activeTab) {
-                        tab.count = this.tableData.length
-                    } else {
-                        tab.count = this.globalCounts[tab.name] || 0
-                    }
-                })
-            }
-        },
 
         handleAdd () {
             this.form = {}
@@ -720,8 +721,8 @@
                 content: '',
                 photos: [],
             }
-            if (this.$refs.form) {
-                this.$refs.form.resetFields()
+            if (this.$refs.testform) {
+                this.$refs.testform.resetFields()
             }
         },
 
@@ -758,7 +759,33 @@
                 })
             })
         },
+        //自己点发布
+           userPublishPush (id) {
+            this.$confirm('确定发布吗?', '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning',
+            }).then(() => {
+                  let response= userPublish(id);
+                  this.$message.success('发布成功');
+                  this.fetchTableData();
 
+            })
+        },
+
+    //删除
+    deleteOrderLog(id){
+        this.$confirm('确定删除吗?', '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning',
+            }).then(() => {
+                  let response= deleteOrderLog(id);
+                  this.$message.success('删除');
+                  this.fetchTableData();
+
+            })
+    },
         refreshChange () {
             this.fetchTableData()
         },
@@ -866,7 +893,7 @@
     watch: {
         tableData: {
             handler () {
-                this.updateTabCounts()
+                // this.updateTabCounts()
             },
             deep: true,
         },

--
Gitblit v1.9.3