test.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962
  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 { delMessageV2 } from '~com/message/index.js'
  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. delMessageV2(async (action, instance, done) => {
  521. if (action === 'confirm') {
  522. instance.confirmButtonLoading = true
  523. const ids = arrToId(rows)
  524. removeDataApi(ids)
  525. instance.confirmButtonLoading = false
  526. done()
  527. } else {
  528. done()
  529. }
  530. })
  531. } else {
  532. window.$message?.warning('请先勾选需要删除的记录')
  533. }
  534. }
  535. //请求删除
  536. const removeLoading = ref(false)
  537. const removeDataApi = async (ids) => {
  538. //请求数据
  539. removeLoading.value = true
  540. const { error, code, msg } = await dataApi.removeData({
  541. ids: ids,
  542. }, false)
  543. //处理数据
  544. removeLoading.value = false
  545. if (!error && code === 200) {
  546. window.$message?.success('删除成功')
  547. searchClick()
  548. } else {
  549. window.$message?.error(msg)
  550. }
  551. }
  552. //批量打印
  553. const printPdfLoading = ref(false)
  554. const printPdfClick = async () => {
  555. const rows = tableCheckedKeys.value
  556. if (rows.length > 0) {
  557. const ids = arrToId(rows)
  558. //请求数据
  559. printPdfLoading.value = true
  560. const { error, code, msg, data } = await dataApi.printPdf({
  561. ids: ids,
  562. }, false)
  563. //处理数据
  564. const pdfUrl = isString(data) ? data || '' : ''
  565. printPdfLoading.value = false
  566. if (!error && code === 200 && pdfUrl) {
  567. window.open(pdfUrl, '_blank')
  568. } else {
  569. window.$message?.error(msg || '文件异常')
  570. }
  571. } else {
  572. window.$message?.warning('请先勾选需要批量打印的记录')
  573. }
  574. }
  575. //批量废除
  576. const quitPdfLoading = ref(false)
  577. const quitPdfClick = async () => {
  578. const rows = tableCheckedKeys.value
  579. if (rows.length > 0) {
  580. const ids = arrToId(rows)
  581. const res1 = rows.some(item => item.taskStatus === '未上报')
  582. const res2 = rows.some(item => item.taskStatus === '已废除')
  583. if (res1) {
  584. window.$message?.warning('未上报的文件不能废除')
  585. } else if (res2) {
  586. window.$message?.warning('已废除的文件不能再次废除')
  587. } else {
  588. //请求数据
  589. quitPdfLoading.value = true
  590. const { error, code, msg, data } = await dataApi.batchAbolish({
  591. ids: ids,
  592. }, false)
  593. //处理数据
  594. if (!error && code === 200) {
  595. window.$message?.success('废除成功')
  596. quitPdfLoading.value = false
  597. searchClick()
  598. } else {
  599. quitPdfLoading.value = false
  600. window.$message?.error(msg)
  601. }
  602. }
  603. } else {
  604. window.$message?.warning('请先勾选需要批量打印的记录')
  605. }
  606. }
  607. //批量上报
  608. const reportPdfLoading = ref(false)
  609. //批量上报
  610. const reportIds = ref('')
  611. const reportTaskName = ref('')
  612. const reportAddition = ref({})
  613. const showReportModal = ref(false)
  614. const reportLoading = ref(false)
  615. const reportTypeData = ref([])
  616. const reportPdfClick = async () => {
  617. const rows = tableCheckedKeys.value
  618. if (rows.length > 0) {
  619. const info = getStoreValue('prenodeDataInfo') || {}
  620. const res1 = rows.some(item => item.pdfUrl.length < 1)
  621. const res2 = rows.some(item => item.taskStatus === '待审批' || item.taskStatus === '已审批')
  622. if (res1) {
  623. window.$message?.warning('当前数据暂无pdf无法上报')
  624. } else if (res2) {
  625. window.$message?.warning('已上报的数据无法再次上报')
  626. } else {
  627. reportLoading.value = true
  628. const ids = arrToId(rows)
  629. reportIds.value = ids
  630. const taskCheck = await eVisaTaskCheckApi({
  631. projectId: projectId.value,
  632. contractId: contractId.value,
  633. })
  634. //处理数据
  635. let newArr = []
  636. for (let i = 0; i < rows.length; i++) {
  637. newArr.push(rows[i]['tableIds'])
  638. }
  639. reportTypeData.value = [...newArr]
  640. console.log(reportTypeData.value, ' reportTypeData.value')
  641. reportLoading.value = false
  642. if (taskCheck) {
  643. //初始弹出弹窗,防呆
  644. reportAddition.value = {
  645. classify: authBtnTabKey.value,
  646. contractIdRelation: info['contractIdRelation'],
  647. }
  648. showReportModal.value = true
  649. //请求文件题名
  650. const { data } = await wbsApi.queryDocumentTitle({
  651. // primaryKeyId: info['primaryKeyId'],
  652. primaryKeyId: rows[0].id,
  653. classify: authBtnTabKey.value,
  654. })
  655. reportTaskName.value = isString(data) ? data : ''
  656. } else {
  657. window.$message?.warning('暂无相关数据')
  658. }
  659. }
  660. } else {
  661. window.$message?.warning('请先勾选需要批量上报的记录')
  662. }
  663. }
  664. //上报完成
  665. const showReportFinish = () => {
  666. showReportModal.value = false
  667. getTableData()
  668. }
  669. //打印空表
  670. const printNullPdfLoading = ref(false)
  671. const printNullPdfClick = async () => {
  672. const rows = tableCheckedKeys.value
  673. if (rows.length > 0) {
  674. const ids = arrToId(rows)
  675. //请求数据
  676. printNullPdfLoading.value = true
  677. const { error, code, msg, data } = await dataApi.printNullPdf({
  678. ids: ids,
  679. }, false)
  680. //处理数据
  681. const pdfUrl = isString(data) ? data || '' : ''
  682. printNullPdfLoading.value = false
  683. if (!error && code === 200 && pdfUrl) {
  684. window.open(pdfUrl, '_blank')
  685. } else {
  686. window.$message?.error(msg || '文件异常')
  687. }
  688. } else {
  689. window.$message?.warning('请先勾选需要打印空表的记录')
  690. }
  691. }
  692. //查看附件
  693. const viewAttachmentModal = ref(false)
  694. const viewAttachmentLoading = ref(false)
  695. const viewAttachmentId = ref('')
  696. const viewAttachmentData = ref([])
  697. const viewAttachmentModalClick = async ({ id }) => {
  698. viewAttachmentId.value = id
  699. viewAttachmentModal.value = true
  700. getAttachmentModalClick(viewAttachmentId.value, '1')
  701. }
  702. const getCaption = (obj) => {
  703. const index = obj.lastIndexOf('pdf')
  704. return index
  705. }
  706. //获取附件
  707. const getAttachmentModalClick = async (id, type) => {
  708. viewAttachmentLoading.value = true
  709. const { error, code, data } = await dataApi.ancillaryDocumentsList({ id: id, type: type })
  710. console.log(data, 'data')
  711. viewAttachmentLoading.value = false
  712. if (!error && code === 200) {
  713. viewAttachmentData.value = getArrValue(data)
  714. curFileData.value = viewAttachmentData.value[0]
  715. viewCurFile(curFileData.value)
  716. } else {
  717. viewAttachmentData.value = []
  718. }
  719. }
  720. const refeshAttachmentModalClick = async (id, type) => {
  721. const { error, code, data } = await dataApi.ancillaryDocumentsList({ id: id, type: type })
  722. //处理数据
  723. viewAttachmentLoading.value = false
  724. if (!error && code === 200) {
  725. viewAttachmentData.value = getArrValue(data)
  726. if (viewAttachmentData.value.length < 1) {
  727. // window.$message?.warning('该条记录不存在附件')
  728. } else {
  729. viewCurFile(viewAttachmentData.value[0])
  730. }
  731. } else {
  732. viewAttachmentData.value = []
  733. }
  734. }
  735. const attachmentPdfUrl = ref('')
  736. const curFileData = ref({})
  737. //类型tab数据和相关处理
  738. const tabTypeKey = ref('1')
  739. const tabTypeTab = ref([
  740. { key: '1', name: '生产合格证' },
  741. { key: '2', name: '厂家质检报告' },
  742. { key: '3', name: '其他文件' },
  743. ])
  744. const tabTypeChange = (item) => {
  745. console.log(1111111111)
  746. tabTypeKey.value = item?.key
  747. getAttachmentModalClick(viewAttachmentId.value, item?.key)
  748. fileListData.value = []
  749. refeshAttachmentModalClick(viewAttachmentId.value, tabTypeKey.value)
  750. }
  751. //关闭查看附件
  752. const viewAttachmentModalClose = () => {
  753. viewAttachmentModal.value = false
  754. curFileData.value = ''
  755. attachmentPdfUrl.value = ''
  756. }
  757. const uploadData = ref({})
  758. const fileListData = ref([])
  759. const listuploadref = ref('1')
  760. //截取文件名称
  761. const splitFileName = (str) => {
  762. // if(str.indexOf("https://bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload") != -1){
  763. if (str.indexOf('https://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload') != -1) {
  764. let a = str.split('//')[2].split('/')[2]
  765. return a
  766. } else {
  767. return str
  768. }
  769. }
  770. //查看当前文件pdf
  771. const viewCurFile = (item) => {
  772. console.log(item, 'item')
  773. if (item) {
  774. curFileData.value = item
  775. let arr = []
  776. arr.push({ name: item.fileName, url: item.url })
  777. fileListData.value = getArrValue(arr)
  778. viewAttachmentData.value.forEach((ele) => {
  779. ele.isCheck = false
  780. })
  781. item.isCheck = true
  782. }
  783. }
  784. //上传进度
  785. const uploadprogress = (res) => {
  786. console.log('进度')
  787. }
  788. //上传完成
  789. const uploadFinished = async (res) => {
  790. const { error, code, data } = await dataApi.updateAncillaryDocument(
  791. {
  792. selfId: viewAttachmentId.value,
  793. url: res.link,
  794. type: tabTypeKey.value,
  795. })
  796. console.log(data, 'data')
  797. if (!error && code === 200) {
  798. refeshAttachmentModalClick(viewAttachmentId.value, tabTypeKey.value)
  799. }
  800. }
  801. //上传文件delFileData
  802. const delFileData = async (res) => {
  803. console.log('删除文件', curFileData.value)
  804. if (curFileData.value.isDel == 0) {
  805. window.$message.warning('该文件不可删除')
  806. } else {
  807. const { error, code, data } = await dataApi.removedocuments(
  808. {
  809. id: curFileData.value.id,
  810. })
  811. if (!error && code === 200) {
  812. window.$message.success('删除成功')
  813. refeshAttachmentModalClick(viewAttachmentId.value, tabTypeKey.value)
  814. }
  815. }
  816. }
  817. //样品信息数据
  818. const samplingTableColumn = ref([
  819. { key: 'materialName', name: '样品名称' },
  820. { key: 'samplingDate', name: '取样时间' },
  821. { key: 'specificationNumber', name: '样品编号' },
  822. { key: 'specificationModel', name: '规格型号' },
  823. { key: 'materialCount', name: '试样数量' },
  824. { key: 'calculationUnit', name: '计算单位' },
  825. { key: 'proposedPosition', name: '拟用部位' },
  826. { key: 'representativeCount', name: '代表数量' },
  827. { key: 'userName', name: '取样人' },
  828. ])
  829. const samplingTableData = ref([])
  830. const samplingTableLoading = ref(false)
  831. //取样记录
  832. const samplingRecordModal = ref(false)
  833. const samplingRecordModalClick = async ({ id }) => {
  834. samplingRecordModal.value = true
  835. samplingTableLoading.value = true
  836. const { error, code, data } = await dataApi.getSampleList({
  837. id: id,
  838. })
  839. //处理数据
  840. samplingTableLoading.value = false
  841. if (!error && code === 200) {
  842. samplingTableData.value = getArrValue(data)
  843. } else {
  844. samplingTableData.value = []
  845. }
  846. }
  847. //关闭样品信息
  848. const samplingRecordModalClose = () => {
  849. samplingRecordModal.value = false
  850. samplingTableData.value = []
  851. }
  852. //左右拖动,改变树形结构宽度
  853. const leftWidth = ref(382)
  854. const onmousedown = () => {
  855. const leftNum = isCollapse.value ? 142 : 272
  856. document.onmousemove = (ve) => {
  857. let diffVal = ve.clientX - leftNum
  858. if (diffVal >= 310 && diffVal <= 900) {
  859. leftWidth.value = diffVal
  860. }
  861. }
  862. document.onmouseup = () => {
  863. document.onmousemove = null
  864. document.onmouseup = null
  865. }
  866. }
  867. </script>
  868. <style lang="scss" scoped>
  869. @import "../../../styles/tentative/detect/test.scss";
  870. .hc-switch-tab-content {
  871. .pdf-file-list-box {
  872. position: relative;
  873. border-right: 1px solid #e9e9e9;
  874. padding: 5px 0;
  875. overflow-y: auto;
  876. height: 100%;
  877. flex: 1;
  878. .file-item {
  879. position: relative;
  880. cursor: pointer;
  881. padding: 6px 10px;
  882. &:hover {
  883. color: var(--el-color-primary);
  884. background-color: var(--el-color-primary-light-8);
  885. }
  886. &.cur {
  887. color: var(--el-color-primary);
  888. background-color: var(--el-color-primary-light-8);
  889. }
  890. }
  891. }
  892. .hc-no-table-form {
  893. flex: 1;
  894. }
  895. }
  896. </style>