Blame view

pages-sub/problem/ai-manage/index.vue 24.2 KB
6e9f0396   刘淇   全域督察员
1
2
3
4
5
  <template>
    <view class="page-container">
      <!-- 顶部固定区域 -->
      <up-sticky>
        <view class="header-wrap">
6e9f0396   刘淇   全域督察员
6
7
8
9
10
11
12
13
          <up-tabs
              v-model="activeTab"
              :list="tabList"
              active-color="#1989fa"
              inactive-color="#666"
              font-size="30rpx"
              @click="handleTabChange"
          />
6e9f0396   刘淇   全域督察员
14
15
          <!-- 第二行:下拉框 + 搜索框 -->
          <view class="search-header">
6e9f0396   刘淇   全域督察员
16
17
18
19
20
21
22
23
24
25
            <view class="select-wrap common-text-color">
              <up-select
                  v-model:current="selectedSortValue"
                  :options="sortOptions"
                  :showOptionsLabel="true"
                  @select="handleSortChange"
                  border="surround"
                  :style="{ flex: 1 }"
              />
            </view>
6e9f0396   刘淇   全域督察员
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
            <view class="search-input-wrap">
              <up-search
                  v-model="searchValue"
                  placeholder="请输入关键字"
                  @search="handleSearch"
                  bg-color="#f5f5f5"
                  :clearabled="false"
                  :show-action="true"
                  actionText="搜索"
                  :animation="true"
                  @custom="handleSearch"
              />
            </view>
          </view>
        </view>
      </up-sticky>
  
      <!-- 列表容器 -->
      <z-paging
8ddc6f6e   刘淇   登录 修改样式
45
          ref="pagingRef"
6e9f0396   刘淇   全域督察员
46
47
48
          v-model="orderList"
          @query="queryList"
          :auto-show-system-loading="true"
6e9f0396   刘淇   全域督察员
49
50
      >
        <template #empty>
8ddc6f6e   刘淇   登录 修改样式
51
          <empty-view />
6e9f0396   刘淇   全域督察员
52
53
54
55
56
        </template>
  
        <view class="common-card-list" style="padding-top: 200rpx;padding-bottom: 30rpx">
          <!-- 待办工单卡片 -->
          <up-card
8ddc6f6e   刘淇   登录 修改样式
57
              v-if="activeTab === 0"
6e9f0396   刘淇   全域督察员
58
59
60
              :border="false"
              :foot-border-top="false"
              v-for="(item, index) in orderList"
8ddc6f6e   刘淇   登录 修改样式
61
              :key="`todo_${item.id}_${index}`"
6e9f0396   刘淇   全域督察员
62
63
64
65
66
67
68
69
70
71
72
73
74
75
              :show-head="false"
              class="order-card"
          >
            <template #body>
              <view class="card-body">
                <view class="u-body-item u-flex">
                  <view class="u-body-item-title">工单编号:</view>
                  <view class="u-line-1 u-body-value">{{ item.orderNo || '-' }}</view>
                </view>
                <view class="u-body-item u-flex">
                  <view class="u-body-item-title">工单位置:</view>
                  <view class="u-line-1 u-body-value">{{ item.lonLatAddress || '-' }}</view>
                </view>
                <view class="u-body-item u-flex">
c64da17b   刘淇   新的业务线
76
                  <view class="u-body-item-title">问题类型:</view>
6e9f0396   刘淇   全域督察员
77
78
79
80
81
82
                  <view class="u-line-1 u-body-value">{{ item.orderName || '未填写' }}</view>
                </view>
                <view class="u-body-item u-flex">
                  <view class="u-body-item-title">情况描述:</view>
                  <view class="u-line-1 u-body-value">{{ item.remark || '无' }}</view>
                </view>
8ddc6f6e   刘淇   登录 修改样式
83
                <view class="u-body-item u-flex common-item-center common-justify-between">
6e9f0396   刘淇   全域督察员
84
85
86
87
88
89
90
91
92
93
94
95
96
97
                  <view class="u-body-item-title">紧急程度:</view>
                  <view class="u-line-1 u-body-value">
                    {{ uni.$dict.getDictLabel('workorder_pressing_type', item.pressingType) }}
                  </view>
                </view>
                <view class="u-body-item u-flex">
                  <view class="u-body-item-title">工单状态:</view>
                  <view class="u-line-1 u-body-value">{{ buzStatusMap[item.buzStatus] }}</view>
                </view>
                <view class="u-body-item u-flex">
                  <view class="u-body-item-title">提交时间:</view>
                  <view class="u-line-1 u-body-value">{{ timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss') }}</view>
                </view>
                <!-- 操作按钮行 -->
83673de2   刘淇   ai 大区经理 优化添加结束功能
98
                <view class="u-body-item u-flex u-body-item-btn-wrap common-justify-between common-item-center mt-20">
6bce1057   刘淇   ai 大区经理
99
100
  <!--                <up-button type="warning" size="mini" @click="handleReject(item)" v-show="nextStepMap[item.taskKey].backShow">回退</up-button>-->
  <!--                <up-button type="success" size="mini" @click="handleRenew(item)" v-show="nextStepMap[item.taskKey].renewShow">重新提交</up-button>-->
b6e4a018   王彪总   业务线 小程序不用写死,从后端接口获取
101
                  <up-button type="primary" size="large" @click="handleUnifiedProcess(item)">{{ nextStepMap[item.taskKey].btnText }}</up-button>
83673de2   刘淇   ai 大区经理 优化添加结束功能
102
  <!--                <up-button type="primary" size="large" @click="handleProcess(item)" v-show="nextStepMap[item.taskKey].ysShow">验收</up-button>-->
6bce1057   刘淇   ai 大区经理
103
  
83673de2   刘淇   ai 大区经理 优化添加结束功能
104
                  <up-button type="info" size="large" @click="handleDetail(item)">详情</up-button>
6e9f0396   刘淇   全域督察员
105
106
107
108
109
110
111
                </view>
              </view>
            </template>
          </up-card>
  
          <!-- 已办工单卡片和我发起的 -->
          <up-card
8ddc6f6e   刘淇   登录 修改样式
112
              v-if="activeTab === 1 || activeTab === 2"
6e9f0396   刘淇   全域督察员
113
114
115
              :border="false"
              :foot-border-top="false"
              v-for="(item, index) in orderList"
8ddc6f6e   刘淇   登录 修改样式
116
              :key="`done_${item.id}_${index}`"
6e9f0396   刘淇   全域督察员
117
118
119
120
121
              :show-head="false"
              class="order-card"
          >
            <template #body>
              <view class="card-body">
83673de2   刘淇   ai 大区经理 优化添加结束功能
122
123
124
                <view class="common-custom-btn " style="--btn-top: 130px;"  @click="handleDetail(item)">
                  工单详情
                </view>
6e9f0396   刘淇   全域督察员
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
                <view class="u-body-item u-flex">
                  <view class="u-body-item-title">工单编号:</view>
                  <view class="u-line-1 u-body-value">{{ item.orderNo || '-' }}</view>
                </view>
                <view class="u-body-item u-flex">
                  <view class="u-body-item-title">工单位置:</view>
                  <view class="u-line-1 u-body-value">{{ item.lonLatAddress || '-' }}</view>
                </view>
                <view class="u-body-item u-flex">
                  <view class="u-body-item-title">工单名称:</view>
                  <view class="u-line-1 u-body-value">{{ item.orderName || '未填写' }}</view>
                </view>
                <view class="u-body-item u-flex">
                  <view class="u-body-item-title">情况描述:</view>
                  <view class="u-line-1 u-body-value">{{ item.remark || '无' }}</view>
                </view>
6e9f0396   刘淇   全域督察员
141
142
143
144
                <view class="u-body-item u-flex common-justify-between common-item-center">
                  <view class="u-body-item-title">
                    紧急程度:{{ uni.$dict.getDictLabel('workorder_pressing_type', item.pressingType) }}
                  </view>
83673de2   刘淇   ai 大区经理 优化添加结束功能
145
146
147
  <!--                <view>-->
  <!--                  <up-button type="primary" size="mini" @click="handleDetail(item)">工单详情</up-button>-->
  <!--                </view>-->
6e9f0396   刘淇   全域督察员
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
                </view>
                <view class="u-body-item u-flex">
                  <view class="u-body-item-title">工单状态:</view>
                  <view class="u-line-1 u-body-value">{{ buzStatusMap[item.buzStatus] }}</view>
                </view>
                <view class="u-body-item u-flex">
                  <view class="u-body-item-title">提交时间:</view>
                  <view class="u-line-1 u-body-value">{{ timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss') }}</view>
                </view>
              </view>
            </template>
          </up-card>
        </view>
      </z-paging>
  
8ddc6f6e   刘淇   登录 修改样式
163
      <!-- 底部新增工单按钮 -->
6e9f0396   刘淇   全域督察员
164
      <view class="fixed-bottom-btn-wrap" v-if="isAi">
8ddc6f6e   刘淇   登录 修改样式
165
        <up-button type="primary" size="large" @click="handleAddOrder">新增工单</up-button>
6e9f0396   刘淇   全域督察员
166
167
      </view>
  
8ddc6f6e   刘淇   登录 修改样式
168
      <!-- 回退原因弹窗 -->
6e9f0396   刘淇   全域督察员
169
170
171
172
173
174
175
176
177
178
      <up-modal
          :show="rejectModalShow"
          title="回退原因"
          :closeOnClickOverlay="false"
          :showConfirmButton="true"
          :showCancelButton="true"
          @cancel="handleRejectModalCancel"
          @confirm="confirmReject"
      >
        <view class="reject-modal-content">
6e9f0396   刘淇   全域督察员
179
180
181
182
183
184
185
186
          <up-textarea
              v-model.trim="rejectReason"
              placeholder="请输入回退原因(必填)"
              rows="6"
              :count="200"
              maxlength="200"
              class="reject-textarea"
          />
6e9f0396   刘淇   全域督察员
187
188
189
          <view class="upload-wrap mt-20">
            <view class="upload-title">上传图片(选填)</view>
            <up-upload
8ddc6f6e   刘淇   登录 修改样式
190
                :file-list="rejectImgs.rawImgList.value || []"
6e9f0396   刘淇   全域督察员
191
192
193
194
195
196
197
198
199
200
201
202
203
                @after-read="rejectImgs.uploadImgs"
                @delete="rejectImgs.deleteImg"
                multiple
                width="70"
                height="70"
                :max-count="rejectImgs.uploadConfig.maxCount"
                :upload-text="rejectImgs.uploadConfig.uploadText"
                :size-type="rejectImgs.uploadConfig.sizeType"
            />
          </view>
        </view>
      </up-modal>
  
8ddc6f6e   刘淇   登录 修改样式
204
      <!-- 验收弹窗 -->
6e9f0396   刘淇   全域督察员
205
206
207
208
209
210
211
212
213
214
      <up-modal
          :show="acceptModalShow"
          title="验收"
          :closeOnClickOverlay="false"
          :showConfirmButton="true"
          :showCancelButton="true"
          @cancel="handleAcceptModalCancel"
          @confirm="handleAcceptModalConfirm"
      >
        <view class="accept-modal-content">
6e9f0396   刘淇   全域督察员
215
216
217
218
219
220
          <view class="radio-group-wrap">
            <up-radio-group v-model="acceptRadioValue">
              <up-radio name="0" label="通过"></up-radio>
              <up-radio name="1" label="不通过"></up-radio>
            </up-radio-group>
          </view>
6e9f0396   刘淇   全域督察员
221
222
223
224
225
226
227
228
229
230
          <view class="textarea-wrap mt-30">
            <up-textarea
                v-model.trim="acceptReason"
                placeholder="请输入验收原因(必填,最多200字)"
                :required="true"
                maxlength="200"
                rows="5"
                count
            />
          </view>
6e9f0396   刘淇   全域督察员
231
232
233
234
235
236
          <view class="upload-wrap mt-20">
            <view class="upload-title">上传验收图片(选填)</view>
            <up-upload
                :file-list="acceptImgs.rawImgList.value || []"
                @after-read="acceptImgs.uploadImgs"
                @delete="acceptImgs.deleteImg"
6e9f0396   刘淇   全域督察员
237
238
239
240
241
242
243
244
245
246
                multiple
                width="70"
                height="70"
                :max-count="acceptImgs.uploadConfig.maxCount"
                :upload-text="acceptImgs.uploadConfig.uploadText"
                :size-type="acceptImgs.uploadConfig.sizeType"
            />
          </view>
        </view>
      </up-modal>
b6e4a018   王彪总   业务线 小程序不用写死,从后端接口获取
247
248
249
  
      <!-- 统一节点动作弹窗(工作流配置化,未配置时回退原有逻辑) -->
      <unified-task-actions ref="unifiedActionsRef" @success="handleUnifiedSuccess" />
6e9f0396   刘淇   全域督察员
250
251
252
253
254
255
256
257
258
259
260
    </view>
  </template>
  
  <script setup>
  import { ref, computed } from 'vue';
  import { onShow, onLoad } from '@dcloudio/uni-app';
  import { timeFormat } from '@/uni_modules/uview-plus';
  import {
    myBuzSimplePage,
    todoBuzSimplePage,
    doneBuzSimplePage,
6e9f0396   刘淇   全域督察员
261
262
    qyUniversalApproval,
    daquUniversalApproval,
c5fdc60a   刘淇   树详情
263
264
    dcyUniversalApproval,
    aiUniversalApproval
6e9f0396   刘淇   全域督察员
265
  } from '@/api/regional-order-manage/regional-order-manage'
b6e4a018   王彪总   业务线 小程序不用写死,从后端接口获取
266
  import { getTaskActions } from '@/api/work-order-manage/work-order-manage'
6e9f0396   刘淇   全域督察员
267
268
  import { useUserStore } from '@/pinia/user';
  import { nextStepMap, buzStatusMap } from '@/common/utils/common'
6e9f0396   刘淇   全域督察员
269
  import { useUploadImgs } from '@/common/utils/useUploadImgs'
8ddc6f6e   刘淇   登录 修改样式
270
271
  
  // ========== 全局实例 & 常量 ==========
6e9f0396   刘淇   全域督察员
272
  const userStore = useUserStore();
8ddc6f6e   刘淇   登录 修改样式
273
274
275
276
  const USER_ROLES = userStore.userInfo?.roles || [];
  
  // ========== 基础状态 (按模块分组,语义化更强) ==========
  // tab切换
6bce1057   刘淇   ai 大区经理
277
278
  const activeTab = ref(0); // 0-待办 1-已办 2-我发起的
  const tabList = ref([{name: '待办'}, {name: '已办'}, {name: '我发起的'}]);
8ddc6f6e   刘淇   登录 修改样式
279
  // 排序与搜索
6e9f0396   刘淇   全域督察员
280
281
  const selectedSortValue = ref(1);
  const sortOptions = ref([
8ddc6f6e   刘淇   登录 修改样式
282
    {name: '位置', id: 1}, {name: '名称', id: 2}, {name: '描述', id: 3}, {name: '编号', id: 4},
6e9f0396   刘淇   全域督察员
283
  ]);
6e9f0396   刘淇   全域督察员
284
  const searchValue = ref('');
8ddc6f6e   刘淇   登录 修改样式
285
286
  // 分页相关
  const pagingRef = ref(null);
6e9f0396   刘淇   全域督察员
287
  const orderList = ref([]);
8ddc6f6e   刘淇   登录 修改样式
288
289
  
  // ========== 角色权限计算属性 (修复核心bug: 原代码取反逻辑写反) ==========
6e9f0396   刘淇   全域督察员
290
  const isAi = computed(() => {
8ddc6f6e   刘淇   登录 修改样式
291
292
    // AI工单派发人员 不显示新增按钮,其他角色显示
    return !USER_ROLES.includes('AI_dispatcher');
6e9f0396   刘淇   全域督察员
293
  });
8ddc6f6e   刘淇   登录 修改样式
294
295
296
297
298
  
  // ========== 回退弹窗相关 ==========
  const rejectModalShow = ref(false);
  const rejectReason = ref('');
  const currentRejectItem = ref(null);
6e9f0396   刘淇   全域督察员
299
  const rejectImgs = useUploadImgs({
8ddc6f6e   刘淇   登录 修改样式
300
    maxCount: 3, uploadText: '选择回退图片', sizeType: ['compressed'], formRef: null, fieldName: 'rejectImgs'
6e9f0396   刘淇   全域督察员
301
  })
8ddc6f6e   刘淇   登录 修改样式
302
303
304
305
306
307
  
  // ========== 验收弹窗相关 ==========
  const acceptModalShow = ref(false);
  const acceptRadioValue = ref('0'); // 默认通过
  const acceptReason = ref('');
  const currentAcceptItem = ref(null);
6e9f0396   刘淇   全域督察员
308
  const acceptImgs = useUploadImgs({
8ddc6f6e   刘淇   登录 修改样式
309
    maxCount: 3, uploadText: '选择验收图片', sizeType: ['compressed'], formRef: null, fieldName: 'acceptImgs'
6e9f0396   刘淇   全域督察员
310
  })
8ddc6f6e   刘淇   登录 修改样式
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
  
  // ========== 公共封装方法 (核心优化:消灭重复代码) ==========
  /**
   * 生成统一的临时存储key
   * @param {String} prefix 前缀标识
   * @returns {String} 唯一key
   */
  const generateTempKey = (prefix = 'order') => {
    return `${prefix}_${Date.now()}_${Math.floor(Math.random() * 10000)}`;
  };
  
  /**
   * 存储工单数据到本地缓存
   * @param {Object} item 工单数据
   * @param {String} prefix key前缀
   * @returns {String|null} 成功返回key,失败返回null
   */
  const setOrderStorage = (item, prefix) => {
    if (!item?.id) return null;
    const tempKey = generateTempKey(prefix);
    try {
      uni.setStorageSync(tempKey, item);
      return tempKey;
    } catch (error) {
      console.error('存储工单数据失败:', error);
      uni.showToast({title: '数据存储异常,请重试', icon: 'none'});
      return null;
    }
  };
  
  /**
   * 获取分页请求公共参数
   * @param {Number} pageNo 页码
   * @param {Number} pageSize 页大小
   * @returns {Object} 请求参数
   */
  const getQueryParams = (pageNo, pageSize) => {
    return {
      searchContent: searchValue.value.trim() || '',
      pageNo,
      pageSize,
      type: selectedSortValue.value
    };
  };
  
  /**
   * 统一调用审批接口
   * @param {Object} params 请求参数
   * @param {String} taskKey 工单任务key
   * @returns {Promise} 接口请求Promise
   */
  const callApprovalApi = async (params, taskKey) => {
    if (taskKey === 'shRegionManager') return await dcyUniversalApproval(params);
    if (taskKey === 'regionManager') return await qyUniversalApproval(params);
    // 根据角色匹配对应接口
    if (USER_ROLES.includes('regional_manager')) return await daquUniversalApproval(params);
    if (USER_ROLES.includes('Inspector_global')) return await dcyUniversalApproval(params);
    if (USER_ROLES.includes('patrol_global')) return await qyUniversalApproval(params);
c5fdc60a   刘淇   树详情
369
    if (USER_ROLES.includes('AI_dispatcher')) return await  aiUniversalApproval(params);
8ddc6f6e   刘淇   登录 修改样式
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
  };
  
  /**
   * 统一跳转工单页面
   * @param {String} path 页面路径
   * @param {Object} query 拼接参数
   */
  const navToOrderPage = (path, query = {}) => {
    const queryStr = Object.keys(query).map(k => `${k}=${query[k]}`).join('&');
    uni.navigateTo({ url: `${path}${queryStr ? '?' + queryStr : ''}` });
  };
  
  /**
   * 刷新列表 - 统一封装,避免空指针
   */
  const refreshOrderList = () => {
    pagingRef.value && pagingRef.value.reload();
  };
  
  // ========== 业务核心方法 ==========
6e9f0396   刘淇   全域督察员
390
391
392
  // 分页查询列表
  const queryList = async (pageNo, pageSize) => {
    try {
8ddc6f6e   刘淇   登录 修改样式
393
      const params = getQueryParams(pageNo, pageSize);
6e9f0396   刘淇   全域督察员
394
      let res;
8ddc6f6e   刘淇   登录 修改样式
395
      if (activeTab.value === 0) res = await todoBuzSimplePage(params);
6bce1057   刘淇   ai 大区经理
396
      else if (activeTab.value === 2) res = await myBuzSimplePage(params);
8ddc6f6e   刘淇   登录 修改样式
397
398
      else res = await doneBuzSimplePage(params);
      pagingRef.value.complete(res?.list || [], res?.total || 0);
6e9f0396   刘淇   全域督察员
399
400
    } catch (error) {
      console.error('加载工单失败:', error);
8ddc6f6e   刘淇   登录 修改样式
401
      pagingRef.value?.complete(false);
6e9f0396   刘淇   全域督察员
402
403
404
      uni.showToast({title: '加载失败,请重试', icon: 'none'});
    }
  };
8ddc6f6e   刘淇   登录 修改样式
405
  
6e9f0396   刘淇   全域督察员
406
407
  // 标签页切换
  const handleTabChange = (item) => {
6e9f0396   刘淇   全域督察员
408
    activeTab.value = item.index;
8ddc6f6e   刘淇   登录 修改样式
409
410
    orderList.value = [];
    refreshOrderList();
6e9f0396   刘淇   全域督察员
411
  };
8ddc6f6e   刘淇   登录 修改样式
412
  
6e9f0396   刘淇   全域督察员
413
414
415
416
  // 排序变更
  const handleSortChange = (val) => {
    selectedSortValue.value = val.id;
    searchValue.value = '';
8ddc6f6e   刘淇   登录 修改样式
417
    refreshOrderList();
6e9f0396   刘淇   全域督察员
418
  };
8ddc6f6e   刘淇   登录 修改样式
419
  
6e9f0396   刘淇   全域督察员
420
421
422
  // 搜索
  const handleSearch = (val) => {
    searchValue.value = val;
8ddc6f6e   刘淇   登录 修改样式
423
    refreshOrderList();
6e9f0396   刘淇   全域督察员
424
  };
8ddc6f6e   刘淇   登录 修改样式
425
  
6e9f0396   刘淇   全域督察员
426
427
  // 工单详情
  const handleDetail = (item) => {
8ddc6f6e   刘淇   登录 修改样式
428
429
430
431
432
433
434
    if (!item?.taskId) return uni.showToast({title: '工单信息异常', icon: 'none'});
    navToOrderPage('/pages-sub/problem/regional-order-manage/order-detail', {
      taskId: item.taskId,
      activeTab: activeTab.value,
      processInstanceId: item.processInstanceId
    }, {
      needRefresh: () => refreshOrderList()
6e9f0396   刘淇   全域督察员
435
436
    });
  };
8ddc6f6e   刘淇   登录 修改样式
437
438
  
  // 重新提交工单
6e9f0396   刘淇   全域督察员
439
  const handleRenew = (item) => {
8ddc6f6e   刘淇   登录 修改样式
440
441
    const tempKey = setOrderStorage(item, 'renew_order');
    if (!tempKey) return;
6e9f0396   刘淇   全域督察员
442
  
8ddc6f6e   刘淇   登录 修改样式
443
444
445
    const pageUrl = USER_ROLES.includes('patrol_global')
        ? '/pages-sub/problem/regional-order-manage/add-patrol-order'
        : '/pages-sub/problem/regional-order-manage/add-order';
6e9f0396   刘淇   全域督察员
446
  
8ddc6f6e   刘淇   登录 修改样式
447
    navToOrderPage(pageUrl, { isRenew: 1, tempKey });
6e9f0396   刘淇   全域督察员
448
  };
8ddc6f6e   刘淇   登录 修改样式
449
  
b6e4a018   王彪总   业务线 小程序不用写死,从后端接口获取
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
  // ========== 统一节点动作(工作流配置化) ==========
  const unifiedActionsRef = ref(null)
  
  /** 查询当前任务是否已配置统一动作;未配置或接口异常时返回 null,回退原有逻辑 */
  const queryUnifiedActions = async (item) => {
    if (!item || !item.taskId) return null
    try {
      const data = await getTaskActions(item.taskId)
      if (data && data.configured && Array.isArray(data.actions) && data.actions.length > 0) {
        return data.actions
      }
    } catch (e) {
      console.warn('查询统一节点动作失败,回退原有逻辑', e)
    }
    return null
  }
  
  /** 待办-处理工单:已配置统一动作时走新逻辑,否则回退原有处理 */
  const handleUnifiedProcess = async (item) => {
    const actions = await queryUnifiedActions(item)
    if (actions) {
      unifiedActionsRef.value?.open(item, actions)
      return
    }
    handleProcess(item)
  }
  
  /** 统一动作执行成功后刷新列表 */
  const handleUnifiedSuccess = () => {
    pagingRef.value && pagingRef.value.reload()
  }
  
8ddc6f6e   刘淇   登录 修改样式
482
  // 处理工单核心逻辑
6e9f0396   刘淇   全域督察员
483
  const handleProcess = async (item) => {
8ddc6f6e   刘淇   登录 修改样式
484
485
    if (!item) return uni.showToast({title: '工单信息异常', icon: 'none'});
    const stepName = nextStepMap[item.taskKey]?.name;
83673de2   刘淇   ai 大区经理 优化添加结束功能
486
    console.log(stepName)
6e9f0396   刘淇   全域督察员
487
    try {
8ddc6f6e   刘淇   登录 修改样式
488
489
490
491
      // 大区经理分配
      if (stepName === '大区经理分配') {
        const tempKey = setOrderStorage(item, 'distribute_order');
        tempKey && navToOrderPage('/pages-sub/problem/regional-order-manage/distribution-order', { tempKey });
6e9f0396   刘淇   全域督察员
492
      }
8ddc6f6e   刘淇   登录 修改样式
493
494
495
496
497
498
      // 督察员单子大区经理分配
      else if (stepName === '督察员单子大区经理分配') {
        const postData = { taskKey: item.taskKey, taskId: item.taskId, operateType:60, workerDataId:item.id, agree:0, reason:item.remark, roadId:item.roadId, roadName:item.roadName, pressingType:item.pressingType, orderName:item.orderName, expectedFinishDate: item.expectedFinishDate, busiLine:item.busiLine };
        await dcyUniversalApproval(postData);
        uni.showToast({title: '分配成功', icon: 'success'});
        refreshOrderList();
6e9f0396   刘淇   全域督察员
499
      }
8ddc6f6e   刘淇   登录 修改样式
500
501
502
503
504
505
      // 验收弹窗
      else if (['巡查员验收', '养护组长验收'].includes(stepName)) {
        currentAcceptItem.value = item;
        acceptReason.value = '';
        acceptRadioValue.value = '0';
        acceptModalShow.value = true;
6e9f0396   刘淇   全域督察员
506
      }
8ddc6f6e   刘淇   登录 修改样式
507
508
      // 发起人确认-结束工单
      else if (stepName === '发起人确认') {
6e9f0396   刘淇   全域督察员
509
510
511
        uni.showModal({
          title: "结束工单",
          content: "请确定是否结束工单?",
8ddc6f6e   刘淇   登录 修改样式
512
          success: async (res) => {
6e9f0396   刘淇   全域督察员
513
            if (res.confirm) {
6e9f0396   刘淇   全域督察员
514
              const requestData = {
8ddc6f6e   刘淇   登录 修改样式
515
516
                workerDataId: item.id, taskKey: 'ylInspectorStart', taskId: item.taskId,
                operateType: 200, agree: 1, reason: '结束工单'
6e9f0396   刘淇   全域督察员
517
              };
8ddc6f6e   刘淇   登录 修改样式
518
519
520
              await callApprovalApi(requestData, item.taskKey);
              uni.showToast({title: '结束成功', icon: 'success'});
              refreshOrderList();
6e9f0396   刘淇   全域督察员
521
            }
8ddc6f6e   刘淇   登录 修改样式
522
          }
6e9f0396   刘淇   全域督察员
523
524
        });
      }
83673de2   刘淇   ai 大区经理 优化添加结束功能
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
      else if (stepName === 'AI工单派发人员') {
        uni.showModal({
          title: "结束工单",
          content: "请确定是否结束工单?",
          success: async (res) => {
            if (res.confirm) {
              const requestData = {
                workerDataId: item.id, taskKey: 'ylInspectorStart', taskId: item.taskId,
                operateType: 200, agree: 1, reason: 'AI工单派发人员结束工单'
              };
              await callApprovalApi(requestData, item.taskKey);
              uni.showToast({title: '结束成功', icon: 'success'});
              refreshOrderList();
            }
          }
        });
      }
6e9f0396   刘淇   全域督察员
542
543
544
545
546
    } catch (error) {
      console.error('处理工单失败:', error);
      uni.showToast({title: '处理失败,请重试', icon: 'none'});
    }
  };
8ddc6f6e   刘淇   登录 修改样式
547
548
  
  // 回退工单-打开弹窗
6e9f0396   刘淇   全域督察员
549
  const handleReject = (item) => {
8ddc6f6e   刘淇   登录 修改样式
550
    if (!item?.id) return uni.showToast({title: '工单信息异常,无法回退', icon: 'none'});
6e9f0396   刘淇   全域督察员
551
    currentRejectItem.value = item;
8ddc6f6e   刘淇   登录 修改样式
552
553
554
    rejectReason.value = '';
    rejectImgs.clearImgs();
    rejectModalShow.value = true;
6e9f0396   刘淇   全域督察员
555
  };
8ddc6f6e   刘淇   登录 修改样式
556
557
  
  // 关闭回退弹窗-重置状态
6e9f0396   刘淇   全域督察员
558
559
560
  const handleRejectModalCancel = () => {
    rejectModalShow.value = false;
    rejectReason.value = '';
8ddc6f6e   刘淇   登录 修改样式
561
    rejectImgs.clearImgs();
6e9f0396   刘淇   全域督察员
562
  };
8ddc6f6e   刘淇   登录 修改样式
563
  
6e9f0396   刘淇   全域督察员
564
565
  // 确认回退工单
  const confirmReject = async () => {
8ddc6f6e   刘淇   登录 修改样式
566
567
568
569
570
571
    const reason = rejectReason.value.trim();
    if (!reason) return uni.showToast({title: '请填写回退原因', icon: 'none'});
    const item = currentRejectItem.value;
    if (!item?.id) return uni.showToast({title: '工单信息异常', icon: 'none'});
  
    uni.showLoading({title: '提交中...', mask: true});
6e9f0396   刘淇   全域督察员
572
    try {
6e9f0396   刘淇   全域督察员
573
      const requestData = {
8ddc6f6e   刘淇   登录 修改样式
574
575
        returnImgs: rejectImgs.getSuccessImgUrls(), workerDataId: item.id, taskKey: item.taskKey,
        taskId: item.taskId, operateType: nextStepMap[item.taskKey].operateTypeNoPass, agree:1, reason
6e9f0396   刘淇   全域督察员
576
      };
8ddc6f6e   刘淇   登录 修改样式
577
578
579
580
      await callApprovalApi(requestData, item.taskKey);
      uni.showToast({title: '回退成功', icon: 'success'});
      handleRejectModalCancel();
      refreshOrderList();
6e9f0396   刘淇   全域督察员
581
582
    } catch (error) {
      console.error('回退工单失败:', error);
8ddc6f6e   刘淇   登录 修改样式
583
      uni.showToast({title: '回退失败,请重试', icon: 'none'});
6e9f0396   刘淇   全域督察员
584
    } finally {
6e9f0396   刘淇   全域督察员
585
586
587
      uni.hideLoading();
    }
  };
8ddc6f6e   刘淇   登录 修改样式
588
  
6e9f0396   刘淇   全域督察员
589
590
  // 新增工单
  const handleAddOrder = () => {
8ddc6f6e   刘淇   登录 修改样式
591
592
593
594
    const pageUrl = USER_ROLES.includes('patrol_global')
        ? '/pages-sub/problem/regional-order-manage/add-patrol-order'
        : '/pages-sub/problem/regional-order-manage/add-order';
    navToOrderPage(pageUrl);
6e9f0396   刘淇   全域督察员
595
  };
8ddc6f6e   刘淇   登录 修改样式
596
597
  
  // 关闭验收弹窗-重置状态
6e9f0396   刘淇   全域督察员
598
599
  const handleAcceptModalCancel = () => {
    acceptModalShow.value = false;
8ddc6f6e   刘淇   登录 修改样式
600
601
602
    acceptReason.value = '';
    acceptRadioValue.value = '0';
    acceptImgs.clearImgs();
6e9f0396   刘淇   全域督察员
603
  };
8ddc6f6e   刘淇   登录 修改样式
604
605
  
  // 验收提交
6e9f0396   刘淇   全域督察员
606
  const handleAcceptModalConfirm = async () => {
8ddc6f6e   刘淇   登录 修改样式
607
    const reason = acceptReason.value.trim();
6bce1057   刘淇   ai 大区经理
608
609
    console.log(acceptRadioValue.value)
    if (!reason&&acceptRadioValue.value==1) return uni.showToast({title: '请填写验收原因', icon: 'none'});
8ddc6f6e   刘淇   登录 修改样式
610
    if (reason.length > 200) return uni.showToast({title: '验收原因最多200字', icon: 'none'});
6e9f0396   刘淇   全域督察员
611
  
8ddc6f6e   刘淇   登录 修改样式
612
613
614
615
616
617
618
619
620
621
622
623
624
    const item = currentAcceptItem.value;
    if (!item?.id) return uni.showToast({title: '工单信息异常', icon: 'none'});
  
    try {
      const postData = {
        returnImgs: acceptImgs.getSuccessImgUrls(), taskKey: item.taskKey, workerDataId: item.id,
        taskId: item.taskId, agree: acceptRadioValue.value, reason,
        operateType: acceptRadioValue.value === '0' ? nextStepMap[item.taskKey].operateTypePass : nextStepMap[item.taskKey].operateTypeNoPass
      };
      await callApprovalApi(postData, item.taskKey);
      uni.showToast({title: '提交成功', icon: 'success'});
      handleAcceptModalCancel();
      refreshOrderList();
6e9f0396   刘淇   全域督察员
625
    } catch (error) {
6e9f0396   刘淇   全域督察员
626
      console.error('验收失败:', error);
8ddc6f6e   刘淇   登录 修改样式
627
      uni.showToast({title: '验收提交失败,请重试', icon: 'none'});
6e9f0396   刘淇   全域督察员
628
629
    }
  };
8ddc6f6e   刘淇   登录 修改样式
630
631
  
  // ========== 页面生命周期 ==========
83673de2   刘淇   ai 大区经理 优化添加结束功能
632
633
634
635
  // onLoad(() => {
  //   refreshOrderList();
  // });
  onShow(() => {
8ddc6f6e   刘淇   登录 修改样式
636
    refreshOrderList();
6e9f0396   刘淇   全域督察员
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
  });
  </script>
  
  <style scoped lang="scss">
  .page-container {
    min-height: 100vh;
    background-color: #fafafa;
  }
  
  // 顶部固定区域
  .header-wrap {
    background-color: #fff;
  }
  
  // 搜索栏样式
  .search-header {
    display: flex;
    align-items: center;
    padding: 20rpx;
    box-sizing: border-box;
  
    .select-wrap {
      width: 120rpx;
      margin-right: 20rpx;
8ddc6f6e   刘淇   登录 修改样式
661
      :deep(.u-select), :deep(.u-input__placeholder) {
6e9f0396   刘淇   全域督察员
662
663
664
        width: 100%;
        font-size: 28rpx;
      }
6e9f0396   刘淇   全域督察员
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
    }
  
    .search-input-wrap {
      flex: 1;
    }
  }
  
  // 工单卡片样式
  .order-card {
    margin: 0 20rpx 20rpx;
    background: #fff;
    border-radius: 12rpx;
    box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
  }
  
83673de2   刘淇   ai 大区经理 优化添加结束功能
680
681
682
683
684
  .u-body-item-btn-wrap :deep(.u-button--large){
    height: 28px;
  }
  
  
8ddc6f6e   刘淇   登录 修改样式
685
686
  // 弹窗公共样式
  .reject-modal-content, .accept-modal-content {
6e9f0396   刘淇   全域督察员
687
688
689
690
691
    width: 100%;
    box-sizing: border-box;
    padding: 10rpx 0;
  }
  
6e9f0396   刘淇   全域督察员
692
  .upload-wrap {
6e9f0396   刘淇   全域督察员
693
694
695
696
697
698
699
    .upload-title {
      font-size: 28rpx;
      color: #333;
      margin-bottom: 10rpx;
    }
  }
  
8ddc6f6e   刘淇   登录 修改样式
700
  // 验收弹窗单选框样式
6e9f0396   刘淇   全域督察员
701
702
703
  .radio-group-wrap {
    display: flex;
    align-items: center;
8ddc6f6e   刘淇   登录 修改样式
704
    gap: 40rpx;
6e9f0396   刘淇   全域督察员
705
706
707
708
709
710
    font-size: 28rpx;
    margin-bottom: 20rpx;
  }
  
  .textarea-wrap {
    width: 100%;
6e9f0396   刘淇   全域督察员
711
712
  }
  
8ddc6f6e   刘淇   登录 修改样式
713
714
715
  // 间距公共样式
  .mt-20 { margin-top: 20rpx; }
  .mt-30 { margin-top: 30rpx; }
6e9f0396   刘淇   全域督察员
716
  </style>