|
|
@@ -0,0 +1,387 @@
|
|
|
+/**
|
|
|
+ * Created by zhang on 2019/5/15.
|
|
|
+ */
|
|
|
+let materialAdjustObj = {
|
|
|
+ spread:null,
|
|
|
+ priceInfoSheet:null,
|
|
|
+ priceCoeSheet:null,
|
|
|
+ priceInfoDatas:[],
|
|
|
+ priceCoeDatas:[],
|
|
|
+ priceInfoSetting:{
|
|
|
+ header: [
|
|
|
+ {headerName: "编号", headerWidth: 80, dataCode: "code", dataType: "String"},
|
|
|
+ {headerName: "材料名称", headerWidth: 160, dataCode: "name", dataType: "String",cellType:'tipsCell'},
|
|
|
+ {headerName: "规格型号", headerWidth: 120, dataCode: "specs", hAlign: "left", dataType: "String",cellType:'tipsCell'},
|
|
|
+ {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
|
|
|
+ {headerName: "数量", headerWidth: 90, dataCode: "quantity", hAlign: "right", dataType: "Number",decimalField:'glj.quantity'},
|
|
|
+ {headerName: "风险系数", headerWidth: 90, dataCode: "riskCoe", hAlign: "right", dataType: "Number",validator:"number"},
|
|
|
+ {headerName: "基准单价", headerWidth: 70, dataCode: "standardPrice", hAlign: "right", dataType: "Number",validator:"number"},
|
|
|
+ {headerName: "投标单价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},
|
|
|
+ {headerName: "合价", headerWidth: 70, dataCode: "totalPrice", hAlign: "right", dataType: "Number",validator:"number"},
|
|
|
+ {headerName: "产地", headerWidth: 80, dataCode: "originPlace", hAlign: "left", dataType: "String"},
|
|
|
+ {headerName: "厂家", headerWidth: 80, dataCode: "vender", hAlign: "left", dataType: "String"},
|
|
|
+ {headerName: "供货方式", headerWidth: 70, dataCode: "supply", hAlign: "center", dataType: "String",cellType:'comboBox',editorValueType:true,options:supplyComboMap},
|
|
|
+ {headerName: "备注", headerWidth: 100, dataCode: "remark", hAlign: "left", dataType: "String"}
|
|
|
+ ],
|
|
|
+ view:{ lockColumns: ["code","name","specs","unit","quantity","totalPrice","originPlace","vender","supply","remark"]}
|
|
|
+ },
|
|
|
+ priceCoeSetting:{
|
|
|
+ header: [
|
|
|
+ {headerName: "编号", headerWidth: 80, dataCode: "code", dataType: "String"},
|
|
|
+ {headerName: "材料名称", headerWidth: 160, dataCode: "name", dataType: "String",cellType:'tipsCell'},
|
|
|
+ {headerName: "规格型号", headerWidth: 120, dataCode: "specs", hAlign: "left", dataType: "String",cellType:'tipsCell'},
|
|
|
+ {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
|
|
|
+ {headerName: "变值权重B", headerWidth: 90, dataCode: "varWeight", hAlign: "right", dataType: "Number",validator:"number"},
|
|
|
+ {headerName: "基本价格指数FO", headerWidth: 70, dataCode: "FO", hAlign: "right", dataType: "Number",validator:"number"},
|
|
|
+ {headerName: "现行价格指数FI", headerWidth: 70, dataCode: "FI", hAlign: "right", dataType: "Number",validator:"number"},
|
|
|
+ {headerName: "数量", headerWidth: 90, dataCode: "quantity", hAlign: "right", dataType: "Number",decimalField:'glj.quantity'},
|
|
|
+ {headerName: "单价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},
|
|
|
+ {headerName: "合价", headerWidth: 70, dataCode: "totalPrice", hAlign: "right", dataType: "Number",validator:"number"},
|
|
|
+ {headerName: "产地", headerWidth: 80, dataCode: "originPlace", hAlign: "left", dataType: "String"},
|
|
|
+ {headerName: "厂家", headerWidth: 80, dataCode: "vender", hAlign: "left", dataType: "String"},
|
|
|
+ {headerName: "供货方式", headerWidth: 70, dataCode: "supply", hAlign: "center", dataType: "String",cellType:'comboBox',editorValueType:true,options:supplyComboMap},
|
|
|
+ {headerName: "备注", headerWidth: 100, dataCode: "remark", hAlign: "left", dataType: "String"}
|
|
|
+ ],
|
|
|
+ view:{ lockColumns: ["code","name","specs","unit","quantity","totalPrice","originPlace","vender","supply","remark"]}
|
|
|
+ },
|
|
|
+ refreshSheetDatas:function () {
|
|
|
+ $("#adjustType").val() == "priceInfo" ? materialAdjustObj.showPriceInfoDatas():materialAdjustObj.showPriceCoeDatas();
|
|
|
+ //let sheetIndex = $("#adjustType").val()
|
|
|
+ },
|
|
|
+ initSpread:function () {
|
|
|
+ if(!this.spread){
|
|
|
+ this.spread = SheetDataHelper.createNewSpread($("#material_adjust_sheet")[0],2);
|
|
|
+ sheetCommonObj.spreadDefaultStyle(this.spread);
|
|
|
+ }
|
|
|
+ this.initPriceInfoSheet();
|
|
|
+ this.initPriceCoeSheet();
|
|
|
+ //disableRightMenu("project_glj_sheet",this.projectGljSpread,this.rightClickCallback);
|
|
|
+ //打开别人分享的项目,只读
|
|
|
+ if(projectReadOnly){
|
|
|
+ disableSpread(this.spread);
|
|
|
+ }else {
|
|
|
+ this.initRightClick();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ initPriceInfoSheet:function () {
|
|
|
+ this.priceInfoSheet = this.spread.getSheet(0);
|
|
|
+ sheetCommonObj.initSheet(this.priceInfoSheet,this.priceInfoSetting,30);
|
|
|
+ this.priceInfoSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onSheetValueChange);
|
|
|
+ this.priceInfoSheet.name('priceInfoSheet');
|
|
|
+ this.priceInfoSheet.setRowHeight(0, 45, 1);
|
|
|
+ },
|
|
|
+ initPriceCoeSheet:function () {
|
|
|
+ this.priceCoeSheet = this.spread.getSheet(1);
|
|
|
+ sheetCommonObj.initSheet(this.priceCoeSheet,this.priceCoeSetting,30);
|
|
|
+ this.priceCoeSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onSheetValueChange);
|
|
|
+ this.priceCoeSheet.name('priceCoeSheet');
|
|
|
+ this.priceCoeSheet.setRowHeight(0, 45, 1);
|
|
|
+ },
|
|
|
+ onSheetValueChange:function (a,args) {
|
|
|
+ let me = materialAdjustObj,row = args.row, col = args.col;
|
|
|
+ let projectGLJ = projectObj.project.projectGLJ;
|
|
|
+ let setting = $("#adjustType").val() == "priceInfo"?me.priceInfoSetting:me.priceCoeSetting;
|
|
|
+ let datas = $("#adjustType").val() == "priceInfo"?me.priceInfoDatas:me.priceCoeDatas;
|
|
|
+ let dataCode = setting.header[col].dataCode;
|
|
|
+ let recode = datas[row];
|
|
|
+ let value = args.newValue;
|
|
|
+ if(value === undefined ){
|
|
|
+ me.refreshSheetDatas();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (value&&!projectGljObject.checkData(col,setting,value)) {
|
|
|
+ alert('输入的数据类型不对,请重新输入!');
|
|
|
+ me.refreshSheetDatas();
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ if(recode[dataCode] == value) return;
|
|
|
+
|
|
|
+ if(dataCode=='marketPrice'){//修改市场价和修改定额价时需要重新记算很多受影响的树节点,现在改成与定字额工料机那里调相同的方法。
|
|
|
+ let editField ="market_price";
|
|
|
+ projectGLJ.updatePrice(recode,editField,value,'pg',me.refreshSheetDatas);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ value = scMathUtil.roundForObj(value,getDecimal("process"));
|
|
|
+ let updateData = {id: recode.id, field: dataCode, value: value+""};
|
|
|
+ projectGLJ.pGljUpdate(updateData,me.refreshSheetDatas);
|
|
|
+
|
|
|
+ },
|
|
|
+ deleteAdjust:function (row) {
|
|
|
+ let me = this;
|
|
|
+ let projectGLJ = projectObj.project.projectGLJ;
|
|
|
+ let field = $("#adjustType").val() == "priceInfo"?"is_info_adjust":"is_coe_adjust";
|
|
|
+ let datas = $("#adjustType").val() == "priceInfo"?me.priceInfoDatas:me.priceCoeDatas;
|
|
|
+ let recode = datas[row];
|
|
|
+ let updateData = {id: recode.id, field: field, value: 0};
|
|
|
+ projectGLJ.pGljUpdate(updateData,me.refreshSheetDatas);
|
|
|
+ },
|
|
|
+ showPriceInfoDatas:function () {
|
|
|
+ this.spread.setActiveSheetIndex(0);
|
|
|
+ this.priceInfoDatas = this.getPirceInfoDatas();
|
|
|
+ sheetCommonObj.showData(this.priceInfoSheet, this.priceInfoSetting,this.priceInfoDatas);
|
|
|
+ this.priceInfoSheet.setRowCount(this.priceInfoDatas.length);
|
|
|
+ },
|
|
|
+ showPriceCoeDatas:function () {
|
|
|
+ this.spread.setActiveSheetIndex(1);
|
|
|
+ this.priceCoeDatas = this.getPriceCoeDatas();
|
|
|
+ sheetCommonObj.showData(this.priceCoeSheet, this.priceCoeSetting,this.priceCoeDatas);
|
|
|
+ this.priceCoeSheet.setRowCount(this.priceCoeDatas.length);
|
|
|
+ },
|
|
|
+ getPirceInfoDatas:function(){
|
|
|
+ let datas = [];
|
|
|
+ let gljList = this.filterAdjustGlj();
|
|
|
+ gljList = sortProjectGLJ(gljList);
|
|
|
+ for(let glj of gljList){
|
|
|
+ datas.push(getInfoObject(glj));
|
|
|
+ }
|
|
|
+ return datas;
|
|
|
+ function getInfoObject(glj) {
|
|
|
+ let data = materialAdjustObj.getCommonObject(glj);
|
|
|
+ data.riskCoe = glj.riskCoe;
|
|
|
+ data.standardPrice = glj.standardPrice;
|
|
|
+ data.totalPrice = materialAdjustObj.getTotalPrice(data);
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ filterAdjustGlj:function () {
|
|
|
+ let gljList = projectObj.project.projectGLJ.datas.gljList;
|
|
|
+ let field = $("#adjustType").val() == "priceInfo"?"is_info_adjust":"is_coe_adjust";
|
|
|
+ return _.filter(gljList,function (item) {
|
|
|
+ return item.quantity !== 0 && item.quantity !== '0' && item[field] ===1
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getPriceCoeDatas:function () {
|
|
|
+ let datas = [];
|
|
|
+ let node = projectObj.project.Bills.getEngineeringCostNode(projectObj.mainController);
|
|
|
+ let totalFee = node && node.data.feesIndex && node.data.feesIndex.common?node.data.feesIndex.common.totalFee:0;
|
|
|
+ let gljList = this.filterAdjustGlj();
|
|
|
+ gljList = sortProjectGLJ(gljList);
|
|
|
+ for(let glj of gljList){
|
|
|
+ datas.push(getCoeObject(glj,totalFee));
|
|
|
+ }
|
|
|
+ return datas;
|
|
|
+ function getCoeObject(glj,totalFee) {
|
|
|
+ let data = materialAdjustObj.getCommonObject(glj);
|
|
|
+ data.FO = glj.FO;
|
|
|
+ data.FI = glj.FI;
|
|
|
+ data.totalPrice = materialAdjustObj.getTotalPrice(data);
|
|
|
+ if(totalFee !==0) data.varWeight = scMathUtil.roundForObj(data.totalPrice/totalFee,2);
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getTotalPrice:function (data) {
|
|
|
+ return scMathUtil.roundForObj(data.quantity * data.marketPrice,getDecimal("bills.totalPrice"))
|
|
|
+ },
|
|
|
+ initRightClick : function() {
|
|
|
+ let me = this;
|
|
|
+ $.contextMenu({
|
|
|
+ selector: '#material_adjust_sheet',
|
|
|
+ build: function ($trigger, e) {
|
|
|
+ me.rightClickTarget = SheetDataHelper.safeRightClickSelection($trigger, e, me.spread);
|
|
|
+ return me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.viewport ||
|
|
|
+ me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
|
|
|
+ },
|
|
|
+ items: {
|
|
|
+ "addFromGLJ":{
|
|
|
+ name: '从人材机汇总中选择',
|
|
|
+ icon: 'fa-sign-in',
|
|
|
+ disabled: function () {
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+ callback: function (key, opt) {
|
|
|
+ $("#selectFromGLJ").modal('show');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "deleteAdjust": {
|
|
|
+ name: "删除",
|
|
|
+ icon: 'fa-trash-o',
|
|
|
+ disabled: function () {
|
|
|
+ return me.rightClickTarget.row === undefined;
|
|
|
+ },
|
|
|
+ callback: function (key, opt) {
|
|
|
+ let row = me.rightClickTarget.row;
|
|
|
+ me.deleteAdjust(row);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getCommonObject:function (glj) {
|
|
|
+ let data ={
|
|
|
+ select:0,
|
|
|
+ id:glj.id,
|
|
|
+ code:glj.code,
|
|
|
+ name:glj.name,
|
|
|
+ specs:glj.specs,
|
|
|
+ unit:glj.unit,
|
|
|
+ type:glj.type,
|
|
|
+ quantity:glj.quantity,
|
|
|
+ supply:glj.supply,
|
|
|
+ originPlace:glj.originPlace,
|
|
|
+ vender:glj.vender,
|
|
|
+ brand:glj.brand,
|
|
|
+ remark:glj.remark
|
|
|
+ };
|
|
|
+ gljOprObj.setGLJPrice(data,glj);
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+let gljFromObj={
|
|
|
+ spread:null,
|
|
|
+ sheet:null,
|
|
|
+ datas:[],
|
|
|
+ setting:{
|
|
|
+ header: [
|
|
|
+ {headerName: "选择", headerWidth: 45, dataCode: "select", hAlign: "center", dataType: "String",cellType:'checkBox'},
|
|
|
+ {headerName: "编码", headerWidth: 80, dataCode: "code", dataType: "String"},
|
|
|
+ {headerName: "类型", headerWidth: 30, dataCode: "short_name", hAlign: "center", dataType: "String"},
|
|
|
+ {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String",cellType:'tipsCell'},
|
|
|
+ {headerName: "规格型号", headerWidth: 100, dataCode: "specs", hAlign: "left", dataType: "String",cellType:'tipsCell'},
|
|
|
+ {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
|
|
|
+ {headerName: "总消耗量", headerWidth: 90, dataCode: "quantity", hAlign: "right", dataType: "Number",decimalField:'glj.quantity'},
|
|
|
+ {headerName: "市场价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
|
|
|
+ {headerName: "供货方式", headerWidth: 70, dataCode: "supply", hAlign: "center", dataType: "String",cellType:'comboBox',editorValueType:true,options:supplyComboMap},
|
|
|
+ {headerName: "暂估", headerWidth: 45, dataCode: "is_evaluate", hAlign: "center", dataType: "String",cellType:'checkBox'},
|
|
|
+ {headerName: "产地", headerWidth: 80, dataCode: "originPlace", hAlign: "left", dataType: "String"},
|
|
|
+ {headerName: "厂家", headerWidth: 80, dataCode: "vender", hAlign: "left", dataType: "String"},
|
|
|
+ {headerName: "备注", headerWidth: 100, dataCode: "remark", hAlign: "left", dataType: "String"}
|
|
|
+ ],
|
|
|
+ view: {
|
|
|
+ lockColumns: ["is_evaluate"]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ initSpread:function () {
|
|
|
+ if(!this.spread){
|
|
|
+ this.spread = SheetDataHelper.createNewSpread($("#glj_from_sheet")[0]);
|
|
|
+ sheetCommonObj.spreadDefaultStyle(this.spread);
|
|
|
+ }
|
|
|
+ this.sheet = this.spread.getSheet(0);
|
|
|
+ sheetCommonObj.initSheet(this.sheet,this.setting);
|
|
|
+ this.sheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onEditStarting);
|
|
|
+ this.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, this.onClipboardPasting);
|
|
|
+ this.sheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onValueChanged);
|
|
|
+ this.sheet.setRowHeight(0, 45, 1);
|
|
|
+ disableRightMenu("glj_from_sheet",this.spread);
|
|
|
+ },
|
|
|
+ onEditStarting:function (e,args) {
|
|
|
+ args.cancel = true;
|
|
|
+ },
|
|
|
+ onClipboardPasting:function (e,args) {
|
|
|
+ args.cancel = true;
|
|
|
+ },
|
|
|
+ onValueChanged:function (e,args) {
|
|
|
+ let me = gljFromObj;
|
|
|
+ let value = args.newValue;
|
|
|
+ value = value == true?1:0;
|
|
|
+ me.datas[args.row].select = value;
|
|
|
+ },
|
|
|
+ showDatas:function () {
|
|
|
+ this.datas = [];
|
|
|
+ let gljList = projectObj.project.projectGLJ.datas.gljList;
|
|
|
+ gljList = this.filterGLJ(gljList);
|
|
|
+ gljList = sortProjectGLJ(gljList);
|
|
|
+ for(let glj of gljList){
|
|
|
+ this.datas.push(this.getSheetDatas(glj));
|
|
|
+ }
|
|
|
+ this.refreshDatas();
|
|
|
+ },
|
|
|
+ filterGLJ:function (gljList) {
|
|
|
+ let field = $("#adjustType").val() == "priceInfo"?"is_info_adjust":"is_coe_adjust";
|
|
|
+ let typeMap = {};
|
|
|
+ for(let ch of $(".glj_sel_input:checked")){
|
|
|
+ typeMap[$(ch).val()] = true;
|
|
|
+ }
|
|
|
+ let inputV = $("#glj_sel_input").val();
|
|
|
+ return _.filter(gljList,function (item) {
|
|
|
+ if(item.quantity === 0 || item.quantity === '0' || item[field] ===1) return false;
|
|
|
+ if(!typeMap[0]){//如果没有勾选所有,下面再细分
|
|
|
+ let firstS = (item.type+"").substring(0,1);
|
|
|
+ if(!typeMap[firstS]) return false
|
|
|
+ }
|
|
|
+ if(inputV!=""){//输入的关键字过滤
|
|
|
+ if(item.code.indexOf(inputV)==-1 && item.name.indexOf(inputV)==-1) return false
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ refreshDatas:function () {
|
|
|
+ sheetCommonObj.showData(this.sheet, this.setting,this.datas);
|
|
|
+ this.sheet.setRowCount(this.datas.length);
|
|
|
+ },
|
|
|
+ getSheetDatas(glj){
|
|
|
+ let projectGLJ = projectObj.project.projectGLJ;
|
|
|
+ let materialIdList = projectGLJ.datas.constData.materialIdList;
|
|
|
+ let data = materialAdjustObj.getCommonObject(glj);
|
|
|
+ data.select = 0;
|
|
|
+ data.short_name = projectGLJ.getShortNameByID(glj.type);
|
|
|
+ // 只有材料才显示是否暂估
|
|
|
+ if (materialIdList.indexOf(glj.type) >= 0) data.is_evaluate = glj.is_evaluate;
|
|
|
+ return data;
|
|
|
+ },
|
|
|
+ checkByType:function (type) {
|
|
|
+ for(let d of this.datas){
|
|
|
+ d.select = 0;
|
|
|
+ switch (type){
|
|
|
+ case "全选":
|
|
|
+ d.select = 1;
|
|
|
+ break;
|
|
|
+ case "全选主材":
|
|
|
+ if(d.type == 4) d.select = 1;
|
|
|
+ break;
|
|
|
+ case "全选设备":
|
|
|
+ if(d.type == 5) d.select = 1;
|
|
|
+ break;
|
|
|
+ case "取消":
|
|
|
+ d.select = 0;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.refreshDatas();
|
|
|
+ },
|
|
|
+ confirmSelect:function () {
|
|
|
+ let updateMap = {};
|
|
|
+ let adjustType = $("#adjustType").val()
|
|
|
+ for(let d of this.datas){
|
|
|
+ if(d.select == 1){
|
|
|
+ let tem;
|
|
|
+ if(adjustType== "priceInfo"){
|
|
|
+ tem = {is_info_adjust:1,riskCoe:"",standardPrice:d.marketPrice+""};
|
|
|
+ }else {
|
|
|
+ tem = {is_coe_adjust:1,FI:"",FO:""};
|
|
|
+ }
|
|
|
+ updateMap[d.id] = tem;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if( _.isEmpty(updateMap)) return;
|
|
|
+ projectObj.project.projectGLJ.batchUpdateGLJProperty(updateMap,function () {
|
|
|
+ materialAdjustObj.refreshSheetDatas();
|
|
|
+ });
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+$(function () {
|
|
|
+ $("#adjustType").change(function () {
|
|
|
+ materialAdjustObj.refreshSheetDatas();
|
|
|
+ });
|
|
|
+ $('#selectFromGLJ').on('shown.bs.modal',function(e){
|
|
|
+ gljFromObj.initSpread();
|
|
|
+ gljFromObj.showDatas();
|
|
|
+ });
|
|
|
+ $(".glj_sel_input").change(function () {
|
|
|
+ gljFromObj.showDatas();
|
|
|
+ });
|
|
|
+
|
|
|
+ $("#glj_sel_btn_find").click(function () {
|
|
|
+ gljFromObj.showDatas();
|
|
|
+ });
|
|
|
+
|
|
|
+ $(".glj_sel_check_btn").click(function () {
|
|
|
+ gljFromObj.checkByType($(this).text())
|
|
|
+ })
|
|
|
+
|
|
|
+ $("#glj_sel_confirm").click(function () {
|
|
|
+ gljFromObj.confirmSelect();
|
|
|
+ })
|
|
|
+});
|