From 049fda473cc178917a02f3a174dfd08a84b0cb8d Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 17 九月 2026 10:52:28 +0800
Subject: [PATCH] 新疆——新聚lims 1.每个检验项都要有一个选择检测时间的地方,跟温湿度放在一起,还有检测地点,设备也要单独绑定检验项,最后导出模版再总结到一起 2.产品名称改为检测依据、加一个样品名称手输 3.下单时原始记录模板可以从标准库绑定的模板进行删减

---
 src/views/business/reportPreparation/index.vue |  233 ++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 147 insertions(+), 86 deletions(-)

diff --git a/src/views/business/reportPreparation/index.vue b/src/views/business/reportPreparation/index.vue
index 105e4b8..74f7232 100644
--- a/src/views/business/reportPreparation/index.vue
+++ b/src/views/business/reportPreparation/index.vue
@@ -11,37 +11,52 @@
             <el-option v-for="(a, i) in queryStatusList" :key="i" :label="a.label" :value="a.value"></el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="涓嬪崟绫诲埆" prop="typeSource">
-          <el-select v-model="entity.typeSource" clearable size="small" @change="refreshTable()">
-            <el-option v-for="(a, i) in typeSourceList" :key="i" :label="a.label" :value="a.value"></el-option>
-          </el-select>
-        </el-form-item>
+<!--        <el-form-item label="鎶ュ憡绫诲瀷" prop="reportType">-->
+<!--          <el-select v-model="entity.reportType" clearable size="small" @change="refreshTable()">-->
+<!--            <el-option v-for="item in reportTypeList" :key="item.value" :label="item.label" :value="item.value"></el-option>-->
+<!--          </el-select>-->
+<!--        </el-form-item>-->
+<!--        <el-form-item label="涓嬪崟绫诲埆" prop="typeSource">-->
+<!--          <el-select v-model="entity.typeSource" clearable size="small" @change="refreshTable()">-->
+<!--            <el-option v-for="(a, i) in typeSourceList" :key="i" :label="a.label" :value="a.value"></el-option>-->
+<!--          </el-select>-->
+<!--        </el-form-item>-->
+<!--        <el-form-item label="鐗╂枡灞炴��" prop="materialProp">-->
+<!--          <el-select clearable size="small" v-model="entity.materialProp" style="width: 100%">-->
+<!--            <el-option v-for="dict in dict.type.material_prop_type" :key="dict.value" :label="dict.label"-->
+<!--                       :value="dict.value">-->
+<!--            </el-option>-->
+<!--          </el-select>-->
+<!--        </el-form-item>-->
         <el-form-item label="妫�楠岀被鍒�" prop="orderType">
           <el-select v-model="entity.orderType" clearable size="small" @change="refreshTable()">
             <el-option v-for="(a, i) in orderTypeList" :key="i" :label="a.label" :value="a.value"></el-option>
           </el-select>
         </el-form-item>
         <el-form-item>
-          <el-button size="mini" @click="refresh()">閲嶇疆</el-button>
           <el-button size="mini" type="primary" @click="refreshTable()">鏌ヨ</el-button>
-          <el-button :loading="outLoading" size="mini" type="primary" @click="handleDowns">鎵归噺涓嬭浇</el-button>
+          <el-button size="mini" @click="refresh()">閲嶇疆</el-button>
         </el-form-item>
       </el-form>
+    </div>
+    <div style="text-align: right;margin-bottom: 10px">
+      <el-button :loading="outLoading" size="mini" type="primary" @click="handleDowns">鎵归噺涓嬭浇</el-button>
+      <el-button :loading="outExportLoading" size="mini" type="primary" @click="handleExport">鎶ヨ〃瀵煎嚭</el-button>
     </div>
     <div>
       <lims-table :tableData="valueTableData" :column="column" :page="page" :tableLoading="tableLoading"
         :isSelection="true" :handleSelectionChange="handleChange" :height="'calc(100vh - 290px)'"
         @pagination="pagination" key="valueTableData">
         <div slot="action" slot-scope="scope">
-          <el-button size="small" type="text" @click="viewIssued(scope.row)">鏌ョ湅鎶ュ憡</el-button>
+<!--          <el-button size="small" type="text" @click="viewIssued(scope.row)">鏌ョ湅鎶ュ憡</el-button>-->
           <el-upload ref='upload1' style="display: inline;margin: 0 6px" :action="fileAction1 + '?id=' + scope.row.id"
             :auto-upload="true" :before-upload="fileBeforeUpload1" :headers="uploadHeader" :on-error="onError1"
             :on-success="handleSuccessUp1" :show-file-list="false" accept='.doc,.docx'>
             <el-button size="small" type="text"
               :disabled="scope.row.state != 0 || nickName !== scope.row.writeUserName">涓婁紶</el-button>
           </el-upload>
-          <el-button type="text" size="small" :disabled="scope.row.state != 0 || nickName !== scope.row.writeUserName"
-            @click="handleRestore(scope.row)">杩樺師</el-button>
+<!--          <el-button type="text" size="small" :disabled="scope.row.state != 0 || nickName !== scope.row.writeUserName"-->
+<!--            @click="handleRestore(scope.row)">杩樺師</el-button>-->
           <el-button type="text" size="small" :disabled="scope.row.state != 0 || nickName !== scope.row.writeUserName"
             @click="sendBackTask(scope.row)">閫�鍥炰换鍔�</el-button>
           <el-button type="text" size="small" :disabled="scope.row.state != 0 || nickName !== scope.row.writeUserName"
@@ -52,16 +67,10 @@
           <el-button type="text" size="small"
             :disabled="scope.row.state == null || scope.row.state == 0 || scope.row.isExamine == 0 || scope.row.isExamine == null || scope.row.isRatify == 1 || nickName !== scope.row.ratifyUser"
             @click="handleApprove(scope.row)">鎵瑰噯</el-button>
-          <el-popover placement="bottom" trigger="hover" style="margin-left: 6px">
-            <template #reference>
-              <el-button link type="text" size="small">鏇村</el-button>
-            </template>
-            <div>
-              <el-button style="margin-left: 10px" type="text" size="small" @click="download(scope.row)">涓嬭浇</el-button>
-              <el-button type="text" size="small" @click="viewInspectInfo(scope.row)">鍘熷璁板綍</el-button>
-              <el-button type="text" size="small" @click="handleFileLook(scope.row)">闄勪欢涓婁紶</el-button>
-            </div>
-          </el-popover>
+          <el-button style="margin-left: 10px" type="text" size="small"
+                     :disabled="!scope.row.url && !scope.row.urlS" @click="download(scope.row)">涓嬭浇</el-button>
+          <el-button type="text" size="small" @click="viewInspectInfo(scope.row)">鍘熷璁板綍</el-button>
+          <el-button type="text" size="small" @click="handleFileLook(scope.row)">闄勪欢涓婁紶</el-button>
         </div>
       </lims-table>
     </div>
@@ -184,8 +193,8 @@
           <el-button size="small" style="height: 38px" type="primary">闄勪欢涓婁紶</el-button>
         </el-upload>
       </div>
-      <lims-table :tableData="tableDataFile" :column="columnFile" @pagination="paginationFile" height="500px"
-        key="tableDataFile" :page="pageFile" :tableLoading="tableLoadingFile"></lims-table>
+      <lims-table :tableData="tableDataFile" :column="columnFile" height="600px"
+        key="tableDataFile" :tableLoading="tableLoadingFile"></lims-table>
     </el-dialog>
   </div>
 </template>
@@ -193,28 +202,34 @@
 <script>
 import onlyoffice from "@/components/Onlyoffice/onlyoffice.vue";
 // import ShowInfo from "../do/b1-material-ins-order/showInfo.vue";
-import file from "@/utils/file";
 import {
   downAll,
+  downloadReport,
   examineReport,
   pageInsReport,
   ratifyReport,
   sendBackTask,
   upReportUrl,
-  writeReport
+  writeReport,
+  reportAllExport
 } from "@/api/business/insReport";
 import { mapGetters } from "vuex";
 import { selectUserCondition } from "@/api/business/inspectionTask";
 import limsTable from "@/components/Table/lims-table.vue";
-import { delfile, downFile, getFileList } from "@/api/business/rawMaterialOrder";
+import {delFile, downFile, getFileList} from "@/api/business/rawMaterialOrder";
 export default {
+  name: 'ReportPreparation',
   components: { limsTable, onlyoffice },
+  dicts: ['material_prop_type'],
   data() {
     return {
       entity: {
         queryStatus: null,
         code: null,
         typeSource: null,
+        orderType: null,
+        materialProp: null,
+        reportType: null
       },
       page: {
         current: 1,
@@ -239,6 +254,7 @@
       option: null,
       mutiList: [],
       outLoading: false,
+      outExportLoading: false,
       inLoading: false,
       addApproverDia: false, // 鎸囧畾瀹℃壒浜哄憳寮规
       approver: '', // 瀹℃壒浜哄憳
@@ -248,14 +264,19 @@
       verifyUser: null, // 瀹℃牳浜哄憳
       loadingVerify: false, // 瀹℃牳浜哄憳
       typeSourceList: [
-        { label: '鎴愬搧涓嬪崟', value: 0 },
+        { label: '濮旀墭涓嬪崟', value: -1 },
+        { label: '澶栬喘涓嬪崟', value: 0 },
         { label: '鍘熸潗鏂欎笅鍗�', value: 1 },
       ],
       orderTypeList: [
         { label: '濮旀墭璇曢獙', value: 'Customer-ordered test' },
         { label: '鎶芥', value: '鎶芥' },
-        { label: '杩涘巶妫�楠�', value: '杩涘巶妫�楠�' },
-        { label: '瀛e害妫�楠�', value: 'Quarterly inspection' },
+        // { label: '杩涘巶妫�楠�', value: '杩涘巶妫�楠�' },
+        // { label: '瀛e害妫�楠�', value: 'Quarterly inspection' },
+      ],
+      reportTypeList: [
+        { label: '妫�娴嬫姤鍛�', value: 0 },
+        { label: '妫�楠屾姤鍛�', value: 1 },
       ],
       showInfoDialog: false, // 浜т笟閾句俊鎭煡鐪�
       isReport: 1,
@@ -329,11 +350,6 @@
           ]
         }
       ],
-      pageFile: {
-        total: 0,
-        size: 10,
-        current: 1
-      },
       isCopper: null,
       tableLoading: false,
       valueTableData: [],
@@ -345,19 +361,44 @@
           dataType: "link",
           linkMethod: "selectAllByOne",
         },
-        {
-          label: "涓嬪崟绫诲埆",
-          prop: "typeSource",
-          width: "100px",
-          dataType: "tag",
-          formatData: (params) => {
-            if (params == 0) {
-              return "鎴愬搧涓嬪崟";
-            } else {
-              return "鍘熸潗鏂欎笅鍗�";
-            }
-          },
-        },
+        // {
+        //   label: '鎶ュ憡绫诲瀷',
+        //   prop: 'reportType',
+        //   width: '100px',
+        //   dataType: 'tag',
+        //   formatData: (params) => params === 0 ? '妫�娴嬫姤鍛�' : '妫�楠屾姤鍛�',
+        //   formatType: (params) => params === 0 ? 'warning' : 'success',
+        // },
+        // {
+        //   label: "涓嬪崟绫诲埆",
+        //   prop: "typeSource",
+        //   width: "100px",
+        //   dataType: "tag",
+        //   formatData: (params) => {
+        //     if (params == 0) {
+        //       return "澶栬喘涓嬪崟";
+        //     } else if(params==1) {
+        //       return "鍘熸潗鏂欎笅鍗�";
+        //     }else{
+        //       return "濮旀墭涓嬪崟";
+        //     }
+        //   },
+        // },
+        // {
+        //   label: '鐗╂枡灞炴��',
+        //   prop: 'materialProp',
+        //   formatData: (params) => {
+        //     if (!params) return null
+        //
+        //     for (let i = 0; i < this.dict.type.material_prop_type.length; i++) {
+        //       const item = this.dict.type.material_prop_type[i]
+        //       if (item.value == params) {
+        //         return item.label
+        //       }
+        //     }
+        //     return null
+        //   }
+        // },
         {
           label: "妫�楠岀被鍨�",
           prop: "orderType",
@@ -464,7 +505,7 @@
       return this.javaApi + '/insReport/upAll'
     },
     fileAction() {
-      return this.javaApi + '/unqualifiedHandler/uploadFileByUnqualified'
+      return this.javaApi + '/insOrderPlan/uploadFile'
     },
     fileAction1() {
       return this.javaApi + '/insReport/inReport'
@@ -524,19 +565,14 @@
     // 鏌ヨ闄勪欢鏌ョ湅鍒楄〃鍥炶皟
     getFileList() {
       this.tableLoadingFile = true
-      getFileList({ insOrderId: this.filesLookInfo.insOrderId }).then(res => {
+      getFileList({ insOrderId: this.filesLookInfo.insOrderId,current: -1, size: -1 }).then(res => {
         this.tableLoadingFile = false
         if (res.code === 200) {
           this.tableDataFile = res.data.records
-          this.pageFile.total = res.data.total
         }
       }).catch(err => {
         this.tableLoadingFile = false
       })
-    },
-    paginationFile(page) {
-      this.pageFile.size = page.limit
-      this.getFileList()
     },
     closeFilesLook() {
       this.filesDialogVisible = false
@@ -558,37 +594,33 @@
       downFile({
         id: row.id,
       }).then(res => {
-        if (res.code === 200) {
-          let url = '';
-          if (res.data.type == 1) {
-            url = this.javaApi + '/img/' + res.data.fileUrl
-            this.$download.saveAs(url, row.fileName);
-          } else {
-            url = this.javaApi + '/word/' + res.data.fileUrl
-            this.$download.saveAs(url, row.fileName);
-          }
-        }
+        this.$download.saveAs(res.data.fileUrl, row.fileName);
       }).catch(error => {
 
       })
     },
     // 鍒犻櫎闄勪欢鏂囦欢
     delete(row) {
-      this.$confirm('鏄惁鍒犻櫎褰撳墠鏁版嵁?', "璀﹀憡", {
-        confirmButtonText: "纭畾",
-        cancelButtonText: "鍙栨秷",
-        type: "warning"
+      this.$confirm('姝ゆ搷浣滃皢鍒犻櫎璇ユ暟鎹�, 鏄惁缁х画?', '鎻愮ず', {
+        confirmButtonText: '纭畾',
+        cancelButtonText: '鍙栨秷',
+        type: 'warning'
       }).then(() => {
-        delfile({ id: row.id }).then(res => {
-          if (res.code === 500) {
-            return
-          }
+        this.tableLoadingFile = true
+        delFile({ id: row.id }).then(res => {
+          this.tableLoadingFile = false
           this.$message.success('鍒犻櫎鎴愬姛')
-          this.getList()
-        }).catch(e => {
-          this.$message.error('鍒犻櫎澶辫触')
+          this.getFileList()
+        }).catch(err => {
+          this.tableLoadingFile = false
+          console.log('err---', err);
         })
-      }).catch(() => { })
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '宸插彇娑堝垹闄�'
+        });
+      })
     },
     // 鏌ョ湅浜т笟閾句俊鎭�
     openInfoDialog(row) {
@@ -606,7 +638,21 @@
       this.outLoading = true
       downAll({ ids: str }).then(res => {
         this.outLoading = false
-        this.$download.saveAs(this.javaApi + res.message, row.fileName);
+        this.$download.zip(res.data, '鎶ュ憡.zip');
+      }).catch(() => {
+        this.outLoading = false
+      })
+
+    },
+    // 鎶ヨ〃瀵煎嚭
+    handleExport() {
+      this.outExportLoading = true
+      reportAllExport({
+        ...this.entity
+      }).then(res => {
+        this.outExportLoading = false
+        const blob = new Blob([res], { type: 'application/octet-stream' });
+        this.$download.saveAs(blob, "鎶ュ憡鎶ヨ〃瀵煎嚭.xlsx");
       })
     },
     beforeUpload(file) {
@@ -621,6 +667,7 @@
     },
     fileBeforeUpload(file) {
       let flag = true
+      console.log('file----', file)
       if (file.size > 1024 * 1024 * 10) {
         this.$message.error('涓婁紶鏂囦欢涓嶈秴杩�10M');
         this.$refs.upload.clearFiles()
@@ -672,7 +719,7 @@
         case 0:
           // 鍘熸潗鏂�
           this.$router.push({
-            path: "/materialOrder/customsInspection", query: {
+            path: "/materialOrder/customsInspectionView", query: {
               customsInspection: row,
               active: this.activeFace,
               currentId: row.insOrderId,
@@ -683,7 +730,7 @@
         case null:
           // 鎴愬搧
           this.$router.push({
-            path: "/productOrder/add", query: {
+            path: "/productOrder/addView", query: {
               examine: this.examine,
               active: this.activeFace,
               currentId: row.insOrderId
@@ -693,7 +740,7 @@
         case 1:
           // 閾滄潗
           this.$router.push({
-            path: "/materialOrder/copperOrder", query: {
+            path: "/materialOrder/CopperView", query: {
               active: this.activeFace,
               currentId: row.insOrderId
             }
@@ -702,12 +749,25 @@
       }
     },
     download(row) {
-      let url = row.urlS ? row.urlS : row.url;
-      const link = document.createElement('a');
-      link.href = this.javaApi + url;
-      link.target = '_blank';
-      document.body.appendChild(link);
-      link.click();
+      downloadReport(row.id).then(res => {
+        if (res.type && res.type.includes('application/json')) {
+          const reader = new FileReader()
+          reader.onload = () => {
+            try {
+              this.$message.error(JSON.parse(reader.result).msg || '鎶ュ憡涓嬭浇澶辫触')
+            } catch (e) {
+              this.$message.error('鎶ュ憡涓嬭浇澶辫触')
+            }
+          }
+          reader.readAsText(res)
+          return
+        }
+        const reportUrl = row.urlS || row.url || ''
+        const filename = decodeURIComponent(reportUrl.substring(reportUrl.lastIndexOf('/') + 1)) || `${row.code}.docx`
+        this.$download.saveAs(res, filename)
+      }).catch(() => {
+        this.$message.error('鎶ュ憡涓嬭浇澶辫触')
+      })
     },
     // 杩樺師鎿嶄綔
     handleRestore(row) {
@@ -746,6 +806,7 @@
     },
     // 鏌ョ湅鎶ュ憡
     viewIssued(row) {
+      console.log('this.javaApi', this.javaApi)
       this.currentInfo = row;
       let fileName = (row.urlS === null || row.urlS === '') ? row.url : row.urlS
       let fileType = "docx"
@@ -824,7 +885,7 @@
     },
     // 鑾峰彇浜哄憳鍒楄〃
     getAuthorizedPerson() {
-      selectUserCondition({ type: 0 }).then((res) => {
+      selectUserCondition({ type: 1 }).then((res) => {
         let data = [];
         res.data.forEach((a) => {
           data.push({

--
Gitblit v1.9.3