|
|
@@ -8,11 +8,11 @@
|
|
|
<el-form-item>
|
|
|
<el-input v-model="searchInfo" placeholder="搜索订单编号" style="width: 180px;" @keyup.enter="onSubmit()"></el-input>
|
|
|
<el-button type="primary" icon="search" @click="onSubmit" title="搜索" ></el-button>
|
|
|
+ <el-button type="primary" icon="edit" @click="cp_gdprintonClick" class="bt" title="打印生产订单" >订单打印</el-button>
|
|
|
<el-button type="primary" class="bt" icon="edit" @click="jsfjClick">附件上传</el-button>
|
|
|
<el-button type="primary" icon="edit" @click="addgd_onclick" class="bt" title="新增工单资料">新增订单资料</el-button>
|
|
|
<el-button type="primary" icon="edit" @click="addgdyj_onclick" class="bt" title="新增颜色资料">新增颜色资料</el-button>
|
|
|
<el-button type="primary" icon="edit" @click="addgdgy_onclick" class="bt" title="新增工序资料" >新增工序资料</el-button>
|
|
|
- <el-button type="primary" icon="edit" @click="cp_gdprintonClick" class="bt" title="打印生产订单" >订单打印</el-button>
|
|
|
<el-button type="primary" icon="edit" @click="del_ddzlClick" v-if="table_del=== true" :disabled="table_Selection === ''" class="bt" title="删除订单资料" >删除订单资料</el-button>
|
|
|
<el-button type="primary" icon="edit" @click="delgd_delclick" v-if="delall=== true" :disabled="ysSelection === '' && gySelection === ''" class="bt" >删除颜色工艺资料</el-button>
|
|
|
</el-form-item>
|
|
|
@@ -127,10 +127,10 @@
|
|
|
</el-table>
|
|
|
</el-tab-pane>
|
|
|
|
|
|
- <el-tab-pane label="订单资料附件" @click="showTable('订单资料附件')" name="third">
|
|
|
+ <el-tab-pane label="订单资料附件" name="third">
|
|
|
<el-table ref="multipleTable"
|
|
|
- :row-style="{ height: '20px' }"
|
|
|
- :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
|
|
|
+ :row-style="{ height: '30px' }"
|
|
|
+ :cell-style="{ padding: '0px' }" :header-row-style="{ height: '30px' }"
|
|
|
:header-cell-style="{ padding: '0px' }"
|
|
|
:show-overflow-tooltip="true"
|
|
|
:cell-class-name="planUsageCellClass"
|
|
|
@@ -138,31 +138,30 @@
|
|
|
@row-dblclick="gdbomupdateCompanyFunc"
|
|
|
style="width: 100%;height: 36vh" border tooltip-effect="dark" :data="ddtableData" row-key="ID"
|
|
|
@selection-change="fjSelectionChange">
|
|
|
- <!-- <el-table-column type="selection" width="30" /> -->
|
|
|
- <el-table-column align="left" label="关联编号" prop="关联编号" width="105"/>
|
|
|
- <el-table-column align="left" label="建档时间" prop="sys_rq" width="160"/>
|
|
|
- <el-table-column align="left" label="建档用户" prop="sys_id" width="160"/>
|
|
|
- <el-table-column align="left" label="文件类型" prop="附件类型" width="90"/>
|
|
|
- <el-table-column align="left" label="备注" prop="附件备注" width="110"/>
|
|
|
+ <el-table-column align="left" label="关联编号" prop="关联编号" width="115"/>
|
|
|
+ <el-table-column align="left" label="备注" prop="附件备注" width="110"/>
|
|
|
+ <el-table-column align="left" label="文件类型" prop="附件类型" width="100"/>
|
|
|
+ <el-table-column align="left" label="建档时间" prop="sys_rq" width="160"/>
|
|
|
+ <el-table-column align="left" label="建档用户" prop="sys_id" width="200"/>
|
|
|
</el-table>
|
|
|
</el-tab-pane>
|
|
|
+
|
|
|
|
|
|
<el-tab-pane label="技术附件" @click="showTable('技术附件')" name="fourth">
|
|
|
<el-table ref="multipleTable"
|
|
|
- :row-style="{ height: '20px' }"
|
|
|
- :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
|
|
|
+ :row-style="{ height: '30px' }"
|
|
|
+ :cell-style="{ padding: '0px' }" :header-row-style="{ height: '30px' }"
|
|
|
:header-cell-style="{ padding: '0px' }"
|
|
|
:show-overflow-tooltip="true"
|
|
|
:cell-class-name="planUsageCellClass"
|
|
|
highlight-current-row="true"
|
|
|
@row-dblclick="ExcelShow"
|
|
|
style="width: 100%;height: 36vh" border tooltip-effect="dark" :data="jstableData" row-key="ID" @selection-change="fjSelectionChange">
|
|
|
- <!-- <el-table-column type="selection" width="55" /> -->
|
|
|
- <el-table-column align="left" label="关联编号" prop="关联编号" width="105"/>
|
|
|
+ <el-table-column align="left" label="关联编号" prop="关联编号" width="115"/>
|
|
|
+ <el-table-column align="left" label="备注" prop="附件备注" width="110"/>
|
|
|
+ <el-table-column align="left" label="文件类型" prop="附件类型" width="100"/>
|
|
|
<el-table-column align="left" label="建档时间" prop="sys_rq" width="160"/>
|
|
|
- <el-table-column align="left" label="建档用户" prop="sys_id" width="160"/>
|
|
|
- <el-table-column align="left" label="文件类型" prop="附件类型" width="90"/>
|
|
|
- <el-table-column align="left" label="备注" prop="附件备注" width="110"/>
|
|
|
+ <el-table-column align="left" label="建档用户" prop="sys_id" width="200"/>
|
|
|
</el-table>
|
|
|
</el-tab-pane>
|
|
|
</el-tabs>
|
|
|
@@ -872,8 +871,12 @@
|
|
|
<link href="https://cdn.jsdelivr.net/npm/vue-plugin-hiprint@1.0.0/dist/print-lock.css" rel="stylesheet" media="print">
|
|
|
<link href="https://unpkg.com/vue-plugin-hiprint@1.0.0/dist/print-lock.css" rel="stylesheet">
|
|
|
</div> -->
|
|
|
-
|
|
|
+ <div id="preview"></div>
|
|
|
</div>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
</template>
|
|
|
<script>
|
|
|
//点击按钮显示下方表格
|
|
|
@@ -911,6 +914,7 @@ import PrintPage from './components/print.vue'
|
|
|
import AddGongYi from './components/addGongYi.vue'
|
|
|
import { useUserStore } from '@/pinia/modules/user';
|
|
|
|
|
|
+
|
|
|
defineOptions({name: 'Company'})
|
|
|
//定义打印跳转页面
|
|
|
const printPageRef = ref()
|
|
|
@@ -1964,25 +1968,35 @@ for (let i = 0; i < binaryLen; i++) {
|
|
|
const worksheet = workbook.Sheets[workbook.SheetNames[0]];
|
|
|
console.log(121212,worksheet)
|
|
|
const jsonData = XLSX.utils.sheet_to_json(worksheet);
|
|
|
- generatePdf(jsonData);
|
|
|
+
|
|
|
+ let base64 = XLSX.write(worksheet, { type: 'base64' });
|
|
|
+
|
|
|
+ generatePdf(base64);
|
|
|
} catch (error) {
|
|
|
console.error('Error fetching and converting file:', error);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const generatePdf = (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);
|
|
|
+ // let yPosition = 10;
|
|
|
+ // data.forEach((row) => {
|
|
|
+ // const doc = new jsPDF();
|
|
|
+ // doc.text(10, yPosition, JSON.stringify(row));
|
|
|
+ // yPosition += 10;
|
|
|
+ // });
|
|
|
+
|
|
|
+ // const pdfBlob = doc.output('blob');
|
|
|
+
|
|
|
+ // previewPdf(pdfBlob);
|
|
|
+ // downloadPdf(pdfBlob);
|
|
|
+ console/log('pdf data', data)
|
|
|
+ const pdfDoc = new jsPDF()
|
|
|
+ pdfDoc.text(data)
|
|
|
+ pdfDoc.save(a4.pdf)
|
|
|
+
|
|
|
+
|
|
|
};
|
|
|
|
|
|
const previewPdf = (blob) => {
|
|
|
@@ -2241,7 +2255,9 @@ const yulan = (event) =>{
|
|
|
$.getScript('/luckysheet/plugins/js/plugin.js', () => {
|
|
|
$script('/luckysheet/luckysheet.umd.js', () => {
|
|
|
luckyexcelVisible.value = true
|
|
|
+
|
|
|
LuckyExcel.transformExcelToLucky(jsfjformdata.value.附件内容, function(exportJson, luckysheetfile){
|
|
|
+ console.log('jsfjformdata.value.附件内容', jsfjformdata.value.附件内容)
|
|
|
if(exportJson.sheets==null || exportJson.sheets.length==0){
|
|
|
alert("Failed to read the content of the excel file, currently does not support xls files!");
|
|
|
return;
|
|
|
@@ -2303,11 +2319,6 @@ const jsfj_del = (row) =>{
|
|
|
|
|
|
//技术附件弹窗确定
|
|
|
const jsfjenterDialog = () => {
|
|
|
-
|
|
|
- // console.log(jsfjformdata.value.附件类型)
|
|
|
-
|
|
|
-
|
|
|
- // return;
|
|
|
if(jsfjformdata.value.附件备注==''){
|
|
|
ElMessage({
|
|
|
type: 'error',
|
|
|
@@ -2329,11 +2340,6 @@ const jsfjenterDialog = () => {
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
- //判断验证上传文件类型是否为 xlsx
|
|
|
- // if(){//不是此类型提示
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
let fr = new FileReader();
|
|
|
fr.readAsDataURL(jsfjformdata.value.附件内容);
|
|
|
fr.onload = function () {
|
|
|
@@ -2343,7 +2349,7 @@ const jsfjenterDialog = () => {
|
|
|
restoredData.append('附件内容', fr.result);
|
|
|
restoredData.append('附件类型', jsfjformdata.value.附件类型);
|
|
|
restoredData.append('关联编号', jsfjformdata.value.关联编号);
|
|
|
-
|
|
|
+ //将restoredDta数据新增到接口
|
|
|
gdAnnexAdd(restoredData).then(response => {
|
|
|
if(response.code==0){
|
|
|
ElMessage({
|
|
|
@@ -2361,116 +2367,244 @@ const jsfjenterDialog = () => {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-//订单资料附件
|
|
|
-const gdbomupdateCompanyFunc = (row) =>{
|
|
|
- if(!row.附件内容) return
|
|
|
- $.getScript('/luckysheet/plugins/js/plugin.js', () => {
|
|
|
- $script('/luckysheet/luckysheet.umd.js', () => {
|
|
|
- function dataURLtoBlob(dataUrl) {
|
|
|
- const byteString = atob(dataUrl.split(',')[1]);
|
|
|
- const ab = new ArrayBuffer(byteString.length);
|
|
|
- const ia = new Uint8Array(ab);
|
|
|
-
|
|
|
- for (let i = 0; i < byteString.length; i++) {
|
|
|
- ia[i] = byteString.charCodeAt(i);
|
|
|
- }
|
|
|
-
|
|
|
- return new Blob([ab], { type: 'application/octet-stream' });
|
|
|
- }
|
|
|
-
|
|
|
- const blob = dataURLtoBlob(row.附件内容);
|
|
|
- luckyexcelVisible.value = true
|
|
|
- LuckyExcel.transformExcelToLucky(blob, function(exportJson, luckysheetfile){
|
|
|
- if(exportJson.sheets==null || exportJson.sheets.length==0){
|
|
|
- alert("Failed to read the content of the excel file, currently does not support xls files!");
|
|
|
- return;
|
|
|
- }
|
|
|
- if(luckyExcel) luckyExcel.destroy();
|
|
|
- luckysheet.create({
|
|
|
- container: 'luckyexcel', //容器的ID
|
|
|
- data: exportJson.sheets,
|
|
|
- title: exportJson.info.name, // 工作簿名称
|
|
|
- lang: "zh", // 设定表格语言 国际化设置,允许设置表格的语言,支持中文("zh")和英文("en")
|
|
|
- showtoolbar: false, // 是否显示工具栏
|
|
|
- showinfobar: false, // 是否显示顶部信息栏
|
|
|
- allowEdit: false, // 是否允许前台编辑
|
|
|
- enableAddRow: false, // 允许增加行
|
|
|
- enableAddCol: false, // 允许增加列
|
|
|
- userInfo: false, // 右上角的用户信息展示样式
|
|
|
- showRowBar: false, // 是否显示行号区域
|
|
|
- showColumnBar: false, // 是否显示列号区域
|
|
|
- sheetFormulaBar: false, // 是否显示公式栏
|
|
|
- enableAddBackTop: false,//返回头部按钮
|
|
|
- });
|
|
|
- luckyExcel = luckysheet;
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
- $('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', '/luckysheet/plugins/css/pluginsCss.css'));
|
|
|
- $('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', '/luckysheet/plugins/plugins.css'));
|
|
|
- $('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', '/luckysheet/css/luckysheet.css'));
|
|
|
- $('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', '/luckysheet/assets/iconfont/iconfont.css'));
|
|
|
-}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+//订单资料附件 - 预览
|
|
|
+const gdbomupdateCompanyFunc = (row) => {
|
|
|
+ // 加载插件和样式
|
|
|
+ const loadScriptsAndStyles = () => {
|
|
|
+ // 加载插件脚本
|
|
|
+ $.getScript('/luckysheet/plugins/js/plugin.js', () => {
|
|
|
+ $script('/luckysheet/luckysheet.umd.js', () => {
|
|
|
+ initializeLuckysheet(); // 加载完成后初始化 Luckysheet
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ // 定义样式文件路径
|
|
|
+ const styles = [
|
|
|
+ '/luckysheet/plugins/css/pluginsCss.css',
|
|
|
+ '/luckysheet/plugins/plugins.css',
|
|
|
+ '/luckysheet/css/luckysheet.css',
|
|
|
+ '/luckysheet/assets/iconfont/iconfont.css'
|
|
|
+ ];
|
|
|
+
|
|
|
+ // 添加样式文件到页面
|
|
|
+ styles.forEach(style => {
|
|
|
+ $('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', style));
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ // 初始化 Luckysheet
|
|
|
+ const initializeLuckysheet = () => {
|
|
|
+ const callback = (exportJson, luckysheetfile) => {
|
|
|
+ if (!exportJson.sheets || exportJson.sheets.length === 0) {
|
|
|
+ alert("无法读取Excel文件内容,目前不支持xls文件格式!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (luckyExcel) luckyExcel.destroy(); // 销毁之前的实例
|
|
|
+ luckysheet.create({
|
|
|
+ container: 'luckyexcel',
|
|
|
+ data: exportJson.sheets,
|
|
|
+ title: exportJson.info.name,
|
|
|
+ lang: "zh",
|
|
|
+ showtoolbar: false,
|
|
|
+ showinfobar: false,
|
|
|
+ allowEdit: false,
|
|
|
+ enableAddRow: false,
|
|
|
+ enableAddCol: false,
|
|
|
+ userInfo: false,
|
|
|
+ showRowBar: false,
|
|
|
+ showColumnBar: false,
|
|
|
+ sheetFormulaBar: false,
|
|
|
+ enableAddBackTop: false,
|
|
|
+ });
|
|
|
+ luckyExcel = luckysheet; // 存储实例
|
|
|
+ };
|
|
|
+
|
|
|
+ if (row['url'] === null || row['url'] === '') {
|
|
|
+ // 转换Base64数据为Blob对象
|
|
|
+ const blob = dataURLtoBlob(row.附件内容);
|
|
|
+ luckyexcelVisible.value = true; // 控制页面展示
|
|
|
+ LuckyExcel.transformExcelToLucky(blob, callback);
|
|
|
+ } else {
|
|
|
+ // 文件路径处理
|
|
|
+ const excelPath = `/${row.url.replace(/\\/g, "/")}`;
|
|
|
+ const excelName = excelPath.split('/').pop();
|
|
|
+ luckyexcelVisible.value = true;
|
|
|
+ LuckyExcel.transformExcelToLuckyByUrl(excelPath, excelName, callback);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 将Data URL转换为Blob对象
|
|
|
+ const dataURLtoBlob = (dataUrl) => {
|
|
|
+ const byteString = atob(dataUrl.split(',')[1]);
|
|
|
+ const ab = new ArrayBuffer(byteString.length);
|
|
|
+ const ia = new Uint8Array(ab);
|
|
|
+
|
|
|
+ for (let i = 0; i < byteString.length; i++) {
|
|
|
+ ia[i] = byteString.charCodeAt(i);
|
|
|
+ }
|
|
|
+
|
|
|
+ return new Blob([ab], { type: 'application/octet-stream' });
|
|
|
+ };
|
|
|
+
|
|
|
+ loadScriptsAndStyles(); // 开始加载插件和样式
|
|
|
+};
|
|
|
+// const gdbomupdateCompanyFunc = (row) => {
|
|
|
+// // 加载插件和样式
|
|
|
+// const loadScriptsAndStyles = () => {
|
|
|
+// $.getScript('/luckysheet/plugins/js/plugin.js', () => {
|
|
|
+// $script('/luckysheet/luckysheet.umd.js', () => {
|
|
|
+// initializeLuckysheet();
|
|
|
+// });
|
|
|
+// });
|
|
|
+
|
|
|
+// const styles = [
|
|
|
+// '/luckysheet/plugins/css/pluginsCss.css',
|
|
|
+// '/luckysheet/plugins/plugins.css',
|
|
|
+// '/luckysheet/css/luckysheet.css',
|
|
|
+// '/luckysheet/assets/iconfont/iconfont.css'
|
|
|
+// ];
|
|
|
+
|
|
|
+// styles.forEach(style => {
|
|
|
+// $('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', style));
|
|
|
+// });
|
|
|
+// };
|
|
|
+
|
|
|
+// // 初始化 Luckysheet
|
|
|
+// const initializeLuckysheet = () => {
|
|
|
+// const callback = (exportJson, luckysheetfile) => {
|
|
|
+// if (!exportJson.sheets || exportJson.sheets.length === 0) {
|
|
|
+// alert("Failed to read the content of the excel file, currently does not support xls files!");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// if (luckyExcel) luckyExcel.destroy();
|
|
|
+// luckysheet.create({
|
|
|
+// container: 'luckyexcel',
|
|
|
+// data: exportJson.sheets,
|
|
|
+// title: exportJson.info.name,
|
|
|
+// lang: "zh",
|
|
|
+// showtoolbar: false,
|
|
|
+// showinfobar: false,
|
|
|
+// allowEdit: false,
|
|
|
+// enableAddRow: false,
|
|
|
+// enableAddCol: false,
|
|
|
+// userInfo: false,
|
|
|
+// showRowBar: false,
|
|
|
+// showColumnBar: false,
|
|
|
+// sheetFormulaBar: false,
|
|
|
+// enableAddBackTop: false,
|
|
|
+// });
|
|
|
+// luckyExcel = luckysheet;
|
|
|
+// };
|
|
|
+
|
|
|
+// if (row['url'] === null || row['url'] === '') {
|
|
|
+// const blob = dataURLtoBlob(row.附件内容);
|
|
|
+// luckyexcelVisible.value = true;
|
|
|
+// LuckyExcel.transformExcelToLucky(blob, callback);
|
|
|
+// } else {
|
|
|
+// const excelPath = `/${row.url.replace(/\\/g, "/")}`;
|
|
|
+// const excelName = excelPath.split('/').pop();
|
|
|
+// luckyexcelVisible.value = true;
|
|
|
+// LuckyExcel.transformExcelToLuckyByUrl(excelPath, excelName, callback);
|
|
|
+// }
|
|
|
+// };
|
|
|
+
|
|
|
+// // Data URL 转 Blob
|
|
|
+// const dataURLtoBlob = (dataUrl) => {
|
|
|
+// const byteString = atob(dataUrl.split(',')[1]);
|
|
|
+// const ab = new ArrayBuffer(byteString.length);
|
|
|
+// const ia = new Uint8Array(ab);
|
|
|
+
|
|
|
+// for (let i = 0; i < byteString.length; i++) {
|
|
|
+// ia[i] = byteString.charCodeAt(i);
|
|
|
+// }
|
|
|
+
|
|
|
+// return new Blob([ab], { type: 'application/octet-stream' });
|
|
|
+// };
|
|
|
+
|
|
|
+// loadScriptsAndStyles();
|
|
|
+// };
|
|
|
|
|
|
//技术资料excel展示
|
|
|
const ExcelShow = (row) =>{
|
|
|
- console.log("技术资料excel展示")
|
|
|
- console.log(row)
|
|
|
- if(!row.附件内容) return
|
|
|
- $.getScript('/luckysheet/plugins/js/plugin.js', () => {
|
|
|
- $script('/luckysheet/luckysheet.umd.js', () => {
|
|
|
- function dataURLtoBlob(dataUrl) {
|
|
|
- const byteString = atob(dataUrl.split(',')[1]);
|
|
|
- const ab = new ArrayBuffer(byteString.length);
|
|
|
- const ia = new Uint8Array(ab);
|
|
|
-
|
|
|
- for (let i = 0; i < byteString.length; i++) {
|
|
|
- ia[i] = byteString.charCodeAt(i);
|
|
|
- }
|
|
|
-
|
|
|
- return new Blob([ab], { type: 'application/octet-stream' });
|
|
|
- }
|
|
|
-
|
|
|
- const blob = dataURLtoBlob(row.附件内容);
|
|
|
- luckyexcelVisible.value = true
|
|
|
- LuckyExcel.transformExcelToLucky(blob, function(exportJson, luckysheetfile){
|
|
|
- if(exportJson.sheets==null || exportJson.sheets.length==0){
|
|
|
- alert("Failed to read the content of the excel file, currently does not support xls files!");
|
|
|
- return;
|
|
|
- }
|
|
|
- if(luckyExcel) luckyExcel.destroy();
|
|
|
- luckysheet.create({
|
|
|
- container: 'luckyexcel', //容器的ID
|
|
|
- data: exportJson.sheets,
|
|
|
- title: exportJson.info.name, // 工作簿名称
|
|
|
- lang: "zh", // 设定表格语言 国际化设置,允许设置表格的语言,支持中文("zh")和英文("en")
|
|
|
- showtoolbar: false, // 是否显示工具栏
|
|
|
- showinfobar: false, // 是否显示顶部信息栏
|
|
|
- allowEdit: false, // 是否允许前台编辑
|
|
|
- enableAddRow: false, // 允许增加行
|
|
|
- enableAddCol: false, // 允许增加列
|
|
|
- userInfo: false, // 右上角的用户信息展示样式
|
|
|
- showRowBar: false, // 是否显示行号区域
|
|
|
- showColumnBar: false, // 是否显示列号区域
|
|
|
- sheetFormulaBar: false, // 是否显示公式栏
|
|
|
- enableAddBackTop: false,//返回头部按钮
|
|
|
- });
|
|
|
- luckyExcel = luckysheet;
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
- $('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', '/luckysheet/plugins/css/pluginsCss.css'));
|
|
|
- $('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', '/luckysheet/plugins/plugins.css'));
|
|
|
- $('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', '/luckysheet/css/luckysheet.css'));
|
|
|
- $('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', '/luckysheet/assets/iconfont/iconfont.css'));
|
|
|
-
|
|
|
+ // 加载插件和样式
|
|
|
+ const loadScriptsAndStyles = () => {
|
|
|
+ $.getScript('/luckysheet/plugins/js/plugin.js', () => {
|
|
|
+ $script('/luckysheet/luckysheet.umd.js', () => {
|
|
|
+ initializeLuckysheet();
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ const styles = [
|
|
|
+ '/luckysheet/plugins/css/pluginsCss.css',
|
|
|
+ '/luckysheet/plugins/plugins.css',
|
|
|
+ '/luckysheet/css/luckysheet.css',
|
|
|
+ '/luckysheet/assets/iconfont/iconfont.css'
|
|
|
+ ];
|
|
|
+
|
|
|
+ styles.forEach(style => {
|
|
|
+ $('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', style));
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ // 初始化 Luckysheet
|
|
|
+ const initializeLuckysheet = () => {
|
|
|
+ const callback = (exportJson, luckysheetfile) => {
|
|
|
+ if (!exportJson.sheets || exportJson.sheets.length === 0) {
|
|
|
+ alert("Failed to read the content of the excel file, currently does not support xls files!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (luckyExcel) luckyExcel.destroy();
|
|
|
+ luckysheet.create({
|
|
|
+ container: 'luckyexcel',
|
|
|
+ data: exportJson.sheets,
|
|
|
+ title: exportJson.info.name,
|
|
|
+ lang: "zh",
|
|
|
+ showtoolbar: false,
|
|
|
+ showinfobar: false,
|
|
|
+ allowEdit: false,
|
|
|
+ enableAddRow: false,
|
|
|
+ enableAddCol: false,
|
|
|
+ userInfo: false,
|
|
|
+ showRowBar: false,
|
|
|
+ showColumnBar: false,
|
|
|
+ sheetFormulaBar: false,
|
|
|
+ enableAddBackTop: false,
|
|
|
+ });
|
|
|
+ luckyExcel = luckysheet;
|
|
|
+ };
|
|
|
+
|
|
|
+ if (row['url'] === null || row['url'] === '') {
|
|
|
+ const blob = dataURLtoBlob(row.附件内容);
|
|
|
+ luckyexcelVisible.value = true;
|
|
|
+ LuckyExcel.transformExcelToLucky(blob, callback);
|
|
|
+ } else {
|
|
|
+ const excelPath = `/${row.url.replace(/\\/g, "/")}`;
|
|
|
+ const excelName = excelPath.split('/').pop();
|
|
|
+ luckyexcelVisible.value = true;
|
|
|
+ LuckyExcel.transformExcelToLuckyByUrl(excelPath, excelName, callback);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // Data URL 转 Blob
|
|
|
+ const dataURLtoBlob = (dataUrl) => {
|
|
|
+ const byteString = atob(dataUrl.split(',')[1]);
|
|
|
+ const ab = new ArrayBuffer(byteString.length);
|
|
|
+ const ia = new Uint8Array(ab);
|
|
|
+
|
|
|
+ for (let i = 0; i < byteString.length; i++) {
|
|
|
+ ia[i] = byteString.charCodeAt(i);
|
|
|
+ }
|
|
|
+
|
|
|
+ return new Blob([ab], { type: 'application/octet-stream' });
|
|
|
+ };
|
|
|
+
|
|
|
+ loadScriptsAndStyles();
|
|
|
}
|
|
|
|
|
|
-let luckyExcel = null
|
|
|
|
|
|
+let luckyExcel = null
|
|
|
const luckyexcelVisible = ref(false)
|
|
|
const luckyexcelCloseDialog = () => {
|
|
|
luckyexcelVisible.value = false
|
|
|
@@ -2478,8 +2612,6 @@ const luckyexcelCloseDialog = () => {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
</script>
|
|
|
<style scoped>
|
|
|
/* 在样式表中使用媒体查询 */
|