Commit ac230c33 authored by xiangjiaojunxp's avatar xiangjiaojunxp

物料转换数据添加和导出修改

parent c17d93aa
...@@ -125,7 +125,9 @@ var setStyleAndValue = function(cellArr, worksheet,contrast) { ...@@ -125,7 +125,9 @@ var setStyleAndValue = function(cellArr, worksheet,contrast) {
if(contrast){ if(contrast){
const column =worksheet.getColumn(1); const column =worksheet.getColumn(1);
const column2 =worksheet.getColumn(2);
column.hidden=true; column.hidden=true;
column2.hidden=true;
} }
// console.log('1233', letter + (rowid + 1)) // console.log('1233', letter + (rowid + 1))
for (const key in fill) { for (const key in fill) {
......
...@@ -78,6 +78,7 @@ var tempId; ...@@ -78,6 +78,7 @@ var tempId;
var roleId; var roleId;
var uuid1; var uuid1;
var trueORfalse=false; var trueORfalse=false;
var modify=false;
export default { export default {
name: "Mymodule", name: "Mymodule",
data() { data() {
...@@ -132,6 +133,7 @@ export default { ...@@ -132,6 +133,7 @@ export default {
}else{ }else{
trueORfalse=false; trueORfalse=false;
} }
modify=false;
tempId= this.selectedOption; tempId= this.selectedOption;
uuid1=this.uuid=uuidv4().substring(0,8); uuid1=this.uuid=uuidv4().substring(0,8);
console.log(this.uuid); console.log(this.uuid);
...@@ -182,10 +184,9 @@ export default { ...@@ -182,10 +184,9 @@ export default {
break; break;
} }
} }
modify=false;
const sysSupplies = response.rows; const sysSupplies = response.rows;
this.luckysheetData = sysSupplies[0].templateContent; this.luckysheetData = sysSupplies[0].templateContent;
//将接收到的json存到json_data中
//const json_data = response.data;
let json_data = JSON.parse(sysSupplies[0].templateContent); let json_data = JSON.parse(sysSupplies[0].templateContent);
//luckysheet.destroy() //luckysheet.destroy()
luckysheet.create({ luckysheet.create({
...@@ -220,6 +221,7 @@ export default { ...@@ -220,6 +221,7 @@ export default {
this.selectedRule=''; this.selectedRule='';
this.luckyrule=[]; this.luckyrule=[];
trueORfalse=false; trueORfalse=false;
modify=false;
uuid1=''; uuid1='';
//刷新luckysheet表格 //刷新luckysheet表格
this.init(); this.init();
...@@ -286,31 +288,87 @@ export default { ...@@ -286,31 +288,87 @@ export default {
}, },
/** 导入事件*/ /** 导入事件*/
async handleFileChange(evt) { async handleFileChange(evt) {
let exx; if(modify){
this.showMask = true; this.$confirm('再次导入将会清空表内数据,是否继续操作?', '注意!!!', {
const cons = new Promise((resolve, reject) => { confirmButtonText: '确定',
LuckyExcel.transformExcelToLucky(evt, exportJson => { cancelButtonText: '取消',
exx = exportJson; type: 'warning'
resolve(exx); }).then(async () => {
}); // 确认继续后刷新页面返回模板
}); getSuppliesTemplate(7).then(response => {
const sysSupplies = response.rows;
this.luckysheetData = sysSupplies[0].templateContent;
let json_data = JSON.parse(sysSupplies[0].templateContent);
//luckysheet.destroy()
luckysheet.create({
container: "luckysheet", // Luckysheet 的容器元素 ID
title: fileName, // Excel 文件名
data: json_data, // Excel 数据
showinfobar: false, //是否显示顶部名称栏
lang:'zh',
});
modify=false;
}).then(async ()=>{
//将导入数据替换保存
let exx;
this.showMask = true;
const cons = new Promise((resolve, reject) => {
LuckyExcel.transformExcelToLucky(evt, exportJson => {
exx = exportJson;
resolve(exx);
});
});
try {
const exportJson = await cons;
await this.summary(exportJson);
//console.log('summary 执行完毕');
//this.submit(exportJson);
} catch (Error) {
this.$message({
message: Error.message,
type: "error"
});
console.log(Error.message);
console.log("这里是最外面的地方");
} finally {
// 导入完成后关闭遮罩层
this.showMask = false;
}
try { }).catch(() => {
const exportJson = await cons; // 处理错误逻辑,这里是一个空的错误处理函数
await this.summary(exportJson); this.$message.error('查询失败,模板未找到,请联系管理员进行处理!');
//console.log('summary 执行完毕'); });
this.submit(exportJson); }).catch(() => {
// 用户点击了取消按钮
//this.$message({type: 'info', message: '操作已取消'});
});
}else{
let exx;
this.showMask = true;
const cons = new Promise((resolve, reject) => {
LuckyExcel.transformExcelToLucky(evt, exportJson => {
exx = exportJson;
resolve(exx);
});
});
try {
const exportJson = await cons;
await this.summary(exportJson);
//console.log('summary 执行完毕');
//this.submit(exportJson);
} catch (Error) { } catch (Error) {
this.$message({ this.$message({
message: Error.message, message: Error.message,
type: "error"}); type: "error"});
console.log(Error.message); console.log(Error.message);
console.log("这里是最外面的地方"); console.log("这里是最外面的地方");
}finally { }finally {
// 导入完成后关闭遮罩层 // 导入完成后关闭遮罩层
this.showMask = false; this.showMask = false;}
} }
}, },
/** 物料转换汇总到页面*/ /** 物料转换汇总到页面*/
summary(exportJson){ summary(exportJson){
...@@ -900,6 +958,16 @@ export default { ...@@ -900,6 +958,16 @@ export default {
if (searchResult.length != 0 && key != null) { if (searchResult.length != 0 && key != null) {
rowws = searchResult[0].row; rowws = searchResult[0].row;
luckysheet.insertRow(rowws + 1); luckysheet.insertRow(rowws + 1);
let vll1=luckysheet.getCellValue(rowws,sysRulez[0].ct);
luckysheet.setCellValue(rowws+1, sysRulez[0].ct, {
"ct": {
"fa": "@",
"t": "n"
}
});
luckysheet.setCellValue(rowws + 1, sysRulez[0].ct, vll1);
let vll2=luckysheet.getCellValue(rowws,parseInt(sysRulez[0].ct)+1);
luckysheet.setCellValue(rowws + 1, parseInt(sysRulez[0].ct)+1, vll2);
//输出部门数量金额 //输出部门数量金额
luckysheet.setCellValue(rowws + 1, sysRulez[1].ct, depp); luckysheet.setCellValue(rowws + 1, sysRulez[1].ct, depp);
for (let i = 0; i < sysRules.length; i++) { for (let i = 0; i < sysRules.length; i++) {
...@@ -926,6 +994,7 @@ export default { ...@@ -926,6 +994,7 @@ export default {
bord.range[0].column = [0, parseInt(sysRules[sysRules.length - 1].ct)]; bord.range[0].column = [0, parseInt(sysRules[sysRules.length - 1].ct)];
config.borderInfo.push(bord); config.borderInfo.push(bord);
luckysheet.setConfig(config); luckysheet.setConfig(config);
modify=true;
} else{ } else{
warn++; warn++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment