| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509 | 
							- 'use strict';
 
- /**
 
-  * 变更令详细页js
 
-  *
 
-  * @author EllisRan.
 
-  * @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: [
 
-             {title: '计价', colSpan: '1', rowSpan: '2', field: 'is_valuation', hAlign: 1, width: 50, cellType: 'checkbox', readOnly: true},
 
-             {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
 
-             {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120, formatter: '@', readOnly: true},
 
-             {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: true},
 
-             {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.unit_price', readOnly: true},
 
-             {title: '变更部位', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 120, formatter: '@', readOnly: true, getValue: 'getValue.bwmx'},
 
-             {title: '变更详情', colSpan: '1', rowSpan: '2', field: 'detail', hAlign: 0, width: 120, formatter: '@', readOnly: true},
 
-             {title: '计量上限(%)', colSpan: '1', rowSpan: '2', field: 'delimit', hAlign: 2, width: 60, formatter: '@', readOnly: true, visible: openChangeState},
 
-             {title: '原设计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'oamount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.oamount', readOnly: true},
 
-             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'oa_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.oa_tp', readOnly: true},
 
-             {title: '申请变更增(+)减(-)|数量', colSpan: '2|1', rowSpan: '1|1', field: 'camount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.camount', readOnly: true},
 
-             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'ca_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.ca_tp', readOnly: true},
 
-         ],
 
-         emptyRows: 0,
 
-         headRows: 2,
 
-         headRowHeight: [25, 25],
 
-         defaultRowHeight: 21,
 
-         headerFont: '12px 微软雅黑',
 
-         font: '12px 微软雅黑',
 
-         // readOnly: true,
 
-         rowHeader:[
 
-             {
 
-                 rowHeaderType: 'circle',
 
-                 setting: {
 
-                     size: 5,
 
-                     indent: 16,
 
-                     getColor: function (index, data) {
 
-                         if (!data) return;
 
-                         if (_.findIndex(changeLedgerList, { id: data.gcl_id }) !== -1 || _.findIndex(changePosList, { id: data.mx_id }) !== -1) {
 
-                             return '#dc3545';
 
-                         }
 
-                         if(data.lid != 0) return;
 
-                         return '#007bff';
 
-                     }
 
-                 },
 
-             },
 
-         ],
 
-         localCache: {
 
-             key: 'changes-spread',
 
-             colWidth: true,
 
-         }
 
-     };
 
-     for (const aid of aidList) {
 
-         const userinfo = _.find(auditList2, { 'uid': aid });
 
-         const newColcount = {
 
-             title: userinfo.name + ' 审批|数量',
 
-             colSpan: '2|1', rowSpan: '1|1',
 
-             field: 'audit_amount_' + aid,
 
-             hAlign: 2, width: 60, type: 'Number', readOnly: aid !== parseInt(accountId) ? true : 'readOnly.isSettle' ,
 
-         };
 
-         const newColTp = {
 
-             title: '|金额',
 
-             colSpan: '|1', rowSpan: '|1',
 
-             field: 'sa_tp_' + aid,
 
-             hAlign: 2, width: 80, type: 'Number',
 
-             readOnly: true
 
-         };
 
-         changeSpreadSetting.cols.push(newColcount);
 
-         changeSpreadSetting.cols.push(newColTp);
 
-     }
 
-     changeSpreadSetting.cols.push({title: '变更后|数量', colSpan: '2|1', rowSpan: '1|1', field: 'samount', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue: 'getValue.changed_amount'});
 
-     changeSpreadSetting.cols.push({title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sa_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.changed_tp'});
 
-     changeSpreadSetting.getColor = function (sheet, data, row, col, defaultColor) {
 
-         return checkIsSettle(data) ? spreadColor.stage.settle : defaultColor;
 
-     }
 
-     const changeCol = {
 
-         getValue: {
 
-             unit_price: function(data) {
 
-                 return ZhCalc.round(data.unit_price, unitPriceUnit);
 
-             },
 
-             oa_tp: function (data) {
 
-                 return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.oamount, findDecimal(data.unit))), totalPriceUnit);
 
-             },
 
-             ca_tp: function (data) {
 
-                 return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.camount, findDecimal(data.unit))), totalPriceUnit);
 
-             },
 
-             oamount: function (data) {
 
-                 return ZhCalc.round(data.oamount, findDecimal(data.unit));
 
-             },
 
-             camount: function (data) {
 
-                 return ZhCalc.round(data.camount, findDecimal(data.unit));
 
-             },
 
-             changed_amount: function (data) {
 
-                 return ZhCalc.round(ZhCalc.add(data.oamount, data.spamount), findDecimal(data.unit));
 
-             },
 
-             changed_tp: function (data) {
 
-                 return ZhCalc.add(ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.oamount, findDecimal(data.unit))), totalPriceUnit),
 
-                     ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.spamount, findDecimal(data.unit))), totalPriceUnit));
 
-             },
 
-             bwmx: function (data) {
 
-                 return data.bwmx ? data.bwmx : (data.xmj_jldy ? data.xmj_jldy : '');
 
-             }
 
-         },
 
-         readOnly: {
 
-             isSettle: function (data) {
 
-                 return checkIsSettle(data);
 
-             }
 
-         }
 
-     };
 
-     const changeSpreadObj = {
 
-         makeSjsFooter: function () {
 
-             // 增加汇总行并设为锁定禁止编辑状态
 
-             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();
 
-         },
 
-         setAuditValue: function () {
 
-             for (const c  of changeList) {
 
-                 for (const j of aidList) {
 
-                     c['audit_amount_' + j] = ZhCalc.round(c['audit_amount_' + j], findDecimal(c.unit));
 
-                     c['sa_tp_' + j] = ZhCalc.round(ZhCalc.mul(c['audit_amount_' + j], ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit);
 
-                 }
 
-             }
 
-             // const rowCount = changeSpreadSheet.getRowCount();
 
-             // // 用户的数据合计
 
-             // for (const j in aidList) {
 
-             //     for(let i = 0; i <= rowCount - 1; i++){
 
-             //         const data = {
 
-             //             unit_price: changeSpreadSheet.getValue(i, 5),
 
-             //             amount: parseFloat(changeSpreadSheet.getValue(i, 10 + parseInt(j)*2)),
 
-             //         };
 
-             //         const sum = ZhCalc.round(ZhCalc.mul(data.unit_price, data.amount), totalPriceUnit);
 
-             //         changeSpreadSheet.setValue(i, 11 + j*2, sum !== 0 ? sum : null);
 
-             //     }
 
-             // }
 
-         },
 
-         resetXmjSpread: function(data = null) {
 
-             const xmj = [];
 
-             if (data && data.lid != 0 && data.xmj_code !== '' && data.xmj_code !== null) {
 
-                 if (data.bwmx === data.xmj_jldy) {
 
-                     data.bwmx = '';
 
-                 }
 
-                 xmj.push(data);
 
-             }
 
-             SpreadJsObj.loadSheetData(xmjSpread.getActiveSheet(), SpreadJsObj.DataType.Data, xmj);
 
-         },
 
-         selectionChanged: function (e, info) {
 
-             const sel = info.sheet.getSelections()[0];
 
-             const col = info.sheet.zh_setting.cols[sel.col];
 
-             const data = SpreadJsObj.getSelectObject(info.sheet);
 
-             if (col && col.field === 'camount' && data) {
 
-                 $('#camount-expr').val(data.camount_expr ? data.camount_expr : data.camount);
 
-             } else {
 
-                 $('#camount-expr').val('');
 
-             }
 
-             changeSpreadObj.resetXmjSpread(data);
 
-         },
 
-         setRowValueAndSum: function (data, row, col) {
 
-             for (const j in aidList) {
 
-                 const sum = ZhCalc.round(ZhCalc.mul(data.unit_price, parseFloat(changeSpreadSheet.getValue(row, startLimit + 3 + parseInt(j)*2))), totalPriceUnit);
 
-                 changeSpreadSheet.setValue(row, startLimit + 4 + j*2, sum !== 0 ? sum : null);
 
-             }
 
-             // const sum = ZhCalc.round(ZhCalc.mul(data.unit_price, data.spamount), totalPriceUnit);
 
-             // changeSpreadSheet.setValue(row, col+1, sum !== 0 ? sum : null);
 
-             const rowCount = changeSpreadSheet.getRowCount();
 
-             // 用户的数据合计
 
-             // 变更后数据合计
 
-             let audit_sum = 0;
 
-             let changed_sum = 0;
 
-             for(let i = 0; i < rowCount - 1; i++){
 
-                 audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, col+1));
 
-                 changed_sum = ZhCalc.add(changed_sum, changeSpreadSheet.getValue(i, (startLimit + 4 + aidList.length*2)));
 
-             }
 
-             changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, col+1, audit_sum !== 0 ? audit_sum : null);
 
-             changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, (startLimit + 4 + aidList.length*2), changed_sum !== 0 ? changed_sum : null);
 
-         },
 
-         countSum: function() {
 
-             const rowCount = changeSpreadSheet.getRowCount();
 
-             let oSum = 0,
 
-                 cSum = 0,
 
-                 cdSum = 0;
 
-             for(let i = 0; i < rowCount - 1; i++){
 
-                 oSum = ZhCalc.add(oSum, changeSpreadSheet.getValue(i, startLimit));
 
-                 cSum = ZhCalc.add(cSum, changeSpreadSheet.getValue(i, startLimit + 2));
 
-                 cdSum = ZhCalc.add(cdSum, changeSpreadSheet.getValue(i, (startLimit + 4 + aidList.length*2)));
 
-             }
 
-             changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, startLimit, oSum !== 0 ? oSum : null);
 
-             changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, startLimit + 2, cSum !== 0 ? cSum : null);
 
-             changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, (startLimit + 4 + aidList.length*2), cdSum !== 0 ? cdSum : null);
 
-             // 用户的数据合计
 
-             for (const j in aidList) {
 
-                 let audit_sum = 0;
 
-                 for(let i = 0; i < rowCount - 1; i++){
 
-                     audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, startLimit + 4 + j*2));
 
-                 }
 
-                 changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, startLimit + 4 + j*2, audit_sum !== 0 ? audit_sum : null);
 
-             }
 
-         },
 
-         deletePress: function (sheet) {
 
-             return;
 
-         },
 
-         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);
 
-                     changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
 
-                     return;
 
-                 }
 
-                 // 判断部分值是否输入的是数字判断和数据计算
 
-                 if (col.type === 'Number') {
 
-                     if (isNaN(validText)) {
 
-                         toastr.error('不能输入其它非数字类型字符');
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
 
-                         return;
 
-                     }
 
-                     validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-                     // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                     const usedInfo = _.find(changeUsedData, { cbid: select.id });
 
-                     if (usedInfo && validText >= 0 && validText < usedInfo.qty) {
 
-                         toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
 
-                         return;
 
-                     } else if (usedInfo && validText < 0 && validText > usedInfo.qty) {
 
-                         toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.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;
 
-                 const data = {
 
-                     id: select.id,
 
-                     spamount: select.spamount,
 
-                 };
 
-                 console.log(data, select);
 
-                 // 更新至服务器
 
-                 postData(window.location.pathname + '/save', { type:'update', updateData: data }, function (result) {
 
-                     changeList.splice(info.row, 1, select);
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
 
-                 }, function () {
 
-                     select[col.field] = orgValue;
 
-                     select.spamount = orgValue;
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
 
-                 });
 
-             }
 
-         },
 
-         clipboardPasted(e, info) {
 
-             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);
 
-             // if (info.cellRange.row + info.cellRange.rowCount > sortData.length) {
 
-             //     toastMessageUniq(hint.cellError);
 
-             //     // SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
 
-             //     SpreadJsObj.reLoadSheetHeader(changeSpreadSheet);
 
-             //     SpreadJsObj.reLoadSheetData(changeSpreadSheet);
 
-             //     changeSpreadObj.setAuditValue();
 
-             //     changeSpreadObj.makeSjsFooter();
 
-             //     return;
 
-             // }
 
-             // if (sortData.length > 0 && range.col + range.colCount > 10) {
 
-             //     toastMessageUniq(hint.cellError);
 
-             //     SpreadJsObj.reLoadSheetHeader(changeSpreadSheet);
 
-             //     SpreadJsObj.reLoadSheetData(changeSpreadSheet);
 
-             //     changeSpreadObj.setAuditValue();
 
-             //     changeSpreadObj.makeSjsFooter();
 
-             //     return;
 
-             // }
 
-             const data = [];
 
-             // const rowData = [];
 
-             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;
 
-                     }
 
-                     if (colSetting.type === 'Number') {
 
-                         if (isNaN(validText)) {
 
-                             toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
 
-                         // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                         const usedInfo = _.find(changeUsedData, { id: sortData[curRow].id });
 
-                         if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
 
-                             toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                             SpreadJsObj.reLoadRowData(info.sheet, curRow);
 
-                             changeSpreadObj.setRowValueAndSum(sortData[curRow], curRow, curCol);
 
-                             bPaste = false;
 
-                             continue;
 
-                         } else if (usedInfo && usedInfo.qty < 0 && validText > usedInfo.qty) {
 
-                             toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须小于等于已调用值 ' + usedInfo.qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                             SpreadJsObj.reLoadRowData(info.sheet, curRow);
 
-                             changeSpreadObj.setRowValueAndSum(sortData[curRow], curRow, curCol);
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                     }
 
-                     // cLData[colSetting.field] = validText;
 
-                     sortData[curRow][colSetting.field] = validText;
 
-                     cLData.spamount = validText;
 
-                 }
 
-                 if (bPaste) {
 
-                     data.push(cLData);
 
-                     // rowData.push(curRow);
 
-                 } else {
 
-                     // SpreadJsObj.reLoadRowData(info.sheet, curRow);
 
-                 }
 
-             }
 
-             if (data.length === 0) {
 
-                 // SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             }
 
-             console.log(data);
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'paste_amount_rows', updateData: data }, function (result) {
 
-                 changeList = result;
 
-                 changeSpreadObj.setAuditValue();
 
-                 SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
 
-                 changeSpreadObj.makeSjsFooter();
 
-                 changeSpreadObj.resetXmjSpread(SpreadJsObj.getSelectObject(changeSpreadSheet));
 
-             }, function () {
 
-                 changeSpreadObj.setAuditValue();
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             });
 
-         },
 
-     };
 
-     SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
 
-     SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
 
-     changeSpreadObj.setAuditValue();
 
-     SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
 
-     console.log(changeList);
 
-     changeSpreadObj.makeSjsFooter();
 
-     changeSpreadObj.resetXmjSpread(SpreadJsObj.getSelectObject(changeSpreadSheet));
 
-     const userIndex = aidList.indexOf(parseInt(accountId));
 
-     changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
 
-     changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
 
-     changeSpread.bind(spreadNS.Events.SelectionChanged, changeSpreadObj.selectionChanged);
 
-     SpreadJsObj.addDeleteBind(changeSpread, changeSpreadObj.deletePress);
 
-     // 审批提交与判断
 
-     $('.approval-btn').on('click', function () {
 
-         // 判断审批状态
 
-         let returnflag = true;
 
-         if ($(this).hasClass('btn-success')) {
 
-             const sdesc = $('#success-approval').find('textarea').val();
 
-             if (sdesc === '') {
 
-                 toastr.error('审批意见不能为空!');
 
-                 returnflag = false;
 
-             }
 
-             if ($('input[name="p_code"]').val() === '') {
 
-                 toastr.error('变更令号(批复编号)不能为空!');
 
-                 returnflag = false;
 
-             } else if ($('input[name="p_code"]').val() !== undefined) {
 
-                 $('input[name="p_code"]').val($.trim($('input[name="p_code"]').val()));
 
-                 const postData = {
 
-                     p_code: $('input[name="p_code"]').val(),
 
-                 };
 
-                 postDataWithAsync('/tender/' + $('#tenderId').val() + '/change/' + $('#changeId').val() + '/check/codeRepeat',postData, function (result) {
 
-                 }, function (data) {
 
-                     returnflag = false;
 
-                 });
 
-             }
 
-             // 判断并提交变更清单表格数据到表单中
 
-             const clist = [];
 
-             for(const [i,cl] of changeList.entries()) {
 
-                 // if (cl['audit_amount_' + accountId] === null || cl['audit_amount_' + accountId] === '') {
 
-                 //     toastr.error('清单第' + (i+1) + '行审批变更数量不能为空');
 
-                 //     returnflag = false;
 
-                 // } else {
 
-                 clist.push(cl.id + '_' + cl['audit_amount_' + accountId]);
 
-                 // }
 
-             }
 
-             $('#change-list-approval').val(clist.join(','));
 
-             if(returnflag) {
 
-                 $('input[name="w_code"]').val($.trim($('#w_code').val()));
 
-                 $('#success-approval').find('textarea').val(sdesc.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' '));
 
-                 if ($('#warning-text').length) $('#warning-text').remove()
 
-                 $('#success-approval').submit();
 
-             }
 
-         } else {
 
-             const sdesc = $('#fail-approval').find('textarea').val();
 
-             if (sdesc === '') {
 
-                 toastr.error('审批意见不能为空!');
 
-                 returnflag = false;
 
-             }
 
-             const type = $('#fail-approval').find('input[name="status"]:checked').val();
 
-             if (type === undefined) {
 
-                 // toastr.error('请选择退回类型!');
 
-                 if (!$('#warning-text').length) {
 
-                     $('#change-back-content').prepend('<p id="warning-text" style="color: red; margin: 0;">请选择退回流程</p>');
 
-                 }
 
-                 returnflag = false;
 
-             }
 
-             if(returnflag) {
 
-                 $('#fail-approval').find('textarea').val(sdesc.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' '));
 
-                 $('input[name="w_code"]').val($.trim($('#w_code').val()));
 
-                 $('#fail-approval').submit();
 
-             }
 
-         }
 
-     })
 
- });
 
- const postDataWithAsync = function (url, data, successCallback, errorCallBack, showWaiting = true) {
 
-     if (showWaiting) showWaitingView();
 
-     $.ajax({
 
-         type:"POST",
 
-         url: url,
 
-         data: {'data': JSON.stringify(data)},
 
-         dataType: 'json',
 
-         cache: false,
 
-         async: false,
 
-         timeout: 60000,
 
-         beforeSend: function(xhr) {
 
-             let csrfToken = Cookies.get('csrfToken_j');
 
-             xhr.setRequestHeader('x-csrf-token', csrfToken);
 
-         },
 
-         success: function(result){
 
-             if (result.err === 0) {
 
-                 if (successCallback) {
 
-                     successCallback(result.data);
 
-                 }
 
-             } else {
 
-                 toastr.error(result.msg);
 
-                 if (errorCallBack) {
 
-                     errorCallBack(result.msg);
 
-                 }
 
-             }
 
-             if (showWaiting) closeWaitingView();
 
-         },
 
-         error: function(jqXHR, textStatus, errorThrown){
 
-             toastr.error('error: ' + textStatus + " " + errorThrown);
 
-             if (errorCallBack) {
 
-                 errorCallBack();
 
-             }
 
-             if (showWaiting) closeWaitingView();
 
-         }
 
-     });
 
- };
 
- function auditCheck(i) {
 
-     const inlineRadio1 = $('#change-back:checked').val()
 
-     const inlineRadio2 = $('#chagne-backnew:checked').val()
 
-     const opinion = $('textarea[name="sdesc"]').eq(i).val().replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
 
-     $('textarea[name="sdesc"]').eq(i).val(opinion);
 
-     if (i === 1) {
 
-         if (!inlineRadio1 && !inlineRadio2) {
 
-             if (!$('#warning-text').length) {
 
-                 $('#reject-process').prepend('<p id="warning-text" style="color: red; margin: 0;">请选择退回流程</p>');
 
-             }
 
-             return false;
 
-         }
 
-         if ($('#warning-text').length) $('#warning-text').remove()
 
-     }
 
-     return true;
 
- }
 
 
  |