|
@@ -17,6 +17,9 @@ function ProjectGLJSpread() {
|
|
this.firstMachineRow = -1;
|
|
this.firstMachineRow = -1;
|
|
this.firstMixRatioRow = -1;
|
|
this.firstMixRatioRow = -1;
|
|
this.successCallback = null;
|
|
this.successCallback = null;
|
|
|
|
+ this.supplyType = ['自行采购', '部分甲供', '完全甲供', '甲定乙供'];
|
|
|
|
+ // 工料机类型是混凝土、砂浆、配合比、机械(不包括机械组成物)时,供货方式列只读。
|
|
|
|
+ this.supplyReadonlyType = [GLJTypeConst.CONCRETE, GLJTypeConst.MORTAR, GLJTypeConst.MIX_RATIO, GLJTypeConst.GENERAL_MACHINE];
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -25,7 +28,17 @@ function ProjectGLJSpread() {
|
|
* @return {object}
|
|
* @return {object}
|
|
*/
|
|
*/
|
|
ProjectGLJSpread.prototype.init = function () {
|
|
ProjectGLJSpread.prototype.init = function () {
|
|
-
|
|
|
|
|
|
+ // 供货方式类型
|
|
|
|
+ let supplySelect = [];
|
|
|
|
+ for(let index in this.supplyType) {
|
|
|
|
+ supplySelect.push({
|
|
|
|
+ text: this.supplyType[index],
|
|
|
|
+ value: index
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ let selectBox = new GC.Spread.Sheets.CellTypes.ComboBox();
|
|
|
|
+ selectBox.items(supplySelect);
|
|
|
|
+ selectBox.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
|
|
let header = [
|
|
let header = [
|
|
{name: '编码', field: 'code', visible: true},
|
|
{name: '编码', field: 'code', visible: true},
|
|
{name: '名称', field: 'name', visible: true},
|
|
{name: '名称', field: 'name', visible: true},
|
|
@@ -44,7 +57,7 @@ ProjectGLJSpread.prototype.init = function () {
|
|
cellType: new GC.Spread.Sheets.CellTypes.CheckBox(),
|
|
cellType: new GC.Spread.Sheets.CellTypes.CheckBox(),
|
|
validator: 'boolean'
|
|
validator: 'boolean'
|
|
},
|
|
},
|
|
- {name: '供货方式', field: 'supply', visible: true},
|
|
|
|
|
|
+ {name: '供货方式', field: 'supply', visible: true, cellType: selectBox},
|
|
{name: '甲供数量', field: 'supply_quantity', visible: true},
|
|
{name: '甲供数量', field: 'supply_quantity', visible: true},
|
|
{name: '交货方式', field: 'delivery', visible: true},
|
|
{name: '交货方式', field: 'delivery', visible: true},
|
|
{name: '送达地点', field: 'delivery_address', visible: true},
|
|
{name: '送达地点', field: 'delivery_address', visible: true},
|
|
@@ -74,6 +87,7 @@ ProjectGLJSpread.prototype.init = function () {
|
|
let basePriceColumn = this.sheetObj.getFieldColumn('unit_price.base_price');
|
|
let basePriceColumn = this.sheetObj.getFieldColumn('unit_price.base_price');
|
|
let adjustPriceColumn = this.sheetObj.getFieldColumn('adjust_price');
|
|
let adjustPriceColumn = this.sheetObj.getFieldColumn('adjust_price');
|
|
let marketPriceColumn = this.sheetObj.getFieldColumn('unit_price.market_price');
|
|
let marketPriceColumn = this.sheetObj.getFieldColumn('unit_price.market_price');
|
|
|
|
+ let supplyColumn = this.sheetObj.getFieldColumn('supply');
|
|
|
|
|
|
// 居中样式
|
|
// 居中样式
|
|
let centerStyleSetting = {hAlign: 1};
|
|
let centerStyleSetting = {hAlign: 1};
|
|
@@ -92,6 +106,7 @@ ProjectGLJSpread.prototype.init = function () {
|
|
this.sheetObj.setColumnEditable(marketPriceColumn);
|
|
this.sheetObj.setColumnEditable(marketPriceColumn);
|
|
this.sheetObj.setColumnEditable(isEvaluateColumn);
|
|
this.sheetObj.setColumnEditable(isEvaluateColumn);
|
|
this.sheetObj.setColumnEditable(isAdjustPriceColumn);
|
|
this.sheetObj.setColumnEditable(isAdjustPriceColumn);
|
|
|
|
+ this.sheetObj.setColumnEditable(11);
|
|
this.sheetObj.setData(sourceData);
|
|
this.sheetObj.setData(sourceData);
|
|
// 取消正在加载字符提示
|
|
// 取消正在加载字符提示
|
|
$("#project-glj > p").hide();
|
|
$("#project-glj > p").hide();
|
|
@@ -179,6 +194,12 @@ ProjectGLJSpread.prototype.updateProjectGLJField = function(info, callback) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 如果是供货方式则需要处理数据
|
|
|
|
+ if (field === 'supply') {
|
|
|
|
+ value = this.supplyType.indexOf(value);
|
|
|
|
+ extend.supply_quantity = this.getSupplyQuantity(value, activeSheet, info);
|
|
|
|
+ }
|
|
|
|
+
|
|
extend = Object.keys(extend).length > 0 ? JSON.stringify(extend) : '';
|
|
extend = Object.keys(extend).length > 0 ? JSON.stringify(extend) : '';
|
|
$.ajax({
|
|
$.ajax({
|
|
url: '/glj/update',
|
|
url: '/glj/update',
|
|
@@ -220,9 +241,9 @@ ProjectGLJSpread.prototype.specialColumn = function (sourceData) {
|
|
// 获取列号
|
|
// 获取列号
|
|
let isEvaluateColumn = this.sheetObj.getFieldColumn('is_evaluate');
|
|
let isEvaluateColumn = this.sheetObj.getFieldColumn('is_evaluate');
|
|
let marketPriceColumn = this.sheetObj.getFieldColumn('unit_price.market_price');
|
|
let marketPriceColumn = this.sheetObj.getFieldColumn('unit_price.market_price');
|
|
-
|
|
|
|
let connectCodeColumn = this.sheetObj.getFieldColumn('connect_code');
|
|
let connectCodeColumn = this.sheetObj.getFieldColumn('connect_code');
|
|
let consumptionColumn = this.sheetObj.getFieldColumn('consumption');
|
|
let consumptionColumn = this.sheetObj.getFieldColumn('consumption');
|
|
|
|
+ let supplyColumn = this.sheetObj.getFieldColumn('supply');
|
|
let activeSheet = this.sheetObj.getSheet();
|
|
let activeSheet = this.sheetObj.getSheet();
|
|
|
|
|
|
for (let data of sourceData) {
|
|
for (let data of sourceData) {
|
|
@@ -230,20 +251,33 @@ ProjectGLJSpread.prototype.specialColumn = function (sourceData) {
|
|
if (materialIdList.indexOf(data.unit_price.type) < 0) {
|
|
if (materialIdList.indexOf(data.unit_price.type) < 0) {
|
|
let string = new GC.Spread.Sheets.CellTypes.Text();
|
|
let string = new GC.Spread.Sheets.CellTypes.Text();
|
|
activeSheet.setCellType(rowCounter, isEvaluateColumn, string, GC.Spread.Sheets.SheetArea.viewport);
|
|
activeSheet.setCellType(rowCounter, isEvaluateColumn, string, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
|
+
|
|
// 锁定该单元格
|
|
// 锁定该单元格
|
|
- activeSheet.getRange(rowCounter, isEvaluateColumn, 1, 1).locked(true);
|
|
|
|
|
|
+ activeSheet.getCell(rowCounter, isEvaluateColumn, GC.Spread.Sheets.SheetArea.viewport).locked(true);
|
|
activeSheet.setValue(rowCounter, isEvaluateColumn, '');
|
|
activeSheet.setValue(rowCounter, isEvaluateColumn, '');
|
|
}
|
|
}
|
|
|
|
|
|
- // 如果类型为混凝土、砂浆、配合比、机械,则市场单价不能修改
|
|
|
|
|
|
+ // 供货方式数据
|
|
|
|
+ let supplyIndex = parseInt(data.supply);
|
|
|
|
+ supplyIndex = isNaN(supplyIndex) ? 0 : supplyIndex;
|
|
|
|
+ let supplyText = this.supplyType[supplyIndex] !== undefined ? this.supplyType[supplyIndex] : '自行采购';
|
|
|
|
+ activeSheet.setValue(rowCounter, supplyColumn, supplyText);
|
|
|
|
+ if (this.supplyReadonlyType.indexOf(data.unit_price.type) >= 0) {
|
|
|
|
+ // 锁定该单元格
|
|
|
|
+ activeSheet.getCell(rowCounter, supplyColumn, GC.Spread.Sheets.SheetArea.viewport).locked(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 如果类型为混凝土、砂浆、配合比、机械,则市场单价和供货方式不能修改
|
|
if (canNotChangeTypeId.indexOf(data.unit_price.type) >= 0) {
|
|
if (canNotChangeTypeId.indexOf(data.unit_price.type) >= 0) {
|
|
this.firstMixRatioRow = this.firstMixRatioRow === -1 && data.unit_price.type !== GLJTypeConst.GENERAL_MACHINE ?
|
|
this.firstMixRatioRow = this.firstMixRatioRow === -1 && data.unit_price.type !== GLJTypeConst.GENERAL_MACHINE ?
|
|
rowCounter : this.firstMixRatioRow;
|
|
rowCounter : this.firstMixRatioRow;
|
|
this.firstMachineRow = this.firstMachineRow === -1 && data.unit_price.type === GLJTypeConst.GENERAL_MACHINE ?
|
|
this.firstMachineRow = this.firstMachineRow === -1 && data.unit_price.type === GLJTypeConst.GENERAL_MACHINE ?
|
|
rowCounter : this.firstMachineRow;
|
|
rowCounter : this.firstMachineRow;
|
|
// 锁定该单元格
|
|
// 锁定该单元格
|
|
- activeSheet.getRange(rowCounter, marketPriceColumn, 1, 1).locked(true);
|
|
|
|
|
|
+ activeSheet.getCell(rowCounter, marketPriceColumn, GC.Spread.Sheets.SheetArea.viewport).locked(true);
|
|
|
|
+ activeSheet.getCell(rowCounter, supplyColumn, GC.Spread.Sheets.SheetArea.viewport).locked(true);
|
|
}
|
|
}
|
|
|
|
+
|
|
// 处理数据
|
|
// 处理数据
|
|
if (data.ratio_data !== undefined && data.ratio_data.length > 0) {
|
|
if (data.ratio_data !== undefined && data.ratio_data.length > 0) {
|
|
let connectCode = [];
|
|
let connectCode = [];
|
|
@@ -257,6 +291,7 @@ ProjectGLJSpread.prototype.specialColumn = function (sourceData) {
|
|
activeSheet.setValue(rowCounter, connectCodeColumn, connectCodeString);
|
|
activeSheet.setValue(rowCounter, connectCodeColumn, connectCodeString);
|
|
activeSheet.setValue(rowCounter, consumptionColumn, consumptionString);
|
|
activeSheet.setValue(rowCounter, consumptionColumn, consumptionString);
|
|
}
|
|
}
|
|
|
|
+
|
|
rowCounter++;
|
|
rowCounter++;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -377,4 +412,42 @@ ProjectGLJSpread.prototype.priceCalculate = function(info) {
|
|
this.compositionParentUpdate(info.parentMarketPrice);
|
|
this.compositionParentUpdate(info.parentMarketPrice);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 更改供货方式
|
|
|
|
+ *
|
|
|
|
+ * @param {Object} info
|
|
|
|
+ * @return {void}
|
|
|
|
+ */
|
|
|
|
+ProjectGLJSpread.prototype.changeSupplyType = function(info) {
|
|
|
|
+ let supply = info.newValue;
|
|
|
|
+ let supplyNumber = this.supplyType.indexOf(supply) > -1 ? this.supplyType.indexOf(supply) : 0;
|
|
|
|
+ let supplyQuantityColumn = this.sheetObj.getFieldColumn('supply_quantity');
|
|
|
|
+ let activeSheet = this.sheetObj.getSheet();
|
|
|
|
+
|
|
|
|
+ // 部分甲供时可更改甲供数量数据,其余则只读
|
|
|
|
+ let locked = supplyNumber === 1 ? false : true;
|
|
|
|
+ activeSheet.getCell(info.row, supplyQuantityColumn, GC.Spread.Sheets.SheetArea.viewport).locked(locked);
|
|
|
|
+
|
|
|
|
+ let supplyQuantity = this.getSupplyQuantity(supplyNumber, activeSheet, info);
|
|
|
|
+ activeSheet.setValue(info.row, supplyQuantityColumn, supplyQuantity);
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 根据供货方式获取甲供数量
|
|
|
|
+ *
|
|
|
|
+ * @param {Number} supplyType
|
|
|
|
+ * @param {Object} activeSheet
|
|
|
|
+ * @param {Object} info
|
|
|
|
+ * @return {Number}
|
|
|
|
+ */
|
|
|
|
+ProjectGLJSpread.prototype.getSupplyQuantity = function(supplyType, activeSheet, info) {
|
|
|
|
+ let quantityColumn = this.sheetObj.getFieldColumn('quantity');
|
|
|
|
+ // 获取总消耗量
|
|
|
|
+ let quantity = activeSheet.getValue(info.row, quantityColumn);
|
|
|
|
+ // 自行采购和甲定乙供则把甲供数量设置为0,其余情况则设置为当前总消耗量
|
|
|
|
+ let supplyQuantity = supplyType === 0 || supplyType === 3 ? 0 : quantity;
|
|
|
|
+
|
|
|
|
+ return supplyQuantity;
|
|
};
|
|
};
|