f0ec74d6
刘淇
大区经理派单
|
1
2
3
|
<template>
<view class="page-container">
<view class="work-order-form-content commonPageLRpadding">
|
3cbb8754
刘淇
动态字典
|
4
|
<up-form label-position="left" :model="baseForm" ref="workOrderFormRef" labelWidth="200rpx">
|
ecbfbe06
刘淇
树巡检记录
|
5
|
<!-- 1. 工单位置(地图选择)【公共项】 -->
|
3cbb8754
刘淇
动态字典
|
6
7
8
9
|
<up-form-item label="工单位置" prop="workLocation" border-bottom required
@click="chooseWorkLocation(); hideKeyboard()">
<up-input v-model="baseForm.workLocation" border="none" readonly suffix-icon="map-fill"
placeholder="点击选择工单位置"></up-input>
|
f0ec74d6
刘淇
大区经理派单
|
10
|
</up-form-item>
|
ecbfbe06
刘淇
树巡检记录
|
11
|
<!-- 2. 情况描述【公共项】 -->
|
3cbb8754
刘淇
动态字典
|
12
13
14
|
<up-form-item label="情况描述" prop="problemDesc" required border-bottom>
<up-textarea placeholder="请输入情况描述(最多200字)" v-model.trim="baseForm.problemDesc" count maxlength="200" rows="4"
@blur="() => workOrderFormRef.validateField('problemDesc')"></up-textarea>
|
f0ec74d6
刘淇
大区经理派单
|
15
|
</up-form-item>
|
ecbfbe06
刘淇
树巡检记录
|
16
|
<!-- 3. 问题照片【公共项】 -->
|
3cbb8754
刘淇
动态字典
|
17
18
19
20
21
|
<up-form-item label="问题照片" prop="problemImgs" required>
<up-upload :file-list="problemImgs.imgList.value || []" @after-read="problemImgs.uploadImgs"
@delete="problemImgs.deleteImg" multiple :width="70" :height="70"
:max-count="problemImgs.uploadConfig.maxCount" :upload-text="problemImgs.uploadText"
:size-type="problemImgs.uploadConfig.sizeType"></up-upload>
|
f0ec74d6
刘淇
大区经理派单
|
22
|
</up-form-item>
|
ecbfbe06
刘淇
树巡检记录
|
23
24
|
<!-- 多组派单区域 -->
<view class="dispatch-list-wrap">
|
f0ec74d6
刘淇
大区经理派单
|
25
|
<view class="dispatch-title">派单情况</view>
|
ecbfbe06
刘淇
树巡检记录
|
26
27
28
29
30
|
<!-- 循环渲染每组派单 -->
<view class="dispatch-item" v-for="(item, idx) in dispatchList" :key="idx">
<view class="item-head">
<text>派单{{ idx + 1 }}</text>
<!-- 数量大于1才显示红色关闭X -->
|
3cbb8754
刘淇
动态字典
|
31
32
|
<up-icon v-if="dispatchList.length > 1" name="close" color="#f53f3f" size="26" class="close-icon"
@click="delDispatchItem(idx)"></up-icon>
|
ecbfbe06
刘淇
树巡检记录
|
33
|
</view>
|
ecbfbe06
刘淇
树巡检记录
|
34
|
<!-- 业务线 -->
|
3cbb8754
刘淇
动态字典
|
35
36
37
38
|
<up-form-item label="业务线" prop="busiLineCn" border-bottom required
@click="handleActionSheetOpen('busiLine', idx); hideKeyboard()">
<up-input v-model="item.busiLineCn" disabled disabled-color="#ffffff" placeholder="请选择业务线"
border="none"></up-input>
|
ecbfbe06
刘淇
树巡检记录
|
39
40
41
42
|
<template #right>
<up-icon name="arrow-right" size="16"></up-icon>
</template>
</up-form-item>
|
ecbfbe06
刘淇
树巡检记录
|
43
|
<!-- 问题类型 -->
|
3cbb8754
刘淇
动态字典
|
44
45
46
47
|
<up-form-item label="问题类型" prop="orderName" border-bottom required
@click="openCascader(idx); hideKeyboard()">
<up-input v-model="item.orderName" disabled disabled-color="#ffffff" placeholder="请选择问题类型"
border="none"></up-input>
|
ecbfbe06
刘淇
树巡检记录
|
48
49
50
51
|
<template #right>
<up-icon name="arrow-right" size="16"></up-icon>
</template>
</up-form-item>
|
ecbfbe06
刘淇
树巡检记录
|
52
|
<!-- 道路名称 -->
|
3cbb8754
刘淇
动态字典
|
53
54
55
56
|
<up-form-item label="道路名称" prop="roadName" border-bottom required
@click="handleActionSheetOpen('roadName', idx); hideKeyboard()">
<up-input v-model="item.roadName" readonly disabled-color="#ffffff" placeholder="请先选择工单位置"
border="none"></up-input>
|
ecbfbe06
刘淇
树巡检记录
|
57
58
59
60
|
<template #right>
<up-icon name="arrow-right" size="16"></up-icon>
</template>
</up-form-item>
|
ecbfbe06
刘淇
树巡检记录
|
61
|
<!-- 紧急程度 -->
|
3cbb8754
刘淇
动态字典
|
62
63
64
65
|
<up-form-item label="紧急程度" prop="pressingTypeName" border-bottom required
@click="handleActionSheetOpen('pressingType', idx); hideKeyboard()">
<up-input v-model="item.pressingTypeName" disabled disabled-color="#ffffff" placeholder="请选择紧急程度"
border="none"></up-input>
|
ecbfbe06
刘淇
树巡检记录
|
66
67
68
69
|
<template #right>
<up-icon name="arrow-right" size="16"></up-icon>
</template>
</up-form-item>
|
ecbfbe06
刘淇
树巡检记录
|
70
|
<!-- 每组派单独立:希望完成时间 -->
|
3cbb8754
刘淇
动态字典
|
71
72
|
<up-form-item label="希望完成时间" @click="openItemDatePicker(idx); hideKeyboard()">
<up-input v-model="item.expectedFinishDate" border="none" readonly placeholder="点击选择时间"></up-input>
|
ecbfbe06
刘淇
树巡检记录
|
73
74
75
76
77
78
79
80
|
<template #right>
<view v-if="item.expectedFinishDate" @click.stop>
<up-icon name="close" size="16" @click.stop="clearItemDate(idx)"></up-icon>
</view>
<up-icon name="arrow-right" size="16" v-else></up-icon>
</template>
</up-form-item>
</view>
|
f0ec74d6
刘淇
大区经理派单
|
81
|
</view>
|
ecbfbe06
刘淇
树巡检记录
|
82
83
|
<!-- 新增派单按钮 -->
<view class="add-dispatch-btn-wrap" v-if="!isRenew">
|
3cbb8754
刘淇
动态字典
|
84
85
86
|
<up-button type="primary" plain text="新增派单"
:disabled="dispatchList.length >= 3 || getAvailableBusiLineList().length === 0"
@click="addDispatchItem"></up-button>
|
ecbfbe06
刘淇
树巡检记录
|
87
|
</view>
|
f0ec74d6
刘淇
大区经理派单
|
88
89
|
</up-form>
</view>
|
f0ec74d6
刘淇
大区经理派单
|
90
91
|
<!-- 底部提交按钮 -->
<view class="fixed-bottom-btn-wrap">
|
8ddc6f6e
刘淇
登录 修改样式
|
92
|
<up-button type="primary" text="提交工单" @click="submitWorkOrder"></up-button>
|
f0ec74d6
刘淇
大区经理派单
|
93
|
</view>
|
ecbfbe06
刘淇
树巡检记录
|
94
|
<!-- 通用下拉弹窗:业务线 / 道路 / 紧急程度 共用 -->
|
3cbb8754
刘淇
动态字典
|
95
96
97
|
<up-action-sheet :show="showActionSheet" :actions="currentActionSheetData.list"
:title="currentActionSheetData.title" @close="handleActionSheetClose"
@select="handleActionSheetSelect"></up-action-sheet>
|
ecbfbe06
刘淇
树巡检记录
|
98
|
<!-- 问题类型 级联选择器 -->
|
3cbb8754
刘淇
动态字典
|
99
100
|
<up-cascader v-model="cascaderValue" :data="cascaderOptions" v-model:show="showCascader" title="问题类型"
:auto-close="false" @confirm="cascaderConfirm"></up-cascader>
|
ecbfbe06
刘淇
树巡检记录
|
101
|
<!-- 单独时间选择器(给每组派单用) -->
|
3cbb8754
刘淇
动态字典
|
102
103
|
<up-datetime-picker :show="showItemDatePicker" v-model="tempDateValue" mode="datetime" :min-date="Date.now()"
@cancel="closeItemDatePicker" @confirm="itemDateConfirm"></up-datetime-picker>
|
f0ec74d6
刘淇
大区经理派单
|
104
105
|
</view>
</template>
|
f0ec74d6
刘淇
大区经理派单
|
106
|
<script setup>
|
3cbb8754
刘淇
动态字典
|
107
|
import { ref, reactive, nextTick, computed } from 'vue'
|
8ddc6f6e
刘淇
登录 修改样式
|
108
|
import { onReady, onShow, onLoad, onBackPress } from '@dcloudio/uni-app';
|
f0ec74d6
刘淇
大区经理派单
|
109
|
import { useUploadImgs } from '@/common/utils/useUploadImgs'
|
ecbfbe06
刘淇
树巡检记录
|
110
|
import { getRoadListByLatLng, getProblemListByType } from '@/api/common'
|
8ddc6f6e
刘淇
登录 修改样式
|
111
|
import {
|
3cbb8754
刘淇
动态字典
|
112
113
|
daquUniversalApproval, qyUniversalApproval, qyWorkorderCreate, dycCreateBatchNew,
dcyUniversalApproval, daquWorkorderCreate, dcyWorkorderCreate
|
8ddc6f6e
刘淇
登录 修改样式
|
114
|
} from '@/api/regional-order-manage/regional-order-manage'
|
f0ec74d6
刘淇
大区经理派单
|
115
116
117
|
import { timeFormat } from '@/uni_modules/uview-plus'
import { nextStepMap } from '@/common/utils/common'
import { useUserStore } from '@/pinia/user';
|
ecbfbe06
刘淇
树巡检记录
|
118
|
// ========== 常量配置区 ==========
|
8ddc6f6e
刘淇
登录 修改样式
|
119
|
const CONST = {
|
3cbb8754
刘淇
动态字典
|
120
121
122
123
|
DICT_PRESSING_TYPE: 'workorder_pressing_type',
UPLOAD_CONFIG: { maxCount: 3, uploadText: '选择问题照片', sizeType: ['compressed'] },
PAGE_ORDER_LIST: '/pages-sub/problem/regional-order-manage/index',
ROLE: { MANAGER: 'regional_manager', INSPECTOR: 'Inspector_global', PATROL: 'patrol_global', LEADER: 'Inspector_global_leader' }
|
8ddc6f6e
刘淇
登录 修改样式
|
124
|
}
|
ecbfbe06
刘淇
树巡检记录
|
125
|
// ========== 全局实例 & 基础状态 ==========
|
8ddc6f6e
刘淇
登录 修改样式
|
126
127
128
129
|
const userStore = useUserStore();
const USER_ROLES = userStore.userInfo?.roles || [];
const workOrderFormRef = ref(null);
const showActionSheet = ref(false);
|
8ddc6f6e
刘淇
登录 修改样式
|
130
131
|
const isRenew = ref(false);
const renewOrderData = ref(null);
|
ecbfbe06
刘淇
树巡检记录
|
132
133
|
// 当前操作的派单项下标
const currentDispatchIndex = ref(0);
|
ecbfbe06
刘淇
树巡检记录
|
134
135
136
137
|
// 三级级联选择器
const showCascader = ref(false);
const cascaderValue = ref([]);
const cascaderOptions = ref([]);
|
ecbfbe06
刘淇
树巡检记录
|
138
139
|
// 下拉弹窗数据
const currentActionSheetData = reactive({ type: '', list: [], title: '', index: 0 });
|
8ddc6f6e
刘淇
登录 修改样式
|
140
|
const roadNameList = ref([]);
|
8ddc6f6e
刘淇
登录 修改样式
|
141
|
const pressingTypeList = ref([]);
|
f0ec74d6
刘淇
大区经理派单
|
142
|
const busiLineOptions = ref([]);
|
ecbfbe06
刘淇
树巡检记录
|
143
|
const currentBusiLineCode = ref('');
|
ecbfbe06
刘淇
树巡检记录
|
144
145
146
147
|
// 每组派单独立时间选择器
const showItemDatePicker = ref(false);
const tempDateValue = ref(Date.now());
const curSelectDateIndex = ref(-1);
|
ecbfbe06
刘淇
树巡检记录
|
148
|
// 图片上传
|
f0ec74d6
刘淇
大区经理派单
|
149
|
const problemImgs = useUploadImgs({
|
3cbb8754
刘淇
动态字典
|
150
151
152
|
...CONST.UPLOAD_CONFIG,
formRef: workOrderFormRef,
fieldName: 'problemImgs'
|
f0ec74d6
刘淇
大区经理派单
|
153
|
})
|
8ddc6f6e
刘淇
登录 修改样式
|
154
|
if (!Array.isArray(problemImgs.rawImgList.value)) problemImgs.rawImgList.value = [];
|
f0ec74d6
刘淇
大区经理派单
|
155
|
|
3cbb8754
刘淇
动态字典
|
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
// ===================== 【动态构建业务线双向映射,从 userStore.dictList】=====================
let busiLineEnToCnMap = {}; // code -> 中文
let busiLineCnToEnMap = {}; // 中文 -> code
/**
* 从dictList构建业务线双向map
* @param {Array} dictList userStore.dictList
*/
const buildBusiLineMap = (dictList) => {
busiLineEnToCnMap = {};
busiLineCnToEnMap = {};
if (!Array.isArray(dictList)) return;
dictList.forEach(item => {
const code = item.value?.trim();
const name = item.label?.trim();
if (code && name) {
busiLineEnToCnMap[code] = name;
busiLineCnToEnMap[name] = code;
}
})
}
// 工具方法(替换原来硬编码BUSI_LINE_MAP)
const busiLineCnToEn = (cn) => busiLineCnToEnMap[cn] || '';
const busiLineEnToCn = (en) => busiLineEnToCnMap[en] || '';
// ==========================================================================
// ===================== 【新增方法:获取已占用业务线code】=====================
const getUsedBusiCodeList = () => {
return dispatchList.value
.filter(item => !!item.busiLineCode)
.map(item => item.busiLineCode)
}
/**
* 获取【当前可选业务线】:排除已经被其他派单项占用的业务线
* @param {number} currentIdx 当前正在操作的派单项下标
*/
const getAvailableBusiLineList = (currentIdx = -1) => {
const usedCodes = getUsedBusiCodeList()
return busiLineOptions.value.filter(opt => {
// 如果是当前这条自己已经选中的业务线,保留;其他派单项占用的过滤掉
const isSelfSelected = dispatchList.value[currentIdx]?.busiLineCode === opt.value
const isUsedByOther = usedCodes.includes(opt.value) && !isSelfSelected
return !isUsedByOther
})
}
// ==========================================================================
|
ecbfbe06
刘淇
树巡检记录
|
201
202
|
// ========== 公共表单(所有派单共用) ==========
const baseForm = reactive({
|
3cbb8754
刘淇
动态字典
|
203
204
205
206
|
workLocation: '',
problemDesc: '',
lat: 0,
lon: 0
|
4c54ad5d
刘淇
转工单 选择是 传紧急程度和...
|
207
|
})
|
ecbfbe06
刘淇
树巡检记录
|
208
209
|
// ========== 派单列表(多组派单核心数组) ==========
const createDispatchItem = (defaultBusiLine = null) => {
|
3cbb8754
刘淇
动态字典
|
210
211
212
213
214
215
216
217
218
219
|
return {
busiLineCn: defaultBusiLine?.name || '',
busiLineCode: defaultBusiLine?.value || '',
roadId: 0,
roadName: '',
orderName: '',
orderCode: '',
pressingType: '',
pressingTypeName: '',
expectedFinishDate: '' // 每组独立完成时间
|
ecbfbe06
刘淇
树巡检记录
|
220
221
222
223
|
}
}
// 初始化默认 1 组派单
const dispatchList = ref([createDispatchItem()])
|
ecbfbe06
刘淇
树巡检记录
|
224
|
// ========== 表单校验规则 ==========
|
f0ec74d6
刘淇
大区经理派单
|
225
|
const workOrderFormRules = reactive({
|
3cbb8754
刘淇
动态字典
|
226
227
|
workLocation: [{ type: 'string', required: true, message: '请选择工单位置', trigger: ['change', 'blur'] }],
problemDesc: [
|
f0ec74d6
刘淇
大区经理派单
|
228
229
230
|
{ type: 'string', required: true, message: '请输入情况描述', trigger: ['change', 'blur'] },
{ type: 'string', min: 3, max: 200, message: '情况描述需3-200字', trigger: ['change', 'blur'] }
],
|
3cbb8754
刘淇
动态字典
|
231
|
problemImgs: [problemImgs.imgValidateRule]
|
f0ec74d6
刘淇
大区经理派单
|
232
|
})
|
ecbfbe06
刘淇
树巡检记录
|
233
|
// ========== 工具方法 ==========
|
8ddc6f6e
刘淇
登录 修改样式
|
234
|
const toOrderListPage = () => uni.reLaunch({ url: CONST.PAGE_ORDER_LIST });
|
8ddc6f6e
刘淇
登录 修改样式
|
235
|
const formatDate = (dateVal, fmt = 'yyyy-mm-dd hh:MM:ss') => dateVal ? timeFormat(dateVal, fmt) : '';
|
ecbfbe06
刘淇
树巡检记录
|
236
|
const dateToTimestamp = (dateStr) => dateStr ? new Date(dateStr).getTime() : '';
|
8ddc6f6e
刘淇
登录 修改样式
|
237
|
/**
|
ecbfbe06
刘淇
树巡检记录
|
238
|
* 加载三级问题类型级联数据
|
8ddc6f6e
刘淇
登录 修改样式
|
239
|
*/
|
ecbfbe06
刘淇
树巡检记录
|
240
|
const loadProblemCascader = async (parentCode) => {
|
3cbb8754
刘淇
动态字典
|
241
242
243
|
if (!parentCode) {
cascaderOptions.value = [];
return;
|
ecbfbe06
刘淇
树巡检记录
|
244
|
}
|
3cbb8754
刘淇
动态字典
|
245
246
247
248
|
try {
uni.showLoading({ title: '加载类型中...' });
const res = await getProblemListByType({ parentCode });
cascaderOptions.value = res || [];
|
ecbfbe06
刘淇
树巡检记录
|
249
|
} catch (err) {
|
3cbb8754
刘淇
动态字典
|
250
251
252
|
console.error('加载问题类型失败', err);
uni.showToast({ title: '问题类型加载失败', icon: 'none' });
cascaderOptions.value = [];
|
ecbfbe06
刘淇
树巡检记录
|
253
|
} finally {
|
3cbb8754
刘淇
动态字典
|
254
|
uni.hideLoading();
|
ecbfbe06
刘淇
树巡检记录
|
255
256
|
}
};
|
ecbfbe06
刘淇
树巡检记录
|
257
258
|
/** 打开级联选择器 */
const openCascader = (idx) => {
|
3cbb8754
刘淇
动态字典
|
259
260
261
262
263
|
currentDispatchIndex.value = idx;
const item = dispatchList.value[idx];
if (!item.busiLineCode) {
uni.showToast({ title: '请先选择业务线', icon: 'none' });
return;
|
ecbfbe06
刘淇
树巡检记录
|
264
|
}
|
3cbb8754
刘淇
动态字典
|
265
266
267
268
|
if (!cascaderOptions.value || cascaderOptions.value.length === 0) {
uni.showToast({ title: '正在加载问题类型,请稍等', icon: 'none' });
loadProblemCascader(item.busiLineCode);
return;
|
ecbfbe06
刘淇
树巡检记录
|
269
|
}
|
3cbb8754
刘淇
动态字典
|
270
271
|
cascaderValue.value = [];
showCascader.value = true;
|
ecbfbe06
刘淇
树巡检记录
|
272
|
};
|
ecbfbe06
刘淇
树巡检记录
|
273
274
|
/** 级联选择确认回调 */
const cascaderConfirm = (selectedArr) => {
|
3cbb8754
刘淇
动态字典
|
275
276
277
278
279
280
281
282
283
284
285
|
const idx = currentDispatchIndex.value;
const item = dispatchList.value[idx];
console.log('最终选中值数组:', selectedArr);
const getLabelByValueList = (list, valList) => {
const labelArr = [];
let currentList = list;
for (const val of valList) {
const target = currentList.find(item => item.value === val);
if (!target) break;
labelArr.push(target.label);
currentList = target.children || [];
|
ecbfbe06
刘淇
树巡检记录
|
286
|
}
|
3cbb8754
刘淇
动态字典
|
287
|
return labelArr.join('/');
|
ecbfbe06
刘淇
树巡检记录
|
288
|
};
|
3cbb8754
刘淇
动态字典
|
289
290
291
292
293
|
const fullLabel = getLabelByValueList(cascaderOptions.value, selectedArr);
item.orderName = fullLabel;
item.orderCode = selectedArr.at(-1);
cascaderValue.value = selectedArr;
workOrderFormRef.value?.validateField('orderName');
|
ecbfbe06
刘淇
树巡检记录
|
294
|
};
|
ecbfbe06
刘淇
树巡检记录
|
295
296
|
// ========== 每组派单 时间选择相关 ==========
const openItemDatePicker = (idx) => {
|
3cbb8754
刘淇
动态字典
|
297
298
299
|
curSelectDateIndex.value = idx;
tempDateValue.value = Date.now();
showItemDatePicker.value = true;
|
ecbfbe06
刘淇
树巡检记录
|
300
301
|
};
const closeItemDatePicker = () => {
|
3cbb8754
刘淇
动态字典
|
302
303
|
showItemDatePicker.value = false;
curSelectDateIndex.value = -1;
|
ecbfbe06
刘淇
树巡检记录
|
304
305
|
};
const itemDateConfirm = (e) => {
|
3cbb8754
刘淇
动态字典
|
306
307
308
|
const idx = curSelectDateIndex.value;
if (idx > -1 && dispatchList.value[idx]) {
dispatchList.value[idx].expectedFinishDate = formatDate(e.value);
|
ecbfbe06
刘淇
树巡检记录
|
309
|
}
|
3cbb8754
刘淇
动态字典
|
310
|
closeItemDatePicker();
|
ecbfbe06
刘淇
树巡检记录
|
311
312
|
};
const clearItemDate = (idx) => {
|
3cbb8754
刘淇
动态字典
|
313
|
dispatchList.value[idx].expectedFinishDate = '';
|
ecbfbe06
刘淇
树巡检记录
|
314
|
};
|
ecbfbe06
刘淇
树巡检记录
|
315
316
317
|
// ========== 新增 / 删除 派单项 ==========
/** 新增派单 */
const addDispatchItem = () => {
|
3cbb8754
刘淇
动态字典
|
318
319
320
321
322
323
324
325
|
if (dispatchList.value.length >= 3) return;
// 【修改】新增取剩下可用业务线第一条
const availList = getAvailableBusiLineList()
const firstBusi = availList[0] || null;
dispatchList.value.push(createDispatchItem(firstBusi));
if (firstBusi) {
currentBusiLineCode.value = firstBusi.value;
loadProblemCascader(firstBusi.value);
|
ecbfbe06
刘淇
树巡检记录
|
326
327
|
}
};
|
ecbfbe06
刘淇
树巡检记录
|
328
329
|
/** 删除派单项 */
const delDispatchItem = (idx) => {
|
3cbb8754
刘淇
动态字典
|
330
331
|
if (dispatchList.value.length <= 1) return;
dispatchList.value.splice(idx, 1);
|
ecbfbe06
刘淇
树巡检记录
|
332
|
};
|
ecbfbe06
刘淇
树巡检记录
|
333
334
|
// 生命周期
onLoad(async (options) => {
|
3cbb8754
刘淇
动态字典
|
335
336
337
338
339
340
341
342
343
344
345
|
initBusiLineOptions();
// 初始化第一组派单默认业务线
if (busiLineOptions.value.length) {
const availList = getAvailableBusiLineList(0)
const firstLine = availList[0];
dispatchList.value[0].busiLineCn = firstLine.name;
dispatchList.value[0].busiLineCode = firstLine.value;
currentBusiLineCode.value = firstLine.value;
// 非重新提交才默认加载级联
if (!(options.isRenew == 1 && options.tempKey)) {
loadProblemCascader(firstLine.value);
|
ecbfbe06
刘淇
树巡检记录
|
346
347
|
}
}
|
3cbb8754
刘淇
动态字典
|
348
349
350
|
// 重新提交场景:等待回显完成
if (options.isRenew == 1 && options.tempKey) {
await handleRenewOptions(options.tempKey);
|
ecbfbe06
刘淇
树巡检记录
|
351
|
}
|
f0ec74d6
刘淇
大区经理派单
|
352
|
});
|
f0ec74d6
刘淇
大区经理派单
|
353
|
onReady(() => {
|
3cbb8754
刘淇
动态字典
|
354
355
|
nextTick(() => {
workOrderFormRef.value?.setRules(workOrderFormRules);
|
8ddc6f6e
刘淇
登录 修改样式
|
356
357
|
});
});
|
f0ec74d6
刘淇
大区经理派单
|
358
|
onShow(() => {
|
3cbb8754
刘淇
动态字典
|
359
|
pressingTypeList.value = uni.$dict.transformLabelValueToNameValue(uni.$dict.getDictSimpleList(CONST.DICT_PRESSING_TYPE));
|
8ddc6f6e
刘淇
登录 修改样式
|
360
|
});
|
ecbfbe06
刘淇
树巡检记录
|
361
362
|
// 物理返回拦截
onBackPress(() => {
|
3cbb8754
刘淇
动态字典
|
363
364
|
uni.redirectTo({ url: CONST.PAGE_ORDER_LIST });
return true;
|
ecbfbe06
刘淇
树巡检记录
|
365
|
});
|
ecbfbe06
刘淇
树巡检记录
|
366
|
// ========== 业务线相关 ==========
|
8ddc6f6e
刘淇
登录 修改样式
|
367
|
const initBusiLineOptions = () => {
|
3cbb8754
刘淇
动态字典
|
368
369
370
371
372
373
374
375
376
377
|
// 从userStore.dictList构建双向映射
buildBusiLineMap(userStore.dictList);
// 用户拥有的业务线code数组
const rawBusiLines = userStore.userInfo?.user?.busiLine?.split(',') || [];
// 过滤dict,只保留用户有权限的业务线,组装 {name, value}
busiLineOptions.value = userStore.dictList
.filter(dictItem => rawBusiLines.includes(dictItem.value))
.map(dictItem => ({
name: dictItem.label,
value: dictItem.value
|
ecbfbe06
刘淇
树巡检记录
|
378
|
}));
|
8ddc6f6e
刘淇
登录 修改样式
|
379
|
};
|
ecbfbe06
刘淇
树巡检记录
|
380
381
|
/** 业务线切换联动清空数据并重新加载级联 */
const handleBusiLineChange = (code, idx) => {
|
3cbb8754
刘淇
动态字典
|
382
383
384
385
386
387
388
389
390
391
|
const item = dispatchList.value[idx];
item.roadName = '';
item.roadId = 0;
item.orderName = '';
item.orderCode = '';
cascaderValue.value = [];
roadNameList.value = [];
currentBusiLineCode.value = code;
loadProblemCascader(code);
if (baseForm.workLocation) getRoadListByBusiLine();
|
f0ec74d6
刘淇
大区经理派单
|
392
|
};
|
ecbfbe06
刘淇
树巡检记录
|
393
|
/** 根据经纬度+业务线获取道路列表 */
|
f0ec74d6
刘淇
大区经理派单
|
394
|
const getRoadListByBusiLine = async () => {
|
3cbb8754
刘淇
动态字典
|
395
396
397
398
399
400
401
402
403
|
if (!baseForm.lat || !baseForm.lon) return;
const busiLineEn = busiLineCnToEn(dispatchList.value[0].busiLineCn);
if (!busiLineEn) return uni.showToast({ title: '业务线选择异常', icon: 'none' });
try {
uni.showLoading({ title: '获取道路名称中...' });
const roadRes = await getRoadListByLatLng({
busiLine: busiLineEn,
latitude: baseForm.lat,
longitude: baseForm.lon
|
ecbfbe06
刘淇
树巡检记录
|
404
|
});
|
3cbb8754
刘淇
动态字典
|
405
406
407
408
|
roadNameList.value = Array.isArray(roadRes)
? roadRes.map(item => ({ name: item.roadName || '', code: item.roadCode || '', id: item.roadId || 0 }))
: [{ name: '未查询到道路名称', code: '', id: 0 }];
!Array.isArray(roadRes) && uni.showToast({ title: '未查询到该位置的道路信息', icon: 'none' });
|
f0ec74d6
刘淇
大区经理派单
|
409
|
} catch (err) {
|
3cbb8754
刘淇
动态字典
|
410
411
412
|
console.error('获取道路名称失败:', err);
roadNameList.value = [{ name: '获取失败,请重新选择位置', code: '', id: 0 }];
uni.showToast({ title: '获取道路名称失败,请重试', icon: 'none' });
|
8ddc6f6e
刘淇
登录 修改样式
|
413
|
} finally {
|
3cbb8754
刘淇
动态字典
|
414
|
uni.hideLoading();
|
f0ec74d6
刘淇
大区经理派单
|
415
416
|
}
};
|
ecbfbe06
刘淇
树巡检记录
|
417
418
|
// ========== 通用下拉弹窗方法(支持下标) ==========
const handleActionSheetOpen = (type, idx) => {
|
3cbb8754
刘淇
动态字典
|
419
420
421
|
currentDispatchIndex.value = idx;
if (type === 'roadName' && !baseForm.workLocation) {
return uni.showToast({ title: '请先选择工单位置', icon: 'none' });
|
f0ec74d6
刘淇
大区经理派单
|
422
|
}
|
3cbb8754
刘淇
动态字典
|
423
424
425
426
427
|
const configMap = {
// 【重点改动:业务线弹窗,传入当前下标,过滤掉已占用业务线】
busiLine: { title: '请选择业务线', list: getAvailableBusiLineList(idx) },
roadName: { title: '请选择道路名称', list: roadNameList.value },
pressingType: { title: '请选择紧急程度', list: pressingTypeList.value }
|
8ddc6f6e
刘淇
登录 修改样式
|
428
|
};
|
3cbb8754
刘淇
动态字典
|
429
430
|
Object.assign(currentActionSheetData, configMap[type], { type, index: idx });
showActionSheet.value = true;
|
8ddc6f6e
刘淇
登录 修改样式
|
431
|
};
|
f0ec74d6
刘淇
大区经理派单
|
432
|
const handleActionSheetClose = () => {
|
3cbb8754
刘淇
动态字典
|
433
434
|
showActionSheet.value = false;
Object.assign(currentActionSheetData, { type: '', list: [], title: '', index: 0 });
|
8ddc6f6e
刘淇
登录 修改样式
|
435
|
};
|
f0ec74d6
刘淇
大区经理派单
|
436
|
const handleActionSheetSelect = (e) => {
|
3cbb8754
刘淇
动态字典
|
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
|
const { type, index } = currentActionSheetData;
const item = dispatchList.value[index];
switch (type) {
case 'busiLine':
item.busiLineCn = e.name;
item.busiLineCode = e.value;
handleBusiLineChange(e.value, index);
break;
case 'roadName':
item.roadName = e.name;
item.roadId = e.code;
console.log('选中道路对象e:', e)
console.log('赋值后 roadId:', item.roadName, '类型:', typeof item.roadId)
break;
case 'pressingType':
item.pressingType = e.value;
item.pressingTypeName = e.name;
break;
|
f0ec74d6
刘淇
大区经理派单
|
455
|
}
|
3cbb8754
刘淇
动态字典
|
456
|
handleActionSheetClose();
|
8ddc6f6e
刘淇
登录 修改样式
|
457
|
};
|
ecbfbe06
刘淇
树巡检记录
|
458
|
// ========== 页面交互方法 ==========
|
8ddc6f6e
刘淇
登录 修改样式
|
459
|
const hideKeyboard = () => uni.hideKeyboard();
|
ecbfbe06
刘淇
树巡检记录
|
460
|
/** 选择地图位置 */
|
f0ec74d6
刘淇
大区经理派单
|
461
|
const chooseWorkLocation = () => {
|
3cbb8754
刘淇
动态字典
|
462
463
464
465
466
467
468
469
470
|
uni.chooseLocation({
success: async (res) => {
baseForm.workLocation = res.name;
baseForm.lat = res.latitude;
baseForm.lon = res.longitude;
// 清空所有组道路
dispatchList.value.forEach(item => {
item.roadName = '';
item.roadId = 0;
|
ecbfbe06
刘淇
树巡检记录
|
471
|
})
|
3cbb8754
刘淇
动态字典
|
472
473
|
workOrderFormRef.value?.validateField(['workLocation']);
await getRoadListByBusiLine();
|
f0ec74d6
刘淇
大区经理派单
|
474
|
},
|
3cbb8754
刘淇
动态字典
|
475
476
477
478
|
fail: (err) => {
console.error('选择位置失败:', err);
const errMsg = err.errMsg.includes('auth deny') ? '请开启位置权限后重试' : '选择位置失败,请重试';
uni.showToast({ title: errMsg, icon: 'none' });
|
f0ec74d6
刘淇
大区经理派单
|
479
480
|
}
})
|
8ddc6f6e
刘淇
登录 修改样式
|
481
|
};
|
ecbfbe06
刘淇
树巡检记录
|
482
483
|
/** 重新提交数据回显 */
const handleRenewOptions = async (tempKey) => {
|
3cbb8754
刘淇
动态字典
|
484
485
486
487
488
489
|
isRenew.value = true;
try {
const orderData = uni.getStorageSync(tempKey);
if (orderData && typeof orderData === 'object') {
renewOrderData.value = orderData;
await echoOrderData(orderData); // 等待回显执行完毕
|
ecbfbe06
刘淇
树巡检记录
|
490
|
} else {
|
3cbb8754
刘淇
动态字典
|
491
492
|
uni.showToast({ title: '工单数据不存在,无法重新提交', icon: 'none' });
setTimeout(toOrderListPage, 1000);
|
ecbfbe06
刘淇
树巡检记录
|
493
494
|
}
} catch (error) {
|
3cbb8754
刘淇
动态字典
|
495
496
497
|
console.error('读取工单数据失败:', error);
uni.showToast({ title: '数据读取异常,无法重新提交', icon: 'none' });
setTimeout(toOrderListPage, 1000);
|
ecbfbe06
刘淇
树巡检记录
|
498
|
} finally {
|
3cbb8754
刘淇
动态字典
|
499
|
uni.removeStorageSync(tempKey);
|
ecbfbe06
刘淇
树巡检记录
|
500
501
|
}
};
|
ecbfbe06
刘淇
树巡检记录
|
502
503
|
/** 工单数据回显 */
const echoOrderData = async (orderItem) => {
|
3cbb8754
刘淇
动态字典
|
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
|
const busiCode = orderItem.busiLine || '';
// 回显公共字段
baseForm.workLocation = orderItem.lonLatAddress || orderItem.roadName || '';
baseForm.problemDesc = orderItem.remark || '';
baseForm.lat = orderItem.lat || 0;
baseForm.lon = orderItem.lon || 0;
console.log(orderItem)
console.log(orderItem.orderCode)
// 回显第一组派单
if (dispatchList.value[0]) {
const firstItem = dispatchList.value[0]
firstItem.busiLineCn = busiLineEnToCn(busiCode);
firstItem.busiLineCode = busiCode;
firstItem.roadId = orderItem.roadId || 0;
firstItem.roadName = orderItem.roadName || '';
firstItem.orderName = orderItem.orderName || '';
firstItem.orderCode = orderItem.orderCode || ''; // 回显编码
firstItem.pressingType = orderItem.pressingType || '';
firstItem.pressingTypeName = uni.$dict.getDictLabel(CONST.DICT_PRESSING_TYPE, orderItem.pressingType) || '';
firstItem.expectedFinishDate = orderItem.expectedFinishDate ? formatDate(orderItem.expectedFinishDate) : '';
|
ecbfbe06
刘淇
树巡检记录
|
524
|
}
|
3cbb8754
刘淇
动态字典
|
525
526
527
528
529
|
// 图片回显
if (Array.isArray(orderItem.problemsImgs) && orderItem.problemsImgs.length) {
const imgList = orderItem.problemsImgs.map((url, idx) => ({ url, name: `renew_img_${idx}`, status: 'success' }));
problemImgs.imgList.value = imgList;
problemImgs.rawImgList.value = imgList;
|
ecbfbe06
刘淇
树巡检记录
|
530
|
}
|
3cbb8754
刘淇
动态字典
|
531
532
533
534
535
536
537
538
539
540
541
542
543
|
// ========== 关键修复:业务线加载完级联数据后,回填 cascaderValue ==========
if (busiCode) {
// 先加载级联选项
await loadProblemCascader(busiCode);
// 根据回显的 orderCode 反向匹配级联路径,赋值给 cascaderValue
const targetCode = orderItem.orderCode
if (targetCode && cascaderOptions.value.length) {
// 递归查找级联选中路径
const findCascaderPath = (list, targetVal, path = []) => {
for (const node of list) {
const newPath = [...path, node.value]
if (node.value === targetVal) {
return newPath
|
ecbfbe06
刘淇
树巡检记录
|
544
|
}
|
3cbb8754
刘淇
动态字典
|
545
546
547
|
if (node.children && node.children.length) {
const res = findCascaderPath(node.children, targetVal, newPath)
if (res) return res
|
ecbfbe06
刘淇
树巡检记录
|
548
549
|
}
}
|
3cbb8754
刘淇
动态字典
|
550
|
return null
|
ecbfbe06
刘淇
树巡检记录
|
551
|
}
|
3cbb8754
刘淇
动态字典
|
552
553
554
|
const selectPath = findCascaderPath(cascaderOptions.value, targetCode)
if (selectPath) {
cascaderValue.value = selectPath
|
ecbfbe06
刘淇
树巡检记录
|
555
556
557
|
}
}
}
|
3cbb8754
刘淇
动态字典
|
558
|
if (orderItem.lat && orderItem.lon) getRoadListByBusiLine();
|
ecbfbe06
刘淇
树巡检记录
|
559
|
};
|
ecbfbe06
刘淇
树巡检记录
|
560
|
// ========== 接口分发(按角色) ==========
|
8ddc6f6e
刘淇
登录 修改样式
|
561
|
const callApiByRole = async (params, isRenewFlag) => {
|
3cbb8754
刘淇
动态字典
|
562
563
564
565
566
|
if (isRenewFlag) {
if (USER_ROLES.includes(CONST.ROLE.MANAGER)) return await daquUniversalApproval(params);
if (USER_ROLES.includes(CONST.ROLE.INSPECTOR)) return await dcyUniversalApproval(params);
if (USER_ROLES.includes(CONST.ROLE.LEADER)) return await dcyUniversalApproval(params);
if (USER_ROLES.includes(CONST.ROLE.PATROL)) return await qyUniversalApproval(params);
|
8ddc6f6e
刘淇
登录 修改样式
|
567
|
} else {
|
3cbb8754
刘淇
动态字典
|
568
569
570
571
572
573
574
|
console.log('dasda')
console.log(CONST.ROLE.INSPECTOR)
if (USER_ROLES.includes(CONST.ROLE.MANAGER)) return await daquWorkorderCreate(params);
// if (USER_ROLES.includes(CONST.ROLE.INSPECTOR)) return await dcyWorkorderCreate(params);
if (USER_ROLES.includes(CONST.ROLE.INSPECTOR)) return await dycCreateBatchNew(params);
if (USER_ROLES.includes(CONST.ROLE.LEADER)) return await dycCreateBatchNew(params);
if (USER_ROLES.includes(CONST.ROLE.PATROL)) return await qyWorkorderCreate(params);
|
8ddc6f6e
刘淇
登录 修改样式
|
575
576
|
}
};
|
ecbfbe06
刘淇
树巡检记录
|
577
|
// ========== 提交工单(纯数组提交,无 dispatchList,校验 roadId 非0) ==========
|
f0ec74d6
刘淇
大区经理派单
|
578
|
const submitWorkOrder = async () => {
|
3cbb8754
刘淇
动态字典
|
579
580
581
582
|
try {
// 校验公共表单
await workOrderFormRef.value.validate();
// 校验:同一业务线 + 同一问题类型 不允许重复
|
ecbfbe06
刘淇
树巡检记录
|
583
584
585
|
const list = dispatchList.value;
const keySet = new Set();
let hasRepeat = false;
|
ecbfbe06
刘淇
树巡检记录
|
586
|
for (const item of list) {
|
3cbb8754
刘淇
动态字典
|
587
588
589
590
591
592
593
594
595
596
|
const busi = (item.busiLineCn || '').trim();
const type = (item.orderName || '').trim();
// 拼接唯一标识
const uniqueKey = `${busi}_${type}`;
if (keySet.has(uniqueKey)) {
hasRepeat = true;
break;
}
keySet.add(uniqueKey);
}
|
ecbfbe06
刘淇
树巡检记录
|
597
|
if (hasRepeat) {
|
3cbb8754
刘淇
动态字典
|
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
|
uni.showToast({
title: '存在同业务同问题类型,请修改后再提交',
icon: 'none'
});
return;
}
// ==============================================
// 组装纯数组,不再包裹 dispatchList
const submitArr = dispatchList.value.map(item => {
return {
roadId: item.roadId,
roadName: item.roadName,
orderName: item.orderName,
orderCode: item.orderCode,
pressingType: item.pressingType,
busiLine: busiLineCnToEn(item.busiLineCn),
busiType: busiLineCnToEn(item.busiLineCn),
expectedFinishDate: dateToTimestamp(item.expectedFinishDate),
problemsImgs: problemImgs.getSuccessImgUrls(),
remark: baseForm.problemDesc.trim(),
latLonType: 2,
lat: baseForm.lat,
lon: baseForm.lon,
lonLatAddress: baseForm.workLocation,
sourceId: 1,
sourceName: item.busiLineCn
|
ecbfbe06
刘淇
树巡检记录
|
624
625
|
}
});
|
3cbb8754
刘淇
动态字典
|
626
627
628
629
630
631
632
|
// 逐项校验:保证 roadId 不为 0,以及其他必填项
for (let i = 0; i < submitArr.length; i++) {
const row = submitArr[i];
const num = i + 1;
if (!row.roadId || row.roadId === 0) {
uni.showToast({ title: `第${num}条派单请选择道路名称`, icon: 'none' });
return;
|
ecbfbe06
刘淇
树巡检记录
|
633
|
}
|
3cbb8754
刘淇
动态字典
|
634
635
636
|
if (!row.busiLine) {
uni.showToast({ title: `第${num}条派单请选择业务线`, icon: 'none' });
return;
|
ecbfbe06
刘淇
树巡检记录
|
637
|
}
|
3cbb8754
刘淇
动态字典
|
638
639
640
|
if (!row.orderCode) {
uni.showToast({ title: `第${num}条派单请选择问题类型`, icon: 'none' });
return;
|
ecbfbe06
刘淇
树巡检记录
|
641
|
}
|
3cbb8754
刘淇
动态字典
|
642
643
644
|
if (!row.pressingType) {
uni.showToast({ title: `第${num}条派单请选择紧急程度`, icon: 'none' });
return;
|
ecbfbe06
刘淇
树巡检记录
|
645
646
|
}
}
|
3cbb8754
刘淇
动态字典
|
647
648
649
650
651
652
653
654
655
656
657
658
|
uni.showLoading({ title: '提交中...', mask: true });
let submitParams;
if (isRenew.value) {
// 重新提交:外层对象 + list 承载数组
submitParams = {
workerDataId: renewOrderData.value.id,
taskKey: renewOrderData.value.taskKey,
taskId: renewOrderData.value.taskId,
operateType: nextStepMap[renewOrderData.value.taskKey]?.operateTypeRenew || '',
agree: 0,
reason: baseForm.problemDesc.trim(),
...submitArr[0]
|
ecbfbe06
刘淇
树巡检记录
|
659
660
|
};
} else {
|
3cbb8754
刘淇
动态字典
|
661
662
|
// 新建工单:根节点直接为纯数组
submitParams = submitArr;
|
ecbfbe06
刘淇
树巡检记录
|
663
|
}
|
3cbb8754
刘淇
动态字典
|
664
665
666
667
668
669
|
console.log(submitParams)
await callApiByRole(submitParams, isRenew.value);
uni.showToast({
title: isRenew.value ? '重新提交成功' : '工单提交成功',
icon: 'success',
duration: 1000
|
ecbfbe06
刘淇
树巡检记录
|
670
|
});
|
3cbb8754
刘淇
动态字典
|
671
|
setTimeout(toOrderListPage, 1000);
|
f0ec74d6
刘淇
大区经理派单
|
672
|
} catch (error) {
|
3cbb8754
刘淇
动态字典
|
673
674
675
676
677
678
679
|
uni.hideLoading();
if (!Array.isArray(error)) {
console.error(isRenew.value ? '工单重新提交失败:' : '工单提交失败:', error);
uni.showToast({
title: error.msg || '提交失败,请重试',
icon: 'none',
duration: 2000
|
ecbfbe06
刘淇
树巡检记录
|
680
|
});
|
f0ec74d6
刘淇
大区经理派单
|
681
682
683
|
}
}
}
|
4c54ad5d
刘淇
转工单 选择是 传紧急程度和...
|
684
685
|
</script>
|
f0ec74d6
刘淇
大区经理派单
|
686
|
<style lang="scss" scoped>
|
f0ec74d6
刘淇
大区经理派单
|
687
688
|
.page-container {
min-height: 100vh;
|
ecbfbe06
刘淇
树巡检记录
|
689
|
padding-bottom: 100rpx;
|
8ddc6f6e
刘淇
登录 修改样式
|
690
|
background: #fafafa;
|
f0ec74d6
刘淇
大区经理派单
|
691
|
}
|
4c54ad5d
刘淇
转工单 选择是 传紧急程度和...
|
692
|
|
f0ec74d6
刘淇
大区经理派单
|
693
694
695
696
|
.work-order-form-content {
background: #fff;
}
|
ecbfbe06
刘淇
树巡检记录
|
697
|
.dispatch-list-wrap {
|
8ddc6f6e
刘淇
登录 修改样式
|
698
699
700
|
padding-top: 24rpx;
margin-top: 8rpx;
border-top: 1px solid #f5f5f5;
|
ecbfbe06
刘淇
树巡检记录
|
701
|
}
|
8ddc6f6e
刘淇
登录 修改样式
|
702
|
|
ecbfbe06
刘淇
树巡检记录
|
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
|
.dispatch-title {
font-size: 32rpx;
font-weight: 600;
color: $u-primary;
margin-bottom: 20rpx;
padding-left: 10rpx;
}
.dispatch-item {
position: relative;
border: 1px solid #eee;
border-radius: 12rpx;
padding: 20rpx;
margin-bottom: 20rpx;
background: #fdfdfd;
.item-head {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16rpx;
font-size: 28rpx;
font-weight: 500;
}
.close-icon {
position: absolute;
top: 20rpx;
right: 20rpx;
|
8ddc6f6e
刘淇
登录 修改样式
|
732
|
}
|
f0ec74d6
刘淇
大区经理派单
|
733
|
}
|
ecbfbe06
刘淇
树巡检记录
|
734
735
736
737
|
.add-dispatch-btn-wrap {
margin: 20rpx 0;
}
|
3cbb8754
刘淇
动态字典
|
738
|
</style>
|