|
@@ -23,10 +23,31 @@ function getMpSpreadByMBData(id) {
|
|
|
const info = materialBillsData.find(function (item) {
|
|
|
return item.id === parseInt(id);
|
|
|
});
|
|
|
- console.log(info);
|
|
|
return info.m_spread;
|
|
|
}
|
|
|
|
|
|
+function getMaterialListByLeafXmj(gcl_id, xmj_id, mx_id = null) {
|
|
|
+ const list = [];
|
|
|
+ for (const ml of materialListData) {
|
|
|
+ if (gcl_id === ml.gcl_id && xmj_id === ml.xmj_id && (mx_id === null || mx_id === ml.mx_id)) {
|
|
|
+ list.push(ml);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+}
|
|
|
+
|
|
|
+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);
|
|
|
+ for (const l of list) {
|
|
|
+ jiacha = ZhCalc.add(jiacha, ZhCalc.mul(ZhCalc.mul(xmj.gather_qty, l.quantity), getMpSpreadByMBData(l.mb_id)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return jiacha;
|
|
|
+}
|
|
|
+
|
|
|
$(document).ready(() => {
|
|
|
autoFlashHeight();
|
|
|
// 清单table
|
|
@@ -58,6 +79,11 @@ $(document).ready(() => {
|
|
|
function loadLeafXmjData(iGclRow) {
|
|
|
const gcl = gclGatherData[iGclRow];
|
|
|
if (gcl) {
|
|
|
+ for (const [index, xmj] of gcl.leafXmjs.entries()) {
|
|
|
+ const jiacha = calcOneBQJC(xmj);
|
|
|
+ gcl.leafXmjs[index].jiacha = jiacha !== 0 ? ZhCalc.round(jiacha, 2) : null;
|
|
|
+ }
|
|
|
+ // console.log(gcl.leafXmjs);
|
|
|
SpreadJsObj.loadSheetData(leafXmjSpread.getActiveSheet(), SpreadJsObj.DataType.Data, gcl.leafXmjs);
|
|
|
// 对清单调差工料table的单位数量进行改变
|
|
|
materialSpreadSetting.cols[materialSpreadSetting.cols.length - 1].title = '|' + gcl.unit + '数量';
|
|
@@ -82,7 +108,7 @@ $(document).ready(() => {
|
|
|
{title: '本期计量数量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
|
|
|
{title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 80, type: 'Number'},
|
|
|
{title: '|小计', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 60, type: 'Number'},
|
|
|
- {title: '本期价差', colSpan: '1', rowSpan: '2', field: 'jiacha', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.jiacha'},
|
|
|
+ {title: '本期价差', colSpan: '1', rowSpan: '2', field: 'jiacha', hAlign: 2, width: 80, type: 'Number'},
|
|
|
],
|
|
|
emptyRows: 0,
|
|
|
headRows: 2,
|
|
@@ -92,23 +118,23 @@ $(document).ready(() => {
|
|
|
readOnly: true,
|
|
|
font: '10pt 微软雅黑',
|
|
|
};
|
|
|
- const leafXmjCol = {
|
|
|
- getValue: {
|
|
|
- jiacha: function (data) {
|
|
|
- let sum = 0;
|
|
|
- const sheet = leafXmjSpread.getActiveSheet();
|
|
|
- const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
- const notx = findNotJoinLeafXmj(select);
|
|
|
- if (notx === undefined) {
|
|
|
- for(const ml of materialList) {
|
|
|
- sum = ZhCalc.add(sum, ZhCalc.mul(ZhCalc.mul(data.gather_qty, ml.quantity), getMpSpreadByMBData(ml.mb_id)));
|
|
|
- }
|
|
|
- }
|
|
|
- return sum;
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- SpreadJsObj.initSpreadSettingEvents(leafXmjSpreadSetting, leafXmjCol);
|
|
|
+ // const leafXmjCol = {
|
|
|
+ // getValue: {
|
|
|
+ // jiacha: function (data) {
|
|
|
+ // let sum = 0;
|
|
|
+ // const sheet = leafXmjSpread.getActiveSheet();
|
|
|
+ // const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
+ // const notx = findNotJoinLeafXmj(select);
|
|
|
+ // if (notx === undefined) {
|
|
|
+ // for(const ml of materialList) {
|
|
|
+ // sum = ZhCalc.round(ZhCalc.add(sum, ZhCalc.mul(ZhCalc.mul(data.gather_qty, ml.quantity), getMpSpreadByMBData(ml.mb_id))), 2);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // return sum !== 0 ? sum : null;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // };
|
|
|
+ // SpreadJsObj.initSpreadSettingEvents(leafXmjSpreadSetting, leafXmjCol);
|
|
|
SpreadJsObj.initSheet(leafXmjSpread.getActiveSheet(), leafXmjSpreadSetting);
|
|
|
// 加载清单数据
|
|
|
SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Data, gclGatherData);
|
|
@@ -133,7 +159,8 @@ $(document).ready(() => {
|
|
|
const materialBase = {
|
|
|
isEdit: function (data) {
|
|
|
// 是否本期添加的工料
|
|
|
- return data.mid === materialID;
|
|
|
+ console.log(data);
|
|
|
+ return data.order === stage_order;
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -230,6 +257,7 @@ $(document).ready(() => {
|
|
|
gcl_id: xmj.gcl_id,
|
|
|
mx_id: xmj.mx_id !== undefined ? xmj.mx_id : '',
|
|
|
mb_id: mb_id,
|
|
|
+ gather_qty: xmj.gather_qty,
|
|
|
};
|
|
|
// 上传到数据库
|
|
|
postData(window.location.pathname + '/save', {type: 'add', postData: data}, function (result) {
|
|
@@ -321,7 +349,7 @@ $(document).ready(() => {
|
|
|
del: function () {
|
|
|
const sheet = materialSpread.getActiveSheet();
|
|
|
const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
- postData(window.location.pathname + '/save', {type: 'del', id: select.id}, function (result) {
|
|
|
+ postData(window.location.pathname + '/save', {type: 'del', id: select.id, mb_id: select.mb_id}, function (result) {
|
|
|
const index = materialList.indexOf(select);
|
|
|
materialList.splice(index, 1);
|
|
|
sheet.deleteRows(index, 1);
|
|
@@ -330,6 +358,9 @@ $(document).ready(() => {
|
|
|
sheet.setSelection(index > 0 ? index - 1 : 0, sel.length > 0 ? sel[0].col : 0, 1, 1);
|
|
|
const materialListIndex = materialListData.indexOf(select);
|
|
|
materialListData.splice(materialListIndex, 1);
|
|
|
+ const [iGclRow, iRow, lsheet, lselect] = leafXmjSpreadObj.getSelect();
|
|
|
+ gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(lselect);
|
|
|
+ SpreadJsObj.reLoadRowData(lsheet, iRow);
|
|
|
});
|
|
|
},
|
|
|
editEnded: function (e, info) {
|
|
@@ -343,8 +374,21 @@ $(document).ready(() => {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
return;
|
|
|
}
|
|
|
+ if (col.field === 'quantity') {
|
|
|
+ if (isNaN(validText)) {
|
|
|
+ toastr.error('不能输入其它非数字类型字符');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const num = parseFloat(validText);
|
|
|
+ if (num < 0 || !/^\d+(\.\d{1,6})?$/.test(num)) {
|
|
|
+ toastr.error('请输入大于0并且小于6位小数的浮点数');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
// 更新至服务器
|
|
|
- postData(window.location.pathname + '/save', { type:'update', updateData: { id:select.id, quantity: validText } }, function (result) {
|
|
|
+ postData(window.location.pathname + '/save', { type:'update', updateData: { id:select.id, quantity: validText, mb_id: select.mb_id } }, function (result) {
|
|
|
const materialListIndex = materialListData.indexOf(select);
|
|
|
const index = materialList.indexOf(select);
|
|
|
select[col.field] = validText;
|
|
@@ -352,6 +396,7 @@ $(document).ready(() => {
|
|
|
materialList.indexOf(index, 1, select);
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
const [iGclRow, iRow, sheet, lselect] = leafXmjSpreadObj.getSelect();
|
|
|
+ gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(lselect);
|
|
|
SpreadJsObj.reLoadRowData(sheet, iRow);
|
|
|
}, function () {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
@@ -383,17 +428,17 @@ $(document).ready(() => {
|
|
|
}
|
|
|
// 判断需要应用调差工料的清单明细
|
|
|
const needAddList = [];
|
|
|
+ const gather_qty = [];
|
|
|
for (const xmj of ledgerSelect.leafXmjs) {
|
|
|
if (xmj.mx_id !== undefined) {
|
|
|
- const notx = notJoinList.find(function (item) {
|
|
|
- return item.gcl_id === xmj.gcl_id && item.xmj_id === xmj.id && (xmj.mx_id === undefined || (xmj.mx_id !== undefined && xmj.mx_id === item.mx_id));
|
|
|
- });
|
|
|
+ const notx = findNotJoinLeafXmj(xmj);
|
|
|
if (notx === undefined) {
|
|
|
const ml = materialListData.find(function (item) {
|
|
|
return xmj.mx_id === item.mx_id && select.mb_id === item.mb_id;
|
|
|
});
|
|
|
if (ml === undefined) {
|
|
|
needAddList.push(xmj.mx_id);
|
|
|
+ gather_qty.push(xmj.gather_qty);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -403,9 +448,15 @@ $(document).ready(() => {
|
|
|
return false;
|
|
|
}
|
|
|
// 更新至服务器
|
|
|
- postData(window.location.pathname + '/save', { type:'useOther', postData: { mx_id: needAddList, select: select } }, function (result) {
|
|
|
+ postData(window.location.pathname + '/save', { type:'useOther', postData: { mx_id: needAddList, select: select, gather_qty: gather_qty } }, function (result) {
|
|
|
materialListData = result;
|
|
|
toastr.success('成功添加了' + needAddList.length + '条调差工料到其他清单明细中');
|
|
|
+ const index = gclGatherData.indexOf(ledgerSelect);
|
|
|
+ loadLeafXmjData(index);
|
|
|
+ const xmjSheet = leafXmjSpread.getActiveSheet();
|
|
|
+ const xmjSelect = SpreadJsObj.getSelectObject(xmjSheet);
|
|
|
+ const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
|
|
|
+ loadMaterialData(index, xmjIndex);
|
|
|
});
|
|
|
});
|
|
|
$.contextMenu({
|
|
@@ -426,9 +477,7 @@ $(document).ready(() => {
|
|
|
disabled: function (key, opt) {
|
|
|
const sheet = leafXmjSpread.getActiveSheet();
|
|
|
const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
- const notx = notJoinList.find(function (item) {
|
|
|
- return item.gcl_id === select.gcl_id && item.xmj_id === select.id && (select.mx_id === undefined || (select.mx_id !== undefined && select.mx_id === item.mx_id));
|
|
|
- });
|
|
|
+ const notx = findNotJoinLeafXmj(select);
|
|
|
if (!readOnly && notx === undefined) {
|
|
|
return false;
|
|
|
} else {
|
|
@@ -511,6 +560,7 @@ $(document).ready(() => {
|
|
|
SpreadJsObj.resetTopAndSelect(ledgerSpread.getActiveSheet());
|
|
|
SpreadJsObj.resetTopAndSelect(leafXmjSpread.getActiveSheet());
|
|
|
SpreadJsObj.resetTopAndSelect(materialSpread.getActiveSheet());
|
|
|
+ checkNotJoinMaterialData();
|
|
|
|
|
|
});
|
|
|
|