From 3517c8c68d8439796adff77193b82a01ad7b11b2 Mon Sep 17 00:00:00 2001
From: rjg <746338628@qq.com>
Date: Thu, 17 Apr 2025 11:30:19 +0800
Subject: [PATCH] Merge branch 'master' of http://139.196.74.78:10010/r/drone/drone-web-manage

---
 src/views/tickets/ticket.vue   |   11 ++
 src/views/tickets/orderLog.vue |  187 +++++++++++++++++++++++++---------------------
 2 files changed, 114 insertions(+), 84 deletions(-)

diff --git a/src/views/tickets/orderLog.vue b/src/views/tickets/orderLog.vue
index 63a41d9..f44d508 100644
--- a/src/views/tickets/orderLog.vue
+++ b/src/views/tickets/orderLog.vue
@@ -11,7 +11,7 @@
 <template>
     <basic-container>
         <el-tabs v-model="activeTab" @tab-click="handleTabChange">
-            <el-tab-pane v-for="tab in tabs" :key="tab.name" :label="`${tab.label} (${tab.count})`" :name="tab.name">
+            <el-tab-pane v-for="tab in filteredTabs" :key="tab.name" :label="`${tab.label} (${tab.count})`" :name="tab.name">
                 <div class="tab-content">
                     <!-- 查询条件筛选栏 -->
                     <div class="filter-bar">
@@ -67,14 +67,14 @@
                         :table-loading="loading" @current-change="currentChange" @refresh-change="refreshChange"
                         @on-load="onLoad" @search-change="searchChange" @size-change="sizeChange">
                         <template #menu-left>
-                            <el-button type="primary" icon="el-icon-plus" v-if="activeTab!='WAIT_AUDIT' ">新建工单</el-button>
+                            <el-button v-if="hasAddBtnPermission()" type="primary" icon="el-icon-plus" v-if="activeTab!='WAIT_AUDIT' ">新建工单</el-button>
                             <el-button type="success" plain icon="el-icon-download" @click="exportData">导出</el-button>
                         </template>
 
                         <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>
+                                <el-button v-if="hasPaddingBtnPermission()" 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">
@@ -82,28 +82,27 @@
                                 <div v-if="row.status == 1">
                                     <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>
+                                    <el-button type="text" icon="el-icon-view"
+                                        @click="handleViewDetail(row)">详情</el-button>
                                 </div>
-                                   </div>
-                                <!--已驳回-->
-                                <div v-if="row.status == 2">
-                                    <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>
-                                   <div v-if="row.status == 3">
-                    
-                                        <el-button type="text" icon="el-icon-view" @click="handleViewDetail(row)">详情</el-button>
-                                </div>
-                                <!--草稿-->
-                                <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>
+                            <!--已驳回-->
+                            <div v-if="row.status == 2">
+                                <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>
+                            <!--草稿-->
+                            <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>
+
+
                         </template>
                         <template #status="{ row }">
                             <el-tag :type="getStatusTagType(row.status)">{{ mapStatus(row.status) }}</el-tag>
@@ -288,8 +287,7 @@
                         <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"
+                        <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"
@@ -349,7 +347,7 @@
 
 export default {
     name: 'TicketPage',
-    data () {
+    data() {
         return {
             activeTab: 'all',
 
@@ -453,7 +451,7 @@
             mapLoaded: false,
         }
     },
-    async created () {
+    async created() {
         var response = await getDictionary({ code: 'SF' })
         var word_order_typeResponse = await getDictionary({ code: 'WORK_ORDER_TYPE' })
         this.ai_types = response.data.data
@@ -467,15 +465,28 @@
             value: item.id,
         }))
     },
-    mounted () {
+    mounted() {
         this.fetchTableData()
     },
     computed: {
-        ...mapGetters(['userInfo']),
+        ...mapGetters(['userInfo', 'permission']),
+        filteredTabs() {
+            // rejection_and_draft 权限控制“已驳回”和“草稿”tab
+            const canShowRejectAndDraft = this.permission?.rejection_and_draft === true;
+            return this.tabs.map(tab => {
+                if (tab.name === 'DRAFT') {
+                    return { ...tab, isShow: canShowRejectAndDraft };
+                }
+                if (tab.name === 'REJECTED') {
+                    return { ...tab, isShow: canShowRejectAndDraft };
+                }
+                return { ...tab, isShow: true };
+            }).filter(tab => tab.isShow);
+        },
     },
 
     methods: {
-        searchChange (params, done) {
+        searchChange(params, done) {
             console.log('searchChange')
             this.query = params
             this.parentId = ''
@@ -483,7 +494,7 @@
             this.onLoad(this.page, params)
             done()
         },
-        async onLoad (page, params = {}) {
+        async onLoad(page, params = {}) {
             this.loading = true
             getList(
                 null,
@@ -498,11 +509,11 @@
 
 
         },
-        selectionClear () {
+        selectionClear() {
             this.selectionList = []
             this.$refs.crud.toggleSelection()
         },
-        async loadAMapScripts () {
+        async loadAMapScripts() {
             try {
                 // await loadAMap();
                 // await loadAMapUI();
@@ -512,12 +523,12 @@
                 this.$message.error('地图加载失败,请检查网络或API Key配置')
             }
         },
-        formatCycleTime (row) {
+        formatCycleTime(row) {
             return row.begin_time + '-' + row.end_time + '<br/>'
                 + row.rep_rule_type + row.rep_rule_val
         },
 
-        async fetchTableData () {
+        async fetchTableData() {
             this.loading = true
             try {
                 let params = this.getQueryParam()
@@ -532,8 +543,8 @@
                     return item
                 })
 
-          
 
+                console.log('权限检查:', this.permission);
                 this.page.total = total || 0
                 this.updateGlobalCounts()
             } catch (error) {
@@ -546,7 +557,7 @@
             }
         },
 
-        getQueryParam () {
+        getQueryParam() {
             const currentTab = this.tabs.find(tab => tab.name === this.activeTab)
             if (this.filters.dateRange) {
                 console.log(
@@ -585,13 +596,13 @@
             }
             return params
         },
-        sizeChange (pageSize) {
+        sizeChange(pageSize) {
             this.page.pageSize = pageSize
         },
-        async submitForm (status) {
+        async submitForm(status) {
             console.log(this.$refs.testform, '111111')
             this.$refs.testform.validate(async valid => {
-                
+
                 if (valid) {
                     let dateRange = this.form.date_range
                     console.log('dateRange' + dateRange)
@@ -618,7 +629,7 @@
             })
         },
         //驳回原因显示
-        async rejectDetail (id) {
+        async rejectDetail(id) {
             const response = await orderLogDetails(id)
             let data = response.data.data
             this.$confirm(data.remark, '驳回原因', {
@@ -632,7 +643,7 @@
                 this.detailVisible = true
             })
         },
-        formatDate (date) {
+        formatDate(date) {
             if (!date) return undefined
             const d = new Date(date)
             return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(
@@ -640,7 +651,7 @@
             ).padStart(2, '0')} 00:00:00`
         },
 
-        mapStatus (status) {
+        mapStatus(status) {
             const statusTextMap = {
                 0: '草稿',
                 1: '待审核',
@@ -650,7 +661,7 @@
             return statusTextMap[status] || '未知状态'
         },
 
-        getStatusTagType (status) {
+        getStatusTagType(status) {
             const statusMap = {
                 1: 'warning',
                 2: 'info',
@@ -661,20 +672,19 @@
             return statusMap[status] || 'info'
         },
 
-        handleTabChange (tab) {
-            this.activeTab = tab.props?.name || tab.name;
-            this.filters.status = ''
+        handleTabChange(tab) {
+            this.activeTab = tab.props?.name || tab.name
             this.filters.status = ''
             this.page.currentPage = 1
             this.fetchTableData()
         },
 
-        handleSearch () {
+        handleSearch() {
             this.page.currentPage = 1
             this.fetchTableData()
         },
 
-        handleReset () {
+        handleReset() {
             this.filters = {
                 keyword: '',
                 department: '',
@@ -686,39 +696,39 @@
             this.fetchTableData()
         },
 
-        currentChange (currentPage) {
+        currentChange(currentPage) {
             this.page.currentPage = currentPage
         },
 
-        async updateGlobalCounts () {
+        async updateGlobalCounts() {
             const counts = {
                 all: 0,
                 DRAFT: 0,
                 WAIT_AUDIT: 0,
                 REJECTED: 0,
                 PASS: 0,
-          
+
             }
-         var reponse= await jobStatusNum(); 
-         console.log("统计"+reponse.data.data);
+            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);
+                const tab = this.tabs.find(t => t.name === item.dict_key);
                 if (tab) {
-                    tab.count=item.num;
+                    tab.count = item.num;
                 }
             });
 
         },
 
 
-        handleAdd () {
+        handleAdd() {
             this.form = {}
             this.dialogVisible = true
             //航线列表
             this.asyncgetWaylineFileListByArea()
         },
 
-        resetForm () {
+        resetForm() {
             this.form = {
                 name: '',
                 type: '',
@@ -734,14 +744,13 @@
             }
         },
 
-        formatLocation (location) {
+        formatLocation(location) {
             if (!Array.isArray(location)) {
                 return '未知位置'
             }
             return `${location[0].toFixed(6)}, ${location[1].toFixed(6)}`
         },
-
-        async handleViewDetail (row) {
+        async handleViewDetail(row) {
             const response = await orderLogDetails(row.id)
             this.form = {
                 ...response.data.data,
@@ -753,7 +762,7 @@
             this.device_sns = response.data.data.deviceList
         },
         //导出
-        async exportData () {
+        async exportData() {
             this.$confirm('是否智飞工单数据?', '提示', {
                 confirmButtonText: '确定',
                 cancelButtonText: '取消',
@@ -767,45 +776,55 @@
                 })
             })
         },
+        hasAddBtnPermission() {
+            // undefined 或 false 都返回 false,只有 true 返回 true
+            console.log('this.permission.order_log_add :', this.permission.order_log_add );
+            return this.permission && this.permission.order_log_add === true;
+        },
+        hasPaddingBtnPermission() {
+            // undefined 或 false 都返回 false,只有 true 返回 true
+            console.log('权限检查:', this.permission);
+            return this.permission && this.permission.order_log_review === true;
+        },
         //自己点发布
-           userPublishPush (id) {
+        userPublishPush(id) {
             this.$confirm('确定发布吗?', '提示', {
                 confirmButtonText: '确定',
                 cancelButtonText: '取消',
                 type: 'warning',
             }).then(() => {
-                  let response= userPublish(id);
-                  this.$message.success('发布成功');
-                  this.fetchTableData();
+                let response = userPublish(id);
+                this.$message.success('发布成功');
+                this.fetchTableData();
 
             })
         },
 
-    //删除
-    deleteOrderLog(id){
-        this.$confirm('确定删除吗?', '提示', {
+        //删除
+        deleteOrderLog(id) {
+            this.$confirm('确定删除吗?', '提示', {
                 confirmButtonText: '确定',
                 cancelButtonText: '取消',
                 type: 'warning',
             }).then(() => {
-                  let response= deleteOrderLog(id);
-                  this.$message.success('删除');
-                  this.fetchTableData();
+                let response = deleteOrderLog(id);
+                this.$message.success('删除');
+                this.fetchTableData();
 
             })
-    },
-        refreshChange () {
+        },
+        refreshChange() {
             this.fetchTableData()
         },
         //获取航线列表
-        async asyncgetWaylineFileListByArea (name) {
+        async asyncgetWaylineFileListByArea(name) {
             var wayLineListResponse = await getWaylineFileListByArea(this.userInfo.detail.areaCode)
             this.wayLineList = wayLineListResponse.data.data
 
             this.initMapLine()
         },
 
-        initMapLine () {
+        initMapLine() {
             let currentLine = this.wayLineList.find(item => item.wayline_id == this.form.file_id)
 
             if (!currentLine) return
@@ -847,7 +866,7 @@
 
 
         //可飞行机巢列表
-        async getFlyingNestBy (waylineId) {
+        async getFlyingNestBy(waylineId) {
             this.initMapLine()
 
             //按照航线来
@@ -860,7 +879,7 @@
         },
 
         //撤回
-        async orderLogRecall (id) {
+        async orderLogRecall(id) {
             this.$confirm('确定撤回则到草稿箱。', '是否撤回?', {
                 confirmButtonText: '确定',
                 cancelButtonText: '取消',
@@ -870,13 +889,13 @@
                 this.handleSearch()
             })
         },
-        onLoad () {
+        onLoad() {
             this.fetchTableData()
         },
         /**
          * 通过
          */
-        async orderLogPass (id) {
+        async orderLogPass(id) {
             let response = await orderLogPass(id)
             let data = response.data.data
             this.$message.success('审核通过')
@@ -885,7 +904,7 @@
         /**
          * 驳回
          */
-        async orderLogReject (id) {
+        async orderLogReject(id) {
             this.$prompt('', '驳回原因', {
                 confirmButtonText: '确定',
                 cancelButtonText: '取消',
@@ -900,7 +919,7 @@
 
     watch: {
         tableData: {
-            handler () {
+            handler() {
                 // this.updateTabCounts()
             },
             deep: true,
diff --git a/src/views/tickets/ticket.vue b/src/views/tickets/ticket.vue
index a2d1ccf..7fdc901 100644
--- a/src/views/tickets/ticket.vue
+++ b/src/views/tickets/ticket.vue
@@ -446,6 +446,7 @@
   name: "TicketPage",
   data() {
     return {
+      submitLoading: false, // 新增loading状态
       activeTab: "all",
       // tabs 只保留静态结构,不做权限判断
       tabs: [
@@ -965,6 +966,8 @@
     },
 
     async submitForm() {
+      if (this.submitLoading) return; // 防止重复提交
+      this.submitLoading = true;
       try {
         // 提交时需要完整验证
         await this.$refs.form.validate();
@@ -1021,9 +1024,14 @@
           this.$message.error(error.message || '工单创建失败,请稍后重试');
         }
       }
+      finally {
+      this.submitLoading = false;
+    }
     },
 
     async saveDraft() {
+      if (this.submitLoading) return; // 防止重复提交
+      this.submitLoading = true;
       try {
         const submitData = {
           id: this.form.id,
@@ -1067,6 +1075,9 @@
       } catch (error) {
         this.$message.error(error.message || '保存草稿失败,请稍后重试');
       }
+      finally {
+      this.submitLoading = false;
+    }
     },
 
     async handleLocationChange(val) {

--
Gitblit v1.9.3