test.vue 34 KB

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