|
@@ -15,6 +15,7 @@ function CompositionSpread () {
|
|
|
this.isChanging = false;
|
|
|
this.sheetObj = null;
|
|
|
this.successCallback = null;
|
|
|
+ this.rightClickTarget = null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -34,7 +35,7 @@ CompositionSpread.prototype.init = function(target) {
|
|
|
{name: '基价单价', field: "unit_price.base_price", visible: true},
|
|
|
{name: '调整基价', field: 'adjust_price', visible: true},
|
|
|
{name: '市场单价', field: "unit_price.market_price", visible: true},
|
|
|
- {name: '消耗量', field: 'consumption', visible: true, validator: 'number'},
|
|
|
+ {name: name, field: 'consumption', visible: true, validator: 'number'},
|
|
|
{name: 'CID', field: 'mix_ratio_id', visible: false},
|
|
|
];
|
|
|
|
|
@@ -67,27 +68,28 @@ CompositionSpread.prototype.init = function(target) {
|
|
|
/**
|
|
|
* 初始化右键
|
|
|
*
|
|
|
+ * @param {String} target
|
|
|
* @return {void}
|
|
|
*/
|
|
|
-CompositionSpread.prototype.initRightClick = function() {
|
|
|
+CompositionSpread.prototype.initRightClick = function(target) {
|
|
|
let activeSheet = this.sheetObj.getSheet();
|
|
|
let self = this;
|
|
|
$.contextMenu({
|
|
|
- selector: '#mix-ratio',
|
|
|
+ selector: '#' + target,
|
|
|
build: function ($trigger, e) {
|
|
|
- mixRatioRightClickTarget = SheetDataHelper.safeRightClickSelection($trigger, e, self.sheetObj.spread);
|
|
|
- return mixRatioRightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.viewport ||
|
|
|
- mixRatioRightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
|
|
|
+ self.rightClickTarget = SheetDataHelper.safeRightClickSelection($trigger, e, self.sheetObj.spread);
|
|
|
+ return self.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.viewport ||
|
|
|
+ self.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
|
|
|
},
|
|
|
items: {
|
|
|
"deleteMixRatio": {
|
|
|
name: "删除",
|
|
|
icon: 'fa-trash-o',
|
|
|
disabled: function () {
|
|
|
- return mixRatioRightClickTarget.row === undefined;
|
|
|
+ return self.rightClickTarget.row === undefined;
|
|
|
},
|
|
|
callback: function (key, opt) {
|
|
|
- let row = mixRatioRightClickTarget.row;
|
|
|
+ let row = self.rightClickTarget.row;
|
|
|
let idColumn = self.sheetObj.getFieldColumn('mix_ratio_id');
|
|
|
let deleteId = activeSheet.getValue(row, idColumn);
|
|
|
self.deleteComposition(deleteId, row, mixRatioSuccess);
|
|
@@ -286,6 +288,7 @@ CompositionSpread.prototype.deleteComposition = function (id, row, callback) {
|
|
|
// 获取当前行的消耗量
|
|
|
let consumptionColumn = this.sheetObj.getFieldColumn('consumption');
|
|
|
let consumption = activeSheet.getValue(row, consumptionColumn);
|
|
|
+ let self = this;
|
|
|
$.ajax({
|
|
|
url: '/glj/delete-ratio',
|
|
|
type: 'post',
|
|
@@ -301,7 +304,7 @@ CompositionSpread.prototype.deleteComposition = function (id, row, callback) {
|
|
|
success: function(response) {
|
|
|
if (response.err === 0) {
|
|
|
// 计算同级的市场单价和基价单价
|
|
|
- let [parentMarketPrice, parentBasePrice] = this.getCompositionSumPrice('delete', row);
|
|
|
+ let [parentMarketPrice, parentBasePrice] = self.getCompositionSumPrice('delete', row);
|
|
|
let info = {
|
|
|
parentMarketPrice: parentMarketPrice,
|
|
|
parentBasePrice: parentBasePrice,
|