wxFinalize.uvue 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927
  1. <template>
  2. <view class="detail-page">
  3. <scroll-view class="detail-content" :scroll-y="true">
  4. <!-- 工单信息 -->
  5. <view class="info-section">
  6. <view class="section-title">
  7. <text class="section-title-text">工单信息</text>
  8. </view>
  9. <view class="info-card">
  10. <view class="info-item">
  11. <text class="info-label">工单编码</text>
  12. <text class="info-value">{{ workOrderProjectNo ?? '-' }}</text>
  13. </view>
  14. <view class="info-item">
  15. <text class="info-label">工单类型</text>
  16. <text class="info-value">{{ orderType == '1' ? '维修工单' : '维保工单' }}</text>
  17. </view>
  18. <view class="info-item">
  19. <text class="info-label">风机编号</text>
  20. <text class="info-value">{{ pcsDeviceName ?? '-' }}</text>
  21. </view>
  22. <view class="info-item">
  23. <text class="info-label">维保中心</text>
  24. <text class="info-value">{{ gxtCenter ?? '-' }}</text>
  25. </view>
  26. <view class="info-item">
  27. <text class="info-label">场站</text>
  28. <text class="info-value">{{ pcsStationName ?? '-' }}</text>
  29. </view>
  30. <!-- <view class="info-item">
  31. <text class="info-label">品牌</text>
  32. <text class="info-value">{{ detailData.model ?? '' }}</text>
  33. </view> -->
  34. <view class="info-item">
  35. <text class="info-label">机型</text>
  36. <text class="info-value">{{ brand ?? '-' }} {{ model ?? '-' }}</text>
  37. </view>
  38. <view class="info-item">
  39. <text class="info-label">接单时间</text>
  40. <text class="info-value">{{ acceptTime ?? '-' }}</text>
  41. </view>
  42. <view class="info-item">
  43. <text class="info-label">故障代码</text>
  44. <text class="info-value">{{ faultCode ?? '-' }}</text>
  45. </view>
  46. <view class="info-item">
  47. <text class="info-label">故障条文</text>
  48. <text class="info-value">{{ faultBarcode ?? '-' }}</text>
  49. </view>
  50. <view class="info-item">
  51. <text class="info-label">故障描述</text>
  52. <text class="info-value">{{ faultDesc ?? '-' }}</text>
  53. </view>
  54. </view>
  55. </view>
  56. <!-- 结单表单 -->
  57. <view class="info-section">
  58. <view class="section-title">
  59. <text class="section-title-text">结单信息</text>
  60. </view>
  61. <view class="info-card">
  62. <!-- 信息录入 -->
  63. <view class="info-item">
  64. <view class="info-label">
  65. <text class="form-label required">信息录入<text style="color: red;">*</text></text>
  66. </view>
  67. <view class="info-value">
  68. <radio-group @change="handleInfoEntryChange" :disabled="infoEntryDisabled" class="uni-flex uni-row radio-group">
  69. <view v-for="(option, index) in infoEntryOptions" :key="index" class="radio-label">
  70. <radio :value="option.dictValue" :checked="infoEntry == option.dictValue">{{ option.dictLabel }}</radio>
  71. <!-- <text></text> -->
  72. </view>
  73. </radio-group>
  74. </view>
  75. </view>
  76. <!-- MIS工单编码选择(当信息录入为1时显示) -->
  77. <view class="info-item" v-if="infoEntry == '1'">
  78. <view class="info-label">
  79. <text class="form-label required">MIS工单编码<text style="color: red;">*</text></text>
  80. </view>
  81. <view class="info-value">
  82. <view class="input-with-select">
  83. <input
  84. class="input-field"
  85. placeholder="请输入或选择MIS工单编码"
  86. v-model="misNo"
  87. @focus="handleMisNoInputFocus"
  88. @blur="handleMisNoInputBlur"
  89. @input="handleMisNoInput"
  90. :readonly="infoEntry == '1'"
  91. :style="{ paddingRight: '120rpx' }" />
  92. <text class="select-mis-btn" @click="openMisListModal">选择</text>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 工作票编号(当信息录入为2时可编辑) -->
  97. <view class="info-item">
  98. <view class="info-label">
  99. <text class="form-label required">工作票编号<text style="color: red;">*</text></text>
  100. </view>
  101. <view class="info-value">
  102. <input
  103. class="input-field"
  104. placeholder="请输入工作票编号"
  105. v-model="workPermitNum"
  106. maxlength="20"
  107. :disabled="infoEntry == '1'"
  108. @change="handleWorkPermitNumChange"
  109. />
  110. </view>
  111. </view>
  112. <!-- 开始时间 -->
  113. <view class="info-item">
  114. <view class="info-label">
  115. <text class="form-label required">开始时间<text style="color: red;">*</text></text>
  116. </view>
  117. <view class="info-value">
  118. <view class="form-picker" @click="showStartTimePicker = true">
  119. <input
  120. class="input-field"
  121. placeholder="请选择开始时间"
  122. v-model="realStartTime"
  123. :disabled="true"
  124. style="pointer-events: none;"
  125. />
  126. </view>
  127. </view>
  128. </view>
  129. <!-- 结束时间 -->
  130. <view class="info-item">
  131. <view class="info-label">
  132. <text class="form-label required">结束时间<text style="color: red;">*</text></text>
  133. </view>
  134. <view class="info-value">
  135. <view class="form-picker" @click="showEndTimePicker = true">
  136. <input
  137. class="input-field"
  138. placeholder="请选择结束时间"
  139. v-model="realEndTime"
  140. :disabled="true"
  141. />
  142. <!-- <text class="input-field">
  143. {{ realEndTime != '' ? realEndTime : '请选择结束时间' }}
  144. </text> -->
  145. </view>
  146. </view>
  147. </view>
  148. <!-- 工作部位 -->
  149. <view class="info-item">
  150. <view class="info-label">
  151. <text class="form-label">工作部位</text>
  152. </view>
  153. <view class="info-value">
  154. <view class="form-picker" @click="showWorkAreaPicker = true">
  155. <input
  156. class="input-field"
  157. placeholder="请选择工作部位"
  158. v-model="workAreaLabel"
  159. readonly
  160. />
  161. </view>
  162. </view>
  163. </view>
  164. <!-- 外委人员数 -->
  165. <view class="info-item">
  166. <view class="info-label">
  167. <text class="form-label required">外委人员数(人)</text>
  168. </view>
  169. <view class="info-value">
  170. <input
  171. type="number"
  172. class="input-field"
  173. placeholder="请输入外委人员数"
  174. v-model="wwryNum"
  175. @input="onWwryNumInput"
  176. />
  177. </view>
  178. </view>
  179. <!-- 外来人员数 -->
  180. <view class="info-item">
  181. <view class="info-label">
  182. <text class="form-label required">外来人员数(人)</text>
  183. </view>
  184. <view class="info-value">
  185. <input
  186. type="number"
  187. class="input-field"
  188. placeholder="请输入外来人员数"
  189. v-model="wlryNum"
  190. @input="onWlryNumInput"
  191. />
  192. </view>
  193. </view>
  194. <!-- 工作负责人 -->
  195. <view class="info-item">
  196. <view class="info-label">
  197. <text class="form-label required">工作负责人<text style="color: red;">*</text></text>
  198. </view>
  199. <view class="info-value">
  200. <view class="input-with-clear">
  201. <input
  202. class="input-field"
  203. placeholder="请选择工作负责人"
  204. v-model="teamLeaderName"
  205. @click="showLeaderPicker = true"
  206. />
  207. </view>
  208. </view>
  209. </view>
  210. <!-- 工作班成员选择(当信息录入为2时可编辑) -->
  211. <view class="info-item">
  212. <view class="info-label">
  213. <text class="form-label required">工作班成员<text style="color: red;">*</text></text>
  214. </view>
  215. <view class="info-value">
  216. <view class="input-with-clear">
  217. <input
  218. class="input-field"
  219. placeholder="请选择工作班成员"
  220. v-model="workGroupMemberName"
  221. @click="showUserSelect = true"
  222. :disabled="infoEntry == '1'"
  223. />
  224. <text class="select-users-count" v-if="selectedUserIds.length > 0" :style="{ marginRight: selectedUserIds.length > 0 ? '60rpx' : '0' }">({{ selectedUserIds.length }}人)</text>
  225. <text class="select-clear" v-if="selectedUserIds.length > 0" @click="clearSelectedUsers">×</text>
  226. </view>
  227. </view>
  228. </view>
  229. <!-- 维保内容 -->
  230. <view class="info-item full-width">
  231. <view class="info-label">
  232. <text class="form-label required">真实故障原因</text>
  233. </view>
  234. <view class="info-value">
  235. <textarea
  236. class="textarea-field"
  237. placeholder="请输入真实故障原因"
  238. v-model="realFailureReason"
  239. maxlength="500"
  240. :show-confirm-bar="false"
  241. auto-height
  242. ></textarea>
  243. </view>
  244. </view>
  245. <!-- 附件上传 -->
  246. <view class="info-item full-width">
  247. <view class="info-label">
  248. <text class="form-label">附件(可选)</text>
  249. </view>
  250. <view class="info-value">
  251. <upload-image
  252. :limit="8"
  253. :modelValue="uploadedFiles"
  254. :businessType="'workOrder'"
  255. @update:modelValue="uploadedFiles = $event as UTSArray<UploadResponse>"
  256. />
  257. </view>
  258. </view>
  259. </view>
  260. </view>
  261. <!-- 时间选择器弹窗 -->
  262. <!-- Start Date Picker -->
  263. <l-popup v-model="showStartTimePicker" position="bottom" :safe-area-inset-bottom="true" :z-index="10000">
  264. <l-date-time-picker
  265. title="选择开始时间"
  266. :mode="1 | 2 | 4 | 8 | 16"
  267. format="YYYY-MM-DD HH:mm"
  268. :modelValue="realStartTime"
  269. confirm-btn="确定"
  270. cancel-btn="取消"
  271. @confirm="onStartDateConfirm"
  272. @cancel="showStartTimePicker = false">
  273. </l-date-time-picker>
  274. </l-popup>
  275. <!-- End Date Picker -->
  276. <l-popup v-model="showEndTimePicker" position="bottom" :safe-area-inset-bottom="true" :z-index="10000">
  277. <l-date-time-picker
  278. title="选择结束时间"
  279. :mode="31"
  280. format="YYYY-MM-DD HH:mm"
  281. :modelValue="realStartTime"
  282. confirm-btn="确定"
  283. cancel-btn="取消"
  284. @confirm="onEndDateConfirm"
  285. @cancel="showEndTimePicker = false">
  286. </l-date-time-picker>
  287. </l-popup>
  288. <!-- 人员选择弹窗 -->
  289. <view v-if="showUserSelect" class="picker-modal">
  290. <view class="modal-mask" @click="showUserSelect = false"></view>
  291. <view class="modal-content">
  292. <view class="modal-header">
  293. <text class="modal-title">选择工作班成员</text>
  294. <text class="modal-close" @click="confirmSelectedUsers">确定</text>
  295. </view>
  296. <view class="search-bar">
  297. <view class="search-box">
  298. <image class="search-icon" src="/static/images/workbench/list/1.png" mode="aspectFit"></image>
  299. <input class="search-input" type="text" placeholder="搜索姓名" v-model="userKeyword" @input="handleUserSearch" />
  300. <text v-if="userKeyword.length > 0" class="clear-icon" @click="clearUserSearch">✕</text>
  301. </view>
  302. </view>
  303. <scroll-view class="modal-body" scroll-y="true">
  304. <view
  305. v-for="(user, index) in userList"
  306. :key="index"
  307. class="picker-option"
  308. @click="toggleUserSelection(user)"
  309. >
  310. <text class="option-text">{{ (user['nickName'] as string | null) ?? '' }}</text>
  311. <text class="option-text">{{ ((user['dept'] as UTSJSONObject | null)?.['deptName'] as string | null) ?? '' }}</text>
  312. <text class="option-check" v-if="isSelected(user)">✓</text>
  313. </view>
  314. </scroll-view>
  315. </view>
  316. </view>
  317. <!-- MIS工单列表弹窗 -->
  318. <view v-if="showMisListModal" class="picker-modal">
  319. <view class="modal-mask" @click="closeMisListModal"></view>
  320. <view class="modal-content">
  321. <view class="modal-header">
  322. <text class="modal-title">选择MIS工单</text>
  323. <text class="modal-close" @click="closeMisListModal">取消</text>
  324. </view>
  325. <!-- 搜索栏 -->
  326. <view class="search-bar">
  327. <view class="search-box">
  328. <image class="search-icon" src="/static/images/workbench/list/1.png" mode="aspectFit"></image>
  329. <input class="search-input" type="text" placeholder="搜索 MIS工单编码" v-model="misListKeyword" @input="searchMisList" />
  330. <text v-if="misListKeyword.length > 0" class="clear-icon" @click="clearMisListSearch">✕</text>
  331. </view>
  332. </view>
  333. <!-- 列表内容 -->
  334. <scroll-view class="modal-body" scroll-y="true">
  335. <!-- 有数据时显示列表 -->
  336. <view v-if="misList.length > 0">
  337. <view
  338. v-for="(item, index) in misList"
  339. :key="index"
  340. class="picker-option"
  341. @click="selectMisItem(item, index)"
  342. >
  343. <!-- <text class="option-text">{{ option.label }}</text>
  344. <text class="option-text">{{ option.value }}</text> -->
  345. <text class="option-text">{{ ((item['misNo'] as string | null) ?? '-')}}</text>
  346. <text class="option-text">{{ item['workPermitNum'] as string | null ?? '-' }}</text>
  347. <text v-if="index === selectedMisInfoIndex" class="option-check">✓</text>
  348. </view>
  349. </view>
  350. <!-- 无数据时显示提示 -->
  351. <view v-else class="empty-tip">
  352. <text>未找到匹配的MIS工单</text>
  353. </view>
  354. </scroll-view>
  355. </view>
  356. </view>
  357. <!-- 工作部位选择弹窗 -->
  358. <view v-if="showWorkAreaPicker" class="picker-modal">
  359. <view class="modal-mask" @click="showWorkAreaPicker = false"></view>
  360. <view class="modal-content">
  361. <view class="modal-header">
  362. <text class="modal-title">选择工作部位</text>
  363. <text class="modal-close" @click="confirmSelectedWorkAreas">确定</text>
  364. </view>
  365. <scroll-view class="modal-body" scroll-y="true">
  366. <view
  367. v-for="(item, index) in workAreaDictList"
  368. :key="index"
  369. class="picker-option"
  370. @click="toggleWorkAreaSelection(item)"
  371. >
  372. <text class="option-text">{{ item.dictLabel ?? '' }}</text>
  373. <text class="option-check" v-if="isWorkAreaSelected(item)">✓</text>
  374. </view>
  375. </scroll-view>
  376. </view>
  377. </view>
  378. <!-- 工作负责人弹窗 -->
  379. <view v-if="showLeaderPicker" class="picker-modal">
  380. <view class="modal-mask" @click="showLeaderPicker = false"></view>
  381. <view class="modal-content">
  382. <view class="modal-header">
  383. <text class="modal-title">选择工作负责人</text>
  384. <text class="modal-close" @click="showLeaderPicker = false">取消</text>
  385. </view>
  386. <view class="search-bar">
  387. <view class="search-box">
  388. <image class="search-icon" src="/static/images/workbench/list/1.png" mode="aspectFit"></image>
  389. <input class="search-input" type="text" placeholder="搜索姓名" v-model="teamKeyword" @input="handleSearch" />
  390. <text v-if="teamKeyword.length > 0" class="clear-icon" @click="clearSearch">✕</text>
  391. </view>
  392. </view>
  393. <scroll-view class="modal-body" scroll-y="true">
  394. <!-- 有数据时显示列表 -->
  395. <view v-if="teamLeaderList.length > 0">
  396. <view
  397. v-for="(user, index) in teamLeaderList"
  398. :key="index"
  399. class="picker-option"
  400. :class="{ 'selected': index === selectedTeamLeaderIndex }"
  401. @click="selectLeaderManually(user, index)"
  402. >
  403. <text class="option-text">{{ (user['nickName'] as string | null) ?? '' }}</text>
  404. <text class="option-text">{{ ((user['dept'] as UTSJSONObject | null)?.['deptName'] as string | null) ?? '' }}</text>
  405. <text v-if="index === selectedTeamLeaderIndex" class="option-check">✓</text>
  406. </view>
  407. </view>
  408. <!-- 无数据时显示提示 -->
  409. <view v-else class="empty-tip">
  410. <text>未找到匹配的人员</text>
  411. </view>
  412. </scroll-view>
  413. </view>
  414. </view>
  415. </scroll-view>
  416. <!-- 确认结单按钮 -->
  417. <view class="accept-button-container">
  418. <button class="accept-button" @click="handleSubmit" :loading="submitLoading">{{ submitLoading ? '提交中...' : '确认结单' }}</button>
  419. </view>
  420. <!-- 加载中状态 -->
  421. <view v-if="loading" class="loading-mask">
  422. <text class="loading-text">加载中...</text>
  423. </view>
  424. </view>
  425. </template>
  426. <script setup lang="uts">
  427. import { ref } from 'vue'
  428. import type { acceptOrderInfo } from '../../../types/order'
  429. import type { WorkOrderFlow } from '../../../types/flow'
  430. import { getOrderInfoById, getRepairOrderInfoById, returnRepairOrder, repairFinishOrder } from '../../../api/order/detail'
  431. import { getMisInfoList, listWorkPerson, getOrderList, listAutoMisInfo } from '../../../api/order/list'
  432. import type { SysDictData } from '../../../types/dict'
  433. import { getDictDataByType } from '../../../api/dict/index'
  434. import type { UserInfo } from '../../../types/user'
  435. import type { UploadResponse } from '../../../types/workbench'
  436. import {checkPermi} from '../../../utils/storage'
  437. import { getUserList, getLeaderList } from '../../../api/user/list'
  438. import uploadImage from '../../../components/upload-image/upload-image.uvue'
  439. // 工单信息
  440. const orderId = ref<string>('')
  441. const workOrderProjectNo = ref<string>('')
  442. const workOrderStatus = ref<string>('')
  443. const orderType = ref<string>('')
  444. const pcsDeviceName = ref<string>('')
  445. const gxtCenter = ref<string>('')
  446. const pcsStationName = ref<string>('')
  447. const brand = ref<string>('')
  448. const model = ref<string>('')
  449. const acceptTime = ref<string>('')
  450. const returnType = ref<string>('')
  451. const returnReason = ref<string>("")
  452. const returnTypeLabel = ref<string>("")
  453. const acceptReturnType = ref<string>('')
  454. const acceptReturnReason = ref<string>("")
  455. const teamLeaderId = ref<Number | null>(null)
  456. const teamLeaderName = ref<string>('')
  457. const pauseTime = ref<string>('')
  458. const restartTime = ref<string>('')
  459. const faultCode = ref<string>('')
  460. const faultBarcode = ref<string>('')
  461. const faultDesc = ref<string>('')
  462. // 添加字典加载状态
  463. const dictLoaded = ref<boolean>(false)
  464. // 结单表单相关变量
  465. const infoEntry = ref<string>('') // 信息录入
  466. const misNo = ref<string>('') // MIS工单编码
  467. const workPermitNum = ref<string>('') // 工作票编号
  468. const realStartTime = ref<string>('') // 开始时间
  469. const realEndTime = ref<string>('') // 结束时间
  470. const wwryNum = ref<string>('') // 外委人员数
  471. const wlryNum = ref<string>('') // 外来人员数
  472. const workGroupMemberName = ref<string>('') // 工作班成员
  473. const attachmentUrls = ref<string>('') // 附件URLs(逗号分隔的字符串格式)
  474. const uploadedFiles = ref<UploadResponse[]>([]) // 上传的文件对象数组
  475. const workOrderPersonList = ref<UTSJSONObject[]>([]) // 工作班成员数组
  476. const selectedUserIds = ref<string[]>([]) // 选中的用户ID数组
  477. const selectedUsers = ref<UTSJSONObject[]>([]) // 选中的用户对象数组
  478. const realFailureReason = ref<string>('') //真实故障原因
  479. const workArea = ref<string>('') //工作部位
  480. const workAreaLabel = ref<string>('')
  481. const workAreaDictList = ref<SysDictData[]>([]) // 工作部位字典列表
  482. const selectedWorkAreas = ref<SysDictData[]>([]) // 选中的工作部位
  483. const showWorkAreaPicker = ref<boolean>(false) // 显示工作部位选择器
  484. // 选中的负责人信息
  485. const selectedTeamLeaderName = ref<string>('')
  486. const selectedTeamLeaderIndex = ref<number>(-1)
  487. const showLeaderPicker = ref<boolean>(false)
  488. const teamLeaderList = ref<UTSJSONObject[]>([])
  489. const teamAllLeaderList = ref<UTSJSONObject[]>([])
  490. let teamKeyword = ref<string>("")
  491. // 时间选择器相关变量
  492. const showStartTimePicker = ref<boolean>(false)
  493. const showEndTimePicker = ref<boolean>(false)
  494. const startTimeDate = ref<string>('')
  495. const startTimeTime = ref<string>('')
  496. const endTimeDate = ref<string>('')
  497. const endTimeTime = ref<string>('')
  498. // MIS工单选择相关变量
  499. const showMisNoQuickSelect = ref<boolean>(false)
  500. const quickMisNoList = ref<UTSJSONObject[]>([])
  501. // 添加MIS工单列表弹窗显示状态
  502. const showMisListModal = ref<boolean>(false)
  503. // MIS工单列表数据
  504. const misList = ref<UTSJSONObject[]>([])
  505. const allMisList = ref<UTSJSONObject[]>([])
  506. // 分页信息
  507. const misListPage = ref<number>(1)
  508. const misListPageSize = ref<number>(999)
  509. const misListTotal = ref<number>(0)
  510. // 搜索关键词
  511. const misListKeyword = ref<string>('')
  512. const userKeyword = ref<string>('')
  513. // 人员选择相关变量
  514. const showUserSelect = ref<boolean>(false)
  515. const userList = ref<UTSJSONObject[]>([])
  516. const userAllList = ref<UTSJSONObject[]>([])
  517. // 信息录入选项
  518. const infoEntryOptions = ref<SysDictData[]>([])
  519. const selectedMisInfoIndex = ref<number>(-1)
  520. // 获取信息录入字典列表
  521. const loadInfoEntryDictList = async (): Promise<void> => {
  522. try {
  523. const result = await getDictDataByType('gxt_info_entry') // 假设信息录入类型字典类型为gxt_info_entry
  524. const resultObj = result as UTSJSONObject
  525. if (resultObj['code'] == 200) {
  526. const data = resultObj['data'] as any[]
  527. const dictData: SysDictData[] = []
  528. if (data.length > 0) {
  529. for (let i = 0; i < data.length; i++) {
  530. const item = data[i] as UTSJSONObject
  531. // 只提取需要的字段
  532. const dictItem: SysDictData = {
  533. dictValue: item['dictValue'] as string | null,
  534. dictLabel: item['dictLabel'] as string | null,
  535. dictCode: null,
  536. dictSort: null,
  537. dictType: null,
  538. cssClass: null,
  539. listClass: null,
  540. isDefault: null,
  541. status: null,
  542. default: null,
  543. createTime: null,
  544. remark: null
  545. }
  546. dictData.push(dictItem)
  547. }
  548. }
  549. infoEntryOptions.value = dictData
  550. }
  551. } catch (e: any) {
  552. console.error('获取信息录入类型字典失败:', e.message)
  553. // 设置默认值
  554. infoEntryOptions.value = [
  555. { dictValue: '1', dictLabel: 'MIS工单', dictCode: null, dictSort: null, dictType: null, cssClass: null, listClass: null, isDefault: null, status: null, default: null, createTime: null, remark: null },
  556. { dictValue: '2', dictLabel: '手工录入', dictCode: null, dictSort: null, dictType: null, cssClass: null, listClass: null, isDefault: null, status: null, default: null, createTime: null, remark: null }
  557. ];
  558. }
  559. }
  560. // 获取工作部位字典列表
  561. const loadWorkAreaDictList = async (): Promise<void> => {
  562. try {
  563. const result = await getDictDataByType('gxt_work_area')
  564. const resultObj = result as UTSJSONObject
  565. if (resultObj['code'] == 200) {
  566. const data = resultObj['data'] as any[]
  567. const dictData: SysDictData[] = []
  568. if (data.length > 0) {
  569. for (let i = 0; i < data.length; i++) {
  570. const item = data[i] as UTSJSONObject
  571. // 只提取需要的字段
  572. const dictItem: SysDictData = {
  573. dictValue: item['dictValue'] as string | null,
  574. dictLabel: item['dictLabel'] as string | null,
  575. dictCode: null,
  576. dictSort: null,
  577. dictType: null,
  578. cssClass: null,
  579. listClass: null,
  580. isDefault: null,
  581. status: null,
  582. default: null,
  583. createTime: null,
  584. remark: null
  585. }
  586. dictData.push(dictItem)
  587. }
  588. }
  589. workAreaDictList.value = dictData
  590. }
  591. } catch (e: any) {
  592. console.error('获取工作部位字典失败:', e.message)
  593. }
  594. }
  595. // 获取用户列表
  596. const getUserAllList = async (): Promise<void> => {
  597. try {
  598. // 这里应该调用获取用户列表的API
  599. const result = await getLeaderList(-1); // 空参数调用
  600. const resultObj = result as UTSJSONObject;
  601. const code = resultObj['code'] as number
  602. const users = resultObj['data'] as UTSJSONObject[] | null
  603. if (code == 200 && users != null ) {
  604. // 解析列表数据
  605. // const rows = resultObj['rows'] as UTSJSONObject[]
  606. userList.value = users
  607. userAllList.value = users
  608. teamLeaderList.value = users
  609. teamAllLeaderList.value = users
  610. // userList.value = result.data || [];
  611. }
  612. } catch (error) {
  613. console.error('获取用户列表失败:', error);
  614. uni.showToast({
  615. title: '获取用户列表失败',
  616. icon: 'none'
  617. });
  618. }
  619. };
  620. // 外委人员数输入处理
  621. const onWwryNumInput = (): void => {
  622. let value = wwryNum.value;
  623. // 移除非数字字符,包括负号和小数点
  624. value = value.replace(/[^0-9]/g, '');
  625. wwryNum.value = value;
  626. };
  627. // 外来人员数输入处理
  628. const onWlryNumInput = (): void => {
  629. let value = wlryNum.value;
  630. // 移除非数字字符,包括负号和小数点
  631. value = value.replace(/[^0-9]/g, '');
  632. wlryNum.value = value;
  633. };
  634. // 验证和提交
  635. const submitLoading = ref<boolean>(false)
  636. // 信息录入禁用状态
  637. const infoEntryDisabled = ref<boolean>(false)
  638. // 接受用户名
  639. const acceptUserName = ref<string>('')
  640. // 选择器选项类型
  641. type PickerOption = {
  642. label: string
  643. value: string
  644. }
  645. // 选中的挂起原因
  646. const returnTypeOptions = ref<PickerOption[]>([])
  647. const showReasonPicker = ref<boolean>(false)
  648. // 获取负责人列表(使用用户列表接口)
  649. const dictList = async (): Promise<void> => {
  650. try {
  651. const dictString = ref("")
  652. if(workOrderStatus.value != 'to_finish') {
  653. dictString.value = "gxt_accept_return_type"
  654. } else {
  655. dictString.value = "gxt_return_type"
  656. }
  657. const result = await getDictDataByType(dictString.value)
  658. const resultObj = result as UTSJSONObject
  659. if (resultObj['code'] == 200) {
  660. const data = resultObj['data'] as any[]
  661. const options: PickerOption[] = []
  662. if (data.length > 0) {
  663. for (let i = 0; i < data.length; i++) {
  664. const item = data[i] as UTSJSONObject
  665. let dictItem: SysDictData = {
  666. dictValue: item['dictValue'] as string | null,
  667. dictLabel: item['dictLabel'] as string | null,
  668. dictCode: null,
  669. dictSort: null,
  670. dictType: null,
  671. cssClass: null,
  672. listClass: null,
  673. isDefault: null,
  674. status: null,
  675. default: null,
  676. createTime: null,
  677. remark: null
  678. }
  679. // 构建选择器选项
  680. options.push({
  681. label: dictItem.dictLabel ?? '',
  682. value: dictItem.dictValue ?? ''
  683. })
  684. }
  685. }
  686. returnTypeOptions.value = options
  687. }
  688. } catch (e: any) {
  689. console.error('获取挂起原因失败:', e.message)
  690. }
  691. }
  692. // 手动选择负责人
  693. const selectLeaderManually = (user: UTSJSONObject, index: number): void => {
  694. selectedTeamLeaderIndex.value = index
  695. const uid = user['userId']
  696. if (uid != null) {
  697. teamLeaderId.value = uid as Number
  698. }
  699. const name = user['nickName']
  700. teamLeaderName.value = name != null ? name.toString() : ''
  701. showLeaderPicker.value = false
  702. }
  703. // 信息录入变化处理
  704. const handleInfoEntryChange = (e: UniRadioGroupChangeEvent): void => {
  705. // 兼容 radio-group 事件:detail 可能不存在,直接取 e.value
  706. const val = e.detail?.value as string | null
  707. infoEntry.value = val ?? ''
  708. if (infoEntry.value == '1') {
  709. // 当选择MIS工单时,清空手工录入的字段
  710. workPermitNum.value = '';
  711. realStartTime.value = '';
  712. realEndTime.value = '';
  713. workGroupMemberName.value = '';
  714. }
  715. };
  716. // 工作票编号变化处理
  717. const handleWorkPermitNumChange = async(): Promise<void> => {
  718. if (infoEntry.value == '2') {
  719. // 查询工作票编号是否已存在
  720. const response = await getOrderList(1, 10, workPermitNum.value, '')
  721. const responseObj = response as UTSJSONObject
  722. const rows = responseObj['rows'] as UTSJSONObject[] | null
  723. if (rows != null && rows.length > 0) {
  724. uni.showToast({ title: '工作票编号:' + workPermitNum.value + '已存在', icon: 'none' })
  725. workPermitNum.value = ''
  726. return
  727. }
  728. }
  729. };
  730. // MIS工单编码输入处理
  731. const handleMisNoInputFocus = (): void => {
  732. showMisNoQuickSelect.value = true;
  733. };
  734. const handleMisNoInputBlur = (): void => {
  735. setTimeout(() => {
  736. showMisNoQuickSelect.value = false;
  737. }, 200);
  738. };
  739. const handleMisNoInput = (e: SysDictData): void => {
  740. misNo.value = (e['detail'] as string | null) ?? '';
  741. // 这里可以添加实时搜索MIS工单的逻辑
  742. };
  743. const handleMisNoClear = (): void => {
  744. misNo.value = '';
  745. showMisNoQuickSelect.value = false;
  746. };
  747. const handleMisNoQuickSelect = (item: UTSJSONObject): void => {
  748. misNo.value = (item['misNo'] as string | null) ?? '';
  749. showMisNoQuickSelect.value = false;
  750. };
  751. // 获取MIS工单列表
  752. const getMisList = async (): Promise<void> => {
  753. try {
  754. const queryParams = {
  755. pcsDeviceName: pcsDeviceName.value,
  756. pcsStationName: pcsStationName.value,
  757. workOrderStatus: '结束'
  758. } as UTSJSONObject;
  759. // 调用获取MIS工单列表的API
  760. const result = await getMisInfoList(queryParams);
  761. const resultObj = result as UTSJSONObject;
  762. if (resultObj['code'] == 200) {
  763. // 解析列表数据
  764. const rows = resultObj['rows'] as UTSJSONObject[]
  765. misList.value = rows;
  766. allMisList.value = rows
  767. // 解析总数
  768. misListTotal.value = resultObj['total'] as number;
  769. } else {
  770. const msg = resultObj['msg'] as string | null
  771. uni.showToast({
  772. title: msg ?? '获取MIS工单列表失败',
  773. icon: 'none'
  774. })
  775. }
  776. } catch (error: any) {
  777. console.error('获取MIS工单列表失败:', error);
  778. uni.showToast({
  779. title: error.message ?? '获取MIS工单列表失败',
  780. icon: 'none'
  781. });
  782. }
  783. };
  784. // 打开MIS工单选择弹窗
  785. const openMisListModal = (): void => {
  786. showMisListModal.value = true;
  787. misListPage.value = 1; // 重置为第一页
  788. getMisList(); // 获取列表数据
  789. };
  790. // 选择MIS工单
  791. const selectMisItem = async (item: UTSJSONObject, index: number): Promise<void> => {
  792. selectedMisInfoIndex.value = index
  793. // 回填MIS工单相关信息
  794. misNo.value = item['misNo'] as string | '';
  795. // 查询MIS工单是否已存在
  796. const response = await getOrderList(1, 10, misNo.value, '')
  797. const responseObj = response as UTSJSONObject
  798. const rows = responseObj['rows'] as UTSJSONObject[] | null
  799. if (rows != null && rows.length > 0) {
  800. uni.showToast({ title: 'MIS工单:' + misNo.value + '已存在', icon: 'none' })
  801. misNo.value = ''
  802. return
  803. }
  804. // 查询相关工作班成员
  805. await listWorkPerson(misNo.value).then(response => {
  806. const responseObj = response as UTSJSONObject
  807. const rows = responseObj['rows'] as UTSJSONObject[] | null
  808. workOrderPersonList.value = rows ?? []
  809. if (rows != null && rows.length > 0) {
  810. // 查找 isLeader 等于 1 的负责人(优先获取第一个符合条件的,贴合常规单负责人场景)
  811. const leaderPerson = rows.find(person => person.isLeader == 1);
  812. if(leaderPerson != null) {
  813. teamLeaderId.value = (leaderPerson['userId'] as Number | null) ?? null
  814. teamLeaderName.value = (leaderPerson['nickName'] as string | null) ?? ''
  815. }
  816. const nickNames = rows
  817. .filter(person => person.isLeader != 1)
  818. .map(person => (person.nickName as string | null) ?? '')
  819. .join(',');
  820. workGroupMemberName.value = nickNames;
  821. }
  822. })
  823. workPermitNum.value = item['workPermitNum'] as string | '';
  824. realStartTime.value = item['realStartTime'] as string | '';
  825. realEndTime.value = item['realEndTime'] as string | '';
  826. // 关闭弹窗
  827. showMisListModal.value = false;
  828. };
  829. // 搜索
  830. const handleUserSearch = (): void => {
  831. const keyword = userKeyword.value
  832. userList.value = userAllList.value.filter(leader => {
  833. const nickName = leader['nickName'] as string | null
  834. return nickName != null && nickName.indexOf(keyword) >= 0
  835. })
  836. }
  837. // 关闭MIS工单选择弹窗
  838. const closeMisListModal = (): void => {
  839. showMisListModal.value = false;
  840. };
  841. // 搜索
  842. const searchMisList = (): void => {
  843. const keyword = misListKeyword.value
  844. misList.value = allMisList.value.filter(misInfo => {
  845. const misNo = misInfo['misNo'] as string | null
  846. // return misNo != null && misNo.indexOf(keyword) >= 0
  847. const workPermitNum = misInfo['workPermitNum'] as string | null
  848. // 逻辑或(||)连接两个条件,满足其一即可
  849. const misNoMatch = misNo != null && misNo.indexOf(keyword) >= 0
  850. const workPermitNumMatch = workPermitNum != null && workPermitNum.indexOf(keyword) >= 0
  851. return misNoMatch || workPermitNumMatch
  852. })
  853. }
  854. // 清除MIS工单搜索
  855. const clearMisListSearch = (): void => {
  856. misListKeyword.value = "";
  857. misList.value = allMisList.value
  858. };
  859. // 清除用户搜索
  860. const clearUserSearch = (): void => {
  861. userKeyword.value = "";
  862. userList.value = userAllList.value
  863. };
  864. // 搜索工作负责人
  865. const handleSearch = (): void => {
  866. const keyword = teamKeyword.value
  867. teamLeaderList.value = teamAllLeaderList.value.filter(leader => {
  868. const nickName = leader['nickName'] as string | null
  869. return nickName != null && nickName.indexOf(keyword) >= 0
  870. })
  871. }
  872. // 清空搜索工作负责人
  873. const clearSearch = (): void => {
  874. teamKeyword.value = ""
  875. teamLeaderList.value = teamAllLeaderList.value
  876. }
  877. function onStartDateConfirm(value: string) {
  878. // 检查结束时间是否小于新的开始时间
  879. if (realEndTime.value != '' && new Date(value) > new Date(realEndTime.value as string)) {
  880. uni.showToast({ title: '开始时间不能大于结束时间', icon: 'none' })
  881. return
  882. }
  883. realStartTime.value = value
  884. showStartTimePicker.value = false
  885. }
  886. function onEndDateConfirm(value: string) {
  887. // 检查新的结束时间是否小于开始时间
  888. if (realStartTime.value != '' && new Date(realStartTime.value as string) > new Date(value)) {
  889. uni.showToast({ title: '结束时间不能小于开始时间', icon: 'none' })
  890. return
  891. }
  892. realEndTime.value = value
  893. showEndTimePicker.value = false
  894. }
  895. // 检查用户是否已被选中
  896. const isSelected = (user: UTSJSONObject): boolean => {
  897. const userId = user['userId'] as string | number | null;
  898. if (userId !== null) {
  899. return selectedUserIds.value.includes(userId.toString());
  900. }
  901. // 如果没有userId,则比较nickName
  902. const nickName = user['nickName'] as string | null;
  903. if (nickName !== null) {
  904. return selectedUsers.value.some(selected =>
  905. (selected['nickName'] as string | null) === nickName
  906. );
  907. }
  908. return false;
  909. };
  910. // 切换用户选择状态
  911. const toggleUserSelection = (user: UTSJSONObject): void => {
  912. const userId = user['userId'] as string | number | null;
  913. const nickName = user['nickName'] as string | null;
  914. if (userId !== null) {
  915. const userIdStr = userId.toString();
  916. const index = selectedUserIds.value.indexOf(userIdStr);
  917. if (index > -1) {
  918. // 取消选择
  919. selectedUserIds.value.splice(index, 1);
  920. selectedUsers.value = selectedUsers.value.filter(selected =>
  921. (selected['userId'] as string | number | null)?.toString() !== userIdStr
  922. );
  923. } else {
  924. // 添加选择
  925. selectedUserIds.value.push(userIdStr);
  926. selectedUsers.value.push(user);
  927. }
  928. } else if (nickName !== null) {
  929. // 如果没有userId,通过nickName来识别
  930. const index = selectedUsers.value.findIndex(selected =>
  931. (selected['nickName'] as string | null) === nickName
  932. );
  933. if (index > -1) {
  934. // 取消选择
  935. selectedUsers.value.splice(index, 1);
  936. // 同时移除对应的userId(如果有的话)
  937. const userToRemoveId = user['userId'] as string | number | null;
  938. if (userToRemoveId !== null) {
  939. const idIndex = selectedUserIds.value.indexOf(userToRemoveId.toString());
  940. if (idIndex > -1) {
  941. selectedUserIds.value.splice(idIndex, 1);
  942. }
  943. }
  944. } else {
  945. // 添加选择
  946. selectedUsers.value.push(user);
  947. const userToAddId = user['userId'] as string | number | null;
  948. if (userToAddId !== null) {
  949. selectedUserIds.value.push(userToAddId.toString());
  950. }
  951. }
  952. }
  953. };
  954. // 确认选择的用户
  955. const confirmSelectedUsers = (): void => {
  956. // 将选中的用户姓名拼接成字符串
  957. const nickNames = selectedUsers.value
  958. .map(user => (user['nickName'] as string | null) ?? '')
  959. .filter(name => name !== '')
  960. .join(',');
  961. workGroupMemberName.value = nickNames;
  962. // 更新workOrderPersonList为选中的用户
  963. workOrderPersonList.value = [...selectedUsers.value];
  964. showUserSelect.value = false;
  965. };
  966. // 清空已选择的用户
  967. const clearSelectedUsers = (): void => {
  968. // 清空选中的用户数组
  969. selectedUsers.value = [];
  970. selectedUserIds.value = [];
  971. // 清空显示的用户名
  972. workGroupMemberName.value = '';
  973. // 清空工作班成员列表
  974. workOrderPersonList.value = [];
  975. };
  976. // 检查工作部位是否已被选中
  977. const isWorkAreaSelected = (workArea: SysDictData): boolean => {
  978. return selectedWorkAreas.value.some(selected =>
  979. (selected.dictValue as string | null) === (workArea.dictValue as string | null)
  980. );
  981. };
  982. // 切换工作部位选择状态
  983. const toggleWorkAreaSelection = (workArea: SysDictData): void => {
  984. const index = selectedWorkAreas.value.findIndex(selected =>
  985. (selected.dictValue as string | null) === (workArea.dictValue as string | null)
  986. );
  987. if (index > -1) {
  988. // 取消选择
  989. selectedWorkAreas.value.splice(index, 1);
  990. } else {
  991. // 添加选择
  992. selectedWorkAreas.value.push(workArea);
  993. }
  994. };
  995. // 确认选择的工作部位
  996. const confirmSelectedWorkAreas = (): void => {
  997. // 将选中的工作部位标签拼接成字符串,用逗号分隔
  998. const labels = selectedWorkAreas.value
  999. .map(item => item.dictLabel ?? '')
  1000. .filter(label => label !== '');
  1001. workAreaLabel.value = labels.join(', ');
  1002. // 将选中的工作部位值拼接成字符串,用逗号分隔
  1003. workArea.value = selectedWorkAreas.value
  1004. .map(item => item.dictValue ?? '')
  1005. .filter(value => value !== '')
  1006. .join(',');
  1007. showWorkAreaPicker.value = false;
  1008. };
  1009. // 表单验证
  1010. const validateForm = (): boolean => {
  1011. if (infoEntry.value == '') {
  1012. uni.showToast({
  1013. title: '请选择信息录入方式',
  1014. icon: 'none'
  1015. });
  1016. return false;
  1017. }
  1018. if (infoEntry.value == '1' && (misNo.value == '')) {
  1019. uni.showToast({
  1020. title: '请输入MIS工单编码',
  1021. icon: 'none'
  1022. });
  1023. return false;
  1024. }
  1025. if (workPermitNum.value == '') {
  1026. uni.showToast({
  1027. title: '请输入工作票编号',
  1028. icon: 'none'
  1029. });
  1030. return false;
  1031. }
  1032. if (realStartTime.value == '') {
  1033. uni.showToast({
  1034. title: '请选择开始时间',
  1035. icon: 'none'
  1036. });
  1037. return false;
  1038. }
  1039. if (realEndTime.value == '') {
  1040. uni.showToast({
  1041. title: '请选择结束时间',
  1042. icon: 'none'
  1043. });
  1044. return false;
  1045. }
  1046. if (new Date(realEndTime.value) <= new Date(realStartTime.value)) {
  1047. uni.showToast({
  1048. title: '结束时间必须大于开始时间',
  1049. icon: 'none'
  1050. });
  1051. return false;
  1052. }
  1053. if (teamLeaderName.value == '') {
  1054. uni.showToast({
  1055. title: '请选择工作负责人',
  1056. icon: 'none'
  1057. });
  1058. return false;
  1059. }
  1060. if (workGroupMemberName.value == '') {
  1061. uni.showToast({
  1062. title: '请选择工作班成员',
  1063. icon: 'none'
  1064. });
  1065. return false;
  1066. }
  1067. return true;
  1068. };
  1069. const isDealing = ref(false)
  1070. const hasDealed = ref(false)
  1071. // 提交表单
  1072. const handleSubmit = async (): Promise<void> => {
  1073. if (!validateForm()) {
  1074. return;
  1075. }
  1076. submitLoading.value = true;
  1077. try {
  1078. if (isDealing.value || hasDealed.value) return // 双重保险
  1079. isDealing.value = true
  1080. // 确保附件URLs是最新的逗号分隔格式
  1081. attachmentUrls.value = uploadedFiles.value.map(file => file.fileName).join(',');
  1082. const finishData = {
  1083. id: orderId.value,
  1084. orderType: orderType.value,
  1085. workOrderProjectNo: workOrderProjectNo.value,
  1086. infoEntry: infoEntry.value,
  1087. misNo: infoEntry.value == '1' ? misNo.value : null,
  1088. workPermitNum: workPermitNum.value,
  1089. realStartTime: realStartTime.value,
  1090. realEndTime: realEndTime.value,
  1091. wwryNum: wwryNum.value,
  1092. wlryNum: wlryNum.value,
  1093. workGroupMemberName: workGroupMemberName.value,
  1094. realFailureReason: realFailureReason.value,
  1095. attachmentUrls: attachmentUrls.value,
  1096. workOrderPersonList: workOrderPersonList.value,
  1097. teamLeaderId: teamLeaderId.value,
  1098. teamLeaderName: teamLeaderName.value,
  1099. finalizeMethod: '2',
  1100. workOrderStatus: 'completed',
  1101. workArea: workArea.value,
  1102. repairMethod: '1'
  1103. } as UTSJSONObject;
  1104. const result = await repairFinishOrder(finishData);
  1105. const resultObj = result as UTSJSONObject;
  1106. const code = resultObj['code'] as number;
  1107. if (code == 200) {
  1108. uni.showToast({
  1109. title: '结单成功',
  1110. icon: 'success'
  1111. });
  1112. hasDealed.value = true
  1113. // 使用事件总线通知列表页面刷新
  1114. uni.$emit('refreshOrderList', {});
  1115. uni.$emit('refreshAssignedCount');
  1116. uni.$emit('refreshOverdueCount');
  1117. setTimeout(() => {
  1118. uni.navigateBack();
  1119. }, 800);
  1120. } else {
  1121. const msg = resultObj['msg'] as string;
  1122. uni.showToast({
  1123. title: msg.length > 0 ? msg : '结单失败',
  1124. icon: 'none'
  1125. });
  1126. }
  1127. } catch (error: any) {
  1128. console.error('结单失败:', error);
  1129. uni.showToast({
  1130. title: '结单失败',
  1131. icon: 'none'
  1132. });
  1133. } finally {
  1134. submitLoading.value = false;
  1135. isDealing.value = false // 无论成功失败都解锁
  1136. }
  1137. };
  1138. const loading = ref<boolean>(false)
  1139. // 加载详情数据
  1140. const loadDetail = async (id: string, orderType?: string): Promise<void> => {
  1141. try {
  1142. loading.value = true
  1143. let result: any;
  1144. // 根据orderType决定调用哪个API
  1145. if (orderType == '1') {
  1146. // 维修工单
  1147. result = await getRepairOrderInfoById(id)
  1148. } else {
  1149. // 维保工单
  1150. result = await getOrderInfoById(id)
  1151. }
  1152. // 提取响应数据
  1153. const resultObj = result as UTSJSONObject
  1154. const code = resultObj['code'] as number
  1155. const data = resultObj['data'] as UTSJSONObject | null
  1156. if (code == 200 && data != null) {
  1157. workOrderStatus.value = (data['workOrderStatus'] as string | null) ?? ''
  1158. workOrderProjectNo.value = (data['workOrderProjectNo'] as string | null) ?? ''
  1159. pcsDeviceName.value = (data['pcsDeviceName'] as string | null) ?? ''
  1160. gxtCenter.value = (data['gxtCenter'] as string | null) ?? ''
  1161. pcsStationName.value = (data['pcsStationName'] as string | null) ?? ''
  1162. brand.value = (data['brand'] as string | null) ?? ''
  1163. model.value = (data['model'] as string | null) ?? ''
  1164. acceptTime.value = (data['acceptTime'] as string | null) ?? ''
  1165. acceptUserName.value = (data['acceptUserName'] as string | null) ?? ''
  1166. // 初始化结单表单默认值
  1167. infoEntry.value = '1' // 默认为手工录入
  1168. teamLeaderId.value = (data['teamLeaderId'] as Number | null) ?? null
  1169. teamLeaderName.value = (data['teamLeaderName'] as string | null) ?? ''
  1170. returnType.value = workOrderStatus.value == 'to_finish' ? '1' : ''
  1171. faultCode.value = (data['faultCode'] as string | null) ?? ''
  1172. faultBarcode.value = (data['faultBarcode'] as string | null) ?? ''
  1173. faultDesc.value = (data['faultDesc'] as string | null) ?? ''
  1174. // 初始化附件数据
  1175. const attachmentUrlsFromServer = (data['attachmentUrls'] as string | null) ?? ''
  1176. if (attachmentUrlsFromServer.length > 0) {
  1177. attachmentUrls.value = attachmentUrlsFromServer
  1178. // 将逗号分隔的URL字符串转换为UploadResponse对象数组
  1179. const urls = attachmentUrlsFromServer.split(',')
  1180. const fileArr : UploadResponse[] = []
  1181. for (let i = 0; i < urls.length; i++) {
  1182. const url = urls[i]
  1183. const item : UploadResponse = {
  1184. url: url,
  1185. fileId: '',
  1186. fileName: url.substring(url.lastIndexOf('/') + 1),
  1187. filePath: url,
  1188. fileSize: 0,
  1189. fileExt: url.substring(url.lastIndexOf('.') + 1),
  1190. businessType: 'workOrder'
  1191. }
  1192. fileArr.push(item)
  1193. }
  1194. uploadedFiles.value = fileArr
  1195. }
  1196. pauseTime.value = (data['pauseTime'] as string | null) ?? ''
  1197. restartTime.value = (data['restartTime'] as string | null) ?? ''
  1198. if(pauseTime.value != '' && restartTime.value != '') {
  1199. const queryParams = {
  1200. pauseTime: pauseTime.value,
  1201. restartTime: restartTime.value,
  1202. pcsDeviceName: pcsDeviceName.value,
  1203. pcsStationName: pcsStationName.value,
  1204. workOrderStatus: '结束'
  1205. } as UTSJSONObject;
  1206. const result = await listAutoMisInfo(queryParams)
  1207. // 提取响应数据
  1208. const resultObj = result as UTSJSONObject
  1209. const code = resultObj['code'] as number
  1210. const misInfo = resultObj['rows'] as UTSJSONObject[] | null
  1211. if (code == 200 && misInfo != null) {
  1212. if(misInfo.length > 0 && misInfo.length == 1) {
  1213. // 有工作票号提示
  1214. const workPermitNum2 = misInfo[0]['workPermitNum'] as string | null
  1215. const misNo2 = misInfo[0]['misNo'] as string | null
  1216. if (workPermitNum2 != null && workPermitNum2.length > 0) {
  1217. const response = await getOrderList(1, 10, misNo2 ?? '', '')
  1218. const responseObj = response as UTSJSONObject
  1219. const rows = responseObj['rows'] as UTSJSONObject[] | null
  1220. if (rows != null && rows.length > 0) {
  1221. misNo.value = ''
  1222. // infoEntry.value = '2'
  1223. uni.showToast({
  1224. title: '未找到匹配的MIS工单,请确认风机停复机时间是否已录入工效通系统或请进入工作票录入方式',
  1225. icon: 'none'
  1226. });
  1227. return
  1228. } else {
  1229. misNo.value = (misInfo[0]['misNo'] as string | null) ?? ''
  1230. realStartTime.value = (misInfo[0]['realStartTime'] as string | null) ?? ''
  1231. realEndTime.value = (misInfo[0]['realEndTime'] as string | null) ?? ''
  1232. workPermitNum.value = (misInfo[0]['workPermitNum'] as string | null) ?? ''
  1233. // 查询相关工作班成员
  1234. await listWorkPerson(misNo.value).then(response => {
  1235. const responseObj = response as UTSJSONObject
  1236. const rows = responseObj['rows'] as UTSJSONObject[] | null
  1237. workOrderPersonList.value = rows ?? []
  1238. if (rows != null && rows.length > 0) {
  1239. // 查询负责人信息并回填
  1240. for (const person of workOrderPersonList.value) {
  1241. // 严格判断isLeader为1(兼容数字/字符串类型)
  1242. if (person.isLeader == 1) {
  1243. teamLeaderName.value = (person.nickName as string | null) ?? '';
  1244. teamLeaderId.value = (person.userId as Number | null) ?? null;
  1245. break; // 找到后立即停止循环
  1246. }
  1247. }
  1248. const nickNames = rows
  1249. .filter(person => person.isLeader != 1)
  1250. .map(person => (person.nickName as string | null) ?? '')
  1251. .join(',');
  1252. workGroupMemberName.value = nickNames;
  1253. }
  1254. })
  1255. }
  1256. } else {
  1257. misNo.value = ''
  1258. // infoEntry.value = '2'
  1259. uni.showToast({
  1260. title: '已匹配到MIS工单,但未关联工作票号,系统无法自动结单,请进入工作票录入方式。',
  1261. icon: 'none'
  1262. });
  1263. return
  1264. }
  1265. } else if(misInfo.length == 0) {
  1266. misNo.value = ''
  1267. // infoEntry.value = '2'
  1268. uni.showToast({
  1269. title: '未找到匹配的MIS工单,请确认风机停复机时间是否已录入工效通系统或请进入工作票录入方式',
  1270. icon: 'none'
  1271. });
  1272. return
  1273. } else if(misInfo.length > 1) {
  1274. infoEntryDisabled.value = false
  1275. }
  1276. }
  1277. } else {
  1278. infoEntryDisabled.value = true
  1279. misNo.value = ''
  1280. // infoEntry.value = '2'
  1281. uni.showToast({
  1282. title: '未找到匹配的MIS工单,请确认风机停复机时间是否已录入工效通系统或请进入工作票录入方式',
  1283. icon: 'none'
  1284. });
  1285. }
  1286. // await dictList()
  1287. if (returnTypeOptions.value.length > 0 && workOrderStatus.value == 'to_finish') {
  1288. // returnTypeLabel.value = returnTypeOptions.value[0].label
  1289. // 循环匹配
  1290. for (const option of returnTypeOptions.value) {
  1291. // 严格匹配value
  1292. if (returnType.value == option.value) {
  1293. returnTypeLabel.value = option.label;
  1294. break; // 匹配成功后跳出循环,提升性能
  1295. }
  1296. }
  1297. }
  1298. } else {
  1299. const msg = resultObj['msg'] as string | null
  1300. uni.showToast({
  1301. title: msg ?? '加载失败',
  1302. icon: 'none'
  1303. })
  1304. }
  1305. } catch (e: any) {
  1306. uni.showToast({
  1307. title: e.message ?? '加载失败',
  1308. icon: 'none'
  1309. })
  1310. } finally {
  1311. loading.value = false
  1312. }
  1313. }
  1314. // 页面加载
  1315. onLoad((options: any) => {
  1316. const params = options as UTSJSONObject
  1317. const id = params['id'] as string | null
  1318. const orderTypeParam = params['orderType'] as string | null
  1319. if (id != null && orderTypeParam != null) {
  1320. // 先尝试从参数中获取orderType
  1321. // const orderTypeNumber = parseInt(orderTypeParam)
  1322. orderType.value = orderTypeParam
  1323. orderId.value = id
  1324. loadDetail(id, orderTypeParam)
  1325. }
  1326. })
  1327. // 初始化
  1328. onMounted(() => {
  1329. getUserAllList();
  1330. loadInfoEntryDictList();
  1331. loadWorkAreaDictList();
  1332. })
  1333. </script>
  1334. <style lang="scss">
  1335. .detail-page {
  1336. flex: 1;
  1337. background-color: #e8f0f9;
  1338. }
  1339. .detail-content {
  1340. flex: 1;
  1341. padding: 20rpx 0;
  1342. }
  1343. .info-section {
  1344. margin: 0 30rpx 24rpx;
  1345. .section-title {
  1346. position: relative;
  1347. padding-left: 20rpx;
  1348. margin-bottom: 20rpx;
  1349. &::before {
  1350. position: absolute;
  1351. left: 0;
  1352. top: 50%;
  1353. transform: translateY(-50%);
  1354. width: 8rpx;
  1355. height: 32rpx;
  1356. background-color: #007aff;
  1357. border-radius: 4rpx;
  1358. }
  1359. &-text {
  1360. font-size: 32rpx;
  1361. font-weight: bold;
  1362. color: #333333;
  1363. }
  1364. }
  1365. .info-card {
  1366. background-color: #ffffff;
  1367. border-radius: 16rpx;
  1368. padding: 30rpx;
  1369. .info-item {
  1370. flex-direction: row;
  1371. padding: 20rpx 0;
  1372. border-bottom: 1rpx solid #f0f0f0;
  1373. &:last-child {
  1374. border-bottom: none;
  1375. }
  1376. &.full-width {
  1377. flex-direction: column;
  1378. .info-label {
  1379. margin-bottom: 12rpx;
  1380. }
  1381. .info-value {
  1382. line-height: 44rpx;
  1383. }
  1384. }
  1385. .info-label {
  1386. width: 240rpx;
  1387. font-size: 28rpx;
  1388. color: #666666;
  1389. white-space: nowrap;
  1390. }
  1391. .info-value {
  1392. flex: 1;
  1393. font-size: 28rpx;
  1394. color: #333333;
  1395. text-align: left;
  1396. &.highlight {
  1397. color: #007aff;
  1398. font-weight: bold;
  1399. }
  1400. &.input {
  1401. text-align: left;
  1402. border: 1rpx solid #e0e0e0;
  1403. border-radius: 8rpx;
  1404. padding: 10rpx;
  1405. }
  1406. .input-with-clear {
  1407. position: relative;
  1408. display: flex;
  1409. align-items: center;
  1410. }
  1411. .select-clear {
  1412. position: absolute;
  1413. right: 20rpx;
  1414. color: #ccc;
  1415. text-align: center;
  1416. font-size: 40rpx;
  1417. font-weight: bold;
  1418. z-index: 1;
  1419. }
  1420. .input-with-select {
  1421. position: relative;
  1422. display: flex;
  1423. align-items: center;
  1424. }
  1425. .select-mis-btn {
  1426. line-height: 50rpx;
  1427. text-align: center;
  1428. position: absolute;
  1429. right: 0rpx;
  1430. padding: 6rpx 12rpx;
  1431. background-color: #007aff;
  1432. color: #fff;
  1433. border-radius: 6rpx;
  1434. font-size: 26rpx;
  1435. z-index: 1;
  1436. max-width: 100rpx;
  1437. overflow: hidden;
  1438. text-overflow: ellipsis;
  1439. white-space: nowrap;
  1440. }
  1441. }
  1442. }
  1443. .flow-item {
  1444. padding: 20rpx 0;
  1445. border-bottom: 1rpx solid #f0f0f0;
  1446. &:last-child {
  1447. border-bottom: none;
  1448. }
  1449. .flow-header {
  1450. flex-direction: row;
  1451. justify-content: space-between;
  1452. margin-bottom: 10rpx;
  1453. .flow-operator {
  1454. font-size: 28rpx;
  1455. color: #333333;
  1456. font-weight: bold;
  1457. }
  1458. .flow-time {
  1459. font-size: 24rpx;
  1460. color: #999999;
  1461. }
  1462. }
  1463. .flow-content {
  1464. flex-direction: column;
  1465. .flow-action {
  1466. font-size: 26rpx;
  1467. color: #666666;
  1468. margin-bottom: 8rpx;
  1469. }
  1470. .flow-remark {
  1471. font-size: 24rpx;
  1472. color: #999999;
  1473. background-color: #f5f5f5;
  1474. padding: 10rpx;
  1475. border-radius: 8rpx;
  1476. }
  1477. }
  1478. }
  1479. .no-data {
  1480. text-align: center;
  1481. padding: 40rpx 0;
  1482. font-size: 28rpx;
  1483. color: #999999;
  1484. }
  1485. }
  1486. }
  1487. .accept-button-container {
  1488. padding: 30rpx 30rpx 50rpx;
  1489. background-color: #ffffff;
  1490. .accept-button {
  1491. width: 100%;
  1492. height: 80rpx;
  1493. background-color: #007aff;
  1494. color: #ffffff;
  1495. font-size: 32rpx;
  1496. border-radius: 16rpx;
  1497. border: none;
  1498. &:active {
  1499. background-color: #0062cc;
  1500. }
  1501. }
  1502. }
  1503. .loading-mask {
  1504. position: absolute;
  1505. top: 0;
  1506. left: 0;
  1507. right: 0;
  1508. bottom: 0;
  1509. justify-content: center;
  1510. align-items: center;
  1511. background-color: rgba(0, 0, 0, 0.3);
  1512. .loading-text {
  1513. padding: 30rpx 60rpx;
  1514. background-color: rgba(0, 0, 0, 0.7);
  1515. color: #ffffff;
  1516. font-size: 28rpx;
  1517. border-radius: 12rpx;
  1518. }
  1519. }
  1520. .picker-modal {
  1521. position: fixed;
  1522. top: 0;
  1523. left: 0;
  1524. right: 0;
  1525. bottom: 0;
  1526. z-index: 1000;
  1527. }
  1528. .modal-mask {
  1529. position: absolute;
  1530. top: 0;
  1531. left: 0;
  1532. right: 0;
  1533. bottom: 0;
  1534. background-color: rgba(0, 0, 0, 0.5);
  1535. }
  1536. .modal-content {
  1537. position: absolute;
  1538. bottom: 0;
  1539. left: 0;
  1540. right: 0;
  1541. background-color: #ffffff;
  1542. border-top-left-radius: 16rpx;
  1543. border-top-right-radius: 16rpx;
  1544. min-height: 700rpx;
  1545. }
  1546. .modal-header {
  1547. flex-direction: row;
  1548. justify-content: space-between;
  1549. align-items: center;
  1550. padding: 30rpx;
  1551. border-bottom: 1rpx solid #f0f0f0;
  1552. }
  1553. .modal-title {
  1554. font-size: 32rpx;
  1555. font-weight: bold;
  1556. color: #333333;
  1557. }
  1558. .modal-close {
  1559. font-size: 28rpx;
  1560. color: #007aff;
  1561. }
  1562. .modal-body {
  1563. max-height: 800rpx;
  1564. min-height: 800rpx;
  1565. }
  1566. .picker-option {
  1567. flex-direction: row;
  1568. justify-content: space-between;
  1569. align-items: center;
  1570. padding: 24rpx 30rpx;
  1571. border-bottom: 1rpx solid #f0f0f0;
  1572. }
  1573. .picker-option.selected {
  1574. background-color: #f8f9fa;
  1575. }
  1576. .picker-option:last-child {
  1577. border-bottom: none;
  1578. }
  1579. .option-text {
  1580. font-size: 28rpx;
  1581. color: #333333;
  1582. margin-bottom: 10rpx;
  1583. }
  1584. .option-text:last-child {
  1585. margin-bottom: 0;
  1586. }
  1587. .option-check {
  1588. font-size: 28rpx;
  1589. color: #007aff;
  1590. }
  1591. .empty-tip {
  1592. justify-content: space-between;
  1593. padding: 24rpx 30rpx;
  1594. display: flex;
  1595. align-items: center;
  1596. justify-content: center;
  1597. color: #999;
  1598. }
  1599. .picker-option {
  1600. flex-direction: row;
  1601. justify-content: space-between;
  1602. align-items: center;
  1603. padding: 24rpx 30rpx;
  1604. border-bottom: 1rpx solid #f0f0f0;
  1605. }
  1606. .picker-option:last-child {
  1607. border-bottom: none;
  1608. }
  1609. .picker-option.selected {
  1610. background-color: #f8f9fa;
  1611. }
  1612. .option-text {
  1613. font-size: 28rpx;
  1614. color: #333333;
  1615. }
  1616. .mis-list {
  1617. flex: 1;
  1618. height: 100%;
  1619. display: flex;
  1620. flex-direction: column;
  1621. }
  1622. .empty-tip {
  1623. text-align: center;
  1624. padding: 40rpx;
  1625. color: #999;
  1626. font-size: 28rpx;
  1627. }
  1628. .form-item {
  1629. flex-direction: row;
  1630. padding: 20rpx 0;
  1631. border-bottom: 1rpx solid #f0f0f0;
  1632. }
  1633. .reject-reason-textarea {
  1634. width: 100%;
  1635. min-height: 100rpx;
  1636. line-height: 1.5;
  1637. }
  1638. .input-field {
  1639. width: 100%;
  1640. height: 60rpx;
  1641. padding: 0 20rpx;
  1642. border: 1rpx solid #e0e0e0;
  1643. border-radius: 8rpx;
  1644. font-size: 28rpx;
  1645. background-color: #f8f9fa;
  1646. }
  1647. .select-mis-btn {
  1648. width: 150rpx;
  1649. height: 60rpx;
  1650. margin-left: 10rpx;
  1651. background-color: #007aff;
  1652. color: #fff;
  1653. border: none;
  1654. border-radius: 8rpx;
  1655. font-size: 24rpx;
  1656. }
  1657. .textarea-field {
  1658. width: 100%;
  1659. min-height: 120rpx;
  1660. padding: 20rpx;
  1661. border: 1rpx solid #e0e0e0;
  1662. border-radius: 8rpx;
  1663. font-size: 28rpx;
  1664. background-color: #f8f9fa;
  1665. }
  1666. .radio-label {
  1667. display: flex;
  1668. align-items: center;
  1669. margin-right: 30rpx;
  1670. }
  1671. .quick-select-dropdown {
  1672. position: absolute;
  1673. top: 100%;
  1674. left: 0;
  1675. right: 0;
  1676. background: #fff;
  1677. border: 1rpx solid #ddd;
  1678. border-top: none;
  1679. z-index: 1000;
  1680. max-height: 300rpx;
  1681. }
  1682. .quick-select-item {
  1683. padding: 20rpx;
  1684. border-bottom: 1rpx solid #eee;
  1685. }
  1686. .mis-no {
  1687. font-size: 28rpx;
  1688. color: #333;
  1689. }
  1690. .search-bar {
  1691. padding: 20rpx 30rpx;
  1692. background-color: #d7eafe;
  1693. }
  1694. .search-box {
  1695. flex-direction: row;
  1696. align-items: center;
  1697. height: 72rpx;
  1698. padding: 0 24rpx;
  1699. background-color: #f5f5f5;
  1700. border-radius: 36rpx;
  1701. .search-icon {
  1702. width: 32rpx;
  1703. height: 32rpx;
  1704. margin-right: 12rpx;
  1705. }
  1706. .search-input {
  1707. flex: 1;
  1708. font-size: 28rpx;
  1709. color: #333333;
  1710. }
  1711. .clear-icon {
  1712. margin-left: 12rpx;
  1713. font-size: 28rpx;
  1714. color: #999999;
  1715. }
  1716. }
  1717. .mis-list {
  1718. flex: 1;
  1719. height: 100%;
  1720. display: flex;
  1721. flex-direction: column;
  1722. }
  1723. .select-users-count {
  1724. margin-left: 10rpx;
  1725. font-size: 24rpx;
  1726. color: #666;
  1727. }
  1728. </style>