Bladeren bron

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

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

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

@@ -105,3 +105,11 @@ export function queryLastTime (data) {
105
     data: data
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
 module.exports = {
2
 module.exports = {
3
    // 接口地址  本地调试使用 http://192.168.3.222:38080  打包使用 /prod-api
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
   //  baseUrl: process.env.NODE_ENV === 'development' ? 'http://192.168.3.221:8080' : '/prod-api',
5
   //  baseUrl: process.env.NODE_ENV === 'development' ? 'http://192.168.3.221:8080' : '/prod-api',
6
 // baseUrl: process.env.NODE_ENV === 'development' ? 'http://guangxi.qinghe.sundot.cn:8088' : 'http://guangxi.qinghe.sundot.cn:8088/prod-api',
6
 // baseUrl: process.env.NODE_ENV === 'development' ? 'http://guangxi.qinghe.sundot.cn:8088' : 'http://guangxi.qinghe.sundot.cn:8088/prod-api',
7
 // baseUrl: 'http://guangxi.qinghe.sundot.cn:8088',
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
   appInfo: {
10
   appInfo: {
11
     // 应用名称
11
     // 应用名称

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

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

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

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

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

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

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

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

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

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

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

@@ -23,7 +23,7 @@
23
                                 <uni-easyinput type="textarea" v-model="formData.description" placeholder="请输入任务简介"
23
                                 <uni-easyinput type="textarea" v-model="formData.description" placeholder="请输入任务简介"
24
                                     :disabled="true" />
24
                                     :disabled="true" />
25
                             </uni-forms-item>
25
                             </uni-forms-item>
26
-                            <uni-forms-item :label="getCheckLabel" name="checkedDepartmentId" required>
26
+                            <uni-forms-item :label="getCheckLabel" :name="getCheckFieldName" required>
27
                                 <uni-data-picker v-if="getCheckLabel == '被检查科'" :localdata="departments"
27
                                 <uni-data-picker v-if="getCheckLabel == '被检查科'" :localdata="departments"
28
                                     :popup-title="`请选择${getCheckLabel}`" v-model="formData.checkedDepartmentId"
28
                                     :popup-title="`请选择${getCheckLabel}`" v-model="formData.checkedDepartmentId"
29
                                     @change="handlecheckedDepartmentIdChange" :readonly="formDisabled" />
29
                                     @change="handlecheckedDepartmentIdChange" :readonly="formDisabled" />
@@ -205,6 +205,21 @@ export default {
205
                 return '被检查大队'
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
         rules() {
224
         rules() {
210
             let changeRule = {}
225
             let changeRule = {}
@@ -217,11 +232,25 @@ export default {
217
             }
232
             }
218
             if (this.formData.checkedLevel == checkedLevelEnums.PERSONNEL_LEVEL) {
233
             if (this.formData.checkedLevel == checkedLevelEnums.PERSONNEL_LEVEL) {
219
                 changeRule = {
234
                 changeRule = {
220
-                    checkedUserId: {
235
+                    checkedPersonnelId: {
221
                         rules: [{ required: true, errorMessage: '请选择被检查人' }]
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
             return {
254
             return {
226
                 ...changeRule,
255
                 ...changeRule,
227
                 checkLocation: {
256
                 checkLocation: {
@@ -232,6 +261,7 @@ export default {
232
                         },
261
                         },
233
                         {
262
                         {
234
                             validateFunction: (rule, value, data, callback) => {
263
                             validateFunction: (rule, value, data, callback) => {
264
+                                console.log(value,"value")
235
                                 if (!value) {
265
                                 if (!value) {
236
                                     // 检查是否选择了完整的检查地点(终端、区域、通道)
266
                                     // 检查是否选择了完整的检查地点(终端、区域、通道)
237
                                     callback('请选择完整的检查地点');
267
                                     callback('请选择完整的检查地点');
@@ -455,7 +485,7 @@ export default {
455
             let newText = text.split('/')
485
             let newText = text.split('/')
456
             this.$set(this.formData, 'checkedBrigadeName', newText[newText.length - 1].trim());
486
             this.$set(this.formData, 'checkedBrigadeName', newText[newText.length - 1].trim());
457
             this.$set(this.formData, 'checkedDeptId', value);
487
             this.$set(this.formData, 'checkedDeptId', value);
458
-            debugger
488
+            
459
             this.$set(this.formData, 'checkedDeptName', newText[newText.length - 1].trim());
489
             this.$set(this.formData, 'checkedDeptName', newText[newText.length - 1].trim());
460
             this.$set(this.formData, 'checkedDepartmentId', value);
490
             this.$set(this.formData, 'checkedDepartmentId', value);
461
             this.$set(this.formData, 'checkedDepartmentName', newText[newText.length - 1].trim());
491
             this.$set(this.formData, 'checkedDepartmentName', newText[newText.length - 1].trim());
@@ -721,6 +751,7 @@ export default {
721
         // 提交表单
751
         // 提交表单
722
         submitForm() {
752
         submitForm() {
723
             this.$refs.form.validate().then(res => {
753
             this.$refs.form.validate().then(res => {
754
+               
724
                 // 检查所有不合格项是否都填写了相关人员
755
                 // 检查所有不合格项是否都填写了相关人员
725
                 let hasError = false;
756
                 let hasError = false;
726
                 let errorMessage = '';
757
                 let errorMessage = '';
@@ -767,6 +798,7 @@ export default {
767
 
798
 
768
             }).catch(err => {
799
             }).catch(err => {
769
                 console.log('表单验证失败:', err);
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
                         <template v-if="item.instance && item.instance.businessType === 'SEIZURE_REPORT'">
36
                         <template v-if="item.instance && item.instance.businessType === 'SEIZURE_REPORT'">
37
                             <view class="list-row">
37
                             <view class="list-row">
38
                                 <view class="list-label">位置:</view>
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
                             </view>
40
                             </view>
41
                             <view class="list-row" style="height: auto;align-items: flex-start;">
41
                             <view class="list-row" style="height: auto;align-items: flex-start;">
42
                                 <view class="list-label">查获人:</view>
42
                                 <view class="list-label">查获人:</view>

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

@@ -62,15 +62,14 @@
62
               <uni-forms-item label="查获位置" name="securityLocation" required>
62
               <uni-forms-item label="查获位置" name="securityLocation" required>
63
                 <uni-data-picker v-if="!isDetailMode" :readonly="isDetailMode" :localdata="position_options"
63
                 <uni-data-picker v-if="!isDetailMode" :readonly="isDetailMode" :localdata="position_options"
64
                   popup-title="请选择查获位置" v-model="formData.securityLocation" @change="onLocationChange" />
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
               </uni-forms-item>
66
               </uni-forms-item>
68
 
67
 
69
               <uni-forms-item label="查获班组" name="reportTeam" required>
68
               <uni-forms-item label="查获班组" name="reportTeam" required>
70
                 <uni-data-picker v-if="!isDetailMode" :readonly="isDetailMode" :localdata="teams" popup-title="请选择查获班组"
69
                 <uni-data-picker v-if="!isDetailMode" :readonly="isDetailMode" :localdata="teams" popup-title="请选择查获班组"
71
                   v-model="formData.reportTeam" @change="onReportTeamChange" />
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
               </uni-forms-item>
73
               </uni-forms-item>
75
             </uni-collapse-item>
74
             </uni-collapse-item>
76
           </uni-collapse>
75
           </uni-collapse>
@@ -251,7 +250,7 @@ export default {
251
       return this.$store.state.user;
250
       return this.$store.state.user;
252
     },
251
     },
253
     userInfo() {
252
     userInfo() {
254
-   
253
+
255
       return (this.$store.state.user && this.$store.state.user.userInfo) ? this.$store.state.user.userInfo : {}
254
       return (this.$store.state.user && this.$store.state.user.userInfo) ? this.$store.state.user.userInfo : {}
256
     },
255
     },
257
     // 将item_check_method_options转换为字符串数组供uni-combox使用
256
     // 将item_check_method_options转换为字符串数组供uni-combox使用
@@ -323,11 +322,11 @@ export default {
323
         attendanceId: '',
322
         attendanceId: '',
324
         attendanceTeamId: '',
323
         attendanceTeamId: '',
325
         attendanceTeamName: '无',
324
         attendanceTeamName: '无',
326
-        attendanceDepartmentId:  '',
325
+        attendanceDepartmentId: '',
327
         attendanceDepartmentName: '无',
326
         attendanceDepartmentName: '无',
328
-        attendanceStationId:  '',
327
+        attendanceStationId: '',
329
         attendanceStationName: '无',
328
         attendanceStationName: '无',
330
-        regionalCode:  '',
329
+        regionalCode: '',
331
         regionalName: '无',
330
         regionalName: '无',
332
         terminlCode: '',
331
         terminlCode: '',
333
         terminlName: '无',
332
         terminlName: '无',
@@ -434,20 +433,23 @@ export default {
434
     }
433
     }
435
   },
434
   },
436
   async onLoad(options) {
435
   async onLoad(options) {
437
-    
436
+
438
     // if (options && options?.params) {
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
     await this.initPageData();
448
     await this.initPageData();
450
-    this.invokerGetLocationsbyTime()
449
+     if (this.type == 'add') {
450
+      this.invokerGetLocationsbyTime()
451
+    }
452
+
451
     this.invokerCategoryInfo()
453
     this.invokerCategoryInfo()
452
     // 如果有路由ID,获取详情信息
454
     // 如果有路由ID,获取详情信息
453
     if (this.businessId) {
455
     if (this.businessId) {
@@ -575,6 +577,8 @@ export default {
575
         isActiveConcealment: String(detailData?.itemSeizureItemsList[0].isActiveConcealment),
577
         isActiveConcealment: String(detailData?.itemSeizureItemsList[0].isActiveConcealment),
576
         handlingMethodDesc: detailData?.itemSeizureItemsList[0].handlingMethodDesc,
578
         handlingMethodDesc: detailData?.itemSeizureItemsList[0].handlingMethodDesc,
577
         handlingMethod: detailData?.itemSeizureItemsList[0].handlingMethod,
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
       this.$nextTick(() => {
584
       this.$nextTick(() => {
@@ -624,8 +628,7 @@ export default {
624
 
628
 
625
         this.formData.securityLocation = curUserInfo.channelCode || curUserInfo.regionalCode
629
         this.formData.securityLocation = curUserInfo.channelCode || curUserInfo.regionalCode
626
         this.formData.securityLocationText = curUserInfo.channelName || curUserInfo.regionalName
630
         this.formData.securityLocationText = curUserInfo.channelName || curUserInfo.regionalName
627
-        this.formData.channelCode = curUserInfo.channelCode
628
-        this.formData.channelName = curUserInfo.channelName
631
+
629
         this.formData.team = curUserInfo.attendanceTeamId
632
         this.formData.team = curUserInfo.attendanceTeamId
630
         this.formData.reportTeam = curUserInfo.attendanceTeamId
633
         this.formData.reportTeam = curUserInfo.attendanceTeamId
631
         if (curUserInfo.attendanceStationName && curUserInfo.attendanceDepartmentName) {
634
         if (curUserInfo.attendanceStationName && curUserInfo.attendanceDepartmentName) {
@@ -633,9 +636,80 @@ export default {
633
           this.formData.reportTeamText = `${curUserInfo.attendanceStationName} / ${curUserInfo.attendanceDepartmentName} / ${curUserInfo.attendanceTeamName}`
636
           this.formData.reportTeamText = `${curUserInfo.attendanceStationName} / ${curUserInfo.attendanceDepartmentName} / ${curUserInfo.attendanceTeamName}`
634
         }
637
         }
635
         console.log(this.formData);
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
     invokerCategoryInfo() {
713
     invokerCategoryInfo() {
640
       categoryInfo(1).then(res => {
714
       categoryInfo(1).then(res => {
641
         this.commonlyList.forbidden = res.data || []
715
         this.commonlyList.forbidden = res.data || []
@@ -775,6 +849,26 @@ export default {
775
       const arr = e.detail.value || [];
849
       const arr = e.detail.value || [];
776
       this.formData.securityLocation = arr[arr.length - 1]?.value || '';
850
       this.formData.securityLocation = arr[arr.length - 1]?.value || '';
777
       this.formData.securityLocationText = arr.map(item => item.text).join('/');
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
       return parseInt(`${timestamp}${random}`.slice(-15)); // 确保总长度不超过15位
1023
       return parseInt(`${timestamp}${random}`.slice(-15)); // 确保总长度不超过15位
930
     },
1024
     },
931
     formatData() {
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
       this.formData.channelCode =
1028
       this.formData.channelCode =
935
         this.formData.channelCode || this.formData.securityLocation || '无'
1029
         this.formData.channelCode || this.formData.securityLocation || '无'
936
       this.formData.channelName =
1030
       this.formData.channelName =
@@ -996,7 +1090,7 @@ export default {
996
 
1090
 
997
     // 提交表单
1091
     // 提交表单
998
     submitForm() {
1092
     submitForm() {
999
-      console.log("generateNumericID", this.generateNumericID())
1093
+
1000
       this.$refs.form.validate().then(res => {
1094
       this.$refs.form.validate().then(res => {
1001
         uni.showLoading({ title: '提交中...', mask: true });
1095
         uni.showLoading({ title: '提交中...', mask: true });
1002
         let payload = this.formatData()
1096
         let payload = this.formatData()
@@ -1017,10 +1111,12 @@ export default {
1017
             uni.showToast({ title: '提交成功', icon: 'success' });
1111
             uni.showToast({ title: '提交成功', icon: 'success' });
1018
             //开始流程
1112
             //开始流程
1019
             console.log("res0", res)
1113
             console.log("res0", res)
1114
+
1020
             approvalStart({ ...params, businessId: res.data }).then(res => {
1115
             approvalStart({ ...params, businessId: res.data }).then(res => {
1021
               setTimeout(() => uni.navigateBack(), 1500); // 提交成功后跳转
1116
               setTimeout(() => uni.navigateBack(), 1500); // 提交成功后跳转
1022
             })
1117
             })
1023
 
1118
 
1119
+
1024
           })
1120
           })
1025
           .catch((error) => {
1121
           .catch((error) => {
1026
             uni.showToast({ title: '操作失败,请稍后重试!', icon: 'none' }); // 提交失败提示
1122
             uni.showToast({ title: '操作失败,请稍后重试!', icon: 'none' }); // 提交失败提示

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

@@ -63,8 +63,7 @@
63
             <uni-forms-item label="查获位置" name="securityLocation" required>
63
             <uni-forms-item label="查获位置" name="securityLocation" required>
64
               <uni-data-picker v-if="!isDetailMode" :readonly="isDetailMode" :localdata="position_options"
64
               <uni-data-picker v-if="!isDetailMode" :readonly="isDetailMode" :localdata="position_options"
65
                 popup-title="请选择查获位置" v-model="formData.securityLocation" @change="onLocationChange" />
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
             </uni-forms-item>
67
             </uni-forms-item>
69
 
68
 
70
             <uni-forms-item label="查获班组" name="reportTeam" required>
69
             <uni-forms-item label="查获班组" name="reportTeam" required>
@@ -425,7 +424,6 @@ export default {
425
       this.voiceId = params?.voiceId;
424
       this.voiceId = params?.voiceId;
426
     }
425
     }
427
     await this.initPageData();
426
     await this.initPageData();
428
-    this.invokerGetLocationsbyTime()
429
     this.invokerCategoryInfo()
427
     this.invokerCategoryInfo()
430
     // 如果有路由ID,获取详情信息
428
     // 如果有路由ID,获取详情信息
431
     if (this.businessId) {
429
     if (this.businessId) {
@@ -433,8 +431,10 @@ export default {
433
     }
431
     }
434
     // 如果有语音ID,获取语音详情信息
432
     // 如果有语音ID,获取语音详情信息
435
     if (this.voiceId) {
433
     if (this.voiceId) {
436
-      this.getVoiceDetailInfo();
434
+      await this.getVoiceDetailInfo();
437
     }
435
     }
436
+    this.invokerGetLocationsbyTime()
437
+
438
   },
438
   },
439
   methods: {
439
   methods: {
440
     // 获取语音详情信息
440
     // 获取语音详情信息
@@ -855,7 +855,8 @@ export default {
855
         isActiveConcealment: String(detailData?.itemSeizureItemsList[0].isActiveConcealment),
855
         isActiveConcealment: String(detailData?.itemSeizureItemsList[0].isActiveConcealment),
856
         handlingMethodDesc: detailData?.itemSeizureItemsList[0].handlingMethodDesc,
856
         handlingMethodDesc: detailData?.itemSeizureItemsList[0].handlingMethodDesc,
857
         handlingMethod: detailData?.itemSeizureItemsList[0].handlingMethod,
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
       this.$nextTick(() => {
862
       this.$nextTick(() => {
@@ -906,8 +907,7 @@ export default {
906
         console.log(curUserInfo, "curUserInfo")
907
         console.log(curUserInfo, "curUserInfo")
907
         this.formData.securityLocation = curUserInfo.channelCode || curUserInfo.regionalCode
908
         this.formData.securityLocation = curUserInfo.channelCode || curUserInfo.regionalCode
908
         this.formData.securityLocationText = curUserInfo.channelName || curUserInfo.regionalName
909
         this.formData.securityLocationText = curUserInfo.channelName || curUserInfo.regionalName
909
-        this.formData.channelCode = curUserInfo.channelCode
910
-        this.formData.channelName = curUserInfo.channelName
910
+
911
         this.formData.team = curUserInfo.attendanceTeamId
911
         this.formData.team = curUserInfo.attendanceTeamId
912
         this.formData.reportTeam = curUserInfo.attendanceTeamId
912
         this.formData.reportTeam = curUserInfo.attendanceTeamId
913
         if (curUserInfo.attendanceStationName && curUserInfo.attendanceDepartmentName) {
913
         if (curUserInfo.attendanceStationName && curUserInfo.attendanceDepartmentName) {
@@ -915,9 +915,78 @@ export default {
915
           this.formData.reportTeamText = `${curUserInfo.attendanceStationName} / ${curUserInfo.attendanceDepartmentName} / ${curUserInfo.attendanceTeamName}`
915
           this.formData.reportTeamText = `${curUserInfo.attendanceStationName} / ${curUserInfo.attendanceDepartmentName} / ${curUserInfo.attendanceTeamName}`
916
         }
916
         }
917
         console.log(this.formData);
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
     invokerCategoryInfo() {
990
     invokerCategoryInfo() {
922
       categoryInfo(1).then(res => {
991
       categoryInfo(1).then(res => {
923
         this.commonlyList.forbidden = res.data || []
992
         this.commonlyList.forbidden = res.data || []
@@ -1060,6 +1129,24 @@ export default {
1060
       const arr = e.detail.value || [];
1129
       const arr = e.detail.value || [];
1061
       this.formData.securityLocation = arr[arr.length - 1]?.value || '';
1130
       this.formData.securityLocation = arr[arr.length - 1]?.value || '';
1062
       this.formData.securityLocationText = arr.map(item => item.text).join('/');
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
     formatData() {
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
       this.formData.channelCode =
1304
       this.formData.channelCode =
1218
         this.formData.channelCode || this.formData.securityLocation || '无'
1305
         this.formData.channelCode || this.formData.securityLocation || '无'
1219
       this.formData.channelName =
1306
       this.formData.channelName =