|
|
@@ -339,6 +339,7 @@ $(document).ready(function() {
|
|
|
$('#save_contract_btn').hide();
|
|
|
$('#cancel_contract_btn').hide();
|
|
|
$('#add_contract_pay_btn').hide();
|
|
|
+ $('#add_contract_supplement_btn').hide();
|
|
|
$('a[href*="#cons-upfile"]').hide();
|
|
|
if (need) {
|
|
|
for (const c of contractDetail) {
|
|
|
@@ -363,6 +364,7 @@ $(document).ready(function() {
|
|
|
$('#save_contract_btn').hide();
|
|
|
$('#cancel_contract_btn').hide();
|
|
|
$('#add_contract_pay_btn').hide();
|
|
|
+ $('#add_contract_supplement_btn').hide();
|
|
|
if (node.settle_code) {
|
|
|
$('#add_contract_pay_btn').hide();
|
|
|
if (need) {
|
|
|
@@ -390,12 +392,44 @@ $(document).ready(function() {
|
|
|
$('#save_contract_btn').hide();
|
|
|
$('#cancel_contract_btn').hide();
|
|
|
$('#add_contract_pay_btn').hide();
|
|
|
+ $('#add_contract_supplement_btn').hide();
|
|
|
$('a[href*="#cons-upfile"]').show();
|
|
|
+ } else if ($('.bc-bar .nav li .active').attr('href') === '#htsupplement') {
|
|
|
+ $('#edit_contract_btn').hide();
|
|
|
+ $('#save_contract_btn').hide();
|
|
|
+ $('#cancel_contract_btn').hide();
|
|
|
+ $('#add_contract_pay_btn').hide();
|
|
|
+ $('#add_contract_supplement_btn').hide();
|
|
|
+ if (node.settle_code) {
|
|
|
+ $('#add_contract_supplement_btn').hide();
|
|
|
+ if (need) {
|
|
|
+ $('#htsupplement-table tbody').find('.pay-edit').hide();
|
|
|
+ $('#htsupplement-table tbody').find('.pay-del').hide();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ((node.uid === user_id || permission_edit_contract) && (!shenpi_status || (shenpi_status && node.status === auditConst.status.checked))) $('#add_contract_supplement_btn').show();
|
|
|
+ if (need && contractSupplements && contractSupplements.length > 0) {
|
|
|
+ for (const [i, cp] of contractSupplements.entries()) {
|
|
|
+ if (cp.uid === user_id && (!shenpi_status || (shenpi_status && (cp.status === auditConst.status.uncheck || cp.status === auditConst.status.checkNo)))) {
|
|
|
+ $('#htsupplement-table tbody tr').eq(i).find('.pay-edit').show();
|
|
|
+ $('#htsupplement-table tbody tr').eq(i).find('.pay-del').show();
|
|
|
+ } else if (shenpi_status && cp.status === auditConst.status.checked && is_admin) {
|
|
|
+ $('#htsupplement-table tbody tr').eq(i).find('.pay-del').show();
|
|
|
+ } else if (shenpi_status && (cp.status === auditConst.status.checking || cp.status === auditConst.status.checkNoPre) && cp.curAuditorIds && cp.curAuditorIds.length > 0 && cp.curAuditorIds.indexOf(user_id) !== -1) {
|
|
|
+ $('#htsupplement-table tbody tr').eq(i).find('.pay-edit').show();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $('a[href*="#cons-upfile"]').hide();
|
|
|
}
|
|
|
},
|
|
|
openContractPayFiles: function (pay) {
|
|
|
this.setContractFiles(pay.files, pay.cid, pay.id, '#cons-pay-file table tbody');
|
|
|
},
|
|
|
+ openContractSupplementFiles: function (supplement) {
|
|
|
+ this.setContractFiles(supplement.files, supplement.cid, supplement.id, '#cons-supplement-file table tbody');
|
|
|
+ },
|
|
|
checkCloseStatus: function (node) {
|
|
|
if (pay_shenpi_status) {
|
|
|
let have_uncheck = false;
|
|
|
@@ -467,6 +501,11 @@ $(document).ready(function() {
|
|
|
} else {
|
|
|
$('#add_contract_pay_btn').hide();
|
|
|
}
|
|
|
+ if (node && node.c_code && $('.bc-bar .nav li .active').attr('href') === '#htsupplement' && (node.uid === user_id || permission_edit_contract) && node.status === auditConst.status.checked) {
|
|
|
+ $('#add_contract_supplement_btn').show();
|
|
|
+ } else {
|
|
|
+ $('#add_contract_supplement_btn').hide();
|
|
|
+ }
|
|
|
}
|
|
|
} else if ((node.uid === user_id || permission_edit_contract)) {
|
|
|
if (node.settle_code) {
|
|
|
@@ -490,6 +529,11 @@ $(document).ready(function() {
|
|
|
} else {
|
|
|
$('#add_contract_pay_btn').hide();
|
|
|
}
|
|
|
+ if (node && node.c_code && $('.bc-bar .nav li .active').attr('href') === '#htsupplement' && (node.uid === user_id || permission_edit_contract)) {
|
|
|
+ $('#add_contract_supplement_btn').show();
|
|
|
+ } else {
|
|
|
+ $('#add_contract_supplement_btn').hide();
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
setContractFiles: function (files, cid, cpid = null, _this = '#htfile-table tbody') {
|
|
|
@@ -515,6 +559,9 @@ $(document).ready(function() {
|
|
|
});
|
|
|
$(_this).html(filesHtml);
|
|
|
},
|
|
|
+ setContractListHtml: function (type, node, list) {
|
|
|
+ reOrderTenders(type, node, list);
|
|
|
+ },
|
|
|
setContractPays: function (pays, node) {
|
|
|
contractPays = pays;
|
|
|
let paysHtml = '';
|
|
|
@@ -554,6 +601,44 @@ $(document).ready(function() {
|
|
|
});
|
|
|
$('#htpay-table tbody').html(paysHtml);
|
|
|
},
|
|
|
+ setContractSupplements: function (supplements, node) {
|
|
|
+ contractSupplements = supplements;
|
|
|
+ let supplementsHtml = '';
|
|
|
+ const newSupplements = supplements.map(supplement => {
|
|
|
+ let showEdit = false;
|
|
|
+ let showDel = false;
|
|
|
+ if (supplement.uid === user_id && !node.settle_code && (!shenpi_status || (shenpi_status && (supplement.status === auditConst.status.uncheck || supplement.status === auditConst.status.checkNo)))) {
|
|
|
+ showEdit = true;
|
|
|
+ showDel = true;
|
|
|
+ } else if (!node.settle_code && shenpi_status && supplement.status === auditConst.status.checked && is_admin) {
|
|
|
+ showDel = true;
|
|
|
+ } else if (!node.settle_code && shenpi_status && (supplement.status === auditConst.status.checking || supplement.status === auditConst.status.checkNoPre) && supplement.curAuditorIds && supplement.curAuditorIds.length > 0 && supplement.curAuditorIds.indexOf(user_id) !== -1) {
|
|
|
+ showEdit = true;
|
|
|
+ }
|
|
|
+ return {...supplement, showEdit, showDel}
|
|
|
+ })
|
|
|
+ console.log(supplements);
|
|
|
+ newSupplements.forEach((supplement, idx) => {
|
|
|
+ const shenpi_html = setSupplementShenpiHtml(supplement, false, node);
|
|
|
+ const operationHtml = `<a href="javascript:void(0);" class="text-primary supplement-edit" data-id="${supplement.id}" ${!supplement.showEdit ? `style="display:none"` : ''}>编辑</a> <a href="javascript:void(0);" class="text-danger supplement-del" data-id="${supplement.id}" ${!supplement.showDel ? `style="display:none"` : ''}>删除</a>`;
|
|
|
+ supplementsHtml += `<tr class="text-center" data-cpid="${supplement.id}">
|
|
|
+ <td>${supplement.code}</td>
|
|
|
+ <td>${supplement.name}</td>
|
|
|
+ <td>${supplement.price}</td>
|
|
|
+ <td>${supplement.party_a}</td>
|
|
|
+ <td>${supplement.party_b}</td>
|
|
|
+ <td>${supplement.sign_time ? moment(supplement.sign_time).format('YYYY-MM-DD') : ''}</td>
|
|
|
+ <td>${supplement.address}</td>
|
|
|
+ <td>${supplement.username}</td>
|
|
|
+ <td>${moment(supplement.create_time).format('YYYY-MM-DD HH:mm:ss')}</td>
|
|
|
+ <td>${supplement.content}</td>
|
|
|
+ <td><a href="javascript:void(0);" class="text-primary open-supplement-files" data-csid="${supplement.id}"><i class="fa fa-paperclip fa-rotate-90"></i></a> <span class="files-num">${supplement.files.length > 0 ? supplement.files.length : ''}</span></td>
|
|
|
+ ${shenpi_html}
|
|
|
+ <td>${operationHtml}</td>
|
|
|
+ </tr>`;
|
|
|
+ });
|
|
|
+ $('#htsupplement-table tbody').html(supplementsHtml);
|
|
|
+ },
|
|
|
setContract: function (sheet, needPost = true) {
|
|
|
const node = SpreadJsObj.getSelectObject(sheet);
|
|
|
|
|
|
@@ -562,6 +647,7 @@ $(document).ready(function() {
|
|
|
$('#htdetail-attr').show();
|
|
|
$('#htpay-table').show();
|
|
|
$('#htfile-table').show();
|
|
|
+ $('#htsupplement-table').show();
|
|
|
for (const c of contractDetail) {
|
|
|
if (c === 'create_time') {
|
|
|
$('#htdetail_' + c).text(node[c] ? moment(node[c]).format('YYYY-MM-DD HH:mm:ss') : '');
|
|
|
@@ -581,8 +667,11 @@ $(document).ready(function() {
|
|
|
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.setContractPays(result.pays, node);
|
|
|
+ contractTreeSpreadObj.setContractListHtml('pay', node, result.pays);
|
|
|
contractTreeSpreadObj.setContractFiles(result.files, node.id);
|
|
|
+ // contractTreeSpreadObj.setContractSupplements(result.supplements, node.id);
|
|
|
+ contractTreeSpreadObj.setContractListHtml('supplement', node, result.supplements);
|
|
|
contractTreeSpreadObj.setContractBtn(result.contract);
|
|
|
});
|
|
|
}
|
|
|
@@ -591,6 +680,7 @@ $(document).ready(function() {
|
|
|
$('#htdetail-attr').hide();
|
|
|
$('#htpay-table').hide();
|
|
|
$('#htfile-table').hide();
|
|
|
+ $('#htsupplement-table').hide();
|
|
|
$('#edit_contract_btn').hide();
|
|
|
$('#save_contract_btn').hide();
|
|
|
$('#cancel_contract_btn').hide();
|
|
|
@@ -599,6 +689,7 @@ $(document).ready(function() {
|
|
|
$('a[href*="#cons-upfile"]').hide();
|
|
|
if (node && node.c_code && $('.bc-bar .nav li .active').attr('href') === '#htfile' && permission_att) $('a[href*="#cons-upfile"]').show();
|
|
|
$('#add_contract_pay_btn').hide();
|
|
|
+ $('#add_contract_supplement_btn').hide();
|
|
|
$('#shenpi_btn').html('');
|
|
|
}
|
|
|
},
|
|
|
@@ -961,7 +1052,7 @@ $(document).ready(function() {
|
|
|
if (select.c_code) {
|
|
|
if (!(select.uid === user_id || is_admin)) {
|
|
|
canDelete = false;
|
|
|
- } else if (select.exist_pay) {
|
|
|
+ } else if (select.exist_pay || select.exist_supplement) {
|
|
|
canDelete = false;
|
|
|
}
|
|
|
} else {
|
|
|
@@ -974,7 +1065,7 @@ $(document).ready(function() {
|
|
|
if (!(sc.uid === user_id || is_admin)) {
|
|
|
canDelete = false;
|
|
|
break;
|
|
|
- } else if (sc.exist_pay) {
|
|
|
+ } else if (sc.exist_pay || sc.exist_supplement) {
|
|
|
canDelete = false;
|
|
|
break;
|
|
|
}
|
|
|
@@ -986,6 +1077,93 @@ $(document).ready(function() {
|
|
|
};
|
|
|
contractSpread.bind(spreadNS.Events.SelectionChanged, contractTreeSpreadObj.selectionChanged);
|
|
|
contractSpread.bind(spreadNS.Events.topRowChanged, contractTreeSpreadObj.topRowChanged);
|
|
|
+
|
|
|
+ // 支付/回款,补充合同列表排序及切换排序
|
|
|
+ let payOrderSetting = getLocalCache('jl-contract-pay-list-order-' + spid);
|
|
|
+ if (!payOrderSetting) payOrderSetting = 'create_time|down';
|
|
|
+
|
|
|
+ let supplementOrderSetting = getLocalCache('jl-contract-supplement-list-order-' + spid);
|
|
|
+ if (!supplementOrderSetting) supplementOrderSetting = 'create_time|down';
|
|
|
+ const pinyin = new PinYinOrder();
|
|
|
+ function CompareStr (x, y) {
|
|
|
+ return pinyin.compareWord(x, y);
|
|
|
+ }
|
|
|
+
|
|
|
+ function reOrderTenders (type, node = null, ts = null, orderStr = '') {
|
|
|
+ let orders = [];
|
|
|
+ if (type === 'pay') {
|
|
|
+ if (orderStr) {
|
|
|
+ payOrderSetting = orderStr;
|
|
|
+ setLocalCache('jl-contract-pay-list-order-' + spid, orderStr);
|
|
|
+ }
|
|
|
+ if (!ts) ts = contractPays;
|
|
|
+ orders = payOrderSetting.split('|');
|
|
|
+ } else if (type === 'supplement') {
|
|
|
+ if (orderStr) {
|
|
|
+ supplementOrderSetting = orderStr;
|
|
|
+ setLocalCache('jl-contract-supplement-list-order-' + spid, orderStr);
|
|
|
+ }
|
|
|
+ if (!ts) ts = contractSupplements;
|
|
|
+ orders = supplementOrderSetting.split('|');
|
|
|
+ }
|
|
|
+ if (orders[0] === 'code') {
|
|
|
+ ts.sort(function (a, b) {
|
|
|
+ // return orders[1] === 'up'
|
|
|
+ // ? a[orders[0]].localeCompare(b[orders[0]], 'zh')
|
|
|
+ // : -a[orders[0]].localeCompare(b[orders[0]], 'zh');
|
|
|
+ return orders[1] === 'up'
|
|
|
+ ? CompareStr(a[orders[0]], b[orders[0]])
|
|
|
+ : CompareStr(b[orders[0]], a[orders[0]]);
|
|
|
+ });
|
|
|
+ } else if (orders[0] === 'pay_time') {
|
|
|
+ ts.sort(function (a, b){
|
|
|
+ return orders[1] === 'up'
|
|
|
+ ? Date.parse(a[orders[0]]) - Date.parse(b[orders[0]])
|
|
|
+ : Date.parse(b[orders[0]]) - Date.parse(a[orders[0]]);
|
|
|
+ });
|
|
|
+ } else if (orders[0] === 'create_time') {
|
|
|
+ ts.sort(function (a, b){
|
|
|
+ return orders[1] === 'up'
|
|
|
+ ? Date.parse(a[orders[0]]) - Date.parse(b[orders[0]])
|
|
|
+ : Date.parse(b[orders[0]]) - Date.parse(a[orders[0]]);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (!node) node = SpreadJsObj.getSelectObject(contractSheet);
|
|
|
+ setHeaderOrderButtonHtml(type);
|
|
|
+ if (type === 'pay') {
|
|
|
+ contractTreeSpreadObj.setContractPays(ts, node);
|
|
|
+ } else if (type === 'supplement') {
|
|
|
+ contractTreeSpreadObj.setContractSupplements(ts, node);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function setHeaderOrderButtonHtml(type) {
|
|
|
+ if (type === 'pay') {
|
|
|
+ $('#pay-header th[sort="pay_time"]').html((contract_type === contractConst.type.expenses ? '支付' : '回款') + '日期' + getOrderButton('pay_time', 'pay') + '</th>');
|
|
|
+ $('#pay-header th[sort="create_time"]').html('创建时间' + getOrderButton('create_time', 'pay') + '</th>');
|
|
|
+ } else if (type === 'supplement') {
|
|
|
+ $('#supplement-header th[sort="code"]').html('编号' + getOrderButton('code', 'supplement') + '</th>');
|
|
|
+ $('#supplement-header th[sort="create_time"]').html('创建时间' + getOrderButton('create_time', 'supplement') + '</th>');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function getOrderButton(field, type) {
|
|
|
+ let orders = [];
|
|
|
+ if (type === 'pay') {
|
|
|
+ orders = payOrderSetting.split('|');
|
|
|
+ } else {
|
|
|
+ orders = supplementOrderSetting.split('|');
|
|
|
+ }
|
|
|
+ const button = field === orders[0]
|
|
|
+ ? (orders[1] === 'up'
|
|
|
+ ? `<i class="fa fa-sort-amount-asc" aria-hidden="true" data-filed="${field + '|down'}" data-type="${type}"></i>`
|
|
|
+ : `<i class="fa fa-sort-amount-desc" aria-hidden="true" data-filed="${field + '|up'}" data-type="${type}"></i>`)
|
|
|
+ : `<i class="fa fa-sort" aria-hidden="true" data-filed="${field + '|up'}" data-type="${type}"></i>`;
|
|
|
+ return '<a href="javascript:void(0)" class="btn btn-sm ml-1">' + button + '</a>';
|
|
|
+ }
|
|
|
+ $('body').on('click', '#pay-header th[sort] a, #supplement-header th[sort] a', function (e) {
|
|
|
+ const field = $(this).find('i').data('filed');
|
|
|
+ const type = $(this).find('i').data('type');
|
|
|
+ reOrderTenders(type, null, null, field);
|
|
|
+ });
|
|
|
// 右键菜单
|
|
|
let batchInsertObj;
|
|
|
$.contextMenu.types.batchInsert = function (item, opt, root) {
|
|
|
@@ -1637,9 +1815,11 @@ $(document).ready(function() {
|
|
|
const node = SpreadJsObj.getSelectObject(contractSheet);
|
|
|
$('a[href*="#cons-upfile"]').hide();
|
|
|
$('#add_contract_pay_btn').hide();
|
|
|
+ $('#add_contract_supplement_btn').hide();
|
|
|
if (node && node.c_code) {
|
|
|
if ($('.bc-bar .nav li .active').attr('href') === '#htfile' && permission_att) $('a[href*="#cons-upfile"]').show();
|
|
|
if ($('.bc-bar .nav li .active').attr('href') === '#htpay' && !node.settle_code && permission_add_pay && (!shenpi_status || (shenpi_status && node.status === auditConst.status.checked))) $('#add_contract_pay_btn').show();
|
|
|
+ if ($('.bc-bar .nav li .active').attr('href') === '#htsupplement' && !node.settle_code && permission_edit_contract && (!shenpi_status || (shenpi_status && node.status === auditConst.status.checked))) $('#add_contract_supplement_btn').show();
|
|
|
if ((node.uid === user_id || permission_edit_contract)) contractTreeSpreadObj.changeContractTab(node, true);
|
|
|
}
|
|
|
});
|
|
|
@@ -1845,7 +2025,8 @@ $(document).ready(function() {
|
|
|
postData(window.location.pathname + '/update', {postType: 'del-contract-pay', postData: { select: node.id, pay: cpid }}, function (result) {
|
|
|
const refreshNode = contractTree.loadPostData(result.node);
|
|
|
contractTreeSpreadObj.refreshTree(contractSheet, refreshNode);
|
|
|
- contractTreeSpreadObj.setContractPays(result.pays, node);
|
|
|
+ // contractTreeSpreadObj.setContractPays(result.pays, node);
|
|
|
+ contractTreeSpreadObj.setContractListHtml('pay', node, result.pays);
|
|
|
contractTreeSpreadObj.checkCloseStatus(node);
|
|
|
contractTreeSpreadObj.setContract(contractSheet, false);
|
|
|
})
|
|
|
@@ -1991,6 +2172,162 @@ $(document).ready(function() {
|
|
|
}, '确认删除该文件?');
|
|
|
});
|
|
|
|
|
|
+ $('body').on('click', '#htsupplement .supplement-del', function () {
|
|
|
+ const node = SpreadJsObj.getSelectObject(contractSheet);
|
|
|
+ const csid = $(this).data('id');
|
|
|
+ if (!node || !node.c_code) {
|
|
|
+ toastr.warning('请选择合同节点');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (node.settle_code) {
|
|
|
+ toastr.warning('已结算的合同不能删除补充合同');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ deleteAfterHint(function () {
|
|
|
+ postData(window.location.pathname + '/update', {postType: 'del-contract-supplement', postData: { select: node.id, supplement: csid }}, function (result) {
|
|
|
+ const refreshNode = contractTree.loadPostData(result.node);
|
|
|
+ contractTreeSpreadObj.refreshTree(contractSheet, refreshNode);
|
|
|
+ // contractTreeSpreadObj.setContractSupplements(result.supplements, node);
|
|
|
+ contractTreeSpreadObj.setContractListHtml('supplement', node, result.supplements);
|
|
|
+ contractTreeSpreadObj.checkCloseStatus(node);
|
|
|
+ contractTreeSpreadObj.setContract(contractSheet, false);
|
|
|
+ })
|
|
|
+ }, '确认删除该补充合同?');
|
|
|
+ });
|
|
|
+
|
|
|
+ const signTime = $('#cons-addsupplement input[name="sign_time"]').datepicker().data('datepicker');
|
|
|
+
|
|
|
+ $('#add_contract_supplement_btn').on('click', function () {
|
|
|
+ const node = SpreadJsObj.getSelectObject(contractSheet);
|
|
|
+ if (!node || !node.c_code) {
|
|
|
+ toastr.error('请选择一个合同节点');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $('#cons-addsupplement .modal-title').text('新增补充合同');
|
|
|
+ $('#cons-addsupplement input[name="csid"]').val('');
|
|
|
+ $('#add-contract-supplement').show();
|
|
|
+ $('#save-contract-supplement').hide();
|
|
|
+ setSupplementModalInfo();
|
|
|
+ $('#cons-addsupplement').modal('show');
|
|
|
+ });
|
|
|
+
|
|
|
+ $('body').on('click', '#htsupplement .supplement-edit', function () {
|
|
|
+ const node = SpreadJsObj.getSelectObject(contractSheet);
|
|
|
+ if (!node || !node.c_code) {
|
|
|
+ toastr.error('请选择一个合同节点');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const csid = $(this).data('id');
|
|
|
+ const csInfo = _.find(contractSupplements, { id: parseInt(csid) });
|
|
|
+ if (!csInfo) {
|
|
|
+ toastr.error('未找到该补充合同');
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (node.settle_code) {
|
|
|
+ toastr.warning('已结算的合同不能编辑补充合同');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let only_sf_edit = false;
|
|
|
+ if (shenpi_status && (csInfo.status === auditConst.status.checking || csInfo.status === auditConst.status.checkNoPre) && csInfo.curAuditorIds && csInfo.curAuditorIds.length > 0 && csInfo.curAuditorIds.indexOf(user_id) > -1) {
|
|
|
+ only_sf_edit = true;
|
|
|
+ }
|
|
|
+ $('#cons-addsupplement .modal-title').text('编辑补充合同');
|
|
|
+ $('#cons-addsupplement input[name="csid"]').val(csid);
|
|
|
+ $('#add-contract-supplement').hide();
|
|
|
+ $('#save-contract-supplement').show();
|
|
|
+ setSupplementModalInfo(csInfo, only_sf_edit);
|
|
|
+ $('#cons-addsupplement').modal('show');
|
|
|
+ });
|
|
|
+
|
|
|
+ function setSupplementModalInfo(csInfo = null, only_sf_edit = false) {
|
|
|
+ $('#cons-addsupplement input[name="code"]').val(csInfo ? csInfo.code : '');
|
|
|
+ $('#cons-addsupplement input[name="name"]').val(csInfo ? csInfo.name : '');
|
|
|
+ $('#cons-addsupplement input[name="price"]').val(csInfo ? csInfo.price : '');
|
|
|
+ $('#cons-addsupplement input[name="party_a"]').val(csInfo ? csInfo.party_a : '');
|
|
|
+ $('#cons-addsupplement input[name="party_b"]').val(csInfo ? csInfo.party_b : '');
|
|
|
+ $('#cons-addsupplement input[name="sign_time"]').val(csInfo ? moment(csInfo.sign_time).format('YYYY-MM-DD') : '');
|
|
|
+ signTime.selectDate(csInfo ? new Date(csInfo.sign_time) : '');
|
|
|
+ $('#cons-addsupplement textarea[name="content"]').val(csInfo ? csInfo.content : '');
|
|
|
+ if (only_sf_edit) {
|
|
|
+ // 用readOnly
|
|
|
+ $('#cons-addsupplement input[name="code"]').attr('readonly', true);
|
|
|
+ $('#cons-addsupplement input[name="name"]').attr('readonly', true);
|
|
|
+ $('#cons-addsupplement input[name="party_a"]').attr('readonly', true);
|
|
|
+ $('#cons-addsupplement input[name="party_b"]').attr('readonly', true);
|
|
|
+ $('#cons-addsupplement input[name="sign_time"]').attr('readonly', true);
|
|
|
+ $('#cons-addsupplement input[name="address"]').attr('readonly', true);
|
|
|
+ $('#cons-addsupplement textarea[name="content"]').attr('readonly', true);
|
|
|
+ } else {
|
|
|
+ $('#cons-addsupplement input[name="code"]').removeAttr('readonly');
|
|
|
+ $('#cons-addsupplement input[name="name"]').removeAttr('readonly');
|
|
|
+ $('#cons-addsupplement input[name="party_a"]').removeAttr('readonly');
|
|
|
+ $('#cons-addsupplement input[name="party_b"]').removeAttr('readonly');
|
|
|
+ $('#cons-addsupplement input[name="sign_time"]').removeAttr('readonly');
|
|
|
+ $('#cons-addsupplement input[name="address"]').removeAttr('readonly');
|
|
|
+ $('#cons-addsupplement textarea[name="content"]').removeAttr('readonly');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 上传附件
|
|
|
+ $('#cons-supplement-file input[type="file"]').change(function () {
|
|
|
+ const files = Array.from(this.files);
|
|
|
+ console.log(files);
|
|
|
+ const valiData = files.map(v => {
|
|
|
+ const ext = v.name.substring(v.name.lastIndexOf('.') + 1)
|
|
|
+ return {
|
|
|
+ size: v.size,
|
|
|
+ ext
|
|
|
+ }
|
|
|
+ })
|
|
|
+ const node = SpreadJsObj.getSelectObject(contractSheet);
|
|
|
+ if (!node || !node.c_code) {
|
|
|
+ toastr.warning('请选择合同再上传文件');
|
|
|
+ $('#cons-supplement-file input[type="file"]').val('');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const csid = $('#cons-supplement-file input[name="csid"]').val();
|
|
|
+ const csInfo = _.find(contractsupplements, { id: parseInt(csid) });
|
|
|
+ if (!csInfo) {
|
|
|
+ toastr.warning('请选择补充合同再上传文件');
|
|
|
+ $('#cons-supplement-file input[type="file"]').val('');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (validateFiles(valiData)) {
|
|
|
+ if (files.length) {
|
|
|
+ const formData = new FormData()
|
|
|
+ files.forEach(file => {
|
|
|
+ formData.append('name', file.name)
|
|
|
+ formData.append('size', file.size)
|
|
|
+ formData.append('file', file)
|
|
|
+ })
|
|
|
+ postDataWithFile(`${thisUrl}/${contractConst.typeMap[contract_type]}/${node.id}/supplement/${csInfo.id}/file/upload`, formData, function (result) {
|
|
|
+ csInfo.files = result;
|
|
|
+ contractTreeSpreadObj.openContractSupplementFiles(csInfo);
|
|
|
+ $('#htsupplement-table tbody').find('tr[data-csid="' + csInfo.id + '"]').find('.files-num').text(result.length || '');
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $('#cons-supplement-file input[type="file"]').val('');
|
|
|
+ });
|
|
|
+
|
|
|
+ $('body').on('click', '#cons-supplement-file .file-del', function () {
|
|
|
+ const node = SpreadJsObj.getSelectObject(contractSheet);
|
|
|
+ const csid = $('#cons-supplement-file input[name="csid"]').val();
|
|
|
+ const csInfo = _.find(contractSupplements, { id: parseInt(csid) });
|
|
|
+ if (!csInfo) {
|
|
|
+ toastr.warning('未选择补充合同');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const fid = $(this).data('id');
|
|
|
+ deleteAfterHint(function () {
|
|
|
+ postData(`${thisUrl}/${contractConst.typeMap[contract_type]}/${node.id}/supplement/${csInfo.id}/file/delete`, { id: fid }, function (result) {
|
|
|
+ csInfo.files = result;
|
|
|
+ contractTreeSpreadObj.openContractSupplementFiles(csInfo);
|
|
|
+ $('#htsupplement-table tbody').find('tr[data-csid="' + csInfo.id + '"]').find('.files-num').text(result.length || '');
|
|
|
+ });
|
|
|
+ }, '确认删除该文件?');
|
|
|
+ });
|
|
|
+
|
|
|
postData(window.location.pathname + '/load', {}, function (result) {
|
|
|
const datas = result.contractTree.concat(result.contractList);
|
|
|
for (const t of datas) {
|
|
|
@@ -2428,7 +2765,8 @@ $(document).ready(function() {
|
|
|
postData(window.location.pathname + '/update', {postType: 'add-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);
|
|
|
+ // contractTreeSpreadObj.setContractPays(result.pays, node);
|
|
|
+ contractTreeSpreadObj.setContractListHtml('pay', node, result.pays);
|
|
|
contractTreeSpreadObj.checkCloseStatus(node);
|
|
|
contractTreeSpreadObj.setContract(contractSheet, false);
|
|
|
// const selection = contractSheet.getSelections();
|
|
|
@@ -2482,7 +2820,8 @@ $(document).ready(function() {
|
|
|
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);
|
|
|
+ // contractTreeSpreadObj.setContractPays(result.pays, node);
|
|
|
+ contractTreeSpreadObj.setContractListHtml('pay', node, result.pays);
|
|
|
contractTreeSpreadObj.setContract(contractSheet, false);
|
|
|
// const selection = contractSheet.getSelections();
|
|
|
// const sel = selection ? selection[0] : contractSheet.getSelections()[0];
|
|
|
@@ -2579,6 +2918,151 @@ $(document).ready(function() {
|
|
|
contractTreeSpreadObj.openContractPayFiles(pay);
|
|
|
});
|
|
|
|
|
|
+ $('#add-contract-supplement').click(function () {
|
|
|
+ const node = SpreadJsObj.getSelectObject(contractSheet);
|
|
|
+ if (!node || !node.c_code) {
|
|
|
+ toastr.error('请选择一个合同节点');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!(node.uid === user_id || permission_edit_contract)) {
|
|
|
+ toastr.error('没有权限新增补充合同');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!(!shenpi_status || (shenpi_status && node.status === auditConst.status.checked))) {
|
|
|
+ toastr.error('该合同审批状态未通过,不能添加');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (node.settle_code) {
|
|
|
+ toastr.error('该合同已结算,不能添加');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const data = {
|
|
|
+ code: $('#cons-addsupplement input[name="code"]').val(),
|
|
|
+ name: $('#cons-addsupplement input[name="name"]').val(),
|
|
|
+ price: $('#cons-addsupplement input[name="price"]').val(),
|
|
|
+ party_a: $('#cons-addsupplement input[name="party_a"]').val(),
|
|
|
+ party_b: $('#cons-addsupplement input[name="party_b"]').val(),
|
|
|
+ sign_time: $('#cons-addsupplement input[name="sign_time"]').val() || null,
|
|
|
+ address: $('#cons-addsupplement input[name="address"]').val(),
|
|
|
+ content: $('#cons-addsupplement textarea[name="content"]').val(),
|
|
|
+ }
|
|
|
+ if (!judgeSupplements(data)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log(node, data);
|
|
|
+ postData(window.location.pathname + '/update', {postType: 'add-contract-supplement', postData: { select: node.id, supplement: data }}, function (result) {
|
|
|
+ const refreshNode = contractTree.loadPostData(result.node);
|
|
|
+ contractTreeSpreadObj.refreshTree(contractSheet, refreshNode);
|
|
|
+ // contractTreeSpreadObj.setContractSupplements(result.supplements, node);
|
|
|
+ contractTreeSpreadObj.setContractListHtml('supplement', node, result.supplements);
|
|
|
+ contractTreeSpreadObj.checkCloseStatus(node);
|
|
|
+ contractTreeSpreadObj.setContract(contractSheet, false);
|
|
|
+ $('#cons-addsupplement').modal('hide');
|
|
|
+ })
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#save-contract-supplement').click(function () {
|
|
|
+ const node = SpreadJsObj.getSelectObject(contractSheet);
|
|
|
+ if (!node || !node.c_code) {
|
|
|
+ toastr.error('请选择一个合同节点');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (node.settle_code) {
|
|
|
+ toastr.error('该合同已结算,不能修改');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const csid = $('#cons-addsupplement input[name="csid"]').val();
|
|
|
+ const csInfo = _.find(contractSupplements, { id: parseInt(csid) });
|
|
|
+ if (!csInfo) {
|
|
|
+ toastr.error('未找到该补充合同');
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let only_sf_edit = false;
|
|
|
+ if (shenpi_status && (csInfo.status === auditConst.status.checking || csInfo.status === auditConst.status.checkNoPre) && csInfo.curAuditorIds && csInfo.curAuditorIds.length > 0 && csInfo.curAuditorIds.indexOf(user_id) > -1) {
|
|
|
+ only_sf_edit = true;
|
|
|
+ }
|
|
|
+ if (!(csInfo.uid === user_id || only_sf_edit)) {
|
|
|
+ toastr.error('只能编辑自己创建的补充合同');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const data = {
|
|
|
+ id: csInfo.id,
|
|
|
+ code: $('#cons-addsupplement input[name="code"]').val(),
|
|
|
+ name: $('#cons-addsupplement input[name="name"]').val(),
|
|
|
+ price: $('#cons-addsupplement input[name="price"]').val(),
|
|
|
+ party_a: $('#cons-addsupplement input[name="party_a"]').val(),
|
|
|
+ party_b: $('#cons-addsupplement input[name="party_b"]').val(),
|
|
|
+ sign_time: $('#cons-addsupplement input[name="sign_time"]').val() || null,
|
|
|
+ address: $('#cons-addsupplement input[name="address"]').val(),
|
|
|
+ content: $('#cons-addsupplement textarea[name="content"]').val(),
|
|
|
+ }
|
|
|
+ if (!judgeSupplements(data)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log(node, data);
|
|
|
+ postData(window.location.pathname + '/update', {postType: 'save-contract-supplement', postData: { select: node.id, supplement: data }}, function (result) {
|
|
|
+ const refreshNode = contractTree.loadPostData(result.node);
|
|
|
+ contractTreeSpreadObj.refreshTree(contractSheet, refreshNode);
|
|
|
+ // contractTreeSpreadObj.setContractSupplements(result.supplements, node);
|
|
|
+ contractTreeSpreadObj.setContractListHtml('supplement', node, result.supplements);
|
|
|
+ contractTreeSpreadObj.setContract(contractSheet, false);
|
|
|
+ // const selection = contractSheet.getSelections();
|
|
|
+ // const sel = selection ? selection[0] : contractSheet.getSelections()[0];
|
|
|
+ // const row = sel ? sel.row : -1;
|
|
|
+ // contractTreeSpreadObj.setForeColor(contractSheet, row);
|
|
|
+ $('#cons-addsupplement').modal('hide');
|
|
|
+ })
|
|
|
+ });
|
|
|
+
|
|
|
+ function judgeSupplements(data) {
|
|
|
+ let flag = true;
|
|
|
+ if (!data.code) {
|
|
|
+ toastr.error('请输入编号');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (!data.name) {
|
|
|
+ toastr.error('请输入名称');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ console.log(data.price);
|
|
|
+ if (data.price === '') {
|
|
|
+ toastr.error('请输入金额');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 金额只能输入数字
|
|
|
+ if (!/^\d+(\.\d+)?$/.test(data.price)) {
|
|
|
+ toastr.error('金额只能输入数字');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ $('body').on('click', '.open-supplement-files', function () {
|
|
|
+ const csid = $(this).attr('data-csid');
|
|
|
+ if (!csid) {
|
|
|
+ toastr.error('获取补充合同信息失败');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const supplement = _.find(contractSupplements, { id: parseInt(csid) });
|
|
|
+ if (!supplement) {
|
|
|
+ toastr.error('获取补充合同信息失败');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const node = SpreadJsObj.getSelectObject(contractSheet);
|
|
|
+ if (!node || !node.c_code) {
|
|
|
+ toastr.error('请选择一个合同节点');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (node.uid === user_id || supplement.uid === user_id || permission_att) {
|
|
|
+ $('#cons-supplement-file .upload-permission').show();
|
|
|
+ } else {
|
|
|
+ $('#cons-supplement-file .upload-permission').hide();
|
|
|
+ }
|
|
|
+ $('#cons-supplement-file').modal('show');
|
|
|
+ $('#cons-supplement-file input[name="csid"]').val(csid);
|
|
|
+ contractTreeSpreadObj.openContractSupplementFiles(supplement);
|
|
|
+ });
|
|
|
+
|
|
|
$('#cons-close').on('show.bs.modal', function () {
|
|
|
const node = SpreadJsObj.getSelectObject(contractSheet);
|
|
|
if (!node || !node.c_code) {
|
|
|
@@ -2696,6 +3180,42 @@ $(document).ready(function() {
|
|
|
return shenpi_html;
|
|
|
}
|
|
|
|
|
|
+ function setSupplementShenpiHtml(pay, reload = false, contract = null) {
|
|
|
+ let shenpi_html = '';
|
|
|
+ if (shenpi_status) {
|
|
|
+ if (contract && contract.status !== auditConst.status.checked) {
|
|
|
+ shenpi_html += `<td class="text-secondary">合同未完成审批</td>`;
|
|
|
+ return shenpi_html;
|
|
|
+ }
|
|
|
+ shenpi_html += !reload ? `<td class="shenpi-td ${auditConst.auditProgressClass[pay.status]}">` : '';
|
|
|
+ if ((pay.status === auditConst.status.uncheck || pay.status === auditConst.status.checkNo) && pay.uid === user_id) {
|
|
|
+ shenpi_html += `<a href="javascript:void(0);" node-cid="${pay.cid}" node-cpid="${pay.id}" class="btn ${auditConst.statusButtonClass[pay.status]} btn-sm show-sub-sp">${auditConst.statusButton[pay.status]}</a>`;
|
|
|
+ } else if ((pay.status === auditConst.status.checking || pay.status === auditConst.status.checkNoPre) && pay.curAuditors && pay.curAuditors.findIndex(x => { return x.aid === user_id; }) >= 0) {
|
|
|
+ shenpi_html += `<a href="javascript: void(0);" node-cid="${pay.cid}" node-cpid="${pay.id}" data-operate="checked" data-title="审批通过" class="btn btn-success btn-sm mr-2 show-sp-list">审批通过</a>`;
|
|
|
+ shenpi_html += `<a href="javascript: void(0);" node-cid="${pay.cid}" node-cpid="${pay.id}" data-operate="checkNo" data-title="审批退回" class="btn btn-warning btn-sm show-sp-list">审批退回</a>`;
|
|
|
+ } else {
|
|
|
+ if (pay.status === auditConst.status.checked && pay.final_auditor_str) {
|
|
|
+ shenpi_html += `<a href="javascript:void(0);" node-cid="${pay.cid}" node-cpid="${pay.id}" class="show-sp-list">${pay.final_auditor_str}</a>`;
|
|
|
+ } else if (pay.status === auditConst.status.checkNo && pay.curAuditors2 && pay.curAuditors2.length > 0) {
|
|
|
+ if (pay.curAuditors2[0].audit_type === auditType.key.common) {
|
|
|
+ shenpi_html += `<a href="javascript:void(0);" node-cid="${pay.cid}" node-cpid="${pay.id}" class="show-sp-list">${pay.curAuditors2[0].name}${pay.curAuditors2[0].role !== '' && pay.curAuditors2[0].role !== null ? '-' + pay.curAuditors2[0].role : ''}</a>`;
|
|
|
+ } else {
|
|
|
+ shenpi_html += `<a href="javascript:void(0);" node-cid="${pay.cid}" node-cpid="${pay.id}" class="show-sp-list">${transFormToChinese(pay.curAuditors2[0].audit_order) + '审'}</a>`;
|
|
|
+ }
|
|
|
+ } else if (pay.curAuditors.length > 0) {
|
|
|
+ if (pay.curAuditors[0].audit_type === auditType.key.common) {
|
|
|
+ shenpi_html += `<a href="javascript:void(0);" node-cid="${pay.cid}" node-cpid="${pay.id}" class="show-sp-list">${pay.curAuditors[0].name}${pay.curAuditors[0].role !== '' && pay.curAuditors[0].role !== null ? '-' + pay.curAuditors[0].role : ''}</a>`;
|
|
|
+ } else {
|
|
|
+ shenpi_html += `<a href="javascript:void(0);" node-cid="${pay.cid}" node-cpid="${pay.id}" class="show-sp-list">${transFormToChinese(pay.curAuditors[0].audit_order) + '审'}</a>`;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ shenpi_html += ` ${auditConst.auditProgress[pay.status]}`;
|
|
|
+ }
|
|
|
+ shenpi_html += !reload ? '</td>' : '';
|
|
|
+ }
|
|
|
+ return shenpi_html;
|
|
|
+ }
|
|
|
+
|
|
|
if (shenpi_status || pay_shenpi_status) {
|
|
|
$('body').on('click', '.show-sub-sp', function () {
|
|
|
console.log($(this).attr('node-cid'));
|