test.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
  1. <template>
  2. <div class="hc-page-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">
  11. {{ projectInfo.name }}
  12. </div>
  13. </div>
  14. </div>
  15. <div class="hc-tree-box">
  16. <el-scrollbar>
  17. <TestTree
  18. :auto-expand-keys="treeAutoExpandKeys"
  19. :project-id="projectId"
  20. :tenant-id="userInfo?.tenant_id"
  21. :wbs-temp-id="projectInfo?.referenceWbsTemplateIdTrial"
  22. :wbs-type="2"
  23. @nodeTap="wbsElTreeClick"
  24. />
  25. <!-- <HcLazyTree
  26. :isType="false"
  27. :autoExpandKeys="treeAutoExpandKeys"
  28. @load="treeLoadNode"
  29. @nodeTap="wbsElTreeClick"
  30. /> -->
  31. </el-scrollbar>
  32. </div>
  33. <!-- 左右拖动 -->
  34. <div class="horizontal-drag-line" @mousedown="onmousedown" />
  35. </div>
  36. <div class="hc-page-content-box">
  37. <HcCard :scrollbar="false" action-size="lg">
  38. <template #header>
  39. <HcTooltip keys="tentative_detect_test_add">
  40. <el-button :disabled="!primaryKeyId" hc-btn type="primary" @click="addFormModalClick">
  41. <HcIcon name="add-circle" />
  42. <span>新增</span>
  43. </el-button>
  44. </HcTooltip>
  45. <HcTooltip keys="tentative_detect_test_copy">
  46. <el-button
  47. :disabled="tableCheckedKeys.length <= 0" :loading="copyLoading" hc-btn
  48. @click="copyDataClick"
  49. >
  50. <HcIcon name="file-copy-2" />
  51. <span>复制</span>
  52. </el-button>
  53. </HcTooltip>
  54. <HcTooltip keys="tentative_detect_test_del">
  55. <el-button
  56. :disabled="tableCheckedKeys.length <= 0" :loading="removeLoading" hc-btn
  57. @click="delModalClick"
  58. >
  59. <HcIcon name="delete-bin-2" />
  60. <span>删除</span>
  61. </el-button>
  62. </HcTooltip>
  63. <HcTooltip keys="tentative_detect_test_print">
  64. <el-button
  65. :disabled="tableCheckedKeys.length <= 0" :loading="printPdfLoading" hc-btn
  66. @click="printPdfClick"
  67. >
  68. <HcIcon name="printer" />
  69. <span>批量打印</span>
  70. </el-button>
  71. </HcTooltip>
  72. <HcTooltip keys="tentative_detect_test_report">
  73. <el-button
  74. :disabled="tableCheckedKeys.length <= 0" :loading="reportPdfLoading" hc-btn
  75. @click="reportPdfClick"
  76. >
  77. <HcIcon name="send-plane-2" />
  78. <span>批量上报</span>
  79. </el-button>
  80. </HcTooltip>
  81. <HcTooltip keys="tentative_detect_test_quit">
  82. <el-button
  83. :disabled="tableCheckedKeys.length <= 0" :loading="quitPdfLoading" hc-btn
  84. @click="quitPdfClick"
  85. >
  86. <HcIcon name="delete-bin-3" />
  87. <span>批量废除</span>
  88. </el-button>
  89. </HcTooltip>
  90. <HcTooltip keys="tentative_detect_test_null">
  91. <el-button
  92. :disabled="tableCheckedKeys.length <= 0" :loading="printNullPdfLoading" hc-btn
  93. @click="printNullPdfClick"
  94. >
  95. <HcIcon name="printer" />
  96. <span>打印空表</span>
  97. </el-button>
  98. </HcTooltip>
  99. </template>
  100. <template #extra>
  101. <el-button :type="authBtnTabKey === '1' ? 'primary' : ''" hc-btn @click="authBtnTabClick('1')">
  102. <HcIcon name="folder-user" />
  103. <span>施工自检</span>
  104. </el-button>
  105. <el-button :type="authBtnTabKey === '2' ? 'primary' : ''" hc-btn @click="authBtnTabClick('2')">
  106. <HcIcon name="folder-shield" />
  107. <span>监理质检</span>
  108. </el-button>
  109. </template>
  110. <template #search>
  111. <div class="w-40">
  112. <el-input
  113. v-model="searchForm.trialUserName" clearable placeholder="请输入试验人员"
  114. @keyup="keyUpEvent"
  115. />
  116. </div>
  117. <div class="w-40 ml-2">
  118. <el-select v-model="searchForm.queryStatus" clearable placeholder="请选择是否合格">
  119. <el-option
  120. v-for="item in qualifiedData" :key="item.value" :label="item.label"
  121. :value="item.value"
  122. />
  123. </el-select>
  124. </div>
  125. <div class="w-64 ml-2">
  126. <HcDatePicker :dates="betweenTime" clearable @change="betweenTimeUpdate" />
  127. </div>
  128. <div class="w-72 ml-2">
  129. <el-input
  130. v-model="searchForm.queryValue" clearable placeholder="请输入项目名称关键字"
  131. @keyup="keyUpEvent"
  132. />
  133. </div>
  134. <div class="ml-2">
  135. <el-button type="primary" @click="searchClick">
  136. <HcIcon name="search-2" />
  137. <span>搜索</span>
  138. </el-button>
  139. </div>
  140. </template>
  141. <HcTable
  142. ref="tableRef" :column="tableColumn" :datas="tableData" :loading="tableLoading" is-check
  143. @selection-change="tableSelection"
  144. >
  145. <template #recordNo="{ row }">
  146. <span class="text-link" @click="tableRowEdit(row, '1')">{{ row?.recordNo }}</span>
  147. </template>
  148. <template #reportNo="{ row }">
  149. <span class="text-link" @click="tableRowEdit(row, '2')">{{ row?.reportNo }}</span>
  150. </template>
  151. <template #trialProjectName="{ row }">
  152. <span class="text-link font-bold" @click="tableRowPdf(row)">{{ row?.trialProjectName }}</span>
  153. </template>
  154. <template #taskStatus="{ row }">
  155. <!-- <el-tag :type="`${row.status === 2 ? 'success' : row.status === 0 ? 'warning' : row.status === 1 ? 'danger' : 'info'}`" -->
  156. <el-tag
  157. v-if="row.taskStatus"
  158. :type="`${row.taskStatus === '已审批' ? 'success' : row.taskStatus === '待审批' ? 'warning' : row.taskStatus === '已废除' ? 'danger' : 'info'}`"
  159. class="mx-1" effect="dark"
  160. >
  161. {{ row.taskStatus }}
  162. </el-tag>
  163. </template>
  164. <template #detectionCategory="{ row }">
  165. <!-- <span>{{arrKeyValue(categoryData, 'dictKey', 'dictValue', row.detectionCategory)}}</span> -->
  166. <span>{{ row.detectionCategoryName }}</span>
  167. </template>
  168. <template #isUploadCertificate="{ row }">
  169. <!-- <span>{{row.isUploadCertificate == 0 ? '是':row.isUploadCertificate == -1?'' : '否'}}</span> -->
  170. <span>{{ row.isUploadCertificateName }}</span>
  171. </template>
  172. <template #contractId="{ row }">
  173. <span>{{ contractInfo?.name }}</span>
  174. </template>
  175. <template #detectionResult="{ row }">
  176. <span>{{ row?.reportNo && row?.reportNo.length > 0 ? row.detectionResultName : '' }}</span>
  177. </template>
  178. <template #action="{ row }">
  179. <HcTooltip keys="tentative_detect_test_annex">
  180. <el-button plain size="small" type="primary" @click="viewAttachmentModalClick(row)">
  181. 附件
  182. </el-button>
  183. </HcTooltip>
  184. <HcTooltip keys="tentative_detect_test_info">
  185. <el-button plain size="small" type="primary" @click="samplingRecordModalClick(row)">
  186. 样品信息
  187. </el-button>
  188. </HcTooltip>
  189. </template>
  190. </HcTable>
  191. <template #action>
  192. <HcPages :pages="searchForm" @change="pageChange" />
  193. </template>
  194. </HcCard>
  195. </div>
  196. <!-- 查看附件 -->
  197. <HcDialog
  198. :footer="false" :show="viewAttachmentModal" is-table title="查看附件" widths="70rem"
  199. @close="viewAttachmentModalClose"
  200. >
  201. <template #extra>
  202. <HcNewSwitch :datas="tabTypeTab" :keys="tabTypeKey" @change="tabTypeChange" />
  203. </template>
  204. <div v-loading="viewAttachmentLoading" class="hc-switch-tab-content">
  205. <div class="h-full w-full flex">
  206. <div v-if="viewAttachmentData.length > 0" class="pdf-file-list-box">
  207. <template v-for="item in viewAttachmentData">
  208. <div :class="[item.isCheck ? 'cur' : '']" class="file-item" @click="viewCurFile(item)">
  209. {{ item.fileName || '' }}
  210. </div>
  211. </template>
  212. </div>
  213. <div v-else class="pdf-file-list-box">
  214. <HcNoData />
  215. </div>
  216. <iframe v-if="attachmentPdfUrl" :src="attachmentPdfUrl" frameborder="1" height="100%" width="80%" />
  217. <div class="hc-no-table-form">
  218. <div class="table-form-no">
  219. <HcDragUpload
  220. :datas="uploadData" :file-list="fileListData" @delFile="delFileData"
  221. @finished="uploadFinished" @progress="uploadprogress"
  222. />
  223. </div>
  224. </div>
  225. </div>
  226. </div>
  227. </HcDialog>
  228. <!-- 查看样品信息 -->
  229. <HcDialog
  230. :footer="false" :show="samplingRecordModal" is-table title="查看样品信息" widths="60%"
  231. @close="samplingRecordModalClose"
  232. >
  233. <HcTable
  234. :column="samplingTableColumn" :datas="samplingTableData" :is-index="false"
  235. :loading="samplingTableLoading"
  236. />
  237. </HcDialog>
  238. <!-- 批量上报审批 -->
  239. <HcReportModal
  240. :addition="reportAddition" :contract-id="contractId" :ids="reportIds"
  241. :project-id="projectId" :show="showReportModal" :task-name="reportTaskName"
  242. :trial-self-inspection-record-id="1"
  243. :type-data="reportTypeData" title="批量上报审批" type="wbs"
  244. url="informationWriteQuery/batchTask" @finish="showReportFinish"
  245. @hide="showReportModal = false"
  246. />
  247. </div>
  248. </template>
  249. <script setup>
  250. import { onActivated, onMounted, ref, watch } from 'vue'
  251. import { useRouter } from 'vue-router'
  252. import { useAppStore } from '~src/store'
  253. import TestTree from '../material/components/TestTree.vue'
  254. import { delStoreValue, getStoreValue, setStoreValue } from '~src/utils/storage'
  255. import HcDragUpload from './components/HcDragUpload.vue'
  256. import dataApi from '~api/tentative/detect/test'
  257. import { getDictionary } from '~api/other'
  258. import { eVisaTaskCheckApi } from '~api/other'
  259. import wbsApi from '~api/data-fill/wbs'
  260. import samplingApi from '~api/tentative/material/sampling'
  261. import { arrKeyValue, arrToId, getArrValue, getObjValue, isString } from 'js-fast-way'
  262. import { Loading } from 'element-plus/es/components/loading/src/service'
  263. import notableform from '~src/assets/view/notableform.svg'
  264. import { delMessage } from '~uti/tools'
  265. //变量
  266. const router = useRouter()
  267. const useAppState = useAppStore()
  268. const userInfo = ref(useAppState.getUserInfo)
  269. const projectId = ref(useAppState.getProjectId)
  270. const contractId = ref(useAppState.getContractId)
  271. const projectInfo = ref(useAppState.getProjectInfo)
  272. const contractInfo = ref(useAppState.getContractInfo)
  273. const isCollapse = ref(useAppState.getCollapse)
  274. const isBubble = ref(useAppState.getBubble)
  275. //监听
  276. watch(() => [
  277. useAppState.getCollapse,
  278. useAppState.getBubble,
  279. ], ([Collapse, bubble]) => {
  280. isCollapse.value = Collapse
  281. isBubble.value = bubble
  282. })
  283. //获取气泡数据
  284. const getButtonsVal = (value) => {
  285. return useAppState.getButtonsVal(value)
  286. }
  287. //自动展开缓存
  288. const treeAutoExpandKeys = ref(getStoreValue('testTreeExpandKeys') || [])
  289. const btn_edit = ref(false)
  290. //渲染完成
  291. onMounted(() => {
  292. btn_edit.value = getButtonsVal('tentative_detect_test_edit')
  293. setContractType(contractInfo.value?.contractType)
  294. getCategoryData()
  295. })
  296. //缓存被激活时,重新获取表格数据
  297. onActivated(() => {
  298. // setMountOnEventKey()
  299. getTableData()
  300. })
  301. const qualifiedData = ref([
  302. { label: '不合格', value: '0' },
  303. { label: '合格', value: '1' },
  304. ])
  305. //加载树形结构数据
  306. const treeLoadNode = async ({ node, item, level }, resolve) => {
  307. let contractIdRelation = '', parentId = '0', primaryKeyId = ''
  308. if (level !== 0) {
  309. const nodeData = getObjValue(item)
  310. contractIdRelation = nodeData?.contractIdRelation || ''
  311. parentId = nodeData?.id
  312. primaryKeyId = nodeData?.id || ''
  313. }
  314. //获取数据
  315. const { data } = await samplingApi.queryLazyTree({
  316. wbsId: projectInfo.value?.referenceWbsTemplateIdTrial,
  317. tenantId: userInfo.value?.tenant_id,
  318. projectId: projectId.value,
  319. parentId,
  320. wbsType: 2,
  321. })
  322. resolve(getArrValue(data))
  323. }
  324. //获取检测类别类型
  325. const categoryData = ref([])
  326. const getCategoryData = async () => {
  327. const { data } = await getDictionary({
  328. code: 'trial_detection_category',
  329. })
  330. const arrData = getArrValue(data)
  331. arrData.forEach(item => {
  332. item.dictKey = Number(item.dictKey)
  333. })
  334. categoryData.value = arrData
  335. }
  336. //搜索表单
  337. const searchForm = ref({
  338. trialUserName: null, queryStatus: null, queryValue: null, type: '1',
  339. current: 1, size: 20, total: 0,
  340. })
  341. //树相关的变量
  342. const primaryKeyId = ref('')
  343. const nodeDataInfo = ref({})
  344. //树被点击
  345. const wbsElTreeClick = ({ data, keys }) => {
  346. nodeDataInfo.value = data
  347. primaryKeyId.value = data['primaryKeyId'] || ''
  348. setStoreValue('testTreeItem', data)
  349. //缓存自动展开
  350. treeAutoExpandKeys.value = keys
  351. setStoreValue('testTreeExpandKeys', keys)
  352. //改变搜索表单数据
  353. searchForm.value.nodeId = data['primaryKeyId']
  354. searchForm.value.current = 1
  355. getTableData()
  356. }
  357. //身份按钮切换数据
  358. const authBtnTabKey = ref('1')
  359. const authBtnTabClick = (val) => {
  360. if (val !== authBtnTabKey.value) {
  361. authBtnTabKey.value = val
  362. searchForm.value.type = val
  363. searchForm.value.current = 1
  364. getTableData()
  365. }
  366. }
  367. //contractType, 1施工,2监理
  368. const setContractType = (contractType) => {
  369. let typeValue = '1'
  370. if (contractType > 0) {
  371. typeValue = contractType + ''
  372. }
  373. authBtnTabKey.value = typeValue
  374. searchForm.value.type = typeValue
  375. searchForm.value.current = 1
  376. }
  377. //日期时间被选择
  378. const betweenTime = ref(null)
  379. const betweenTimeUpdate = ({ arr }) => {
  380. betweenTime.value = arr
  381. if (arr.length > 0) {
  382. searchForm.value.startTime = arr[0]
  383. searchForm.value.endTime = arr[1]
  384. } else {
  385. searchForm.value.startTime = ''
  386. searchForm.value.endTime = ''
  387. }
  388. }
  389. //回车搜索
  390. const keyUpEvent = (e) => {
  391. if (e.key === 'Enter') {
  392. searchForm.value.current = 1
  393. getTableData()
  394. }
  395. }
  396. //搜索
  397. const searchClick = () => {
  398. searchForm.value.current = 1
  399. getTableData()
  400. }
  401. //分页被点击
  402. const pageChange = ({ current, size }) => {
  403. searchForm.value.current = current
  404. searchForm.value.size = size
  405. getTableData()
  406. }
  407. //表格数据
  408. const tableRef = ref(null)
  409. const tableColumn = ref([
  410. { key: 'recordNo', name: '记录编号', width: 220 },
  411. { key: 'reportNo', name: '报告编号', width: 220 },
  412. { key: 'samplingLocation', name: '取样地点', width: 220 },
  413. { key: 'trialProjectName', name: '试验项目名称', width: 220 },
  414. { key: 'detectionResult', name: '检测结果', width: 160 },
  415. { key: 'taskStatus', name: '任务状态', width: 140 },
  416. { key: 'detectionCategory', name: '检测类别', width: 120 },
  417. { key: 'isUploadCertificate', name: '是否上传合格证', width: 130 },
  418. { key: 'contractId', name: '合同段', width: 220 },
  419. { key: 'company', name: '单位', width: 160 },
  420. { key: 'specificationNumber', name: '样品编号', width: 220 },
  421. { key: 'specificationModel', name: '规格类型', width: 200 },
  422. //{key:'projectPosition', name: '工程部位及用途', width: 160},
  423. { key: 'projectPositionName', name: '工程部位及用途', width: 160 },
  424. { key: 'reportDate', name: '报告日期', width: 170 },
  425. { key: 'trialUserName', name: '试验人员', width: 170 },
  426. { key: 'action', name: '操作', width: 150, fixed: 'right', align: 'center' },
  427. ])
  428. const tableData = ref([])
  429. //获取数据
  430. const tableLoading = ref(false)
  431. const getTableData = async () => {
  432. tableLoading.value = true
  433. const { error, code, data } = await dataApi.queryPage({
  434. ...searchForm.value,
  435. projectId: projectId.value,
  436. contractId: contractId.value,
  437. })
  438. //处理数据
  439. tableLoading.value = false
  440. if (!error && code === 200) {
  441. tableData.value = getArrValue(data?.records)
  442. searchForm.value.total = data?.total || 0
  443. } else {
  444. tableData.value = []
  445. searchForm.value.total = 0
  446. }
  447. }
  448. //多选
  449. const tableCheckedKeys = ref([])
  450. const tableSelection = (rows) => {
  451. tableCheckedKeys.value = rows
  452. }
  453. //新增
  454. const addFormModalClick = () => {
  455. delStoreValue('test-form')
  456. router.push({
  457. path: '/tentative/detect/test-form',
  458. query: {
  459. nodeId: primaryKeyId.value,
  460. dataType: authBtnTabKey.value,
  461. isaddType: true,
  462. },
  463. })
  464. }
  465. //编辑
  466. const tableRowEdit = (row, tabTypeKey) => {
  467. setStoreValue('test-form', row)
  468. setStoreValue('prenodeDataInfo', nodeDataInfo.value)
  469. console.log(JSON.stringify(nodeDataInfo.value), 'JSON.stringify(nodeDataInfo.value)')
  470. router.push({
  471. path: '/tentative/detect/test-form',
  472. query: {
  473. id: row.id,
  474. nodeId: row.nodeId,
  475. dataType: row.type,
  476. tabTypeKey: tabTypeKey,
  477. // prenodeDataInfo:JSON.stringify(nodeDataInfo.value)
  478. },
  479. })
  480. }
  481. //预览PDF
  482. const tableRowPdf = ({ pdfUrl }) => {
  483. if (pdfUrl) {
  484. window.open(pdfUrl, '_blank')
  485. } else {
  486. window.$message?.warning('该数据暂无PDF')
  487. }
  488. }
  489. //复制
  490. const copyDataClick = () => {
  491. const rows = tableCheckedKeys.value
  492. if (rows.length > 0) {
  493. const ids = arrToId(rows)
  494. copyDataApi(ids)
  495. } else {
  496. window.$message?.warning('请先勾选需要复制的记录')
  497. }
  498. }
  499. //请求复制
  500. const copyLoading = ref(false)
  501. const copyDataApi = async (ids) => {
  502. //请求数据
  503. copyLoading.value = true
  504. const { error, code, msg } = await dataApi.copyData({
  505. ids: ids,
  506. }, false)
  507. //处理数据
  508. copyLoading.value = false
  509. if (!error && code === 200) {
  510. window.$message?.success('复制成功')
  511. searchClick()
  512. } else {
  513. window.$message?.error(msg)
  514. }
  515. }
  516. //删除
  517. const delModalClick = () => {
  518. const rows = tableCheckedKeys.value
  519. if (rows.length > 0) {
  520. delMessage(() => {
  521. const ids = arrToId(rows)
  522. removeDataApi(ids)
  523. })
  524. } else {
  525. window.$message?.warning('请先勾选需要删除的记录')
  526. }
  527. }
  528. //请求删除
  529. const removeLoading = ref(false)
  530. const removeDataApi = async (ids) => {
  531. //请求数据
  532. removeLoading.value = true
  533. const { error, code, msg } = await dataApi.removeData({
  534. ids: ids,
  535. }, false)
  536. //处理数据
  537. removeLoading.value = false
  538. if (!error && code === 200) {
  539. window.$message?.success('删除成功')
  540. searchClick()
  541. } else {
  542. window.$message?.error(msg)
  543. }
  544. }
  545. //批量打印
  546. const printPdfLoading = ref(false)
  547. const printPdfClick = async () => {
  548. const rows = tableCheckedKeys.value
  549. if (rows.length > 0) {
  550. const ids = arrToId(rows)
  551. //请求数据
  552. printPdfLoading.value = true
  553. const { error, code, msg, data } = await dataApi.printPdf({
  554. ids: ids,
  555. }, false)
  556. //处理数据
  557. const pdfUrl = isString(data) ? data || '' : ''
  558. printPdfLoading.value = false
  559. if (!error && code === 200 && pdfUrl) {
  560. window.open(pdfUrl, '_blank')
  561. } else {
  562. window.$message?.error(msg || '文件异常')
  563. }
  564. } else {
  565. window.$message?.warning('请先勾选需要批量打印的记录')
  566. }
  567. }
  568. //批量废除
  569. const quitPdfLoading = ref(false)
  570. const quitPdfClick = async () => {
  571. const rows = tableCheckedKeys.value
  572. if (rows.length > 0) {
  573. const ids = arrToId(rows)
  574. const res1 = rows.some(item => item.taskStatus === '未上报')
  575. const res2 = rows.some(item => item.taskStatus === '已废除')
  576. if (res1) {
  577. window.$message?.warning('未上报的文件不能废除')
  578. } else if (res2) {
  579. window.$message?.warning('已废除的文件不能再次废除')
  580. } else {
  581. //请求数据
  582. quitPdfLoading.value = true
  583. const { error, code, msg, data } = await dataApi.batchAbolish({
  584. ids: ids,
  585. }, false)
  586. //处理数据
  587. if (!error && code === 200) {
  588. window.$message?.success('废除成功')
  589. quitPdfLoading.value = false
  590. searchClick()
  591. } else {
  592. quitPdfLoading.value = false
  593. window.$message?.error(msg)
  594. }
  595. }
  596. } else {
  597. window.$message?.warning('请先勾选需要批量打印的记录')
  598. }
  599. }
  600. //批量上报
  601. const reportPdfLoading = ref(false)
  602. //批量上报
  603. const reportIds = ref('')
  604. const reportTaskName = ref('')
  605. const reportAddition = ref({})
  606. const showReportModal = ref(false)
  607. const reportLoading = ref(false)
  608. const reportTypeData = ref([])
  609. const reportPdfClick = async () => {
  610. const rows = tableCheckedKeys.value
  611. if (rows.length > 0) {
  612. const info = getStoreValue('prenodeDataInfo') || {}
  613. const res1 = rows.some(item => item.pdfUrl.length < 1)
  614. const res2 = rows.some(item => item.taskStatus === '待审批' || item.taskStatus === '已审批')
  615. if (res1) {
  616. window.$message?.warning('当前数据暂无pdf无法上报')
  617. } else if (res2) {
  618. window.$message?.warning('已上报的数据无法再次上报')
  619. } else {
  620. reportLoading.value = true
  621. const ids = arrToId(rows)
  622. reportIds.value = ids
  623. const taskCheck = await eVisaTaskCheckApi({
  624. projectId: projectId.value,
  625. contractId: contractId.value,
  626. })
  627. //处理数据
  628. let newArr = []
  629. for (let i = 0; i < rows.length; i++) {
  630. newArr.push(rows[i]['tableIds'])
  631. }
  632. reportTypeData.value = [...newArr]
  633. console.log(reportTypeData.value, ' reportTypeData.value')
  634. reportLoading.value = false
  635. if (taskCheck) {
  636. //初始弹出弹窗,防呆
  637. reportAddition.value = {
  638. classify: authBtnTabKey.value,
  639. contractIdRelation: info['contractIdRelation'],
  640. }
  641. showReportModal.value = true
  642. //请求文件题名
  643. const { data } = await wbsApi.queryDocumentTitle({
  644. // primaryKeyId: info['primaryKeyId'],
  645. primaryKeyId: rows[0].id,
  646. classify: authBtnTabKey.value,
  647. })
  648. reportTaskName.value = isString(data) ? data : ''
  649. } else {
  650. window.$message?.warning('暂无相关数据')
  651. }
  652. }
  653. } else {
  654. window.$message?.warning('请先勾选需要批量上报的记录')
  655. }
  656. }
  657. //上报完成
  658. const showReportFinish = () => {
  659. showReportModal.value = false
  660. getTableData()
  661. }
  662. //打印空表
  663. const printNullPdfLoading = ref(false)
  664. const printNullPdfClick = async () => {
  665. const rows = tableCheckedKeys.value
  666. if (rows.length > 0) {
  667. const ids = arrToId(rows)
  668. //请求数据
  669. printNullPdfLoading.value = true
  670. const { error, code, msg, data } = await dataApi.printNullPdf({
  671. ids: ids,
  672. }, false)
  673. //处理数据
  674. const pdfUrl = isString(data) ? data || '' : ''
  675. printNullPdfLoading.value = false
  676. if (!error && code === 200 && pdfUrl) {
  677. window.open(pdfUrl, '_blank')
  678. } else {
  679. window.$message?.error(msg || '文件异常')
  680. }
  681. } else {
  682. window.$message?.warning('请先勾选需要打印空表的记录')
  683. }
  684. }
  685. //查看附件
  686. const viewAttachmentModal = ref(false)
  687. const viewAttachmentLoading = ref(false)
  688. const viewAttachmentId = ref('')
  689. const viewAttachmentData = ref([])
  690. const viewAttachmentModalClick = async ({ id }) => {
  691. viewAttachmentId.value = id
  692. viewAttachmentModal.value = true
  693. getAttachmentModalClick(viewAttachmentId.value, '1')
  694. }
  695. const getCaption = (obj) => {
  696. const index = obj.lastIndexOf('pdf')
  697. return index
  698. }
  699. //获取附件
  700. const getAttachmentModalClick = async (id, type) => {
  701. viewAttachmentLoading.value = true
  702. const { error, code, data } = await dataApi.ancillaryDocumentsList({ id: id, type: type })
  703. console.log(data, 'data')
  704. viewAttachmentLoading.value = false
  705. if (!error && code === 200) {
  706. viewAttachmentData.value = getArrValue(data)
  707. curFileData.value = viewAttachmentData.value[0]
  708. viewCurFile(curFileData.value)
  709. } else {
  710. viewAttachmentData.value = []
  711. }
  712. }
  713. const refeshAttachmentModalClick = async (id, type) => {
  714. const { error, code, data } = await dataApi.ancillaryDocumentsList({ id: id, type: type })
  715. //处理数据
  716. viewAttachmentLoading.value = false
  717. if (!error && code === 200) {
  718. viewAttachmentData.value = getArrValue(data)
  719. if (viewAttachmentData.value.length < 1) {
  720. // window.$message?.warning('该条记录不存在附件')
  721. } else {
  722. viewCurFile(viewAttachmentData.value[0])
  723. }
  724. } else {
  725. viewAttachmentData.value = []
  726. }
  727. }
  728. const attachmentPdfUrl = ref('')
  729. const curFileData = ref({})
  730. //类型tab数据和相关处理
  731. const tabTypeKey = ref('1')
  732. const tabTypeTab = ref([
  733. { key: '1', name: '生产合格证' },
  734. { key: '2', name: '厂家质检报告' },
  735. { key: '3', name: '其他文件' },
  736. ])
  737. const tabTypeChange = (item) => {
  738. console.log(1111111111)
  739. tabTypeKey.value = item?.key
  740. getAttachmentModalClick(viewAttachmentId.value, item?.key)
  741. fileListData.value = []
  742. refeshAttachmentModalClick(viewAttachmentId.value, tabTypeKey.value)
  743. }
  744. //关闭查看附件
  745. const viewAttachmentModalClose = () => {
  746. viewAttachmentModal.value = false
  747. curFileData.value = ''
  748. attachmentPdfUrl.value = ''
  749. }
  750. const uploadData = ref({})
  751. const fileListData = ref([])
  752. const listuploadref = ref('1')
  753. //截取文件名称
  754. const splitFileName = (str) => {
  755. // if(str.indexOf("https://bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload") != -1){
  756. if (str.indexOf('https://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload') != -1) {
  757. let a = str.split('//')[2].split('/')[2]
  758. return a
  759. } else {
  760. return str
  761. }
  762. }
  763. //查看当前文件pdf
  764. const viewCurFile = (item) => {
  765. console.log(item, 'item')
  766. if (item) {
  767. curFileData.value = item
  768. let arr = []
  769. arr.push({ name: item.fileName, url: item.url })
  770. fileListData.value = getArrValue(arr)
  771. viewAttachmentData.value.forEach((ele) => {
  772. ele.isCheck = false
  773. })
  774. item.isCheck = true
  775. }
  776. }
  777. //上传进度
  778. const uploadprogress = (res) => {
  779. console.log('进度')
  780. }
  781. //上传完成
  782. const uploadFinished = async (res) => {
  783. const { error, code, data } = await dataApi.updateAncillaryDocument(
  784. {
  785. selfId: viewAttachmentId.value,
  786. url: res.link,
  787. type: tabTypeKey.value,
  788. })
  789. console.log(data, 'data')
  790. if (!error && code === 200) {
  791. refeshAttachmentModalClick(viewAttachmentId.value, tabTypeKey.value)
  792. }
  793. }
  794. //上传文件delFileData
  795. const delFileData = async (res) => {
  796. console.log('删除文件', curFileData.value)
  797. if (curFileData.value.isDel == 0) {
  798. window.$message.warning('该文件不可删除')
  799. } else {
  800. const { error, code, data } = await dataApi.removedocuments(
  801. {
  802. id: curFileData.value.id,
  803. })
  804. if (!error && code === 200) {
  805. window.$message.success('删除成功')
  806. refeshAttachmentModalClick(viewAttachmentId.value, tabTypeKey.value)
  807. }
  808. }
  809. }
  810. //样品信息数据
  811. const samplingTableColumn = ref([
  812. { key: 'materialName', name: '样品名称' },
  813. { key: 'samplingDate', name: '取样时间' },
  814. { key: 'specificationNumber', name: '样品编号' },
  815. { key: 'specificationModel', name: '规格型号' },
  816. { key: 'materialCount', name: '试样数量' },
  817. { key: 'calculationUnit', name: '计算单位' },
  818. { key: 'proposedPosition', name: '拟用部位' },
  819. { key: 'representativeCount', name: '代表数量' },
  820. { key: 'userName', name: '取样人' },
  821. ])
  822. const samplingTableData = ref([])
  823. const samplingTableLoading = ref(false)
  824. //取样记录
  825. const samplingRecordModal = ref(false)
  826. const samplingRecordModalClick = async ({ id }) => {
  827. samplingRecordModal.value = true
  828. samplingTableLoading.value = true
  829. const { error, code, data } = await dataApi.getSampleList({
  830. id: id,
  831. })
  832. //处理数据
  833. samplingTableLoading.value = false
  834. if (!error && code === 200) {
  835. samplingTableData.value = getArrValue(data)
  836. } else {
  837. samplingTableData.value = []
  838. }
  839. }
  840. //关闭样品信息
  841. const samplingRecordModalClose = () => {
  842. samplingRecordModal.value = false
  843. samplingTableData.value = []
  844. }
  845. //左右拖动,改变树形结构宽度
  846. const leftWidth = ref(382)
  847. const onmousedown = () => {
  848. const leftNum = isCollapse.value ? 142 : 272
  849. document.onmousemove = (ve) => {
  850. let diffVal = ve.clientX - leftNum
  851. if (diffVal >= 310 && diffVal <= 900) {
  852. leftWidth.value = diffVal
  853. }
  854. }
  855. document.onmouseup = () => {
  856. document.onmousemove = null
  857. document.onmouseup = null
  858. }
  859. }
  860. </script>
  861. <style lang="scss" scoped>
  862. @import "../../../styles/tentative/detect/test.scss";
  863. .hc-switch-tab-content {
  864. .pdf-file-list-box {
  865. position: relative;
  866. border-right: 1px solid #e9e9e9;
  867. padding: 5px 0;
  868. overflow-y: auto;
  869. height: 100%;
  870. flex: 1;
  871. .file-item {
  872. position: relative;
  873. cursor: pointer;
  874. padding: 6px 10px;
  875. &:hover {
  876. color: var(--el-color-primary);
  877. background-color: var(--el-color-primary-light-8);
  878. }
  879. &.cur {
  880. color: var(--el-color-primary);
  881. background-color: var(--el-color-primary-light-8);
  882. }
  883. }
  884. }
  885. .hc-no-table-form {
  886. flex: 1;
  887. }
  888. }
  889. </style>