|
@@ -7,6 +7,15 @@
|
|
|
* @date 2018/11/22
|
|
|
* @version
|
|
|
*/
|
|
|
+
|
|
|
+function getPasteHint (str, row = '') {
|
|
|
+ let returnObj = str;
|
|
|
+ if (row) {
|
|
|
+ returnObj.msg = '清单第' + (row+1) + '行' + str.msg;
|
|
|
+ }
|
|
|
+ return returnObj;
|
|
|
+}
|
|
|
+
|
|
|
$(document).ready(() => {
|
|
|
const changeSpreadSetting = {
|
|
|
cols: [
|
|
@@ -181,10 +190,22 @@ $(document).ready(() => {
|
|
|
return;
|
|
|
}
|
|
|
validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
|
|
|
+ // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
|
|
|
+ const usedInfo = _.find(changeUsedData, { id: select.id });
|
|
|
+ if (usedInfo && validText >= 0 && validText < usedInfo.used_qty) {
|
|
|
+ toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.used_qty);
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
|
|
|
+ return;
|
|
|
+ } else if (usedInfo && validText < 0 && validText > usedInfo.used_qty) {
|
|
|
+ toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.used_qty);
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
select[col.field] = validText;
|
|
|
select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
|
|
|
- console.log(select);
|
|
|
|
|
|
const data = {
|
|
|
id: select.id,
|
|
@@ -206,10 +227,11 @@ $(document).ready(() => {
|
|
|
}
|
|
|
},
|
|
|
clipboardPasted(e, info) {
|
|
|
- // const hint = {
|
|
|
- // cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
|
|
|
- // numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
|
|
|
- // };
|
|
|
+ const hint = {
|
|
|
+ cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
|
|
|
+ numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
|
|
|
+ qtyError: {type: 'error', msg: '变更数值必须大于等于已调用值'},
|
|
|
+ };
|
|
|
const range = info.cellRange;
|
|
|
const sortData = info.sheet.zh_data || [];
|
|
|
// console.log(info, range);
|
|
@@ -261,6 +283,21 @@ $(document).ready(() => {
|
|
|
continue;
|
|
|
}
|
|
|
validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
|
|
|
+ // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
|
|
|
+ const usedInfo = _.find(changeUsedData, { id: sortData[curRow].id });
|
|
|
+ if (usedInfo && usedInfo.used_qty >= 0 && validText < usedInfo.used_qty) {
|
|
|
+ toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.used_qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.used_qty);
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, curRow);
|
|
|
+ changeSpreadObj.setRowValueAndSum(sortData[curRow], curRow, curCol);
|
|
|
+ bPaste = false;
|
|
|
+ continue;
|
|
|
+ } else if (usedInfo && usedInfo.used_qty < 0 && validText > usedInfo.used_qty) {
|
|
|
+ toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须小于等于已调用值 ' + usedInfo.used_qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.used_qty);
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, curRow);
|
|
|
+ changeSpreadObj.setRowValueAndSum(sortData[curRow], curRow, curCol);
|
|
|
+ bPaste = false;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
// cLData[colSetting.field] = validText;
|
|
|
sortData[curRow][colSetting.field] = validText;
|
|
@@ -270,11 +307,11 @@ $(document).ready(() => {
|
|
|
data.push(cLData);
|
|
|
// rowData.push(curRow);
|
|
|
} else {
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, curRow);
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, curRow);
|
|
|
}
|
|
|
}
|
|
|
if (data.length === 0) {
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
+ // SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
|
|
|
return;
|
|
|
}
|
|
|
console.log(data);
|