|
|
@@ -45,6 +45,18 @@ function findSelfLeafXmj(x, type = '') {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+function findQtyLeafXmj(x, type = '', get_ms_id = null) {
|
|
|
+ const ms_id = get_ms_id ? get_ms_id : (isStageSelf ? parseInt($('#myTab').find('.active').data('msid')) : null);
|
|
|
+ if (type === 'index') {
|
|
|
+ return qtyList.findIndex(function (item) {
|
|
|
+ return item.gcl_id === x.gcl_id && item.xmj_id === x.id && (ms_id ? item.ms_id === ms_id : true) && (x.mx_id === undefined || (x.mx_id !== undefined && x.mx_id === item.mx_id));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return qtyList.find(function (item) {
|
|
|
+ return item.gcl_id === x.gcl_id && item.xmj_id === x.id && (ms_id ? item.ms_id === ms_id : true) && (x.mx_id === undefined || (x.mx_id !== undefined && x.mx_id === item.mx_id));
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
function getMpSpreadByMBData(id) {
|
|
|
const info = materialBillsData.find(function (item) {
|
|
|
return item.id === parseInt(id);
|
|
|
@@ -63,19 +75,23 @@ function getMaterialListByLeafXmj(gcl_id, xmj_id, mx_id = '') {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+function getOneQtyByLeafXmj(xmj) {
|
|
|
+ const qtyInfo = findQtyLeafXmj(xmj);
|
|
|
+ if (qtyInfo && qtyInfo.qty !== null) {
|
|
|
+ return qtyInfo.qty;
|
|
|
+ }
|
|
|
+ const notx2 = findNotChangeLeafXmj(xmj);
|
|
|
+ return calcQty(xmj, notx2 !== undefined ? 2 : 1);
|
|
|
+}
|
|
|
+
|
|
|
function calcOneBQJC(xmj) {
|
|
|
let jiacha = 0;
|
|
|
const notx = findNotJoinLeafXmj(xmj);
|
|
|
if (notx === undefined) {
|
|
|
const list = xmj.mx_id !== undefined ? getMaterialListByLeafXmj(xmj.gcl_id, xmj.id, xmj.mx_id) : getMaterialListByLeafXmj(xmj.gcl_id, xmj.id);
|
|
|
- const notx2 = findNotChangeLeafXmj(xmj);
|
|
|
- // if (notx2 !== undefined) {
|
|
|
- // for (const l of list) {
|
|
|
- // jiacha = ZhCalc.add(jiacha, ZhCalc.mul(ZhCalc.mul(xmj.contract_qty, l.quantity), getMpSpreadByMBData(l.mb_id)));
|
|
|
- // }
|
|
|
- // } else {
|
|
|
for (const l of list) {
|
|
|
- jiacha = ZhCalc.add(jiacha, ZhCalc.mul(ZhCalc.mul(calcQty(xmj, notx2 !== undefined ? 2 : 1), l.quantity), getMpSpreadByMBData(l.mb_id)));
|
|
|
+ const qty = getOneQtyByLeafXmj(xmj);
|
|
|
+ jiacha = ZhCalc.add(jiacha, ZhCalc.mul(ZhCalc.mul(qty, l.quantity), getMpSpreadByMBData(l.mb_id)));
|
|
|
}
|
|
|
// }
|
|
|
}
|
|
|
@@ -113,6 +129,7 @@ function calculateJiaCha(data, index) {
|
|
|
for (const [index, xmj] of gcld.leafXmjs.entries()) {
|
|
|
const jiacha = calcOneBQJC(xmj);
|
|
|
gcld.leafXmjs[index].jiacha = jiacha !== 0 ? jiacha : null;
|
|
|
+ gcld.leafXmjs[index].qty = getOneQtyByLeafXmj(xmj);
|
|
|
total_jiacha += jiacha;
|
|
|
}
|
|
|
gcld.total_jiacha = ZhCalc.round(total_jiacha, materialDecimal.tp)
|
|
|
@@ -122,6 +139,7 @@ function calculateJiaCha(data, index) {
|
|
|
for (const [index, xmj] of gcld.leafXmjs.entries()) {
|
|
|
const jiacha = calcOneBQJC(xmj);
|
|
|
gcld.leafXmjs[index].jiacha = jiacha !== 0 ? jiacha : null;
|
|
|
+ gcld.leafXmjs[index].qty = getOneQtyByLeafXmj(xmj);
|
|
|
total_jiacha += jiacha;
|
|
|
}
|
|
|
gcld.total_jiacha = ZhCalc.round(total_jiacha, materialDecimal.tp)
|
|
|
@@ -247,6 +265,7 @@ $(document).ready(() => {
|
|
|
for (const [index, xmj] of gcl.leafXmjs.entries()) {
|
|
|
const jiacha = calcOneBQJC(xmj);
|
|
|
gcl.leafXmjs[index].jiacha = jiacha !== 0 ? ZhCalc.round(jiacha, materialDecimal.tp) : null;
|
|
|
+ gcl.leafXmjs[index].qty = getOneQtyByLeafXmj(xmj);
|
|
|
}
|
|
|
const leafXmjs = gcl.leafXmjs.filter(item => {
|
|
|
return item.qc_qty || item.contract_qty || item.qc_minus_qty;
|
|
|
@@ -268,27 +287,28 @@ $(document).ready(() => {
|
|
|
// 项目明细table
|
|
|
const leafXmjSpread = SpreadJsObj.createNewSpread($('#leaf-xmj-spread')[0]);
|
|
|
const leafXmjCols = [
|
|
|
- {title: '项目节|编号', colSpan: '2|1', rowSpan: '1|1', field: 'code', hAlign: 0, width: 80, formatter: '@'},
|
|
|
- {title: '|项目节名称', colSpan: '|1', rowSpan: '|1', field: 'jldy', hAlign: 0, width: 100, formatter: '@'},
|
|
|
- {title: '计量单元|计量单元', colSpan: '2|1', rowSpan: '1|1', field: 'bwmx', hAlign: 0, width: 100, formatter: '@'},
|
|
|
- {title: '|复核数量', colSpan: '|1', rowSpan: '|1', field: 'quantity', hAlign: 0, width: 80, type: 'Number'},
|
|
|
- {title: '部位信息|单位工程', colSpan: '3|1', rowSpan: '1|1', field: 'dwgc', hAlign: 0, width: 100, formatter: '@'},
|
|
|
- {title: '|分部工程', colSpan: '|1', rowSpan: '|1', field: 'fbgc', hAlign: 0, width: 100, formatter: '@'},
|
|
|
- {title: '|分项工程', colSpan: '|1', rowSpan: '|1', field: 'fxgc', hAlign: 0, width: 180, formatter: '@'},
|
|
|
+ {title: '项目节|编号', colSpan: '2|1', rowSpan: '1|1', field: 'code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
|
|
|
+ {title: '|项目节名称', colSpan: '|1', rowSpan: '|1', field: 'jldy', hAlign: 0, width: 100, formatter: '@', readOnly: true},
|
|
|
+ {title: '计量单元|计量单元', colSpan: '2|1', rowSpan: '1|1', field: 'bwmx', hAlign: 0, width: 100, formatter: '@', readOnly: true},
|
|
|
+ {title: '|复核数量', colSpan: '|1', rowSpan: '|1', field: 'quantity', hAlign: 0, width: 80, type: 'Number', readOnly: true},
|
|
|
+ {title: '部位信息|单位工程', colSpan: '3|1', rowSpan: '1|1', field: 'dwgc', hAlign: 0, width: 100, formatter: '@', readOnly: true},
|
|
|
+ {title: '|分部工程', colSpan: '|1', rowSpan: '|1', field: 'fbgc', hAlign: 0, width: 100, formatter: '@', readOnly: true},
|
|
|
+ {title: '|分项工程', colSpan: '|1', rowSpan: '|1', field: 'fxgc', hAlign: 0, width: 180, formatter: '@', readOnly: true},
|
|
|
];
|
|
|
if (qtySource === qtySourceValueConst.gather_qty) {
|
|
|
- leafXmjCols.push({title: '本期计量数量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'});
|
|
|
- leafXmjCols.push({title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number'});
|
|
|
- leafXmjCols.push({title: '|小计', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 60, type: 'Number'});
|
|
|
+ leafXmjCols.push({title: '本期计量数量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true});
|
|
|
+ leafXmjCols.push({title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true});
|
|
|
+ leafXmjCols.push({title: '|小计', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true});
|
|
|
} else if (qtySource === qtySourceValueConst.contract_qty) {
|
|
|
- leafXmjCols.push({title: '本期计量数量|合同', colSpan: '1|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 100, type: 'Number'});
|
|
|
+ leafXmjCols.push({title: '本期计量数量|合同', colSpan: '1|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 100, type: 'Number', readOnly: true});
|
|
|
} else if (qtySource === qtySourceValueConst.gather_minus_qty) {
|
|
|
- leafXmjCols.push({title: '本期计量数量|合同', colSpan: '4|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'});
|
|
|
- leafXmjCols.push({title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number'});
|
|
|
- leafXmjCols.push({title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 60, type: 'Number'});
|
|
|
- leafXmjCols.push({title: '|小计', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.gather_qty'});
|
|
|
+ leafXmjCols.push({title: '本期计量数量|合同', colSpan: '4|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true});
|
|
|
+ leafXmjCols.push({title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true});
|
|
|
+ leafXmjCols.push({title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true});
|
|
|
+ leafXmjCols.push({title: '|小计', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue: 'getValue.gather_qty'});
|
|
|
}
|
|
|
- leafXmjCols.push({title: '本期价差', colSpan: '1', rowSpan: '2', field: 'jiacha', hAlign: 2, width: 80, type: 'Number'});
|
|
|
+ leafXmjCols.push({title: '本期调差数量', colSpan: '1', rowSpan: '2', field: 'qty', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.qty', readOnly: 'readOnly.qty'});
|
|
|
+ leafXmjCols.push({title: '本期价差', colSpan: '1', rowSpan: '2', field: 'jiacha', hAlign: 2, width: 80, type: 'Number', readOnly: true });
|
|
|
const leafXmjSpreadSetting = {
|
|
|
// cols: [
|
|
|
// {title: '项目节|编号', colSpan: '2|1', rowSpan: '1|1', field: 'code', hAlign: 0, width: 80, formatter: '@'},
|
|
|
@@ -310,7 +330,7 @@ $(document).ready(() => {
|
|
|
defaultRowHeight: 21,
|
|
|
headerFont: '12px 微软雅黑',
|
|
|
font: '12px 微软雅黑',
|
|
|
- readOnly: true,
|
|
|
+ // readOnly: true,
|
|
|
rowHeader:[
|
|
|
{
|
|
|
rowHeaderType: 'circle',
|
|
|
@@ -328,13 +348,29 @@ $(document).ready(() => {
|
|
|
],
|
|
|
};
|
|
|
leafXmjSpreadSetting.cols = leafXmjCols;
|
|
|
+ const qtyColIndex = _.findIndex(leafXmjCols, {field: 'qty'});
|
|
|
const leafXmjCol = {
|
|
|
+ readOnly: {
|
|
|
+ qty: function (data) {
|
|
|
+ return !(!readOnly && editQtyPermission);
|
|
|
+ }
|
|
|
+ },
|
|
|
getValue: {
|
|
|
gather_qty: function (data) {
|
|
|
if (qtySource === qtySourceValueConst.gather_minus_qty) {
|
|
|
return ZhCalc.add(data.gather_qty, data.qc_minus_qty);
|
|
|
}
|
|
|
},
|
|
|
+ qty: function (data) {
|
|
|
+ if (data.qty !== null) return data.qty;
|
|
|
+ if (qtySource === qtySourceValueConst.gather_qty) {
|
|
|
+ return data.gather_qty;
|
|
|
+ } else if (qtySource === qtySourceValueConst.contract_qty) {
|
|
|
+ return data.contract_qty;
|
|
|
+ } else if (qtySource === qtySourceValueConst.gather_minus_qty) {
|
|
|
+ return ZhCalc.add(data.gather_qty, data.qc_minus_qty);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
const needUpdateArray = ['quantity', 'msg_tp', 'msg_times', 'msg_spread', 'm_spread', 'm_tp', 'm_tax_tp', 'is_summary', 'remark'];
|
|
|
@@ -370,6 +406,7 @@ $(document).ready(() => {
|
|
|
notJoinList = result.materialNotJoinListData;
|
|
|
notChangeList = result.materialNotChangeListData;
|
|
|
selfList = result.materialSelfListData;
|
|
|
+ qtyList = result.materialQtyListData;
|
|
|
materialChecklistData = result.materialChecklistData;
|
|
|
if (isStageSelf) {
|
|
|
updateBillsData(ms_id);
|
|
|
@@ -858,6 +895,10 @@ $(document).ready(() => {
|
|
|
const notx2 = findNotChangeLeafXmj(x);
|
|
|
const color2 = notx2 === undefined || qtySource === qtySourceValueConst.contract_qty ? color : '#FFE699';
|
|
|
leafXmjSheet.getRange(iRow, -1, 1, -1).backColor(color2);
|
|
|
+ const qtyInfo = findQtyLeafXmj(x);
|
|
|
+ if (x.qty !== undefined && x.qty !== null && qtyInfo) {
|
|
|
+ leafXmjSheet.getCell(iRow, qtyColIndex).backColor('#f8d7da');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -906,6 +947,7 @@ $(document).ready(() => {
|
|
|
for (const xmj of gcl) {
|
|
|
const notx = findNotJoinLeafXmj(xmj);
|
|
|
const notx2 = findNotChangeLeafXmj(xmj);
|
|
|
+ const qtyInfo = findQtyLeafXmj(xmj);
|
|
|
const data = {
|
|
|
xmj_id: xmj.id,
|
|
|
gcl_id: xmj.gcl_id,
|
|
|
@@ -914,6 +956,7 @@ $(document).ready(() => {
|
|
|
qc_qty: xmj.qc_qty,
|
|
|
qc_minus_qty: xmj.qc_minus_qty,
|
|
|
gather_qty: xmj.gather_qty,
|
|
|
+ qty: qtyInfo ? qtyInfo.qty : null,
|
|
|
is_join: notx !== undefined ? 0 : notx2 !== undefined ? 2 : 1,
|
|
|
};
|
|
|
if (ms_id) data.ms_id = ms_id;
|
|
|
@@ -933,6 +976,7 @@ $(document).ready(() => {
|
|
|
for (const xmj of leafXmjs) {
|
|
|
const notx = findNotJoinLeafXmj(xmj);
|
|
|
const notx2 = findNotChangeLeafXmj(xmj);
|
|
|
+ const qtyInfo = findQtyLeafXmj(xmj, '', ms.id);
|
|
|
const data = {
|
|
|
xmj_id: xmj.id,
|
|
|
gcl_id: xmj.gcl_id,
|
|
|
@@ -941,6 +985,7 @@ $(document).ready(() => {
|
|
|
qc_qty: xmj.qc_qty,
|
|
|
qc_minus_qty: xmj.qc_minus_qty,
|
|
|
gather_qty: xmj.gather_qty,
|
|
|
+ qty: qtyInfo ? qtyInfo.qty : null,
|
|
|
is_join: notx !== undefined ? 0 : notx2 !== undefined ? 2 : 1,
|
|
|
ms_id: ms.id,
|
|
|
};
|
|
|
@@ -979,6 +1024,7 @@ $(document).ready(() => {
|
|
|
const xmj = gcl[leafXmjIndex];
|
|
|
const notx = findNotJoinLeafXmj(xmj);
|
|
|
const notx2 = findNotChangeLeafXmj(xmj);
|
|
|
+ const qtyInfo = findQtyLeafXmj(xmj);
|
|
|
const data = {
|
|
|
xmj_id: xmj.id,
|
|
|
gcl_id: xmj.gcl_id,
|
|
|
@@ -988,6 +1034,7 @@ $(document).ready(() => {
|
|
|
qc_qty: xmj.qc_qty,
|
|
|
qc_minus_qty: xmj.qc_minus_qty,
|
|
|
gather_qty: xmj.gather_qty,
|
|
|
+ qty: qtyInfo ? qtyInfo.qty : null,
|
|
|
is_join: notx !== undefined ? 0 : notx2 !== undefined ? 2 : 1,
|
|
|
};
|
|
|
console.log(data);
|
|
|
@@ -1037,6 +1084,7 @@ $(document).ready(() => {
|
|
|
calculateJiaCha(gclGatherData, iGclRow);
|
|
|
SpreadJsObj.reLoadRowData(sheet, nRow);
|
|
|
sheet.getRange(nRow, -1, 1, -1).backColor(color);
|
|
|
+ leafXmjSpreadObj.refreshQtyColor(select, nRow);
|
|
|
loadMaterialData(iGclRow);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
});
|
|
|
@@ -1058,9 +1106,12 @@ $(document).ready(() => {
|
|
|
notChangeList.push(result);
|
|
|
}
|
|
|
gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(select);
|
|
|
+ gclGatherData[iGclRow].leafXmjs[iRow].qty = getOneQtyByLeafXmj(select);
|
|
|
calculateJiaCha(gclGatherData, iGclRow);
|
|
|
+ console.log(gclGatherData[iGclRow].leafXmjs[iRow]);
|
|
|
SpreadJsObj.reLoadRowData(sheet, nRow);
|
|
|
sheet.getRange(nRow, -1, 1, -1).backColor(color);
|
|
|
+ leafXmjSpreadObj.refreshQtyColor(select, nRow);
|
|
|
loadMaterialData(iGclRow);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
});
|
|
|
@@ -1129,21 +1180,225 @@ $(document).ready(() => {
|
|
|
materialListData = result.materialListData;
|
|
|
}
|
|
|
gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(select);
|
|
|
+ gclGatherData[iGclRow].leafXmjs[iRow].qty = getOneQtyByLeafXmj(select);
|
|
|
calculateJiaCha(gclGatherData, iGclRow);
|
|
|
SpreadJsObj.reLoadRowData(sheet, nRow);
|
|
|
sheet.getRange(nRow, -1, 1, -1).backColor(color);
|
|
|
+ leafXmjSpreadObj.refreshQtyColor(select, nRow);
|
|
|
loadXmjMaterialData(iGclRow, nRow);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
});
|
|
|
},
|
|
|
+ refreshQtyColor(xmj, row) {
|
|
|
+ const leafXmjSheet = leafXmjSpread.getActiveSheet();
|
|
|
+ const qtyInfo = findQtyLeafXmj(xmj);
|
|
|
+ if (xmj.qty !== undefined && xmj.qty !== null && qtyInfo) {
|
|
|
+ leafXmjSheet.getCell(row, qtyColIndex).backColor('#f8d7da');
|
|
|
+ }
|
|
|
+ },
|
|
|
}
|
|
|
if (!readOnly) {
|
|
|
+ // 编辑本期调差数量
|
|
|
+ if (editQtyPermission) {
|
|
|
+ leafXmjSpreadObj.editEnded = function (e, info) {
|
|
|
+ if (info.sheet.zh_setting) {
|
|
|
+ const [iGclRow, iRow, nRow, sheet, select, color] = leafXmjSpreadObj.getSelect();
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
+ // 未改变值则不提交
|
|
|
+ const validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
|
|
|
+ const orgValue = select[col.field];
|
|
|
+ if (orgValue == validText || ((orgValue === '' || orgValue === null) && (validText === '' || validText === null))) {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (isNaN(validText)) {
|
|
|
+ toastr.error('不能输入其它非数字类型字符');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const qty = parseFloat(validText) !== 0 ? ZhCalc.round(parseFloat(validText), materialDecimal.qty) : 0;
|
|
|
+ console.log(qty);
|
|
|
+ let qtyInfo = findQtyLeafXmj(select);
|
|
|
+ if (qtyInfo) {
|
|
|
+ qtyInfo.qty = qty;
|
|
|
+ } else {
|
|
|
+ if (qty === null) {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ qtyInfo = {
|
|
|
+ gcl_id: select.gcl_id,
|
|
|
+ xmj_id: select.id,
|
|
|
+ mx_id: select.mx_id || '',
|
|
|
+ qty: qty,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ postData(window.location.pathname + '/save', { type:'update-qty', updateData: qtyInfo, ms_id: $('#myTab').find('.active').data('msid') || null }, function (result) {
|
|
|
+ if (qtyInfo && qtyInfo.id) {
|
|
|
+ const index = findQtyLeafXmj(select, 'index');
|
|
|
+ if (result.info === null) {
|
|
|
+ qtyList.splice(index, 1);
|
|
|
+ } else {
|
|
|
+ qtyList.splice(index, 1, result.info);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ qtyList.push(result.info);
|
|
|
+ }
|
|
|
+ materialListData = result.materialListData;
|
|
|
+ gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(select);
|
|
|
+ gclGatherData[iGclRow].leafXmjs[iRow].qty = getOneQtyByLeafXmj(select);
|
|
|
+ calculateJiaCha(gclGatherData, iGclRow);
|
|
|
+ SpreadJsObj.reLoadRowData(sheet, nRow);
|
|
|
+ sheet.getRange(nRow, -1, 1, -1).backColor(color);
|
|
|
+ leafXmjSpreadObj.refreshQtyColor(select, nRow);
|
|
|
+ loadXmjMaterialData(iGclRow, nRow);
|
|
|
+ SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ leafXmjSpreadObj.clipboardPasted = function (e, info) {
|
|
|
+ const range = info.cellRange;
|
|
|
+ const sortData = info.sheet.zh_data || [];
|
|
|
+ const data = [];
|
|
|
+ for (let iRow = 0; iRow < range.rowCount; iRow++) {
|
|
|
+ let bPaste = true;
|
|
|
+ const curRow = range.row + iRow;
|
|
|
+ const select = sortData[curRow];
|
|
|
+ if (!select) continue;
|
|
|
+ let qtyInfo = findQtyLeafXmj(select);
|
|
|
+ const hintRow = range.rowCount > 1 ? curRow : '';
|
|
|
+ let sameCol = 0;
|
|
|
+ for (let iCol = 0; iCol < range.colCount; iCol++) {
|
|
|
+ const curCol = range.col + iCol;
|
|
|
+ const colSetting = info.sheet.zh_setting.cols[curCol];
|
|
|
+ if (!colSetting) continue;
|
|
|
+ let validText = info.sheet.getText(curRow, curCol).replace('\n', '');
|
|
|
+ validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : null);
|
|
|
+ const orgValue = sortData[curRow][colSetting.field];
|
|
|
+ console.log(validText, orgValue);
|
|
|
+ if (orgValue == validText || ((orgValue === '' || orgValue === null) && (validText === '' || validText === null))) {
|
|
|
+ sameCol++;
|
|
|
+ if (range.colCount === sameCol) {
|
|
|
+ bPaste = false;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (isNaN(validText)) {
|
|
|
+ toastr.error('不能粘贴其它非数字类型字符');
|
|
|
+ bPaste = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ const qty = parseFloat(validText) !== 0 ? ZhCalc.round(parseFloat(validText), materialDecimal.qty) : 0;
|
|
|
+ if (qtyInfo) {
|
|
|
+ qtyInfo.qty = qty;
|
|
|
+ } else {
|
|
|
+ if (qty === null) {
|
|
|
+ bPaste = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ qtyInfo = {
|
|
|
+ gcl_id: select.gcl_id,
|
|
|
+ xmj_id: select.id,
|
|
|
+ mx_id: select.mx_id || '',
|
|
|
+ qty: qty,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sortData[curRow][colSetting.field] = qty;
|
|
|
+ }
|
|
|
+ if (bPaste) {
|
|
|
+ data.push(qtyInfo);
|
|
|
+ } else {
|
|
|
+ console.log(curRow, info.cellRange);
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, curRow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (data.length === 0) {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
+ checkNotJoinMaterialData();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log(data);
|
|
|
+ // 更新至服务器
|
|
|
+ postData(window.location.pathname + '/save', { type:'pastes-qty', updateData: data, ms_id: $('#myTab').find('.active').data('msid') || null }, function (result) {
|
|
|
+ const ledgerSheet = ledgerSpread.getActiveSheet();
|
|
|
+ const ledgerSelect = SpreadJsObj.getSelectObject(ledgerSheet);
|
|
|
+ const index = gclGatherData.indexOf(ledgerSelect);
|
|
|
+ materialListData = result.materialListData;
|
|
|
+ qtyList = result.qtyList;
|
|
|
+ calculateJiaCha(gclGatherData);
|
|
|
+ loadLeafXmjData(index);
|
|
|
+ loadMaterialData(index);
|
|
|
+ checkNotJoinMaterialData();
|
|
|
+ SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
|
|
|
+ // leafXmjSpread.getActiveSheet().setSelection(info.cellRange.row, info.cellRange.col, info.cellRange.rowCount, info.cellRange.colCount);
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ leafXmjSpreadObj.deletePress = function (sheet) {
|
|
|
+ if (!sheet.zh_setting) return;
|
|
|
+ // 暂时仅支持移除数量
|
|
|
+ const sel = sheet.getSelections()[0], datas = [];
|
|
|
+ for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
|
|
|
+ let bDel = false;
|
|
|
+ const select = sheet.zh_data[iRow];
|
|
|
+ if (!select) continue;
|
|
|
+ let qtyInfo = findQtyLeafXmj(select);
|
|
|
+ for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
|
|
|
+ const col = sheet.zh_setting.cols[iCol];
|
|
|
+ const orgValue = select[col.field];
|
|
|
+ if (orgValue === '' || orgValue === null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (qtyInfo) {
|
|
|
+ qtyInfo.qty = null;
|
|
|
+ bDel = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (bDel) datas.push(qtyInfo);
|
|
|
+ }
|
|
|
+ if (datas.length > 0) {
|
|
|
+ // 更新至服务器
|
|
|
+ postData(window.location.pathname + '/save', { type:'pastes-qty', updateData: datas, ms_id: $('#myTab').find('.active').data('msid') || null }, function (result) {
|
|
|
+ const ledgerSheet = ledgerSpread.getActiveSheet();
|
|
|
+ const ledgerSelect = SpreadJsObj.getSelectObject(ledgerSheet);
|
|
|
+ const index = gclGatherData.indexOf(ledgerSelect);
|
|
|
+ materialListData = result.materialListData;
|
|
|
+ qtyList = result.qtyList;
|
|
|
+ calculateJiaCha(gclGatherData);
|
|
|
+ loadLeafXmjData(index);
|
|
|
+ loadMaterialData(index);
|
|
|
+ checkNotJoinMaterialData();
|
|
|
+ SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ leafXmjSpreadObj.valueChanged = function (e, info) {
|
|
|
+ // 防止ctrl+z撤销数据
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ }
|
|
|
+ leafXmjSpread.bind(spreadNS.Events.EditEnded, leafXmjSpreadObj.editEnded);
|
|
|
+ leafXmjSpread.bind(spreadNS.Events.ClipboardPasted, leafXmjSpreadObj.clipboardPasted);
|
|
|
+ leafXmjSpread.bind(spreadNS.Events.ValueChanged, leafXmjSpreadObj.valueChanged);
|
|
|
+ SpreadJsObj.addDeleteBind(leafXmjSpread, leafXmjSpreadObj.deletePress);
|
|
|
+ }
|
|
|
// leafXmj右键功能
|
|
|
if (!editForAudit) {
|
|
|
$.contextMenu({
|
|
|
selector: '#leaf-xmj-spread',
|
|
|
build: function ($trigger, e) {
|
|
|
const target = SpreadJsObj.safeRightClickSelection($trigger, e, leafXmjSpread);
|
|
|
+ const sheet = ledgerSpread.getActiveSheet();
|
|
|
+ const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
+ const index = gclGatherData.indexOf(select);
|
|
|
+ const xmj = target.row !== undefined ? gclGatherData[index].leafXmjs[target.row] : null;
|
|
|
+ if (xmj) leafXmjSpreadObj.refreshQtyColor(xmj, target.row);
|
|
|
return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
|
|
|
},
|
|
|
items: {
|
|
|
@@ -1843,6 +2098,7 @@ $(document).ready(() => {
|
|
|
calculateJiaCha(gclGatherData, iGclRow);
|
|
|
SpreadJsObj.reLoadRowData(lsheet, nRow);
|
|
|
lsheet.getRange(nRow, -1, 1, -1).backColor(color);
|
|
|
+ leafXmjSpreadObj.refreshQtyColor(lselect, nRow);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
});
|
|
|
},
|
|
|
@@ -1927,6 +2183,7 @@ $(document).ready(() => {
|
|
|
SpreadJsObj.reLoadRowData(sheet, nRow);
|
|
|
console.log(lselect, color);
|
|
|
sheet.getRange(nRow, -1, 1, -1).backColor(color);
|
|
|
+ leafXmjSpreadObj.refreshQtyColor(lselect, nRow);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
}, function () {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|