wbBackfillFinalize.uvue 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178
  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">{{ brand ?? '' }} {{ model ?? '' }}</text>
  33. </view>
  34. <view class="info-item">
  35. <text class="info-label">MIS工单</text>
  36. <text class="info-value">{{ misNo ?? '' }}</text>
  37. </view>
  38. <view class="info-item">
  39. <text class="info-label">工作票编号</text>
  40. <text class="info-value">{{ workPermitNum ?? '' }}</text>
  41. </view>
  42. <view class="info-item">
  43. <text class="info-label">接单时间</text>
  44. <text class="info-value">{{ acceptTime ?? '' }}</text>
  45. </view>
  46. </view>
  47. </view>
  48. <!-- 结单表单 -->
  49. <view class="info-section">
  50. <view class="section-title">
  51. <text class="section-title-text">结单信息</text>
  52. </view>
  53. <view class="info-card">
  54. <!-- 开始时间 -->
  55. <view class="info-item">
  56. <view class="info-label">
  57. <text class="form-label required">开始时间<text style="color: red;">*</text></text>
  58. </view>
  59. <view class="info-value">
  60. <view class="form-picker" @click="showStartTimePicker = true">
  61. <input
  62. class="input-field"
  63. placeholder="请选择开始时间"
  64. v-model="realStartTime"
  65. />
  66. </view>
  67. </view>
  68. </view>
  69. <!-- 结束时间 -->
  70. <view class="info-item">
  71. <view class="info-label">
  72. <text class="form-label required">结束时间<text style="color: red;">*</text></text>
  73. </view>
  74. <view class="info-value">
  75. <view class="form-picker" @click="showEndTimePicker = true">
  76. <input
  77. class="input-field"
  78. placeholder="请选择结束时间"
  79. v-model="realEndTime"
  80. />
  81. </view>
  82. </view>
  83. </view>
  84. <!-- 外委人员数 -->
  85. <view class="info-item">
  86. <view class="info-label">
  87. <text class="form-label required">外委人员数(人)</text>
  88. </view>
  89. <view class="info-value">
  90. <input
  91. type="number"
  92. class="input-field"
  93. placeholder="请输入外委人员数"
  94. v-model="wwryNum"
  95. />
  96. </view>
  97. </view>
  98. <!-- 外来人员数 -->
  99. <view class="info-item">
  100. <view class="info-label">
  101. <text class="form-label required">外来人员数(人)</text>
  102. </view>
  103. <view class="info-value">
  104. <input
  105. type="number"
  106. class="input-field"
  107. placeholder="请输入外来人员数"
  108. v-model="wlryNum"
  109. />
  110. </view>
  111. </view>
  112. <!-- 工作负责人 -->
  113. <view class="info-item">
  114. <view class="info-label">
  115. <text class="form-label required">工作负责人</text>
  116. </view>
  117. <view class="info-value">
  118. <input
  119. class="input-field"
  120. placeholder="请输入工作负责人"
  121. v-model="teamLeaderName"
  122. :disabled="true"
  123. />
  124. </view>
  125. </view>
  126. <!-- 工作班成员选择(当信息录入为2时可编辑) -->
  127. <view class="info-item">
  128. <view class="info-label">
  129. <text class="form-label required">工作班成员</text>
  130. </view>
  131. <view class="info-value">
  132. <view class="input-with-clear">
  133. <input
  134. class="input-field"
  135. placeholder="请选择工作班成员"
  136. v-model="workGroupMemberName"
  137. @click="showUserSelect = true"
  138. :disabled="infoEntry == '1'"
  139. />
  140. <text class="select-users-count" v-if="selectedUserIds.length > 0" :style="{ marginRight: selectedUserIds.length > 0 ? '60rpx' : '0' }">({{ selectedUserIds.length }}人)</text>
  141. <text class="select-clear" v-if="selectedUserIds.length > 0" @click="clearSelectedUsers">×</text>
  142. </view>
  143. </view>
  144. </view>
  145. <!-- 维保内容 -->
  146. <view class="info-item full-width">
  147. <view class="info-label">
  148. <text class="form-label required">维保内容<text style="color: red;">*</text></text>
  149. </view>
  150. <view class="info-value">
  151. <textarea
  152. class="textarea-field"
  153. placeholder="请输入维保内容"
  154. v-model="content"
  155. maxlength="500"
  156. :disabled="infoEntry == '1'"
  157. :show-confirm-bar="false"
  158. auto-height
  159. ></textarea>
  160. </view>
  161. </view>
  162. <!-- 附件上传 -->
  163. <view class="info-item full-width">
  164. <view class="info-label">
  165. <text class="form-label">附件(可选)</text>
  166. </view>
  167. <view class="info-value">
  168. <upload-image
  169. :limit="8"
  170. :modelValue="uploadedFiles"
  171. :businessType="'workOrder'"
  172. @update:modelValue="uploadedFiles = $event as UTSArray<UploadResponse>"
  173. />
  174. </view>
  175. </view>
  176. </view>
  177. </view>
  178. <!-- 时间选择器弹窗 -->
  179. <!-- Start Date Picker -->
  180. <l-popup v-model="showStartTimePicker" position="bottom">
  181. <l-date-time-picker
  182. title="选择开始时间"
  183. :mode="1 | 2 | 4 | 8 | 16"
  184. format="YYYY-MM-DD HH:mm"
  185. :modelValue="realStartTime"
  186. confirm-btn="确定"
  187. cancel-btn="取消"
  188. @confirm="onStartDateConfirm"
  189. @cancel="showStartTimePicker = false">
  190. </l-date-time-picker>
  191. </l-popup>
  192. <!-- End Date Picker -->
  193. <l-popup v-model="showEndTimePicker" position="bottom">
  194. <l-date-time-picker
  195. title="选择结束时间"
  196. :mode="31"
  197. format="YYYY-MM-DD HH:mm"
  198. :modelValue="realStartTime"
  199. confirm-btn="确定"
  200. cancel-btn="取消"
  201. @confirm="onEndDateConfirm"
  202. @cancel="showEndTimePicker = false">
  203. </l-date-time-picker>
  204. </l-popup>
  205. <!-- 人员选择弹窗 -->
  206. <view v-if="showUserSelect" class="picker-modal">
  207. <view class="modal-mask" @click="showUserSelect = false"></view>
  208. <view class="modal-content">
  209. <view class="modal-header">
  210. <text class="modal-title">选择工作班成员</text>
  211. <text class="modal-close" @click="confirmSelectedUsers">确定</text>
  212. </view>
  213. <view class="search-bar">
  214. <view class="search-box">
  215. <image class="search-icon" src="/static/images/workbench/list/1.png" mode="aspectFit"></image>
  216. <input class="search-input" type="text" placeholder="搜索姓名" v-model="userKeyword" @input="handleSearch" />
  217. <text v-if="userKeyword.length > 0" class="clear-icon" @click="clearSearch">✕</text>
  218. </view>
  219. </view>
  220. <scroll-view class="modal-body" scroll-y="true">
  221. <view
  222. v-for="(user, index) in userList"
  223. :key="index"
  224. class="picker-option"
  225. @click="toggleUserSelection(user)"
  226. >
  227. <text class="option-text">{{ (user['nickName'] as string | null) ?? '' }}</text>
  228. <text class="option-text">{{ ((user['dept'] as UTSJSONObject | null)?.['deptName'] as string | null) ?? '' }}</text>
  229. <text class="option-check" v-if="isSelected(user)">✓</text>
  230. </view>
  231. </scroll-view>
  232. </view>
  233. </view>
  234. </scroll-view>
  235. <!-- 确认结单按钮 -->
  236. <view class="accept-button-container">
  237. <button class="accept-button" @click="handleSubmit" :loading="submitLoading">{{ submitLoading ? '提交中...' : '确认结单' }}</button>
  238. </view>
  239. <!-- 加载中状态 -->
  240. <view v-if="loading" class="loading-mask">
  241. <text class="loading-text">加载中...</text>
  242. </view>
  243. </view>
  244. </template>
  245. <script setup lang="uts">
  246. import { ref } from 'vue'
  247. import type { acceptOrderInfo } from '../../../types/order'
  248. import type { WorkOrderFlow } from '../../../types/flow'
  249. import { getOrderInfoById, getRepairOrderInfoById, returnRepairOrder, finishOrder } from '../../../api/order/detail'
  250. import { getMisInfoList, listWorkPerson, getOrderList, listAutoMisInfo } from '../../../api/order/list'
  251. import type { SysDictData } from '../../../types/dict'
  252. import { getDictDataByType } from '../../../api/dict/index'
  253. import type { UserInfo } from '../../../types/user'
  254. import type { UploadResponse } from '../../../types/workbench'
  255. import {checkPermi} from '../../../utils/storage'
  256. import { getUserList, getLeaderList } from '../../../api/user/list'
  257. // import uploadImage from '../../../components/upload-image/upload-image.uvue'
  258. // 工单信息
  259. const orderId = ref<string>('')
  260. const workOrderProjectNo = ref<string>('')
  261. const workOrderStatus = ref<string>('')
  262. const orderType = ref<string>('')
  263. const pcsDeviceName = ref<string>('')
  264. const gxtCenter = ref<string>('')
  265. const pcsStationName = ref<string>('')
  266. const brand = ref<string>('')
  267. const model = ref<string>('')
  268. const acceptTime = ref<string>('')
  269. const returnType = ref<string>('')
  270. const returnReason = ref<string>("")
  271. const returnTypeLabel = ref<string>("")
  272. const acceptReturnType = ref<string>('')
  273. const acceptReturnReason = ref<string>("")
  274. const teamLeaderId = ref<Number | null>(null)
  275. const teamLeaderName = ref<string>('')
  276. const pauseTime = ref<string>('')
  277. const restartTime = ref<string>('')
  278. const misNo = ref<string>('') // MIS工单编码
  279. // 添加字典加载状态
  280. const dictLoaded = ref<boolean>(false)
  281. // 结单表单相关变量
  282. const infoEntry = ref<string>('') // 信息录入
  283. const workPermitNum = ref<string>('') // 工作票编号
  284. const realStartTime = ref<string>('') // 开始时间
  285. const realEndTime = ref<string>('') // 结束时间
  286. const wwryNum = ref<string>('') // 外委人员数
  287. const wlryNum = ref<string>('') // 外来人员数
  288. const workGroupMemberName = ref<string>('') // 工作班成员
  289. const content = ref<string>('') // 维保内容
  290. const attachmentUrls = ref<string>('') // 附件URLs(逗号分隔的字符串格式)
  291. const uploadedFiles = ref<UploadResponse[]>([]) // 上传的文件对象数组
  292. const workOrderPersonList = ref<UTSJSONObject[]>([]) // 工作班成员数组
  293. const selectedUserIds = ref<string[]>([]) // 选中的用户ID数组
  294. const selectedUsers = ref<UTSJSONObject[]>([]) // 选中的用户对象数组
  295. // 时间选择器相关变量
  296. const showStartTimePicker = ref<boolean>(false)
  297. const showEndTimePicker = ref<boolean>(false)
  298. const startTimeDate = ref<string>('')
  299. const startTimeTime = ref<string>('')
  300. const endTimeDate = ref<string>('')
  301. const endTimeTime = ref<string>('')
  302. // 搜索关键词
  303. const userKeyword = ref<string>('')
  304. // 人员选择相关变量
  305. const showUserSelect = ref<boolean>(false)
  306. const userList = ref<UTSJSONObject[]>([])
  307. const userAllList = ref<UTSJSONObject[]>([])
  308. // 信息录入选项
  309. const selectedMisInfoIndex = ref<number>(-1)
  310. // 获取用户列表
  311. const getUserAllList = async (): Promise<void> => {
  312. try {
  313. // 这里应该调用获取用户列表的API
  314. const result = await getLeaderList(-1); // 空参数调用
  315. const resultObj = result as UTSJSONObject;
  316. const code = resultObj['code'] as number
  317. const users = resultObj['data'] as UTSJSONObject[] | null
  318. if (code == 200 && users != null ) {
  319. // 解析列表数据
  320. // const rows = resultObj['rows'] as UTSJSONObject[]
  321. userList.value = users;
  322. userAllList.value = users
  323. // userList.value = result.data || [];
  324. }
  325. } catch (error) {
  326. console.error('获取用户列表失败:', error);
  327. uni.showToast({
  328. title: '获取用户列表失败',
  329. icon: 'none'
  330. });
  331. }
  332. };
  333. // 验证和提交
  334. const submitLoading = ref<boolean>(false)
  335. // 接受用户名
  336. const acceptUserName = ref<string>('')
  337. // 选择器选项类型
  338. type PickerOption = {
  339. label: string
  340. value: string
  341. }
  342. // 搜索
  343. const handleSearch = (): void => {
  344. const keyword = userKeyword.value
  345. userList.value = userAllList.value.filter(leader => {
  346. const nickName = leader['nickName'] as string | null
  347. return nickName != null && nickName.indexOf(keyword) >= 0
  348. })
  349. }
  350. // 清除用户搜索
  351. const clearSearch = (): void => {
  352. userKeyword.value = "";
  353. userList.value = userAllList.value
  354. };
  355. function onStartDateConfirm(value: string) {
  356. // 检查结束时间是否小于新的开始时间
  357. if (realEndTime.value != '' && new Date(value) > new Date(realEndTime.value as string)) {
  358. uni.showToast({ title: '开始时间不能大于结束时间', icon: 'none' })
  359. return
  360. }
  361. realStartTime.value = value
  362. showStartTimePicker.value = false
  363. }
  364. function onEndDateConfirm(value: string) {
  365. // 检查新的结束时间是否小于开始时间
  366. if (realStartTime.value != '' && new Date(realStartTime.value as string) > new Date(value)) {
  367. uni.showToast({ title: '结束时间不能小于开始时间', icon: 'none' })
  368. return
  369. }
  370. realEndTime.value = value
  371. showEndTimePicker.value = false
  372. }
  373. // 检查用户是否已被选中
  374. const isSelected = (user: UTSJSONObject): boolean => {
  375. const userId = user['userId'] as string | number | null;
  376. if (userId !== null) {
  377. return selectedUserIds.value.includes(userId.toString());
  378. }
  379. // 如果没有userId,则比较nickName
  380. const nickName = user['nickName'] as string | null;
  381. if (nickName !== null) {
  382. return selectedUsers.value.some(selected =>
  383. (selected['nickName'] as string | null) === nickName
  384. );
  385. }
  386. return false;
  387. };
  388. // 切换用户选择状态
  389. const toggleUserSelection = (user: UTSJSONObject): void => {
  390. const userId = user['userId'] as string | number | null;
  391. const nickName = user['nickName'] as string | null;
  392. if (userId !== null) {
  393. const userIdStr = userId.toString();
  394. const index = selectedUserIds.value.indexOf(userIdStr);
  395. if (index > -1) {
  396. // 取消选择
  397. selectedUserIds.value.splice(index, 1);
  398. selectedUsers.value = selectedUsers.value.filter(selected =>
  399. (selected['userId'] as string | number | null)?.toString() !== userIdStr
  400. );
  401. } else {
  402. // 添加选择
  403. selectedUserIds.value.push(userIdStr);
  404. selectedUsers.value.push(user);
  405. }
  406. } else if (nickName !== null) {
  407. // 如果没有userId,通过nickName来识别
  408. const index = selectedUsers.value.findIndex(selected =>
  409. (selected['nickName'] as string | null) === nickName
  410. );
  411. if (index > -1) {
  412. // 取消选择
  413. selectedUsers.value.splice(index, 1);
  414. // 同时移除对应的userId(如果有的话)
  415. const userToRemoveId = user['userId'] as string | number | null;
  416. if (userToRemoveId !== null) {
  417. const idIndex = selectedUserIds.value.indexOf(userToRemoveId.toString());
  418. if (idIndex > -1) {
  419. selectedUserIds.value.splice(idIndex, 1);
  420. }
  421. }
  422. } else {
  423. // 添加选择
  424. selectedUsers.value.push(user);
  425. const userToAddId = user['userId'] as string | number | null;
  426. if (userToAddId !== null) {
  427. selectedUserIds.value.push(userToAddId.toString());
  428. }
  429. }
  430. }
  431. };
  432. // 确认选择的用户
  433. const confirmSelectedUsers = (): void => {
  434. // 将选中的用户姓名拼接成字符串
  435. const nickNames = selectedUsers.value
  436. .map(user => (user['nickName'] as string | null) ?? '')
  437. .filter(name => name !== '')
  438. .join(',');
  439. workGroupMemberName.value = nickNames;
  440. // 更新workOrderPersonList为选中的用户
  441. workOrderPersonList.value = [...selectedUsers.value];
  442. showUserSelect.value = false;
  443. };
  444. // 清空已选择的用户
  445. const clearSelectedUsers = (): void => {
  446. // 清空选中的用户数组
  447. selectedUsers.value = [];
  448. selectedUserIds.value = [];
  449. // 清空显示的用户名
  450. workGroupMemberName.value = '';
  451. // 清空工作班成员列表
  452. workOrderPersonList.value = [];
  453. };
  454. // 表单验证
  455. const validateForm = (): boolean => {
  456. if (infoEntry.value == '') {
  457. uni.showToast({
  458. title: '请选择信息录入方式',
  459. icon: 'none'
  460. });
  461. return false;
  462. }
  463. if (realStartTime.value == '') {
  464. uni.showToast({
  465. title: '请选择开始时间',
  466. icon: 'none'
  467. });
  468. return false;
  469. }
  470. if (realEndTime.value == '') {
  471. uni.showToast({
  472. title: '请选择结束时间',
  473. icon: 'none'
  474. });
  475. return false;
  476. }
  477. if (new Date(realEndTime.value) <= new Date(realStartTime.value)) {
  478. uni.showToast({
  479. title: '结束时间必须大于开始时间',
  480. icon: 'none'
  481. });
  482. return false;
  483. }
  484. // if (infoEntry.value == '2' && (workGroupMemberName.value == '' || selectedUsers.value.length == 0)) {
  485. // uni.showToast({
  486. // title: '请选择工作班成员',
  487. // icon: 'none'
  488. // });
  489. // return false;
  490. // }
  491. return true;
  492. };
  493. const isDealing = ref(false)
  494. const hasDealed = ref(false)
  495. // 提交表单
  496. const handleSubmit = async (): Promise<void> => {
  497. if (!validateForm()) {
  498. return;
  499. }
  500. submitLoading.value = true;
  501. try {
  502. if (isDealing.value || hasDealed.value) return // 双重保险
  503. isDealing.value = true
  504. // 确保附件URLs是最新的逗号分隔格式
  505. attachmentUrls.value = uploadedFiles.value.map(file => file.fileName).join(',');
  506. const finishData = {
  507. id: orderId.value,
  508. orderType: orderType.value,
  509. workOrderProjectNo: workOrderProjectNo.value,
  510. infoEntry: infoEntry.value,
  511. misNo: misNo.value,
  512. workPermitNum: workPermitNum.value,
  513. realStartTime: realStartTime.value,
  514. realEndTime: realEndTime.value,
  515. wwryNum: wwryNum.value,
  516. wlryNum: wlryNum.value,
  517. workGroupMemberName: workGroupMemberName.value,
  518. content: content.value,
  519. attachmentUrls: attachmentUrls.value,
  520. workOrderPersonList: workOrderPersonList.value,
  521. teamLeaderId: teamLeaderId.value,
  522. teamLeaderName: teamLeaderName.value,
  523. finalizeMethod: '2',
  524. workOrderStatus: 'completed'
  525. } as UTSJSONObject;
  526. const result = await finishOrder(finishData);
  527. const resultObj = result as UTSJSONObject;
  528. const code = resultObj['code'] as number;
  529. if (code == 200) {
  530. uni.showToast({
  531. title: '结单成功',
  532. icon: 'success'
  533. });
  534. hasDealed.value = true
  535. // 使用事件总线通知列表页面刷新
  536. uni.$emit('refreshOrderList', {});
  537. uni.$emit('refreshAssignedCount');
  538. uni.$emit('refreshOverdueCount');
  539. setTimeout(() => {
  540. uni.navigateBack();
  541. }, 800);
  542. } else {
  543. const msg = resultObj['msg'] as string;
  544. uni.showToast({
  545. title: msg.length > 0 ? msg : '结单失败',
  546. icon: 'none'
  547. });
  548. }
  549. } catch (error: any) {
  550. console.error('结单失败:', error);
  551. uni.showToast({
  552. title: '结单失败',
  553. icon: 'none'
  554. });
  555. } finally {
  556. submitLoading.value = false;
  557. isDealing.value = false // 无论成功失败都解锁
  558. }
  559. };
  560. const loading = ref<boolean>(false)
  561. // 加载详情数据
  562. const loadDetail = async (id: string, orderType?: string): Promise<void> => {
  563. try {
  564. loading.value = true
  565. let result: any;
  566. // 根据orderType决定调用哪个API
  567. if (orderType == '1') {
  568. // 维修工单
  569. result = await getRepairOrderInfoById(id)
  570. } else {
  571. // 维保工单
  572. result = await getOrderInfoById(id)
  573. }
  574. // 提取响应数据
  575. const resultObj = result as UTSJSONObject
  576. const code = resultObj['code'] as number
  577. const data = resultObj['data'] as UTSJSONObject | null
  578. if (code == 200 && data != null) {
  579. workOrderStatus.value = (data['workOrderStatus'] as string | null) ?? ''
  580. workOrderProjectNo.value = (data['workOrderProjectNo'] as string | null) ?? ''
  581. pcsDeviceName.value = (data['pcsDeviceName'] as string | null) ?? ''
  582. gxtCenter.value = (data['gxtCenter'] as string | null) ?? ''
  583. pcsStationName.value = (data['pcsStationName'] as string | null) ?? ''
  584. brand.value = (data['brand'] as string | null) ?? ''
  585. model.value = (data['model'] as string | null) ?? ''
  586. acceptTime.value = (data['acceptTime'] as string | null) ?? ''
  587. acceptUserName.value = (data['acceptUserName'] as string | null) ?? ''
  588. // 初始化结单表单默认值
  589. infoEntry.value = '1' // 默认为手工录入
  590. teamLeaderId.value = (data['teamLeaderId'] as Number | null) ?? null
  591. teamLeaderName.value = (data['teamLeaderName'] as string | null) ?? ''
  592. returnType.value = workOrderStatus.value == 'to_finish' ? '1' : ''
  593. content.value = (data['content'] as string | null) ?? ''
  594. misNo.value = (data['misNo'] as string | null) ?? ''
  595. workPermitNum.value = (data['workPermitNum'] as string | null) ?? ''
  596. const queryParams = {
  597. misNo: misNo.value,
  598. } as UTSJSONObject;
  599. const result = await getMisInfoList(queryParams)
  600. // 提取响应数据
  601. const resultObj = result as UTSJSONObject
  602. const code = resultObj['code'] as number
  603. const misInfo = resultObj['rows'] as UTSJSONObject[] | null
  604. if (code == 200 && misInfo != null) {
  605. if(misInfo.length > 0) {
  606. realStartTime.value = (misInfo[0]['realStartTime'] as string | null) ?? ''
  607. realEndTime.value = (misInfo[0]['realEndTime'] as string | null) ?? ''
  608. // 查询相关工作班成员
  609. await listWorkPerson(misNo.value).then(response => {
  610. const responseObj = response as UTSJSONObject
  611. const rows = responseObj['rows'] as UTSJSONObject[] | null
  612. workOrderPersonList.value = rows ?? []
  613. if (rows != null && rows.length > 0) {
  614. // 查询负责人信息并回填
  615. for (const person of workOrderPersonList.value) {
  616. // 严格判断isLeader为1(兼容数字/字符串类型)
  617. if (person.isLeader == 1) {
  618. teamLeaderName.value = (person.nickName as string | null) ?? '';
  619. break; // 找到后立即停止循环
  620. }
  621. }
  622. const nickNames = rows
  623. .map((person: UTSJSONObject) => (person['nickName'] as string | null) ?? '')
  624. .join(',');
  625. workGroupMemberName.value = nickNames;
  626. }
  627. })
  628. }
  629. }
  630. } else {
  631. const msg = resultObj['msg'] as string | null
  632. uni.showToast({
  633. title: msg ?? '加载失败',
  634. icon: 'none'
  635. })
  636. }
  637. } catch (e) {
  638. uni.showToast({
  639. title: (e as Error).message ?? '加载失败',
  640. icon: 'none'
  641. })
  642. } finally {
  643. loading.value = false
  644. }
  645. }
  646. // 页面加载
  647. onLoad((options: any) => {
  648. const params = options as UTSJSONObject
  649. const id = params['id'] as string | null
  650. const orderTypeParam = params['orderType'] as string | null
  651. if (id != null && orderTypeParam != null) {
  652. // 先尝试从参数中获取orderType
  653. // const orderTypeNumber = parseInt(orderTypeParam)
  654. orderType.value = orderTypeParam
  655. orderId.value = id
  656. loadDetail(id, orderTypeParam)
  657. }
  658. })
  659. // 初始化
  660. onMounted(() => {
  661. getUserAllList();
  662. })
  663. </script>
  664. <style lang="scss">
  665. .detail-page {
  666. flex: 1;
  667. background-color: #e8f0f9;
  668. }
  669. .detail-content {
  670. flex: 1;
  671. padding: 20rpx 0;
  672. }
  673. .info-section {
  674. margin: 0 30rpx 24rpx;
  675. .section-title {
  676. position: relative;
  677. padding-left: 20rpx;
  678. margin-bottom: 20rpx;
  679. &::before {
  680. // content: '';
  681. position: absolute;
  682. left: 0;
  683. top: 50%;
  684. transform: translateY(-50%);
  685. width: 8rpx;
  686. height: 32rpx;
  687. background-color: #007aff;
  688. border-radius: 4rpx;
  689. }
  690. &-text {
  691. font-size: 32rpx;
  692. font-weight: bold;
  693. color: #333333;
  694. }
  695. }
  696. .info-card {
  697. background-color: #ffffff;
  698. border-radius: 16rpx;
  699. padding: 30rpx;
  700. .info-item {
  701. flex-direction: row;
  702. padding: 20rpx 0;
  703. border-bottom: 1rpx solid #f0f0f0;
  704. &:last-child {
  705. border-bottom: none;
  706. }
  707. &.full-width {
  708. flex-direction: column;
  709. .info-label {
  710. margin-bottom: 12rpx;
  711. }
  712. .info-value {
  713. line-height: 44rpx;
  714. }
  715. }
  716. .info-label {
  717. width: 240rpx;
  718. font-size: 28rpx;
  719. color: #666666;
  720. white-space: nowrap;
  721. }
  722. .info-value {
  723. flex: 1;
  724. font-size: 28rpx;
  725. color: #333333;
  726. text-align: left;
  727. &.highlight {
  728. color: #007aff;
  729. font-weight: bold;
  730. }
  731. &.input {
  732. text-align: left;
  733. border: 1rpx solid #e0e0e0;
  734. border-radius: 8rpx;
  735. padding: 10rpx;
  736. }
  737. .input-with-clear {
  738. position: relative;
  739. display: flex;
  740. align-items: center;
  741. }
  742. .select-clear {
  743. position: absolute;
  744. right: 20rpx;
  745. color: #ccc;
  746. text-align: center;
  747. font-size: 40rpx;
  748. font-weight: bold;
  749. z-index: 1;
  750. }
  751. }
  752. }
  753. .flow-item {
  754. padding: 20rpx 0;
  755. border-bottom: 1rpx solid #f0f0f0;
  756. &:last-child {
  757. border-bottom: none;
  758. }
  759. .flow-header {
  760. flex-direction: row;
  761. justify-content: space-between;
  762. margin-bottom: 10rpx;
  763. .flow-operator {
  764. font-size: 28rpx;
  765. color: #333333;
  766. font-weight: bold;
  767. }
  768. .flow-time {
  769. font-size: 24rpx;
  770. color: #999999;
  771. }
  772. }
  773. .flow-content {
  774. flex-direction: column;
  775. .flow-action {
  776. font-size: 26rpx;
  777. color: #666666;
  778. margin-bottom: 8rpx;
  779. }
  780. .flow-remark {
  781. font-size: 24rpx;
  782. color: #999999;
  783. background-color: #f5f5f5;
  784. padding: 10rpx;
  785. border-radius: 8rpx;
  786. }
  787. }
  788. }
  789. .no-data {
  790. text-align: center;
  791. padding: 40rpx 0;
  792. font-size: 28rpx;
  793. color: #999999;
  794. }
  795. }
  796. }
  797. .accept-button-container {
  798. padding: 30rpx 30rpx 50rpx;
  799. background-color: #ffffff;
  800. .accept-button {
  801. width: 100%;
  802. height: 80rpx;
  803. background-color: #007aff;
  804. color: #ffffff;
  805. font-size: 32rpx;
  806. border-radius: 16rpx;
  807. border: none;
  808. &:active {
  809. background-color: #0062cc;
  810. }
  811. }
  812. }
  813. .loading-mask {
  814. position: absolute;
  815. top: 0;
  816. left: 0;
  817. right: 0;
  818. bottom: 0;
  819. justify-content: center;
  820. align-items: center;
  821. background-color: rgba(0, 0, 0, 0.3);
  822. .loading-text {
  823. padding: 30rpx 60rpx;
  824. background-color: rgba(0, 0, 0, 0.7);
  825. color: #ffffff;
  826. font-size: 28rpx;
  827. border-radius: 12rpx;
  828. }
  829. }
  830. .picker-modal {
  831. position: fixed;
  832. top: 0;
  833. left: 0;
  834. right: 0;
  835. bottom: 0;
  836. z-index: 1000;
  837. }
  838. .modal-mask {
  839. position: absolute;
  840. top: 0;
  841. left: 0;
  842. right: 0;
  843. bottom: 0;
  844. background-color: rgba(0, 0, 0, 0.5);
  845. }
  846. .modal-content {
  847. position: absolute;
  848. bottom: 0;
  849. left: 0;
  850. right: 0;
  851. background-color: #ffffff;
  852. border-top-left-radius: 16rpx;
  853. border-top-right-radius: 16rpx;
  854. min-height: 700rpx;
  855. }
  856. .modal-header {
  857. flex-direction: row;
  858. justify-content: space-between;
  859. align-items: center;
  860. padding: 30rpx;
  861. border-bottom: 1rpx solid #f0f0f0;
  862. }
  863. .modal-title {
  864. font-size: 32rpx;
  865. font-weight: bold;
  866. color: #333333;
  867. }
  868. .modal-close {
  869. font-size: 28rpx;
  870. color: #007aff;
  871. }
  872. .modal-body {
  873. max-height: 800rpx;
  874. min-height: 800rpx;
  875. }
  876. .picker-option {
  877. flex-direction: row;
  878. justify-content: space-between;
  879. align-items: center;
  880. padding: 24rpx 30rpx;
  881. border-bottom: 1rpx solid #f0f0f0;
  882. }
  883. .picker-option.selected {
  884. background-color: #f8f9fa;
  885. }
  886. .picker-option:last-child {
  887. border-bottom: none;
  888. }
  889. .option-text {
  890. font-size: 28rpx;
  891. color: #333333;
  892. margin-bottom: 10rpx;
  893. }
  894. .option-text:last-child {
  895. margin-bottom: 0;
  896. }
  897. .option-check {
  898. font-size: 28rpx;
  899. color: #007aff;
  900. }
  901. .empty-tip {
  902. justify-content: space-between;
  903. padding: 24rpx 30rpx;
  904. display: flex;
  905. align-items: center;
  906. justify-content: center;
  907. color: #999;
  908. }
  909. .picker-option {
  910. flex-direction: row;
  911. justify-content: space-between;
  912. align-items: center;
  913. padding: 24rpx 30rpx;
  914. border-bottom: 1rpx solid #f0f0f0;
  915. }
  916. .picker-option:last-child {
  917. border-bottom: none;
  918. }
  919. .picker-option.selected {
  920. background-color: #f8f9fa;
  921. }
  922. .option-text {
  923. font-size: 28rpx;
  924. color: #333333;
  925. }
  926. .mis-list {
  927. flex: 1;
  928. height: 100%;
  929. display: flex;
  930. flex-direction: column;
  931. }
  932. .empty-tip {
  933. text-align: center;
  934. padding: 40rpx;
  935. color: #999;
  936. font-size: 28rpx;
  937. }
  938. .form-item {
  939. flex-direction: row;
  940. padding: 20rpx 0;
  941. border-bottom: 1rpx solid #f0f0f0;
  942. }
  943. .reject-reason-textarea {
  944. width: 100%;
  945. min-height: 100rpx;
  946. line-height: 1.5;
  947. }
  948. .input-field {
  949. width: 100%;
  950. height: 60rpx;
  951. padding: 0 20rpx;
  952. border: 1rpx solid #e0e0e0;
  953. border-radius: 8rpx;
  954. font-size: 28rpx;
  955. background-color: #f8f9fa;
  956. }
  957. .select-mis-btn {
  958. width: 150rpx;
  959. height: 60rpx;
  960. margin-left: 10rpx;
  961. background-color: #007aff;
  962. color: #fff;
  963. border: none;
  964. border-radius: 8rpx;
  965. font-size: 24rpx;
  966. }
  967. .textarea-field {
  968. width: 100%;
  969. min-height: 120rpx;
  970. padding: 20rpx;
  971. border: 1rpx solid #e0e0e0;
  972. border-radius: 8rpx;
  973. font-size: 28rpx;
  974. background-color: #f8f9fa;
  975. }
  976. .radio-label {
  977. display: flex;
  978. align-items: center;
  979. margin-right: 30rpx;
  980. }
  981. .quick-select-dropdown {
  982. position: absolute;
  983. top: 100%;
  984. left: 0;
  985. right: 0;
  986. background: #fff;
  987. border: 1rpx solid #ddd;
  988. border-top: none;
  989. z-index: 1000;
  990. max-height: 300rpx;
  991. }
  992. .quick-select-item {
  993. padding: 20rpx;
  994. border-bottom: 1rpx solid #eee;
  995. }
  996. .mis-no {
  997. font-size: 28rpx;
  998. color: #333;
  999. }
  1000. .search-bar {
  1001. padding: 20rpx 30rpx;
  1002. background-color: #d7eafe;
  1003. }
  1004. .search-box {
  1005. flex-direction: row;
  1006. align-items: center;
  1007. height: 72rpx;
  1008. padding: 0 24rpx;
  1009. background-color: #f5f5f5;
  1010. border-radius: 36rpx;
  1011. .search-icon {
  1012. width: 32rpx;
  1013. height: 32rpx;
  1014. margin-right: 12rpx;
  1015. }
  1016. .search-input {
  1017. flex: 1;
  1018. font-size: 28rpx;
  1019. color: #333333;
  1020. }
  1021. .clear-icon {
  1022. margin-left: 12rpx;
  1023. font-size: 28rpx;
  1024. color: #999999;
  1025. }
  1026. }
  1027. .mis-list {
  1028. flex: 1;
  1029. height: 100%;
  1030. display: flex;
  1031. flex-direction: column;
  1032. }
  1033. .select-users-count {
  1034. margin-left: 10rpx;
  1035. font-size: 24rpx;
  1036. color: #666;
  1037. }
  1038. </style>