|
@@ -29,11 +29,14 @@ function loadUpdateDealPays(newPay, fields) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function makeAttTable(id, attachment) {
|
|
|
+function makeAttTable(payNode) {
|
|
|
+ const id = payNode.id, attachment = payNode.attachment;
|
|
|
let html = '';
|
|
|
if (attachment !== null) {
|
|
|
for (const [index, att] of attachment.entries()) {
|
|
|
- const delhtml = uploadPermission && parseInt(att.uid) === parseInt(userID) ? '<a class="delete-att text-danger" href="javascript:void(0);" data-payid="'+ id +'" data-attindex="'+ index +'" title="删除"><i class="fa fa-remove "></i></a>' : '';
|
|
|
+ const delhtml = !readOnly && uploadPermission && (parseInt(att.uid) === userID || payNode.uid === userID || (payNode.uid === -1 && userID === stage.user_id))
|
|
|
+ ? '<a class="delete-att text-danger" href="javascript:void(0);" data-payid="'+ id +'" data-attindex="'+ index +'" title="删除"><i class="fa fa-remove "></i></a>'
|
|
|
+ : '';
|
|
|
html += '<tr><td style="width: 200px">' + att.filename + att.fileext + '</td><td>' + att.username + '</td><td>' + att.in_time + '</td>' +
|
|
|
'<td><a href="/tender/'+ tender.id + '/measure/stage/' + tender.ledger_times +'/pay/download/file/'+ id +'/'+ index +'" title="下载"><i class="fa fa-download "></i></a> ' +
|
|
|
delhtml +
|
|
@@ -45,8 +48,44 @@ function makeAttTable(id, attachment) {
|
|
|
|
|
|
$(document).ready(() => {
|
|
|
autoFlashHeight();
|
|
|
+ const payCalc = (function (b) {
|
|
|
+ class PayCalc {
|
|
|
+ constructor (bases) {
|
|
|
+ this.percentReg = /[0-9]+%/g;
|
|
|
+ this.bases = bases;
|
|
|
+ this.bases.sort(function (a, b) {
|
|
|
+ return a.sort - b.sort;
|
|
|
+ });
|
|
|
+ for (const b of this.bases) {
|
|
|
+ b.reg = new RegExp(b.code, 'igm');
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ calculateExpr(expr) {
|
|
|
+ let formula = expr;
|
|
|
+ for (const b of this.bases) {
|
|
|
+ formula = formula.replace(b.reg, b.value);
|
|
|
+ }
|
|
|
+ const percent = formula.match(this.percentReg);
|
|
|
+ if (percent) {
|
|
|
+ for (const p of percent) {
|
|
|
+ const v = math.eval(p.replace('%', '/100'));
|
|
|
+ formula = formula.replace(p, v);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ const value = math.eval(formula);
|
|
|
+ return value;
|
|
|
+ } catch(err) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return new PayCalc(b);
|
|
|
+ })(calcBase);
|
|
|
const paySpread = SpreadJsObj.createNewSpread($('#pay-spread')[0]);
|
|
|
+ const wcPay = dealPay.find(function (x) {return x.ptype === 4});
|
|
|
|
|
|
$.subMenu({
|
|
|
menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
|
|
@@ -88,7 +127,7 @@ $(document).ready(() => {
|
|
|
pos: SpreadJsObj.getObjPos($('#pay-spread')[0]),
|
|
|
};
|
|
|
paySpreadSetting.imageClick = function (data) {
|
|
|
- makeAttTable(data.id, data.attachment);
|
|
|
+ makeAttTable(data);
|
|
|
$('#file').modal('show');
|
|
|
};
|
|
|
paySpreadSetting.getColor = function (sheet, data, col, defaultColor) {
|
|
@@ -106,6 +145,42 @@ $(document).ready(() => {
|
|
|
return defaultColor;
|
|
|
}
|
|
|
};
|
|
|
+ const payBase = {
|
|
|
+ isNonZero: function (num) {
|
|
|
+ return !(!num || num === 0)
|
|
|
+ },
|
|
|
+ isYF: function (data) {
|
|
|
+ return data.ptype === 2;
|
|
|
+ },
|
|
|
+ isWC: function (data) {
|
|
|
+ return data.ptype === 4;
|
|
|
+ },
|
|
|
+ isSF: function (data) {
|
|
|
+ return data.ptype === 3;
|
|
|
+ },
|
|
|
+ isSpecial: function (data) {
|
|
|
+ return data.ptype !== 1;
|
|
|
+ },
|
|
|
+ isOld: function (data) {
|
|
|
+ if (data.csorder === 0 && payBase.isYB) {
|
|
|
+ return stage.order > 1;
|
|
|
+ } else {
|
|
|
+ return stage.order > data.csorder;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ isYB: function () {
|
|
|
+ return userID === stage.user_id;
|
|
|
+ },
|
|
|
+ isOwner: function (data) {
|
|
|
+ return data.uid === 0 ? payCol.isYB() : data.uid === userID;
|
|
|
+ },
|
|
|
+ isStarted: function (data) {
|
|
|
+ return data.pre_used;
|
|
|
+ },
|
|
|
+ isFinish: function (data) {
|
|
|
+ return data.pre_finish;
|
|
|
+ }
|
|
|
+ };
|
|
|
const payCol = {
|
|
|
getValue: {
|
|
|
attachment: function (data) {
|
|
@@ -123,79 +198,243 @@ $(document).ready(() => {
|
|
|
},
|
|
|
},
|
|
|
readOnly: {
|
|
|
- isNonZero: function (num) {
|
|
|
- return !(!num || num === 0)
|
|
|
- },
|
|
|
- isYF: function (data) {
|
|
|
- return data.ptype === 2;
|
|
|
- },
|
|
|
- isSpecial: function (data) {
|
|
|
- return data.ptype !== 1;
|
|
|
- },
|
|
|
- isOld: function (data) {
|
|
|
- if (data.csorder === 0 && payCol.readOnly.isYB(data)) {
|
|
|
- return stage.order > 1 || stage.times > 1 || stage.curOrder > 0;
|
|
|
- } else {
|
|
|
- return stage.order > data.csorder || stage.times > data.cstimes || stage.curOrder > data.csaorder;
|
|
|
- }
|
|
|
- },
|
|
|
- isYB: function (data) {
|
|
|
- return (stage.status === 1 || stage.status === 4);
|
|
|
- },
|
|
|
- isStarted: function (data) {
|
|
|
- return ((payCol.readOnly.isNonZero(data.end_tp) || payCol.readOnly.isNonZero(data.tp)) && data.tp !== data.end_tp) || payCol.readOnly.isNonZero(data.pre_tp) || data.pre_used;
|
|
|
- },
|
|
|
name: function (data) {
|
|
|
- return payCol.readOnly.isSpecial(data); //所有人,轮到自己时,均可修改
|
|
|
+ return payBase.isSpecial(data);
|
|
|
},
|
|
|
minus: function (data) {
|
|
|
- if (payCol.readOnly.isOld(data)) { // 上报或审批后,仅原报,在未开始计量前,可修改
|
|
|
- return payCol.readOnly.isSpecial(data) || payCol.readOnly.isStarted(data) || !payCol.readOnly.isYB(data);
|
|
|
- } else { // 新增时,新增人可修改
|
|
|
- return payCol.readOnly.isSpecial(data);
|
|
|
+ if (payBase.isOld(data)) {
|
|
|
+ return payBase.isSpecial(data) || payBase.isStarted(data) || !payBase.isYB();
|
|
|
+ } else {
|
|
|
+ return !(payBase.isOwner(data) || payBase.isYB(data));
|
|
|
}
|
|
|
},
|
|
|
tp: function (data) {
|
|
|
- return data.ptype === 2 || data.ptype === 4; // 仅本期完成计量、本期应付,不可修改
|
|
|
+ return payBase.isWC(data) || payBase.isYF(data);
|
|
|
},
|
|
|
sprice: function (data) {
|
|
|
- if (payCol.readOnly.isOld(data)) { // 上报或审批后,仅原报,在未开始计量前,可修改
|
|
|
- return payCol.readOnly.isYF(data) || payCol.readOnly.isStarted(data) || !payCol.readOnly.isYB(data);
|
|
|
- } else { // 新增时,新增人可修改
|
|
|
- return payCol.readOnly.isSpecial(data);
|
|
|
+ if (payBase.isOld(data)) {
|
|
|
+ return payBase.isStarted(data) || !payBase.isYB(data);
|
|
|
+ } else {
|
|
|
+ return payBase.isWC(data) || payBase.isSF(data) || !(payBase.isOwner(data) || payBase.isYB());
|
|
|
}
|
|
|
},
|
|
|
rprice: function (data) {
|
|
|
- return payCol.readOnly.sprice(data); // 同起扣金额
|
|
|
+ if (payBase.isOld(data)) {
|
|
|
+ return !payBase.isYB(data);
|
|
|
+ } else {
|
|
|
+ return payBase.isWC(data) || payBase.isSF(data) && !(payBase.isOwner(data) || payBase.isYB());
|
|
|
+ }
|
|
|
},
|
|
|
+ },
|
|
|
+ menuVisible: {
|
|
|
pause: function (data) {
|
|
|
- if (payCol.readOnly.isOld(data)) { // 上报或审批后,仅原报,可修改
|
|
|
- return payCol.readOnly.isSpecial(data) || !payCol.readOnly.isYB(data);
|
|
|
- } else { // 新增时,新增人可修改
|
|
|
- return payCol.readOnly.isSpecial(data);
|
|
|
+ if (payBase.isOld(data)) {
|
|
|
+ return payBase.isYB(data);
|
|
|
+ } else {
|
|
|
+ return payBase.isOwner(data) || payBase.isYB();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ deadline: function (data) {
|
|
|
+ if (payBase.isOld(data)) {
|
|
|
+ return !payBase.isFinish(data) && payBase.isYB();
|
|
|
+ } else {
|
|
|
+ return payBase.isOwner(data) || payBase.isYB();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ belongYF: function (data) {
|
|
|
+ if (payBase.isOld(data)) {
|
|
|
+ return !payBase.isStarted(data) && payBase.isYB(data);
|
|
|
+ } else {
|
|
|
+ return payBase.isOwner(data) || payBase.isYB(data);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
};
|
|
|
SpreadJsObj.initSpreadSettingEvents(paySpreadSetting, payCol);
|
|
|
SpreadJsObj.initSheet(paySpread.getActiveSheet(), paySpreadSetting);
|
|
|
SpreadJsObj.loadSheetData(paySpread.getActiveSheet(), SpreadJsObj.DataType.Data, dealPay);
|
|
|
|
|
|
const paySpreadObj = {
|
|
|
- _checkExpr: function (text, data, priceField, exprField) {
|
|
|
+ _checkExprValid(expr, invalidParam) {
|
|
|
+ if (!expr) return [true, null];
|
|
|
+ const param = [];
|
|
|
+ let num = '', base = '';
|
|
|
+ for (let i = 0, iLen = expr.length; i < iLen; i++) {
|
|
|
+ if (/^[\d\.%]+/.test(expr[i])) {
|
|
|
+ if (base !== '') {
|
|
|
+ param.push({type: 'base', value: base});
|
|
|
+ base = '';
|
|
|
+ }
|
|
|
+ num = num + expr[i];
|
|
|
+ } else if (/^[a-z]/.test(expr[i])) {
|
|
|
+ if (num !== '') {
|
|
|
+ param.push({type: 'num', value: num});
|
|
|
+ base = '';
|
|
|
+ }
|
|
|
+ base = base + expr[i];
|
|
|
+ } else if (expr[i] === '(') {
|
|
|
+ if (num !== '') {
|
|
|
+ param.push({type: 'num', value: num});
|
|
|
+ base = '';
|
|
|
+ }
|
|
|
+ if (base !== '') {
|
|
|
+ param.push({type: 'base', value: base});
|
|
|
+ base = '';
|
|
|
+ }
|
|
|
+ param.push({type: 'left', value: '('});
|
|
|
+ } else if (expr[i] === ')') {
|
|
|
+ if (num !== '') {
|
|
|
+ param.push({type: 'num', value: num});
|
|
|
+ base = '';
|
|
|
+ }
|
|
|
+ if (base !== '') {
|
|
|
+ param.push({type: 'base', value: base});
|
|
|
+ base = '';
|
|
|
+ }
|
|
|
+ param.push({type: 'right', value: ')'});
|
|
|
+ } else if (/^[\+\-*\/]/.test(expr[i])) {
|
|
|
+ if (num !== '') {
|
|
|
+ param.push({type: 'num', value: num});
|
|
|
+ base = '';
|
|
|
+ }
|
|
|
+ if (base !== '') {
|
|
|
+ param.push({type: 'base', value: base});
|
|
|
+ base = '';
|
|
|
+ }
|
|
|
+ param.push({type: 'calc', value: expr[i]});
|
|
|
+ } else {
|
|
|
+ return [false, '输入的表达式含有非法字符: ' + expr[i]];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (num !== '') {
|
|
|
+ param.push({type: 'num', value: num});
|
|
|
+ base = '';
|
|
|
+ }
|
|
|
+ if (base !== '') {
|
|
|
+ param.push({type: 'base', value: base});
|
|
|
+ base = '';
|
|
|
+ }
|
|
|
+ if (param.length === 0) return true;
|
|
|
+ if (param.length > 1) {
|
|
|
+ if (param[0].value === '-') {
|
|
|
+ param[1].value = '-' + param[1];
|
|
|
+ }
|
|
|
+ param.unshift();
|
|
|
+ }
|
|
|
+ const iLen = param.length;
|
|
|
+ let iLeftCount = 0, iRightCount = 0;
|
|
|
+ for (const [i, p] of param.entries()) {
|
|
|
+ if (p.type === 'calc') {
|
|
|
+ if (i === 0 || i === iLen - 1)
|
|
|
+ return [false, '输入的表达式非法:计算符号' + p.value + '前后应有数字或计算基数'];
|
|
|
+ }
|
|
|
+ if (p.type === 'num') {
|
|
|
+ num = p.value.replace('%', '');
|
|
|
+ if (p.value.length - num.length > 1)
|
|
|
+ return [false, '输入的表达式非法:' + p.value + '不是一个有效的数字'];
|
|
|
+ num = _.toNumber(num);
|
|
|
+ if (num === undefined || num === null || _.isNaN(num))
|
|
|
+ return [false, '输入的表达式非法:' + p.value + '不是一个有效的数字'];
|
|
|
+ if (i > 0) {
|
|
|
+ if (param[i - 1].type !== 'calc') {
|
|
|
+ return [false, '输入的表达式非法:' + p.value + '前应有运算符'];
|
|
|
+ } else if (param[i - 1].value === '/' && num === 0) {
|
|
|
+ return [false, '输入的表达式非法:请勿除0'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (p.type === 'base') {
|
|
|
+ const baseParam = _.find(calcBase, {code: p.value});
|
|
|
+ if (!baseParam)
|
|
|
+ return [false, '输入的表达式非法:不存在计算基数' + p.value];
|
|
|
+ if (invalidParam && invalidParam.indexOf(p.value) >= 0)
|
|
|
+ return [false, '不可使用计算基数' + p.value];
|
|
|
+ if (i > 0 && param[i - 1].type === 'calc')
|
|
|
+ return [false, '输入的表达式非法:' + p.value + '前应有运算符'];
|
|
|
+ }
|
|
|
+ if (p.type === 'left') {
|
|
|
+ iLeftCount += 1;
|
|
|
+ if (i !== 0 && param[i-1].type !== 'calc')
|
|
|
+ return [false, '输入的表达式非法:(前应有运算符'];
|
|
|
+ }
|
|
|
+ if (p.type === 'right') {
|
|
|
+ iRightCount += 1;
|
|
|
+ if (i !== iLen - 1 && param[i+1].type !== 'calc')
|
|
|
+ return [false, '输入的表达式非法:)后应有运算符'];
|
|
|
+ if (iRightCount > iLeftCount)
|
|
|
+ return [false, '输入的表达式非法:")"前无对应的"("'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (iLeftCount > iRightCount)
|
|
|
+ return [false, '输入的表达式非法:"("后无对应的")"'];
|
|
|
+ return [true, ''];
|
|
|
+ },
|
|
|
+ _checkSExpr: function (payNode, text, data) {
|
|
|
+ if (!payNode) return [false, '数据错误'];
|
|
|
+
|
|
|
+ const num = text ? _.toNumber(text) : null;
|
|
|
+ let expr = text ? (num ? null : text) : null;
|
|
|
+ expr = expr ? expr.replace('=', '').toLowerCase(): null;
|
|
|
+ const [valid, msg] = this._checkExprValid(expr, ['bqwc', 'ybbqwc']);
|
|
|
+ if (!valid) return [valid, msg];
|
|
|
+
|
|
|
+ if (payBase.isStarted(payNode)) {
|
|
|
+ return [false, '已经开始计量,请勿修改起扣金额'];
|
|
|
+ } else {
|
|
|
+ if (stage.order > 1) {
|
|
|
+ const value = expr ? payCalc.calculateExpr(expr) : num;
|
|
|
+ if (wcPay.pre_tp && value < wcPay.pre_tp)
|
|
|
+ return [false, '已进行到第' + stage.order + '期,起扣金额请勿少于本期完成截止上期计量金额' + wcPay.pre_tp];
|
|
|
+ data.sprice = num;
|
|
|
+ data.sexpr = expr;
|
|
|
+ return [true, ''];
|
|
|
+ } else {
|
|
|
+ data.sprice = num;
|
|
|
+ data.sexpr = expr;
|
|
|
+ return [true, ''];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ _checkRExpr: function (payNode, text, data) {
|
|
|
+ if (!payNode) return [false, '数据错误'];
|
|
|
+
|
|
|
+ const num = text ? _.toNumber(text) : null;
|
|
|
+ let expr = text ? (num ? null : text) : null;
|
|
|
+ expr = expr ? expr.replace('=', '').toLowerCase(): null;
|
|
|
+ const [valid, msg] = this._checkExprValid(expr, ['bqwc', 'ybbqwc']);
|
|
|
+ if (!valid) return [valid, msg];
|
|
|
+
|
|
|
+ if (payBase.isStarted(payNode)) {
|
|
|
+ if (payNode.pre_finish) return [false, '已达扣款限额,请勿修改'];
|
|
|
+ const value = expr ? payCalc.calculateExpr(expr) : num;
|
|
|
+ if (payNode.pre_tp && value < payNode.pre_tp) return [false, '截止上期已计量' + payNode.pre_tp + ',扣款限额请勿少于改值'];
|
|
|
+ data.rprice = num;
|
|
|
+ data.rexpr = expr;
|
|
|
+ return [true, ''];
|
|
|
+ } else {
|
|
|
+ data.rprice = num;
|
|
|
+ data.rexpr = expr;
|
|
|
+ return [true, ''];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ _checkExpr: function (text, data) {
|
|
|
if (text) {
|
|
|
const num = _.toNumber(text);
|
|
|
if (num) {
|
|
|
- data[priceField] = num;
|
|
|
- data[exprField] = null;
|
|
|
+ data.tp = num;
|
|
|
+ data.expr = null;
|
|
|
} else {
|
|
|
- data[exprField] = text.replace('=', '');
|
|
|
- data[priceField] = null;
|
|
|
+ const expr = text.replace('=', '').toLowerCase();
|
|
|
+ const [valid, msg] = this._checkExprValid(expr);
|
|
|
+ if (!valid) return [valid, msg];
|
|
|
+ data.expr = expr;
|
|
|
+ data.tp = null;
|
|
|
}
|
|
|
} else {
|
|
|
- data[priceField] = null;
|
|
|
- data[exprField] = null;
|
|
|
+ data.tp = null;
|
|
|
+ data.expr = null;
|
|
|
}
|
|
|
+ return [true, ''];
|
|
|
},
|
|
|
refreshActn: function () {
|
|
|
const setObjEnable = function (obj, enable) {
|
|
@@ -208,10 +447,12 @@ $(document).ready(() => {
|
|
|
const sheet = paySpread.getActiveSheet();
|
|
|
const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
setObjEnable($('#add'), !readOnly);
|
|
|
- setObjEnable($('#del'), !readOnly && select && (!payCol.readOnly.isOld(select) ||
|
|
|
- (!payCol.readOnly.isStarted(select) && payCol.readOnly.isYB(select))));
|
|
|
- setObjEnable($('#up-move'), !readOnly && select && select.ptype === 1 && dealPay.indexOf(select) > 3);
|
|
|
- setObjEnable($('#down-move'), !readOnly && select && select.ptype === 1 && dealPay.indexOf(select) < dealPay.length - 1);
|
|
|
+ const delValid = payBase.isOld(select)
|
|
|
+ ? !payBase.isStarted(select) && payBase.isYB()
|
|
|
+ : payBase.isYB() || payBase.isOwner(select);
|
|
|
+ setObjEnable($('#del'), !readOnly && select && delValid);
|
|
|
+ setObjEnable($('#up-move'), !readOnly && select && !payBase.isSpecial(select) && dealPay.indexOf(select) > 3);
|
|
|
+ setObjEnable($('#down-move'), !readOnly && select && !payBase.isSpecial(select) && dealPay.indexOf(select) < dealPay.length - 1);
|
|
|
},
|
|
|
add: function () {
|
|
|
const sheet = paySpread.getActiveSheet();
|
|
@@ -228,11 +469,11 @@ $(document).ready(() => {
|
|
|
del: function () {
|
|
|
const sheet = paySpread.getActiveSheet();
|
|
|
const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
- if (payCol.readOnly.isNonZero(select.tp)) {
|
|
|
+ if (payBase.isNonZero(select.tp)) {
|
|
|
toast('该支付(扣款)项存在数据,如需删除请先清除本期金额!');
|
|
|
return;
|
|
|
- } else if (payCol.readOnly.isOld(select)) {
|
|
|
- if (payCol.readOnly.isStarted(select)) {
|
|
|
+ } else if (payBase.isOld(select)) {
|
|
|
+ if (payBase.isStarted(select)) {
|
|
|
toast('该合同支付项往期已进行计算,不允许删除');
|
|
|
return;
|
|
|
}
|
|
@@ -295,13 +536,13 @@ $(document).ready(() => {
|
|
|
const data = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
if (col.field === 'tp') {
|
|
|
$('#expr').val(data.expr).attr('field', 'expr').attr('org', data.expr)
|
|
|
- .attr('readOnly', readOnly|| payCol.readOnly.isSpecial(data));
|
|
|
+ .attr('readOnly', readOnly|| payBase.isSpecial(data));
|
|
|
} else if (col.field === 'sprice') {
|
|
|
$('#expr').val(data.sexpr).attr('field', 'sexpr').attr('org', data.sexpr)
|
|
|
- .attr('readOnly', readOnly|| payCol.readOnly.isSpecial(data) || payCol.readOnly.isOld(data));
|
|
|
+ .attr('readOnly', readOnly|| payCol.readOnly.sprice(data));
|
|
|
} else if (col.field === 'rprice') {
|
|
|
$('#expr').val(data.rexpr).attr('field', 'rexpr').attr('org', data.rexpr)
|
|
|
- .attr('readOnly', readOnly|| payCol.readOnly.isSpecial(data) || payCol.readOnly.isOld(data));
|
|
|
+ .attr('readOnly', readOnly|| payCol.readOnly.rprice(data));
|
|
|
} else {
|
|
|
$('#expr').val('').attr('readOnly', true);
|
|
|
}
|
|
@@ -317,11 +558,17 @@ $(document).ready(() => {
|
|
|
const validText = info.editingText ? info.editingText.replace('\n', '') : null;
|
|
|
let orgValue;
|
|
|
if (col.field === 'tp') {
|
|
|
- orgValue = _.toNumber(validText) ? select.tp : select.expr;
|
|
|
+ orgValue = validText && validText !== ''
|
|
|
+ ? _.toNumber(validText) ? select.tp : select.expr
|
|
|
+ : (select.expr && select.expr !== '') ? select.expr : select.tp;
|
|
|
} else if (col.field === 'sprice') {
|
|
|
- orgValue = _.toNumber(validText) ? select.sprice : select.sexpr;
|
|
|
+ orgValue = validText && validText !== ''
|
|
|
+ ? _.toNumber(validText) ? select.sprice : select.sexpr
|
|
|
+ : (select.sexpr && select.sexpr !== '') ? select.sexpr : select.sprice;
|
|
|
} else if (col.field === 'rprice') {
|
|
|
- orgValue = _.toNumber(validText) ? select.rexpr : select.rexpr;
|
|
|
+ orgValue = validText && validText !== ''
|
|
|
+ ? _.toNumber(validText) ? select.rprice : select.rexpr
|
|
|
+ : (select.rexpr && select.rexpr !== '') ? select.rexpr : select.rprice;
|
|
|
} else {
|
|
|
orgValue = select[col.field];
|
|
|
}
|
|
@@ -337,7 +584,12 @@ $(document).ready(() => {
|
|
|
// 获取更新数据
|
|
|
if (col.field === 'tp') {
|
|
|
data.updateData.pid = select.pid;
|
|
|
- paySpreadObj._checkExpr(validText, data.updateData, 'tp', 'expr');
|
|
|
+ const [valid, msg] = paySpreadObj._checkExpr(validText, data.updateData);
|
|
|
+ if (!valid) {
|
|
|
+ toastr.warning(msg);
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
} else if (col.field === 'name') {
|
|
|
data.updateData.pid = select.pid;
|
|
|
data.updateData.name = validText;
|
|
@@ -345,9 +597,19 @@ $(document).ready(() => {
|
|
|
data.updateData.id = select.pid;
|
|
|
if (validText) {
|
|
|
if (col.field === 'sprice') {
|
|
|
- paySpreadObj._checkExpr(validText, data.updateData, 'sprice', 'sexpr');
|
|
|
+ const [valid, msg] = paySpreadObj._checkSExpr(select, validText, data.updateData);
|
|
|
+ if (!valid) {
|
|
|
+ toastr.warning(msg);
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
} else if (col.field === 'rprice') {
|
|
|
- paySpreadObj._checkExpr(validText, data.updateData, 'rprice', 'rexpr');
|
|
|
+ const [valid, msg] = paySpreadObj._checkRExpr(select, validText, data.updateData);
|
|
|
+ if (!valid) {
|
|
|
+ toastr.warning(msg);
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
} else {
|
|
|
data.updateData[col.field] = validText;
|
|
|
}
|
|
@@ -359,6 +621,8 @@ $(document).ready(() => {
|
|
|
postData(window.location.pathname + '/save', data, function (result) {
|
|
|
loadUpdateDealPays(result, col.field === 'name' ? ['name'] : null);
|
|
|
SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
|
+ }, function () {
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
});
|
|
|
}
|
|
|
},
|
|
@@ -430,11 +694,17 @@ $(document).ready(() => {
|
|
|
} else {
|
|
|
updateData.id = node.pid;
|
|
|
if (col.field === 'sprice') {
|
|
|
- updateData.sprice = null;
|
|
|
- updateData.sexpr = null;
|
|
|
+ const [valid, msg] = paySpreadObj._checkSExpr(node, null, updateData);
|
|
|
+ if (!valid) {
|
|
|
+ toastr.warning(msg);
|
|
|
+ return;
|
|
|
+ }
|
|
|
} else if (col.field === 'rprice') {
|
|
|
- updateData.rprice = null;
|
|
|
- updateData.rexpr = null;
|
|
|
+ const [valid, msg] = paySpreadObj._checkRExpr(node, null, updateData);
|
|
|
+ if (!valid) {
|
|
|
+ toastr.warning(msg);
|
|
|
+ return;
|
|
|
+ }
|
|
|
} else {
|
|
|
updateData[col.field] = null;
|
|
|
}
|
|
@@ -465,7 +735,10 @@ $(document).ready(() => {
|
|
|
}
|
|
|
|
|
|
const sortData = info.sheet.zh_data;
|
|
|
- const data = {type: col.field === 'tp' ? 'stage' : 'info', updateData: []};
|
|
|
+ const data = {
|
|
|
+ type: (col.field === 'tp' || col.field === 'name') ? 'stage' : 'info',
|
|
|
+ updateData: []
|
|
|
+ };
|
|
|
|
|
|
for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
|
|
|
const curRow = info.cellRange.row + iRow;
|
|
@@ -475,14 +748,32 @@ $(document).ready(() => {
|
|
|
const updateData = {};
|
|
|
if (col.field === 'tp') {
|
|
|
updateData.pid = node.pid;
|
|
|
- paySpreadObj._checkExpr(validText, updateData, 'tp', 'expr');
|
|
|
+ const [valid, msg] = paySpreadObj._checkExpr(validText, updateData);
|
|
|
+ if (!valid) {
|
|
|
+ toastr.warning(msg);
|
|
|
+ SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else if (col.field === 'name') {
|
|
|
+ updateData.pid = node.pid;
|
|
|
+ updateData.name = validText;
|
|
|
} else {
|
|
|
updateData.id = node.pid;
|
|
|
if (validText) {
|
|
|
if (col.field === 'sprice') {
|
|
|
- paySpreadObj._checkExpr(validText, updateData, 'sprice', 'sexpr');
|
|
|
+ const [valid, msg] = paySpreadObj._checkSExpr(node, validText, updateData);
|
|
|
+ if (!valid) {
|
|
|
+ toastr.warning(msg);
|
|
|
+ SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
|
+ return;
|
|
|
+ }
|
|
|
} else if (col.field === 'rprice') {
|
|
|
- paySpreadObj._checkExpr(validText, updateData, 'rprice', 'rexpr');
|
|
|
+ const [valid, msg] = paySpreadObj._checkRExpr(node, validText, updateData);
|
|
|
+ if (!valid) {
|
|
|
+ toastr.warning(msg);
|
|
|
+ SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
|
+ return;
|
|
|
+ }
|
|
|
} else {
|
|
|
updateData[col.field] = validText;
|
|
|
}
|
|
@@ -520,7 +811,7 @@ $(document).ready(() => {
|
|
|
const expr = $(this);
|
|
|
const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
|
|
|
const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = expr.val();
|
|
|
- if (orgValue === newValue) { return; }
|
|
|
+ if (orgValue === newValue || (!orgValue && newValue == '')) { return; }
|
|
|
|
|
|
const data = {};
|
|
|
if (field === 'expr') {
|
|
@@ -528,11 +819,22 @@ $(document).ready(() => {
|
|
|
data.updateData = { pid: select.pid, tp: null, expr: newValue }
|
|
|
} else if (field === 'sexpr') {
|
|
|
data.type = 'info';
|
|
|
- data.updateData = {id: select.pid, sprice: null, sexpr: newValue};
|
|
|
-
|
|
|
+ data.updateData = {id: select.pid};
|
|
|
+ const [valid, msg] = paySpreadObj._checkSExpr(select, newValue, data.updateData);
|
|
|
+ if (!valid) {
|
|
|
+ toastr.warning(msg);
|
|
|
+ this.value = select.sexpr;
|
|
|
+ return;
|
|
|
+ }
|
|
|
} else if (field === 'rexpr') {
|
|
|
data.type = 'info';
|
|
|
- data.updateData = {id: select.pid, rprice: null, rexpr: newValue};
|
|
|
+ data.updateData = {id: select.pid};
|
|
|
+ const [valid, msg] = paySpreadObj._checkRExpr(select, newValue, data.updateData);
|
|
|
+ if (!valid) {
|
|
|
+ toastr.warning(msg);
|
|
|
+ this.value = select.rexpr;
|
|
|
+ return;
|
|
|
+ }
|
|
|
} else {
|
|
|
expr.val('');
|
|
|
return;
|
|
@@ -600,7 +902,6 @@ $(document).ready(() => {
|
|
|
} else {
|
|
|
$('#dl-hint').show();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
};
|
|
|
// 右键菜单
|
|
@@ -636,7 +937,7 @@ $(document).ready(() => {
|
|
|
},
|
|
|
visible: function(key, opt){
|
|
|
const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
|
|
|
- return select.ptype === 4;
|
|
|
+ return payBase.isWC(select);
|
|
|
}
|
|
|
},
|
|
|
'start': {
|
|
@@ -659,11 +960,7 @@ $(document).ready(() => {
|
|
|
},
|
|
|
visible: function (key, opt) {
|
|
|
const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
|
|
|
- return select.ptype === 1 && select.pause;
|
|
|
- },
|
|
|
- disabled: function (key, opt) {
|
|
|
- const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
|
|
|
- return readOnly || payCol.readOnly.pause(select);
|
|
|
+ return !payBase.isSpecial(select) && !readOnly && select.pause && payCol.menuVisible.pause(select);
|
|
|
}
|
|
|
},
|
|
|
'stop': {
|
|
@@ -686,33 +983,24 @@ $(document).ready(() => {
|
|
|
},
|
|
|
visible: function (key, opt) {
|
|
|
const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
|
|
|
- return select.ptype === 1 && !select.pause;
|
|
|
+ return !payBase.isSpecial(select) && !readOnly && !payBase.pause && payCol.menuVisible.pause(select);
|
|
|
},
|
|
|
- disabled: function (key, opt) {
|
|
|
- const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
|
|
|
- return readOnly || payCol.readOnly.pause(select);
|
|
|
- }
|
|
|
},
|
|
|
'setDeadline': {
|
|
|
name: '设置计提期限',
|
|
|
icon: 'fa-clipboard',
|
|
|
- visible: function (key, opt) {
|
|
|
- const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
|
|
|
- const stageId = getStageId();
|
|
|
- return select.ptype === 1 && (select.csorder == stageId || stageId == 1);
|
|
|
- },
|
|
|
callback: function (key, opt) {
|
|
|
const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
|
|
|
deadlineObj.initView(select);
|
|
|
if (select.rprice) {
|
|
|
$('#deadline').modal('show');
|
|
|
} else {
|
|
|
- toast('计提期限用于达到条件时,即刻计量至付(扣)款限额,应先设置付(扣)款限额', 'warning');
|
|
|
+ toastr.warning('计提期限用于达到条件时,即刻计量至付(扣)款限额,应先设置付(扣)款限额');
|
|
|
}
|
|
|
},
|
|
|
- disabled: function (key, opt) {
|
|
|
+ visible: function (key, opt) {
|
|
|
const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
|
|
|
- return readOnly || payCol.readOnly.minus(select);
|
|
|
+ return !payBase.isSpecial(select) && !readOnly && payCol.menuVisible.deadline(select);
|
|
|
}
|
|
|
},
|
|
|
'dropYF': {
|
|
@@ -720,8 +1008,7 @@ $(document).ready(() => {
|
|
|
icon: 'fa-chain-broken',
|
|
|
visible: function (key, opt) {
|
|
|
const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
|
|
|
- const stageId = getStageId();
|
|
|
- return select.ptype === 1 && select.is_yf && (select.csorder == stageId || stageId == 1);
|
|
|
+ return !payBase.isSpecial(select) && select.is_yf && payCol.menuVisible.belongYF(select);
|
|
|
},
|
|
|
callback: function (key, opt) {
|
|
|
const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
|
|
@@ -737,10 +1024,6 @@ $(document).ready(() => {
|
|
|
loadUpdateDealPays(result);
|
|
|
SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
|
});
|
|
|
- },
|
|
|
- disabled: function (key, opt) {
|
|
|
- const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
|
|
|
- return readOnly || payCol.readOnly.minus(select);
|
|
|
}
|
|
|
},
|
|
|
'belongYF': {
|
|
@@ -748,8 +1031,7 @@ $(document).ready(() => {
|
|
|
icon: 'fa-chain',
|
|
|
visible: function (key, opt) {
|
|
|
const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
|
|
|
- const stageId = getStageId();
|
|
|
- return select.ptype === 1 && !select.is_yf && (select.csorder == stageId || stageId == 1);
|
|
|
+ return !payBase.isSpecial(select) && !select.is_yf && payCol.menuVisible.belongYF(select);
|
|
|
},
|
|
|
callback: function (key, opt) {
|
|
|
const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
|
|
@@ -760,15 +1042,10 @@ $(document).ready(() => {
|
|
|
is_yf: true
|
|
|
}
|
|
|
};
|
|
|
- // 更新至服务器
|
|
|
postData(window.location.pathname + '/save', data, function (result) {
|
|
|
loadUpdateDealPays(result);
|
|
|
SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
|
});
|
|
|
- },
|
|
|
- disabled: function (key, opt) {
|
|
|
- const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
|
|
|
- return readOnly || payCol.readOnly.minus(select);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -779,6 +1056,10 @@ $(document).ready(() => {
|
|
|
$('#tp').change(deadlineObj.getTotalPriceHint);
|
|
|
$('#deadline-ok').click(function () {
|
|
|
const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
|
|
|
+ if (payBase.isFinish(select)) {
|
|
|
+ toastr.warning('已达扣款限额,请勿修改');
|
|
|
+ return;
|
|
|
+ }
|
|
|
const data = {
|
|
|
type: 'info',
|
|
|
updateData: {
|
|
@@ -789,6 +1070,22 @@ $(document).ready(() => {
|
|
|
data.updateData.dl_count = parseInt($('#stage-count').val());
|
|
|
data.updateData.dl_tp_type = $('[name=tp-type]:checked').val();
|
|
|
data.updateData.dl_tp = parseFloat($('#tp').val());
|
|
|
+ if (data.updateData.dl_type === 1) {
|
|
|
+ if (data.updateData.dl_count < stage.order) {
|
|
|
+ toastr.warning('已计量至第' + stage.order + '期,不可设置计提期限为第' + data.updateData.dl_count + '期');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (data.updateData.dl_tp_type === 'contract' && preContractTp && data.updateData.dl_tp < preContractTp) {
|
|
|
+ toastr.warning('截止上期,合同已计量' + preContractTp + ',不可设置计提期限为累计合同计量达' + data.updateData.dl_tp);
|
|
|
+ return;
|
|
|
+ } else if (data.updateData.dl_tp_type === 'gather' && preGatherTp && data.updateData.dl_tp < preGatherTp) {
|
|
|
+ toastr.warning('截止上期,合同+变更已计量' + preGatherTp + ',不可设置计提期限为累计完成计量达' + data.updateData.dl_tp);
|
|
|
+ return;
|
|
|
+ } else if (data.updateData.dl_tp_type === 'qc' && preGatherTp && data.updateData.dl_tp < preQcTp) {
|
|
|
+ toastr.warning('截止上期,变更已计量' + preQcTp + ',不可设置计提期限为累计变更计量达' + data.updateData.dl_tp);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
postData(window.location.pathname + '/save', data, function (result) {
|
|
|
loadUpdateDealPays(result);
|
|
|
SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
@@ -829,7 +1126,7 @@ $(document).ready(() => {
|
|
|
} else {
|
|
|
select.attachment = data.concat(select.attachment);
|
|
|
}
|
|
|
- makeAttTable(select.id, select.attachment);
|
|
|
+ makeAttTable(select);
|
|
|
const index = dealPay.indexOf(select);
|
|
|
dealPay.splice(index, 1, select);
|
|
|
SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|
|
@@ -850,7 +1147,7 @@ $(document).ready(() => {
|
|
|
const select = SpreadJsObj.getSelectObject(paySpread.getActiveSheet());
|
|
|
postData('/tender/' + tender.id + '/measure/stage/' + tender.ledger_times + '/pay/delete/file', data, function (result) {
|
|
|
select.attachment.splice(index, 1);
|
|
|
- makeAttTable(id, select.attachment);
|
|
|
+ makeAttTable(select);
|
|
|
const pay_index = dealPay.indexOf(select);
|
|
|
dealPay.splice(pay_index, 1, select);
|
|
|
SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
|