|
@@ -223,41 +223,44 @@ $(document).ready(() => {
|
|
|
}
|
|
|
},
|
|
|
dragFillBlock: function (e, info) {
|
|
|
- console.log(info);
|
|
|
- if (info.fromCol !== info.toCol) {
|
|
|
- info.cancel = true;
|
|
|
- }
|
|
|
- },
|
|
|
- dragFillBlockCompleted: function (e, info) {
|
|
|
- if (info.sheet.zh_setting && info.sheet.zh_data) {
|
|
|
- const datas = [];
|
|
|
- for (let iRow = 0; iRow < info.fillRange.rowCount; iRow++) {
|
|
|
- const curRow = info.fillRange.row + iRow;
|
|
|
- const data = info.sheet.zh_data[curRow];
|
|
|
- if (data) {
|
|
|
- const updateData = {lid: data.lid};
|
|
|
- if (data.uuid) {
|
|
|
- updateData.uuid = data.uuid;
|
|
|
- } else {
|
|
|
- updateData.code = data.code;
|
|
|
- updateData.name = data.name;
|
|
|
- updateData.unit = data.unit;
|
|
|
- updateData.unit_price = data.unit_price;
|
|
|
- }
|
|
|
- updateData.doc_code = info.sheet.getText(curRow, info.fillRange.col).replace('\n', '');
|
|
|
- datas.push(updateData);
|
|
|
+ info.cancel = true;
|
|
|
+ if (!info.sheet.zh_setting || !info.sheet.zh_data) return;
|
|
|
+ const sel = info.sheet.getSelections()[0];
|
|
|
+ const col = info.sheet.zh_setting.cols[info.fillRange.col];
|
|
|
+ if (info.fillRange.colCount > 1 || !sel || col.field !== 'doc_code') return;
|
|
|
+ const text = info.sheet.getText(sel.row + sel.rowCount - 1, sel.col);
|
|
|
+ if (text === '') return;
|
|
|
+
|
|
|
+ const regRst = /(\d+)$/g.exec(text), datas = [];
|
|
|
+ for (let iRow = 0; iRow < info.fillRange.rowCount; iRow++) {
|
|
|
+ const curRow = info.fillRange.row + iRow;
|
|
|
+ const data = info.sheet.zh_data[curRow];
|
|
|
+ if (data) {
|
|
|
+ const updateData = {lid: data.lid};
|
|
|
+ if (data.uuid) {
|
|
|
+ updateData.uuid = data.uuid;
|
|
|
+ } else {
|
|
|
+ updateData.code = data.code;
|
|
|
+ updateData.name = data.name;
|
|
|
+ updateData.unit = data.unit;
|
|
|
+ updateData.unit_price = data.unit_price;
|
|
|
}
|
|
|
+ if (regRst) {
|
|
|
+ updateData.doc_code = text.substr(0, regRst.index) + (parseInt(regRst[0]) + iRow + 1);
|
|
|
+ } else {
|
|
|
+ updateData.doc_code = text.replace('\n', '');
|
|
|
+ }
|
|
|
+ datas.push(updateData);
|
|
|
}
|
|
|
- if (datas.length > 0) {
|
|
|
- postData(window.location.pathname + '/save', datas, function (result) {
|
|
|
- stageIm.loadUpdateDetailData(result);
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.fillRange.row, info.fillRange.rowCount);
|
|
|
- }, function () {
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.fillRange.row, info.fillRange.rowCount);
|
|
|
- })
|
|
|
- }
|
|
|
}
|
|
|
- console.log(info);
|
|
|
+ if (datas.length > 0) {
|
|
|
+ postData(window.location.pathname + '/save', datas, function (result) {
|
|
|
+ stageIm.loadUpdateDetailData(result);
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.fillRange.row, info.fillRange.rowCount);
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.fillRange.row, info.fillRange.rowCount);
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
};
|
|
|
detailSpread.bind(spreadNS.Events.SelectionChanged, detailOperationObj.selectionChanged);
|
|
@@ -265,7 +268,6 @@ $(document).ready(() => {
|
|
|
detailSpread.bind(spreadNS.Events.EditEnded, detailOperationObj.editEnded);
|
|
|
detailSpread.bind(spreadNS.Events.ClipboardPasted, detailOperationObj.clipboardPasted);
|
|
|
detailSpread.bind(spreadNS.Events.DragFillBlock, detailOperationObj.dragFillBlock);
|
|
|
- detailSpread.bind(spreadNS.Events.DragFillBlockCompleted, detailOperationObj.dragFillBlockCompleted);
|
|
|
SpreadJsObj.addDeleteBind(detailSpread, detailOperationObj.deletePress);
|
|
|
}
|
|
|
|