|
@@ -2,28 +2,261 @@
|
|
|
* Created by zhang on 2018/3/13.
|
|
|
*/
|
|
|
projectGljObject={
|
|
|
- projectGljSetting:{},
|
|
|
- projectGljSpread:{},
|
|
|
- projectGljSheet:{},
|
|
|
- projectGljSheetData:{}
|
|
|
+ projectGljSetting:{
|
|
|
+ header: [
|
|
|
+ {headerName: "编码", headerWidth: 80, dataCode: "code", dataType: "String"},
|
|
|
+ {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String"},
|
|
|
+ {headerName: "规格型号", headerWidth: 120, dataCode: "specs", hAlign: "left", dataType: "String"},
|
|
|
+ {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
|
|
|
+ {headerName: "类型", headerWidth: 45, dataCode: "short_name", hAlign: "center", dataType: "String"},
|
|
|
+ {headerName: "总消耗量", headerWidth: 100, dataCode: "quantity", hAlign: "right", dataType: "Number",decimalField:'glj.quantity'},
|
|
|
+ {headerName: "定额价", headerWidth: 70, dataCode: "basePrice", hAlign: "right", dataType: "Number",decimalField:'glj.quantity',validator:"number"},
|
|
|
+ {headerName: "调整价", headerWidth: 70, dataCode: "adjustPrice", hAlign: "right", dataType: "Number",decimalField:"glj.unitPrice"},
|
|
|
+ {headerName: "市场价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",decimalField:"glj.unitPrice",validator:"number"},
|
|
|
+ {headerName: "是否暂估", headerWidth: 60, dataCode: "is_evaluate", hAlign: "center", dataType: "String",cellType:'checkBox'},
|
|
|
+ {headerName: "供货方式", headerWidth: 80, dataCode: "supply", hAlign: "center", dataType: "String",cellType:'comboBox',editorValueType:true,options:supplyComboMap},
|
|
|
+ {headerName: "甲供数量", headerWidth: 100, dataCode: "supply_quantity", hAlign: "right", dataType: "String",validator:"number"},
|
|
|
+ {headerName: "交货方式", headerWidth: 90, dataCode: "delivery", hAlign: "left", dataType: "String"},
|
|
|
+ {headerName: "送达地点", headerWidth: 100, dataCode: "delivery_address", hAlign: "left", dataType: "String"},
|
|
|
+ {headerName: "不调价", headerWidth: 55, dataCode: "is_adjust_price", dataType: "String",cellType: "checkBox"}
|
|
|
+ ],
|
|
|
+ view: {
|
|
|
+ lockColumns: [0,1,2,3,4,5,7,12,13]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ projectGljSpread:null,
|
|
|
+ projectGljSheet:null,
|
|
|
+ projectGljSheetData:[],
|
|
|
+ mixRatioSetting:{
|
|
|
+ header:[
|
|
|
+ {headerName: "编码", headerWidth: 80, dataCode: "code", dataType: "String"},
|
|
|
+ {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String"},
|
|
|
+ {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
|
|
|
+ {headerName: "类型", headerWidth: 45, dataCode: "short_name", hAlign: "center", dataType: "String"},
|
|
|
+ {headerName: "定额价", headerWidth: 70, dataCode: "basePrice", hAlign: "right", dataType: "Number",decimalField:'glj.quantity',validator:"number"},
|
|
|
+ {headerName: "调整价", headerWidth: 70, dataCode: "adjustPrice", hAlign: "right", dataType: "Number",decimalField:"glj.unitPrice"},
|
|
|
+ {headerName: "市场价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",decimalField:"glj.unitPrice",validator:"number"}
|
|
|
+ ],
|
|
|
+ view: {
|
|
|
+ lockColumns: [0,1]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mixRatioSpread:null,
|
|
|
+ mixRatioSheet:null,
|
|
|
+ mixRatioData:[],
|
|
|
+ initProjectGljSpread:function () {
|
|
|
+ this.projectGljSpread = SheetDataHelper.createNewSpread($("#project_glj_sheet")[0]);
|
|
|
+ this.projectGljSheet = this.projectGljSpread .getSheet(0);
|
|
|
+ this.initSheet(this.projectGljSheet,this.projectGljSetting);
|
|
|
+ this.projectGljSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onProjectGljSelectionChange);
|
|
|
+ this.projectGljSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onProjectGljEditStarting);
|
|
|
+ this.projectGljSheet.name('projectGljSheet');
|
|
|
+ },
|
|
|
+ onProjectGljEditStarting:function (sender, args) {
|
|
|
+ let me = projectGljObject;
|
|
|
+ let row = args.row;
|
|
|
+ let col = args.col;
|
|
|
+ let dataCode = me.projectGljSetting.header[col].dataCode;
|
|
|
+ if(dataCode=='is_adjust_price'||dataCode=='is_evaluate'){
|
|
|
+ args.cancel = true;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onProjectGljSelectionChange:function (sender, args) {
|
|
|
+ let me = projectGljObject;
|
|
|
+ let row = args.newSelections[0].row;
|
|
|
+ let col = args.newSelections[0].col;
|
|
|
+ let data = me.projectGljSheetData[row];
|
|
|
+ let dataCode = me.projectGljSetting.header[col].dataCode;
|
|
|
+ if(dataCode=='basePrice'||dataCode=='marketPrice'||dataCode=='supply'){//有组成物时,市场单价、定额价、供货方式不能修改
|
|
|
+ let priceCell = false;
|
|
|
+ if (data.ratio_data && data.ratio_data.length > 0){
|
|
|
+ priceCell = true;
|
|
|
+ }
|
|
|
+ if(priceCell==false&&dataCode=='basePrice'&&data.is_add!=1){//如果不是新增,定额价不可修改。
|
|
|
+ priceCell = true;
|
|
|
+ }
|
|
|
+ me.projectGljSheet.getCell(row, col, GC.Spread.Sheets.SheetArea.viewport).locked(priceCell);
|
|
|
+ }
|
|
|
+ if(dataCode == 'supply_quantity'){
|
|
|
+ if (data.supply == 1) {// 如果为部分甲供则甲供数量需要可编辑
|
|
|
+ me.projectGljSheet.getCell(row, col, GC.Spread.Sheets.SheetArea.viewport).locked(false);
|
|
|
+ }else {
|
|
|
+ me.projectGljSheet.getCell(row, col, GC.Spread.Sheets.SheetArea.viewport).locked(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ me.projectGljSheet.repaint();
|
|
|
+ },
|
|
|
|
|
|
|
|
|
+ showProjectGljData:function () {
|
|
|
+ let projectGljSheetData = [];
|
|
|
+ let gljList = projectObj.project.projectGLJ.datas.gljList;
|
|
|
+ gljList = filterProjectGLJ(gljList);
|
|
|
+ gljList = sortProjectGLJ(gljList);
|
|
|
+ for(let glj of gljList){
|
|
|
+ projectGljSheetData.push(this.getSheetDataByGLJ(glj));
|
|
|
+ }
|
|
|
+ this.projectGljSheetData = projectGljSheetData;
|
|
|
+ this.projectGljSheet.setRowCount(0);
|
|
|
+ sheetCommonObj.showData(this.projectGljSheet, this.projectGljSetting,this.projectGljSheetData);
|
|
|
+ this.projectGljSheet.setRowCount(this.projectGljSheetData.length);
|
|
|
+ },
|
|
|
+ getSheetDataByGLJ:function (glj) {
|
|
|
+ let projectGLJ = projectObj.project.projectGLJ;
|
|
|
+ let materialIdList = projectGLJ.datas.constData.materialIdList;
|
|
|
+ let data ={
|
|
|
+ id:glj.id,
|
|
|
+ code:glj.code,
|
|
|
+ name:glj.name,
|
|
|
+ specs:glj.specs,
|
|
|
+ unit:glj.unit,
|
|
|
+ type:glj.type,
|
|
|
+ short_name:projectGLJ.getShortNameByID(glj.type),
|
|
|
+ quantity:glj.quantity,
|
|
|
+ supply:glj.supply,
|
|
|
+ supply_quantity:glj.supply_quantity,
|
|
|
+ delivery:glj.delivery,
|
|
|
+ delivery_address:glj.delivery_address,
|
|
|
+ is_adjust_price:glj.is_adjust_price,
|
|
|
+ ratio_data:glj.ratio_data,
|
|
|
+ is_add:glj.unit_price.is_add,
|
|
|
+ bgColour:'white'
|
|
|
+ };
|
|
|
+ gljOprObj.setGLJPrice(data,glj);
|
|
|
|
|
|
+ //供货方式为完全甲供时设置甲供数量为总消耗量
|
|
|
+ if (data.supply == 2) {
|
|
|
+ data.supply_quantity = glj.quantity;
|
|
|
+ }
|
|
|
+ // 只有材料才显示是否暂估
|
|
|
+ if (materialIdList.indexOf(glj.type) >= 0) {
|
|
|
+ data.is_evaluate = glj.is_evaluate;
|
|
|
+ }
|
|
|
+ //bgColour
|
|
|
+ if(data.basePrice == data.marketPrice){//如果定额价等于市场价时,改底色。 优先度低于有组成物时的底色
|
|
|
+ data.bgColour = "#C4CAFB";
|
|
|
+ }
|
|
|
+ if (notEditType.indexOf(glj.type) >= 0) {
|
|
|
+ if (data.ratio_data && data.ratio_data.length > 0){//有组成物时
|
|
|
+ //设置底色
|
|
|
+ data.bgColour = "#E0E0E0";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ },
|
|
|
+ refreshProjectGljRow:function (row) {
|
|
|
+ let me = projectGljObject;
|
|
|
+ let rowData = me.projectGljSheetData[row];
|
|
|
+ let glj = projectObj.project.projectGLJ.getByID(rowData.id);
|
|
|
+ if(glj){
|
|
|
+ me.projectGljSheetData[row] = me.getSheetDataByGLJ(glj);
|
|
|
+ }
|
|
|
+ sheetCommonObj.showRowData(this.projectGljSheet, this.projectGljSetting,row,this.projectGljSheetData);
|
|
|
+ },
|
|
|
+ initSheet: function (sheet,setting) {
|
|
|
+ var me = this;
|
|
|
+ sheetCommonObj.initSheet(sheet, setting, 30);
|
|
|
+ sheet.bind(GC.Spread.Sheets.Events.ValueChanged, me.onSheetValueChange);
|
|
|
+ },
|
|
|
+ onSheetValueChange:function (e,info) {
|
|
|
+ let me = projectGljObject;
|
|
|
+ if(info.sheetName=='projectGljSheet'){
|
|
|
+ me.onProjectGLJValueChange(e,info);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onProjectGLJValueChange:function (e,info) {
|
|
|
+ let projectGLJ = projectObj.project.projectGLJ;
|
|
|
+ let me = projectGljObject,row = info.row, col = info.col;
|
|
|
+ let dataCode = me.projectGljSetting.header[col].dataCode;
|
|
|
+ let recode = me.projectGljSheetData[row];
|
|
|
+ let value = info.newValue;
|
|
|
+ if (!me.checkData(col,me.projectGljSetting,value)) {
|
|
|
+ alert('输入的数据类型不对,请重新输入!');
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ let callback=function (impactList) {
|
|
|
+ info.sheet.suspendPaint();
|
|
|
+ info.sheet.suspendEvent();
|
|
|
+ me.refreshProjectGljRow(row);
|
|
|
+ for(let g of impactList){
|
|
|
+ let index = _.findIndex(me.projectGljSheetData, { 'id': g.id });
|
|
|
+ if(index>=0&&index != row){
|
|
|
+ me.refreshProjectGljRow(index);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ info.sheet.resumeEvent();
|
|
|
+ info.sheet.resumePaint();
|
|
|
+ };
|
|
|
+ if(dataCode=='basePrice'||dataCode=='marketPrice'){
|
|
|
+ value= scMathUtil.roundForObj(value,getDecimal('glj.unitPrice'));//修改市场价和修改定额价时需要重新记算很多受影响的树节点,现在改成与定字额工料机那里调相同的方法。
|
|
|
+ let editField = dataCode === 'basePrice'?"base_price":"market_price";
|
|
|
+ projectObj.project.projectGLJ.updatePrice(recode,editField,value,'pg',callback);
|
|
|
+
|
|
|
+ }else {
|
|
|
+ let extend = {};
|
|
|
+ // 如果是供货方式则需要处理数据
|
|
|
+ if (dataCode === 'supply') {
|
|
|
+ extend.supply_quantity = me.getSupplyQuantity(value, recode.quantity);
|
|
|
+ }
|
|
|
+ if(dataCode === 'supply_quantity'){//修改数量需做4舍5入
|
|
|
+ value= value.toDecimal(getDecimal('glj.quantity'));
|
|
|
+ }
|
|
|
+ if(dataCode === 'is_evaluate'||dataCode === 'is_adjust_price'){
|
|
|
+ if(value == true){
|
|
|
+ value = 1;
|
|
|
+ }else if(value == false){
|
|
|
+ value = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ extend = Object.keys(extend).length > 0 ? JSON.stringify(extend) : '';
|
|
|
+ let updateData = {id: recode.id, field: dataCode, value: value, extend: extend};
|
|
|
+ projectGLJ.pGljUpdate(updateData,callback);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getSupplyQuantity : function(supplyType, quantity) {
|
|
|
+ // 自行采购和甲定乙供则把甲供数量设置为0,其余情况则设置为当前总消耗量
|
|
|
+ let supplyQuantity = supplyType == 0 || supplyType == 3 ? 0 : quantity;
|
|
|
+ supplyQuantity = parseFloat(supplyQuantity);
|
|
|
+ return supplyQuantity;
|
|
|
+ },
|
|
|
+ checkData : function(col,setting, value) {
|
|
|
+ let result = true;
|
|
|
+ let validator = setting.header[col].validator !== undefined ? setting.header[col].validator : null;
|
|
|
+ if (validator === null) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ switch (validator) {
|
|
|
+ case 'number':
|
|
|
+ let regular = /^\d+(\.\d+)?$/;
|
|
|
+ result = regular.test(value);
|
|
|
+ break;
|
|
|
+ case 'boolean':
|
|
|
+ let booleanValue = [true, false];
|
|
|
+ result = booleanValue.indexOf(value) >= 0;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
|
|
|
$(function () {
|
|
|
-
|
|
|
-
|
|
|
$('#tab_project_glj').on('show.bs.tab', function (e) {
|
|
|
+ let me = projectGljObject;
|
|
|
$(e.relatedTarget.hash).removeClass('active');
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ setTimeout(function () {
|
|
|
+ if(me.projectGljSpread==null){
|
|
|
+ me.initProjectGljSpread();
|
|
|
+ }
|
|
|
+ me.showProjectGljData();
|
|
|
+ loadSize("project-glj-main", function () {
|
|
|
+ me.projectGljSpread.refresh();
|
|
|
+ });
|
|
|
+ },1)
|
|
|
+ });
|
|
|
+ slideResize($("#project-glj-main"), function () {
|
|
|
+ projectGljObject.projectGljSpread.refresh();
|
|
|
});
|
|
|
-
|
|
|
});
|
|
|
|
|
|
|