ソースを参照

试验检测>>新增【文件下载】按钮

duy 1 週間 前
コミット
a6c5a84601

+ 1 - 1
public/version.json

@@ -1,3 +1,3 @@
 {
-  "value": "20251203173935"
+  "value": "20251204155017"
 }

+ 9 - 1
src/api/modules/tentative/detect/test.js

@@ -274,5 +274,13 @@ export default {
             data: form,
         })
     },
-
+    //文件下载
+    async downloadFile(form) {
+        return HcApi({
+            url: '/api/blade-business/detection/self/download',
+            method: 'post',
+            responseType: 'blob',
+            params: form,
+        })
+    },
 }

+ 88 - 51
src/views/tentative/detect/test.vue

@@ -29,12 +29,12 @@
             <div class="horizontal-drag-line" @mousedown="onmousedown" />
         </div>
         <div class="hc-page-content-box">
-            <!---展开收缩树 -->
+            <!-- 展开收缩树 -->
             <div class="hc-expansion-contraction-tree" @click="setWbsTreeShow">
                 <hc-icon v-show="isWbsTreeShow" name="arrow-left-s" />
                 <hc-icon v-show="!isWbsTreeShow" name="arrow-right-s" />
             </div>
-            <HcTabCard :tabs="authBtnTabdata" :tab-key="authBtnTabKey" @change="authBtnTabClick">
+            <HcTabCard :tabs="authBtnTabData" :tab-key="authBtnTabKey" @change="authBtnTabClick">
                 <template #extra>
                     <HcTooltip keys="tentative_detect_test_add">
                         <el-button
@@ -111,7 +111,20 @@
                     </HcTooltip>
                     <el-button class="ml-2" :disabled="tableCheckedKeys.length <= 0" :loading="signLoading" hc-btn type="primary" @click="resignClick">re-sign</el-button>
                     <el-dropdown trigger="click">
-                        <el-button hc-btn type="success" :loading="dataBtnLoad">
+                        <el-button hc-btn :disabled="tableCheckedKeys.length <= 0" type="success" color="#2550A1" :loading="fileDownloadLoading">
+                            <span>文件下载</span>
+                            <hc-icon name="arrow-down-s" />
+                        </el-button>
+                        <template #dropdown>
+                            <el-dropdown-menu>
+                                <template v-for="(val, key) in fileDownloadType" :key="key">
+                                    <el-dropdown-item :disabled="tableCheckedKeys.length <= 0" @click="fileDownloadClick(key)">{{ val }}</el-dropdown-item>
+                                </template>
+                            </el-dropdown-menu>
+                        </template>
+                    </el-dropdown>
+                    <el-dropdown trigger="click">
+                        <el-button hc-btn type="success" class="ml-2" :loading="dataBtnLoad">
                             <span>综合功能</span>
                             <hc-icon name="arrow-down-s" />
                         </el-button>
@@ -192,7 +205,7 @@
                         <!-- <span>{{row.isUploadCertificate == 0 ? '是':row.isUploadCertificate == -1?'' : '否'}}</span> -->
                         <span>{{ row.isUploadCertificateName }}</span>
                     </template>
-                    <template #contractId="{ row }">
+                    <template #contractId>
                         <span>{{ contractInfo?.name }}</span>
                     </template>
                     <template #detectionResult="{ row }">
@@ -225,8 +238,8 @@
             <div v-loading="viewAttachmentLoading" class="hc-switch-tab-content">
                 <div class="h-full w-full flex">
                     <div v-if="viewAttachmentData.length > 0" class="pdf-file-list-box">
-                        <template v-for="item in viewAttachmentData">
-                            <div :class="[item.isCheck ? 'cur' : '']" class="file-item" @click="viewCurFile(item)">
+                        <template v-for="(item, index) in viewAttachmentData" :key="index">
+                            <div class="file-item" :class="[item.isCheck ? 'cur' : '']" @click="viewCurFile(item)">
                                 {{ item.fileName || '' }}
                             </div>
                         </template>
@@ -360,7 +373,7 @@ import dataApi from '~api/tentative/detect/test'
 import testSampleApi from '~api/tentative/material/testSample'
 import commissionApi from '~api/tentative/detect/commission'
 import acquisitionApi from '~api/tentative/acquisition/data'
-import { arrToId, arrToKey, formValidate, getArrValue, getObjVal, getObjValue, isNullES, isString } from 'js-fast-way'
+import { arrToId, arrToKey, downloadBlob, formValidate, getArrValue, getObjVal, getObjValue, isNullES, isString } from 'js-fast-way'
 import { HcDelMsg } from 'hc-vue3-ui'
 import { toPdfPage } from '~uti/btn-auth'
 
@@ -431,7 +444,7 @@ const getContractData = async () => {
     if (res.length <= 0) return
     let cid
     for (let i = 0; i < res.length; i++) {
-        if (contractId.value == res[i].id) {
+        if (String(contractId.value) === String(res[i].id)) {
             cid = res[i].id
         }
     }
@@ -492,7 +505,7 @@ const wbsElTreeClick = ({ data, keys }) => {
 
 //身份按钮切换数据
 const authBtnTabKey = ref('1')
-const authBtnTabdata = ref([
+const authBtnTabData = ref([
     { key: '1', name: '施工自检' },
     { key: '2', name: '监理抽检' },
     { key: '3', name: '业主抽检' },
@@ -556,6 +569,31 @@ const pageChange = ({ current, size }) => {
     getTableData()
 }
 
+// 文件下载
+const fileDownloadLoading = ref(false)
+const fileDownloadType = { 1:'整份下载', 2:'报告表下载', 3:'记录表下载', 4:'委托单下载' }
+const fileDownloadClick = async (type) => {
+    fileDownloadLoading.value = true
+    const rows = tableCheckedKeys.value
+    if (rows.some(el=> el.taskStatus !== '已审批')) {
+        window.$message?.warning('存在未审批的记录,无法下载')
+        return
+    }
+    const ids = arrToId(rows)
+    fileDownloadLoading.value = true
+    const { error, disposition, res, code } = await dataApi.downloadFile({ ids, type, classify: authBtnTabKey.value })
+    //处理数据
+    fileDownloadLoading.value = false
+    if (!error && code === 200) {
+        if (disposition) {
+            downloadBlob(res, disposition)
+        } else {
+            window.$message?.error('数据异常')
+        }
+    }
+}
+
+
 
 const dataBtnLoad = ref(false)
 //综合功能菜单
@@ -696,7 +734,7 @@ const copyDataApi = async (ids) => {
     //请求数据
     copyLoading.value = true
     dataBtnLoad.value = true
-    const { error, code, msg } = await dataApi.copyData({
+    const { error, code } = await dataApi.copyData({
         projectId: projectId.value,
         ids: ids,
     }, false)
@@ -728,7 +766,7 @@ const removeLoading = ref(false)
 const removeDataApi = async (ids) => {
     //请求数据
     removeLoading.value = true
-    const { error, code, msg } = await dataApi.removeData({
+    const { error, code } = await dataApi.removeData({
         projectId: projectId.value,
         ids: ids,
     }, false)
@@ -784,7 +822,7 @@ const quitPdfClick = async () => {
             //请求数据
             quitPdfLoading.value = true
             dataBtnLoad.value = true
-            const { error, code, msg } = await dataApi.batchAbolish({
+            const { error, code } = await dataApi.batchAbolish({
                 projectId: projectId.value,
                 contractId: contractId.value,
                 primaryKeyId: primaryKeyId.value,
@@ -913,10 +951,10 @@ const viewAttachmentModalClick = async ({ id }) => {
     getAttachmentModalClick(viewAttachmentId.value, '1')
 
 }
-const getCaption = (obj) => {
-    const index = obj.lastIndexOf('pdf')
-    return index
-}
+// const getCaption = (obj) => {
+//     const index = obj.lastIndexOf('pdf')
+//     return index
+// }
 
 //获取附件
 const getAttachmentModalClick = async (id, type) => {
@@ -981,18 +1019,17 @@ const viewAttachmentModalClose = () => {
 }
 const uploadData = ref({})
 const fileListData = ref([])
-const listuploadref = ref('1')
+// const listuploadref = ref('1')
 //截取文件名称
-const splitFileName = (str) => {
-    // if(str.indexOf("https://bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload") != -1){
-    if (str.indexOf('https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload') != -1) {
-        let a = str.split('//')[2].split('/')[2]
-        return a
-    } else {
-        return str
-    }
-
-}
+// const splitFileName = (str) => {
+//     // if(str.indexOf("https://bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload") != -1){
+//     if (str.indexOf('https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload') != -1) {
+//         let a = str.split('//')[2].split('/')[2]
+//         return a
+//     } else {
+//         return str
+//     }
+// }
 //查看当前文件pdf
 const viewCurFile = (item) => {
      if (!item) return
@@ -1022,7 +1059,7 @@ const viewCurFile = (item) => {
 }
 
 //上传进度
-const uploadprogress = (res) => {
+const uploadprogress = () => {
     console.log('进度')
 }
 
@@ -1044,7 +1081,7 @@ const uploadFinished = async (res) => {
         viewAttachmentLoading.value = true
         
         // 2. 调用更新附件接口
-        const { error, code, data } = await dataApi.updateAncillaryDocument({
+        const { error, code } = await dataApi.updateAncillaryDocument({
             selfId: viewAttachmentId.value,
             url: res.link,
             type: tabTypeKey.value,
@@ -1064,12 +1101,12 @@ const uploadFinished = async (res) => {
     }
 }
 //上传文件delFileData
-const delFileData = async (res) => {
+const delFileData = async () => {
     console.log('删除文件', curFileData.value)
-    if (curFileData.value.isDel == 0) {
+    if (Number(curFileData.value.isDel) === 0) {
         window.$message.warning('该文件不可删除')
     } else {
-        const { error, code, data } = await dataApi.removedocuments({
+        const { error, code } = await dataApi.removedocuments({
             projectId: projectId.value,
             id: curFileData.value.id,
         })
@@ -1098,21 +1135,21 @@ const samplingTableLoading = ref(false)
 
 //取样记录
 const samplingRecordModal = ref(false)
-const samplingRecordModalClick = async ({ id }) => {
-    samplingRecordModal.value = true
-    samplingTableLoading.value = true
-    const { error, code, data } = await dataApi.getSampleList({
-        projectId: projectId.value,
-        id: id,
-    })
-    //处理数据
-    samplingTableLoading.value = false
-    if (!error && code === 200) {
-        samplingTableData.value = getArrValue(data)
-    } else {
-        samplingTableData.value = []
-    }
-}
+// const samplingRecordModalClick = async ({ id }) => {
+//     samplingRecordModal.value = true
+//     samplingTableLoading.value = true
+//     const { error, code, data } = await dataApi.getSampleList({
+//         projectId: projectId.value,
+//         id: id,
+//     })
+//     //处理数据
+//     samplingTableLoading.value = false
+//     if (!error && code === 200) {
+//         samplingTableData.value = getArrValue(data)
+//     } else {
+//         samplingTableData.value = []
+//     }
+// }
 
 //关闭样品信息
 const samplingRecordModalClose = () => {
@@ -1170,7 +1207,7 @@ const relatedColumn1 = [
 const relatedData1 = ref([])
 const getSampleList = async (id) => {
     relatedData1.value = []
-    if (isNullES(id) || id == 0) return
+    if (isNullES(id) || Number(id) === 0) return
     const { data } = await dataApi.getSampleList({ id })
     relatedData1.value = getArrValue(data)
 }
@@ -1185,7 +1222,7 @@ const relatedColumn2 = [
 const relatedData2 = ref([])
 const getCommissionData = async (id) => {
     relatedData2.value = []
-    if (isNullES(id) || id == 0) return
+    if (isNullES(id) || Number(id) === 0) return
     const { data } = await commissionApi.detail(id)
     const res = getObjVal(data)
     relatedData2.value = res ? [res] : []
@@ -1224,7 +1261,7 @@ const relatedColumn3 = [
 const relatedData3 = ref([])
 const getAcquisitionData = async (id) => {
     relatedData3.value = []
-    if (isNullES(id) || id == 0) return
+    if (isNullES(id) || Number(id) === 0) return
     const { data } = await acquisitionApi.selectDataInfoById(id)
     const res = getObjVal(data)
     if (res) {
@@ -1506,7 +1543,7 @@ const closeSort = ()=>{
 const sortLoading = ref(false)
 const sortClick = async ()=>{
     sortLoading.value = true
-    const { error, code, data } = await dataApi.updateSort({
+    const { error, code } = await dataApi.updateSort({
     
         nodeId:searchForm.value.nodeId,
          type:searchForm.value.type,