wbFinalize.uvue 64 KB

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