wbFinalize.uvue 64 KB

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