|
@@ -188,6 +188,8 @@ $(document).ready(() => {
|
|
|
{title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'oa_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.oa_tp'},
|
|
|
{title: '申请变更增(+)减(-)|数量', colSpan: '2|1', rowSpan: '1|1', field: 'camount', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit', getValue: 'getValue.camount'},
|
|
|
{title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'ca_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.ca_tp'},
|
|
|
+ {title: '审批后变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'samount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.samount'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sa_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.sa_tp'},
|
|
|
],
|
|
|
emptyRows: !readOnly ? 3 : 0,
|
|
|
headRows: 2,
|
|
@@ -195,12 +197,35 @@ $(document).ready(() => {
|
|
|
defaultRowHeight: 21,
|
|
|
headerFont: '12px 微软雅黑',
|
|
|
font: '12px 微软雅黑',
|
|
|
- readOnly: readOnly,
|
|
|
+ readOnly: change.status === auditConst.status.checking ? false : readOnly,
|
|
|
localCache: {
|
|
|
key: 'changes-plan-list-spread',
|
|
|
colWidth: true,
|
|
|
}
|
|
|
};
|
|
|
+ console.log(changeList, change.listAudits);
|
|
|
+
|
|
|
+ if (change.status === auditConst.status.checking || change.status === auditConst.status.checked) {
|
|
|
+ for (const audit of change.listAudits) {
|
|
|
+ // const userinfo = _.find(auditList2, { 'aid': aid });
|
|
|
+ const newColcount = {
|
|
|
+ title: audit.name + ' 审批|数量',
|
|
|
+ colSpan: '2|1', rowSpan: '1|1',
|
|
|
+ field: 'audit_amount_' + audit.aid,
|
|
|
+ hAlign: 2, width: 60, type: 'Number',
|
|
|
+ readOnly: !(change.shenpiPower && audit.aid === parseInt(cur_uid))
|
|
|
+ };
|
|
|
+ const newColTp = {
|
|
|
+ title: '|金额',
|
|
|
+ colSpan: '|1', rowSpan: '|1',
|
|
|
+ field: 'sa_tp_' + audit.aid,
|
|
|
+ hAlign: 2, width: 80, type: 'Number',
|
|
|
+ readOnly: true
|
|
|
+ };
|
|
|
+ changeSpreadSetting.cols.push(newColcount);
|
|
|
+ changeSpreadSetting.cols.push(newColTp);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
const changeCol = {
|
|
|
getValue: {
|
|
@@ -219,6 +244,12 @@ $(document).ready(() => {
|
|
|
camount: function (data) {
|
|
|
return ZhCalc.round(data.camount, findDecimal(data.unit));
|
|
|
},
|
|
|
+ samount: function (data) {
|
|
|
+ return ZhCalc.round(data.samount, findDecimal(data.unit));
|
|
|
+ },
|
|
|
+ sa_tp: function (data) {
|
|
|
+ return ZhCalc.round(ZhCalc.mul(data.unit_price, data.samount), totalPriceUnit);
|
|
|
+ },
|
|
|
},
|
|
|
readOnly: {
|
|
|
isEdit: function (data) {
|
|
@@ -226,72 +257,94 @@ $(document).ready(() => {
|
|
|
},
|
|
|
},
|
|
|
};
|
|
|
-
|
|
|
const changeSpreadObj = {
|
|
|
- makeSjsFooter: function () {
|
|
|
+ makeSjsFooter: function() {
|
|
|
// 增加汇总行并设为锁定禁止编辑状态
|
|
|
changeSpreadSheet.addRows(changeSpreadSheet.getRowCount(), 1);
|
|
|
changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 0, '合计');
|
|
|
changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
|
|
|
changeSpreadObj.countSum();
|
|
|
},
|
|
|
+ setAuditValue: function () {
|
|
|
+ for (const c of changeList) {
|
|
|
+ for (const audit of change.listAudits) {
|
|
|
+ c['sa_tp_' + audit.aid] = ZhCalc.round(ZhCalc.mul(c['audit_amount_' + audit.aid], c.unit_price), totalPriceUnit);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setRowValueAndSum: function (data, row, col) {
|
|
|
+ for (const j in change.listAudits) {
|
|
|
+ const sum = ZhCalc.round(ZhCalc.mul(data.unit_price, parseFloat(changeSpreadSheet.getValue(row, 10 + parseInt(j)*2))), totalPriceUnit);
|
|
|
+ changeSpreadSheet.setValue(row, 11 + j*2, sum !== 0 ? sum : null);
|
|
|
+ }
|
|
|
+ // const sum = ZhCalc.round(ZhCalc.mul(data.unit_price, data.spamount), totalPriceUnit);
|
|
|
+ // changeSpreadSheet.setValue(row, col+1, sum !== 0 ? sum : null);
|
|
|
+ const rowCount = changeSpreadSheet.getRowCount();
|
|
|
+ // 用户的数据合计
|
|
|
+ let audit_sum = 0;
|
|
|
+ for(let i = 0; i < rowCount - 1; i++){
|
|
|
+ audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, col+1));
|
|
|
+ }
|
|
|
+ changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, col+1, audit_sum !== 0 ? audit_sum : null);
|
|
|
+ },
|
|
|
countSum: function() {
|
|
|
const rowCount = changeSpreadSheet.getRowCount();
|
|
|
let oSum = 0,
|
|
|
- cSum = 0;
|
|
|
- for(var i = 0; i < rowCount - 1; i++){
|
|
|
+ cSum = 0,
|
|
|
+ sSum = 0;
|
|
|
+ for (let i = 0; i < rowCount - 1; i++) {
|
|
|
oSum = ZhCalc.add(oSum, changeSpreadSheet.getValue(i, 5));
|
|
|
cSum = ZhCalc.add(cSum, changeSpreadSheet.getValue(i, 7));
|
|
|
+ sSum = ZhCalc.add(sSum, changeSpreadSheet.getValue(i, 9));
|
|
|
}
|
|
|
changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 5, oSum !== 0 ? oSum : null);
|
|
|
changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 7, cSum !== 0 ? cSum : null);
|
|
|
- },
|
|
|
- add: function () {
|
|
|
- postData(preUrl + '/list/save', {type: 'add'}, function (result) {
|
|
|
- if (result) {
|
|
|
- changeList.push(result);
|
|
|
- changeSpreadSheet.addRows(changeList.length - 1, 1);
|
|
|
- SpreadJsObj.reLoadRowData(changeSpreadSheet, changeList.length - 1);
|
|
|
- changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
|
|
|
- changeSpreadSheet.setSelection(changeList.length - 1, 0, 1, 1);
|
|
|
- // $('#plan-spread').css('height', `${21*changeList + 100}px`);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- batchAdd: function(num) {
|
|
|
- postData(preUrl + '/list/save', {type: 'batchadd', num}, function (result) {
|
|
|
- if (result) {
|
|
|
- changeList = _.concat(changeList, result);
|
|
|
- SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
|
|
|
- changeSpreadObj.makeSjsFooter();
|
|
|
+ changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 9, sSum !== 0 ? sSum : null);
|
|
|
+ // 用户的数据合计
|
|
|
+ for (const j in change.listAudits) {
|
|
|
+ let audit_sum = 0;
|
|
|
+ for(let i = 0; i < rowCount - 1; i++){
|
|
|
+ audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, 11 + j*2));
|
|
|
}
|
|
|
- });
|
|
|
- },
|
|
|
- del: function () {
|
|
|
- const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
|
|
|
- const index = changeList.indexOf(select);
|
|
|
- if (index > -1) {
|
|
|
- postData(preUrl + '/list/save', {type: 'del', id: select.id}, function (result) {
|
|
|
- changeList.splice(index, 1);
|
|
|
- changeSpreadSheet.deleteRows(index, 1);
|
|
|
- const sel = changeSpreadSheet.getSelections();
|
|
|
- changeSpreadSheet.setSelection(0, 0, 1, 1);
|
|
|
- changeSpreadObj.countSum();
|
|
|
- });
|
|
|
+ changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 11 + j*2, audit_sum !== 0 ? audit_sum : null);
|
|
|
}
|
|
|
},
|
|
|
- selectionChanged: function (e, info) {
|
|
|
- // const sel = info.sheet.getSelections()[0];
|
|
|
- // const col = info.sheet.zh_setting.cols[sel.col];
|
|
|
- // // const data = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
- // if (col && col.field === 'del_list') {
|
|
|
- // changeSpreadObj.del();
|
|
|
- // }
|
|
|
- },
|
|
|
deletePress: function (sheet) {
|
|
|
return;
|
|
|
},
|
|
|
- editEnded: function (e, info) {
|
|
|
+ showHideAudit: function (show = false) {
|
|
|
+ const count = changeSpreadSetting.cols.length;
|
|
|
+ for (let i = 10; i < count; i++) {
|
|
|
+ changeSpreadSheet.setColumnVisible(i, show, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ }
|
|
|
+ changeSpreadSheet.setColumnVisible(8, !show, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ changeSpreadSheet.setColumnVisible(9, !show, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ },
|
|
|
+ valueChanged: function (e, info) {
|
|
|
+ // 防止ctrl+z撤销数据
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ if (!readOnly) {
|
|
|
+ changeSpreadObj.del = function (sheet) {
|
|
|
+ const selection = sheet.getSelections();
|
|
|
+ const row = selection[0].row, count = selection[0].rowCount;
|
|
|
+ const sortData = sheet.zh_data;
|
|
|
+ const ids = [];
|
|
|
+ for (let iRow = 0; iRow < count; iRow++) {
|
|
|
+ if (sortData[iRow + row]) {
|
|
|
+ ids.push(sortData[iRow + row].id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ids.length > 0) {
|
|
|
+ postData(preUrl + '/list/save', {type: 'del', ids}, function (result) {
|
|
|
+ changeList = result;
|
|
|
+ SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
|
|
|
+ changeSpreadObj.makeSjsFooter();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+ changeSpreadObj.editEnded = function (e, info) {
|
|
|
if (info.sheet.zh_setting) {
|
|
|
const type = SpreadJsObj.getSelectObject(info.sheet) ? 'update' : 'add';
|
|
|
const select = type === 'update' ? SpreadJsObj.getSelectObject(info.sheet) : {unit: ''};
|
|
@@ -353,8 +406,11 @@ $(document).ready(() => {
|
|
|
SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
});
|
|
|
}
|
|
|
- },
|
|
|
- clipboardPasted(e, info) {
|
|
|
+ };
|
|
|
+ changeSpreadObj.clipboardPasted = function(e, info, cellRange) {
|
|
|
+ if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
|
|
|
+ info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
|
|
|
+ }
|
|
|
const hint = {
|
|
|
cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
|
|
|
numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
|
|
@@ -363,22 +419,6 @@ $(document).ready(() => {
|
|
|
const sortData = info.sheet.zh_data || [];
|
|
|
const range = info.cellRange;
|
|
|
const data = [];
|
|
|
- // if (info.cellRange.row + info.cellRange.rowCount > sortData.length) {
|
|
|
- // toastMessageUniq(hint.cellError);
|
|
|
- // // SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
|
|
|
- // SpreadJsObj.reLoadSheetHeader(changeSpreadSheet);
|
|
|
- // SpreadJsObj.reLoadSheetData(changeSpreadSheet);
|
|
|
- // changeSpreadObj.makeSjsFooter();
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // if (sortData.length > 0 && range.col + range.colCount > 8) {
|
|
|
- // toastMessageUniq(hint.cellError);
|
|
|
- // SpreadJsObj.reLoadSheetHeader(changeSpreadSheet);
|
|
|
- // SpreadJsObj.reLoadSheetData(changeSpreadSheet);
|
|
|
- // changeSpreadObj.makeSjsFooter();
|
|
|
- // return;
|
|
|
- // }
|
|
|
-
|
|
|
for (let iRow = 0; iRow < range.rowCount; iRow++) {
|
|
|
let bPaste = true;
|
|
|
const curRow = range.row + iRow;
|
|
@@ -421,19 +461,22 @@ $(document).ready(() => {
|
|
|
//粘贴内容要为下拉列表里所有的单位,不然为空
|
|
|
if (changeUnits.indexOf(validText) === -1) {
|
|
|
unitdecimal = '';
|
|
|
+ // validText = null;
|
|
|
}
|
|
|
cLData.camount = curRow >= sortData.length ? 0 : ZhCalc.round(sortData[curRow].camount, findDecimal(unitdecimal)) || 0;
|
|
|
cLData.oamount = curRow >= sortData.length ? 0 : ZhCalc.round(sortData[curRow].oamount, findDecimal(unitdecimal)) || 0;
|
|
|
cLData.spamount = curRow >= sortData.length ? 0 : ZhCalc.round(sortData[curRow].camount, findDecimal(unitdecimal)) || 0;
|
|
|
}
|
|
|
// sortData[curRow][colSetting.field] = validText;
|
|
|
- if (colSetting.type === 'camount') {
|
|
|
+ if (colSetting.field === 'camount') {
|
|
|
cLData.spamount = ZhCalc.round(validText, findDecimal(unitdecimal)) || 0;
|
|
|
}
|
|
|
cLData[colSetting.field] = validText;
|
|
|
|
|
|
}
|
|
|
if (bPaste) {
|
|
|
+ delete cLData.oa_tp;
|
|
|
+ delete cLData.ca_tp;
|
|
|
data.push(cLData);
|
|
|
// rowData.push(curRow);
|
|
|
} else {
|
|
@@ -446,21 +489,18 @@ $(document).ready(() => {
|
|
|
}
|
|
|
console.log(data);
|
|
|
// 更新至服务器
|
|
|
- // postData(preUrl + '/list/save', { type:'paste', updateData: data }, function (result) {
|
|
|
- // changeList = result;
|
|
|
- // SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
|
|
|
- // changeSpreadObj.makeSjsFooter();
|
|
|
- // }, function () {
|
|
|
- // SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
- // return;
|
|
|
- // });
|
|
|
+ postData(preUrl + '/list/save', { type:'paste', updateData: data }, function (result) {
|
|
|
+ changeList = result;
|
|
|
+ SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
|
|
|
+ changeSpreadObj.makeSjsFooter();
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
+ return;
|
|
|
+ });
|
|
|
}
|
|
|
- },
|
|
|
- valueChanged(e, info) {
|
|
|
- // 防止ctrl+z撤销数据
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
- },
|
|
|
- updateOamount: function () {
|
|
|
+ };
|
|
|
+
|
|
|
+ changeSpreadObj.updateOamount = function () {
|
|
|
const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
|
|
|
console.log(changeSpreadSheet);
|
|
|
const index = changeList.indexOf(select);
|
|
@@ -493,44 +533,9 @@ $(document).ready(() => {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- },
|
|
|
- };
|
|
|
- let changeListData;
|
|
|
- let gclGatherData;
|
|
|
- let dealBillList;
|
|
|
- const billUrl = window.location.pathname.split('/').slice(0, 4).join('/');
|
|
|
- postData(billUrl + '/defaultBills', {}, function (result) {
|
|
|
- gclGatherModel.loadLedgerData(result.bills);
|
|
|
- gclGatherModel.loadPosData(result.pos);
|
|
|
-
|
|
|
- gclGatherData = gclGatherModel.gatherGclData();
|
|
|
- gclGatherData = _.filter(gclGatherData, function (item) {
|
|
|
- return item.leafXmjs && item.leafXmjs.length !== 0;
|
|
|
- });
|
|
|
- // 数组去重
|
|
|
- dealBillList = result.dealBills;
|
|
|
- // for (const db of gclGatherData) {
|
|
|
- // const exist_index = dealBillList.findIndex(function (item) {
|
|
|
- // return item.code === db.code && item.name === db.name && item.unit === db.unit && item.unit_price === db.unit_price;
|
|
|
- // });
|
|
|
- // if (exist_index !== -1) {
|
|
|
- // dealBillList.splice(exist_index, 1);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // changeListData = gclGatherData.concat(dealBillList);
|
|
|
- changeListData = gclGatherData;
|
|
|
- console.log(changeListData, dealBillList);
|
|
|
-
|
|
|
- SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
|
|
|
- SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
|
|
|
- SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
|
|
|
- changeSpreadObj.makeSjsFooter();
|
|
|
- });
|
|
|
-
|
|
|
- if (!readOnly) {
|
|
|
- $('#add-white-btn').click(changeSpreadObj.add);
|
|
|
+ };
|
|
|
+ // changeSpread.bind(spreadNS.Events.CellChanged, changeSpreadObj.cellChanged);
|
|
|
changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
|
|
|
- changeSpread.bind(spreadNS.Events.SelectionChanged, changeSpreadObj.selectionChanged);
|
|
|
changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
|
|
|
changeSpread.bind(spreadNS.Events.ValueChanged, changeSpreadObj.valueChanged);
|
|
|
SpreadJsObj.addDeleteBind(changeSpread, changeSpreadObj.deletePress);
|
|
@@ -568,14 +573,20 @@ $(document).ready(() => {
|
|
|
changeSpreadObj.del(changeSpreadSheet);
|
|
|
},
|
|
|
disabled: function (key, opt) {
|
|
|
- const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
|
|
|
- const sel = changeSpreadSheet.getSelections()[0];
|
|
|
- // console.log(select, sel);
|
|
|
- if (!readOnly && select && sel.row !== changeSpreadSheet.getRowCount() - 1) {
|
|
|
- return false;
|
|
|
+ // const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
|
|
|
+ if (changeSpreadSheet.zh_data) {
|
|
|
+ const selection = changeSpreadSheet.getSelections();
|
|
|
+ return changeSpreadSheet.zh_data.length < selection[0].row + selection[0].rowCount;
|
|
|
} else {
|
|
|
return true;
|
|
|
}
|
|
|
+ // const sel = changeSpreadSheet.getSelections()[0];
|
|
|
+ // // console.log(select, sel);
|
|
|
+ // if (!readOnly && select && sel.row !== changeSpreadSheet.getRowCount() - 1) {
|
|
|
+ // return false;
|
|
|
+ // } else {
|
|
|
+ // return true;
|
|
|
+ // }
|
|
|
}
|
|
|
},
|
|
|
}
|
|
@@ -605,6 +616,172 @@ $(document).ready(() => {
|
|
|
});
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+ if (change.shenpiPower) {
|
|
|
+ changeSpreadObj.editEnded = function (e, info) {
|
|
|
+ if (info.sheet.zh_setting) {
|
|
|
+ const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
+ // 未改变值则不提交
|
|
|
+ let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
|
|
|
+ const orgValue = select[col.field];
|
|
|
+ if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 判断部分值是否输入的是数字判断和数据计算
|
|
|
+ if (col.type === 'Number') {
|
|
|
+ if (isNaN(validText)) {
|
|
|
+ toastr.error('不能输入其它非数字类型字符');
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
|
|
|
+ // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
|
|
|
+ }
|
|
|
+ select[col.field] = validText;
|
|
|
+ select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
|
|
|
+
|
|
|
+ const data = {
|
|
|
+ id: select.id,
|
|
|
+ spamount: select.spamount,
|
|
|
+ };
|
|
|
+ console.log(data);
|
|
|
+
|
|
|
+ // 更新至服务器
|
|
|
+ postData(preUrl + '/list/save', { type:'update', updateData: data }, function (result) {
|
|
|
+ changeList.splice(info.row, 1, select);
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
|
|
|
+ }, function () {
|
|
|
+ select[col.field] = orgValue;
|
|
|
+ select.spamount = orgValue;
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+ changeSpreadObj.clipboardPasted = function(e, info) {
|
|
|
+ const hint = {
|
|
|
+ cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
|
|
|
+ numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
|
|
|
+ };
|
|
|
+ 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 materialData = JSON.parse(JSON.stringify(sortData[curRow]));
|
|
|
+ const cLData = { id: sortData[curRow].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 orgValue = sortData[curRow][colSetting.field];
|
|
|
+ if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
|
|
|
+ sameCol++;
|
|
|
+ if (range.colCount === sameCol) {
|
|
|
+ bPaste = false;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (colSetting.type === 'Number') {
|
|
|
+ if (isNaN(validText)) {
|
|
|
+ toastMessageUniq(hint.numberExpr);
|
|
|
+ bPaste = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
|
|
|
+ }
|
|
|
+ // cLData[colSetting.field] = validText;
|
|
|
+ sortData[curRow][colSetting.field] = validText;
|
|
|
+ cLData.spamount = validText;
|
|
|
+ }
|
|
|
+ if (bPaste) {
|
|
|
+ data.push(cLData);
|
|
|
+ // rowData.push(curRow);
|
|
|
+ } else {
|
|
|
+ changeSpreadObj.setAuditValue();
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, curRow);
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, curRow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (data.length === 0) {
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log(data);
|
|
|
+ // 更新至服务器
|
|
|
+ postData(preUrl + '/list/save', { type:'paste_amount_rows', updateData: data }, function (result) {
|
|
|
+ changeList = result;
|
|
|
+ changeSpreadObj.setAuditValue();
|
|
|
+ SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
|
|
|
+ changeSpreadObj.makeSjsFooter();
|
|
|
+ }, function () {
|
|
|
+ changeSpreadObj.setAuditValue();
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
+ return;
|
|
|
+ });
|
|
|
+ };
|
|
|
+ changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
|
|
|
+ changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
|
|
|
+ changeSpread.bind(spreadNS.Events.ValueChanged, changeSpreadObj.valueChanged);
|
|
|
+ SpreadJsObj.addDeleteBind(changeSpread, changeSpreadObj.deletePress);
|
|
|
+ }
|
|
|
+
|
|
|
+ let changeListData;
|
|
|
+ let gclGatherData;
|
|
|
+ let dealBillList;
|
|
|
+ const billUrl = window.location.pathname.split('/').slice(0, 4).join('/');
|
|
|
+ postData(billUrl + '/defaultBills', {}, function (result) {
|
|
|
+ gclGatherModel.loadLedgerData(result.bills);
|
|
|
+ gclGatherModel.loadPosData(result.pos);
|
|
|
+
|
|
|
+ gclGatherData = gclGatherModel.gatherGclData();
|
|
|
+ gclGatherData = _.filter(gclGatherData, function (item) {
|
|
|
+ return item.leafXmjs && item.leafXmjs.length !== 0;
|
|
|
+ });
|
|
|
+ // 数组去重
|
|
|
+ dealBillList = result.dealBills;
|
|
|
+ // for (const db of gclGatherData) {
|
|
|
+ // const exist_index = dealBillList.findIndex(function (item) {
|
|
|
+ // return item.code === db.code && item.name === db.name && item.unit === db.unit && item.unit_price === db.unit_price;
|
|
|
+ // });
|
|
|
+ // if (exist_index !== -1) {
|
|
|
+ // dealBillList.splice(exist_index, 1);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // changeListData = gclGatherData.concat(dealBillList);
|
|
|
+ changeListData = gclGatherData;
|
|
|
+ console.log(changeListData, dealBillList);
|
|
|
+
|
|
|
+ SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
|
|
|
+ SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
|
|
|
+ if (change.status === auditConst.status.checking || change.status === auditConst.status.checked) changeSpreadObj.setAuditValue();
|
|
|
+ SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
|
|
|
+ changeSpreadObj.makeSjsFooter();
|
|
|
+ if (change.status === auditConst.status.checked) {
|
|
|
+ changeSpreadObj.showHideAudit(false);
|
|
|
+ } else {
|
|
|
+ changeSpreadObj.showHideAudit(true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 审批流程展示与隐藏
|
|
|
+ $('#show-table-detail').on('click', function (e) {
|
|
|
+ if($(e.target).is('label')){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ changeSpreadObj.showHideAudit($(this).is(':checked'));
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
/**
|
|
@@ -648,3 +825,11 @@ const is_numeric = (value) => {
|
|
|
return !Number.isNaN(Number(value)) && value.toString().trim() !== '';
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
+function getPasteHint (str, row = '') {
|
|
|
+ let returnObj = str;
|
|
|
+ if (row) {
|
|
|
+ returnObj.msg = '清单第' + (row+1) + '行' + str.msg;
|
|
|
+ }
|
|
|
+ return returnObj;
|
|
|
+}
|