|
@@ -236,38 +236,53 @@ $(document).ready(() => {
|
|
|
if (sheet.zh_setting && sheet.zh_data) {
|
|
|
const sel = sheet.getSelections()[0];
|
|
|
if (!sel) return;
|
|
|
-
|
|
|
- const col = sheet.zh_setting.cols[sel.col];
|
|
|
- const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
- const orgValue = select[col.field];
|
|
|
- if (sel.colCount > 1) {
|
|
|
- toastr.warning('请勿同时删除多列数据');
|
|
|
- }
|
|
|
- if (orgValue === null || col.field === 'type' || col.field === 'is_summary') {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (col.field === 'weight_num') {
|
|
|
- if(materialExponentCol.readOnly.isConstant(select)) {
|
|
|
- return;
|
|
|
+ const sortData = sheet.zh_data || [];
|
|
|
+ const data = [];
|
|
|
+ for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
|
|
|
+ // let bPaste = true;
|
|
|
+ const exData = sortData[iRow];
|
|
|
+ const materialExData = { id: sortData[iRow].id };
|
|
|
+ for (let iCol = 0; iCol < sel.colCount; iCol++) {
|
|
|
+ const curCol = sel.col + iCol;
|
|
|
+ const colSetting = sheet.zh_setting.cols[curCol];
|
|
|
+ if (!colSetting) continue;
|
|
|
+ const orgValue = sortData[iRow][colSetting.field];
|
|
|
+ if(orgValue === null) {
|
|
|
+ // bPaste = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (exData.type === materialType.ex_type[0].value && colSetting.field !== 'weight_num') {
|
|
|
+ // bPaste = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (colSetting.field === 'type' || colSetting.field === 'calc_num' || colSetting.field === 'is_summary'){
|
|
|
+ // bPaste = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ materialExData[colSetting.field] = null;
|
|
|
+ sortData[iRow][colSetting.field] = null;
|
|
|
}
|
|
|
- } else {
|
|
|
- if(materialExponentCol.readOnly.isEdit(select)) {
|
|
|
- return
|
|
|
+ if (exData.type !== materialType.ex_type[0].value) materialExData.calc_num = materialExponentCol.getValue.calc_num(sortData[iRow]);
|
|
|
+ const arr = Object.keys(materialExData);
|
|
|
+ if (arr.length !== 1) {
|
|
|
+ data.push(materialExData);
|
|
|
}
|
|
|
}
|
|
|
- select[col.field] = null;
|
|
|
- select.calc_num = materialExponentCol.getValue.calc_num(select);
|
|
|
- // console.log(select);
|
|
|
+ if (data.length === 0) {
|
|
|
+ SpreadJsObj.reLoadSheetData(sheet);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // console.log(data);
|
|
|
// 更新至服务器
|
|
|
- postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
|
|
|
+ postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
|
|
|
+ materialExponentData = result.info;
|
|
|
+ SpreadJsObj.loadSheetData(materialExponentSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialExponentData);
|
|
|
ex_tp = result.ex_tp;
|
|
|
ex_expr = result.ex_expr;
|
|
|
resetExTpTable();
|
|
|
- SpreadJsObj.reLoadRowData(sheet, sel.row);
|
|
|
- materialExponentData.splice(sel.row, 1, select);
|
|
|
}, function () {
|
|
|
- select[col.field] = orgValue;
|
|
|
- SpreadJsObj.reLoadRowData(sheet, sel.row);
|
|
|
+ SpreadJsObj.reLoadSheetData(sheet);
|
|
|
+ return;
|
|
|
});
|
|
|
}
|
|
|
},
|
|
@@ -344,7 +359,6 @@ $(document).ready(() => {
|
|
|
continue;
|
|
|
}
|
|
|
const total_weight = ZhCalc.add(ZhCalc.sub(_.sumBy(materialExponentData, 'weight_num'), parseFloat(orgValue)), num);
|
|
|
- console.log(total_weight, _.sumBy(materialExponentData, 'weight_num'), orgValue, num);
|
|
|
if (total_weight > 1) {
|
|
|
toastMessageUniq(getPasteHint(hint.weightNumberCan, hintRow));
|
|
|
bPaste = false;
|