|
@@ -127,27 +127,6 @@ $(document).ready(function() {
|
|
|
}
|
|
|
return [tree, node, count];
|
|
|
},
|
|
|
- // setAllForeColor: function (sheet) {
|
|
|
- // for(var i = 0; i < sheet.zh_tree.nodes.length; i++){
|
|
|
- // if (!sheet.zh_tree.nodes[i].c_code) continue;
|
|
|
- // const value = contractCol.getValue.status(sheet.zh_tree.nodes[i]);
|
|
|
- // console.log(i, value);
|
|
|
- // this.setForeColor(sheet, i, value);
|
|
|
- // }
|
|
|
- // },
|
|
|
- // setForeColor: function (sheet, row, value = null, col = 7, color = '') {
|
|
|
- // value = value !== null ? value : sheet.getValue(row, col);
|
|
|
- // if (!value) return;
|
|
|
- // if (value === '已结算') {
|
|
|
- // color = '#6c757d';
|
|
|
- // } else if (value === '已完成') {
|
|
|
- // color = '#28a745';
|
|
|
- // } else if (value === '履行中') {
|
|
|
- // color = '#da9500';
|
|
|
- // }
|
|
|
- // console.log(sheet.getCell(row, col).text(), color);
|
|
|
- // sheet.getCell(row, col).foreColor(color);
|
|
|
- // },
|
|
|
/**
|
|
|
* 刷新顶部按钮是否可用
|
|
|
* @param sheet
|
|
@@ -1733,25 +1712,7 @@ $(document).ready(function() {
|
|
|
remark: $('#cons-addpay textarea[name="remark"]').val(),
|
|
|
}
|
|
|
const name = contract_type === contractConst.type.expenses ? '付' : '回';
|
|
|
- if (!data.pay_price) {
|
|
|
- toastr.error('请输入'+ name +'款金额');
|
|
|
- return;
|
|
|
- }
|
|
|
- // 金额只能输入数字
|
|
|
- if (!/^\d+(\.\d+)?$/.test(data.pay_price)) {
|
|
|
- toastr.error(name + '款金额只能输入数字');
|
|
|
- return;
|
|
|
- }
|
|
|
- if (data.debit_price && !/^\d+(\.\d+)?$/.test(data.debit_price)) {
|
|
|
- toastr.error('扣款金额只能输入数字');
|
|
|
- return;
|
|
|
- }
|
|
|
- if (data.sf_price && !/^\d+(\.\d+)?$/.test(data.sf_price)) {
|
|
|
- toastr.error('实'+ name +'金额只能输入数字');
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!data.pay_type) {
|
|
|
- toastr.error('请选择' + contractConst.typeName[contract_type] + '方式');
|
|
|
+ if (!judgePays(node, data, name)) {
|
|
|
return;
|
|
|
}
|
|
|
console.log(node, data);
|
|
@@ -1798,39 +1759,70 @@ $(document).ready(function() {
|
|
|
remark: $('#cons-addpay textarea[name="remark"]').val(),
|
|
|
}
|
|
|
const name = contract_type === contractConst.type.expenses ? '付' : '回';
|
|
|
+ if (!judgePays(node, data, name, cpInfo)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log(node, data);
|
|
|
+ postData(window.location.pathname + '/update', {postType: 'save-contract-pay', postData: { select: node.id, pay: data }}, function (result) {
|
|
|
+ const refreshNode = contractTree.loadPostData(result.node);
|
|
|
+ contractTreeSpreadObj.refreshTree(contractSheet, refreshNode);
|
|
|
+ contractTreeSpreadObj.setContractPays(result.pays, node);
|
|
|
+ // const selection = contractSheet.getSelections();
|
|
|
+ // const sel = selection ? selection[0] : contractSheet.getSelections()[0];
|
|
|
+ // const row = sel ? sel.row : -1;
|
|
|
+ // contractTreeSpreadObj.setForeColor(contractSheet, row);
|
|
|
+ $('#cons-addpay').modal('hide');
|
|
|
+ })
|
|
|
+ });
|
|
|
+
|
|
|
+ function judgePays(node, data, name, cpInfo = null) {
|
|
|
+ let flag = true;
|
|
|
if (!data.pay_price) {
|
|
|
toastr.error('请输入'+ name +'款金额');
|
|
|
- return;
|
|
|
+ return false;
|
|
|
}
|
|
|
// 金额只能输入数字
|
|
|
if (!/^\d+(\.\d+)?$/.test(data.pay_price)) {
|
|
|
toastr.error(name + '款金额只能输入数字');
|
|
|
- return;
|
|
|
+ return false;
|
|
|
}
|
|
|
+ // if (cpInfo) {
|
|
|
+ // const newNodePayPrice = ZhCalc.add(ZhCalc.sub(node.pay_price, cpInfo.pay_price), parseFloat(data.pay_price));
|
|
|
+ // const newNodeDebitPrice = ZhCalc.add(ZhCalc.sub(node.debit_price, cpInfo.debit_price), parseFloat(data.debit_price));
|
|
|
+ // const newNodeYfPrice = ZhCalc.sub(newNodePayPrice, newNodeDebitPrice);
|
|
|
+ // const newNodeSfPrice = ZhCalc.add(ZhCalc.sub(node.sf_price, cpInfo.sf_price), parseFloat(data.sf_price));
|
|
|
+ // // if (parseFloat(data.pay_price) > ZhCalc.sub(newNodeYfPrice, newNodeSfPrice)) {
|
|
|
+ // // toastr.error(name + '款金额不能大于待支付金额 ' + ZhCalc.sub(newNodeYfPrice, newNodeSfPrice) + '元');
|
|
|
+ // // return false;
|
|
|
+ // // }
|
|
|
+ // } else {
|
|
|
+ // if (parseFloat(data.pay_price) > ZhCalc.sub(node.yf_price, node.sf_price)) {
|
|
|
+ // toastr.error(name + '款金额不能大于待支付金额 ' + ZhCalc.sub(node.yf_price, node.sf_price) + '元');
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
if (data.debit_price && !/^\d+(\.\d+)?$/.test(data.debit_price)) {
|
|
|
toastr.error('扣款金额只能输入数字');
|
|
|
- return;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (parseFloat(data.debit_price) > parseFloat(data.pay_price)) {
|
|
|
+ toastr.error('扣款金额不能大于'+ name +'款金额');
|
|
|
+ return false;
|
|
|
}
|
|
|
if (data.sf_price && !/^\d+(\.\d+)?$/.test(data.sf_price)) {
|
|
|
toastr.error('实'+ name +'金额只能输入数字');
|
|
|
- return;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (parseFloat(data.sf_price) > parseFloat(data.yf_price)) {
|
|
|
+ toastr.error('实'+ name +'金额不能大于应'+ name +'金额');
|
|
|
+ return false;
|
|
|
}
|
|
|
if (!data.pay_type) {
|
|
|
toastr.error('请选择' + contractConst.typeName[contract_type] + '方式');
|
|
|
- return;
|
|
|
+ return false;
|
|
|
}
|
|
|
- console.log(node, data);
|
|
|
- postData(window.location.pathname + '/update', {postType: 'save-contract-pay', postData: { select: node.id, pay: data }}, function (result) {
|
|
|
- const refreshNode = contractTree.loadPostData(result.node);
|
|
|
- contractTreeSpreadObj.refreshTree(contractSheet, refreshNode);
|
|
|
- contractTreeSpreadObj.setContractPays(result.pays, node);
|
|
|
- // const selection = contractSheet.getSelections();
|
|
|
- // const sel = selection ? selection[0] : contractSheet.getSelections()[0];
|
|
|
- // const row = sel ? sel.row : -1;
|
|
|
- // contractTreeSpreadObj.setForeColor(contractSheet, row);
|
|
|
- $('#cons-addpay').modal('hide');
|
|
|
- })
|
|
|
- });
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
|
|
|
$('body').on('click', '.open-pay-files', function () {
|
|
|
const cpid = $(this).attr('data-cpid');
|