|
|
@@ -2687,6 +2687,129 @@ $(document).ready(function() {
|
|
|
$('#cons-total').modal('show');
|
|
|
});
|
|
|
|
|
|
+ // 查找定位:右侧面板,通过 编号/合同编号/项目名称/合同名称 查找,双击定位到对应行
|
|
|
+ // 附加条件:签订日期超过XX天、实付比例小于XX%
|
|
|
+ function initContractSearch() {
|
|
|
+ const $panel = $('#contract-search');
|
|
|
+ $panel.html(
|
|
|
+ '<div class="sjs-bar">\n' +
|
|
|
+ ' <div class="input-group input-group-sm pb-1">\n' +
|
|
|
+ ' <input id="contractSearchKeyword" type="text" class="form-control" autocomplete="off" placeholder="可查找 编号/合同编号/项目名称/合同名称">\n' +
|
|
|
+ ' <div class="input-group-append">\n' +
|
|
|
+ ' <button class="btn btn-outline-secondary" type="button" id="contractSearchBtn">搜索</button>\n' +
|
|
|
+ ' <button class="btn btn-outline-secondary dropdown-toggle" type="button" id="contractSearchFilterBtn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="附加条件"><i class="fa fa-filter"></i></button>\n' +
|
|
|
+ ' <div class="dropdown-menu dropdown-menu-right p-2" aria-labelledby="contractSearchFilterBtn" style="width: 260px;">\n' +
|
|
|
+ ' <div class="form-check form-check-inline mb-1">\n' +
|
|
|
+ ' <input class="form-check-input" type="checkbox" id="contractSearchSignDate">\n' +
|
|
|
+ ' <label class="form-check-label small" for="contractSearchSignDate">签订日期超过</label>\n' +
|
|
|
+ ' <input type="number" class="form-control form-control-sm mx-1" id="contractSearchSignDays" value="180" min="0" step="1" style="width: 70px;">\n' +
|
|
|
+ ' <label class="form-check-label small">天</label>\n' +
|
|
|
+ ' </div>\n' +
|
|
|
+ ' <div class="form-check form-check-inline mb-1">\n' +
|
|
|
+ ' <input class="form-check-input" type="checkbox" id="contractSearchSfRatio">\n' +
|
|
|
+ ' <label class="form-check-label small" for="contractSearchSfRatio">实付比例小于</label>\n' +
|
|
|
+ ' <input type="number" class="form-control form-control-sm mx-1" id="contractSearchSfPercent" value="50" min="0" max="100" step="1" style="width: 70px;">\n' +
|
|
|
+ ' <label class="form-check-label small">%</label>\n' +
|
|
|
+ ' </div>\n' +
|
|
|
+ ' </div>\n' +
|
|
|
+ ' <span class="input-group-text" id="contractSearchCount">结果:0</span>\n' +
|
|
|
+ ' </div>\n' +
|
|
|
+ ' </div>\n' +
|
|
|
+ '</div>\n' +
|
|
|
+ '<div id="contract-search-result" class="sjs-contract"></div>'
|
|
|
+ );
|
|
|
+ autoFlashHeight();
|
|
|
+ const resultSpreadSetting = {
|
|
|
+ cols: [
|
|
|
+ {title: '编号', field: 'code', hAlign: 0, width: 120, formatter: '@'},
|
|
|
+ {title: '合同编号', field: 'c_code', hAlign: 0, width: 150, formatter: '@'},
|
|
|
+ {title: '项目名称/合同名称', field: 'name', hAlign: 0, width: 260, formatter: '@'},
|
|
|
+ {title: '合同金额', field: 'total_price', hAlign: 2, width: 130, formatter: '@'},
|
|
|
+ ],
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [32],
|
|
|
+ headColWidth: [30],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ selectedBackColor: '#fffacd',
|
|
|
+ readOnly: true,
|
|
|
+ };
|
|
|
+ const resultSpread = SpreadJsObj.createNewSpread($('#contract-search-result')[0]);
|
|
|
+ SpreadJsObj.initSheet(resultSpread.getActiveSheet(), resultSpreadSetting);
|
|
|
+
|
|
|
+ const doSearch = function () {
|
|
|
+ const keyword = ($('#contractSearchKeyword').val() || '').trim();
|
|
|
+ const checkSignDate = $('#contractSearchSignDate').is(':checked');
|
|
|
+ const checkSfRatio = $('#contractSearchSfRatio').is(':checked');
|
|
|
+ const signDays = parseInt($('#contractSearchSignDays').val());
|
|
|
+ const sfPercent = parseFloat($('#contractSearchSfPercent').val());
|
|
|
+ const today = moment();
|
|
|
+ const result = [];
|
|
|
+ for (const node of contractTree.nodes) {
|
|
|
+ // 关键词匹配:编号/合同编号/项目名称/合同名称
|
|
|
+ let matched = false;
|
|
|
+ if (!keyword) {
|
|
|
+ matched = true;
|
|
|
+ } else {
|
|
|
+ matched = (node.code && String(node.code).indexOf(keyword) > -1) ||
|
|
|
+ (node.c_code && String(node.c_code).indexOf(keyword) > -1) ||
|
|
|
+ (node.name && String(node.name).indexOf(keyword) > -1);
|
|
|
+ }
|
|
|
+ if (!matched) continue;
|
|
|
+ // 附加条件1:签订日期超过XX天(签订日期为空的不查)
|
|
|
+ if (checkSignDate) {
|
|
|
+ if (!isNaN(signDays) && signDays >= 0) {
|
|
|
+ if (!node.sign_date) continue;
|
|
|
+ const diffDays = today.diff(moment(node.sign_date), 'days');
|
|
|
+ if (diffDays <= signDays) continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 附加条件2:实付比例小于XX%
|
|
|
+ if (checkSfRatio) {
|
|
|
+ if (!isNaN(sfPercent) && sfPercent >= 0 && sfPercent <= 100) {
|
|
|
+ const totalPrice = Number(node.total_price || 0);
|
|
|
+ const sfPrice = Number(node.sf_price || 0);
|
|
|
+ const ratio = totalPrice > 0 ? ZhCalc.mul(ZhCalc.div(sfPrice, totalPrice, 4), 100, 2) : 0;
|
|
|
+ if (ratio >= sfPercent) continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.push({
|
|
|
+ contract_id: node.contract_id,
|
|
|
+ code: node.code || '',
|
|
|
+ c_code: node.c_code || '',
|
|
|
+ name: node.name || '',
|
|
|
+ total_price: node.total_price || 0,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ $('#contractSearchCount').text('结果:' + result.length);
|
|
|
+ SpreadJsObj.loadSheetData(resultSpread.getActiveSheet(), 'data', result);
|
|
|
+ };
|
|
|
+
|
|
|
+ $('#contractSearchKeyword', $panel).bind('keydown', function (e) {
|
|
|
+ if (e.keyCode === 13) doSearch();
|
|
|
+ });
|
|
|
+ $('#contractSearchBtn', $panel).bind('click', doSearch);
|
|
|
+ // 点击附加条件面板内的元素时不关闭下拉菜单
|
|
|
+ $('#contractSearchFilterBtn').next('.dropdown-menu').on('click', function (e) {
|
|
|
+ e.stopPropagation();
|
|
|
+ });
|
|
|
+ // 复选框/数值变化时不自动搜索,用户点搜索按钮触发
|
|
|
+
|
|
|
+ // 双击结果行定位到合同树
|
|
|
+ resultSpread.getActiveSheet().bind(spreadNS.Events.CellDoubleClick, function (e, info) {
|
|
|
+ const sheet = info.sheet;
|
|
|
+ const data = sheet.zh_data;
|
|
|
+ if (!data) return;
|
|
|
+ const cur = data[info.row];
|
|
|
+ if (!cur || !cur.contract_id) return;
|
|
|
+ SpreadJsObj.locateTreeNode(contractSheet, cur.contract_id, true);
|
|
|
+ });
|
|
|
+
|
|
|
+ return {spread: resultSpread};
|
|
|
+ }
|
|
|
+
|
|
|
if (is_admin) {
|
|
|
const sqSpreadSetting = {
|
|
|
cols: [
|
|
|
@@ -4257,6 +4380,7 @@ $(document).ready(function() {
|
|
|
}
|
|
|
});
|
|
|
// 展开收起月信息价并浏览器记住本期展开收起
|
|
|
+ let contractSearch;
|
|
|
$('a', '.right-nav').bind('click', function () {
|
|
|
const tab = $(this), tabPanel = $(tab.attr('content'));
|
|
|
if (!tab.hasClass('active')) {
|
|
|
@@ -4265,6 +4389,13 @@ $(document).ready(function() {
|
|
|
tab.addClass('active');
|
|
|
tabPanel.addClass('active');
|
|
|
showSideTools(tab.hasClass('active'));
|
|
|
+ if (tab.attr('content') === '#contract-search') {
|
|
|
+ if (!contractSearch) {
|
|
|
+ contractSearch = initContractSearch();
|
|
|
+ }
|
|
|
+ updateSjsHeight();
|
|
|
+ contractSearch.spread.refresh();
|
|
|
+ }
|
|
|
if (tab.attr('content') === '#std-xmj') {
|
|
|
if (!stdXmj) {
|
|
|
stdXmj = $.stdLib(stdXmjSetting);
|