index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <ContentWrap>
  3. <!-- 搜索工作栏 -->
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="120px"
  10. >
  11. <el-row :gutter="20" class="flex-wrap" style="margin-right: 0">
  12. <el-form-item label="工程号" prop="projectNo">
  13. <el-input
  14. v-model="queryParams.projectNo"
  15. placeholder="请输入工程号"
  16. clearable
  17. @keyup.enter="handleQuery"
  18. class="!w-240px"
  19. />
  20. </el-form-item>
  21. <el-form-item label="使用单位名称" prop="unitName">
  22. <el-input
  23. v-model="queryParams.unitName"
  24. placeholder="请输入使用单位名称"
  25. clearable
  26. @keyup.enter="handleQuery"
  27. class="!w-240px"
  28. />
  29. </el-form-item>
  30. <el-form-item label="使用登记证编号" prop="certificateNo">
  31. <el-input
  32. v-model="queryParams.certificateNo"
  33. placeholder="请输入使用登记证编号"
  34. clearable
  35. @keyup.enter="handleQuery"
  36. class="!w-240px"
  37. />
  38. </el-form-item>
  39. <el-form-item label="报告编号" prop="reportNo">
  40. <el-input
  41. v-model="queryParams.reportNo"
  42. placeholder="请输入报告编号"
  43. clearable
  44. @keyup.enter="handleQuery"
  45. class="!w-240px"
  46. />
  47. </el-form-item>
  48. </el-row>
  49. <el-row :gutter="20" class="flex-wrap" style="margin-right: 0">
  50. <el-form-item label="审核状态" prop="status">
  51. <el-select
  52. multiple
  53. v-model="queryParams.status"
  54. placeholder="请选择审核状态"
  55. clearable
  56. class="!w-240px"
  57. >
  58. <el-option label="审核中" value="100" />
  59. <el-option label="已通过" value="200" />
  60. <el-option label="已拒绝" value="300" />
  61. </el-select>
  62. </el-form-item>
  63. <el-form-item label="部门" prop="deptId">
  64. <DeptSelect
  65. v-model="queryParams.deptId"
  66. placeholder="请选择部门"
  67. clearable
  68. class="!w-240px"
  69. />
  70. </el-form-item>
  71. <el-form-item label="是否办证" prop="hasCertificateNo">
  72. <el-select
  73. v-model="queryParams.hasCertificateNo"
  74. placeholder="请选择是否办证"
  75. clearable
  76. class="!w-240px"
  77. >
  78. <el-option label="已办证" value="1" />
  79. <el-option label="未办证" value="0" />
  80. </el-select>
  81. </el-form-item>
  82. </el-row>
  83. <el-row class="flex justify-end mt-2">
  84. <el-form-item>
  85. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  86. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  87. <el-button
  88. type="primary"
  89. plain
  90. @click="handleExport"
  91. :loading="exportLoading"
  92. >
  93. <Icon icon="ep:download" class="mr-5px" /> 导出
  94. </el-button>
  95. <!-- <el-button-->
  96. <!-- type="primary"-->
  97. <!-- plain-->
  98. <!-- @click="generateTest()"-->
  99. <!-- >-->
  100. <!-- <Icon icon="ep:plus" class="mr-5px" /> 新增-->
  101. <!-- </el-button>-->
  102. </el-form-item>
  103. </el-row>
  104. </el-form>
  105. </ContentWrap>
  106. <!-- 列表 -->
  107. <ContentWrap>
  108. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" border @selection-change="handleSelectionChange">
  109. <el-table-column type="selection" align="center" width="40" />
  110. <el-table-column type="index" label="序号" align="center" width="60" />
  111. <el-table-column label="工程号" align="center" prop="projectNo" min-width="180px"/>
  112. <el-table-column label="使用单位名称" align="center" prop="unitName" min-width="270px"/>
  113. <el-table-column label="报告编号" align="center" prop="reportNo" min-width="180px"/>
  114. <!-- <el-table-column label="使用登记证编号" align="center" prop="certificateNo" min-width="200px"/>-->
  115. <el-table-column
  116. label="申请日期"
  117. align="center"
  118. prop="submitTime"
  119. :formatter="dateFormatter"
  120. width="160px"
  121. >
  122. <template #default="{ row }">
  123. <div>{{ formatDate(row.submitTime) }}</div>
  124. </template>
  125. </el-table-column>
  126. <el-table-column
  127. label="审核日期"
  128. align="center"
  129. prop="approvalTime"
  130. :formatter="dateFormatter"
  131. width="160px"
  132. >
  133. <template #default="{ row }">
  134. {{ formatDate(row.approvalTime) }}
  135. </template>
  136. </el-table-column>
  137. <!-- <el-table-column label="审核人" align="center" prop="approvalName" min-width="100px">-->
  138. <!-- <template #default="{ row }">-->
  139. <!-- <div>{{ row.approvalName || '-' }}</div>-->
  140. <!-- </template>-->
  141. <!-- </el-table-column>-->
  142. <!-- <el-table-column label="提交人" align="center" prop="submitName" min-width="100px">-->
  143. <!-- <template #default="{ row }">-->
  144. <!-- <div>{{ row.submitName || '-' }}</div>-->
  145. <!-- </template>-->
  146. <!-- </el-table-column>-->
  147. <el-table-column label="备注" align="center" prop="remark" min-width="150px"/>
  148. <el-table-column label="部门" align="center" prop="deptName" min-width="150px"/>
  149. <el-table-column label="审核状态" align="center" prop="status" min-width="100px">
  150. <template #default="{ row }">
  151. <el-tag v-if="row.status === 100" type="warning">审核中</el-tag>
  152. <el-tag v-else-if="row.status === 200" type="success">已通过</el-tag>
  153. <el-tag v-else-if="row.status === 300" type="danger">已拒绝</el-tag>
  154. <div v-else>{{ '-' }}</div>
  155. </template>
  156. </el-table-column>
  157. <el-table-column label="操作" align="center" min-width="240px" fixed="right">
  158. <template #default="scope">
  159. <el-button link type="primary" @click="handleViewPdf(scope.row)">查看</el-button>
  160. <el-button link type="primary" @click="handlePrint(scope.row)" v-if="scope.row.status === 200"> 打印 </el-button>
  161. <el-button link type="primary" @click="handleAudit(scope.row)" v-if="scope.row.status == null">提交审核</el-button>
  162. <el-button link type="primary" @click="handleApprove(scope.row)" v-if="scope.row.status === 100">通过</el-button>
  163. <el-button link type="danger" @click="handleReject(scope.row)" v-if="scope.row.status === 100">拒绝</el-button>
  164. </template>
  165. </el-table-column>
  166. </el-table>
  167. <!-- 分页 -->
  168. <Pagination
  169. :total="total"
  170. v-model:page="queryParams.pageNo"
  171. v-model:limit="queryParams.pageSize"
  172. @pagination="getList"
  173. />
  174. </ContentWrap>
  175. <!-- PDF预览弹窗 -->
  176. <PdfPreviewDialog
  177. v-model="pdfPreviewVisible"
  178. :pdfBlob="currentPdfBlob"
  179. @close="handlePdfPreviewClose"
  180. />
  181. </template>
  182. <script setup lang="ts">
  183. import {dateFormatter, formatArrayDate, formatDate} from '@/utils/formatTime'
  184. import download from '@/utils/download'
  185. import { PipeUseRegistrationReportApi, PipeUseRegistrationReportVO } from '@/api/pressure2/pipeuseregistrationreport'
  186. import DeptSelect from "@/views/pressure2/pipescheduling/components/DeptSelect.vue";
  187. import {PipeInputApi} from "@/api/pressure2/pipeInput";
  188. import PdfPreviewDialog from "@/views/pressure2/boilertaskorder/PdfPreviewDialog.vue";
  189. import 'https://printjs-4de6.kxcdn.com/print.min.js'
  190. /** 管道使用登记 列表 */
  191. defineOptions({ name: 'pipeUseRegistrationReport' })
  192. const message = useMessage() // 消息弹窗
  193. const { t } = useI18n() // 国际化
  194. const loading = ref(true) // 列表的加载中
  195. const list = ref<PipeUseRegistrationReportVO[]>([]) // 列表的数据
  196. const total = ref(0) // 列表的总页数
  197. // 状态筛选
  198. const queryParams = reactive({
  199. pageNo: 1,
  200. pageSize: 10,
  201. taskOrderId: undefined,
  202. templateId: undefined,
  203. createTime: [],
  204. reportNo: undefined,
  205. status: undefined,
  206. remark: undefined,
  207. reportName: undefined,
  208. approvalId: undefined,
  209. approvalTime: [],
  210. approvalName: undefined,
  211. submitId: undefined,
  212. submitTime: [],
  213. submitName: undefined,
  214. projectNo: undefined,
  215. unitName: undefined,
  216. certificateNo: undefined,
  217. deptId: undefined,
  218. hasCertificateNo: undefined
  219. })
  220. const queryFormRef = ref() // 搜索的表单
  221. const exportLoading = ref(false) // 导出的加载中
  222. const selectedRows = ref<PipeUseRegistrationReportVO[]>([]) // 勾选的行
  223. /** 查询列表 */
  224. const getList = async () => {
  225. loading.value = true
  226. try {
  227. const data = await PipeUseRegistrationReportApi.getPipeUseRegistrationReportPage(queryParams)
  228. list.value = data.list
  229. total.value = data.total
  230. } finally {
  231. loading.value = false
  232. }
  233. }
  234. /** 搜索按钮操作 */
  235. const handleQuery = () => {
  236. queryParams.pageNo = 1
  237. getList()
  238. }
  239. /** 重置按钮操作 */
  240. const resetQuery = () => {
  241. queryFormRef.value.resetFields()
  242. handleQuery()
  243. }
  244. /** 勾选变化 */
  245. const handleSelectionChange = (rows: PipeUseRegistrationReportVO[]) => {
  246. selectedRows.value = rows
  247. }
  248. /** 删除按钮操作 */
  249. const handleDelete = async (id: number) => {
  250. try {
  251. // 删除的二次确认
  252. await message.delConfirm()
  253. // 发起删除
  254. await PipeUseRegistrationReportApi.deletePipeUseRegistrationReport(id)
  255. message.success(t('common.delSuccess'))
  256. // 刷新列表
  257. await getList()
  258. } catch {}
  259. }
  260. // const generateTest = async () => {
  261. //
  262. // const params = {
  263. // taskOrderId: '65fd02581d5eb08852500502217b405a'
  264. // }
  265. // await PipeUseRegistrationReportApi.generatePipeUseRegistrationReport(params)
  266. //
  267. // }
  268. /** 导出按钮操作 */
  269. const handleExport = async () => {
  270. try {
  271. // 导出的二次确认
  272. await message.exportConfirm()
  273. exportLoading.value = true
  274. // 有勾选时导出勾选的数据,否则导出全部
  275. const params: any = { ...queryParams }
  276. if (selectedRows.value.length > 0) {
  277. params.ids = selectedRows.value.map(row => row.id).join(',')
  278. }
  279. const data = await PipeUseRegistrationReportApi.exportPipeUseRegistrationReport(params)
  280. download.excel(data, '管道使用登记.xls')
  281. } catch {
  282. } finally {
  283. exportLoading.value = false
  284. }
  285. }
  286. // PDF预览相关
  287. const pdfPreviewVisible = ref(false)
  288. const currentPdfBlob = ref<Blob | null>(null)
  289. const handleViewPdf = async (row) => {
  290. let data: any[] = []
  291. data.push({
  292. taskStatus: 100,
  293. resultTemplateId: '',
  294. templateId: row.templateId,
  295. id: row.id,
  296. })
  297. const loadingInstance = ElLoading.service({
  298. fullscreen: true,
  299. text: '正在生成...'
  300. })
  301. try {
  302. // 调用 API 获取 ZIP blob
  303. const pdfBlob = await PipeInputApi.handlePrint(data)
  304. if (pdfBlob) {
  305. currentPdfBlob.value = pdfBlob
  306. pdfPreviewVisible.value = true
  307. } else {
  308. ElMessage.error('获取文件失败')
  309. }
  310. } catch (error) {
  311. console.error('预览失败:', error)
  312. ElMessage.error('预览失败')
  313. } finally {
  314. loadingInstance.close()
  315. }
  316. }
  317. // PDF预览关闭处理
  318. const handlePdfPreviewClose = () => {
  319. currentPdfBlob.value = null
  320. }
  321. // 打印
  322. const printRow = ref<any>({})
  323. const handlePrint = async (row) => {
  324. let data: any[] = []
  325. data.push({
  326. taskStatus: 100,
  327. resultTemplateId: '',
  328. templateId: row.templateId,
  329. id: row.id,
  330. })
  331. const loadingInstance = ElLoading.service({
  332. fullscreen: true,
  333. text: '正在打印...'
  334. })
  335. try {
  336. const pdfBlob = await PipeInputApi.handlePrint(data)
  337. if (pdfBlob) {
  338. // 创建临时 URL
  339. const pdfUrl = URL.createObjectURL(pdfBlob)
  340. // 使用 printJS 打印
  341. printJS({
  342. printable: pdfUrl,
  343. type: 'pdf',
  344. showModal: false,
  345. onPrintDialogClose: () => {
  346. // 打印对话框关闭后释放 URL
  347. URL.revokeObjectURL(pdfUrl)
  348. },
  349. })
  350. } else {
  351. ElMessage.error('获取打印文件失败')
  352. }
  353. } catch (error) {
  354. console.error('打印失败:', error)
  355. ElMessage.error('打印失败')
  356. }finally {
  357. loadingInstance.close()
  358. }
  359. }
  360. /** 提交审核 */
  361. const handleAudit = async (row) => {
  362. try {
  363. await message.confirm('确定提交审核吗?')
  364. await PipeUseRegistrationReportApi.auditPipeUseRegistrationReport({ id: row.id })
  365. message.success('提交审核成功')
  366. await getList()
  367. } catch {}
  368. }
  369. /** 审核通过 */
  370. const handleApprove = async (row) => {
  371. try {
  372. await message.confirm('确定通过该审核吗?')
  373. await PipeUseRegistrationReportApi.approvePipeUseRegistrationReport({ id: row.id, status: 200 })
  374. message.success('审核通过成功')
  375. await getList()
  376. } catch {}
  377. }
  378. /** 审核拒绝 */
  379. const handleReject = async (row) => {
  380. try {
  381. await message.confirm('确定拒绝该审核吗?')
  382. await PipeUseRegistrationReportApi.approvePipeUseRegistrationReport({ id: row.id, status: 300 })
  383. message.success('已拒绝该审核')
  384. await getList()
  385. } catch {}
  386. }
  387. /** 初始化 **/
  388. onMounted(() => {
  389. getList()
  390. })
  391. </script>