wxFinalize.uvue 66 KB

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