|  | @@ -0,0 +1,386 @@
 | 
	
		
			
				|  |  | +'use strict';
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * 变更令详细页js
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * @author EllisRan.
 | 
	
		
			
				|  |  | + * @date 2018/11/22
 | 
	
		
			
				|  |  | + * @version
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +$(document).ready(() => {
 | 
	
		
			
				|  |  | +    const changeSpreadSetting = {
 | 
	
		
			
				|  |  | +        cols: [
 | 
	
		
			
				|  |  | +            {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: 'bwmx', hAlign: 0, width: 120, formatter: '@', readOnly: true},
 | 
	
		
			
				|  |  | +            {title: '变更详情', colSpan: '1', rowSpan: '2', field: 'detail', 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: '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, formatter: '@', 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, formatter: '@', type: 'Number', getValue: 'getValue.ca_tp', readOnly: true},
 | 
	
		
			
				|  |  | +        ],
 | 
	
		
			
				|  |  | +        emptyRows: 0,
 | 
	
		
			
				|  |  | +        headRows: 2,
 | 
	
		
			
				|  |  | +        headRowHeight: [25, 25],
 | 
	
		
			
				|  |  | +        defaultRowHeight: 21,
 | 
	
		
			
				|  |  | +        headerFont: '12px 微软雅黑',
 | 
	
		
			
				|  |  | +        font: '12px 微软雅黑',
 | 
	
		
			
				|  |  | +        // readOnly: 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)
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        const newColTp = {
 | 
	
		
			
				|  |  | +            title: '|金额',
 | 
	
		
			
				|  |  | +            colSpan: '|1', rowSpan: '|1',
 | 
	
		
			
				|  |  | +            field: 'sa_tp',
 | 
	
		
			
				|  |  | +            hAlign: 2, width: 80, formatter: '@', type: 'Number',
 | 
	
		
			
				|  |  | +            readOnly: true
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        changeSpreadSetting.cols.push(newColcount);
 | 
	
		
			
				|  |  | +        changeSpreadSetting.cols.push(newColTp);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    const changeCol = {
 | 
	
		
			
				|  |  | +        getValue: {
 | 
	
		
			
				|  |  | +            unit_price: function(data) {
 | 
	
		
			
				|  |  | +                return ZhCalc.round(data.unit_price, unitPriceUnit);
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +            oa_tp: function (data) {
 | 
	
		
			
				|  |  | +                return ZhCalc.round(ZhCalc.mul(data.unit_price, data.oamount), totalPriceUnit);
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +            ca_tp: function (data) {
 | 
	
		
			
				|  |  | +                return ZhCalc.round(ZhCalc.mul(data.unit_price, data.camount), totalPriceUnit);
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +            oamount: function (data) {
 | 
	
		
			
				|  |  | +                return ZhCalc.round(data.oamount, findDecimal(data.unit));
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +            camount: function (data) {
 | 
	
		
			
				|  |  | +                return ZhCalc.round(data.camount, findDecimal(data.unit));
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    const changeSpreadObj = {
 | 
	
		
			
				|  |  | +        makeSjsFooter: function () {
 | 
	
		
			
				|  |  | +            // 增加汇总行并设为锁定禁止编辑状态
 | 
	
		
			
				|  |  | +            changeSpreadSheet.addRows(changeSpreadSheet.getRowCount(), 1);
 | 
	
		
			
				|  |  | +            changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 0, '合计');
 | 
	
		
			
				|  |  | +            changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
 | 
	
		
			
				|  |  | +            changeSpreadObj.countSum();
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +        setAuditValue: function () {
 | 
	
		
			
				|  |  | +            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);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +        setRowValueAndSum: function (data, row, col) {
 | 
	
		
			
				|  |  | +            for (const j in aidList) {
 | 
	
		
			
				|  |  | +                const sum = ZhCalc.round(ZhCalc.mul(data.unit_price, parseFloat(changeSpreadSheet.getValue(row, 10 + parseInt(j)*2))), totalPriceUnit);
 | 
	
		
			
				|  |  | +                changeSpreadSheet.setValue(row, 11 + 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;
 | 
	
		
			
				|  |  | +            for(let i = 0; i < rowCount - 1; i++){
 | 
	
		
			
				|  |  | +                audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, col+1));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, col+1, audit_sum !== 0 ? audit_sum : null);
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +        countSum: function() {
 | 
	
		
			
				|  |  | +            const rowCount = changeSpreadSheet.getRowCount();
 | 
	
		
			
				|  |  | +            let oSum = 0,
 | 
	
		
			
				|  |  | +                cSum = 0;
 | 
	
		
			
				|  |  | +            for(let i = 0; i < rowCount - 1; i++){
 | 
	
		
			
				|  |  | +                oSum = ZhCalc.add(oSum, changeSpreadSheet.getValue(i, 7));
 | 
	
		
			
				|  |  | +                cSum = ZhCalc.add(cSum, changeSpreadSheet.getValue(i, 9));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 7, oSum !== 0 ? oSum : null);
 | 
	
		
			
				|  |  | +            changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 9, cSum !== 0 ? cSum : 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, 11 + j*2));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 11 + j*2, audit_sum !== 0 ? audit_sum : null);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +        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;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                select[col.field] = validText;
 | 
	
		
			
				|  |  | +                select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 | 
	
		
			
				|  |  | +                console.log(select);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                const data = {
 | 
	
		
			
				|  |  | +                    id: select.id,
 | 
	
		
			
				|  |  | +                    spamount: select.spamount,
 | 
	
		
			
				|  |  | +                };
 | 
	
		
			
				|  |  | +                console.log(data);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                // 更新至服务器
 | 
	
		
			
				|  |  | +                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: '不能粘贴其它非数字类型字符'},
 | 
	
		
			
				|  |  | +            // };
 | 
	
		
			
				|  |  | +            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;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    // 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;
 | 
	
		
			
				|  |  | +                SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
 | 
	
		
			
				|  |  | +                changeSpreadObj.setAuditValue();
 | 
	
		
			
				|  |  | +                changeSpreadObj.makeSjsFooter();
 | 
	
		
			
				|  |  | +            }, function () {
 | 
	
		
			
				|  |  | +                SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 | 
	
		
			
				|  |  | +                changeSpreadObj.setAuditValue();
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
 | 
	
		
			
				|  |  | +    SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
 | 
	
		
			
				|  |  | +    SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
 | 
	
		
			
				|  |  | +    changeSpreadObj.setAuditValue();
 | 
	
		
			
				|  |  | +    changeSpreadObj.makeSjsFooter();
 | 
	
		
			
				|  |  | +    const userIndex = aidList.indexOf(parseInt(accountId));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
 | 
	
		
			
				|  |  | +    changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // 审批提交与判断
 | 
	
		
			
				|  |  | +    $('.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');
 | 
	
		
			
				|  |  | +            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;
 | 
	
		
			
				|  |  | +}
 |