|
@@ -525,7 +525,7 @@ $(document).ready(() => {
|
|
|
// 是否本期添加的工料
|
|
|
// return data.order === stage_order && !openMaterialChecklist;
|
|
|
let flag = true;
|
|
|
- if (type === 'del') {
|
|
|
+ if (type === 'del' || !editListPermission) {
|
|
|
flag = data.order === stage_order;
|
|
|
}
|
|
|
return flag && !openMaterialChecklist;
|
|
@@ -613,7 +613,7 @@ $(document).ready(() => {
|
|
|
// const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
// const notx = findNotJoinLeafXmj(select);
|
|
|
// return !(!readOnly && notx === undefined && materialBase.isEdit(data));
|
|
|
- return !(!readOnly && materialSelfBase.isEdit(data));
|
|
|
+ return openMaterialSelf && !(!readOnly && materialSelfBase.isEdit(data));
|
|
|
},
|
|
|
},
|
|
|
};
|
|
@@ -928,6 +928,9 @@ $(document).ready(() => {
|
|
|
leafXmjSpreadObj.checkSelfMaterial('self');
|
|
|
},
|
|
|
visible: function (key, opt) {
|
|
|
+ if (!openMaterialSelf) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
const sheet = leafXmjSpread.getActiveSheet();
|
|
|
const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
const sel = sheet.getSelections()[0];
|
|
@@ -950,6 +953,9 @@ $(document).ready(() => {
|
|
|
// leafXmjSpreadObj.checkSelfMaterial('noself');
|
|
|
},
|
|
|
visible: function (key, opt) {
|
|
|
+ if (!openMaterialSelf) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
const sheet = leafXmjSpread.getActiveSheet();
|
|
|
const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
const sel = sheet.getSelections()[0];
|
|
@@ -1450,148 +1456,66 @@ $(document).ready(() => {
|
|
|
materialSpread.bind(spreadNS.Events.ClipboardPasted, materialSpreadObj.clipboardPasted);
|
|
|
SpreadJsObj.addDeleteBind(materialSpread, materialSpreadObj.deletePress);
|
|
|
// material-spread右键功能
|
|
|
- const materialSelfSpreadObj = {
|
|
|
- del: function () {
|
|
|
- const sheet = materialSelfSpread.getActiveSheet();
|
|
|
- const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
- console.log(select);
|
|
|
- postData(window.location.pathname + '/save', {type: 'del', id: select.id, mb_id: select.mb_id, ms_id: $('#myTab').find('.active').data('msid') || null}, function (result) {
|
|
|
- const index = materialListSelf.indexOf(select);
|
|
|
- materialListSelf.splice(index, 1);
|
|
|
- sheet.deleteRows(index, 1);
|
|
|
- SpreadJsObj.reLoadSheetData(materialSelfSpread.getActiveSheet());
|
|
|
- const sel = sheet.getSelections();
|
|
|
- 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, nRow, lsheet, lselect, color] = leafXmjSpreadObj.getSelect();
|
|
|
- gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(lselect);
|
|
|
- calculateJiaCha(gclGatherData, iGclRow);
|
|
|
- SpreadJsObj.reLoadRowData(lsheet, nRow);
|
|
|
- lsheet.getRange(nRow, -1, 1, -1).backColor(color);
|
|
|
- SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
- });
|
|
|
- },
|
|
|
- deletePress: function (sheet) {
|
|
|
- return;
|
|
|
- },
|
|
|
- editStarting: function (e, info) {
|
|
|
- const col = info.sheet.zh_setting.cols[info.col];
|
|
|
- const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
- if (col.field === 'quantity') {
|
|
|
- if (select.expr && select.expr !== '') {
|
|
|
- info.sheet.getCell(info.row, info.col).text(select.expr);
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- editEnded: function (e, info) {
|
|
|
- if (info.sheet.zh_setting) {
|
|
|
- const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
- const col = info.sheet.zh_setting.cols[info.col];
|
|
|
- // 未改变值则不提交
|
|
|
- // const validText = info.editingText ? (typeof(info.editingText) === 'String' ? info.editingText.replace('\n', '') : info.editingText) : null;
|
|
|
- // const validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
|
|
|
- // let orgValue = select[col.field];
|
|
|
- const validText = info.editingText ? info.editingText.replace('\n', '') : null;
|
|
|
- let orgValue;
|
|
|
- if (col.field === 'quantity') {
|
|
|
- orgValue = validText && validText !== ''
|
|
|
- ? _.toNumber(validText) ? select.quantity : select.expr
|
|
|
- : (select.expr && select.expr !== '') ? select.expr : select.quantity;
|
|
|
- } else {
|
|
|
- orgValue = select[col.field];
|
|
|
- }
|
|
|
- if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
- }
|
|
|
- const exprQuantity = {
|
|
|
- expr: '',
|
|
|
- quantity: 0,
|
|
|
- };
|
|
|
- const [valid, msg] = materialSpreadObj._checkExpr(validText, exprQuantity);
|
|
|
- if (!valid) {
|
|
|
- toastr.error(msg);
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (isNaN(exprQuantity.quantity)) {
|
|
|
- toastr.error('不能输入其它非数字类型字符');
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- return;
|
|
|
- }
|
|
|
- const num = parseFloat(exprQuantity.quantity);
|
|
|
- if (num < 0 || !/^\d+(\.\d{1,6})?$/.test(num)) {
|
|
|
- // toastr.error('数量值必须大于0并且小于6位小数的浮点数');
|
|
|
- // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- // return;
|
|
|
- toastr.warning('已保留6位小数');
|
|
|
- exprQuantity.quantity = ZhCalc.round(num, 6);
|
|
|
- }
|
|
|
- // 更新至服务器
|
|
|
- console.log(exprQuantity, select.mb_id);
|
|
|
- postData(window.location.pathname + '/save', { type:'update', updateData: { id: select.id, expr: exprQuantity.expr, quantity: exprQuantity.quantity, mb_id: select.mb_id }, ms_id: $('#myTab').find('.active').data('msid') || null }, function (result) {
|
|
|
+ if (openMaterialSelf) {
|
|
|
+ const materialSelfSpreadObj = {
|
|
|
+ del: function () {
|
|
|
+ const sheet = materialSelfSpread.getActiveSheet();
|
|
|
+ const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
+ console.log(select);
|
|
|
+ postData(window.location.pathname + '/save', {
|
|
|
+ type: 'del',
|
|
|
+ id: select.id,
|
|
|
+ mb_id: select.mb_id,
|
|
|
+ ms_id: $('#myTab').find('.active').data('msid') || null
|
|
|
+ }, function (result) {
|
|
|
+ const index = materialListSelf.indexOf(select);
|
|
|
+ materialListSelf.splice(index, 1);
|
|
|
+ sheet.deleteRows(index, 1);
|
|
|
+ SpreadJsObj.reLoadSheetData(materialSelfSpread.getActiveSheet());
|
|
|
+ const sel = sheet.getSelections();
|
|
|
+ sheet.setSelection(index > 0 ? index - 1 : 0, sel.length > 0 ? sel[0].col : 0, 1, 1);
|
|
|
const materialListIndex = materialListData.indexOf(select);
|
|
|
- const index = materialList.indexOf(select);
|
|
|
- select.quantity = exprQuantity.quantity;
|
|
|
- select.expr = exprQuantity.expr;
|
|
|
- materialListData.splice(materialListIndex, 1, select);
|
|
|
- materialList.indexOf(index, 1, select);
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- const [iGclRow, iRow, nRow, sheet, lselect, color] = leafXmjSpreadObj.getSelect();
|
|
|
+ materialListData.splice(materialListIndex, 1);
|
|
|
+ const [iGclRow, iRow, nRow, lsheet, lselect, color] = leafXmjSpreadObj.getSelect();
|
|
|
gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(lselect);
|
|
|
calculateJiaCha(gclGatherData, iGclRow);
|
|
|
- SpreadJsObj.reLoadRowData(sheet, nRow);
|
|
|
- console.log(lselect, color);
|
|
|
- sheet.getRange(nRow, -1, 1, -1).backColor(color);
|
|
|
+ SpreadJsObj.reLoadRowData(lsheet, nRow);
|
|
|
+ lsheet.getRange(nRow, -1, 1, -1).backColor(color);
|
|
|
SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
- }, function () {
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
});
|
|
|
- }
|
|
|
- },
|
|
|
- clipboardPasted(e, info) {
|
|
|
- const hint = {
|
|
|
- cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
|
|
|
- numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
|
|
|
- numberCan: {type: 'warning', msg: '已保留6位小数'},
|
|
|
- };
|
|
|
- const range = info.cellRange;
|
|
|
- const sortData = info.sheet.zh_data || [];
|
|
|
- if (range.row + range.rowCount > sortData.length) {
|
|
|
- toastMessageUniq(hint.cellError);
|
|
|
- SpreadJsObj.reLoadSheetHeader(materialSpread.getActiveSheet());
|
|
|
- SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
|
|
|
- return;
|
|
|
- }
|
|
|
- if (sortData.length > 0 && range.col + range.colCount > 5) {
|
|
|
- toastMessageUniq(hint.cellError);
|
|
|
- SpreadJsObj.reLoadSheetHeader(materialSpread.getActiveSheet());
|
|
|
- SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
|
|
|
+ },
|
|
|
+ deletePress: function (sheet) {
|
|
|
return;
|
|
|
- }
|
|
|
- const data = [];
|
|
|
- for (let iRow = 0; iRow < range.rowCount; iRow++) {
|
|
|
- let bPaste = true;
|
|
|
- const curRow = range.row + iRow;
|
|
|
- const materialData = { id: sortData[curRow].id, mb_id: sortData[curRow].mb_id };
|
|
|
- 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);
|
|
|
- // validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : null);
|
|
|
- const validText = info.sheet.getText(curRow, curCol).replace('\n', '');
|
|
|
- const orgValue = sortData[curRow][colSetting.field];
|
|
|
- if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
|
|
|
- sameCol++;
|
|
|
- if (range.colCount === sameCol) {
|
|
|
- bPaste = false;
|
|
|
- }
|
|
|
- continue;
|
|
|
+ },
|
|
|
+ editStarting: function (e, info) {
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
+ const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
+ if (col.field === 'quantity') {
|
|
|
+ if (select.expr && select.expr !== '') {
|
|
|
+ info.sheet.getCell(info.row, info.col).text(select.expr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ editEnded: function (e, info) {
|
|
|
+ if (info.sheet.zh_setting) {
|
|
|
+ const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
+ // 未改变值则不提交
|
|
|
+ // const validText = info.editingText ? (typeof(info.editingText) === 'String' ? info.editingText.replace('\n', '') : info.editingText) : null;
|
|
|
+ // const validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
|
|
|
+ // let orgValue = select[col.field];
|
|
|
+ const validText = info.editingText ? info.editingText.replace('\n', '') : null;
|
|
|
+ let orgValue;
|
|
|
+ if (col.field === 'quantity') {
|
|
|
+ orgValue = validText && validText !== ''
|
|
|
+ ? _.toNumber(validText) ? select.quantity : select.expr
|
|
|
+ : (select.expr && select.expr !== '') ? select.expr : select.quantity;
|
|
|
+ } else {
|
|
|
+ orgValue = select[col.field];
|
|
|
+ }
|
|
|
+ if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
}
|
|
|
const exprQuantity = {
|
|
|
expr: '',
|
|
@@ -1599,55 +1523,157 @@ $(document).ready(() => {
|
|
|
};
|
|
|
const [valid, msg] = materialSpreadObj._checkExpr(validText, exprQuantity);
|
|
|
if (!valid) {
|
|
|
- toastMessageUniq(getPasteHint(msg, hintRow));
|
|
|
- bPaste = false;
|
|
|
- continue;
|
|
|
+ toastr.error(msg);
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
}
|
|
|
if (isNaN(exprQuantity.quantity)) {
|
|
|
- toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
|
|
|
- bPaste = false;
|
|
|
- continue;
|
|
|
+ toastr.error('不能输入其它非数字类型字符');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
}
|
|
|
const num = parseFloat(exprQuantity.quantity);
|
|
|
if (num < 0 || !/^\d+(\.\d{1,6})?$/.test(num)) {
|
|
|
- toastMessageUniq(getPasteHint(hint.numberCan, hintRow));
|
|
|
- // bPaste = false;
|
|
|
- // continue;
|
|
|
+ // toastr.error('数量值必须大于0并且小于6位小数的浮点数');
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ // return;
|
|
|
+ toastr.warning('已保留6位小数');
|
|
|
exprQuantity.quantity = ZhCalc.round(num, 6);
|
|
|
}
|
|
|
- // materialData[colSetting.field] = validText;
|
|
|
- materialData.expr = exprQuantity.expr;
|
|
|
- materialData.quantity = exprQuantity.quantity;
|
|
|
+ // 更新至服务器
|
|
|
+ console.log(exprQuantity, select.mb_id);
|
|
|
+ postData(window.location.pathname + '/save', {
|
|
|
+ type: 'update',
|
|
|
+ updateData: {
|
|
|
+ id: select.id,
|
|
|
+ expr: exprQuantity.expr,
|
|
|
+ quantity: exprQuantity.quantity,
|
|
|
+ mb_id: select.mb_id
|
|
|
+ },
|
|
|
+ ms_id: $('#myTab').find('.active').data('msid') || null
|
|
|
+ }, function (result) {
|
|
|
+ const materialListIndex = materialListData.indexOf(select);
|
|
|
+ const index = materialList.indexOf(select);
|
|
|
+ select.quantity = exprQuantity.quantity;
|
|
|
+ select.expr = exprQuantity.expr;
|
|
|
+ materialListData.splice(materialListIndex, 1, select);
|
|
|
+ materialList.indexOf(index, 1, select);
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ const [iGclRow, iRow, nRow, sheet, lselect, color] = leafXmjSpreadObj.getSelect();
|
|
|
+ gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(lselect);
|
|
|
+ calculateJiaCha(gclGatherData, iGclRow);
|
|
|
+ SpreadJsObj.reLoadRowData(sheet, nRow);
|
|
|
+ console.log(lselect, color);
|
|
|
+ sheet.getRange(nRow, -1, 1, -1).backColor(color);
|
|
|
+ SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ });
|
|
|
}
|
|
|
- if (bPaste) {
|
|
|
- data.push(materialData);
|
|
|
- // rowData.push(curRow);
|
|
|
- } else {
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, curRow);
|
|
|
+ },
|
|
|
+ clipboardPasted(e, info) {
|
|
|
+ const hint = {
|
|
|
+ cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
|
|
|
+ numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
|
|
|
+ numberCan: {type: 'warning', msg: '已保留6位小数'},
|
|
|
+ };
|
|
|
+ const range = info.cellRange;
|
|
|
+ const sortData = info.sheet.zh_data || [];
|
|
|
+ if (range.row + range.rowCount > sortData.length) {
|
|
|
+ toastMessageUniq(hint.cellError);
|
|
|
+ SpreadJsObj.reLoadSheetHeader(materialSpread.getActiveSheet());
|
|
|
+ SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
|
|
|
+ return;
|
|
|
}
|
|
|
- }
|
|
|
- if (data.length === 0) {
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
- return;
|
|
|
- }
|
|
|
- console.log(data);
|
|
|
- postData(window.location.pathname + '/save', { type:'paste', updateData: data, ms_id: $('#myTab').find('.active').data('msid') || null }, function (result) {
|
|
|
- materialListData = result;
|
|
|
- const [iGclRow, iRow, nRow, sheet, lselect] = leafXmjSpreadObj.getSelect();
|
|
|
- gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(lselect);
|
|
|
- calculateJiaCha(gclGatherData, iGclRow);
|
|
|
- SpreadJsObj.reLoadRowData(sheet, nRow);
|
|
|
- SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
- loadXmjMaterialData(iGclRow, nRow);
|
|
|
- }, function () {
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
- });
|
|
|
- },
|
|
|
- };
|
|
|
- materialSelfSpread.bind(spreadNS.Events.EditStarting, materialSelfSpreadObj.editStarting);
|
|
|
- materialSelfSpread.bind(spreadNS.Events.EditEnded, materialSelfSpreadObj.editEnded);
|
|
|
- materialSelfSpread.bind(spreadNS.Events.ClipboardPasted, materialSelfSpreadObj.clipboardPasted);
|
|
|
- SpreadJsObj.addDeleteBind(materialSelfSpread, materialSelfSpreadObj.deletePress);
|
|
|
+ if (sortData.length > 0 && range.col + range.colCount > 5) {
|
|
|
+ toastMessageUniq(hint.cellError);
|
|
|
+ SpreadJsObj.reLoadSheetHeader(materialSpread.getActiveSheet());
|
|
|
+ SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const data = [];
|
|
|
+ for (let iRow = 0; iRow < range.rowCount; iRow++) {
|
|
|
+ let bPaste = true;
|
|
|
+ const curRow = range.row + iRow;
|
|
|
+ const materialData = {id: sortData[curRow].id, mb_id: sortData[curRow].mb_id};
|
|
|
+ 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);
|
|
|
+ // validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : null);
|
|
|
+ const validText = info.sheet.getText(curRow, curCol).replace('\n', '');
|
|
|
+ const orgValue = sortData[curRow][colSetting.field];
|
|
|
+ if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
|
|
|
+ sameCol++;
|
|
|
+ if (range.colCount === sameCol) {
|
|
|
+ bPaste = false;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ const exprQuantity = {
|
|
|
+ expr: '',
|
|
|
+ quantity: 0,
|
|
|
+ };
|
|
|
+ const [valid, msg] = materialSpreadObj._checkExpr(validText, exprQuantity);
|
|
|
+ if (!valid) {
|
|
|
+ toastMessageUniq(getPasteHint(msg, hintRow));
|
|
|
+ bPaste = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (isNaN(exprQuantity.quantity)) {
|
|
|
+ toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
|
|
|
+ bPaste = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ const num = parseFloat(exprQuantity.quantity);
|
|
|
+ if (num < 0 || !/^\d+(\.\d{1,6})?$/.test(num)) {
|
|
|
+ toastMessageUniq(getPasteHint(hint.numberCan, hintRow));
|
|
|
+ // bPaste = false;
|
|
|
+ // continue;
|
|
|
+ exprQuantity.quantity = ZhCalc.round(num, 6);
|
|
|
+ }
|
|
|
+ // materialData[colSetting.field] = validText;
|
|
|
+ materialData.expr = exprQuantity.expr;
|
|
|
+ materialData.quantity = exprQuantity.quantity;
|
|
|
+ }
|
|
|
+ if (bPaste) {
|
|
|
+ data.push(materialData);
|
|
|
+ // rowData.push(curRow);
|
|
|
+ } else {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, curRow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (data.length === 0) {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log(data);
|
|
|
+ postData(window.location.pathname + '/save', {
|
|
|
+ type: 'paste',
|
|
|
+ updateData: data,
|
|
|
+ ms_id: $('#myTab').find('.active').data('msid') || null
|
|
|
+ }, function (result) {
|
|
|
+ materialListData = result;
|
|
|
+ const [iGclRow, iRow, nRow, sheet, lselect] = leafXmjSpreadObj.getSelect();
|
|
|
+ gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(lselect);
|
|
|
+ calculateJiaCha(gclGatherData, iGclRow);
|
|
|
+ SpreadJsObj.reLoadRowData(sheet, nRow);
|
|
|
+ SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
|
|
|
+ loadXmjMaterialData(iGclRow, nRow);
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ };
|
|
|
+ materialSelfSpread.bind(spreadNS.Events.EditStarting, materialSelfSpreadObj.editStarting);
|
|
|
+ materialSelfSpread.bind(spreadNS.Events.EditEnded, materialSelfSpreadObj.editEnded);
|
|
|
+ materialSelfSpread.bind(spreadNS.Events.ClipboardPasted, materialSelfSpreadObj.clipboardPasted);
|
|
|
+ SpreadJsObj.addDeleteBind(materialSelfSpread, materialSelfSpreadObj.deletePress);
|
|
|
+ }
|
|
|
if (!openMaterialChecklist) {
|
|
|
$.contextMenu({
|
|
|
selector: '#material-spread',
|
|
@@ -1702,58 +1728,60 @@ $(document).ready(() => {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- $.contextMenu({
|
|
|
- selector: '#material-self-spread',
|
|
|
- build: function ($trigger, e) {
|
|
|
- const target = SpreadJsObj.safeRightClickSelection($trigger, e, materialSelfSpread);
|
|
|
- return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
|
|
|
- },
|
|
|
- items: {
|
|
|
- 'create': {
|
|
|
- name: '添加工料',
|
|
|
- icon: 'fa-sign-in',
|
|
|
- callback: function (key, opt) {
|
|
|
- // 获取已选清单
|
|
|
- changeMaterialTable('self');
|
|
|
- $('#add_type').val('self');
|
|
|
- $('#addgl').modal('show');
|
|
|
- },
|
|
|
- disabled: function (key, opt) {
|
|
|
- const sheet = leafXmjSpread.getActiveSheet();
|
|
|
- const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
- // const notx = findNotJoinLeafXmj(select);
|
|
|
- if (!select) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- // if (!readOnly && notx === undefined) {
|
|
|
- // return false;
|
|
|
- // } else {
|
|
|
- // return true;
|
|
|
- // }
|
|
|
- return readOnly;
|
|
|
- }
|
|
|
+ if (openMaterialSelf) {
|
|
|
+ $.contextMenu({
|
|
|
+ selector: '#material-self-spread',
|
|
|
+ build: function ($trigger, e) {
|
|
|
+ const target = SpreadJsObj.safeRightClickSelection($trigger, e, materialSelfSpread);
|
|
|
+ return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
|
|
|
},
|
|
|
- 'delete': {
|
|
|
- name: '删除工料',
|
|
|
- icon: 'fa-remove',
|
|
|
- callback: function (key, opt) {
|
|
|
- materialSelfSpreadObj.del(materialSelfSpread.getActiveSheet());
|
|
|
+ items: {
|
|
|
+ 'create': {
|
|
|
+ name: '添加工料',
|
|
|
+ icon: 'fa-sign-in',
|
|
|
+ callback: function (key, opt) {
|
|
|
+ // 获取已选清单
|
|
|
+ changeMaterialTable('self');
|
|
|
+ $('#add_type').val('self');
|
|
|
+ $('#addgl').modal('show');
|
|
|
+ },
|
|
|
+ disabled: function (key, opt) {
|
|
|
+ const sheet = leafXmjSpread.getActiveSheet();
|
|
|
+ const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
+ // const notx = findNotJoinLeafXmj(select);
|
|
|
+ if (!select) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ // if (!readOnly && notx === undefined) {
|
|
|
+ // return false;
|
|
|
+ // } else {
|
|
|
+ // return true;
|
|
|
+ // }
|
|
|
+ return readOnly;
|
|
|
+ },
|
|
|
},
|
|
|
- disabled: function (key, opt) {
|
|
|
- const sheet = materialSelfSpread.getActiveSheet();
|
|
|
- const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
- if (!select) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- if (!readOnly && select) {
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- return true;
|
|
|
+ 'delete': {
|
|
|
+ name: '删除工料',
|
|
|
+ icon: 'fa-remove',
|
|
|
+ callback: function (key, opt) {
|
|
|
+ materialSelfSpreadObj.del(materialSelfSpread.getActiveSheet());
|
|
|
+ },
|
|
|
+ disabled: function (key, opt) {
|
|
|
+ const sheet = materialSelfSpread.getActiveSheet();
|
|
|
+ const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
+ if (!select) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (!readOnly && select) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- },
|
|
|
- }
|
|
|
- });
|
|
|
+ },
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 应用调差工料至其他清单明细
|