Kaynağa Gözat

feat(attendance): 添加上下班打卡按钮状态查询功能

fix(attendance): 修复人员选择数据字段错误问题
fix(checklist): 修正不合格项人员名称空格处理
fix(attendance): 调整上通道按钮禁用逻辑
feat(attendance): 增加考勤权限控制功能
fix(checklist): 完善表单验证字段和规则
fix(attendance): 优化维护区域/人员弹窗交互
fix(seizedReport): 修正查获位置和班组显示问题
fix(config): 更新接口地址配置
huoyi 4 ay önce
ebeveyn
işleme
b402352568

+ 8 - 0
src/api/attendance/attendance.js

@@ -105,3 +105,11 @@ export function queryLastTime (data) {
105 105
     data: data
106 106
   })
107 107
 }
108
+
109
+//查询上班打卡和下班打卡是否可以点击
110
+export function queryClickAble () {
111
+  return request({
112
+    url: '/attendance/v1/getRecordType',
113
+    method: 'get',
114
+  })
115
+}

+ 2 - 2
src/config.js

@@ -1,11 +1,11 @@
1 1
 // 应用全局配置
2 2
 module.exports = {
3 3
    // 接口地址  本地调试使用 http://192.168.3.222:38080  打包使用 /prod-api
4
-  //  baseUrl: process.env.NODE_ENV === 'development' ? 'http://192.168.3.221:82/prod-api' : '/prod-api', //生产
4
+ // baseUrl: process.env.NODE_ENV === 'development' ? 'http://192.168.3.221:82/prod-api' : '/prod-api', //生产
5 5
   //  baseUrl: process.env.NODE_ENV === 'development' ? 'http://192.168.3.221:8080' : '/prod-api',
6 6
 // baseUrl: process.env.NODE_ENV === 'development' ? 'http://guangxi.qinghe.sundot.cn:8088' : 'http://guangxi.qinghe.sundot.cn:8088/prod-api',
7 7
 // baseUrl: 'http://guangxi.qinghe.sundot.cn:8088',
8
-   baseUrl:'http://airport.samsundot.com:9021/prod-api',
8
+     baseUrl:'http://airport.samsundot.com:9021/prod-api',
9 9
   // 应用信息
10 10
   appInfo: {
11 11
     // 应用名称

+ 1 - 1
src/pages/attendance/components/AddAttendancePersonnelModal.vue

@@ -217,7 +217,7 @@ export default {
217 217
               attendanceDate: moment().format('YYYY-MM-DD')
218 218
             }).then(res => {
219 219
               console.log(res.rows, "res.rows")
220
-              this.selectedUser = res.rows || []
220
+              this.selectedUser = res.data || []
221 221
 
222 222
             })
223 223
             return

+ 21 - 4
src/pages/attendance/components/AttendanceControl.vue

@@ -1,7 +1,7 @@
1 1
 <template>
2 2
   <view>
3 3
     <view class="attendance-control">
4
-      <view class="control-btn" :class="{ disable: !result }" @click="clockIn(1)">
4
+      <view class="control-btn" :class="{ disable: !result || checkAbleType != '1' }" @click="clockIn(1)">
5 5
         <text class="control-btn-text">上班打卡</text>
6 6
       </view>
7 7
       <view class="attendance-info">
@@ -24,7 +24,7 @@
24 24
           </view>
25 25
         </view>
26 26
       </view>
27
-      <view class="control-btn" :class="{ disable: !result }" @click="clockIn(2)">
27
+      <view class="control-btn" :class="{ disable: !result || checkAbleType != '2' }" @click="clockIn(2)">
28 28
         <text class="control-btn-text">下班打卡</text>
29 29
       </view>
30 30
     </view>
@@ -47,6 +47,7 @@
47 47
 
48 48
 <script>
49 49
 import { isInRangeOptimized, wgs84ToGcj02 } from '@/utils/handler'
50
+import { queryClickAble } from '@/api/attendance/attendance'
50 51
 export default {
51 52
   props: {
52 53
     attendanceInfo: {
@@ -66,6 +67,7 @@ export default {
66 67
   data() {
67 68
     return {
68 69
       result: null,
70
+      checkAbleType: null,
69 71
       position: {
70 72
         latitude: 0,
71 73
         longitude: 0,
@@ -73,8 +75,15 @@ export default {
73 75
     }
74 76
   },
75 77
   watch: {
78
+    attendanceInfo: {
79
+      handler(newValue) {
80
+        this.getCheckAbleType()
81
+      },
82
+      deep: true
83
+    },
76 84
     checkInPosiInfo(newValue) {
77 85
       if (newValue && newValue.length) {
86
+        this.getCheckAbleType()
78 87
         if (window.android && typeof window.android.getLocation === 'function') {
79 88
           window.android.getLocation()
80 89
         } else {
@@ -86,9 +95,10 @@ export default {
86 95
     }
87 96
   },
88 97
   mounted() {
98
+    this.getCheckAbleType()
89 99
     // app 在前台时获取位置信息
90 100
     uni.onLocationChange((res) => {
91
-   
101
+
92 102
       const [latitude, longitude] = wgs84ToGcj02(res.latitude, res.longitude);
93 103
 
94 104
       this.result = this.checkInPosiInfo.find(item => {
@@ -100,7 +110,7 @@ export default {
100 110
     // 暴露回调给原生外壳
101 111
     window.locationCallBack = (res) => {
102 112
       let resPositionInfo = JSON.parse(res)
103
-
113
+      this.getCheckAbleType()
104 114
       const [latitude, longitude] = wgs84ToGcj02(resPositionInfo.latitude, resPositionInfo.longitude);
105 115
       this.position = {
106 116
         latitude: latitude,
@@ -117,6 +127,13 @@ export default {
117 127
     this.removeEvent()
118 128
   },
119 129
   methods: {
130
+    //获取考勤权限
131
+    getCheckAbleType() {
132
+      queryClickAble().then(res => {
133
+        this.checkAbleType = res.data
134
+
135
+      })
136
+    },
120 137
     clockIn(type) {
121 138
       if (!this.result) return uni.showToast({ title: '当前未进入考勤范围!', icon: 'none' })
122 139
       this.$emit('attendanceHandler', type, this.result)

+ 42 - 17
src/pages/attendance/components/MaintainAreaOrMemberModal.vue

@@ -21,7 +21,8 @@
21 21
                     </view>
22 22
                 </view>
23 23
             </view>
24
-            <view v-else class="custom-btn" @click="openModal">维护工作区域/班组成员</view>
24
+            <view v-else :class="{ 'custom-btn': true, 'disabled': !attendanceInfo.checkInTime }" @click="openModal">
25
+                维护工作区域/班组成员</view>
25 26
         </view>
26 27
         <u-popup :show="show" mode="center" :round="8">
27 28
             <view class="modal-content">
@@ -95,8 +96,13 @@
95 96
 
96 97
                 <view class="footer-btn">
97 98
                     <view v-if="searchViewShow" class="custom-btn-normal" @click="appendWorkUsers"
98
-                        :class="{ disabled: addWorkUsers.length === 0 }">添加人员</view>
99
-                    <view v-else class="custom-btn-normal" @click="confirm" :class="{ disabled: !selectedTerminal }">确认
99
+                        :class="{ disabled: addWorkUsers.length === 0 }">
100
+                        <text>添加人员</text>
101
+                    </view>
102
+                    <view v-else class="custom-btn-normal" @click="confirm"
103
+                        :class="{ disabled: !selectedTerminal || loading }">
104
+                        <text v-if="loading">处理中...</text>
105
+                        <text v-else>确认</text>
100 106
                     </view>
101 107
                 </view>
102 108
             </view>
@@ -116,7 +122,16 @@ export default {
116 122
         userInfo: {
117 123
             type: Object,
118 124
             default: () => { }
119
-        }
125
+        },
126
+        attendanceInfo: {
127
+            type: Object,
128
+            default: () => ({
129
+                attendanceDate: '', // 当前日期
130
+                checkInTime: '', //上班打卡时间
131
+                checkOutTime: '', //下班打卡时间
132
+                items: [], // 打开记录 第一条为最早上班打卡时间 最后一条为最晚下班打卡时间
133
+            })
134
+        },
120 135
     },
121 136
     data() {
122 137
         return {
@@ -131,7 +146,8 @@ export default {
131 146
             allUsers: [],//所有的人员
132 147
             searchViewShow: false,//搜索人员
133 148
             addWorkUsers: [], // 额外添加的人员 
134
-            teamUsers: [],//同组用户
149
+            teamUsers: [],//同组用户,
150
+            loading: false // 防止重复点击的loading状态
135 151
         }
136 152
     },
137 153
     computed: {
@@ -149,8 +165,8 @@ export default {
149 165
     },
150 166
     methods: {
151 167
         selectAddUser(selectItem) { // 移除额外添加人员
152
-            console.log(selectItem, "selectItem",this.addWorkUsers)
153
-            
168
+            console.log(selectItem, "selectItem", this.addWorkUsers)
169
+
154 170
             const index = this.addWorkUsers.findIndex(item => item.userId === selectItem.userId)
155 171
             if (index >= 0) {
156 172
                 this.addWorkUsers.splice(index, 1)
@@ -159,8 +175,7 @@ export default {
159 175
             }
160 176
         },
161 177
         appendWorkUsers() {
162
-            
163
-            console.log("appendWorkUsers",this.addWorkUsers,this.teamMembers)
178
+            console.log("appendWorkUsers", this.addWorkUsers, this.teamMembers)
164 179
             if (this.addWorkUsers.length) {
165 180
                 this.addWorkUsers.forEach(item => {
166 181
                     if (!this.teamMembers.some(member => member.userId === item.userId)) {
@@ -182,7 +197,7 @@ export default {
182 197
         },
183 198
         //获取默认的teammember
184 199
         getTeamMember() {
185
-            
200
+
186 201
             this.loadTeamUsers().then(() => {
187 202
                 // 选中全组人员  
188 203
                 this.teamMembers = this.teamUsers
@@ -196,7 +211,8 @@ export default {
196 211
                 // 调用用户列表接口,传递deptId获取同组用户
197 212
                 const response = await getUserList({
198 213
                     deptId: currentUserDeptId, // 🔥 使用从getInfo获取的deptId
199
-                    status: '0' // 只获取正常状态的用户
214
+                    status: '0', // 只获取正常状态的用户
215
+                    pageSize: 100
200 216
                 });
201 217
 
202 218
                 if (response && response.code === 200) {
@@ -221,13 +237,13 @@ export default {
221 237
         },
222 238
         //回显member
223 239
         getSelectedMember() {
224
-            
240
+
225 241
             memberList({
226 242
                 attendanceTeamId: this.userInfo.teamsId,
227 243
                 attendanceDate: moment().format('YYYY-MM-DD')
228 244
             }).then(res => {
229 245
 
230
-                this.selectedMember = res.rows || []
246
+                this.selectedMember = res.data || []
231 247
                 this.$emit('update-member', this.selectedMember)
232 248
             })
233 249
 
@@ -241,7 +257,8 @@ export default {
241 257
             // 调用用户列表接口,传递deptId获取同组用户
242 258
             const response = await getUserList({
243 259
                 deptId: currentUserDeptId, // 🔥 使用从getInfo获取的deptId
244
-                status: '0' // 只获取正常状态的用户
260
+                status: '0', // 只获取正常状态的用户
261
+                pageSize: 100
245 262
             });
246 263
             console.log(response, "response")
247 264
             if (response && response.code === 200) {
@@ -291,7 +308,8 @@ export default {
291 308
                 // 调用用户搜索接口,不限制部门
292 309
                 const response = await getUserList({
293 310
                     nickName: keyword,    // 按昵称搜索
294
-                    status: '0'          // 只获取正常状态的用户
311
+                    status: '0', // 只获取正常状态的用户
312
+                    pageSize: 100        // 只获取正常状态的用户
295 313
                 });
296 314
                 if (response && response.code === 200) {
297 315
                     this.allUsers = (response.rows || []).map(item => {
@@ -324,7 +342,8 @@ export default {
324 342
             this.selectedTerminal = terminal
325 343
         },
326 344
         confirm() {
327
-            if (!this.selectedTerminal) return
345
+            if (!this.selectedTerminal) return;
346
+            this.loading = true;
328 347
             let selectTerminal = this.channelList.find(item => item.value === this.selectedTerminal)
329 348
             let res = this.teamMembers.map(item => {
330 349
                 return {
@@ -343,9 +362,15 @@ export default {
343 362
                 uni.showToast({ title: '提交成功', icon: 'success' });
344 363
                 this.close()
345 364
                 this.getSelectedMember()
365
+                return res;
366
+            }).finally(() => {
367
+                this.loading = false
346 368
             })
347 369
         },
348 370
         openModal() {
371
+            if (!this.attendanceInfo.checkInTime) {
372
+                return;
373
+            }
349 374
             this.show = true;
350 375
             this.initMember()
351 376
             this.getTeamMember()
@@ -558,7 +583,7 @@ export default {
558 583
         .footer-btn {
559 584
             padding: 20rpx 30rpx;
560 585
 
561
-            
586
+
562 587
         }
563 588
     }
564 589
 }

+ 3 - 2
src/pages/attendance/components/WorkingGroup.vue

@@ -48,12 +48,13 @@
48 48
           </view>
49 49
         </view>
50 50
       </view>
51
+      <!-- {{ selectedMember.length === 0 }}{{ !userInfo.roles.includes('kezhang') }}{{ !attendanceInfo.checkInTime }} -->
51 52
       <!-- :disabled="!attendanceInfo.checkInTime || checkOutStatus" -->
52 53
       <AddAttendancePersonnelModal v-if="index === 0" :disabled="checkOutStatus" :notkezhang="notkezhang"
53 54
         :userInfo="userInfo" @updateRecord="invokerGetPostRecordList" :selectedMember="selectedMember">
54
-        <!-- :class="{ disabled: !attendanceInfo.checkInTime }"  不加控制逻辑  科长没有选人可以上通道,但是其他人必须选人才能选人上通道 -->
55
+        <!-- :class="{ disabled: !attendanceInfo.checkInTime }"   没有选人可以上通道 -->
55 56
         <view v-if="authority" class="custom-btn" @click="openModal"
56
-          :class="{ disabled: selectedMember.length === 0 && !userInfo.roles.includes('kezhang') }">
57
+          :class="{ disabled: selectedMember.length === 0 && !userInfo.roles.includes('kezhang') || (!attendanceInfo.checkInTime && attendanceInfo.checkOutTime) }">
57 58
           {{ checkOutStatus ? '下通道' : '上通道' }}
58 59
         </view>
59 60
       </AddAttendancePersonnelModal>

+ 1 - 1
src/pages/attendance/index.vue

@@ -26,7 +26,7 @@
26 26
         @attendanceHandler="handleCheckIn" />
27 27
       <!-- 工作区域/班组成员 -->
28 28
       <MaintainAreaOrMemberModal ref="maintainAreaOrMemberModal" v-if="showMaintain" :userInfo="userInfoAndRoles"
29
-        @update-member="updateMember" />
29
+        @update-member="updateMember" :attendanceInfo="attendanceInfo"/>
30 30
       <!-- 新界面工作组状态 -->
31 31
       <WorkingGroup ref="workingGroup" style="margin: 16px 0 24px 0" :attendanceInfo="attendanceInfo"
32 32
         :loadUserInfoOver="loadUserInfoOver" :userInfo="userInfoAndRoles" :selectedMember="selectedMember" />

+ 2 - 1
src/pages/checklist/components/unqualified.vue

@@ -138,7 +138,8 @@ export default {
138 138
     emitPersonnelChange() {
139 139
       let personnelData = this.localPersonnelData.map(item => ({
140 140
         ...item,
141
-        userName: item.nickName
141
+        userName:item.nickName.replace(/\s+/g, ''),
142
+        nickName:item.nickName.replace(/\s+/g, ''), // 去掉nickName中的所有空格
142 143
       }))
143 144
       const changeData = {
144 145
         parentIndex: this.parentIndex,

+ 35 - 3
src/pages/checklist/index.vue

@@ -23,7 +23,7 @@
23 23
                                 <uni-easyinput type="textarea" v-model="formData.description" placeholder="请输入任务简介"
24 24
                                     :disabled="true" />
25 25
                             </uni-forms-item>
26
-                            <uni-forms-item :label="getCheckLabel" name="checkedDepartmentId" required>
26
+                            <uni-forms-item :label="getCheckLabel" :name="getCheckFieldName" required>
27 27
                                 <uni-data-picker v-if="getCheckLabel == '被检查科'" :localdata="departments"
28 28
                                     :popup-title="`请选择${getCheckLabel}`" v-model="formData.checkedDepartmentId"
29 29
                                     @change="handlecheckedDepartmentIdChange" :readonly="formDisabled" />
@@ -205,6 +205,21 @@ export default {
205 205
                 return '被检查大队'
206 206
             }
207 207
         },
208
+        // 获取验证字段名
209
+        getCheckFieldName() {
210
+            if (this.formData.checkedLevel == checkedLevelEnums.TEAM_LEVEL) {
211
+                return 'checkedTeamId'
212
+            }
213
+            if (this.formData.checkedLevel == checkedLevelEnums.PERSONNEL_LEVEL) {
214
+                return 'checkedPersonnelId'
215
+            }
216
+            if (this.formData.checkedLevel == checkedLevelEnums.DEPARTMENT_LEVEL) {
217
+                return 'checkedDepartmentId'
218
+            }
219
+            if (this.formData.checkedLevel == checkedLevelEnums.BRIGADE_LEVEL) {
220
+                return 'checkedBrigadeId'
221
+            }
222
+        },
208 223
         // 验证规则
209 224
         rules() {
210 225
             let changeRule = {}
@@ -217,11 +232,25 @@ export default {
217 232
             }
218 233
             if (this.formData.checkedLevel == checkedLevelEnums.PERSONNEL_LEVEL) {
219 234
                 changeRule = {
220
-                    checkedUserId: {
235
+                    checkedPersonnelId: {
221 236
                         rules: [{ required: true, errorMessage: '请选择被检查人' }]
222 237
                     }
223 238
                 }
224 239
             }
240
+            if (this.formData.checkedLevel == checkedLevelEnums.DEPARTMENT_LEVEL) {
241
+                changeRule = {
242
+                    checkedDepartmentId: {
243
+                        rules: [{ required: true, errorMessage: '请选择被检查科' }]
244
+                    }
245
+                }
246
+            }
247
+            if (this.formData.checkedLevel == checkedLevelEnums.BRIGADE_LEVEL) {
248
+                changeRule = {
249
+                    checkedBrigadeId: {
250
+                        rules: [{ required: true, errorMessage: '请选择被检查大队' }]
251
+                    }
252
+                }
253
+            }
225 254
             return {
226 255
                 ...changeRule,
227 256
                 checkLocation: {
@@ -232,6 +261,7 @@ export default {
232 261
                         },
233 262
                         {
234 263
                             validateFunction: (rule, value, data, callback) => {
264
+                                console.log(value,"value")
235 265
                                 if (!value) {
236 266
                                     // 检查是否选择了完整的检查地点(终端、区域、通道)
237 267
                                     callback('请选择完整的检查地点');
@@ -455,7 +485,7 @@ export default {
455 485
             let newText = text.split('/')
456 486
             this.$set(this.formData, 'checkedBrigadeName', newText[newText.length - 1].trim());
457 487
             this.$set(this.formData, 'checkedDeptId', value);
458
-            debugger
488
+            
459 489
             this.$set(this.formData, 'checkedDeptName', newText[newText.length - 1].trim());
460 490
             this.$set(this.formData, 'checkedDepartmentId', value);
461 491
             this.$set(this.formData, 'checkedDepartmentName', newText[newText.length - 1].trim());
@@ -721,6 +751,7 @@ export default {
721 751
         // 提交表单
722 752
         submitForm() {
723 753
             this.$refs.form.validate().then(res => {
754
+               
724 755
                 // 检查所有不合格项是否都填写了相关人员
725 756
                 let hasError = false;
726 757
                 let errorMessage = '';
@@ -767,6 +798,7 @@ export default {
767 798
 
768 799
             }).catch(err => {
769 800
                 console.log('表单验证失败:', err);
801
+                uni.showToast({ title: '请填写完整表单信息', icon: 'none' });
770 802
             });
771 803
         }
772 804
 

+ 1 - 1
src/pages/myToDoList/index.vue

@@ -36,7 +36,7 @@
36 36
                         <template v-if="item.instance && item.instance.businessType === 'SEIZURE_REPORT'">
37 37
                             <view class="list-row">
38 38
                                 <view class="list-label">位置:</view>
39
-                                <view class="list-value">{{ getFormData(item, 'channelName') }}</view>
39
+                                <view class="list-value">{{ getFormData(item, 'securityLocationText') }}</view>
40 40
                             </view>
41 41
                             <view class="list-row" style="height: auto;align-items: flex-start;">
42 42
                                 <view class="list-label">查获人:</view>

+ 120 - 24
src/pages/seizedReported/index.vue

@@ -62,15 +62,14 @@
62 62
               <uni-forms-item label="查获位置" name="securityLocation" required>
63 63
                 <uni-data-picker v-if="!isDetailMode" :readonly="isDetailMode" :localdata="position_options"
64 64
                   popup-title="请选择查获位置" v-model="formData.securityLocation" @change="onLocationChange" />
65
-                <uni-easyinput v-else :disabled="true" placeholder="请选择查获班组"
66
-                  :value="formData.channelName || formData.regionalName" />
65
+                <uni-easyinput v-else :disabled="true" placeholder="请选择查获班组" :value="formData.securityLocationText" />
67 66
               </uni-forms-item>
68 67
 
69 68
               <uni-forms-item label="查获班组" name="reportTeam" required>
70 69
                 <uni-data-picker v-if="!isDetailMode" :readonly="isDetailMode" :localdata="teams" popup-title="请选择查获班组"
71 70
                   v-model="formData.reportTeam" @change="onReportTeamChange" />
72 71
 
73
-                <uni-easyinput v-else :disabled="true" placeholder="请选择查获班组" :value="formData.reportTeamText" />
72
+                <uni-easyinput v-else :disabled="true" placeholder="请选择查获班组" :value="formData.attendanceTeamName" />
74 73
               </uni-forms-item>
75 74
             </uni-collapse-item>
76 75
           </uni-collapse>
@@ -251,7 +250,7 @@ export default {
251 250
       return this.$store.state.user;
252 251
     },
253 252
     userInfo() {
254
-   
253
+
255 254
       return (this.$store.state.user && this.$store.state.user.userInfo) ? this.$store.state.user.userInfo : {}
256 255
     },
257 256
     // 将item_check_method_options转换为字符串数组供uni-combox使用
@@ -323,11 +322,11 @@ export default {
323 322
         attendanceId: '',
324 323
         attendanceTeamId: '',
325 324
         attendanceTeamName: '无',
326
-        attendanceDepartmentId:  '',
325
+        attendanceDepartmentId: '',
327 326
         attendanceDepartmentName: '无',
328
-        attendanceStationId:  '',
327
+        attendanceStationId: '',
329 328
         attendanceStationName: '无',
330
-        regionalCode:  '',
329
+        regionalCode: '',
331 330
         regionalName: '无',
332 331
         terminlCode: '',
333 332
         terminlName: '无',
@@ -434,20 +433,23 @@ export default {
434 433
     }
435 434
   },
436 435
   async onLoad(options) {
437
-    
436
+
438 437
     // if (options && options?.params) {
439
-      let params = {};
440
-      if (options?.params) {
441
-        params = JSON.parse(decodeURIComponent(options.params));
442
-      }
443
-      this.businessId = params?.businessId;
444
-      this.instanceId = params?.instanceId;
445
-      this.id = params?.id;
446
-      this.nodeCode = params?.nodeCode;
447
-      this.type = params?.type || 'add';
438
+    let params = {};
439
+    if (options?.params) {
440
+      params = JSON.parse(decodeURIComponent(options.params));
441
+    }
442
+    this.businessId = params?.businessId;
443
+    this.instanceId = params?.instanceId;
444
+    this.id = params?.id;
445
+    this.nodeCode = params?.nodeCode;
446
+    this.type = params?.type || 'add';
448 447
     // }
449 448
     await this.initPageData();
450
-    this.invokerGetLocationsbyTime()
449
+     if (this.type == 'add') {
450
+      this.invokerGetLocationsbyTime()
451
+    }
452
+
451 453
     this.invokerCategoryInfo()
452 454
     // 如果有路由ID,获取详情信息
453 455
     if (this.businessId) {
@@ -575,6 +577,8 @@ export default {
575 577
         isActiveConcealment: String(detailData?.itemSeizureItemsList[0].isActiveConcealment),
576 578
         handlingMethodDesc: detailData?.itemSeizureItemsList[0].handlingMethodDesc,
577 579
         handlingMethod: detailData?.itemSeizureItemsList[0].handlingMethod,
580
+        // reportTeamText:`${detailData?.inspectStationName}/${detailData?.inspectBrigadeName}/${detailData?.inspectDepartmentName}/${detailData?.inspectTeamName}`,
581
+        securityLocationText:`${detailData?.terminlName}/${detailData?.regionalName}/${detailData?.channelName}`
578 582
       };
579 583
 
580 584
       this.$nextTick(() => {
@@ -624,8 +628,7 @@ export default {
624 628
 
625 629
         this.formData.securityLocation = curUserInfo.channelCode || curUserInfo.regionalCode
626 630
         this.formData.securityLocationText = curUserInfo.channelName || curUserInfo.regionalName
627
-        this.formData.channelCode = curUserInfo.channelCode
628
-        this.formData.channelName = curUserInfo.channelName
631
+
629 632
         this.formData.team = curUserInfo.attendanceTeamId
630 633
         this.formData.reportTeam = curUserInfo.attendanceTeamId
631 634
         if (curUserInfo.attendanceStationName && curUserInfo.attendanceDepartmentName) {
@@ -633,9 +636,80 @@ export default {
633 636
           this.formData.reportTeamText = `${curUserInfo.attendanceStationName} / ${curUserInfo.attendanceDepartmentName} / ${curUserInfo.attendanceTeamName}`
634 637
         }
635 638
         console.log(this.formData);
636
-
639
+        const locationResult = this.getParentLocation(this.formData.securityLocation)
640
+        console.log(locationResult);
641
+
642
+        // 安全地处理可能为null的结果
643
+        if (locationResult) {
644
+          this.formData.terminlName = locationResult.grandParent?.text || '';
645
+          this.formData.terminlCode = locationResult.grandParent?.value || '';
646
+          this.formData.regionalName = locationResult.parent?.text || '';
647
+          this.formData.regionalCode = locationResult.parent?.value || '';
648
+          this.formData.channelName = locationResult.current?.text || '';
649
+          this.formData.channelCode = locationResult.current?.value || '';
650
+        } else {
651
+          // 如果找不到位置信息,清空相关字段
652
+          this.formData.terminlName = '';
653
+          this.formData.terminlCode = '';
654
+          this.formData.regionalName = '';
655
+          this.formData.regionalCode = '';
656
+          this.formData.channelName = '';
657
+          this.formData.channelCode = '';
658
+        }
637 659
       })
638 660
     },
661
+    //根据securityLocation,从this.position_options中向上找到前两级别的父级对象和当前级别对象
662
+    getParentLocation(securityLocation) {
663
+      if (!securityLocation || !this.position_options || !this.position_options.length) {
664
+        return null;
665
+      }
666
+
667
+      // 递归查找节点及其父级
668
+      const findNodeAndParents = (nodes, targetValue, parents = []) => {
669
+        for (const node of nodes) {
670
+          if (node.value === targetValue) {
671
+            return { node, parents };
672
+          }
673
+
674
+          if (node.children && node.children.length) {
675
+            const result = findNodeAndParents(node.children, targetValue, [...parents, node]);
676
+            if (result) {
677
+              return result;
678
+            }
679
+          }
680
+        }
681
+        return null;
682
+      };
683
+
684
+      const result = findNodeAndParents(this.position_options, securityLocation);
685
+
686
+      if (!result) {
687
+        return null;
688
+      }
689
+
690
+      const { node, parents } = result;
691
+
692
+      // 返回当前级别对象和前两级的父级对象(如果存在)
693
+      if (parents.length >= 2) {
694
+        return {
695
+          current: node,                              // 当前级别对象
696
+          grandParent: parents[parents.length - 2],  // 祖父级
697
+          parent: parents[parents.length - 1]        // 父级
698
+        };
699
+      } else if (parents.length === 1) {
700
+        return {
701
+          current: node,                              // 当前级别对象
702
+          grandParent: null,                         // 没有祖父级
703
+          parent: parents[0]                         // 只有父级
704
+        };
705
+      } else {
706
+        return {
707
+          current: node,                              // 当前级别对象
708
+          grandParent: null,                         // 没有祖父级
709
+          parent: null                               // 没有父级
710
+        };
711
+      }
712
+    },
639 713
     invokerCategoryInfo() {
640 714
       categoryInfo(1).then(res => {
641 715
         this.commonlyList.forbidden = res.data || []
@@ -775,6 +849,26 @@ export default {
775 849
       const arr = e.detail.value || [];
776 850
       this.formData.securityLocation = arr[arr.length - 1]?.value || '';
777 851
       this.formData.securityLocationText = arr.map(item => item.text).join('/');
852
+      const locationResult = this.getParentLocation(this.formData.securityLocation)
853
+        console.log(locationResult);
854
+
855
+        // 安全地处理可能为null的结果
856
+        if (locationResult) {
857
+          this.formData.terminlName = locationResult.grandParent?.text || '';
858
+          this.formData.terminlCode = locationResult.grandParent?.value || '';
859
+          this.formData.regionalName = locationResult.parent?.text || '';
860
+          this.formData.regionalCode = locationResult.parent?.value || '';
861
+          this.formData.channelName = locationResult.current?.text || '';
862
+          this.formData.channelCode = locationResult.current?.value || '';
863
+        } else {
864
+          // 如果找不到位置信息,清空相关字段
865
+          this.formData.terminlName = '';
866
+          this.formData.terminlCode = '';
867
+          this.formData.regionalName = '';
868
+          this.formData.regionalCode = '';
869
+          this.formData.channelName = '';
870
+          this.formData.channelCode = '';
871
+        }
778 872
     },
779 873
 
780 874
     // 通用取值:只拿最后一级
@@ -929,8 +1023,8 @@ export default {
929 1023
       return parseInt(`${timestamp}${random}`.slice(-15)); // 确保总长度不超过15位
930 1024
     },
931 1025
     formatData() {
932
-      this.formData.regionalCode = this.formData.securityLocation
933
-      this.formData.regionalName = this.formData.securityLocationText
1026
+      // this.formData.regionalCode = this.formData.securityLocation
1027
+      // this.formData.regionalName = this.formData.securityLocationText
934 1028
       this.formData.channelCode =
935 1029
         this.formData.channelCode || this.formData.securityLocation || '无'
936 1030
       this.formData.channelName =
@@ -996,7 +1090,7 @@ export default {
996 1090
 
997 1091
     // 提交表单
998 1092
     submitForm() {
999
-      console.log("generateNumericID", this.generateNumericID())
1093
+
1000 1094
       this.$refs.form.validate().then(res => {
1001 1095
         uni.showLoading({ title: '提交中...', mask: true });
1002 1096
         let payload = this.formatData()
@@ -1017,10 +1111,12 @@ export default {
1017 1111
             uni.showToast({ title: '提交成功', icon: 'success' });
1018 1112
             //开始流程
1019 1113
             console.log("res0", res)
1114
+
1020 1115
             approvalStart({ ...params, businessId: res.data }).then(res => {
1021 1116
               setTimeout(() => uni.navigateBack(), 1500); // 提交成功后跳转
1022 1117
             })
1023 1118
 
1119
+
1024 1120
           })
1025 1121
           .catch((error) => {
1026 1122
             uni.showToast({ title: '操作失败,请稍后重试!', icon: 'none' }); // 提交失败提示

+ 97 - 10
src/pages/seizedReportedVoice/index.vue

@@ -63,8 +63,7 @@
63 63
             <uni-forms-item label="查获位置" name="securityLocation" required>
64 64
               <uni-data-picker v-if="!isDetailMode" :readonly="isDetailMode" :localdata="position_options"
65 65
                 popup-title="请选择查获位置" v-model="formData.securityLocation" @change="onLocationChange" />
66
-              <uni-easyinput v-else :disabled="true" placeholder="请选择查获班组"
67
-                :value="formData.channelName || formData.regionalName" />
66
+              <uni-easyinput v-else :disabled="true" placeholder="请选择查获班组" :value="formData.securityLocationText" />
68 67
             </uni-forms-item>
69 68
 
70 69
             <uni-forms-item label="查获班组" name="reportTeam" required>
@@ -425,7 +424,6 @@ export default {
425 424
       this.voiceId = params?.voiceId;
426 425
     }
427 426
     await this.initPageData();
428
-    this.invokerGetLocationsbyTime()
429 427
     this.invokerCategoryInfo()
430 428
     // 如果有路由ID,获取详情信息
431 429
     if (this.businessId) {
@@ -433,8 +431,10 @@ export default {
433 431
     }
434 432
     // 如果有语音ID,获取语音详情信息
435 433
     if (this.voiceId) {
436
-      this.getVoiceDetailInfo();
434
+      await this.getVoiceDetailInfo();
437 435
     }
436
+    this.invokerGetLocationsbyTime()
437
+
438 438
   },
439 439
   methods: {
440 440
     // 获取语音详情信息
@@ -855,7 +855,8 @@ export default {
855 855
         isActiveConcealment: String(detailData?.itemSeizureItemsList[0].isActiveConcealment),
856 856
         handlingMethodDesc: detailData?.itemSeizureItemsList[0].handlingMethodDesc,
857 857
         handlingMethod: detailData?.itemSeizureItemsList[0].handlingMethod,
858
-
858
+        reportTeamText: `${detailData?.inspectStationName}/${detailData?.inspectBrigadeName}/${detailData?.inspectDepartmentName}/${detailData?.inspectTeamName}`,
859
+        securityLocationText: `${detailData?.terminlName}/${detailData?.regionalName}/${detailData?.channelName}`
859 860
       };
860 861
 
861 862
       this.$nextTick(() => {
@@ -906,8 +907,7 @@ export default {
906 907
         console.log(curUserInfo, "curUserInfo")
907 908
         this.formData.securityLocation = curUserInfo.channelCode || curUserInfo.regionalCode
908 909
         this.formData.securityLocationText = curUserInfo.channelName || curUserInfo.regionalName
909
-        this.formData.channelCode = curUserInfo.channelCode
910
-        this.formData.channelName = curUserInfo.channelName
910
+
911 911
         this.formData.team = curUserInfo.attendanceTeamId
912 912
         this.formData.reportTeam = curUserInfo.attendanceTeamId
913 913
         if (curUserInfo.attendanceStationName && curUserInfo.attendanceDepartmentName) {
@@ -915,9 +915,78 @@ export default {
915 915
           this.formData.reportTeamText = `${curUserInfo.attendanceStationName} / ${curUserInfo.attendanceDepartmentName} / ${curUserInfo.attendanceTeamName}`
916 916
         }
917 917
         console.log(this.formData);
918
-
918
+        const locationResult = this.getParentLocation(this.formData.securityLocation)
919
+        // 安全地处理可能为null的结果
920
+        if (locationResult) {
921
+          this.formData.terminlName = locationResult.grandParent?.text || '';
922
+          this.formData.terminlCode = locationResult.grandParent?.value || '';
923
+          this.formData.regionalName = locationResult.parent?.text || '';
924
+          this.formData.regionalCode = locationResult.parent?.value || '';
925
+          this.formData.channelName = locationResult.current?.text || '';
926
+          this.formData.channelCode = locationResult.current?.value || '';
927
+        } else {
928
+          // 如果找不到位置信息,清空相关字段
929
+          this.formData.terminlName = '';
930
+          this.formData.terminlCode = '';
931
+          this.formData.regionalName = '';
932
+          this.formData.regionalCode = '';
933
+          this.formData.channelName = '';
934
+          this.formData.channelCode = '';
935
+        }
919 936
       })
920 937
     },
938
+    //根据securityLocation,从this.position_options中向上找到前两级别的父级对象和当前级别对象
939
+    getParentLocation(securityLocation) {
940
+      if (!securityLocation || !this.position_options || !this.position_options.length) {
941
+        return null;
942
+      }
943
+
944
+      // 递归查找节点及其父级
945
+      const findNodeAndParents = (nodes, targetValue, parents = []) => {
946
+        for (const node of nodes) {
947
+          if (node.value === targetValue) {
948
+            return { node, parents };
949
+          }
950
+
951
+          if (node.children && node.children.length) {
952
+            const result = findNodeAndParents(node.children, targetValue, [...parents, node]);
953
+            if (result) {
954
+              return result;
955
+            }
956
+          }
957
+        }
958
+        return null;
959
+      };
960
+
961
+      const result = findNodeAndParents(this.position_options, securityLocation);
962
+
963
+      if (!result) {
964
+        return null;
965
+      }
966
+
967
+      const { node, parents } = result;
968
+
969
+      // 返回当前级别对象和前两级的父级对象(如果存在)
970
+      if (parents.length >= 2) {
971
+        return {
972
+          current: node,                              // 当前级别对象
973
+          grandParent: parents[parents.length - 2],  // 祖父级
974
+          parent: parents[parents.length - 1]        // 父级
975
+        };
976
+      } else if (parents.length === 1) {
977
+        return {
978
+          current: node,                              // 当前级别对象
979
+          grandParent: null,                         // 没有祖父级
980
+          parent: parents[0]                         // 只有父级
981
+        };
982
+      } else {
983
+        return {
984
+          current: node,                              // 当前级别对象
985
+          grandParent: null,                         // 没有祖父级
986
+          parent: null                               // 没有父级
987
+        };
988
+      }
989
+    },
921 990
     invokerCategoryInfo() {
922 991
       categoryInfo(1).then(res => {
923 992
         this.commonlyList.forbidden = res.data || []
@@ -1060,6 +1129,24 @@ export default {
1060 1129
       const arr = e.detail.value || [];
1061 1130
       this.formData.securityLocation = arr[arr.length - 1]?.value || '';
1062 1131
       this.formData.securityLocationText = arr.map(item => item.text).join('/');
1132
+      const locationResult = this.getParentLocation(this.formData.securityLocation)
1133
+      // 安全地处理可能为null的结果
1134
+      if (locationResult) {
1135
+        this.formData.terminlName = locationResult.grandParent?.text || '';
1136
+        this.formData.terminlCode = locationResult.grandParent?.value || '';
1137
+        this.formData.regionalName = locationResult.parent?.text || '';
1138
+        this.formData.regionalCode = locationResult.parent?.value || '';
1139
+        this.formData.channelName = locationResult.current?.text || '';
1140
+        this.formData.channelCode = locationResult.current?.value || '';
1141
+      } else {
1142
+        // 如果找不到位置信息,清空相关字段
1143
+        this.formData.terminlName = '';
1144
+        this.formData.terminlCode = '';
1145
+        this.formData.regionalName = '';
1146
+        this.formData.regionalCode = '';
1147
+        this.formData.channelName = '';
1148
+        this.formData.channelCode = '';
1149
+      }
1063 1150
     },
1064 1151
 
1065 1152
     // 通用取值:只拿最后一级
@@ -1212,8 +1299,8 @@ export default {
1212 1299
     },
1213 1300
     formatData() {
1214 1301
 
1215
-      this.formData.regionalCode = this.formData.securityLocation
1216
-      this.formData.regionalName = this.formData.securityLocationText
1302
+      // this.formData.regionalCode = this.formData.securityLocation
1303
+      // this.formData.regionalName = this.formData.securityLocationText
1217 1304
       this.formData.channelCode =
1218 1305
         this.formData.channelCode || this.formData.securityLocation || '无'
1219 1306
       this.formData.channelName =