project-scanning.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972
  1. <template>
  2. <div class="hc-layout-box">
  3. <div :style="'width:' + leftWidth + 'px;'" class="hc-layout-left-box">
  4. <div class="hc-project-box">
  5. <div class="hc-project-icon-box">
  6. <HcIcon name="stack"/>
  7. </div>
  8. <div class="ml-2 project-name-box">
  9. <span class="text-xl text-cut project-alias">{{ projectInfo['projectAlias'] }}</span>
  10. <div class="text-xs text-cut project-name">{{ projectInfo['name'] }}</div>
  11. </div>
  12. </div>
  13. <div class="hc-tree-box">
  14. <el-scrollbar>
  15. <ProjectTree :autoExpandKeys="TreeAutoExpandKeys" :datas="ElTreeData" @nodeTap="nodeElTreeClick"/>
  16. </el-scrollbar>
  17. </div>
  18. <!--左右拖动-->
  19. <div class="horizontal-drag-line" @mousedown="onmousedown"/>
  20. </div>
  21. <div class="hc-layout-content-box">
  22. <HcCard :scrollbar="false" actionSize="lg">
  23. <template #header>
  24. <HcTooltip keys="project-scanning-upload">
  25. <el-button :disabled="!nodeIds" hc-btn type="primary" @click="uploadModalClick">
  26. <HcIcon name="add-circle"/>
  27. <span>上传文件</span>
  28. </el-button>
  29. </HcTooltip>
  30. <HcTooltip keys="project-scanning-download">
  31. <el-button :disabled="tableCheckedKeys.length <= 0" :loading="batchDownloadLoading" hc-btn
  32. @click="batchDownload">
  33. <HcIcon name="download"/>
  34. <span>批量下载</span>
  35. </el-button>
  36. </HcTooltip>
  37. <HcTooltip keys="project-scanning-report">
  38. <el-button :disabled="tableCheckedKeys.length <= 0" :loading="reportLoading" hc-btn
  39. @click="reportModalClick">
  40. <HcIcon name="send-plane-2"/>
  41. <span>批量上报</span>
  42. </el-button>
  43. </HcTooltip>
  44. <HcTooltip keys="project-scanning-attest">
  45. <el-button :disabled="tableCheckedKeys.length <= 0" hc-btn @click="certificationModalClick">
  46. <HcIcon name="vip-diamond"/>
  47. <span>批量认证</span>
  48. </el-button>
  49. </HcTooltip>
  50. <HcTooltip keys="project-scanning-del">
  51. <el-button :disabled="tableCheckedKeys.length <= 0" hc-btn @click="batchDel">
  52. <HcIcon name="delete-bin-2"/>
  53. <span>批量删除</span>
  54. </el-button>
  55. </HcTooltip>
  56. <HcTooltip keys="project-scanning-edit">
  57. <el-button :disabled="tableCheckedKeys.length <= 0" hc-btn @click="batchEditClick">
  58. <HcIcon name="draft"/>
  59. <span>批量编辑</span>
  60. </el-button>
  61. </HcTooltip>
  62. <HcTooltip keys="project-scanning-abolish">
  63. <el-button :disabled="tableCheckedKeys.length <= 0" hc-btn @click="batchAbolishClick">
  64. <HcIcon name="delete-bin-3"/>
  65. <span>批量废除</span>
  66. </el-button>
  67. </HcTooltip>
  68. </template>
  69. <template #search>
  70. <div class="w-32">
  71. <el-select v-model="searchForm.isApprovalValue" clearable placeholder="审批状态">
  72. <el-option v-for="item in approvalData" :label="item['dictValue']"
  73. :value="item['dictKey']"/>
  74. </el-select>
  75. </div>
  76. <div class="w-32 ml-4">
  77. <el-select v-model="searchForm.isCertificationValue" clearable placeholder="认证状态">
  78. <el-option v-for="item in certificationType" :label="item['dictValue']"
  79. :value="item['dictKey']"/>
  80. </el-select>
  81. </div>
  82. <div class="w-64 ml-3">
  83. <el-input v-model="searchForm.queryValue" clearable placeholder="请输入文件名、责任者进行搜索"
  84. @keyup="keyUpEvent"/>
  85. </div>
  86. <div class="ml-2">
  87. <el-button type="primary" @click="searchClick">
  88. <HcIcon name="search-2"/>
  89. <span>搜索</span>
  90. </el-button>
  91. </div>
  92. </template>
  93. <HcTable ref="tableListRef" :column="tableListColumn" :datas="tableListData" :loading="tableLoading"
  94. isCheck @selection-change="tableSelectionChange">
  95. <template #fileName="{row}">
  96. <span class="text-link" @click="tablePreview(row)">{{ row?.fileName }}</span>
  97. </template>
  98. <template #isApprovalValue="{row}">
  99. <el-tag
  100. v-if="row['isApprovalValue']"
  101. :type="`${row.status === 2 ? 'success' : row.status === 0 ? 'warning' : row.status === 1 ? 'danger' : 'info'}`"
  102. class="mx-1" effect="dark">{{ row['isApprovalValue'] }}
  103. </el-tag>
  104. </template>
  105. </HcTable>
  106. <template #action>
  107. <HcPages :pages="searchForm" @change="pageChange"/>
  108. </template>
  109. </HcCard>
  110. </div>
  111. <!--新增编辑文件-->
  112. <el-dialog v-model="showUploadModal" class="hc-modal-border hc-modal-table" title="上传工程文件" width="80vw">
  113. <HcTable :column="tableUploadColumn" :datas="tableUploadData" :loading="uploadSaveLoading"
  114. ui="hc-form-table">
  115. <template #fileNumber="{row}">
  116. <el-input v-model="row.fileNumber" :class="row['isFileNumber'] ? 'is-error' : ''"
  117. @input="tableInput($event, row, 'isFileNumber')"/>
  118. </template>
  119. <template #fileName="{row}">
  120. <el-input v-model="row.fileName" :class="row['isFileName'] ? 'is-error' : ''"
  121. @input="tableInput($event, row, 'isFileName')"/>
  122. </template>
  123. <template #fileTime="{row}">
  124. <el-date-picker v-model="row.fileTime" :clearable="false" format="YYYY/MM/DD" type="date"
  125. value-format="YYYY-MM-DD"/>
  126. </template>
  127. <template v-if="isBuiltDrawing === 1" #sheetType="{row}">
  128. <el-select v-model="row.sheetType">
  129. <el-option v-for="item in sheetType" :key="item['dictKey']" :label="item['dictValue']"
  130. :value="item['dictKey']"/>
  131. </el-select>
  132. </template>
  133. <template v-if="isBuiltDrawing === 1" #sheetSource="{row}">
  134. <el-select v-model="row.sheetSource">
  135. <el-option v-for="item in sheetSourceType" :key="item['dictKey']" :label="item['dictValue']"
  136. :value="item['dictKey']"/>
  137. </el-select>
  138. </template>
  139. <template v-if="isBuiltDrawing === 1" #drawingNo="{row}">
  140. <el-input v-model="row.drawingNo"/>
  141. </template>
  142. <template v-if="isBuiltDrawing === 1" #citeChangeNumber="{row}">
  143. <el-input v-model="row.citeChangeNumber"/>
  144. </template>
  145. <template #isApproval="{row}">
  146. <el-select v-model="row.isApproval">
  147. <el-option v-for="item in whetherData" :key="item.value" :label="item.label"
  148. :value="item.value"/>
  149. </el-select>
  150. </template>
  151. <template #isNeedCertification="{row}">
  152. <el-select v-model="row.isNeedCertification">
  153. <el-option v-for="item in whetherData" :key="item.value" :label="item.label"
  154. :value="item.value"/>
  155. </el-select>
  156. </template>
  157. <template #dutyUser="{row}">
  158. <el-input v-model="row.dutyUser"/>
  159. </template>
  160. <template #action="{row,index}">
  161. <HcFileUpload1 v-if="row.id" @change="newUploadsChange($event, row)"
  162. @progress="newUploadsProgress($event, row)">
  163. <el-button :loading="row['newBtnLoading']" plain size="small" type="primary">上传新文件
  164. </el-button>
  165. </HcFileUpload1>
  166. <el-button :loading="row['delBtnLoading']" plain size="small" type="danger"
  167. @click="delUploadData(row,index)">删除
  168. </el-button>
  169. </template>
  170. </HcTable>
  171. <template #footer>
  172. <div class="lr-dialog-footer">
  173. <div class="left flex items-center">
  174. <HcFileUpload @change="uploadsChange" @progress="uploadsProgress">
  175. <el-button :disabled="uploadSaveLoading" :loading="uploadsLoading" hc-btn type="primary">
  176. <HcIcon name="add-circle"/>
  177. <span>新增上传</span>
  178. </el-button>
  179. </HcFileUpload>
  180. </div>
  181. <div class="right">
  182. <el-button size="large" @click="batchUploadCancel">
  183. <HcIcon name="close"/>
  184. <span>取消</span>
  185. </el-button>
  186. <el-button :disabled="uploadsLoading" :loading="uploadSaveLoading" hc-btn type="primary"
  187. @click="batchUploadSave">
  188. <HcIcon name="save"/>
  189. <span>提交保存</span>
  190. </el-button>
  191. </div>
  192. </div>
  193. </template>
  194. </el-dialog>
  195. <!--批量上报审批-->
  196. <HcReportModal
  197. :contractId="contractId"
  198. :datas="reportDatas"
  199. :ids="reportIds"
  200. :projectId="projectId"
  201. :show="showReportModal"
  202. :taskName="reportTaskName"
  203. isDatas
  204. title="批量上报审批"
  205. url="archiveFile/batchApproval"
  206. @finish="showReportFinish"
  207. @hide="showReportModal = false"
  208. @tagClose="reportTaskTagClose"
  209. />
  210. <!--批量认证-->
  211. <el-dialog v-model="showCertificationModal" class="hc-modal-border hc-modal-table" title="批量认证"
  212. width="80vw">
  213. <div class="hc-card-body-flex">
  214. <div class="flex-table">
  215. <HcTable :column="CertColumns" :datas="CertData" ui="hc-form-table" @row-click="CertRowClick">
  216. <template #action="{row,index}">
  217. <el-button plain size="small" type="primary" @click.stop="CertRowClick2(row)">预览
  218. </el-button>
  219. </template>
  220. </HcTable>
  221. </div>
  222. <div v-if="CertPdf" class="flex-iframe">
  223. <iframe :src="CertPdf" allow="display-capture" frameborder='1' height='100%' width='100%'></iframe>
  224. </div>
  225. <div v-else class="flex-iframe hc-no-table-form">
  226. <div class="table-form-no">
  227. <img :src="notableform" alt=""/>
  228. <div class="desc">暂无 PDF 数据</div>
  229. </div>
  230. </div>
  231. </div>
  232. <template #footer>
  233. <div class="dialog-footer">
  234. <el-button size="large" @click="showCertificationModal = false">
  235. <HcIcon name="close"/>
  236. <span>取消</span>
  237. </el-button>
  238. <el-button :loading="CertLoading" hc-btn type="primary" @click="CertClick">
  239. <HcIcon name="save"/>
  240. <span>确认认证</span>
  241. </el-button>
  242. </div>
  243. </template>
  244. </el-dialog>
  245. </div>
  246. </template>
  247. <script setup>
  248. import {onMounted, ref, watch} from 'vue'
  249. import {useAppStore} from "~src/store";
  250. import {useRouter, useRoute} from 'vue-router'
  251. import ProjectTree from "./components/ProjectTree.vue"
  252. import HcFileUpload from "./components/HcFileUpload.vue"
  253. import HcFileUpload1 from "./components/HcFileUpload1.vue"
  254. import {getStoreValue, setStoreValue} from '~src/utils/storage'
  255. import projectScanningApi from "~api/other-file/projectScanning";
  256. import notableform from '~src/assets/view/notableform.svg';
  257. import {downloadBlob, getArrValue, deepClone} from "js-fast-way"
  258. import {eVisaTaskCheckApi} from "~api/other"
  259. import tasksDataApi from '~api/tasks/data';
  260. import ossApi from "~api/oss";
  261. import dayjs from "dayjs"
  262. //变量
  263. const router = useRouter()
  264. const useRoutes = useRoute()
  265. const useAppState = useAppStore()
  266. const projectId = ref(useAppState.getProjectId);
  267. const contractId = ref(useAppState.getContractId);
  268. const projectInfo = ref(useAppState.getProjectInfo);
  269. const isCollapse = ref(useAppState.getCollapse)
  270. //监听
  271. watch(() => [
  272. useAppState.getCollapse
  273. ], ([Collapse]) => {
  274. isCollapse.value = Collapse
  275. })
  276. //自动展开缓存
  277. const TreeAutoExpandKeys = ref(getStoreValue('scanningTreeExpandKeys') || [])
  278. const dayDate = ref('')
  279. //渲染完成
  280. onMounted(() => {
  281. getClassIfyList()
  282. firstTaskStatus()
  283. certificationStatus()
  284. dayDate.value = dayjs(new Date()).format('YYYY-MM-DD')
  285. })
  286. //获取树的数据
  287. const ElTreeData = ref([])
  288. const getClassIfyList = async () => {
  289. const {error, code, data} = await projectScanningApi.getClassIfyList({
  290. projectId: projectId.value,
  291. contractId: contractId.value
  292. })
  293. //处理数据
  294. if (!error && code === 200) {
  295. ElTreeData.value = getArrValue(data)
  296. } else {
  297. ElTreeData.value = []
  298. }
  299. }
  300. //项目树被点击
  301. const treeNodeInfo = ref({})
  302. const treeDataInfo = ref({})
  303. const nodeIds = ref('')
  304. const isStorageNode = ref(0)
  305. const isBuiltDrawing = ref(0)
  306. const nodeElTreeClick = ({node, data, keys, key}) => {
  307. treeNodeInfo.value = node
  308. treeDataInfo.value = data
  309. //设置变量
  310. nodeIds.value = key || ''
  311. isStorageNode.value = data['isStorageNode'] || 0
  312. isBuiltDrawing.value = data['isBuiltDrawing'] || 0
  313. //设置搜索数据
  314. searchForm.value.current = 1;
  315. searchForm.value.nodeIds = key || ''
  316. setTableColumns()
  317. getTableData()
  318. //缓存展开的节点
  319. setStoreValue('scanningTreeExpandKeys', keys)
  320. }
  321. //获取任务类型
  322. const approvalData = ref([])
  323. const firstTaskStatus = async () => {
  324. const {error, code, data} = await tasksDataApi.queryTaskTypeStatus({
  325. typeOrStatus: 'first_task_status'
  326. })
  327. //处理数据
  328. if (!error && code === 200) {
  329. approvalData.value = getArrValue(data)
  330. } else {
  331. approvalData.value = []
  332. }
  333. }
  334. //获取认证状态
  335. const certificationType = ref([])
  336. const certificationStatus = async () => {
  337. const {error, code, data} = await tasksDataApi.queryTaskTypeStatus({
  338. typeOrStatus: 'certification_status'
  339. })
  340. //处理数据
  341. if (!error && code === 200) {
  342. certificationType.value = getArrValue(data)
  343. } else {
  344. certificationType.value = []
  345. }
  346. }
  347. //获取图幅类型
  348. const sheetType = ref([])
  349. const sheetTypeStatus = async () => {
  350. const {error, code, data} = await tasksDataApi.queryTaskTypeStatus({
  351. typeOrStatus: 'sheet_type'
  352. })
  353. //处理数据
  354. if (!error && code === 200) {
  355. sheetType.value = getArrValue(data)
  356. } else {
  357. sheetType.value = []
  358. }
  359. }
  360. //获取图表来源
  361. const sheetSourceType = ref([])
  362. const sheetSourceStatus = async () => {
  363. const {error, code, data} = await tasksDataApi.queryTaskTypeStatus({
  364. typeOrStatus: 'sheet_source'
  365. })
  366. //处理数据
  367. if (!error && code === 200) {
  368. sheetSourceType.value = getArrValue(data)
  369. } else {
  370. sheetSourceType.value = []
  371. }
  372. }
  373. //搜索表单
  374. const searchForm = ref({
  375. nodeIds: '', isApprovalValue: null, isCertificationValue: null, queryValue: null,
  376. current: 1, size: 20, total: 0
  377. })
  378. //回车搜索
  379. const keyUpEvent = (e) => {
  380. if (e.key === "Enter") {
  381. searchClick()
  382. }
  383. }
  384. //搜索
  385. const searchClick = () => {
  386. if (nodeIds.value) {
  387. searchForm.value.current = 1;
  388. getTableData()
  389. } else {
  390. window?.$message?.warning('请先在左边选择一个树节点')
  391. }
  392. }
  393. //分页被点击
  394. const pageChange = ({current, size}) => {
  395. searchForm.value.current = current
  396. searchForm.value.size = size
  397. getTableData()
  398. }
  399. //设置表头
  400. const tableListColumn = ref([
  401. {key: 'fileNumber', name: '文件编号', width: 160},
  402. {key: 'fileName', name: '文件名称'},
  403. {key: 'filePage', name: '文件页数', width: 120},
  404. {key: 'isCertificationValue', name: '认证状态', width: 160},
  405. {key: 'isApprovalValue', name: '状态', width: 160},
  406. {key: 'fileTime', name: '文件时间', width: 160},
  407. {key: 'dutyUser', name: '责任者', width: 160}
  408. ])
  409. const setTableColumns = () => {
  410. if (isBuiltDrawing.value === 1) {
  411. tableListColumn.value = [
  412. {key: 'fileNumber', name: '文件编号', width: 160},
  413. {key: 'fileName', name: '文件名称'},
  414. {key: 'filePage', name: '文件页数', width: 120},
  415. {key: 'sheetType', name: '图幅'},
  416. {key: 'sheetSourceValue', name: '图表来源'},
  417. {key: 'drawingNo', name: '图号'},
  418. {key: 'citeChangeNumber', name: '引用变更令编号'},
  419. {key: 'isCertificationValue', name: '认证状态', width: 160},
  420. {key: 'isApprovalValue', name: '状态', width: 160},
  421. {key: 'fileTime', name: '文件时间', width: 160},
  422. {key: 'dutyUser', name: '责任者', width: 160}
  423. ]
  424. sheetTypeStatus()
  425. sheetSourceStatus()
  426. } else {
  427. tableListColumn.value = [
  428. {key: 'fileNumber', name: '文件编号', width: 160},
  429. {key: 'fileName', name: '文件名称'},
  430. {key: 'filePage', name: '文件页数', width: 120},
  431. {key: 'isCertificationValue', name: '认证状态', width: 160},
  432. {key: 'isApprovalValue', name: '状态', width: 160},
  433. {key: 'fileTime', name: '文件时间', width: 160},
  434. {key: 'dutyUser', name: '责任者', width: 160}
  435. ]
  436. }
  437. }
  438. //获取数据
  439. const tableLoading = ref(false)
  440. const tableListData = ref([])
  441. const getTableData = async () => {
  442. tableLoading.value = true
  443. const {error, code, data} = await projectScanningApi.getarchiveFilePage({
  444. ...searchForm.value,
  445. projectId: projectId.value,
  446. contractId: contractId.value
  447. })
  448. //判断状态
  449. tableLoading.value = false
  450. if (!error && code === 200) {
  451. tableListData.value = getArrValue(data['records'])
  452. searchForm.value.total = data['total'] || 0
  453. } else {
  454. tableListData.value = []
  455. searchForm.value.total = 0
  456. }
  457. }
  458. //多选
  459. const tableListRef = ref(null)
  460. const tableCheckedKeys = ref([]);
  461. const tableSelectionChange = (rows) => {
  462. tableCheckedKeys.value = rows.filter((item) => {
  463. return (item ?? '') !== '';
  464. })
  465. }
  466. //文件名称被点击
  467. const tablePreview = (row) => {
  468. const pdfUrl = row['pdfFileUrl'] || ''
  469. const evisaFile = row['evisaFile'] || ''
  470. if (evisaFile) {
  471. window.open(evisaFile, '_blank')
  472. } else if (pdfUrl) {
  473. window.open(pdfUrl, '_blank')
  474. } else {
  475. window.$message?.warning('该数据暂无PDF')
  476. }
  477. }
  478. //新增文件
  479. const tableUploadType = ref('add')
  480. const showUploadModal = ref(false)
  481. const uploadModalClick = () => {
  482. if (nodeIds.value && isStorageNode.value === 1) {
  483. tableUploadType.value = 'add'
  484. setTableUploadColumn()
  485. uploadSaveLoading.value = false
  486. tableUploadData.value = []
  487. showUploadModal.value = true
  488. } else {
  489. window?.$message?.warning('请先选择一个子节点')
  490. }
  491. }
  492. //设置文件表头
  493. const tableUploadColumn = ref([
  494. {key: 'fileNumber', name: '文件编号'},
  495. {key: 'fileName', name: '文件名称'},
  496. {key: 'fileTime', name: '文件时间'},
  497. {key: 'isApproval', name: '是否需要审批'},
  498. {key: 'isNeedCertification', name: '是否需要认证'},
  499. {key: 'dutyUser', name: '责任者'},
  500. {key: 'action', name: '操作', width: 180}
  501. ])
  502. const setTableUploadColumn = () => {
  503. if (isBuiltDrawing.value === 1) {
  504. tableUploadColumn.value = [
  505. {key: 'fileNumber', name: '文件编号'},
  506. {key: 'fileName', name: '文件名称'},
  507. {key: 'fileTime', name: '文件时间'},
  508. {key: 'sheetType', name: '图幅'},
  509. {key: 'sheetSource', name: '图表来源'},
  510. {key: 'drawingNo', name: '图号'},
  511. {key: 'citeChangeNumber', name: '引用变更令编号'},
  512. {key: 'isApproval', name: '是否需要审批'},
  513. {key: 'isNeedCertification', name: '是否需要认证'},
  514. {key: 'dutyUser', name: '责任者'},
  515. {key: 'action', name: '操作', width: 180}
  516. ]
  517. } else {
  518. tableUploadColumn.value = [
  519. {key: 'fileNumber', name: '文件编号'},
  520. {key: 'fileName', name: '文件名称'},
  521. {key: 'fileTime', name: '文件时间'},
  522. {key: 'isApproval', name: '是否需要审批'},
  523. {key: 'isNeedCertification', name: '是否需要认证'},
  524. {key: 'dutyUser', name: '责任者'},
  525. {key: 'action', name: '操作', width: 180}
  526. ]
  527. }
  528. }
  529. const tableUploadData = ref([])
  530. //上传的文件结果
  531. const uploadsChange = ({fileList}) => {
  532. let newArr = []
  533. const sheet = sheetType.value, source = sheetSourceType.value
  534. for (let i = 0; i < fileList.length; i++) {
  535. const item = fileList[i]
  536. let name = item['originalName'] || ''
  537. let fileName = name.substring(0, name.lastIndexOf("."))
  538. newArr.push({
  539. projectId: projectId.value,
  540. contractId: contractId.value,
  541. nodeId: nodeIds.value,
  542. fileNumber: '',
  543. fileName: fileName,
  544. ossFileName: item?.name || '',
  545. fileTime: dayDate.value,
  546. fileUrl: item?.link || '',
  547. sheetType: sheet.length > 0 ? sheet[0]['dictKey'] || '' : '',
  548. sheetSource: source.length > 0 ? source[0]['dictKey'] || '' : '',
  549. drawingNo: '',
  550. citeChangeNumber: '',
  551. isApproval: 0,
  552. isNeedCertification: 0,
  553. dutyUser: '',
  554. pdfFileUrl: item?.pdfUrl || '',
  555. filePage: item?.page || '',
  556. })
  557. }
  558. tableUploadData.value = newArr
  559. }
  560. //上传进度
  561. const uploadsLoading = ref(false)
  562. const uploadsProgress = (val) => {
  563. uploadsLoading.value = val
  564. }
  565. //表单下拉数据
  566. const whetherData = ref([{label: "不需要", value: 0}, {label: "需要", value: 1}])
  567. //输入框验证
  568. const tableInput = (val, row, isv) => {
  569. if (val) {
  570. row[isv] = false
  571. } else {
  572. row[isv] = true
  573. }
  574. }
  575. //上传新文件
  576. const newUploadsChange = ({fileList}, row) => {
  577. if (fileList.length > 0) {
  578. const item = fileList[0]
  579. const name = item['originalName'] || ''
  580. const fileName = name.substring(0, name.lastIndexOf("."))
  581. //更新数据
  582. row.fileName = fileName;
  583. row.ossFileName = item?.name || ''
  584. row.fileUrl = item?.link || ''
  585. row.pdfFileUrl = item?.pdfUrl || ''
  586. row.filePage = item?.page || ''
  587. }
  588. }
  589. const newUploadsProgress = (val, row) => {
  590. row.newBtnLoading = val
  591. }
  592. //删除
  593. const delUploadData = async (row, index) => {
  594. if (row['ossFileName']) {
  595. row['delBtnLoading'] = true
  596. await ossApi.removeFile({fileName: row['ossFileName']})
  597. row['delBtnLoading'] = false
  598. tableUploadData.value.splice(index, 1);
  599. } else {
  600. tableUploadData.value.splice(index, 1);
  601. }
  602. }
  603. //批量上传保存
  604. const uploadSaveLoading = ref(false)
  605. const batchUploadSave = async () => {
  606. const rows = tableUploadData.value
  607. if (rows.length > 0) {
  608. //验证表单数据
  609. uploadSaveLoading.value = true
  610. let isTableRows = false;
  611. for (let i = 0; i < rows.length; i++) {
  612. if (!rows[i]['fileNumber']) {
  613. rows[i]['isFileNumber'] = true
  614. isTableRows = true
  615. } else if (!rows[i]['fileName']) {
  616. rows[i]['isFileName'] = true
  617. isTableRows = true
  618. }
  619. }
  620. //判断数据
  621. if (isTableRows) {
  622. uploadSaveLoading.value = false
  623. window.$message?.warning('请先完善表单信息')
  624. } else {
  625. if (tableUploadType.value === 'add') {
  626. await batchUploadSaveApi(rows)
  627. } else {
  628. await batchEditSaveApi(rows)
  629. }
  630. }
  631. } else {
  632. window.$message?.warning('请先上传文件')
  633. }
  634. }
  635. //确认上传保存
  636. const batchUploadSaveApi = async (rows) => {
  637. uploadSaveLoading.value = true
  638. const {error, code} = await projectScanningApi.batchUploadSave({
  639. list: rows
  640. }, false)
  641. //判断状态
  642. uploadSaveLoading.value = false
  643. if (!error && code === 200) {
  644. window.$message?.success('保存成功')
  645. batchUploadCancel()
  646. getTableData()
  647. } else {
  648. window.$message?.error('保存失败')
  649. }
  650. }
  651. //取消上传
  652. const batchUploadCancel = () => {
  653. tableUploadData.value = []
  654. uploadSaveLoading.value = false
  655. uploadsLoading.value = false
  656. showUploadModal.value = false
  657. }
  658. //批量编辑
  659. const batchEditClick = () => {
  660. const rows = deepClone(tableCheckedKeys.value)
  661. //判断是否满足条件
  662. const result = rows.every(({status}) => {
  663. return status !== 1 && status !== 2
  664. })
  665. console.log(rows)
  666. //判断状态
  667. if (result) {
  668. tableUploadType.value = 'edit'
  669. setTableUploadColumn()
  670. uploadSaveLoading.value = false
  671. tableUploadData.value = rows
  672. showUploadModal.value = true
  673. } else {
  674. window.$message?.warning('已上报或已审批的文件不能编辑')
  675. }
  676. }
  677. //确认编辑上传保存
  678. const batchEditSaveApi = async (rows) => {
  679. uploadSaveLoading.value = true
  680. const {error, code} = await projectScanningApi.batchEditSave({
  681. list: rows
  682. }, false)
  683. //判断状态
  684. uploadSaveLoading.value = false
  685. if (!error && code === 200) {
  686. window.$message?.success('保存成功')
  687. batchUploadCancel()
  688. getTableData()
  689. } else {
  690. window.$message?.error('保存失败')
  691. }
  692. }
  693. //批量下载
  694. const batchDownloadLoading = ref(false)
  695. const batchDownload = async () => {
  696. const rows = deepClone(tableCheckedKeys.value)
  697. const ids = rowsToId(rows)
  698. //批量下载
  699. batchDownloadLoading.value = true
  700. const {error, disposition, res} = await projectScanningApi.batchDownloadFileToZip({ids: ids})
  701. //处理数据
  702. batchDownloadLoading.value = false
  703. if (!error) {
  704. if (disposition) {
  705. downloadBlob(res, disposition)
  706. } else {
  707. window.$message?.error('数据异常')
  708. }
  709. }
  710. }
  711. //批量上报
  712. const reportIds = ref('')
  713. const reportTaskName = ref('')
  714. const reportDatas = ref([])
  715. const showReportModal = ref(false)
  716. const reportLoading = ref(false)
  717. const reportModalClick = async () => {
  718. const rows = tableCheckedKeys.value;
  719. const result = rows.every(({status}) => {
  720. return status === 0 //isApproval !== 1 && status !== 0 || isApproval === 1 && status !== 0
  721. })
  722. if (result) {
  723. reportLoading.value = true
  724. const taskCheck = await eVisaTaskCheckApi({
  725. projectId: projectId.value,
  726. contractId: contractId.value
  727. })
  728. if (taskCheck) {
  729. reportIds.value = rowsToId(rows)
  730. //设置任务数据
  731. let reportDataArr = []
  732. rows.forEach(item => {
  733. reportDataArr.push({
  734. id: item?.id,
  735. name: item?.fileName
  736. })
  737. })
  738. reportDatas.value = reportDataArr
  739. //设置任务名称
  740. reportTaskName.value = rows.length > 1 ? `${rows[0].fileName}等${rows.length}个文件` : rows[0].fileName
  741. reportLoading.value = false
  742. showReportModal.value = true
  743. } else {
  744. reportLoading.value = false
  745. }
  746. } else {
  747. window.$message?.warning('已上报的文件不能进行再次上报,若要重新上报,要先撤回之前的上报,再重新上报')
  748. }
  749. }
  750. //上报的审批内容移除
  751. const reportTaskTagClose = (index) => {
  752. const row = tableCheckedKeys.value[index];
  753. tableListRef.value?.toggleRowSelection(row, false)
  754. }
  755. //上报完成
  756. const showReportFinish = () => {
  757. showReportModal.value = false
  758. getTableData()
  759. }
  760. //批量认证
  761. const CertData = ref([])
  762. const CertIds = ref([])
  763. const CertPdf = ref('')
  764. const CertColumns = [
  765. {key: 'fileName', name: '文件名称'},
  766. {key: 'action', name: '操作', width: 100}
  767. ]
  768. //批量认证弹窗
  769. const showCertificationModal = ref(false)
  770. const certificationModalClick = () => {
  771. const rows = tableCheckedKeys.value;
  772. const result = rows.every(({isCertification}) => {
  773. return isCertification === 0
  774. })
  775. if (result) {
  776. CertData.value = rows
  777. CertIds.value = rowsToId(rows)
  778. CertPdf.value = rows[0]?.pdfFileUrl || ''
  779. showCertificationModal.value = true
  780. } else {
  781. window.$message?.warning('已认证的文件不能再认证')
  782. }
  783. }
  784. //认证行被点击
  785. const CertRowClick = ({row}) => {
  786. const pdfFileUrl = row?.pdfFileUrl || ''
  787. if (CertPdf.value !== pdfFileUrl) {
  788. CertPdf.value = pdfFileUrl
  789. }
  790. }
  791. //认证预览被点击
  792. const CertRowClick2 = ({pdfFileUrl}) => {
  793. const pdfUrl = pdfFileUrl || ''
  794. if (CertPdf.value !== pdfUrl) {
  795. CertPdf.value = pdfUrl
  796. }
  797. }
  798. //确认认证
  799. const CertLoading = ref(false)
  800. const CertClick = async () => {
  801. CertLoading.value = true
  802. const {error, code} = await projectScanningApi.batchCertification({
  803. ids: CertIds.value
  804. }, false)
  805. //判断状态
  806. CertLoading.value = false
  807. if (!error && code === 200) {
  808. window.$message?.success('认证成功')
  809. showCertificationModal.value = false
  810. getTableData()
  811. } else {
  812. window.$message?.error('认证失败')
  813. }
  814. }
  815. //批量删除
  816. const batchDel = () => {
  817. const rows = tableCheckedKeys.value;
  818. const result = rows.every(({status}) => {
  819. return status === 0
  820. })
  821. if (result) {
  822. const ids = rowsToId(rows)
  823. window?.$messageBox?.alert('请谨慎考虑是否要 批量删除文件?', '删除文件', {
  824. type: 'error',
  825. showCancelButton: true,
  826. confirmButtonText: '确定删除',
  827. cancelButtonText: '取消',
  828. callback: (action) => {
  829. if (action === 'confirm') {
  830. removeArchiveFile(ids)
  831. }
  832. }
  833. })
  834. } else {
  835. window.$message?.warning('已上报的文件需要先废除,才能执行删除')
  836. }
  837. }
  838. //确认批量删除
  839. const removeArchiveFile = async (ids) => {
  840. const {error, code} = await projectScanningApi.removeArchiveFile({
  841. ids: ids
  842. }, false)
  843. //判断状态
  844. CertLoading.value = false
  845. if (!error && code === 200) {
  846. window.$message?.success('删除成功')
  847. getTableData()
  848. } else {
  849. window.$message?.error('删除失败')
  850. }
  851. }
  852. //批量废除
  853. const batchAbolishClick = () => {
  854. const rows = tableCheckedKeys.value;
  855. const result = rows.every(({status}) => {
  856. return status > 0
  857. })
  858. if (result) {
  859. const ids = rowsToId(rows)
  860. window?.$messageBox?.alert('是否废除勾选的已上报文件?', '确认操作', {
  861. type: 'warning',
  862. showCancelButton: true,
  863. confirmButtonText: '确定废除',
  864. cancelButtonText: '取消',
  865. callback: (action) => {
  866. if (action === 'confirm') {
  867. batchAbolishSave(ids)
  868. }
  869. }
  870. })
  871. } else {
  872. window.$message?.warning('未上报的文件不能废除')
  873. }
  874. }
  875. //确认批量废除
  876. const batchAbolishSave = async (ids) => {
  877. const {error, code} = await projectScanningApi.batchAbolishSave({
  878. ids: ids
  879. }, false)
  880. //判断状态
  881. if (!error && code === 200) {
  882. window.$message?.success('批量废除成功')
  883. getTableData()
  884. } else {
  885. window.$message?.error('批量废除失败')
  886. }
  887. }
  888. //拼接ID
  889. const rowsToId = (rows) => {
  890. return rows.map((obj) => {
  891. return obj.id;
  892. }).join(",")
  893. }
  894. //左右拖动,改变树形结构宽度
  895. const leftWidth = ref(382)
  896. const onmousedown = () => {
  897. const leftNum = isCollapse.value ? 142 : 272
  898. document.onmousemove = (ve) => {
  899. const diffVal = ve.clientX - leftNum;
  900. if (diffVal >= 310 && diffVal <= 900) {
  901. leftWidth.value = diffVal;
  902. }
  903. }
  904. document.onmouseup = () => {
  905. document.onmousemove = null;
  906. document.onmouseup = null;
  907. }
  908. }
  909. </script>
  910. <style lang="scss" scoped>
  911. @import '../../styles/other-file/project-scanning.scss';
  912. </style>
  913. <style lang="scss">
  914. .el-table td.el-table__cell .hc-file-upload-box {
  915. display: inline-block;
  916. margin-right: 12px;
  917. }
  918. </style>