|
|
@@ -369,6 +369,10 @@ $(document).ready(function() {
|
|
|
if (cp.uid === user_id && (!pay_shenpi_status || (pay_shenpi_status && (cp.status === auditConst.status.uncheck || cp.status === auditConst.status.checkNo)))) {
|
|
|
$('#htpay-table tbody tr').eq(i).find('.pay-edit').show();
|
|
|
$('#htpay-table tbody tr').eq(i).find('.pay-del').show();
|
|
|
+ } else if (pay_shenpi_status && cp.status === auditConst.status.checked && is_admin) {
|
|
|
+ $('#htpay-table tbody tr').eq(i).find('.pay-del').show();
|
|
|
+ } else if (pay_shenpi_status && (cp.status === auditConst.status.checking || cp.status === auditConst.status.checkNoPre) && cp.curAuditorIds && cp.curAuditorIds.length > 0 && cp.curAuditorIds.indexOf(user_id) !== -1) {
|
|
|
+ $('#htpay-table tbody tr').eq(i).find('.pay-edit').show();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -509,15 +513,21 @@ $(document).ready(function() {
|
|
|
let paysHtml = '';
|
|
|
const newPays = pays.map(pay => {
|
|
|
let showEdit = false;
|
|
|
+ let showDel = false;
|
|
|
if (pay.uid === user_id && !node.settle_code && (!pay_shenpi_status || (pay_shenpi_status && (pay.status === auditConst.status.uncheck || pay.status === auditConst.status.checkNo)))) {
|
|
|
- showEdit = true
|
|
|
- }
|
|
|
- return {...pay, showEdit}
|
|
|
+ showEdit = true;
|
|
|
+ showDel = true;
|
|
|
+ } else if (!node.settle_code && pay_shenpi_status && pay.status === auditConst.status.checked && is_admin) {
|
|
|
+ showDel = true;
|
|
|
+ } else if (!node.settle_code && pay_shenpi_status && (pay.status === auditConst.status.checking || pay.status === auditConst.status.checkNoPre) && pay.curAuditorIds && pay.curAuditorIds.length > 0 && pay.curAuditorIds.indexOf(user_id) !== -1) {
|
|
|
+ showEdit = true;
|
|
|
+ }
|
|
|
+ return {...pay, showEdit, showDel}
|
|
|
})
|
|
|
console.log(pays);
|
|
|
newPays.forEach((pay, idx) => {
|
|
|
const shenpi_html = setPayShenpiHtml(pay, false, node);
|
|
|
- const operationHtml = !pay.fpcid ? `<a href="javascript:void(0);" class="text-primary pay-edit" data-id="${pay.id}" ${!pay.showEdit ? `style="display:none"` : ''}>编辑</a> <a href="javascript:void(0);" class="text-danger pay-del" data-id="${pay.id}" ${!pay.showEdit ? `style="display:none"` : ''}>删除</a>` : '';
|
|
|
+ const operationHtml = !pay.fpcid ? `<a href="javascript:void(0);" class="text-primary pay-edit" data-id="${pay.id}" ${!pay.showEdit ? `style="display:none"` : ''}>编辑</a> <a href="javascript:void(0);" class="text-danger pay-del" data-id="${pay.id}" ${!pay.showDel ? `style="display:none"` : ''}>删除</a>` : '';
|
|
|
paysHtml += `<tr class="text-center" data-cpid="${pay.id}">
|
|
|
<td style="position: relative">${idx + 1}${ pay.fpcid ? '<a href="javascript:void(0);" style="position: absolute;right: 2px;top:50%;transform: translate(-50%, -50%);"><i class="fa fa-cny"></i></a>' : ''}</td>
|
|
|
<td>${moment(pay.pay_time).format('YYYY-MM-DD')}</td>
|
|
|
@@ -537,7 +547,7 @@ $(document).ready(function() {
|
|
|
});
|
|
|
$('#htpay-table tbody').html(paysHtml);
|
|
|
},
|
|
|
- setContract: function (sheet) {
|
|
|
+ setContract: function (sheet, needPost = true) {
|
|
|
const node = SpreadJsObj.getSelectObject(sheet);
|
|
|
|
|
|
if (node && node.c_code) {
|
|
|
@@ -555,13 +565,15 @@ $(document).ready(function() {
|
|
|
$('#htdetail_' + c).text(node[c] || '');
|
|
|
}
|
|
|
$('#htdetail_df_price').text(ZhCalc.sub(node.yf_price, node.sf_price) || '');
|
|
|
- postData(window.location.pathname + '/update', {postType: 'get-contract', postData: node.id}, function (result) {
|
|
|
- const refreshNode = contractTree.loadPostData({ update: result.contract });
|
|
|
- contractTreeSpreadObj.refreshTree(contractSheet, refreshNode);
|
|
|
- contractTreeSpreadObj.setContractPays(result.pays, node);
|
|
|
- contractTreeSpreadObj.setContractFiles(result.files, node.id);
|
|
|
- contractTreeSpreadObj.setContractBtn(result.contract);
|
|
|
- });
|
|
|
+ if (needPost) {
|
|
|
+ postData(window.location.pathname + '/update', {postType: 'get-contract', postData: node.id}, function (result) {
|
|
|
+ const refreshNode = contractTree.loadPostData({ update: result.contract });
|
|
|
+ contractTreeSpreadObj.refreshTree(contractSheet, refreshNode);
|
|
|
+ contractTreeSpreadObj.setContractPays(result.pays, node);
|
|
|
+ contractTreeSpreadObj.setContractFiles(result.files, node.id);
|
|
|
+ contractTreeSpreadObj.setContractBtn(result.contract);
|
|
|
+ });
|
|
|
+ }
|
|
|
} else {
|
|
|
$('#htdetail-table').hide();
|
|
|
$('#htpay-table').hide();
|
|
|
@@ -1762,6 +1774,7 @@ $(document).ready(function() {
|
|
|
contractTreeSpreadObj.refreshTree(contractSheet, refreshNode);
|
|
|
contractTreeSpreadObj.setContractPays(result.pays, node);
|
|
|
contractTreeSpreadObj.checkCloseStatus(node);
|
|
|
+ contractTreeSpreadObj.setContract(contractSheet, false);
|
|
|
})
|
|
|
}, '确认删除该合同' + contractConst.typeName[contract_type] + '?');
|
|
|
});
|
|
|
@@ -1797,15 +1810,23 @@ $(document).ready(function() {
|
|
|
toastr.error('未找到该合同' + contractConst.typeName[contract_type]);
|
|
|
return
|
|
|
}
|
|
|
+ if (node.settle_code) {
|
|
|
+ toastr.warning('已结算的合同不能编辑合同' + contractConst.typeName[contract_type]);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let only_sf_edit = false;
|
|
|
+ if (pay_shenpi_status && (cpInfo.status === auditConst.status.checking || cpInfo.status === auditConst.status.checkNoPre) && cpInfo.curAuditorIds && cpInfo.curAuditorIds.length > 0 && cpInfo.curAuditorIds.indexOf(user_id) > -1) {
|
|
|
+ only_sf_edit = true;
|
|
|
+ }
|
|
|
$('#cons-addpay .modal-title').text('编辑' + contractConst.typeName[contract_type]);
|
|
|
$('#cons-addpay input[name="cpid"]').val(cpid);
|
|
|
$('#add-contract-pay').hide();
|
|
|
$('#save-contract-pay').show();
|
|
|
- setPayModalInfo(cpInfo);
|
|
|
+ setPayModalInfo(cpInfo, only_sf_edit);
|
|
|
$('#cons-addpay').modal('show');
|
|
|
});
|
|
|
|
|
|
- function setPayModalInfo(cpInfo = null) {
|
|
|
+ function setPayModalInfo(cpInfo = null, only_sf_edit = false) {
|
|
|
$('#cons-addpay input[name="pay_time"]').val(cpInfo ? moment(cpInfo.pay_time).format('YYYY-MM-DD') : '');
|
|
|
payTime.selectDate(cpInfo ? new Date(cpInfo.pay_time) : '');
|
|
|
$('#cons-addpay select[name="used"]').val(cpInfo ? cpInfo.used : '合同');
|
|
|
@@ -1817,6 +1838,24 @@ $(document).ready(function() {
|
|
|
$('#cons-addpay textarea[name="remark"]').val(cpInfo ? cpInfo.remark : '');
|
|
|
$('#cons-addpay .yf-tips').text('');
|
|
|
$('#cons-addpay .sf-tips').text('');
|
|
|
+ if (only_sf_edit) {
|
|
|
+ // 用readOnly
|
|
|
+ $('#cons-addpay input[name="pay_time"]').attr('readonly', true);
|
|
|
+ $('#cons-addpay select[name="used"]').attr('disabled', true);
|
|
|
+ $('#cons-addpay input[name="pay_price"]').attr('readonly', true);
|
|
|
+ $('#cons-addpay input[name="debit_price"]').attr('readonly', true);
|
|
|
+ $('#cons-addpay input[name="yf_price"]').attr('readonly', true);
|
|
|
+ $('#cons-addpay select[name="pay_type"]').attr('disabled', true);
|
|
|
+ $('#cons-addpay textarea[name="remark"]').attr('readonly', true);
|
|
|
+ } else {
|
|
|
+ $('#cons-addpay input[name="pay_time"]').removeAttr('readonly');
|
|
|
+ $('#cons-addpay select[name="used"]').removeAttr('readonly');
|
|
|
+ $('#cons-addpay input[name="pay_price"]').removeAttr('readonly');
|
|
|
+ $('#cons-addpay input[name="debit_price"]').removeAttr('readonly');
|
|
|
+ $('#cons-addpay input[name="yf_price"]').removeAttr('readonly');
|
|
|
+ $('#cons-addpay select[name="pay_type"]').removeAttr('readonly');
|
|
|
+ $('#cons-addpay textarea[name="remark"]').removeAttr('readonly');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 上传附件
|
|
|
@@ -2213,10 +2252,6 @@ $(document).ready(function() {
|
|
|
toastr.error('请选择一个合同节点');
|
|
|
return;
|
|
|
}
|
|
|
- if (!(node.uid === user_id || permission_add_pay)) {
|
|
|
- toastr.error('没有权限添加合同' + contractConst.typeName[contract_type]);
|
|
|
- return;
|
|
|
- }
|
|
|
if (node.settle_code) {
|
|
|
toastr.error('该合同已结算,不能修改');
|
|
|
return;
|
|
|
@@ -2229,6 +2264,18 @@ $(document).ready(function() {
|
|
|
const cpid = $('#cons-addpay input[name="cpid"]').val();
|
|
|
if (cpid) {
|
|
|
const cpInfo = _.find(contractPays, { id: parseInt(cpid) });
|
|
|
+ if (!cpInfo) {
|
|
|
+ toastr.error('未找到' + contractConst.typeName[contract_type] + '信息');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let only_sf_edit = false;
|
|
|
+ if (pay_shenpi_status && (cpInfo.status === auditConst.status.checking || cpInfo.status === auditConst.status.checkNoPre) && cpInfo.curAuditorIds && cpInfo.curAuditorIds.length > 0 && cpInfo.curAuditorIds.indexOf(user_id) > -1) {
|
|
|
+ only_sf_edit = true;
|
|
|
+ }
|
|
|
+ if (!(node.uid === user_id || permission_add_pay || only_sf_edit)) {
|
|
|
+ toastr.error('没有权限编辑合同' + contractConst.typeName[contract_type]);
|
|
|
+ return;
|
|
|
+ }
|
|
|
const newNodePayPrice = ZhCalc.add(ZhCalc.sub(node.pay_price, cpInfo.pay_price), parseFloat(pay_price));
|
|
|
const newNodeDebitPrice = ZhCalc.add(ZhCalc.sub(node.debit_price, cpInfo.debit_price), parseFloat(debit_price));
|
|
|
const newNodeYfPrice = ZhCalc.sub(newNodePayPrice, newNodeDebitPrice);
|
|
|
@@ -2243,6 +2290,10 @@ $(document).ready(function() {
|
|
|
$('#cons-addpay .yf-tips').text('');
|
|
|
}
|
|
|
} else {
|
|
|
+ if (!(node.uid === user_id || permission_add_pay)) {
|
|
|
+ toastr.error('没有权限添加合同' + contractConst.typeName[contract_type]);
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (name !== 'sf_price') {
|
|
|
$('#cons-addpay input[name="sf_price"]').val(yf_price);
|
|
|
sf_price = yf_price;
|
|
|
@@ -2301,6 +2352,7 @@ $(document).ready(function() {
|
|
|
contractTreeSpreadObj.refreshTree(contractSheet, refreshNode);
|
|
|
contractTreeSpreadObj.setContractPays(result.pays, node);
|
|
|
contractTreeSpreadObj.checkCloseStatus(node);
|
|
|
+ contractTreeSpreadObj.setContract(contractSheet, false);
|
|
|
// const selection = contractSheet.getSelections();
|
|
|
// const sel = selection ? selection[0] : contractSheet.getSelections()[0];
|
|
|
// const row = sel ? sel.row : -1;
|
|
|
@@ -2325,8 +2377,12 @@ $(document).ready(function() {
|
|
|
toastr.error('未找到该合同' + contractConst.typeName[contract_type]);
|
|
|
return
|
|
|
}
|
|
|
- if (cpInfo.uid !== user_id) {
|
|
|
- toastr.error('只能编辑自己的合同' + contractConst.typeName[contract_type]);
|
|
|
+ let only_sf_edit = false;
|
|
|
+ if (pay_shenpi_status && (cpInfo.status === auditConst.status.checking || cpInfo.status === auditConst.status.checkNoPre) && cpInfo.curAuditorIds && cpInfo.curAuditorIds.length > 0 && cpInfo.curAuditorIds.indexOf(user_id) > -1) {
|
|
|
+ only_sf_edit = true;
|
|
|
+ }
|
|
|
+ if (!(cpInfo.uid === user_id || only_sf_edit)) {
|
|
|
+ toastr.error('只能编辑自己创建的合同' + contractConst.typeName[contract_type]);
|
|
|
return;
|
|
|
}
|
|
|
const data = {
|
|
|
@@ -2349,6 +2405,7 @@ $(document).ready(function() {
|
|
|
const refreshNode = contractTree.loadPostData(result.node);
|
|
|
contractTreeSpreadObj.refreshTree(contractSheet, refreshNode);
|
|
|
contractTreeSpreadObj.setContractPays(result.pays, node);
|
|
|
+ contractTreeSpreadObj.setContract(contractSheet, false);
|
|
|
// const selection = contractSheet.getSelections();
|
|
|
// const sel = selection ? selection[0] : contractSheet.getSelections()[0];
|
|
|
// const row = sel ? sel.row : -1;
|