InspectionItemList.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  1. <template>
  2. <div class="inspection-item-list">
  3. <!-- 胶囊形状的 Tabs -->
  4. <div class="capsule-tabs">
  5. <el-badge
  6. :value="inspectionItems.length"
  7. :hidden="inspectionItems.length === 0"
  8. :type="activeTab === 'inspection' ? 'primary' : 'danger'"
  9. style="flex: 1"
  10. >
  11. <div
  12. class="tab-item"
  13. :class="{ active: activeTab === 'inspection' }"
  14. @click="activeTab = 'inspection'"
  15. >
  16. <span style="font-size: 12px">检验项目</span>
  17. </div>
  18. </el-badge>
  19. <el-badge
  20. :value="documentItems.length"
  21. :hidden="documentItems.length === 0"
  22. :type="activeTab === 'document' ? 'primary' : 'danger'"
  23. style="flex: 1"
  24. >
  25. <div
  26. class="tab-item"
  27. :class="{ active: activeTab === 'document' }"
  28. @click="activeTab = 'document'"
  29. >
  30. <span style="font-size: 12px">记录文件</span>
  31. </div>
  32. </el-badge>
  33. </div>
  34. <div class="list-content">
  35. <div v-if="currentTabItems.length === 0" class="empty-state">
  36. <el-empty
  37. :description="`暂无${activeTab === 'inspection' ? '检验项目' : '记录文件'}`"
  38. :image-size="120"
  39. />
  40. </div>
  41. <div v-else class="item-list">
  42. <div
  43. v-for="item in currentTabItems"
  44. :key="item.id"
  45. :class="getItemClass(item)"
  46. @click="handleItemClick(item)"
  47. @contextmenu.prevent="handleContextMenu($event, item)"
  48. @dblclick.prevent="handleDoubleClick($event, item)"
  49. >
  50. <div class="item-header">
  51. <div class="item-title-wrapper break-all">
  52. <div class="title-content">
  53. <div
  54. v-if="getReportTypeIcon(item.reportType)"
  55. :class="getReportTypeIconClass(item.reportType)"
  56. >
  57. {{ getReportTypeIcon(item.reportType) }}
  58. </div>
  59. <div class="item-title">
  60. <span
  61. v-if="activeTab == 'inspection'"
  62. :style="{color: getStatusBgColor(item.taskStatus) }"
  63. >
  64. <span>{{ item.reportName || '检验项目' }}</span>
  65. <span >({{ getCurrentStepName(item) }})</span>
  66. </span>
  67. <span v-else>
  68. {{ item.reportName || '检验项目' }}
  69. </span>
  70. <span style="color: red" v-if="isOtherReport(item) && getOtherStepName(item)">({{ getOtherStepName(item) }})</span>
  71. <span>&nbsp;&mdash;&nbsp;</span>
  72. <span v-if="activeTab == 'inspection'" :style="{color: getStatusBgColor(item.taskStatus) }">{{
  73. item.checkUsers.length ? item.checkUsers[0].nickname : '未分配'
  74. }}</span>
  75. <span v-else>{{ item.checkUsers.length ? item.checkUsers[0]?.nickname : '' }}</span>
  76. <div
  77. class="text-[14px]"
  78. v-if="item.reportType === 300 && !item.instructionId && item.instructionTempId"
  79. >
  80. <el-button
  81. link
  82. :type="item.instructionId ? 'warning' : 'primary'"
  83. size="small"
  84. :disabled="isDisabledBtn(item)"
  85. @click.stop.prevent="() => handleCorrelationReport(item)"
  86. >
  87. {{ `(${item.instructionId ? '已' : '未'}关联操作指导书)` }}
  88. </el-button>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. <div v-if="activeTab == 'inspection'" class="fee-btn">
  94. <el-button
  95. :disabled="item?.taskStatus === PressureTaskOrderTaskStatus['REPORT_END']"
  96. link
  97. type="primary"
  98. @click.stop.prevent="() => handleInputCalcField(props.taskOrderItem, item)"
  99. >
  100. <span
  101. v-if="activeTab == 'inspection'"
  102. >
  103. {{ getCheckItemFeeType(item) }}
  104. </span>
  105. <span v-else>{{ getCheckItemFeeType(item) }}</span>
  106. </el-button>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. <!-- 右键菜单 -->
  113. <div
  114. v-show="contextMenuVisible"
  115. class="context-menu"
  116. :style="contextMenuStyle"
  117. @click.stop
  118. >
  119. <div
  120. class="context-menu-item"
  121. :class="{ disabled: contextMenuItem && !canMoveUp(contextMenuItem) }"
  122. @click="handleContextMenuCommand('moveUp')"
  123. >
  124. <el-icon><ArrowUp /></el-icon>
  125. <span>上移</span>
  126. </div>
  127. <div
  128. class="context-menu-item"
  129. :class="{ disabled: contextMenuItem && !canMoveDown(contextMenuItem) }"
  130. @click="handleContextMenuCommand('moveDown')"
  131. >
  132. <el-icon><ArrowDown /></el-icon>
  133. <span>下移</span>
  134. </div>
  135. <div class="context-menu-divider"></div>
  136. <div
  137. class="context-menu-item"
  138. @click="handleContextMenuCommand('setPipeDetail')"
  139. :class="{ disabled: checkerIsLoginUser }"
  140. >
  141. <el-icon><Setting /></el-icon>
  142. <span>选择管线</span>
  143. </div>
  144. <div class="context-menu-divider"></div>
  145. <div
  146. class="context-menu-item"
  147. @click="handleContextMenuCommand('modifyChecker')"
  148. :class="{ disabled: checkerIsLoginUser }"
  149. >
  150. <el-icon><User /></el-icon>
  151. <span>修改检验员</span>
  152. </div>
  153. <div class="context-menu-divider"></div>
  154. <div
  155. class="context-menu-item"
  156. :class="{ disabled: (contextMenuItem && !canSyncReport(contextMenuItem) || checkerIsLoginUserForSync) }"
  157. @click="handleContextMenuCommand('syncAllReport')"
  158. >
  159. <el-icon><RefreshLeft /></el-icon>
  160. <span>同步报表</span>
  161. </div>
  162. <div class="context-menu-divider"></div>
  163. <div
  164. class="context-menu-item danger"
  165. :class="{ disabled: (contextMenuItem && !canVoidItem(contextMenuItem) || checkerIsLoginUser) }"
  166. @click="handleContextMenuCommand('voidItem')"
  167. >
  168. <el-icon><Delete /></el-icon>
  169. <span>作废项目</span>
  170. <!-- <span v-if="contextMenuItem && !canVoidItem(contextMenuItem)" class="disabled-tip">(当前状态不可作废)</span> -->
  171. </div>
  172. </div>
  173. <!-- 检验录入-模板 -->
  174. <InlineEditCheckRecord
  175. v-if="showInlineEditCheckRecord"
  176. v-model:visible="showInlineEditCheckRecord"
  177. :task-order-item="taskOrderItem"
  178. :report-list="reportList"
  179. :template-params="templateParams"
  180. @confirm="handleTemplateConfirm"
  181. @cancel="handleRefresh"
  182. />
  183. <Teleport to="body">
  184. <!-- 费用计算弹窗 -->
  185. <calcCheckItemFee
  186. v-if="showCalcCheckItemFeeDialog"
  187. v-model="showCalcCheckItemFeeDialog"
  188. :equipmentId="calcEquipmentId"
  189. :templateInfo="calcTemplateInfo"
  190. @save="handleSaveCalcFee"
  191. />
  192. </Teleport>
  193. </div>
  194. </template>
  195. <script setup lang="ts">
  196. import { ref, computed, nextTick, onMounted, onUnmounted } from 'vue'
  197. import calcCheckItemFee from '@/views/pressure2/boilertaskorder/components/calcCheckItemFee.vue'
  198. import { User, Delete, ArrowUp, ArrowDown,Setting, RefreshLeft } from '@element-plus/icons-vue'
  199. import {ElMessage, ElMessageBox} from 'element-plus'
  200. import {
  201. PressureCheckerMyTaskStatusMap,
  202. PressureCheckerMyTaskStatus,
  203. PressureTaskOrderTaskStatus,
  204. PressureReportType
  205. } from '@/utils/constants'
  206. import InlineEditCheckRecord from './InlineEditCheckRecord.vue'
  207. import type { ReportItemVO, PipeTaskOrderOrderItemVO } from '@/api/pressure2/pipetaskorder'
  208. import { PipeTaskOrderApi } from '@/api/pressure2/pipetaskorder'
  209. import { is } from '@/utils/is'
  210. import { useUserStore } from '@/store/modules/user'
  211. import { useTaskProgress } from './useTaskProgress'
  212. import { cloneDeep } from 'lodash-es'
  213. interface Props {
  214. reportList: ReportItemVO[]
  215. reportGroupList: []
  216. orderInfo: []
  217. equipmentIds: []
  218. orderItemIds: []
  219. selectedItem: ReportItemVO | null
  220. taskOrderItem: PipeTaskOrderOrderItemVO
  221. isAuditMode?: boolean
  222. }
  223. interface Emits {
  224. (e: 'refresh'): void
  225. (e: 'template-confirm', templateUrl?: string): void
  226. (e: 'item-select', item: ReportItemVO): void
  227. (e: 'modify-checker', item: ReportItemVO): void
  228. (e: 'void-item', item: ReportItemVO): void
  229. (e: 'set-pipe-detail', item: ReportItemVO): void
  230. (e: 'sort-report'): void
  231. (e: 'correlation-report', item: ReportItemVO): void
  232. (e: 'sync-all-report', item: ReportItemVO)
  233. }
  234. const props = defineProps<Props>()
  235. const emit = defineEmits<Emits>()
  236. const userStore = useUserStore()
  237. const showCalcCheckItemFeeDialog = ref(false)
  238. const calcEquipmentId = ref('')
  239. const calcTemplateInfo = ref({})
  240. // 注意:过滤逻辑已移到父组件中处理
  241. // 主报告处于 报告审核审核/报告审批/报告办结,是则不能添加检验项目
  242. const canAddReportItem = computed(()=>{
  243. const disabledStatus = [PressureCheckerMyTaskStatus.REPORT_AUDIT, PressureCheckerMyTaskStatus.REPORT_APPROVE, PressureCheckerMyTaskStatus.REPORT_END]
  244. const mainReport = unref(props.reportList).find(x => x.reportType === PressureReportType['MAIN'])
  245. // console.log(mainReport, 'mainReport')
  246. return mainReport && disabledStatus.includes(mainReport.taskStatus)
  247. })
  248. // 右键菜单相关
  249. const contextMenuRef = ref()
  250. const contextMenuVisible = ref(false)
  251. const contextMenuStyle = ref<Record<string, string>>({ left: '0px', top: '0px' })
  252. const contextMenuItem = ref<ReportItemVO | null>(null)
  253. // 判断“填写记录”按钮是否显示
  254. const isCanEditTestRecord = computed(
  255. () =>
  256. props.selectedItem &&
  257. (props.selectedItem.taskStatus === PressureCheckerMyTaskStatus['RECORD_INPUT'] ||
  258. props.selectedItem.taskStatus === PressureCheckerMyTaskStatus['CONFIRMED'])
  259. )
  260. // 模板参数
  261. const templateParams = computed(() => {
  262. if (!props.selectedItem) return {}
  263. return {
  264. ...props.selectedItem,
  265. equipCode: props.taskOrderItem?.equipCode || '',
  266. equipId: props.taskOrderItem?.id || ''
  267. }
  268. })
  269. const handleInputCalcField = async (taskOrderItem, item) => {
  270. try {
  271. showCalcCheckItemFeeDialog.value = true
  272. calcTemplateInfo.value = item
  273. calcEquipmentId.value = taskOrderItem.equipId
  274. } catch (error) {
  275. ElMessage.error('录入费用出错啦!')
  276. console.error('录入费用出错啦!', error)
  277. }
  278. }
  279. // 独走报告关联操作指导书
  280. const handleCorrelationReport = (item: ReportItemVO) => {
  281. emit('item-select', item)
  282. emit('correlation-report', item)
  283. }
  284. // 获取状态颜色
  285. const getStatusColor = (status: number): 'success' | 'warning' | 'info' | 'primary' | 'danger' => {
  286. const statusMap: Record<number, 'success' | 'warning' | 'info' | 'primary' | 'danger'> = {
  287. [PressureCheckerMyTaskStatus.CONFIRMED]: 'success',
  288. [PressureCheckerMyTaskStatus.RECORD_INPUT]: 'warning',
  289. [PressureCheckerMyTaskStatus.RECORD_CHECK]: 'info',
  290. [PressureCheckerMyTaskStatus.REPORT_INPUT]: 'warning',
  291. [PressureCheckerMyTaskStatus.REPORT_AUDIT]: 'warning',
  292. [PressureCheckerMyTaskStatus.REPORT_APPROVE]: 'warning',
  293. [PressureCheckerMyTaskStatus.REPORT_END]: 'success'
  294. }
  295. return statusMap[status] || 'info'
  296. }
  297. const getReportStatusText = (item: ReportItemVO): string => {
  298. return item.taskStatus === PressureCheckerMyTaskStatus.CONFIRMED && item.reportType === PressureReportType.SUBCONTRACT ? '待审核' : PressureCheckerMyTaskStatusMap[item.taskStatus] || '未知状态'
  299. }
  300. // 获取报告类型图标
  301. const getReportTypeIcon = (reportType?: number): string | null => {
  302. switch (reportType) {
  303. case PressureReportType.MAIN: // 100 主报告
  304. return '主'
  305. case PressureReportType.SINGLE: // 300 独审报告
  306. return '独'
  307. case PressureReportType.SUB: // 200 子报告
  308. return '子'
  309. case PressureReportType.SUGGUESTION:
  310. return '附'
  311. case PressureReportType.SUBCONTRACT:
  312. return '分'
  313. default:
  314. return null
  315. }
  316. }
  317. // 获取报告类型图标样式类
  318. const getReportTypeIconClass = (reportType?: number): string => {
  319. switch (reportType) {
  320. case PressureReportType.MAIN: // 100 主报告
  321. return 'report-type-icon main'
  322. case PressureReportType.SINGLE: // 300 独审报告
  323. return 'report-type-icon single'
  324. case PressureReportType.SUB: // 200 子报告
  325. return 'report-type-icon sub'
  326. case PressureReportType.SUBCONTRACT:
  327. return 'report-type-icon subcontract'
  328. default:
  329. return 'report-type-icon'
  330. }
  331. }
  332. // 获取检验结果录入状态文本
  333. const getConclusionStatusText = (item: ReportItemVO): string => {
  334. const hasConclusion = (item as any)?.feeConfirm
  335. return hasConclusion ? '费用已确认' : '费用未确认'
  336. }
  337. // 获取检验结果录入状态类型
  338. const getConclusionStatusType = (item: ReportItemVO): 'success' | 'info' => {
  339. const hasConclusion = (item as any)?.feeConfirm
  340. return hasConclusion ? 'success' : 'info'
  341. }
  342. // 判断是否允许作废
  343. const canVoidItem = (item: ReportItemVO): boolean => {
  344. const forbiddenStatuses = [
  345. PressureCheckerMyTaskStatus.RECORD_CHECK, // 记录校核
  346. PressureCheckerMyTaskStatus.REPORT_AUDIT, // 报告审核
  347. PressureCheckerMyTaskStatus.REPORT_APPROVE, // 报告审批
  348. PressureCheckerMyTaskStatus.REPORT_END // 报告办结
  349. ]
  350. return [PressureReportType.MAINQUESTION, PressureReportType.INSPECTIONPLAN, PressureReportType.WORKINSTRUCTION].includes(item.reportType) || !forbiddenStatuses.includes(item.taskStatus)
  351. }
  352. // 判断是否允许同步报表数据
  353. const canSyncReport = (item: ReportItemVO): boolean => {
  354. const forbiddenStatuses = [
  355. PressureCheckerMyTaskStatus.REPORT_AUDIT, // 报告审核
  356. PressureCheckerMyTaskStatus.REPORT_APPROVE, // 报告审批
  357. PressureCheckerMyTaskStatus.REPORT_END // 报告办结
  358. ]
  359. return !forbiddenStatuses.includes(item.taskStatus)
  360. }
  361. // 判断当前检验员或主检人是否为登录用户,如果不是,则功能按钮disabled
  362. const checkerIsLoginUser = computed(() => {
  363. //记录校核后不允许修改
  364. if (contextMenuItem.value?.taskStatus >= PressureCheckerMyTaskStatus.RECORD_CHECK) return true
  365. const checkerUserIds = contextMenuItem.value?.checkUsers.map(checker => checker?.id)
  366. return !(checkerUserIds?.includes(userStore?.user?.id) || props.taskOrderItem?.mainCheckerUser?.id === userStore?.user?.id)
  367. })
  368. // 判断当前检验员或主检人是否为登录用户,如果不是,则功能按钮disabled
  369. const checkerIsLoginUserForSync = computed(() => {
  370. //记录校核后不允许修改
  371. const checkerUserIds = contextMenuItem.value?.checkUsers.map(checker => checker?.id)
  372. return !(checkerUserIds?.includes(userStore?.user?.id) || props.taskOrderItem?.mainCheckerUser?.id === userStore?.user?.id)
  373. })
  374. // 判断是否可以上移
  375. const canMoveUp = (item: ReportItemVO): boolean => {
  376. const currentIndex = props.reportList.findIndex(report => report.id === item.id)
  377. return currentIndex > 0
  378. }
  379. // 判断是否可以下移
  380. const canMoveDown = (item: ReportItemVO): boolean => {
  381. const currentIndex = props.reportList.findIndex(report => report.id === item.id)
  382. return currentIndex >= 0 && currentIndex < props.reportList.length - 1
  383. }
  384. // 处理报告移动
  385. const handleMoveReport = async (item: ReportItemVO, direction: 'up' | 'down') => {
  386. try {
  387. const sortList = activeTab.value === 'inspection' ? inspectionItems.value : documentItems.value
  388. const currentIndex = sortList.findIndex((report) => report.id === item.id)
  389. if (currentIndex === -1) return
  390. // 创建新的排序数组
  391. const sortedItems = cloneDeep(props.reportList)
  392. const prevReport = sortList[currentIndex - 1]
  393. const currentReport = sortList[currentIndex]
  394. const nextReport = sortList[currentIndex + 1]
  395. const prevSort = prevReport?.sort || 0
  396. const curSort = currentReport.sort
  397. const nextSort = nextReport?.sort || 0
  398. if (direction === 'up' && currentIndex > 0) {
  399. // 上移:与前一个交换位置, 修改sort字段值
  400. sortedItems.forEach((item) => {
  401. if(item.id === prevReport.id){
  402. item.sort = curSort
  403. } else if(item.id === currentReport.id){
  404. item.sort = prevSort
  405. }
  406. })
  407. // sortedItems[currentIndex].sort = sortedItems[currentIndex-1].sort
  408. // sortedItems[currentIndex-1].sort = curSort
  409. // ;[sortedItems[currentIndex - 1], sortedItems[currentIndex]] = [
  410. // sortedItems[currentIndex],
  411. // sortedItems[currentIndex - 1]
  412. // ]
  413. } else if (direction === 'down' && currentIndex < sortedItems.length - 1) {
  414. // 下移:与后一个交换位置, 修改sort字段值
  415. sortedItems.forEach((item) => {
  416. if(item.id === currentReport.id){
  417. item.sort = nextSort
  418. } else if(item.id === nextReport.id){
  419. item.sort = curSort
  420. }
  421. })
  422. // sortedItems[currentIndex].sort = sortedItems[currentIndex+1].sort
  423. // sortedItems[currentIndex+1].sort = curSort
  424. // ;[sortedItems[currentIndex], sortedItems[currentIndex + 1]] = [
  425. // sortedItems[currentIndex + 1],
  426. // sortedItems[currentIndex]
  427. // ]
  428. } else {
  429. return // 无法移动
  430. }
  431. // 构造API参数,重新分配sort值(从1开始)
  432. const newItems = sortedItems.sort((a, b) => (a.sort || 0) - (b.sort || 0))
  433. const items = newItems.map((report, index) => ({
  434. id: report.id,
  435. sort: index + 1
  436. }))
  437. // 调用API
  438. await PipeTaskOrderApi.sortReport({ items })
  439. ElMessage.success('排序已更新')
  440. // 通知父组件刷新数据
  441. emit('sort-report')
  442. } catch (error) {
  443. console.error('移动报告失败:', error)
  444. ElMessage.error('移动报告失败')
  445. }
  446. }
  447. // 获取项目样式类
  448. const getItemClass = (item: ReportItemVO) => {
  449. return [
  450. 'list-item',
  451. {
  452. 'selected': props.selectedItem?.id === item.id
  453. }
  454. ]
  455. }
  456. const handleTemplateConfirm = (templateUrl: string) => {
  457. emit('template-confirm', templateUrl)
  458. }
  459. const handleRefresh = () => {
  460. emit('refresh')
  461. }
  462. // 处理项目点击 - 开放所有状态
  463. const handleItemClick = (item: ReportItemVO) => {
  464. emit('item-select', item)
  465. }
  466. // 处理右键菜单 - 审核模式下不显示右键菜单
  467. const handleContextMenu = (event: MouseEvent, item: ReportItemVO) => {
  468. // 审核模式下不显示右键菜单
  469. if (props.isAuditMode) {
  470. return
  471. }
  472. event.preventDefault()
  473. event.stopPropagation()
  474. contextMenuItem.value = item
  475. contextMenuStyle.value = {
  476. left: `${event.clientX}px`,
  477. top: `${event.clientY}px`,
  478. position: 'fixed',
  479. zIndex: '9999'
  480. }
  481. nextTick(() => {
  482. contextMenuVisible.value = true
  483. })
  484. }
  485. // 获取检验员名称
  486. const getCheckersName = (): string => {
  487. if (!props.selectedItem?.checkUsers || props.selectedItem.checkUsers.length === 0) {
  488. return '未分配'
  489. }
  490. return props.selectedItem.checkUsers.map((user) => user.nickname).join('、')
  491. }
  492. // 处理双击事件 - 填写记录存在则开启
  493. const handleDoubleClick = (event: MouseEvent, item: ReportItemVO) => {
  494. // 审核模式下不显示右键菜单
  495. // if (isCanEditTestRecord.value === false) {
  496. // return
  497. // }
  498. // const reportType = props.selectedItem?.reportType || -1
  499. // if([PressureReportType.SUBCONTRACT].includes(reportType)){
  500. // return
  501. // }
  502. // event.preventDefault()
  503. // event.stopPropagation()
  504. // showInlineEditCheckRecord.value = true
  505. }
  506. const showInlineEditCheckRecord = ref(false)
  507. // 处理右键菜单命令
  508. const handleContextMenuCommand = async (command: string) => {
  509. if (!contextMenuItem.value) return
  510. switch (command) {
  511. case 'moveUp':
  512. if (!canMoveUp(contextMenuItem.value)) {
  513. return
  514. }
  515. await handleMoveReport(contextMenuItem.value, 'up')
  516. break
  517. case 'moveDown':
  518. if (!canMoveDown(contextMenuItem.value)) {
  519. return
  520. }
  521. await handleMoveReport(contextMenuItem.value, 'down')
  522. break
  523. case 'modifyChecker':
  524. if(unref(checkerIsLoginUser)) return
  525. emit('modify-checker', contextMenuItem.value)
  526. break
  527. case 'voidItem':
  528. // 检查是否允许作废
  529. if ((contextMenuItem.value && !canVoidItem(contextMenuItem.value)) || unref(checkerIsLoginUser)) {
  530. return
  531. }
  532. emit('void-item', contextMenuItem.value)
  533. break
  534. case 'setPipeDetail':
  535. if(unref(checkerIsLoginUser)) return
  536. emit('set-pipe-detail', contextMenuItem.value)
  537. break
  538. case 'syncAllReport':
  539. if((contextMenuItem.value && !canSyncReport(contextMenuItem.value) || unref(checkerIsLoginUserForSync)) ) return
  540. emit('sync-all-report', contextMenuItem.value)
  541. break
  542. }
  543. contextMenuVisible.value = false
  544. contextMenuItem.value = null
  545. }
  546. // 点击其他地方关闭右键菜单
  547. const handleDocumentClick = (event: Event) => {
  548. // 如果点击的是右键菜单内部,不关闭菜单
  549. const target = event.target as HTMLElement
  550. if (target && target.closest('.context-menu')) {
  551. return
  552. }
  553. contextMenuVisible.value = false
  554. contextMenuItem.value = null
  555. }
  556. const getCheckItemFeeType = computed(() => {
  557. return ({isAutoAmount, fee}) => {
  558. if(is(fee, 'Number')) return fee
  559. else if(is(fee, 'Null') && isAutoAmount === '1') return '录入计算'
  560. else return '无'
  561. }
  562. })
  563. const handleSaveCalcFee = async (templateInfo: any) => {
  564. // 更新检验项目的费用
  565. const updateRes = await PipeTaskOrderApi.updateCheckItemFee({id: templateInfo.id, fee: templateInfo.fee, feeCalculateJson: templateInfo.feeCalculateJson })
  566. if(updateRes) {
  567. emit('refresh');
  568. ElMessage.success('费用已更新')
  569. }
  570. }
  571. // 处理文档右键点击
  572. const handleDocumentContextMenu = (event: MouseEvent) => {
  573. // 如果不是在我们的列表项上右键,关闭菜单
  574. const target = event.target as HTMLElement
  575. if (!target || !target.closest('.list-item')) {
  576. contextMenuVisible.value = false
  577. contextMenuItem.value = null
  578. }
  579. }
  580. onMounted(() => {
  581. document.addEventListener('click', handleDocumentClick)
  582. document.addEventListener('contextmenu', handleDocumentContextMenu)
  583. })
  584. onUnmounted(() => {
  585. document.removeEventListener('click', handleDocumentClick)
  586. document.removeEventListener('contextmenu', handleDocumentContextMenu)
  587. })
  588. //新加
  589. // 使用任务进度逻辑
  590. const { getCurrentStepName } = useTaskProgress()
  591. // 检验项目类型:主报告(100)、子报告(200)、独审报告(300)、检验意见通知书(400)、分包项目(900)
  592. const inspectionTypes = [
  593. PressureReportType.MAIN,
  594. PressureReportType.SUB,
  595. PressureReportType.SINGLE,
  596. PressureReportType.SUGGUESTION,
  597. PressureReportType.SUBCONTRACT
  598. ]
  599. // 项目文件类型:操作指导书(700)、检验方案(600)、重大问题线索告知表(500)
  600. const documentTypes = [
  601. PressureReportType.WORKINSTRUCTION,
  602. PressureReportType.INSPECTIONPLAN,
  603. PressureReportType.MAINQUESTION,
  604. ]
  605. // 获取状态字体颜色
  606. const getStatusBgColor = (status: number): '#5B9BD5' | '#70AD47' | '#ED7D31' | '#9973C2' | '#FF8DC7' | '#FFC000' | '#A7D78B' | 'primary' | 'danger' => {
  607. const statusMap: Record<number, '#5B9BD5' | '#70AD47' | '#FFC000'| '#9973C2' | '#ED7D31'| '#FF8DC7' | '#A7D78B' | 'primary' | 'danger'> = {
  608. [PressureCheckerMyTaskStatus.CONFIRMED]: '#5B9BD5', //待录入
  609. [PressureCheckerMyTaskStatus.RECORD_INPUT]: '#70AD47', //记录录入
  610. [PressureCheckerMyTaskStatus.RECORD_CHECK]: '#9973C2', //记录校核
  611. [PressureCheckerMyTaskStatus.REPORT_INPUT]: '#FFC000', //报告编制
  612. [PressureCheckerMyTaskStatus.REPORT_AUDIT]: '#ED7D31', //报告审核
  613. [PressureCheckerMyTaskStatus.REPORT_APPROVE]: '#FF8DC7', //报告审批
  614. [PressureCheckerMyTaskStatus.REPORT_END]: '#303133' //报告办结
  615. }
  616. return statusMap[status] || '#A7D78B'
  617. }
  618. // 操作指导书名称
  619. const getWorkInstructionStepName = (item: ReportItemVO): string => {
  620. switch (item.status) {
  621. case 0:
  622. return '待提交'
  623. case 100:
  624. return '待批准'
  625. case 300:
  626. return '退回'
  627. default:
  628. return ''
  629. }
  630. }
  631. // Tabs 状态
  632. const activeTab = ref<'inspection' | 'document'>('inspection')
  633. // 根据类型分类数据
  634. const inspectionItems = computed(() => {
  635. return props.reportList.filter((item) => inspectionTypes.includes(item.reportType))
  636. })
  637. const documentItems = computed(() => {
  638. return props.reportList.filter((item) => documentTypes.includes(item.reportType))
  639. })
  640. // 当前激活的 tab 对应的数据
  641. const currentTabItems = computed(() => {
  642. return activeTab.value === 'inspection' ? inspectionItems.value : documentItems.value
  643. })
  644. // 判断是否为其他报告类型
  645. const isOtherReport = (item: ReportItemVO): boolean => {
  646. return [PressureReportType.WORKINSTRUCTION].includes(item.reportType)
  647. }
  648. // 获取其他报告类型的步骤名称
  649. const getOtherStepName = (item: ReportItemVO): string => {
  650. if(PressureReportType.WORKINSTRUCTION == item.reportType) return getWorkInstructionStepName(item)
  651. return getCurrentStepName(item)
  652. }
  653. // 独走报告关联操作指导书
  654. const isDisabledBtn = (item) => {
  655. const checkerUserIds = item.checkUsers.map(checker => checker?.id)
  656. return !(checkerUserIds?.includes(userStore?.user?.id))
  657. }
  658. </script>
  659. <style lang="scss" scoped>
  660. .inspection-item-list {
  661. height: 100%;
  662. display: flex;
  663. flex-direction: column;
  664. .capsule-tabs {
  665. display: flex;
  666. align-items: center;
  667. gap: 4px;
  668. padding: 12px 6px;
  669. background: #f5f7fa;
  670. border-radius: 8px;
  671. margin: 8px;
  672. .tab-item {
  673. flex: 1;
  674. display: flex;
  675. align-items: center;
  676. justify-content: center;
  677. gap: 6px;
  678. padding: 10px 10px;
  679. font-size: 12px;
  680. background: white;
  681. border-radius: 20px;
  682. cursor: pointer;
  683. transition: all 0.3s ease;
  684. font-size: 14px;
  685. color: #606266;
  686. font-weight: 500;
  687. border: 2px solid transparent;
  688. user-select: none;
  689. &:hover {
  690. color: #409eff;
  691. border-color: #409eff;
  692. }
  693. &.active {
  694. background: linear-gradient(135deg, #409eff 0%, #66b1ff 100%);
  695. color: white;
  696. border-color: #409eff;
  697. box-shadow: 0 2px 8px rgba(64, 158, 255, 0.3);
  698. // 激活状态下的 badge 样式调整
  699. :deep(.el-badge__content) {
  700. background-color: white;
  701. color: #409eff;
  702. border: 1px solid rgba(255, 255, 255, 0.3);
  703. }
  704. }
  705. // el-badge 样式优化
  706. :deep(.el-badge) {
  707. display: flex;
  708. align-items: center;
  709. }
  710. :deep(.el-badge__content) {
  711. transform: translateY(-50%) translateX(50%);
  712. font-weight: bold;
  713. }
  714. }
  715. }
  716. .list-content {
  717. flex: 1;
  718. overflow-y: auto;
  719. .empty-state {
  720. height: 100%;
  721. display: flex;
  722. align-items: center;
  723. justify-content: center;
  724. }
  725. .item-list {
  726. padding: 8px;
  727. .list-item {
  728. border: 1px solid #e4e7ed;
  729. border-radius: 6px;
  730. // padding: 8px 12px;
  731. margin-bottom: 6px;
  732. cursor: pointer;
  733. transition: all 0.2s;
  734. background-color: white;
  735. &:hover {
  736. border-color: #409eff;
  737. box-shadow: 0 2px 8px rgba(64, 158, 255, 0.1);
  738. .fee-btn {
  739. border-color: #409eff !important;
  740. }
  741. }
  742. &.selected {
  743. border-color: #409eff;
  744. background-color: #f0f9ff;
  745. .fee-btn {
  746. border-color: #409eff !important;
  747. }
  748. }
  749. .item-header {
  750. display: flex;
  751. // flex-direction: column;
  752. // gap: 8px;
  753. .item-title-wrapper {
  754. display: flex;
  755. align-items: center;
  756. flex-wrap: wrap;
  757. gap: 6px;
  758. line-height: 1.5;
  759. padding: 8px 12px;
  760. flex: 1;
  761. .title-content {
  762. display: flex;
  763. gap: 6px;
  764. // flex-wrap: wrap;
  765. flex: 1;
  766. min-width: 0;
  767. }
  768. .report-type-icon {
  769. display: inline-flex;
  770. align-items: center;
  771. justify-content: center;
  772. width: 20px;
  773. height: 20px;
  774. background-color: var(--el-color-primary);
  775. color: white;
  776. border-radius: 3px;
  777. font-size: 12px;
  778. font-weight: bold;
  779. flex-shrink: 0;
  780. &.main {
  781. background-color: var(--el-color-primary);
  782. }
  783. &.single {
  784. background-color: #e6a23c;
  785. }
  786. &.sub {
  787. background-color: #91d5ff;
  788. }
  789. &.subcontract {
  790. background-color: #afadf6;
  791. }
  792. &.work {
  793. background-color: #67c23a;
  794. }
  795. &.zdwtxsgz {
  796. background-color: #ff579b;
  797. }
  798. &.jyfa {
  799. background-color: #d6e645;
  800. }
  801. &.plan {
  802. background-color: #909399;
  803. }
  804. &.question {
  805. background-color: #f56c6c;
  806. }
  807. }
  808. .item-title {
  809. // display: inline-flex;
  810. // flex-wrap: wrap;
  811. font-weight: 500;
  812. color: #303133;
  813. font-size: 14px;
  814. flex: 1;
  815. > span {
  816. // display: inline-flex;
  817. // align-items: center;
  818. }
  819. .el-button {
  820. padding: 0 4px;
  821. height: auto;
  822. line-height: 1.5;
  823. font-size: 14px;
  824. vertical-align: baseline;
  825. }
  826. }
  827. }
  828. .fee-btn {
  829. display: flex;
  830. align-items: center;
  831. justify-content: center;
  832. flex-basis: 60px;
  833. border-left: 1px solid #e4e7ed;
  834. }
  835. .pl-\[28px\] {
  836. padding-left: 28px;
  837. }
  838. .status-wrapper {
  839. display: flex;
  840. align-items: center;
  841. flex-wrap: wrap;
  842. padding-left: 28px;
  843. gap: 6px;
  844. box-sizing: border-box;
  845. .el-tag {
  846. margin: 0;
  847. }
  848. }
  849. }
  850. }
  851. }
  852. }
  853. }
  854. @media (max-width: 768px) {
  855. .inspection-item-list {
  856. .capsule-tabs {
  857. padding: 10px 12px;
  858. .tab-item {
  859. padding: 8px 16px;
  860. font-size: 13px;
  861. }
  862. }
  863. .list-content .item-list .list-item {
  864. padding: 10px;
  865. .item-header {
  866. gap: 6px;
  867. .item-title-wrapper {
  868. gap: 4px;
  869. }
  870. }
  871. }
  872. }
  873. }
  874. </style>
  875. <style>
  876. /* 右键菜单全局样式 */
  877. .context-menu {
  878. position: fixed;
  879. background: white;
  880. border: 1px solid #ebeef5;
  881. border-radius: 6px;
  882. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  883. z-index: 9999;
  884. padding: 6px 0;
  885. min-width: 120px;
  886. }
  887. .context-menu .context-menu-item {
  888. display: flex;
  889. align-items: center;
  890. padding: 8px 16px;
  891. cursor: pointer;
  892. font-size: 14px;
  893. color: #606266;
  894. transition: all 0.2s;
  895. }
  896. .context-menu .context-menu-item:hover {
  897. background-color: #f5f7fa;
  898. color: #409eff;
  899. }
  900. .context-menu .context-menu-item.danger {
  901. color: #f56c6c;
  902. }
  903. .context-menu .context-menu-item.danger:hover {
  904. background-color: #fef0f0;
  905. color: #f56c6c;
  906. }
  907. .context-menu .context-menu-item.disabled {
  908. color: #c0c4cc;
  909. cursor: not-allowed;
  910. }
  911. .context-menu .context-menu-item.disabled:hover {
  912. background-color: transparent;
  913. color: #c0c4cc;
  914. }
  915. .context-menu .context-menu-item .disabled-tip {
  916. font-size: 12px;
  917. margin-left: 4px;
  918. }
  919. .context-menu .context-menu-item .el-icon {
  920. margin-right: 8px;
  921. font-size: 16px;
  922. }
  923. .context-menu .context-menu-item span {
  924. flex: 1;
  925. }
  926. .context-menu .context-menu-divider {
  927. height: 1px;
  928. background-color: #e4e7ed;
  929. margin: 6px 0;
  930. }
  931. </style>