|
@@ -72,6 +72,8 @@ projectGljObject = {
|
|
|
/*{ID:'MAIN_MATERIAL',text:'主材'},
|
|
/*{ID:'MAIN_MATERIAL',text:'主材'},
|
|
|
{ID:'EQUIPMENT',text:'设备'}*/
|
|
{ID:'EQUIPMENT',text:'设备'}*/
|
|
|
],
|
|
],
|
|
|
|
|
+ importJson: null,
|
|
|
|
|
+
|
|
|
initSpreads: function () {
|
|
initSpreads: function () {
|
|
|
if (this.projectGljSpread == null) this.initProjectGljSpread();
|
|
if (this.projectGljSpread == null) this.initProjectGljSpread();
|
|
|
//if(materialAdjustObj.spread == null) materialAdjustObj.initSpread();
|
|
//if(materialAdjustObj.spread == null) materialAdjustObj.initSpread();
|
|
@@ -1281,7 +1283,7 @@ projectGljObject = {
|
|
|
return compilationName === "四川养护(2013)" || compilationName === "部颁2018计价标准";
|
|
return compilationName === "四川养护(2013)" || compilationName === "部颁2018计价标准";
|
|
|
},
|
|
},
|
|
|
callback: function (key, opt) {
|
|
callback: function (key, opt) {
|
|
|
- me.ExportExcelFile();
|
|
|
|
|
|
|
+ me.exportToExcelFile();
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
importPriceFromExcel: {
|
|
importPriceFromExcel: {
|
|
@@ -1438,9 +1440,10 @@ projectGljObject = {
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
|
},
|
|
},
|
|
|
- ExportExcelFile: function () {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ exportToExcelFile: function () {
|
|
|
const excelIO = new GC.Spread.Excel.IO();
|
|
const excelIO = new GC.Spread.Excel.IO();
|
|
|
- console.log(projectGljObject.projectGljSheetData);
|
|
|
|
|
|
|
+ console.log(this.projectGljSheetData);
|
|
|
let workbook = new GC.Spread.Sheets.Workbook(document.getElementById("#project_glj_sheet_Temp"));
|
|
let workbook = new GC.Spread.Sheets.Workbook(document.getElementById("#project_glj_sheet_Temp"));
|
|
|
let sheet = workbook.sheets[0];
|
|
let sheet = workbook.sheets[0];
|
|
|
workbook.commandManager().execute({ cmd: "renameSheet", sheetName: "Sheet1", name: "材料预算价" });
|
|
workbook.commandManager().execute({ cmd: "renameSheet", sheetName: "Sheet1", name: "材料预算价" });
|
|
@@ -1467,14 +1470,17 @@ projectGljObject = {
|
|
|
sheet.getRange(-1, 5, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign.right);
|
|
sheet.getRange(-1, 5, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign.right);
|
|
|
sheet.getRange(0, -1, 1, -1).hAlign(GC.Spread.Sheets.HorizontalAlign.center); // 标题行居中对齐
|
|
sheet.getRange(0, -1, 1, -1).hAlign(GC.Spread.Sheets.HorizontalAlign.center); // 标题行居中对齐
|
|
|
|
|
|
|
|
- for (let i = 0; i < projectGljObject.projectGljSheetData.length; i++) {
|
|
|
|
|
- const e = projectGljObject.projectGljSheetData[i];
|
|
|
|
|
- sheet.getCell(i + 1, 0).value(e.code);
|
|
|
|
|
- sheet.getCell(i + 1, 1).value(e.name);
|
|
|
|
|
- sheet.getCell(i + 1, 2).value(e.specs);
|
|
|
|
|
- sheet.getCell(i + 1, 3).value(e.unit);
|
|
|
|
|
- sheet.getCell(i + 1, 4).value(e.type);
|
|
|
|
|
- sheet.getCell(i + 1, 5).value(e.unit_price.market_price);
|
|
|
|
|
|
|
+ let j = 0;
|
|
|
|
|
+ for (let i = 0; i < this.projectGljSheetData.length; i++) {
|
|
|
|
|
+ const e = this.projectGljSheetData[i];
|
|
|
|
|
+ if (!e.code || e.type !== 201) continue; // 过滤非材料、无编号。
|
|
|
|
|
+ j += 1;
|
|
|
|
|
+ sheet.getCell(j, 0).value(e.code);
|
|
|
|
|
+ sheet.getCell(j, 1).value(e.name);
|
|
|
|
|
+ sheet.getCell(j, 2).value(e.specs);
|
|
|
|
|
+ sheet.getCell(j, 3).value(e.unit);
|
|
|
|
|
+ sheet.getCell(j, 4).value(e.type);
|
|
|
|
|
+ sheet.getCell(j, 5).value(e.unit_price.market_price);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
let json = JSON.stringify(workbook.toJSON());
|
|
let json = JSON.stringify(workbook.toJSON());
|
|
@@ -1491,6 +1497,69 @@ projectGljObject = {
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
},
|
|
},
|
|
|
|
|
+ readExcelFileToJson: function (excelFile) {
|
|
|
|
|
+ projectGljObject.importJson = null;
|
|
|
|
|
+ let excelIo = new GC.Spread.Excel.IO();
|
|
|
|
|
+ let sDate = +new Date();
|
|
|
|
|
+ excelIo.open(
|
|
|
|
|
+ excelFile,
|
|
|
|
|
+ function (json) {
|
|
|
|
|
+ projectGljObject.importJson = json;
|
|
|
|
|
+ console.log(`解析Excel文件时间:${+new Date() - sDate}`);
|
|
|
|
|
+ $.bootstrapLoading.end();
|
|
|
|
|
+ },
|
|
|
|
|
+ function (e) {
|
|
|
|
|
+ $.bootstrapLoading.end();
|
|
|
|
|
+ alert(e.errorMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+ );
|
|
|
|
|
+ },
|
|
|
|
|
+ readJsonSheets: function () {
|
|
|
|
|
+ const err = "当前Excel文件格式不正确,请参考导出Excel材料预算价文件!";
|
|
|
|
|
+ const sheet = projectGljObject.importJson.sheets["材料预算价"];
|
|
|
|
|
+ if (!sheet) throw err;
|
|
|
|
|
+ const sheetData = sheet.data.dataTable;
|
|
|
|
|
+ if (!sheetData) throw err;
|
|
|
|
|
+ const isRightHead =
|
|
|
|
|
+ sheetData[0][0].value === "编号" &&
|
|
|
|
|
+ sheetData[0][1].value === "名称" &&
|
|
|
|
|
+ sheetData[0][2].value === "规格" &&
|
|
|
|
|
+ sheetData[0][3].value === "单位" &&
|
|
|
|
|
+ sheetData[0][4].value === "类型" &&
|
|
|
|
|
+ sheetData[0][5].value === "预算价";
|
|
|
|
|
+ if (!isRightHead) throw err;
|
|
|
|
|
+
|
|
|
|
|
+ let rst = [];
|
|
|
|
|
+ for (let row = 1; row < sheet.rows.length - 1; row++) {
|
|
|
|
|
+ const rowData = {
|
|
|
|
|
+ code: sheetData[row][0] ? sheetData[row][0].value : undefined,
|
|
|
|
|
+ name: sheetData[row][1] ? sheetData[row][1].value : undefined,
|
|
|
|
|
+ specs: sheetData[row][2] ? sheetData[row][2].value : undefined,
|
|
|
|
|
+ unit: sheetData[row][3] ? sheetData[row][3].value : undefined,
|
|
|
|
|
+ type: sheetData[row][4] ? sheetData[row][4].value : undefined,
|
|
|
|
|
+ unitPrice: sheetData[row][5] ? sheetData[row][5].value : undefined,
|
|
|
|
|
+ };
|
|
|
|
|
+ rst.push(rowData);
|
|
|
|
|
+ }
|
|
|
|
|
+ return rst;
|
|
|
|
|
+ },
|
|
|
|
|
+ importExcelPrice: function () {
|
|
|
|
|
+ const priceData = this.readJsonSheets();
|
|
|
|
|
+ if (priceData.length === 0) {
|
|
|
|
|
+ throw "当前Excel文件没有材料预算价!";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const priceCol = this.getColIndex("预算价");
|
|
|
|
|
+ const changeInfo = [];
|
|
|
|
|
+ for (const pd of priceData) {
|
|
|
|
|
+ const idx = gljUtil.getIndex(pd, gljKeyArray);
|
|
|
|
|
+ const pGlj = this.getSheetDataRowAndPrice(idx);
|
|
|
|
|
+ if (pGlj && pGlj.price !== pd.unitPrice) {
|
|
|
|
|
+ changeInfo.push({ row: pGlj.row, col: priceCol, value: pd.unitPrice });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (changeInfo.length > 0) this.batchUpdateProjectGLJ(changeInfo, "projectGljSheet");
|
|
|
|
|
+ },
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
function getProjectResizeEles() {
|
|
function getProjectResizeEles() {
|
|
@@ -1834,8 +1903,6 @@ $(function () {
|
|
|
projectGljObject.showRelatedRationDatas();
|
|
projectGljObject.showRelatedRationDatas();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- let importJson = null;
|
|
|
|
|
-
|
|
|
|
|
function showAlert(msg, isHint) {
|
|
function showAlert(msg, isHint) {
|
|
|
$("#showAlert").removeClass("alert-success");
|
|
$("#showAlert").removeClass("alert-success");
|
|
|
if (isHint) $("#showAlert").addClass("alert-info");
|
|
if (isHint) $("#showAlert").addClass("alert-info");
|
|
@@ -1844,37 +1911,6 @@ $(function () {
|
|
|
$("#showAlert").show();
|
|
$("#showAlert").show();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function getExcelData(sheets) {
|
|
|
|
|
- debugger;
|
|
|
|
|
- const err = "当前Excel文件格式不正确,请参考导出Excel材料预算价文件!";
|
|
|
|
|
- const sheet = sheets["材料预算价"];
|
|
|
|
|
- if (!sheet) throw err;
|
|
|
|
|
- const sheetData = sheet.data.dataTable;
|
|
|
|
|
- if (!sheetData) throw err;
|
|
|
|
|
- const isRightHead =
|
|
|
|
|
- sheetData[0][0].value === "编号" &&
|
|
|
|
|
- sheetData[0][1].value === "名称" &&
|
|
|
|
|
- sheetData[0][2].value === "规格" &&
|
|
|
|
|
- sheetData[0][3].value === "单位" &&
|
|
|
|
|
- sheetData[0][4].value === "类型" &&
|
|
|
|
|
- sheetData[0][5].value === "预算价";
|
|
|
|
|
- if (!isRightHead) throw err;
|
|
|
|
|
-
|
|
|
|
|
- let rst = [];
|
|
|
|
|
- for (let row = 1; row < sheet.rows.length; row++) {
|
|
|
|
|
- const rowData = {
|
|
|
|
|
- code: sheetData[row][0] ? sheetData[row][0].value : undefined,
|
|
|
|
|
- name: sheetData[row][1] ? sheetData[row][1].value : undefined,
|
|
|
|
|
- specs: sheetData[row][2] ? sheetData[row][2].value : undefined,
|
|
|
|
|
- unit: sheetData[row][3] ? sheetData[row][3].value : undefined,
|
|
|
|
|
- type: sheetData[row][4] ? sheetData[row][4].value : undefined,
|
|
|
|
|
- unitPrice: sheetData[row][5] ? sheetData[row][5].value : undefined,
|
|
|
|
|
- };
|
|
|
|
|
- rst.push(rowData);
|
|
|
|
|
- }
|
|
|
|
|
- return rst;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
//选择导入的excel文件
|
|
//选择导入的excel文件
|
|
|
$("#customPriceFile").change(function () {
|
|
$("#customPriceFile").change(function () {
|
|
|
let file = $(this)[0];
|
|
let file = $(this)[0];
|
|
@@ -1891,25 +1927,7 @@ $(function () {
|
|
|
$("#showAlert").hide();
|
|
$("#showAlert").hide();
|
|
|
$.bootstrapLoading.start();
|
|
$.bootstrapLoading.start();
|
|
|
$("#loadingPage").css("z-index", "2000");
|
|
$("#loadingPage").css("z-index", "2000");
|
|
|
- //前端解析excel数据
|
|
|
|
|
- if (importJson) {
|
|
|
|
|
- importJson = null;
|
|
|
|
|
- }
|
|
|
|
|
- let excelIo = new GC.Spread.Excel.IO();
|
|
|
|
|
- let sDate = +new Date();
|
|
|
|
|
- excelIo.open(
|
|
|
|
|
- excelFile,
|
|
|
|
|
- function (json) {
|
|
|
|
|
- importJson = json;
|
|
|
|
|
- console.log(json);
|
|
|
|
|
- console.log(`解析Excel文件时间:${+new Date() - sDate}`);
|
|
|
|
|
- $.bootstrapLoading.end();
|
|
|
|
|
- },
|
|
|
|
|
- function (e) {
|
|
|
|
|
- $.bootstrapLoading.end();
|
|
|
|
|
- alert(e.errorMessage);
|
|
|
|
|
- }
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ projectGljObject.readExcelFileToJson(excelFile);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -1927,23 +1945,8 @@ $(function () {
|
|
|
throw "项目数据出错";
|
|
throw "项目数据出错";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const priceData = getExcelData(importJson.sheets);
|
|
|
|
|
- if (priceData.length === 0) {
|
|
|
|
|
- throw "当前Excel文件没有材料预算价!";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
showAlert("正在导入预算价...", true);
|
|
showAlert("正在导入预算价...", true);
|
|
|
- const priceCol = projectGljObject.getColIndex("预算价");
|
|
|
|
|
- console.log(projectGljObject.projectGljSheetData);
|
|
|
|
|
- const changeInfo = [];
|
|
|
|
|
- for (const pd of priceData) {
|
|
|
|
|
- const idx = gljUtil.getIndex(pd, gljKeyArray);
|
|
|
|
|
- const pGlj = projectGljObject.getSheetDataRowAndPrice(idx);
|
|
|
|
|
- if (pGlj && pGlj.price !== pd.unitPrice) {
|
|
|
|
|
- changeInfo.push({ row: pGlj.row, col: priceCol, value: pd.unitPrice });
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (changeInfo.length > 0) projectGljObject.batchUpdateProjectGLJ(changeInfo, "projectGljSheet");
|
|
|
|
|
|
|
+ projectGljObject.importExcelPrice();
|
|
|
$("#showAlert").hide();
|
|
$("#showAlert").hide();
|
|
|
$(me).removeClass("disabled");
|
|
$(me).removeClass("disabled");
|
|
|
$("#importPriceForm").modal("hide");
|
|
$("#importPriceForm").modal("hide");
|