|
@@ -197,6 +197,7 @@ $(document).ready(() => {
|
|
|
|
|
|
const changeSpreadSetting = {
|
|
|
cols: [
|
|
|
+ {title: '新增单价', colSpan: '1', rowSpan: '2', field: 'new_up', hAlign: 1, width: 35, cellType: 'checkbox', readOnly: 'readOnly.isEdit'},
|
|
|
{title: '清单编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 110, formatter: '@', readOnly: 'readOnly.isEdit'},
|
|
|
{title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 130, formatter: '@', readOnly: 'readOnly.isEdit'},
|
|
|
{title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: 'readOnly.isEdit', cellType: 'unit', comboItems: changeUnits, comboEdit: true},
|
|
@@ -205,6 +206,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: '备注1', colSpan: '1', rowSpan: '2', field: 'ex_memo1', hAlign: 0, width: 110, formatter: '@', readOnly: 'readOnly.isEdit2'},
|
|
|
+ {title: '备注2', colSpan: '1', rowSpan: '2', field: 'ex_memo2', hAlign: 0, width: 110, formatter: '@', readOnly: 'readOnly.isEdit2'},
|
|
|
],
|
|
|
emptyRows: !readOnly ? 3 : 0,
|
|
|
headRows: 2,
|
|
@@ -212,7 +215,7 @@ $(document).ready(() => {
|
|
|
defaultRowHeight: 21,
|
|
|
headerFont: '12px 微软雅黑',
|
|
|
font: '12px 微软雅黑',
|
|
|
- readOnly: readOnly,
|
|
|
+ readOnly: change.status === auditConst.status.checking ? false : readOnly,
|
|
|
localCache: {
|
|
|
key: 'changes-apply-list-spread',
|
|
|
colWidth: true,
|
|
@@ -243,6 +246,9 @@ $(document).ready(() => {
|
|
|
isEdit: function (data) {
|
|
|
return readOnly;
|
|
|
},
|
|
|
+ isEdit2: function (data) {
|
|
|
+ return !(!readOnly || change.shenpiPower);
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
const changeSpreadObj = {
|
|
@@ -250,6 +256,8 @@ $(document).ready(() => {
|
|
|
// 增加汇总行并设为锁定禁止编辑状态
|
|
|
changeSpreadSheet.addRows(changeSpreadSheet.getRowCount(), 1);
|
|
|
changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 0, '合计');
|
|
|
+ const cellType1 = new GC.Spread.Sheets.CellTypes.Text();
|
|
|
+ changeSpreadSheet.getCell(changeSpreadSheet.getRowCount() - 1, 0).cellType(cellType1);
|
|
|
changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
|
|
|
changeSpreadObj.countSum();
|
|
|
},
|
|
@@ -258,11 +266,11 @@ $(document).ready(() => {
|
|
|
let oSum = 0,
|
|
|
cSum = 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));
|
|
|
+ oSum = ZhCalc.add(oSum, changeSpreadSheet.getValue(i, 6));
|
|
|
+ cSum = ZhCalc.add(cSum, changeSpreadSheet.getValue(i, 8));
|
|
|
}
|
|
|
- changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 5, oSum !== 0 ? oSum : null);
|
|
|
- changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 7, cSum !== 0 ? cSum : null);
|
|
|
+ changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 6, oSum !== 0 ? oSum : null);
|
|
|
+ changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 8, cSum !== 0 ? cSum : null);
|
|
|
},
|
|
|
deletePress: function (sheet) {
|
|
|
return;
|
|
@@ -378,11 +386,13 @@ $(document).ready(() => {
|
|
|
const sortData = info.sheet.zh_data || [];
|
|
|
const range = info.cellRange;
|
|
|
const data = [];
|
|
|
+ let haveNew = false;
|
|
|
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 = curRow >= sortData.length ? {unit: ''} : {id: sortData[curRow].id};
|
|
|
+ haveNew = curRow >= sortData.length ? curRow : false;
|
|
|
const hintRow = range.rowCount > 1 ? curRow : '';
|
|
|
let sameCol = 0;
|
|
|
for (let iCol = 0; iCol < range.colCount; iCol++) {
|
|
@@ -484,8 +494,35 @@ $(document).ready(() => {
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
+ changeSpreadObj.buttonClicked = function (e, info) {
|
|
|
+ if (info.sheet.zh_setting) {
|
|
|
+ const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
+ if(!select) {
|
|
|
+ toastr.error('请添加清单编号再勾选');
|
|
|
+ if (info.sheet.isEditing()) {
|
|
|
+ info.sheet.endEdit(true);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ } else if (col.field === 'new_up') {
|
|
|
+ if (info.sheet.isEditing()) {
|
|
|
+ info.sheet.endEdit(true);
|
|
|
+ }
|
|
|
+ select.new_up = info.sheet.getValue(info.row, info.col) ? 0 : 1;
|
|
|
+ postData(preUrl + '/list/save', { type: 'update', updateData: { id: select.id, new_up: select.new_up } }, function (result) {
|
|
|
+ changeList.splice(info.row, 1, select);
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ changeSpreadObj.countSum();
|
|
|
+ }, function () {
|
|
|
+ select.new_up = info.sheet.getValue(info.row, info.col) ? 1 : 0;
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
// changeSpread.bind(spreadNS.Events.CellChanged, changeSpreadObj.cellChanged);
|
|
|
changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
|
|
|
+ changeSpread.bind(spreadNS.Events.ButtonClicked, changeSpreadObj.buttonClicked);
|
|
|
changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
|
|
|
changeSpread.bind(spreadNS.Events.ValueChanged, changeSpreadObj.valueChanged);
|
|
|
SpreadJsObj.addDeleteBind(changeSpread, changeSpreadObj.deletePress);
|
|
@@ -620,6 +657,103 @@ $(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);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ select[col.field] = validText;
|
|
|
+ const data = {
|
|
|
+ id: select.id,
|
|
|
+ };
|
|
|
+ if (col.field === 'ex_memo1' || col.field === 'ex_memo2') {
|
|
|
+ data[col.field] = select[col.field];
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }, function () {
|
|
|
+ select[col.field] = orgValue;
|
|
|
+ if (col.field !== 'ex_memo1' && col.field !== 'ex_memo2') {
|
|
|
+ select.spamount = orgValue;
|
|
|
+ }
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ sortData[curRow][colSetting.field] = validText;
|
|
|
+ if (colSetting.field === 'ex_memo1' || colSetting.field === 'ex_memo2') {
|
|
|
+ cLData[colSetting.field] = validText;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (bPaste) {
|
|
|
+ data.push(cLData);
|
|
|
+ // rowData.push(curRow);
|
|
|
+ } else {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, curRow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (data.length === 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log(data);
|
|
|
+ // 更新至服务器
|
|
|
+ postData(preUrl + '/list/save', { type:'paste_amount_rows', 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;
|
|
|
+ });
|
|
|
+ };
|
|
|
+ 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;
|