TaskOnlineEquipmentList.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275
  1. <route lang="json5" type="page">
  2. {
  3. layout: 'default',
  4. style: {
  5. navigationBarTitleText: '设备列表(分配项目)',
  6. navigationStyle: 'custom',
  7. disableScroll: true,
  8. 'app-plus': {
  9. bounce: 'none',
  10. },
  11. },
  12. }
  13. </route>
  14. <template>
  15. <view class="equipment-list-container">
  16. <NavBar title="设备列表(分配项目)" />
  17. <scroll-view
  18. class="list-scroll"
  19. scroll-y
  20. refresher-enabled
  21. :refresher-triggered="refreshing"
  22. @refresherrefresh="onRefresh"
  23. >
  24. <view v-for="item in equipmentList" :key="item.id" class="equipment-cell">
  25. <view class="cell-top" @click="handleSelectEquipment(item)">
  26. <view class="row">
  27. <view v-if="orderId" class="checkbox-wrapper">
  28. <view class="checkbox" :class="{ checked: selectedMap[item.id] }">
  29. <image
  30. v-if="selectedMap[item.id]"
  31. class="check-icon"
  32. src="/static/images/white-check.png"
  33. mode="aspectFit"
  34. />
  35. </view>
  36. </view>
  37. <view class="cell-top-left">
  38. <text class="equip-name">{{ item.equipName }}({{ item.productNo }})</text>
  39. <text class="main-checker">主检人:{{ item?.mainCheckerUser?.nickname || '' }}</text>
  40. <view
  41. class="status-tag"
  42. :class="
  43. item?.taskStatus !== PressureCheckerMyTaskStatus.CONFIRMED
  44. ? 'status-pending'
  45. : 'status-done'
  46. "
  47. >
  48. <text class="status-text">
  49. {{ PressureCheckerMyTaskStatusMap[item?.taskStatus] }}
  50. </text>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="cell-center" @click="handleRouteToEquipmentDetail(item, 'EQUIPMENT')">
  56. <view class="info-box">
  57. <text class="info-label">
  58. 设备注册代码:
  59. <text class="info-value">{{ item.equipCode }}</text>
  60. </text>
  61. <text class="info-label">
  62. 费用:
  63. <text class="info-value">{{ handleCalcTotalFee(item?.reportDOList) }}</text>
  64. </text>
  65. </view>
  66. </view>
  67. <view class="cell-bottom">
  68. <view
  69. v-if="!item.isClaim && item.taskStatus === PressureCheckerMyTaskStatus.RECORD_INPUT"
  70. class="claim-btn"
  71. :class="item.isClaim ? 'white-btn' : 'blue-btn'"
  72. @click="fetchClaimEquipments(item.id + '', item.isClaim)"
  73. >
  74. <text :class="item.isClaim ? 'white-btn-text' : 'blue-btn-text'">
  75. {{ item.isClaim ? '取消认领' : '认领' }}
  76. </text>
  77. </view>
  78. <view
  79. v-if="item.isClaim"
  80. class="record-btn blue-btn"
  81. @click="handleRouteToEquipmentDetail(item, 'INSPECT')"
  82. >
  83. <text class="blue-btn-text">记录录入</text>
  84. </view>
  85. </view>
  86. </view>
  87. <view v-if="loading && equipmentList.length === 0" class="loading-text">加载中...</view>
  88. <view v-if="!loading && equipmentList.length === 0" class="empty-text">
  89. <text>暂无数据</text>
  90. </view>
  91. </scroll-view>
  92. <view v-if="orderId" class="bottom-operate">
  93. <view class="select-all" @click="handleSelectAll">
  94. <view class="checkbox" :class="{ checked: selectAll }">
  95. <image
  96. v-if="selectAll"
  97. class="check-icon"
  98. src="/static/images/white-check.png"
  99. mode="aspectFit"
  100. />
  101. </view>
  102. <text class="select-all-text">全选</text>
  103. </view>
  104. <view class="btn-group">
  105. <button class="operate-btn blue-btn" @click="showMoreOperate = true">更多操作</button>
  106. <!-- <button
  107. class="operate-btn white-btn"
  108. @click="showBatchClaimPopup({ text: '是否取消认领已选择的设备?', isClaim: true })"
  109. >
  110. 取消认领
  111. </button> -->
  112. <button
  113. class="operate-btn white-btn"
  114. @click="showBatchClaimPopup({ text: '是否认领已选择的设备?', isClaim: false })"
  115. >
  116. 批量认领
  117. </button>
  118. <button class="operate-btn blue-btn" @click="showCheckProjectPopup">添加项目</button>
  119. </view>
  120. </view>
  121. <view v-if="showTipsPopup" class="popup-mask" @click="closeTipsPopup">
  122. <view class="popup-content tips-popup" @click.stop>
  123. <text class="tips-text">{{ tipsPopupData.text }}</text>
  124. <view class="popup-actions">
  125. <button class="action-btn cancel-btn" @click="closeTipsPopup">取消</button>
  126. <button class="action-btn confirm-btn" @click="handleBatchClaim">确定</button>
  127. </view>
  128. </view>
  129. </view>
  130. <view v-if="showMoreOperate" class="more-operate-overlay" @click="showMoreOperate = false">
  131. <view class="more-operate-panel" :class="{ 'more-panel-show': showMoreOperate }">
  132. <view
  133. class="more-btn-item"
  134. :class="{ disabled: !canInform }"
  135. @click="canInform && showAddSpacePopup()"
  136. >
  137. <view class="more-btn-inner">
  138. <text class="more-btn-text" :style="{ color: canInform ? 'rgb(51,51,51)' : '#ccc' }">
  139. 添加有限空间记录
  140. </text>
  141. </view>
  142. </view>
  143. <view
  144. class="more-btn-item"
  145. :class="{ disabled: !canInform }"
  146. @click="canInform && createInform()"
  147. >
  148. <view class="more-btn-inner more-btn-border">
  149. <text class="more-btn-text" :style="{ color: canInform ? 'rgb(51,51,51)' : '#ccc' }">
  150. 重大问题线索告知
  151. </text>
  152. </view>
  153. </view>
  154. <view
  155. class="more-btn-item"
  156. :class="{ disabled: !canSuspend }"
  157. @click="canSuspend && showSuspendPopupFunc()"
  158. >
  159. <view class="more-btn-inner more-btn-border">
  160. <text class="more-btn-text" :style="{ color: canSuspend ? 'rgb(51,51,51)' : '#ccc' }">
  161. 客户拒检
  162. </text>
  163. </view>
  164. </view>
  165. <view
  166. class="more-btn-item"
  167. :class="{ disabled: !canAddInspectionplan }"
  168. @click="canAddInspectionplan && showAddInspectionplanPopup()"
  169. >
  170. <view class="more-btn-inner more-btn-border">
  171. <text
  172. class="more-btn-text"
  173. :style="{ color: canAddInspectionplan ? 'rgb(51,51,51)' : '#ccc' }"
  174. >
  175. 检验方案
  176. </text>
  177. </view>
  178. </view>
  179. <view
  180. class="more-btn-item"
  181. :class="{ disabled: !canAddInspectionplan }"
  182. @click="canAddInspectionplan && handleUpdateContact()"
  183. >
  184. <view class="more-btn-inner more-btn-border">
  185. <text
  186. class="more-btn-text"
  187. :style="{ color: canAddInspectionplan ? 'rgb(51,51,51)' : '#ccc' }"
  188. >
  189. 修改安全管理员
  190. </text>
  191. </view>
  192. </view>
  193. </view>
  194. </view>
  195. <view v-if="showSuspendPopup" class="popup-mask" @click="closeSuspendPopup">
  196. <view class="popup-content suspend-popup" @click.stop>
  197. <text class="popup-title">客户拒检</text>
  198. <textarea
  199. v-model="suspendReason"
  200. class="suspend-textarea"
  201. placeholder="请输入中止检验原因"
  202. />
  203. <view class="popup-actions">
  204. <button class="action-btn cancel-btn" @click="closeSuspendPopup">取消</button>
  205. <button class="action-btn confirm-btn" @click="suspendCheck">确定</button>
  206. </view>
  207. </view>
  208. </view>
  209. <view v-if="showInspectionplanPopup" class="popup-mask" @click="closeInspectionplanPopup">
  210. <view class="popup-content inspectionplan-popup" @click.stop>
  211. <text class="popup-title">添加检验方案</text>
  212. <view class="form-item">
  213. <text class="form-label">模板封面</text>
  214. <wd-picker
  215. v-model="selectedTemplateId"
  216. :columns="templateListColumn"
  217. @change="onTemplateChange"
  218. />
  219. </view>
  220. <view class="form-item">
  221. <text class="form-label">检验方案名称</text>
  222. <input v-model="inspectionplanName" class="form-input" placeholder="请输入检验方案名称" />
  223. </view>
  224. <view class="popup-actions">
  225. <button class="action-btn cancel-btn" @click="closeInspectionplanPopup">取消</button>
  226. <button class="action-btn confirm-btn" @click="addInspectionplanConfirm">确定</button>
  227. </view>
  228. </view>
  229. </view>
  230. <view v-if="showUpdateContactPopup" class="popup-mask" @click="showUpdateContactPopup = false">
  231. <view class="popup-content" @click.stop>
  232. <UpdateContactPopup
  233. :ids="selectedEquipIds"
  234. :safe-manager="currentItem?.safeManager || ''"
  235. :safe-manager-phone="currentItem?.safeManagerPhone || ''"
  236. :safe-manager-id-number="currentItem?.safeManagerIdNumber || ''"
  237. :operator-id-number="currentItem?.operatorIdNumber || ''"
  238. @hide="showUpdateContactPopup = false"
  239. @refresh="refreshList"
  240. />
  241. </view>
  242. </view>
  243. <view v-if="showSpaceTemplatePopup" class="popup-mask" @click="showSpaceTemplatePopup = false">
  244. <view class="popup-content" @click.stop>
  245. <text class="popup-title">选择模板</text>
  246. <scroll-view scroll-y class="template-scroll">
  247. <view
  248. v-for="tpl in spaceTemplateList"
  249. :key="tpl.id"
  250. class="template-item"
  251. :class="{ active: selectedSpaceTemplateId === tpl.id }"
  252. @click="selectedSpaceTemplateId = tpl.id"
  253. >
  254. <text>{{ tpl.name }}</text>
  255. </view>
  256. </scroll-view>
  257. <view class="popup-actions">
  258. <button class="action-btn cancel-btn" @click="showSpaceTemplatePopup = false">
  259. 取消
  260. </button>
  261. <button class="action-btn confirm-btn" @click="confirmSpaceTemplate">确定</button>
  262. </view>
  263. </view>
  264. </view>
  265. </view>
  266. </template>
  267. <script lang="ts" setup>
  268. import { ref, computed } from 'vue'
  269. import { onLoad, onShow } from '@dcloudio/uni-app'
  270. import {
  271. getTaskEquipmentList,
  272. cancelClaim,
  273. confirmTaskClaim,
  274. batchClaim,
  275. orderItemMajorCheck,
  276. getEquipmentsTemplateJSONData,
  277. taskOrderItemSuspendApi,
  278. notVerifyPageApi,
  279. addMajorIssuesApi,
  280. } from '@/api/task'
  281. import { useUserStore } from '@/store/user'
  282. import { useConfigStore } from '@/store/config'
  283. import {
  284. PressureCheckerMyTaskStatus,
  285. PressureCheckerMyTaskStatusMap,
  286. EquipmentType,
  287. } from '@/utils/dictMap'
  288. // import { createBusinessConfig } from '@/pages/webview/common/config/businessEditorConfig'
  289. import { setSpreadsheetEditParams } from '@/common/global'
  290. import { formatDate } from '@/utils/index'
  291. import dayjs from 'dayjs'
  292. import UpdateContactPopup from '@/pages/unClaim/components/UpdateContactPopup.vue'
  293. import * as signApis from '@/api/sign'
  294. import { TaskOrderFuncName, requestFunc } from '@/api/ApiRouter/taskOrder'
  295. import NavBar from '@/components/NavBar/NavBar.vue'
  296. interface PopupData {
  297. text: string
  298. isClaim: boolean
  299. }
  300. defineOptions({ name: 'TaskOnlineEquipmentList' })
  301. const userStore = useUserStore()
  302. const userInfo = computed(() => userStore.userInfo)
  303. const equipType = useConfigStore().getEquipType()
  304. const orderId = ref('')
  305. const orderNo = ref('')
  306. const equipmentList = ref<any[]>([])
  307. const loading = ref(false)
  308. const refreshing = ref(false)
  309. const selectAll = ref(false)
  310. const selectedEquipments = ref<any[]>([])
  311. const selectedMap = ref<Record<string, boolean>>({})
  312. const canInform = ref(false)
  313. const canSuspend = ref(false)
  314. const canAddInspectionplan = ref(false)
  315. const showTipsPopup = ref(false)
  316. const tipsPopupData = ref<PopupData>({ text: '', isClaim: false })
  317. const showMoreOperate = ref(false)
  318. const showSuspendPopup = ref(false)
  319. const suspendReason = ref('')
  320. const showInspectionplanPopup = ref(false)
  321. const inspectionplanName = ref('')
  322. const selectedTemplate = ref<any>(null)
  323. const selectedTemplateId = ref('')
  324. const templateList = ref<any[]>([])
  325. const templateListColumn = computed(() => [
  326. templateList.value.map((item) => ({ label: item.name, value: item.id })),
  327. ])
  328. const showUpdateContactPopup = ref(false)
  329. const currentItem = ref<any>({})
  330. const showSpaceTemplatePopup = ref(false)
  331. const spaceTemplateList = ref<any[]>([])
  332. const selectedSpaceTemplateId = ref('')
  333. onLoad((options: any) => {
  334. orderId.value = options?.orderId || ''
  335. orderNo.value = options?.orderNo || ''
  336. })
  337. onShow(() => {
  338. fetchCheckerOnlineEquipmentList()
  339. })
  340. const selectedEquipIds = computed(() => selectedEquipments.value.map((item) => item.equipId))
  341. const fetchCheckerOnlineEquipmentList = async () => {
  342. loading.value = true
  343. const apiParams: any = {
  344. orderId: orderId.value,
  345. pageSize: 999,
  346. pageNo: 1,
  347. taskStatusList: [400, 500, 510],
  348. }
  349. try {
  350. const equipmentListData = await requestFunc(
  351. TaskOrderFuncName.TaskEquipList,
  352. equipType,
  353. apiParams,
  354. )
  355. equipmentList.value = equipmentListData?.data?.list || []
  356. } catch (error) {
  357. console.error('获取设备列表失败:', error)
  358. } finally {
  359. loading.value = false
  360. }
  361. }
  362. const onRefresh = async () => {
  363. refreshing.value = true
  364. await fetchCheckerOnlineEquipmentList()
  365. refreshing.value = false
  366. }
  367. const refreshList = () => {
  368. fetchCheckerOnlineEquipmentList()
  369. }
  370. const handleSelectEquipment = (item: any) => {
  371. if (!orderId.value) return
  372. const isSelected = !selectedMap.value[item.id]
  373. selectedMap.value[item.id] = isSelected
  374. if (isSelected) {
  375. selectedEquipments.value.push(item)
  376. } else {
  377. selectedEquipments.value = selectedEquipments.value.filter((ele) => ele.id !== item.id)
  378. }
  379. updateOperateStatus()
  380. selectAll.value = selectedEquipments.value.length === equipmentList.value.length
  381. }
  382. const handleSelectAll = () => {
  383. const newSelectAll = !selectAll.value
  384. selectAll.value = newSelectAll
  385. selectedEquipments.value = []
  386. const newMap: Record<string, boolean> = {}
  387. for (const item of equipmentList.value) {
  388. newMap[item.id] = newSelectAll
  389. if (newSelectAll) {
  390. selectedEquipments.value.push(item)
  391. }
  392. }
  393. selectedMap.value = newMap
  394. updateOperateStatus()
  395. }
  396. const updateOperateStatus = () => {
  397. canInform.value = selectedEquipments.value.length === 1
  398. canAddInspectionplan.value = selectedEquipments.value.length > 0
  399. const hasUnClaim =
  400. selectedEquipments.value.length > 0
  401. ? selectedEquipments.value.some((equipments) => !equipments.isClaim)
  402. : true
  403. canSuspend.value = !hasUnClaim
  404. }
  405. const initSelect = () => {
  406. selectedEquipments.value = []
  407. selectedMap.value = {}
  408. selectAll.value = false
  409. updateOperateStatus()
  410. }
  411. const showBatchClaimPopup = (popupData: PopupData) => {
  412. const networkType = uni.getNetworkTypeSync?.()
  413. if (networkType === 'none') {
  414. return uni.showToast({ title: '暂无网络无法认领,请联网后认领设备', icon: 'error' })
  415. }
  416. if (!selectedEquipments.value.length) {
  417. return uni.showToast({
  418. title: `请选择要批量${popupData.isClaim ? '取消认领' : '认领'}的设备`,
  419. icon: 'error',
  420. })
  421. }
  422. tipsPopupData.value = popupData
  423. showTipsPopup.value = true
  424. }
  425. const closeTipsPopup = () => {
  426. showTipsPopup.value = false
  427. }
  428. const handleBatchClaim = async () => {
  429. closeTipsPopup()
  430. const ids = selectedEquipments.value.map((item: any) => item.id)
  431. const params: { ids: string[]; isCancel?: true } = { ids }
  432. if (tipsPopupData.value.isClaim) {
  433. params.isCancel = true
  434. }
  435. try {
  436. const result = await batchClaim(params)
  437. updateClaim(result, ids, !tipsPopupData.value.isClaim)
  438. } catch (error) {
  439. uni.showToast({ title: '操作失败', icon: 'error' })
  440. }
  441. }
  442. const fetchClaimEquipments = async (equipmentId: string, isClaim: boolean) => {
  443. const networkType = uni.getNetworkTypeSync?.()
  444. if (networkType === 'none') {
  445. return uni.showToast({ title: '暂无网络无法认领,请联网后认领设备', icon: 'error' })
  446. }
  447. const currentUserInfo = userInfo.value
  448. if (!currentUserInfo) {
  449. return uni.redirectTo({ url: '/pages/login/login' })
  450. }
  451. try {
  452. let result: any
  453. if (isClaim) {
  454. result = await requestFunc(TaskOrderFuncName.EquipmentConfirmClaim, equipType, { id: equipmentId })
  455. } else {
  456. result = await requestFunc(TaskOrderFuncName.EquipmentCancelClaim, equipType, { id: equipmentId })
  457. }
  458. updateClaim(result, [equipmentId], !isClaim)
  459. } catch (error) {
  460. uni.showToast({ title: '操作失败', icon: 'error' })
  461. }
  462. }
  463. const updateClaim = async (result: any, equipmentIds: string[], isClaim: boolean) => {
  464. if (result?.code === 0 && result?.data === true) {
  465. uni.showToast({ title: `${isClaim ? '认领' : '取消认领'}成功` })
  466. initSelect()
  467. await fetchCheckerOnlineEquipmentList()
  468. } else {
  469. const msg = result?.msg || `${isClaim ? '认领' : '取消认领'}失败`
  470. uni.showToast({ title: msg, icon: 'error' })
  471. }
  472. }
  473. const showCheckProjectPopup = () => {
  474. if (!selectedEquipments.value.length) {
  475. return uni.showToast({ title: '请先选择设备', icon: 'error' })
  476. }
  477. const ids = selectedEquipments.value.map((item: any) => item.id)
  478. uni.navigateTo({
  479. url: `/pages/equipment/detail/components/checkProjectPopup/addCheckProjectPopup?selectedEquipmentIds=${ids.join(',')}&useOnline=1`,
  480. })
  481. }
  482. const showSuspendPopupFunc = () => {
  483. const networkType = uni.getNetworkType?.()
  484. if (networkType === 'none') {
  485. return uni.showToast({ title: '当前网络连接不可用,请检查网络设置后重新操作', icon: 'error' })
  486. }
  487. if (!selectedEquipments.value.length) {
  488. return uni.showToast({ title: '请先选择设备', icon: 'error' })
  489. }
  490. showMoreOperate.value = false
  491. showSuspendPopup.value = true
  492. }
  493. const closeSuspendPopup = () => {
  494. showSuspendPopup.value = false
  495. suspendReason.value = ''
  496. }
  497. const suspendCheck = async () => {
  498. if (!suspendReason.value.trim()) {
  499. return uni.showToast({ title: '请输入中止检验原因', icon: 'error' })
  500. }
  501. closeSuspendPopup()
  502. uni.showLoading({ title: '加载中' })
  503. const ids = selectedEquipments.value.map((item: any) => item.id)
  504. try {
  505. const result = await taskOrderItemSuspendApi({ orderItemIds: ids, reason: suspendReason.value })
  506. uni.hideLoading()
  507. if (result?.code === 0) {
  508. initSelect()
  509. fetchCheckerOnlineEquipmentList()
  510. uni.showToast({ title: '中止检验成功', icon: 'success' })
  511. uni.$emit('RefreshOrder')
  512. } else {
  513. const msg = result?.msg || '中止检验失败'
  514. uni.showToast({ title: msg, icon: 'error' })
  515. }
  516. } catch (error) {
  517. uni.hideLoading()
  518. uni.showToast({ title: '中止检验失败', icon: 'error' })
  519. }
  520. }
  521. const createInform = async () => {
  522. const networkType = uni.getNetworkType?.()
  523. if (networkType === 'none') {
  524. return uni.showToast({ title: '无网络连接,请联网重试' })
  525. }
  526. if (!orderId.value) return
  527. try {
  528. showMoreOperate.value = false
  529. const equipment = selectedEquipments.value[0]
  530. const majorcheckres = await orderItemMajorCheck({ orderItemIds: [equipment?.id] })
  531. const equipmentReportId =
  532. (equipment.reportDOList || []).find((item: any) => item.reportType === 500)?.id || ''
  533. if (majorcheckres.data[equipment?.id]) {
  534. const item = majorcheckres.data[equipment?.id]
  535. if (item.isSignature === '1') {
  536. uni.redirectTo({
  537. url: `/pages/sign-detail/index?orderId=${orderId.value}&type=ZXXX&orderItemId=${equipment?.id}&reportId=${equipmentReportId}`,
  538. })
  539. } else {
  540. uni.redirectTo({
  541. url: `/pages/sign/index?orderId=${orderId.value}&type=ZXXX&orderItemId=${equipment?.id}&reportId=${equipmentReportId}`,
  542. })
  543. }
  544. return
  545. }
  546. const configRes = await signApis.getGcConfig(
  547. {
  548. orderId: orderId.value,
  549. businessType: 400,
  550. orderItemId: equipment.id,
  551. },
  552. userInfo.value,
  553. )
  554. if (configRes?.code === 0) {
  555. const initJSONResult = await getEquipmentsTemplateJSONData({
  556. taskOrderNo: orderNo.value,
  557. templateId: configRes.data?.templateId,
  558. equipCode: equipment?.equipCode,
  559. })
  560. const dataStr = initJSONResult?.data ? JSON.parse(initJSONResult.data) : {}
  561. const { id, nickname, mobile } = userInfo.value || {}
  562. const params = {
  563. dataStr: JSON.stringify({
  564. ...dataStr,
  565. notifierSignName: nickname,
  566. notifierSignDate: dayjs().format('YYYY年MM月DD日'),
  567. notifierPhone: mobile,
  568. }),
  569. standardInitData: configRes.data?.standardInitData,
  570. templateUrl: configRes.data?.templateUrl,
  571. templateId: configRes.data?.templateId,
  572. orderItemId: equipment.id,
  573. prepareId: id || '',
  574. prepareName: nickname || '',
  575. translateInitData: '{}',
  576. reportId: equipmentReportId,
  577. }
  578. const businessConfig = createBusinessConfig('ZXXX')
  579. setSpreadsheetEditParams({
  580. routeType: 'ZXXX',
  581. orderId: orderId.value,
  582. gcConfig: params,
  583. businessConfig,
  584. })
  585. uni.navigateTo({
  586. url: `/pages/webview/generic-webview?businessType=ZXXX&orderId=${orderId.value}&templateId=${configRes.data?.id}&useOnline=1`,
  587. })
  588. } else {
  589. uni.showToast({ title: '获取配置信息失败' })
  590. }
  591. } catch (configError) {
  592. console.error('获取葡萄城配置信息失败:', configError)
  593. uni.showToast({ title: '获取配置信息失败,请重试' })
  594. }
  595. }
  596. const showAddSpacePopup = async () => {
  597. if (!selectedEquipments.value.length) {
  598. return uni.showToast({ title: '请先选择设备', icon: 'error' })
  599. }
  600. try {
  601. const result = await notVerifyPageApi({ type: '10', status: 200, pageNo: 1, pageSize: 9999 })
  602. const list = (result?.data?.list || []).map((item: any) => {
  603. return { ...item, label: item.name || '', value: item.id || '' }
  604. })
  605. if (!list.length) {
  606. return uni.showToast({ title: '暂无有限空间记录模板', icon: 'error' })
  607. }
  608. spaceTemplateList.value = list
  609. selectedSpaceTemplateId.value = ''
  610. showMoreOperate.value = false
  611. showSpaceTemplatePopup.value = true
  612. } catch (error) {
  613. uni.showToast({ title: '获取有限空间记录模板失败' })
  614. }
  615. }
  616. const confirmSpaceTemplate = () => {
  617. if (!selectedSpaceTemplateId.value) {
  618. return uni.showToast({ title: '请选择一个模板', icon: 'error' })
  619. }
  620. const currentTemplate = spaceTemplateList.value.find(
  621. (item) => item.id === selectedSpaceTemplateId.value,
  622. )
  623. if (!currentTemplate) {
  624. return uni.showToast({ title: '模板不存在', icon: 'error' })
  625. }
  626. const currentRow = selectedEquipments.value[0]
  627. const defaultDataSource: Record<string, any> = {
  628. reportNo: currentTemplate.name,
  629. jyName: userInfo.value?.nickname || '',
  630. signName: userInfo.value?.nickname || '',
  631. signDate: formatDate(new Date(), 'YYYY年MM月DD日'),
  632. }
  633. const reportRespVOList = currentRow?.reportDOList || []
  634. const unitName = currentRow?.unitName || ''
  635. defaultDataSource.reportNo = reportRespVOList[0]?.reportNo || ''
  636. defaultDataSource.unitName = unitName
  637. const params = {
  638. dataStr: JSON.stringify({ ...defaultDataSource }),
  639. standardInitData: currentTemplate?.bindingPathSchema,
  640. templateUrl: currentTemplate?.recordTemplateUrl || '',
  641. templateId: currentTemplate?.id,
  642. orderId: orderId.value,
  643. orderItemId: currentRow.id,
  644. prepareId: userInfo.value?.id || '',
  645. prepareName: userInfo.value?.nickname || '',
  646. reportName: currentTemplate.name || '',
  647. translateInitData: '{}',
  648. cacheParams: {
  649. objId: `${currentRow.id}_${currentTemplate.id}`,
  650. type: 8,
  651. cachTime: currentRow.updateTime || currentRow.createTime,
  652. },
  653. }
  654. const businessConfig = createBusinessConfig('YXKJ')
  655. setSpreadsheetEditParams({
  656. routeType: 'YXKJ',
  657. orderId: orderId.value,
  658. gcConfig: params,
  659. businessConfig,
  660. })
  661. showSpaceTemplatePopup.value = false
  662. uni.navigateTo({
  663. url: `/pages/webview/generic-webview?businessType=YXKJ&orderId=${orderId.value}&templateId=${currentTemplate.id}&useOnline=1`,
  664. })
  665. }
  666. const createBusinessConfig = (name) => {
  667. }
  668. const showAddInspectionplanPopup = async () => {
  669. if (!canAddInspectionplan.value) {
  670. return uni.showToast({ title: '请先选择设备', icon: 'error' })
  671. }
  672. showMoreOperate.value = false
  673. showInspectionplanPopup.value = true
  674. inspectionplanName.value = ''
  675. selectedTemplate.value = null
  676. try {
  677. const result = await notVerifyPageApi({ type: '1', status: 200, pageNo: 1, pageSize: 9999 })
  678. templateList.value = result?.data?.list || []
  679. } catch (error) {
  680. console.error('获取模板列表失败:', error)
  681. }
  682. }
  683. const closeInspectionplanPopup = () => {
  684. showInspectionplanPopup.value = false
  685. }
  686. const onTemplateChange = ({ selected }) => {
  687. const index = selected[0]
  688. selectedTemplate.value = templateList.value[index]
  689. selectedTemplateId.value = selectedTemplate.value?.id || ''
  690. }
  691. const addInspectionplanConfirm = async () => {
  692. const templateId = selectedTemplate.value?.id
  693. if (!templateId) {
  694. return uni.showToast({ title: '请选择模板封面', icon: 'error' })
  695. }
  696. if (!inspectionplanName.value.trim()) {
  697. return uni.showToast({ title: '请输入检验方案名称', icon: 'error' })
  698. }
  699. closeInspectionplanPopup()
  700. await handleSuccessInspectionplan({ templateId, reportName: inspectionplanName.value.trim() })
  701. }
  702. const handleSuccessInspectionplan = async (info: any) => {
  703. try {
  704. uni.showLoading({ title: '添加中' })
  705. const resultData = await getEquipmentsTemplateJSONData({
  706. taskOrderNo: orderNo.value,
  707. templateId: info.templateId,
  708. equipCode: selectedEquipments.value[0].equipCode,
  709. })
  710. const defaultUser: Record<string, any> = {
  711. prepareName: userInfo.value?.nickname || '',
  712. prepareDate: dayjs().format('YYYY年MM月DD日'),
  713. }
  714. const initJSONResult = resultData?.data || ''
  715. const prepareJson = initJSONResult
  716. ? { ...JSON.parse(initJSONResult), ...defaultUser }
  717. : defaultUser
  718. const addParams = {
  719. orderId: orderId.value,
  720. templateId: info.templateId,
  721. prepareJson: JSON.stringify(prepareJson),
  722. prepareId: userInfo.value?.id,
  723. prepareName: userInfo.value?.nickname,
  724. orderItemIds: selectedEquipments.value.map((item) => item.id),
  725. reportName: info.reportName,
  726. }
  727. const result = await addMajorIssuesApi(addParams)
  728. const newReportId = result?.data || ''
  729. if (!newReportId) {
  730. uni.hideLoading()
  731. return uni.showToast({ title: '添加失败', icon: 'error' })
  732. }
  733. const url = `/pages/inspectionplanDetail/inspectionplanDetail?reportId=${newReportId}&reportName=${info.reportName}&orderId=${orderId.value}&templateId=${info.templateId}&prepareJson=${encodeURIComponent(JSON.stringify(prepareJson))}`
  734. uni.navigateTo({ url })
  735. } catch (error) {
  736. uni.showToast({ title: '添加检验方案失败', icon: 'error' })
  737. } finally {
  738. uni.hideLoading()
  739. }
  740. }
  741. const handleUpdateContact = () => {
  742. const current = selectedEquipments.value[0]
  743. currentItem.value = current || {}
  744. showMoreOperate.value = false
  745. showUpdateContactPopup.value = true
  746. }
  747. const handleRouteToEquipmentDetail = (item: any, pageType: string) => {
  748. uni.navigateTo({
  749. url: `/pages/equipment/detail/equipmentDetail?orderId=${orderId.value}&orderItemId=${item.id}&equipId=${item.equipId}&pageType=${pageType}&useOnline=1&canEdit=${true}`,
  750. })
  751. }
  752. const handleCalcTotalFee = (reportDOList: any) => {
  753. if (!reportDOList || !Array.isArray(reportDOList)) return 0
  754. return reportDOList
  755. .filter((x: any) => x.fee && !isNaN(x.fee) && typeof x.fee === 'number')
  756. .reduce((sum: number, item: any) => sum + item.fee, 0)
  757. }
  758. const goBack = () => {
  759. uni.navigateBack()
  760. }
  761. </script>
  762. <style lang="scss" scoped>
  763. .equipment-list-container {
  764. display: flex;
  765. flex-direction: column;
  766. height: 100vh;
  767. background-color: #f5f5f5;
  768. }
  769. .navigate-view {
  770. display: flex;
  771. flex-direction: row;
  772. align-items: center;
  773. justify-content: space-between;
  774. height: 44px;
  775. padding: 0 12px;
  776. background-color: #fff;
  777. border-bottom: 1px solid #eee;
  778. }
  779. .navigate-left {
  780. display: flex;
  781. align-items: center;
  782. justify-content: center;
  783. width: 40px;
  784. height: 40px;
  785. }
  786. .back-icon {
  787. width: 20px;
  788. height: 20px;
  789. }
  790. .navigate-title {
  791. flex: 1;
  792. font-size: 17px;
  793. font-weight: 500;
  794. color: #333;
  795. text-align: center;
  796. }
  797. .navigate-right {
  798. width: 40px;
  799. }
  800. .list-scroll {
  801. flex: 1;
  802. overflow: hidden;
  803. }
  804. .equipment-cell {
  805. padding: 12px;
  806. margin: 12px;
  807. margin-bottom: 0;
  808. background-color: #fff;
  809. border-radius: 5px;
  810. }
  811. .cell-top {
  812. padding-bottom: 10px;
  813. margin-bottom: 10px;
  814. border-bottom: 1px solid rgb(244, 244, 244);
  815. }
  816. .row {
  817. display: flex;
  818. flex-direction: row;
  819. align-items: center;
  820. }
  821. .checkbox-wrapper {
  822. margin-right: 10px;
  823. }
  824. .checkbox {
  825. display: flex;
  826. align-items: center;
  827. justify-content: center;
  828. width: 18px;
  829. height: 18px;
  830. border: 1px solid rgb(187, 187, 187);
  831. border-radius: 3px;
  832. }
  833. .checkbox.checked {
  834. background-color: #2f8eff;
  835. border-color: #2f8eff;
  836. }
  837. .check-icon {
  838. width: 12px;
  839. height: 12px;
  840. }
  841. .cell-top-left {
  842. display: flex;
  843. flex: 1;
  844. flex-direction: row;
  845. flex-wrap: wrap;
  846. align-items: center;
  847. justify-content: space-between;
  848. }
  849. .equip-name {
  850. flex: 1;
  851. font-size: 16px;
  852. font-weight: bold;
  853. color: rgb(51, 51, 51);
  854. }
  855. .main-checker {
  856. flex-basis: 160px;
  857. flex-shrink: 0;
  858. font-size: 16px;
  859. font-weight: bold;
  860. color: rgb(51, 51, 51);
  861. }
  862. .status-tag {
  863. display: flex;
  864. flex-basis: 80px;
  865. flex-direction: row;
  866. flex-shrink: 0;
  867. align-items: center;
  868. justify-content: center;
  869. padding: 5px 0;
  870. border-radius: 4px;
  871. }
  872. .status-pending {
  873. background-color: rgba(230, 162, 60, 0.3);
  874. border: 1px solid rgba(230, 162, 60, 0.5);
  875. }
  876. .status-done {
  877. background-color: rgba(103, 194, 58, 0.3);
  878. border: 1px solid rgba(103, 194, 58, 0.5);
  879. }
  880. .status-text {
  881. font-size: 12px;
  882. color: rgb(202, 135, 35);
  883. }
  884. .status-done .status-text {
  885. color: rgb(80, 175, 33);
  886. }
  887. .cell-center {
  888. display: flex;
  889. flex-direction: row;
  890. align-items: center;
  891. justify-content: space-between;
  892. }
  893. .info-box {
  894. display: flex;
  895. flex: 1;
  896. flex-direction: row;
  897. flex-wrap: wrap;
  898. justify-content: space-between;
  899. padding: 8px 12px;
  900. background-color: rgb(244, 244, 244);
  901. border-radius: 5px;
  902. }
  903. .info-label {
  904. margin-top: 8px;
  905. font-size: 12px;
  906. color: rgb(108, 108, 108);
  907. }
  908. .info-value {
  909. color: rgb(51, 51, 51);
  910. }
  911. .cell-bottom {
  912. display: flex;
  913. flex-direction: row;
  914. align-items: center;
  915. justify-content: flex-end;
  916. margin-top: 10px;
  917. }
  918. .claim-btn,
  919. .record-btn {
  920. display: flex;
  921. align-items: center;
  922. justify-content: center;
  923. min-width: 75px;
  924. height: 29px;
  925. padding: 0 5px;
  926. margin-left: 5px;
  927. border-radius: 3px;
  928. }
  929. .blue-btn {
  930. color: white;
  931. background-color: rgb(47, 142, 255);
  932. }
  933. .white-btn {
  934. background-color: #fff;
  935. border: 1px solid rgb(217, 217, 217);
  936. }
  937. .blue-btn-text {
  938. font-size: 12px;
  939. color: rgb(222, 238, 255);
  940. }
  941. .white-btn-text {
  942. font-size: 12px;
  943. color: rgb(59, 59, 59);
  944. }
  945. .loading-text {
  946. padding: 15px;
  947. font-size: 14px;
  948. color: #999;
  949. text-align: center;
  950. }
  951. .empty-text {
  952. display: flex;
  953. flex-direction: column;
  954. align-items: center;
  955. justify-content: center;
  956. padding: 60px 0;
  957. font-size: 14px;
  958. color: #999;
  959. }
  960. .bottom-operate {
  961. display: flex;
  962. flex-direction: row;
  963. align-items: center;
  964. justify-content: space-between;
  965. height: 68px;
  966. padding: 8px 12px;
  967. background-color: #fff;
  968. border-top: 1px solid #eee;
  969. }
  970. .select-all {
  971. display: flex;
  972. flex-direction: row;
  973. align-items: center;
  974. }
  975. .select-all-text {
  976. margin-left: 6px;
  977. font-size: 14px;
  978. color: #333;
  979. }
  980. .btn-group {
  981. display: flex;
  982. flex-direction: row;
  983. align-items: center;
  984. }
  985. .btn-group > button {
  986. min-width: 70px;
  987. height: 32px;
  988. padding: 8px 4px;
  989. margin-left: 6px;
  990. font-size: 14px;
  991. line-height: 1;
  992. border: none;
  993. border-radius: 3px;
  994. }
  995. .operate-btn {
  996. display: flex;
  997. align-items: center;
  998. justify-content: center;
  999. }
  1000. .popup-mask {
  1001. position: fixed;
  1002. top: 0;
  1003. right: 0;
  1004. bottom: 0;
  1005. left: 0;
  1006. z-index: 999;
  1007. display: flex;
  1008. align-items: center;
  1009. justify-content: center;
  1010. background-color: rgba(0, 0, 0, 0.5);
  1011. }
  1012. .popup-content {
  1013. width: 80%;
  1014. max-width: 320px;
  1015. padding: 20px;
  1016. background-color: #fff;
  1017. border-radius: 8px;
  1018. }
  1019. .tips-text {
  1020. display: block;
  1021. margin-bottom: 20px;
  1022. font-size: 16px;
  1023. color: #333;
  1024. text-align: center;
  1025. }
  1026. .popup-actions {
  1027. display: flex;
  1028. flex-direction: row;
  1029. justify-content: space-around;
  1030. }
  1031. .action-btn {
  1032. display: flex;
  1033. align-items: center;
  1034. justify-content: center;
  1035. width: 100px;
  1036. height: 36px;
  1037. font-size: 14px;
  1038. border: none;
  1039. border-radius: 4px;
  1040. }
  1041. .cancel-btn {
  1042. color: #666;
  1043. background-color: #f5f5f5;
  1044. }
  1045. .confirm-btn {
  1046. color: #fff;
  1047. background-color: #2f8eff;
  1048. }
  1049. .more-operate-overlay {
  1050. position: fixed;
  1051. top: 0;
  1052. right: 0;
  1053. bottom: 0;
  1054. left: 0;
  1055. z-index: 998;
  1056. }
  1057. .more-operate-panel {
  1058. position: fixed;
  1059. right: 0;
  1060. bottom: 68px;
  1061. left: 0;
  1062. z-index: 999;
  1063. display: flex;
  1064. flex-direction: column;
  1065. overflow: hidden;
  1066. background-color: #fff;
  1067. border-radius: 5px;
  1068. box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  1069. transition: transform 0.3s ease;
  1070. transform: translateY(100%);
  1071. }
  1072. .more-panel-show {
  1073. transform: translateY(0);
  1074. }
  1075. .more-btn-item {
  1076. display: flex;
  1077. align-items: center;
  1078. justify-content: center;
  1079. padding: 0 15px 10px;
  1080. background-color: #fff;
  1081. }
  1082. .more-btn-inner {
  1083. display: flex;
  1084. align-items: center;
  1085. justify-content: center;
  1086. width: 100%;
  1087. padding-top: 10px;
  1088. }
  1089. .more-btn-border {
  1090. border-top: 1px solid #f4f5f6;
  1091. }
  1092. .more-btn-item.disabled {
  1093. opacity: 1;
  1094. }
  1095. .more-btn-text {
  1096. font-size: 14px;
  1097. color: #333;
  1098. }
  1099. .suspend-popup .popup-title,
  1100. .inspectionplan-popup .popup-title {
  1101. display: block;
  1102. margin-bottom: 15px;
  1103. font-size: 16px;
  1104. font-weight: 500;
  1105. color: #333;
  1106. text-align: center;
  1107. }
  1108. .suspend-textarea {
  1109. box-sizing: border-box;
  1110. width: 100%;
  1111. height: 80px;
  1112. padding: 8px;
  1113. margin-bottom: 15px;
  1114. font-size: 14px;
  1115. border: 1px solid #ddd;
  1116. border-radius: 4px;
  1117. }
  1118. .form-item {
  1119. display: flex;
  1120. flex-direction: column;
  1121. margin-bottom: 12px;
  1122. }
  1123. .form-label {
  1124. margin-bottom: 6px;
  1125. font-size: 14px;
  1126. color: #333;
  1127. }
  1128. .picker-value {
  1129. padding: 8px;
  1130. font-size: 14px;
  1131. color: #333;
  1132. background-color: #f5f5f5;
  1133. border-radius: 4px;
  1134. }
  1135. .form-input {
  1136. padding: 8px;
  1137. font-size: 14px;
  1138. background-color: #f5f5f5;
  1139. border-radius: 4px;
  1140. }
  1141. .template-scroll {
  1142. max-height: 200px;
  1143. margin-bottom: 15px;
  1144. }
  1145. .template-item {
  1146. padding: 10px;
  1147. font-size: 14px;
  1148. color: #333;
  1149. border-bottom: 1px solid #eee;
  1150. }
  1151. .template-item.active {
  1152. color: #2f8eff;
  1153. background-color: #f0f8ff;
  1154. }
  1155. </style>