pipeDetail.vue 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016
  1. <template>
  2. <!-- 单位基本信息 -->
  3. <div class="plan-section mb-4">
  4. <div class="section-title">
  5. <span>受检单位基本信息</span>
  6. </div>
  7. <el-descriptions :column="3" border>
  8. <el-descriptions-item label="单位名称">{{ unitInfo.unitName }}</el-descriptions-item>
  9. <el-descriptions-item label="单位地址">{{ unitInfo.unitAddress }}</el-descriptions-item>
  10. <!-- <el-descriptions-item label="使用单位联系人">{{ unitInfo.contact }}</el-descriptions-item>
  11. <el-descriptions-item label="使用单位联系电话">{{ unitInfo.contactPhone }}</el-descriptions-item>
  12. <el-descriptions-item label="区域">{{ unitInfo.equipDistrictName }}</el-descriptions-item>
  13. <el-descriptions-item label="街道">{{ unitInfo.equipStreetName }}</el-descriptions-item> -->
  14. </el-descriptions>
  15. </div>
  16. <div class="plan-section mb-4">
  17. <div class="section-title">
  18. <span>设备信息</span>
  19. </div>
  20. <!-- 搜索工作栏 -->
  21. <ContentWrap>
  22. <section class="flex gap-2">
  23. <el-form
  24. class="flex-1"
  25. :model="queryParams"
  26. ref="queryFormRef"
  27. :inline="true"
  28. label-width="135px"
  29. >
  30. <!-- 基本信息查询部分 -->
  31. <el-row :gutter="24">
  32. <el-col :span="8">
  33. <el-form-item class="!w-full !mr-0px" label="区域" prop="equipDistrict">
  34. <AreaSelect
  35. v-model="queryParams.equipDistrict"
  36. placeholder="请选择区域"
  37. class="!w-full area-select"
  38. multiple
  39. collapse-tags
  40. collapse-tags-tooltip
  41. :clearable="true"
  42. :area-type="queryParams.areaType"
  43. @clear="handleAreaClear"
  44. @change="handleAreaChange"
  45. />
  46. </el-form-item>
  47. </el-col>
  48. <el-col :span="8">
  49. <el-form-item class="!w-full !mr-0px" label="街道" prop="equipStreet">
  50. <StreetSelect
  51. v-model="queryParams.equipStreet"
  52. :district-ids="queryParams.equipDistrict"
  53. placeholder="请选择街道"
  54. multiple
  55. collapse-tags
  56. collapse-tags-tooltip
  57. :clearable="true"
  58. @clear="handleStreetClear"
  59. @change="handleStreetChange"
  60. />
  61. </el-form-item>
  62. </el-col>
  63. <!-- <el-col :span="8">-->
  64. <!-- <el-form-item class="!w-full !mr-0px" label="设备注册代码" prop="equipCode">-->
  65. <!-- <el-input-->
  66. <!-- v-model="queryParams.equipCode"-->
  67. <!-- placeholder="请输入设备注册代码"-->
  68. <!-- clearable-->
  69. <!-- @keyup.enter="handleQuery"-->
  70. <!-- />-->
  71. <!-- </el-form-item>-->
  72. <!-- </el-col>-->
  73. <!-- <el-col :span="8">
  74. <el-form-item
  75. class="!w-full !mr-0px"
  76. label="社会统一信用代码"
  77. prop="socialCreditCode"
  78. >
  79. <el-input
  80. class="!w-full"
  81. v-model="queryParams.socialCreditCode"
  82. placeholder="请输入社会统一信用代码"
  83. clearable
  84. />
  85. </el-form-item>
  86. </el-col> -->
  87. <!-- <el-col :span="8">
  88. <el-form-item class="!w-full !mr-0px" label="使用证编号" prop="useCertCode">
  89. <el-input
  90. class="!w-full"
  91. v-model="queryParams.useCertCode"
  92. placeholder="请输入使用证编号"
  93. clearable
  94. />
  95. </el-form-item>
  96. </el-col> -->
  97. <ElCollapseTransition v-if="isSearchExpanded">
  98. <el-col :span="8">
  99. <el-form-item class="!w-full !mr-0px" label="临检时间" prop="checkDate">
  100. <div class="w-full flex gap-10px">
  101. <el-select v-model="datePickerType" class="!w-[100px]">
  102. <el-option label="时间段" value="daterange" />
  103. <el-option label="月份" value="month" />
  104. </el-select>
  105. <el-date-picker
  106. v-if="datePickerType === 'daterange'"
  107. v-model="daterange"
  108. type="daterange"
  109. value-format="YYYY-MM-DD HH:mm:ss"
  110. start-placeholder="开始日期"
  111. end-placeholder="结束日期"
  112. class="flex-1"
  113. />
  114. <!-- @change="handleDateChange" -->
  115. <el-date-picker
  116. v-else
  117. v-model="month"
  118. type="month"
  119. value-format="YYYY-MM"
  120. placeholder="选择月份"
  121. class="flex-1"
  122. />
  123. <!-- @change="handleMonthChange" -->
  124. </div>
  125. </el-form-item>
  126. </el-col>
  127. </ElCollapseTransition>
  128. <ElCollapseTransition v-if="isSearchExpanded">
  129. <el-col :span="8">
  130. <el-form-item class="!w-full !mr-0px" label="部门" prop="relateDepartment">
  131. <DeptSelect
  132. class="!w-full"
  133. v-model="queryParams.relateDepartment"
  134. placeholder="请选择部门"
  135. clearable
  136. />
  137. </el-form-item>
  138. </el-col>
  139. </ElCollapseTransition>
  140. <ElCollapseTransition v-if="isSearchExpanded">
  141. <el-col :span="8">
  142. <el-form-item class="!w-full !mr-0px" label="使用状态" prop="useStatus">
  143. <el-select
  144. v-model="queryParams.useStatus"
  145. placeholder="选择使用状态"
  146. clearable
  147. collapse-tags
  148. collapse-tags-tooltip
  149. disabled
  150. >
  151. <el-option
  152. v-for="dict in getStrDictOptions(DICT_TYPE.SYSTEM_EQUIP_BOILER_STATUS)"
  153. :key="dict.value"
  154. :label="dict.label"
  155. :value="dict.value"
  156. />
  157. </el-select>
  158. </el-form-item>
  159. </el-col>
  160. </ElCollapseTransition>
  161. <ElCollapseTransition v-if="isSearchExpanded">
  162. <el-col :span="12">
  163. <el-form-item class="!w-full !mr-0px" label="管道归类" prop="typeList">
  164. <el-checkbox-group
  165. v-model="queryParams.typeList"
  166. class="flex flex-wrap gap-2"
  167. @change="handleTypeListChange"
  168. >
  169. <el-checkbox
  170. v-for="dict in containerTypeOptions"
  171. :key="dict.value"
  172. :label="dict.label"
  173. :value="dict.value"
  174. />
  175. </el-checkbox-group>
  176. </el-form-item>
  177. </el-col>
  178. </ElCollapseTransition>
  179. </el-row>
  180. </el-form>
  181. <div class="flex-[0_0_260px] flex items-start">
  182. <!-- 操作按钮 -->
  183. <el-button type="primary" @click="handleQuery">
  184. <Icon icon="ep:search" class="mr-5px" /> 搜索
  185. </el-button>
  186. <el-button @click="resetQuery">
  187. <Icon icon="ep:refresh" class="mr-5px" /> 重置
  188. </el-button>
  189. <el-button link class="!h-[32px] flex" @click="isSearchExpanded = !isSearchExpanded">
  190. <el-icon>
  191. <ArrowUp v-if="isSearchExpanded" />
  192. <ArrowDown v-else />
  193. </el-icon>
  194. {{ isSearchExpanded ? '收起' : '展开' }}
  195. </el-button>
  196. </div>
  197. </section>
  198. </ContentWrap>
  199. <!-- 列表 -->
  200. <ContentWrap>
  201. <el-row class="mb-2">
  202. <!-- <el-button
  203. type="primary"
  204. @click="() => handleBatchSchedule('regular')"
  205. :disabled="selectedRows.length === 0"
  206. >
  207. <Icon icon="ep:calendar" class="mr-5px" /> 定期约检
  208. </el-button>
  209. <el-button
  210. type="primary"
  211. @click="() => handleBatchSchedule('year')"
  212. :disabled="selectedRows.length === 0"
  213. >
  214. <Icon icon="ep:calendar" class="mr-5px" /> 年度约检
  215. </el-button>
  216. <el-button
  217. type="primary"
  218. @click="() => handleBatchSchedule('expired')"
  219. :disabled="selectedRows.length === 0"
  220. >
  221. <Icon icon="ep:calendar" class="mr-5px" /> 超年限约检
  222. </el-button>
  223. <el-button
  224. type="primary"
  225. @click="() => handleBatchSchedule('')"
  226. :disabled="selectedRows.length === 0"
  227. >
  228. <Icon icon="ep:calendar" class="mr-5px" /> 批量排期
  229. </el-button>-->
  230. <el-button
  231. type="primary"
  232. @click="() => handleBatchSchedule('')"
  233. :disabled="selectedRows.length === 0"
  234. >约检
  235. </el-button>
  236. <el-button type="primary" @click="handleBatchEditFn" :disabled="selectedRows.length === 0">
  237. <Icon icon="ep:edit" class="mr-5px" /> 批量修改约检联系人
  238. </el-button>
  239. <el-button type="primary" @click="() => handleToRoute('AcceptOrder1')">约检单</el-button>
  240. <el-button type="primary" @click="() => handleToRoute('TaskOrder')">任务单</el-button>
  241. </el-row>
  242. <el-table
  243. v-loading="loading"
  244. ref="tableRef"
  245. :data="list"
  246. border
  247. @selection-change="handleSelectionChange"
  248. @sort-change="handleSortChange"
  249. :row-key="(row) => row.id"
  250. :row-class-name="getMainRowClassName"
  251. @row-click="handleMainRowClick"
  252. >
  253. <el-table-column type="selection" width="50" fixed="left"/>
  254. <el-table-column type="expand" width="1">
  255. <template #default="props">
  256. <div class="ml-15px mr-15px">
  257. <el-table :data="props.row.detailSaveReqVOS" border
  258. :header-cell-style="{background: '#f5f7fa', color: '#606266'}"
  259. :ref="(el) => setDetailTableRef(el, props.row.id)"
  260. @selection-change="(selection) => handleDetailSelectionChange(selection, props.row)"
  261. :row-class-name="getRowClassName"
  262. class="inner-table"
  263. @row-click="handleRowClick"
  264. >
  265. <el-table-column type="selection" width="50" fixed="left"/>
  266. <el-table-column type="index" label="序号" width="60" align="center" :index="indexMethod1" />
  267. <el-table-column label="注册代码" prop="equipCode" min-width="120" show-overflow-tooltip/>
  268. <el-table-column label="管道名称" prop="pipeName" min-width="120" show-overflow-tooltip/>
  269. <el-table-column label="管道编号" prop="pipeNo" min-width="120" show-overflow-tooltip/>
  270. <el-table-column label="管道级别" prop="pipeLevel" min-width="120" show-overflow-tooltip/>
  271. <el-table-column label="管道品种" prop="pipeType" min-width="120" show-overflow-tooltip/>
  272. <el-table-column label="长度" prop="pipeLength" min-width="100" show-overflow-tooltip/>
  273. <el-table-column label="管道材质" prop="pipeMaterial" min-width="120" show-overflow-tooltip/>
  274. <el-table-column label="材料标准" prop="materialStandard" min-width="120" show-overflow-tooltip/>
  275. <el-table-column label="定期安全状况等级" prop="legalSafetyStatusLevel" min-width="130" show-overflow-tooltip/>
  276. <el-table-column label="年度安全状况等级" prop="yearSafetyStatusLevel" min-width="130" show-overflow-tooltip/>
  277. <el-table-column label="下次定期检验" prop="nextLegalCheckDate" align="center" min-width="160" show-overflow-tooltip>
  278. <template #default="{ row }">
  279. <div>
  280. <div v-if="row.nextLegalCheckDate">
  281. <span
  282. class="text-xs">{{
  283. formatDate(row.nextLegalCheckDate, 'YYYY-MM-DD')
  284. }}</span>
  285. <div v-if="row.planLegalCheckDate" class="text-xs text-[#2D5FBD]">
  286. (排期时间:{{ row.planLegalCheckDate }})
  287. </div>
  288. </div>
  289. <span v-else>-</span>
  290. </div>
  291. </template>
  292. </el-table-column>
  293. <el-table-column label="下次年度检查" prop="nextYearCheckDate" align="center" min-width="160"
  294. show-overflow-tooltip>
  295. <template #default="{ row }">
  296. <div>
  297. <div v-if="row.nextYearCheckDate">
  298. <span
  299. class="text-xs">{{
  300. formatDate(row.nextYearCheckDate, 'YYYY-MM-DD')
  301. }}</span>
  302. <div v-if="row.planYearCheckDate" class="text-xs text-[#2D5FBD]">
  303. (排期时间:{{ row.planYearCheckDate }})
  304. </div>
  305. </div>
  306. <span v-else>-</span>
  307. </div>
  308. </template>
  309. </el-table-column>
  310. </el-table>
  311. </div>
  312. </template>
  313. </el-table-column>
  314. <el-table-column type="index" label="序号" width="60" align="center" :index="indexMethod" />
  315. <el-table-column
  316. label="工程号"
  317. align="center"
  318. prop="projectNo"
  319. min-width="120"
  320. >
  321. <template #default="{ row }">
  322. <div
  323. v-if="row.projectNo"
  324. class="cursor-pointer"
  325. @click.stop="toggleExpand(row)"
  326. >
  327. <div class="flex items-center justify-center gap-1 schedule-link">
  328. <span class="text-xs color-blue">{{row.projectNo}}</span>
  329. </div>
  330. </div>
  331. </template>
  332. </el-table-column>
  333. <el-table-column label="工程名称"
  334. align="center"
  335. prop="projectName"
  336. min-width="120"
  337. show-overflow-tooltip
  338. />
  339. <el-table-column
  340. label="下次定期检验"
  341. align="center"
  342. prop="nextLegalCheckDate"
  343. min-width="140"
  344. sortable="custom"
  345. >
  346. <template #default="{ row }">
  347. <div
  348. v-if="row.nextLegalCheckDate"
  349. >
  350. <!-- class="cursor-pointer">-->
  351. <!-- @click="handleSingleSchedule(row, 'year')" > -->
  352. <!-- <div class="flex items-center justify-center gap-1 schedule-link">-->
  353. <div class="flex items-center justify-center gap-1">
  354. <span class="text-xs">{{formatDate(row.nextLegalCheckDate, 'YYYY-MM-DD')}}</span>
  355. <!-- <Icon icon="ep:calendar" class="text-xs" />-->
  356. </div>
  357. <!-- <div v-if="row.yearRefuseReasonDict || row.yearRefuseReason" class="text-xs text-red-500 mt-1">
  358. (拒绝检验:{{
  359. getRefuseResonText(row.yearRefuseReasonDict, row.yearRefuseReason)
  360. }})
  361. </div>
  362. <div v-else-if="row.yearAcceptDate" class="text-xs text-[#3D9E5F] mt-1">
  363. (已受理:{{ formatArrayDate(row.yearAcceptDate) }})
  364. </div>
  365. <div v-else-if="row.yearAppointmentDate" class="text-xs text-[#FF9A3D] mt-1">
  366. (待约检:{{ formatArrayDate(row.yearAppointmentDate) }})
  367. </div>-->
  368. <div v-if="row.planLegalCheckDate" class="text-xs text-[#2D5FBD] mt-1">
  369. (排期时间:{{ row.planLegalCheckDate }})
  370. </div>
  371. </div>
  372. <span v-else>-</span>
  373. </template>
  374. </el-table-column>
  375. <el-table-column
  376. label="下次年度检查"
  377. align="center"
  378. prop="nextYearCheckDate"
  379. min-width="150"
  380. sortable="custom"
  381. >
  382. <template #default="{ row }">
  383. <div
  384. v-if="row.nextYearCheckDate"
  385. >
  386. <!-- class="cursor-pointer"> -->
  387. <!-- @click="handleSingleSchedule(row, 'expired')" > -->
  388. <!-- <div class="flex items-center justify-center gap-1 schedule-link">-->
  389. <div class="flex items-center justify-center gap-1">
  390. <span class="text-xs">{{ formatDate(row.nextYearCheckDate, 'YYYY-MM-DD') }}</span>
  391. <!-- <Icon icon="ep:calendar" class="text-xs" />-->
  392. </div>
  393. <!-- <div v-if="row.expiredReasonDict || row.expiredRefuseReason" class="text-xs text-red-500 mt-1">-->
  394. <!-- (拒绝检验:{{-->
  395. <!-- getRefuseResonText(row.expiredReasonDict, row.expiredRefuseReason)-->
  396. <!-- }})-->
  397. <!-- </div>-->
  398. <!-- <div v-else-if="row.expiredAcceptDate" class="text-xs text-[#3D9E5F] mt-1">-->
  399. <!-- (已受理:{{ formatArrayDate(row.expiredAcceptDate) }})-->
  400. <!-- </div>-->
  401. <!-- <div v-else-if="row.expiredAppointmentDate" class="text-xs text-[#FF9A3D] mt-1">-->
  402. <!-- (待约检:{{ formatArrayDate(row.expiredAppointmentDate) }})-->
  403. <!-- </div>-->
  404. <div v-if="row.planYearCheckDate" class="text-xs text-[#2D5FBD] mt-1">
  405. (排期时间:{{ row.planYearCheckDate }})
  406. </div>
  407. </div>
  408. <span v-else>-</span>
  409. </template>
  410. </el-table-column>
  411. <!-- 区域 -->
  412. <el-table-column
  413. label="区域/街道"
  414. align="center"
  415. prop="pipeStreet"
  416. min-width="120"
  417. show-overflow-tooltip
  418. >
  419. <template #default="{ row }">
  420. <span class="text-xs">{{ row.equipStreetName ?? row.equipDistrictName}}</span>
  421. </template>
  422. </el-table-column>
  423. <!-- 管道类别 -->
  424. <el-table-column label="管道类别" align="center" prop="pipeCategory">
  425. <template #default="scope">
  426. {{ containerTypeOptions.find(i => i.value == scope.row.pipeCategory)?.label }}
  427. </template>
  428. </el-table-column>
  429. <el-table-column
  430. label="约检联系人"
  431. align="center"
  432. prop="contact"
  433. min-width="120"
  434. show-overflow-tooltip
  435. />
  436. <el-table-column
  437. label="约检联系人电话"
  438. align="center"
  439. prop="contactPhone"
  440. min-width="140"
  441. show-overflow-tooltip
  442. />
  443. </el-table>
  444. <!-- 分页 -->
  445. <Pagination
  446. :total="total"
  447. v-model:page="queryParams.pageNo"
  448. v-model:limit="queryParams.pageSize"
  449. @pagination="handleQuery"
  450. />
  451. </ContentWrap>
  452. </div>
  453. <!-- 约检弹窗 -->
  454. <PlanScheduleEquipPipeDialog
  455. ref="planScheduleEquipPipeDialogRef"
  456. :source="200"
  457. :equip-list="selectedRows"
  458. :equip-detail-list="selectedDetailRows"
  459. :unitInfo="unitInfo"
  460. @success="handleScheduleSuccess"
  461. />
  462. <PipeBatchEditForm ref="formRef" @success="handleScheduleSuccess" />
  463. </template>
  464. <script setup lang="ts" name="PlanNewDetail">
  465. import {DICT_TYPE, getStrDictOptions, StringDictDataType} from '@/utils/dict'
  466. import {useMessage} from '@/hooks/web/useMessage'
  467. import {PlanNewPageVO} from '@/api/pressure/planScheduling'
  468. import AreaSelect from '../../system/equipcontainer/components/AreaSelect.vue'
  469. import StreetSelect from '../../system/equipcontainer/components/StreetSelect.vue'
  470. import DeptSelect from './components/DeptSelect.vue'
  471. import dayjs from 'dayjs'
  472. import {useUserStore} from '@/store/modules/user'
  473. import {formatArrayDate, formatDate} from '@/utils/formatTime'
  474. import PipeBatchEditForm from './components/PipeBatchEditForm.vue'
  475. import {cloneDeep} from 'lodash-es'
  476. import {isEmpty} from '@/utils/is'
  477. import {useRouter} from 'vue-router'
  478. import {usePlanNewStore} from '@/store/modules/planNew'
  479. import {ArrowDown, ArrowUp} from '@element-plus/icons-vue'
  480. import {EquipBoilerSchedulingEquipVO} from "@/api/pressure2/equipboilerscheduling";
  481. import {
  482. PipeEquipmentApi,
  483. PipeEquipmentDetailVO,
  484. PipeEquipmentVO
  485. } from "@/api/pressure2/pipeequipment";
  486. import PlanScheduleEquipPipeDialog
  487. from "./components/PlanScheduleEquipPipeDialog.vue";
  488. import {EquipPipeSchedulingApi, PipePlanSchedulingVO} from "@/api/pressure2/pipescheduling";
  489. import PlanScheduleBoilerDialog
  490. from "@/views/pressure2/planNew/components/PlanScheduleEquipBoilerDialog.vue";
  491. const router = useRouter()
  492. const props = defineProps({
  493. source: {
  494. type: String as PropType<string>,
  495. default: 'pressure'
  496. }
  497. })
  498. const currentDefaultYear = [
  499. dayjs().startOf('year').format('YYYY-MM-DD HH:mm:ss'),
  500. dayjs().endOf('year').format('YYYY-MM-DD HH:mm:ss')
  501. ]
  502. const message = useMessage()
  503. const userStore = useUserStore()
  504. const datePickerType = ref<'daterange' | 'month'>('month') // 修改时间选择类型定义
  505. const daterange = ref<string[]>([]) // 日期选择值
  506. const month = ref<string>('') // 月份选择值
  507. const areaStreetMap = ref(new Map<number, number[]>()) // 记录每个区域下已选择的街道
  508. const loading = ref(false) // 列表的加载中
  509. const equipIds = ref<string[]>([]) // 设备ID列表
  510. const list = ref<PipeEquipmentVO[]>([]) // 列表的数据
  511. const total = ref(0) // 列表的总页数
  512. const selectedRows = ref<PipeEquipmentVO[]>([]) // 选中的行
  513. const selectedDetailRows = ref<PipeEquipmentDetailVO[]>([]) // 选中的行
  514. const planScheduleEquipPipeDialogRef = ref<InstanceType<typeof PlanScheduleEquipPipeDialog>>() // 计划排期弹窗引用
  515. const selectedTypeList = ref<StringDictDataType[]>([]) // 选中的容器归类
  516. const formRef = ref()
  517. // 单位基本信息
  518. const unitInfo = ref({
  519. unitId: '',
  520. unitName: '',
  521. unitAddress: '',
  522. contact: '',
  523. contactPhone: '',
  524. equipDistrictName: '',
  525. equipStreetName: ''
  526. })
  527. const equipTypeMap = {
  528. 1: '容器'
  529. }
  530. const tableRef = ref()
  531. // 拒绝原因
  532. const refuseInspectedCategoryOptions = getStrDictOptions('refuseInspectedCategory')
  533. const getRefuseResonText = (dictCode: string, value: string) => {
  534. const resonObj = refuseInspectedCategoryOptions.find((item) => item.value === dictCode)
  535. return value || resonObj?.label || dictCode
  536. }
  537. const queryParams = ref<Recordable>({
  538. pageNo: 1,
  539. pageSize: 20,
  540. equipCode: undefined as string | undefined,
  541. productNo: undefined as string | undefined,
  542. relateDepartment: undefined as string | string[] | undefined,
  543. equipDistrict: undefined as number[] | undefined,
  544. equipStreet: undefined as number[] | undefined,
  545. typeList: [] as string[],
  546. nextDate: [] as string[],
  547. useStatus: '100',
  548. areaType: 'all' as 'all' | 'gz'
  549. })
  550. const queryFormRef = ref() // 搜索的表单
  551. // 添加容器类型字典选项变量
  552. const containerTypeOptions = getStrDictOptions(DICT_TYPE.PIPE_TYPE)
  553. // 单条/批量排期相关
  554. const currentEquip = ref<PipeEquipmentVO>()
  555. const currentCheckType = ref<scheduleType>('')
  556. // 存储所有子表引用的对象
  557. const detailTableRefs = ref<Record<string, any>>({})
  558. const setDetailTableRef = (el: any, parentId: string) => {
  559. if (el) {
  560. detailTableRefs.value[parentId] = el;
  561. }
  562. }
  563. const getDetailTableRef = (parentId: string) => {
  564. return detailTableRefs.value[parentId];
  565. }
  566. const getMainRowClassName = ({row}) => {
  567. const isSelected = tableRef.value?.getSelectionRows().some((item) =>
  568. item.id === row.id
  569. )
  570. return isSelected ? 'selected-row' : ''
  571. }
  572. const getRowClassName = ({row}) => {
  573. // 找到当前行所在的分组,从 Map 中获取对应的表格实例
  574. const tableRef = getDetailTableRef(row.equipPipeId)
  575. if (tableRef) {
  576. const isSelected = tableRef.getSelectionRows().some((item) =>
  577. item.id === row.id
  578. )
  579. return isSelected ? 'selected-row' : ''
  580. }
  581. return ''
  582. }
  583. /** 处理行点击勾选 */
  584. const handleMainRowClick = (row) => {
  585. tableRef.value?.toggleRowSelection(row)
  586. }
  587. const handleRowClick = (row, event, column) => {
  588. // 如果点击的是选择列,不处理
  589. if (column.type === 'selection') {
  590. return
  591. }
  592. // 找到当前行所在的分组,从 Map 中获取对应的表格实例
  593. const tableRef = getDetailTableRef(row.equipPipeId)
  594. if (tableRef && tableRef.toggleRowSelection) {
  595. tableRef.toggleRowSelection(row)
  596. }
  597. }
  598. /** 打开弹窗 */
  599. const open = async (row: PlanNewPageVO) => {
  600. equipIds.value = [...new Set([row.equipIds, row.yearEquipIds, row.expiredEquipIds])]
  601. .filter((id) => id) // 过滤掉 null、undefined、空字符串
  602. .join(',')
  603. .split(',')
  604. // 设置单位信息
  605. unitInfo.value = {
  606. unitId: row.unitId || '',
  607. unitName: row.unitName || '',
  608. unitAddress: row.unitAddress || '',
  609. contact: row.contact || '',
  610. contactPhone: row.contactPhone || '',
  611. equipDistrictName: row.equipDistrictName || '',
  612. equipStreetName: row.equipStreetName || ''
  613. }
  614. // 初始化查询参数
  615. queryParams.value = {
  616. ...queryParams.value,
  617. unitCode: row.unitCode,
  618. unitName: row.unitName || '',
  619. unitId: row.unitId || '',
  620. }
  621. // 查询设备列表
  622. await handleQuery()
  623. }
  624. const indexMethod = (index: number) => {
  625. return index + 1
  626. }
  627. const indexMethod1 = (index: number) => {
  628. return index + 1
  629. }
  630. /**获取查询参数 */
  631. const getQueryParams = () => {
  632. const params = cloneDeep({
  633. scene: 0,
  634. pageNo: queryParams.value.pageNo,
  635. pageSize: queryParams.value.pageSize,
  636. unitCode: queryParams.value.unitCode,
  637. // unitName: queryParams.value.unitName,
  638. unitId: queryParams.value.unitId,
  639. // equipIds: equipIds.value,
  640. equipCode: queryParams.value.equipCode,
  641. relateDepartment: queryParams.value.relateDepartment,
  642. productNo: queryParams.value.productNo,
  643. equipDistrict: queryParams.value.equipDistrict,
  644. equipStreet: queryParams.value.equipStreet,
  645. pipeCategory: queryParams.value.typeList?.length === 1 ? queryParams.value.typeList[0] : undefined,
  646. pipeCategorys: queryParams.value.typeList || [],
  647. typeList: queryParams.value.typeList || [],
  648. nextDate: (queryParams.value.nextDate || []).map((item) => dayjs(item).valueOf()),
  649. useStatus: queryParams.value.useStatus ? [+queryParams.value.useStatus] : []
  650. })
  651. if (datePickerType.value === 'daterange') {
  652. params.nextDate = daterange.value ? daterange.value.map((item) => dayjs(item).valueOf()) : []
  653. } else if (datePickerType.value === 'month') {
  654. params.nextDate = month.value
  655. ? [dayjs(month.value).startOf('month').valueOf(), dayjs(month.value).endOf('month').valueOf()]
  656. : []
  657. }
  658. // 移除空值
  659. Object.keys(params).forEach((key) => {
  660. if (isEmpty(params[key])) {
  661. delete params[key]
  662. }
  663. })
  664. return params
  665. }
  666. const isSearchExpanded = ref(false)
  667. /** 搜索按钮操作 */
  668. const handleQuery = async () => {
  669. loading.value = true
  670. try {
  671. // 关闭所有已展开的行
  672. expandRows.value.forEach(row => {
  673. tableRef.value?.toggleRowExpansion(row, false)
  674. })
  675. // 清空展开行记录
  676. expandRowKeys.value = []
  677. expandRows.value = []
  678. selectedRows.value = []
  679. selectedDetailRows.value = []
  680. const params = getQueryParams()
  681. // 调用后端API获取数据
  682. const res = await EquipPipeSchedulingApi.getPlanSchedulingPipesList(params)
  683. console.log(res)
  684. list.value = res.list
  685. total.value = res.total
  686. } finally {
  687. loading.value = false
  688. }
  689. }
  690. /** 重置按钮操作 */
  691. const resetQuery = () => {
  692. queryFormRef.value.resetFields()
  693. // 重置页码
  694. queryParams.value.pageNo = 1
  695. // 清空选中的容器归类对象
  696. selectedTypeList.value = []
  697. // 重置日期值
  698. datePickerType.value = 'daterange'
  699. // daterange.value = [dayjs().startOf('year').format('YYYY-MM-DD HH:mm:ss'), dayjs().endOf('year').format('YYYY-MM-DD HH:mm:ss')]
  700. daterange.value = []
  701. month.value = ''
  702. // 重新查询
  703. handleQuery()
  704. }
  705. /** 处理子表选择变化 */
  706. const handleDetailSelectionChange = (selection: any[], mainRow: PipeEquipmentVO) => {
  707. selectedDetailRows.value = selectedDetailRows.value.filter((item) => item.equipPipeId !== mainRow.id)
  708. selectedDetailRows.value = [...selectedDetailRows.value.filter(row => !selection.some(sel => sel.id === row.id)), ...selection]
  709. // tableRef.value.toggleRowSelection(mainRow, true)
  710. // 如果子表有选中项,则自动选中主表行;否则取消选中主表行
  711. nextTick(() => {
  712. if (selection.length > 0) {
  713. // 子表有选中项,选中主表行
  714. tableRef.value.toggleRowSelection(mainRow, true);
  715. }else if (!selectedDetailRows.value.map(row => row.equipPipeId).includes(mainRow.id)){
  716. const currentlySelected = selectedRows.value.some(row => row.id === mainRow.id);
  717. if (currentlySelected && selection.length === 0) {
  718. // 只有当主行当前是选中状态且子表没有任何选中项时才取消主行选择
  719. tableRef.value.toggleRowSelection(mainRow,false);
  720. }
  721. }
  722. });
  723. }
  724. /** 表格选择框变化 */
  725. const handleSelectionChange = async (selection: PipeEquipmentVO[]) => {
  726. // 计算取消选择的行
  727. const deselectedRows = selectedRows.value.filter(
  728. item => !selection.includes(item)
  729. );
  730. selectedRows.value = selection
  731. // 每一个勾选了主表的要找到对应的子表
  732. for (const item of selection) {
  733. // 如果没有子表,展开当前子表
  734. if (!expandRowKeys.value.includes(item.id)) {
  735. await toggleExpand(item)
  736. }
  737. // 如果没有勾选,勾选子表
  738. if (selectedDetailRows.value.findIndex(selectedDetailRow => selectedDetailRow.equipPipeId === item.id) === -1){
  739. getDetailTableRef(item.id)?.toggleAllSelection(true)
  740. }
  741. }
  742. deselectedRows.forEach(item => {
  743. getDetailTableRef(item.id)?.clearSelection()
  744. })
  745. }
  746. type scheduleType = 'regular' | 'year' | ''
  747. /** 处理单条记录排期 */
  748. const handleSingleSchedule = (row: PipeEquipmentVO, type: scheduleType) => {
  749. currentEquip.value = row
  750. currentCheckType.value = type
  751. planScheduleEquipPipeDialogRef.value?.open()
  752. }
  753. /** 处理批量排期 */
  754. const handleBatchSchedule = (type: scheduleType) => {
  755. if (selectedDetailRows.value.length === 0) {
  756. message.warning('请至少选择一条记录')
  757. return
  758. }
  759. currentCheckType.value = type
  760. planScheduleEquipPipeDialogRef.value?.open(type)
  761. }
  762. /** 处理批量修改 */
  763. const handleBatchEditFn = () => {
  764. if (selectedRows.value.length === 0) {
  765. message.warning('请至少选择一条记录')
  766. return
  767. }
  768. formRef.value.open(selectedRows.value, '1')
  769. }
  770. /** 约检单/任务单 跳转查询 */
  771. const handleToRoute = (routeName: 'AcceptOrder1' | 'TaskOrder') => {
  772. const { unitName } = unref(currentCheckData) || {}
  773. router.push({
  774. name: routeName,
  775. query: {
  776. unitName: unitName,
  777. filterCancel: '400'
  778. }
  779. })
  780. }
  781. /** 排期成功处理 */
  782. const handleScheduleSuccess = () => {
  783. selectedRows.value = []
  784. handleQuery()
  785. }
  786. /** 处理容器归类变化 */
  787. const handleTypeListChange = (values: string[]) => {
  788. selectedTypeList.value = containerTypeOptions.filter((dict) => values.includes(dict.value))
  789. }
  790. /** 处理表格排序 */
  791. const handleSortChange = ({ prop, order }) => {
  792. if (!prop || !order) {
  793. list.value.sort((a, b) => 0) // 重置排序
  794. return
  795. }
  796. list.value.sort((a, b) => {
  797. const aValue = a[prop] || ''
  798. const bValue = b[prop] || ''
  799. if (order === 'ascending') {
  800. return aValue > bValue ? 1 : -1
  801. } else {
  802. return aValue < bValue ? 1 : -1
  803. }
  804. })
  805. }
  806. /** 处理区域变化 */
  807. const handleAreaChange = (areas: number[]) => {
  808. // 获取移除的区域(通过比较之前的区域列表和现在的区域列表)
  809. const prevAreas = Array.from(areaStreetMap.value.keys())
  810. const removedAreas = prevAreas.filter((area) => !areas.includes(area))
  811. // 移除取消选择的区域下的街道
  812. if (removedAreas.length > 0) {
  813. const currentStreets = queryParams.value.equipStreet || []
  814. removedAreas.forEach((areaId) => {
  815. const streetsToRemove = areaStreetMap.value.get(areaId) || []
  816. // 从当前选中的街道中移除这些街道
  817. queryParams.value.equipStreet = currentStreets.filter(
  818. (streetId) => !streetsToRemove.includes(streetId)
  819. )
  820. // 从映射中移除该区域
  821. areaStreetMap.value.delete(areaId)
  822. })
  823. }
  824. }
  825. /** 处理区域清空 */
  826. const handleAreaClear = () => {
  827. // 清空所有选中的街道
  828. queryParams.value.equipStreet = []
  829. // 清空区域-街道映射
  830. areaStreetMap.value.clear()
  831. }
  832. /** 处理街道变化 */
  833. const handleStreetChange = (streets: number[], areaId: number) => {
  834. // 更新区域-街道映射
  835. if (queryParams.value.equipDistrict?.includes(areaId)) {
  836. areaStreetMap.value.set(areaId, streets)
  837. }
  838. }
  839. /** 处理街道清空 */
  840. const handleStreetClear = () => {
  841. // 清空所有区域下的街道选择
  842. areaStreetMap.value.clear()
  843. }
  844. /** 处理日期变化 */
  845. const handleDateChange = (val: [string, string] | null) => {
  846. daterange.value = val || []
  847. queryParams.value.nextDate = val
  848. ? [
  849. dayjs(val[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss'),
  850. dayjs(val[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss')
  851. ]
  852. : []
  853. }
  854. /** 处理月份变化 */
  855. const handleMonthChange = (val: string | null) => {
  856. if (!val) {
  857. queryParams.value.nextDate = []
  858. return
  859. }
  860. const date = dayjs(val)
  861. queryParams.value.nextDate = [
  862. date.startOf('month').format('YYYY-MM-DD HH:mm:ss'),
  863. date.endOf('month').format('YYYY-MM-DD HH:mm:ss')
  864. ]
  865. month.value = val
  866. }
  867. // 已展开行
  868. const expandRowKeys = ref<string[]>([])
  869. const expandRows = ref([])
  870. const toggleExpand = async (row: any) => {
  871. const key = row.id
  872. // 第一次点击展开,第二次点击同一行收起
  873. if (expandRowKeys.value.includes(key)) {
  874. expandRowKeys.value = expandRowKeys.value.filter((key) => key !== key)
  875. expandRows.value = expandRows.value.filter((row) => row.id !== key)
  876. selectedDetailRows.value = selectedDetailRows.value.filter((row) => row.equipPipeId !== key)
  877. tableRef.value.toggleRowExpansion(row, false)
  878. tableRef.value.toggleRowSelection(row, false)
  879. } else {
  880. expandRowKeys.value.push(key)
  881. expandRows.value.push(row)
  882. tableRef.value.toggleRowExpansion(row, true)
  883. await EquipPipeSchedulingApi.getPipeEquipmentDetailListByPipeEquipmentId( key,{equipIds:[]}).then((res) => {
  884. let find = list.value.find(item => item.id === key);
  885. find.detailSaveReqVOS = res.list
  886. })
  887. }
  888. }
  889. // 监听日期类型变化
  890. watch(datePickerType, (newVal) => {
  891. // 清空日期相关字段
  892. // daterange.value = newVal === 'daterange' ? daterange.value = cloneDeep(currentDefaultYear) : []
  893. daterange.value = []
  894. month.value = ''
  895. queryParams.value.nextDate = []
  896. })
  897. const { getPlanNewData } = usePlanNewStore()
  898. const currentCheckData = ref<PlanNewPageVO>()
  899. onMounted(() => {
  900. const { id } = (router.currentRoute.value.query || {}) as unknown as { id: string }
  901. const data = getPlanNewData(id)
  902. if (data) {
  903. currentCheckData.value = data
  904. open(data)
  905. }
  906. })
  907. defineExpose({
  908. open
  909. })
  910. </script>
  911. <style lang="scss" scoped>
  912. .plan-section {
  913. padding: 16px;
  914. border: 1px solid #ebeef5;
  915. border-radius: 4px;
  916. .section-title {
  917. display: flex;
  918. padding: 8px 16px;
  919. margin: -16px -16px 16px;
  920. font-weight: bold;
  921. background-color: #f5f7fa;
  922. border-bottom: 1px solid #ebeef5;
  923. align-items: center;
  924. }
  925. }
  926. .schedule-link {
  927. color: var(--el-color-primary);
  928. &:hover {
  929. color: var(--el-color-primary-light-3);
  930. }
  931. }
  932. :deep(.area-select) {
  933. .area-cascader {
  934. flex: 1;
  935. }
  936. }
  937. :deep(.el-table__expand-icon) {
  938. display: none !important;
  939. }
  940. :deep(.inner-table .el-checkbox__input.is-checked .el-checkbox__inner),
  941. :deep(.inner-table .el-checkbox__input.is-indeterminate .el-checkbox__inner) {
  942. background-color: #67c23a; // 绿色
  943. border-color: #67c23a;
  944. }
  945. :deep(.selected-row){
  946. background-color: #ecf5ff !important;
  947. }
  948. // 子表选中行特殊背景色(浅绿色)
  949. :deep(.inner-table .selected-row) {
  950. background-color: #e8f5e9 !important;
  951. }
  952. </style>