Commit ac230c33 authored by xiangjiaojunxp's avatar xiangjiaojunxp

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

parent c17d93aa
......@@ -125,7 +125,9 @@ var setStyleAndValue = function(cellArr, worksheet,contrast) {
if(contrast){
const column =worksheet.getColumn(1);
const column2 =worksheet.getColumn(2);
column.hidden=true;
column2.hidden=true;
}
// console.log('1233', letter + (rowid + 1))
for (const key in fill) {
......
......@@ -78,6 +78,7 @@ var tempId;
var roleId;
var uuid1;
var trueORfalse=false;
var modify=false;
export default {
name: "Mymodule",
data() {
......@@ -132,6 +133,7 @@ export default {
}else{
trueORfalse=false;
}
modify=false;
tempId= this.selectedOption;
uuid1=this.uuid=uuidv4().substring(0,8);
console.log(this.uuid);
......@@ -182,10 +184,9 @@ export default {
break;
}
}
modify=false;
const sysSupplies = response.rows;
this.luckysheetData = sysSupplies[0].templateContent;
//将接收到的json存到json_data中
//const json_data = response.data;
let json_data = JSON.parse(sysSupplies[0].templateContent);
//luckysheet.destroy()
luckysheet.create({
......@@ -220,6 +221,7 @@ export default {
this.selectedRule='';
this.luckyrule=[];
trueORfalse=false;
modify=false;
uuid1='';
//刷新luckysheet表格
this.init();
......@@ -286,6 +288,28 @@ export default {
},
/** 导入事件*/
async handleFileChange(evt) {
if(modify){
this.$confirm('再次导入将会清空表内数据,是否继续操作?', '注意!!!', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).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) => {
......@@ -294,12 +318,45 @@ export default {
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;
}
}).catch(() => {
// 处理错误逻辑,这里是一个空的错误处理函数
this.$message.error('查询失败,模板未找到,请联系管理员进行处理!');
});
}).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);
//this.submit(exportJson);
} catch (Error) {
this.$message({
......@@ -309,8 +366,9 @@ export default {
console.log("这里是最外面的地方");
}finally {
// 导入完成后关闭遮罩层
this.showMask = false;
this.showMask = false;}
}
},
/** 物料转换汇总到页面*/
summary(exportJson){
......@@ -900,6 +958,16 @@ export default {
if (searchResult.length != 0 && key != null) {
rowws = searchResult[0].row;
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);
for (let i = 0; i < sysRules.length; i++) {
......@@ -926,6 +994,7 @@ export default {
bord.range[0].column = [0, parseInt(sysRules[sysRules.length - 1].ct)];
config.borderInfo.push(bord);
luckysheet.setConfig(config);
modify=true;
} else{
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