|
|
@@ -142,7 +142,7 @@
|
|
|
@row-dblclick="gdbomupdateCompanyFunc"
|
|
|
style="width: 100%;height: 36vh" border tooltip-effect="dark" :data="ddtableData" row-key="ID" @selection-change="handleSelectionChange">
|
|
|
<!-- <el-table-column type="selection" width="30" /> -->
|
|
|
- <el-table-column align="left" label="序号" prop="序号" width="70"/>
|
|
|
+ <!-- <el-table-column align="left" label="序号" prop="序号" width="70"/> -->
|
|
|
<el-table-column align="left" label="备注" prop="备注" width="70"/>
|
|
|
<el-table-column align="left" label="文件类型" prop="文件类型" width="90"/>
|
|
|
<el-table-column align="left" label="关联产品" prop="关联产品" width="90"/>
|
|
|
@@ -164,14 +164,25 @@
|
|
|
@row-dblclick="ExcelShow"
|
|
|
style="width: 100%;height: 36vh" border tooltip-effect="dark" :data="jstableData" row-key="ID" @selection-change="handleSelectionChange">
|
|
|
<!-- <el-table-column type="selection" width="55" /> -->
|
|
|
- <el-table-column align="left" label="序号" prop="序号" width="70"/>
|
|
|
- <el-table-column align="left" label="备注" prop="备注" width="70"/>
|
|
|
- <el-table-column align="left" label="文件类型" prop="文件类型" width="90"/>
|
|
|
- <el-table-column align="left" label="关联产品" prop="关联产品" width="90"/>
|
|
|
- <el-table-column align="left" label="建档用户" prop="建档用户" width="90"/>
|
|
|
- <el-table-column align="left" label="建档时间" prop="建档时间" width="90"/>
|
|
|
- <el-table-column align="left" label="更新时间" prop="更新时间" width="90"/>
|
|
|
- <el-table-column fixed="right" label="操作" width="100">
|
|
|
+ <!-- <el-table-column align="left" label="序号" prop="序号" width="70"/> -->
|
|
|
+ <el-table-column align="left" label="备注" prop="附件备注" width="70"/>
|
|
|
+ <el-table-column align="left" label="文件类型" prop="附件类型" width="90"/>
|
|
|
+ <el-table-column align="left" label="关联产品" prop="关联编号" width="90"/>
|
|
|
+ <el-table-column align="left" label="建档用户" prop="sys_id" width="90"/>
|
|
|
+ <el-table-column align="left" label="建档时间" prop="sys_rq" width="90"/>
|
|
|
+ <el-table-column align="left" label="更新时间" prop="mod_rq" width="90"/>
|
|
|
+ <el-table-column fixed="right" label="操作" width="100">
|
|
|
+ <div>
|
|
|
+ <button @click="fetchAndConvertFile">预览和下载 PDF</button>
|
|
|
+
|
|
|
+ <!-- 弹窗结构 -->
|
|
|
+ <div v-if="showPdfModal" class="modal">
|
|
|
+ <div class="modal-content">
|
|
|
+ <span class="close" @click="closeModal">×</span>
|
|
|
+ <div ref="pdfContainer"></div> <!-- 用于显示 PDF -->
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
<!-- <template v-slot="{ row }">
|
|
|
<button @click="jsfj_del(row)">删除</button>
|
|
|
</template> -->
|
|
|
@@ -734,13 +745,16 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
- <el-row :gutter="24">
|
|
|
- <el-col :span="24">
|
|
|
- <el-form-item label="附件备注:" prop="address" class="mab">
|
|
|
- <el-input v-model="jsfjformdata.附件备注" id="附件备注" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
+ <el-row :gutter="24">
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="附件备注:" prop="address" class="mab">
|
|
|
+ <el-select v-model="jsfjformdata.附件备注" placeholder="请选择附件类型" id="附件备注">
|
|
|
+ <el-option label="订单资料附件" value="订单资料附件"></el-option>
|
|
|
+ <el-option label="技术附件" value="技术附件"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+</el-row>
|
|
|
<el-row :gutter="24">
|
|
|
<el-col :span="6"></el-col>
|
|
|
<el-col :span="12">
|
|
|
@@ -804,7 +818,9 @@ import { ElMessage, ElMessageBox,ElUpload, ElButton } from 'element-plus'
|
|
|
import { ref, reactive, computed, nextTick, watch,onMounted,onBeforeUnmount } from 'vue'
|
|
|
import { useUserStore } from '@/pinia/modules/user'
|
|
|
import axios from 'axios';
|
|
|
-import {Datalist,WorkOrderList,WorkOrderAdd,PrintListData,printDetailAdd,PrintDetailDel,orderDataDel,getWorkOrder,getSuborder,PrintDataEdit,WorkOrderEdit,gdAnnexAdd,upload} from '@/api/mes/job'
|
|
|
+import * as XLSX from 'xlsx';
|
|
|
+import jsPDF from 'jspdf';
|
|
|
+import {Datalist,WorkOrderList,WorkOrderAdd,PrintListData,printDetailAdd,PrintDetailDel,orderDataDel,getWorkOrder,getSuborder,PrintDataEdit,WorkOrderEdit,gdAnnexAdd,upload,OrderAttachments} from '@/api/mes/job'
|
|
|
import PrintPage from './components/print.vue'
|
|
|
import AddGongYi from './components/addGongYi.vue'
|
|
|
defineOptions({name: 'Company'})
|
|
|
@@ -1689,7 +1705,9 @@ const tableRowClick = async (row) => {
|
|
|
_ddhval.value = row.订单编号
|
|
|
try {
|
|
|
const PrintListDatas = await PrintListData({order:_Gd_gdbh.value})
|
|
|
- if(PrintListDatas.data.列表.length === 0){
|
|
|
+ const OrderAttachmentss = await OrderAttachments({order:_Gd_gdbh.value,desc:'技术附件'})
|
|
|
+ console.log(OrderAttachmentss.data.length)
|
|
|
+ if(PrintListDatas.data.列表.length === 0 ){
|
|
|
ystableData.length = []
|
|
|
}else{
|
|
|
sizeDatas.splice(0,PrintListDatas.data.型号.length,...PrintListDatas.data.型号);//型号数据
|
|
|
@@ -1703,11 +1721,92 @@ const tableRowClick = async (row) => {
|
|
|
ystableData.length = 0;
|
|
|
ystableData.push(...newData);
|
|
|
}
|
|
|
+ if(OrderAttachmentss.code === 0){
|
|
|
+ jstableData.splice(0,OrderAttachmentss.data.length,...OrderAttachmentss.data);
|
|
|
+ }
|
|
|
} catch (error) {
|
|
|
console.error(error);
|
|
|
}
|
|
|
}
|
|
|
+//pdf
|
|
|
+const showPdfModal = ref(false);
|
|
|
+const pdfContainer = ref(null);
|
|
|
|
|
|
+const closeModal = () => {
|
|
|
+ showPdfModal.value = false;
|
|
|
+};
|
|
|
+
|
|
|
+const fetchAndConvertFile = async () => {
|
|
|
+ try {
|
|
|
+ // 从后端获取 Base64 编码的 XLSX 文件数据
|
|
|
+ const responses = await OrderAttachments({order:_Gd_gdbh.value,desc:'技术附件'});
|
|
|
+ const response= responses.data[0].附件内容
|
|
|
+ const base64Data = response.match(/base64,(.*)$/)?.[1];
|
|
|
+
|
|
|
+ if (!base64Data) {
|
|
|
+ throw new Error('Invalid Base64 data');
|
|
|
+ }
|
|
|
+
|
|
|
+ const binaryString = atob(base64Data);
|
|
|
+ const binaryLen = binaryString.length;
|
|
|
+ const bytes = new Uint8Array(binaryLen);
|
|
|
+
|
|
|
+ for (let i = 0; i < binaryLen; i++) {
|
|
|
+ bytes[i] = binaryString.charCodeAt(i);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 解析 XLSX 文件
|
|
|
+ const workbook = XLSX.read(bytes, { type: 'array' });
|
|
|
+ const worksheet = workbook.Sheets[workbook.SheetNames[0]];
|
|
|
+ const jsonData = XLSX.utils.sheet_to_json(worksheet);
|
|
|
+
|
|
|
+ generatePdf(jsonData);
|
|
|
+ } catch (error) {
|
|
|
+ console.error('Error fetching and converting file:', error);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const generatePdf = (data) => {
|
|
|
+ console.log(465456,data)
|
|
|
+ const doc = new jsPDF();
|
|
|
+
|
|
|
+ let yPosition = 10;
|
|
|
+ data.forEach((row) => {
|
|
|
+ doc.text(10, yPosition, JSON.stringify(row));
|
|
|
+ yPosition += 10;
|
|
|
+ });
|
|
|
+
|
|
|
+ const pdfBlob = doc.output('blob');
|
|
|
+
|
|
|
+ previewPdf(pdfBlob);
|
|
|
+ downloadPdf(pdfBlob);
|
|
|
+};
|
|
|
+
|
|
|
+const previewPdf = (blob) => {
|
|
|
+ const fileURL = URL.createObjectURL(blob);
|
|
|
+
|
|
|
+ // 显示弹窗
|
|
|
+ showPdfModal.value = true;
|
|
|
+
|
|
|
+ // 通过 ref 引用 pdfContainer 来在指定容器中显示 PDF
|
|
|
+ const iframe = document.createElement('iframe');
|
|
|
+ iframe.src = fileURL;
|
|
|
+ iframe.width = '100%';
|
|
|
+ iframe.height = '600px';
|
|
|
+
|
|
|
+ if (pdfContainer.value) {
|
|
|
+ pdfContainer.value.innerHTML = ''; // 清空之前的内容
|
|
|
+ pdfContainer.value.appendChild(iframe);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const downloadPdf = (blob) => {
|
|
|
+ const link = document.createElement('a');
|
|
|
+ const fileURL = URL.createObjectURL(blob);
|
|
|
+ link.href = fileURL;
|
|
|
+ link.download = 'file.pdf';
|
|
|
+ link.click();
|
|
|
+};
|
|
|
|
|
|
const table_del = ref(true)
|
|
|
//表格复选框
|
|
|
@@ -2123,6 +2222,8 @@ const luckyexcelCloseDialog = () => {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
</script>
|
|
|
<style scoped>
|
|
|
/* 在样式表中使用媒体查询 */
|