|
@@ -115,6 +115,21 @@ $(document).ready(() => {
|
|
|
SpreadJsObj.loadSheetData(paySpread.getActiveSheet(), SpreadJsObj.DataType.Data, dealPay);
|
|
|
|
|
|
const paySpreadObj = {
|
|
|
+ _checkExpr: function (text, data, priceField, exprField) {
|
|
|
+ if (text) {
|
|
|
+ const num = _.toNumber(text);
|
|
|
+ if (num) {
|
|
|
+ data[priceField] = num;
|
|
|
+ data[exprField] = null;
|
|
|
+ } else {
|
|
|
+ data[exprField] = text.replace('=', '');
|
|
|
+ data[priceField] = null;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ data[priceField] = null;
|
|
|
+ data[exprField] = null;
|
|
|
+ }
|
|
|
+ },
|
|
|
refreshActn: function () {
|
|
|
const setObjEnable = function (obj, enable) {
|
|
|
if (enable) {
|
|
@@ -216,21 +231,6 @@ $(document).ready(() => {
|
|
|
}
|
|
|
},
|
|
|
editEnded: function (e, info) {
|
|
|
- const checkExpr = function (text, data, priceField, exprField) {
|
|
|
- if (text) {
|
|
|
- const num = _.toNumber(text);
|
|
|
- if (num) {
|
|
|
- data[priceField] = num;
|
|
|
- data[exprField] = null;
|
|
|
- } else {
|
|
|
- data[exprField] = text;
|
|
|
- data[priceField] = null;
|
|
|
- }
|
|
|
- } else {
|
|
|
- data[priceField] = null;
|
|
|
- data[exprField] = null;
|
|
|
- }
|
|
|
- };
|
|
|
if (info.sheet.zh_setting) {
|
|
|
const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
const col = info.sheet.zh_setting.cols[info.col];
|
|
@@ -261,14 +261,14 @@ $(document).ready(() => {
|
|
|
// 获取更新数据
|
|
|
if (col.field === 'tp') {
|
|
|
data.updateData.pid = select.pid;
|
|
|
- checkExpr(validText, data.updateData, 'tp', 'expr');
|
|
|
+ paySpreadObj._checkExpr(validText, data.updateData, 'tp', 'expr');
|
|
|
} else {
|
|
|
data.updateData.id = select.pid;
|
|
|
if (validText) {
|
|
|
if (col.field === 'sprice') {
|
|
|
- checkExpr(validText, data.updateData, 'sprice', 'sexpr');
|
|
|
+ paySpreadObj._checkExpr(validText, data.updateData, 'sprice', 'sexpr');
|
|
|
} else if (col.field === 'rprice') {
|
|
|
- checkExpr(validText, data.updateData, 'rprice', 'rexpr');
|
|
|
+ paySpreadObj._checkExpr(validText, data.updateData, 'rprice', 'rexpr');
|
|
|
} else {
|
|
|
data.updateData[col.field] = validText;
|
|
|
}
|
|
@@ -327,7 +327,103 @@ $(document).ready(() => {
|
|
|
info.sheet.getCell(info.row, info.col).text(select.rexpr);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ deletePress: function (sheet) {
|
|
|
+ if (sheet.zh_setting && sheet.zh_data) {
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
+ if (!sel) return;
|
|
|
+
|
|
|
+ const col = sheet.zh_setting.cols[sel.col];
|
|
|
+ if (col.readOnly === true) { return; }
|
|
|
+ if (sel.colCount > 1) {
|
|
|
+ toast('请勿同时删除多列数据', 'warning');
|
|
|
+ }
|
|
|
+
|
|
|
+ const data = {type: col.field === 'tp' ? 'stage' : 'info', updateData: []};
|
|
|
+ for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
|
|
|
+ const node = sheet.zh_data[iRow];
|
|
|
+ if (node) {
|
|
|
+ const updateData = {};
|
|
|
+ if (col.field === 'tp') {
|
|
|
+ updateData.pid = node.pid;
|
|
|
+ updateData.tp = null;
|
|
|
+ updateData.expr = null;
|
|
|
+ } else {
|
|
|
+ updateData.id = node.pid;
|
|
|
+ if (col.field === 'sprice') {
|
|
|
+ updateData.sprice = null;
|
|
|
+ updateData.sexpr = null;
|
|
|
+ } else if (col.field === 'rprice') {
|
|
|
+ updateData.rprice = null;
|
|
|
+ updateData.rexpr = null;
|
|
|
+ } else {
|
|
|
+ updateData[col.field] = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ data.updateData.push(updateData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (data.updateData.length > 0) {
|
|
|
+ if (data.updateData.length === 1 && sel.rowCount === 1) {
|
|
|
+ data.updateData = data.updateData[0];
|
|
|
+ }
|
|
|
+ postData(window.location.pathname + '/save', data, function (result) {
|
|
|
+ loadUpdateDealPays(result);
|
|
|
+ SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ clipboardPasted: function (e, info) {
|
|
|
+ if (info.sheet.zh_setting && info.sheet.zh_data) {
|
|
|
+ const col = info.sheet.zh_setting.cols[info.cellRange.col];
|
|
|
+ if (col.readOnly === true) {
|
|
|
+ SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (info.cellRange.colCount > 1) {
|
|
|
+ toast('请勿同时删除多列数据', 'warning');
|
|
|
+ }
|
|
|
+
|
|
|
+ const sortData = info.sheet.zh_data;
|
|
|
+ const data = {type: col.field === 'tp' ? 'stage' : 'info', updateData: []};
|
|
|
+
|
|
|
+ for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
|
|
|
+ const curRow = info.cellRange.row + iRow;
|
|
|
+ const node = sortData[curRow];
|
|
|
+ if (node) {
|
|
|
+ const validText = info.sheet.getText(curRow, info.cellRange.col).replace('\n', '');
|
|
|
+ const updateData = {};
|
|
|
+ if (col.field === 'tp') {
|
|
|
+ updateData.pid = node.pid;
|
|
|
+ paySpreadObj._checkExpr(validText, updateData, 'tp', 'expr');
|
|
|
+ } else {
|
|
|
+ updateData.id = node.pid;
|
|
|
+ if (validText) {
|
|
|
+ if (col.field === 'sprice') {
|
|
|
+ paySpreadObj._checkExpr(validText, updateData, 'sprice', 'sexpr');
|
|
|
+ } else if (col.field === 'rprice') {
|
|
|
+ paySpreadObj._checkExpr(validText, updateData, 'rprice', 'rexpr');
|
|
|
+ } else {
|
|
|
+ updateData[col.field] = validText;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ updateData[col.field] = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ data.updateData.push(updateData);
|
|
|
+ }
|
|
|
+ if (data.updateData.length > 0) {
|
|
|
+ postData(window.location.pathname + '/save', data, function (result) {
|
|
|
+ loadUpdateDealPays(result);
|
|
|
+ SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
};
|
|
|
paySpreadObj.refreshActn();
|
|
|
if (!readOnly) {
|
|
@@ -335,6 +431,8 @@ $(document).ready(() => {
|
|
|
paySpread.bind(spreadNS.Events.SelectionChanged, paySpreadObj.selectionChanged);
|
|
|
paySpread.bind(spreadNS.Events.ButtonClicked, paySpreadObj.buttonClicked);
|
|
|
paySpread.bind(spreadNS.Events.EditStarting, paySpreadObj.editStarting);
|
|
|
+ paySpread.bind(spreadNS.Events.ClipboardPasted, paySpreadObj.clipboardPasted);
|
|
|
+ SpreadJsObj.addDeleteBind(paySpread, paySpreadObj.deletePress);
|
|
|
$('#add').click(paySpreadObj.add);
|
|
|
$('#del').click(paySpreadObj.del);
|
|
|
$('#up-move').click(paySpreadObj.upMove);
|