wbFinalize.uvue 66 KB

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