|
@@ -8,7 +8,10 @@
|
|
|
* @version
|
|
|
*/
|
|
|
|
|
|
+
|
|
|
+
|
|
|
$(document).ready(() => {
|
|
|
+ let xmjSearch;
|
|
|
const preUrl = window.location.pathname.split('/').slice(0, 6).join('/');
|
|
|
autoFlashHeight();
|
|
|
const xmjSpread = SpreadJsObj.createNewSpread($('#xmj-spread')[0]);
|
|
@@ -33,27 +36,29 @@ $(document).ready(() => {
|
|
|
xmjSpread.bind(spreadNS.Events.SelectionChanged, function (e, info) {
|
|
|
unitTreeObj.loadCurUnitData();
|
|
|
});
|
|
|
-
|
|
|
- postData(window.location.pathname + '/load', {}, function (result) {
|
|
|
- const setting = {
|
|
|
- id: 'ledger_id',
|
|
|
- pid: 'ledger_pid',
|
|
|
- order: 'order',
|
|
|
- level: 'level',
|
|
|
- rootId: -1,
|
|
|
- fullPath: 'full_path',
|
|
|
- };
|
|
|
- const xmjTree = createNewPathTree('base', setting);
|
|
|
- xmjTree.loadDatas(result);
|
|
|
- for (const n of xmjTree.nodes) {
|
|
|
- if (n.unitTreeData) {
|
|
|
- n.unitTree = createNewPathTree('base', setting);
|
|
|
- n.unitTree.loadDatas(n.unitTreeData);
|
|
|
+ const loadData = function (dataType) {
|
|
|
+ postData(window.location.pathname + '/load', {filter: dataType}, function (result) {
|
|
|
+ const setting = {
|
|
|
+ id: 'ledger_id',
|
|
|
+ pid: 'ledger_pid',
|
|
|
+ order: 'order',
|
|
|
+ level: 'level',
|
|
|
+ rootId: -1,
|
|
|
+ fullPath: 'full_path',
|
|
|
+ };
|
|
|
+ const xmjTree = createNewPathTree('base', setting);
|
|
|
+ xmjTree.loadDatas(result);
|
|
|
+ for (const n of xmjTree.nodes) {
|
|
|
+ if (n.unitTreeData) {
|
|
|
+ n.unitTree = createNewPathTree('base', setting);
|
|
|
+ n.unitTree.loadDatas(n.unitTreeData);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- SpreadJsObj.loadSheetData(xmjSheet, SpreadJsObj.DataType.Tree, xmjTree);
|
|
|
- unitTreeObj.loadCurUnitData();
|
|
|
- });
|
|
|
+ SpreadJsObj.loadSheetData(xmjSheet, SpreadJsObj.DataType.Tree, xmjTree);
|
|
|
+ unitTreeObj.loadCurUnitData();
|
|
|
+ });
|
|
|
+ };
|
|
|
+ loadData('all');
|
|
|
|
|
|
$.subMenu({
|
|
|
menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
|
|
@@ -83,4 +88,222 @@ $(document).ready(() => {
|
|
|
unitSpread.refresh();
|
|
|
}
|
|
|
});
|
|
|
+ $.divResizer({
|
|
|
+ select: '#right-spr',
|
|
|
+ callback: function () {
|
|
|
+ xmjSpread.refresh();
|
|
|
+ unitSpread.refresh();
|
|
|
+ if (xmjSearch) {
|
|
|
+ xmjSearch.spread.refresh();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $('a', '.side-menu').bind('click', function (e) {
|
|
|
+ e.preventDefault();
|
|
|
+ const tab = $(this), tabPanel = $(tab.attr('content'));
|
|
|
+ const showSideTools = function (show) {
|
|
|
+ const left = $('#left-view'), right = $('#right-view'), parent = left.parent();
|
|
|
+ if (show) {
|
|
|
+ right.show();
|
|
|
+ autoFlashHeight();
|
|
|
+ /**
|
|
|
+ * right.show()后, parent被撑开成2倍left.height, 导致parent.width减少了10px
|
|
|
+ * 第一次left.width调整后,parent的缩回left.height, 此时parent.width又增加了10px
|
|
|
+ * 故需要通过最终的parent.width再计算一次left.width
|
|
|
+ *
|
|
|
+ * Q: 为什么不通过先计算left.width的宽度,以避免计算两次left.width?
|
|
|
+ * A: 右侧工具栏不一定显示,当右侧工具栏显示过一次后,就必须使用parent和right来计算left.width
|
|
|
+ *
|
|
|
+ */
|
|
|
+ //left.css('width', parent.width() - right.outerWidth());
|
|
|
+ //left.css('width', parent.width() - right.outerWidth());
|
|
|
+ const percent = 100 - right.outerWidth() /parent.width() * 100;
|
|
|
+ left.css('width', percent + '%');
|
|
|
+ } else {
|
|
|
+ left.width(parent.width());
|
|
|
+ right.hide();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ // 展开工具栏、切换标签
|
|
|
+ if (!tab.hasClass('active')) {
|
|
|
+ const close = $('.active', '#side-menu').length === 0;
|
|
|
+ $('a', '#side-menu').removeClass('active');
|
|
|
+ tab.addClass('active');
|
|
|
+ $('.tab-content .tab-pane').removeClass('active');
|
|
|
+ tabPanel.addClass('active');
|
|
|
+ showSideTools(tab.hasClass('active'));
|
|
|
+ if (tab.attr('content') === '#search' && !xmjSearch) {
|
|
|
+ if (!xmjSearch) {
|
|
|
+ xmjSearch = $.billsSearch({
|
|
|
+ selector: '#search',
|
|
|
+ searchSpread: xmjSpread,
|
|
|
+ searchRangeStr: '项目节编号/名称',
|
|
|
+ searchOver: true,
|
|
|
+ searchEmpty: true,
|
|
|
+ resultSpreadSetting: {
|
|
|
+ cols: [
|
|
|
+ {title: '项目节编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true},
|
|
|
+ {title: '名称', field: 'name', width: 150, hAlign: 0, formatter: '@', readOnly: true},
|
|
|
+ {title: '单位', field: 'unit', width: 50, hAlign: 1, formatter: '@', readOnly: true},
|
|
|
+ {title: '金额', field: 'total_price', hAlign: 2, width: 80, readOnly: true},
|
|
|
+ {title: '完成率(%)', field: 'complete_percent', hAlign: 2, width: 70},
|
|
|
+ ],
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [32],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ selectedBackColor: '#fffacd',
|
|
|
+ },
|
|
|
+ afterLocated: function () {
|
|
|
+ unitTreeObj.loadCurUnitData();
|
|
|
+ },
|
|
|
+ checkLess: function (node) {
|
|
|
+ if (node.quantity) {
|
|
|
+ return ZhCalc.sub(ZhCalc.add(node.quantity, node.end_qc_qty), node.end_gather_qty) > 0;
|
|
|
+ } else if (node.total_price) {
|
|
|
+ return ZhCalc.sub(ZhCalc.add(node.total_price, node.end_qc_tp), node.end_gather_tp) > 0;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ checkOver: function (node) {
|
|
|
+ if (node.unitTree) {
|
|
|
+ for (const u of node.unitTree.nodes) {
|
|
|
+ if (u.end_gather_qty) {
|
|
|
+ if (ZhCalc.sub(u.end_contract_qty, u.quantity) > 0) return true;
|
|
|
+ } else if (u.end_gather_tp) {
|
|
|
+ if (ZhCalc.sub(u.end_contract_tp, u.total_price) > 0) return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ } else if (node.end_gather_qty) {
|
|
|
+ return !node.quantity || Math.abs(node.end_gather_qty) > Math.abs(ZhCalc.add(node.quantity, node.end_qc_qty));
|
|
|
+ } else if (node.end_gather_tp) {
|
|
|
+ return !node.total_price || Math.abs(node.end_gather_tp) > Math.abs(ZhCalc.add(node.total_price, node.end_qc_tp));
|
|
|
+ }
|
|
|
+ },
|
|
|
+ checkEmpty: function (node) {
|
|
|
+ if (node.quantity) {
|
|
|
+ return !node.end_gather_qty || checkZero(node.end_gather_qty);
|
|
|
+ } else if (node.total_price) {
|
|
|
+ return !node.end_gather_tp || checkZero(node.end_gather_tp);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
+ xmjSearch.spread.refresh();
|
|
|
+ }
|
|
|
+ } else { // 收起工具栏
|
|
|
+ tab.removeClass('active');
|
|
|
+ tabPanel.removeClass('active');
|
|
|
+ showSideTools(tab.hasClass('active'));
|
|
|
+ }
|
|
|
+ xmjSpread.refresh();
|
|
|
+ unitSpread.refresh();
|
|
|
+ });
|
|
|
+ // 显示层次
|
|
|
+ (function (select, sheet) {
|
|
|
+ $(select).click(function () {
|
|
|
+ const tag = $(this).attr('tag');
|
|
|
+ const tree = sheet.zh_tree;
|
|
|
+ if (!tree) return;
|
|
|
+ switch (tag) {
|
|
|
+ case "1":
|
|
|
+ case "2":
|
|
|
+ case "3":
|
|
|
+ case "4":
|
|
|
+ case "5":
|
|
|
+ tree.expandByLevel(parseInt(tag));
|
|
|
+ SpreadJsObj.refreshTreeRowVisible(sheet);
|
|
|
+ break;
|
|
|
+ case "last":
|
|
|
+ tree.expandByCustom(() => { return true; });
|
|
|
+ SpreadJsObj.refreshTreeRowVisible(sheet);
|
|
|
+ break;
|
|
|
+ case "curMeasure":
|
|
|
+ tree.expandByCustom(function (node) {
|
|
|
+ for (const field of ['contract_tp', 'qc_tp', 'gather_tp']) {
|
|
|
+ if (node[field]) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ SpreadJsObj.refreshTreeRowVisible(sheet);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })('a[name=showLevel]', xmjSheet);
|
|
|
+ // 过滤数据
|
|
|
+ $('a[name=load-data]').click(function () {
|
|
|
+ const tag = $(this).attr('tag');
|
|
|
+ loadData(tag);
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#exportBwtz').click(function () {
|
|
|
+ const data = [];
|
|
|
+ const setting = {
|
|
|
+ cols: [
|
|
|
+ {title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 100, formatter: '@'},
|
|
|
+ {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 70, formatter: '@'},
|
|
|
+ {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 300, formatter: '@'},
|
|
|
+ {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@'},
|
|
|
+ {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '台账|数量', colSpan: '2|1', rowSpan: '1|1', field: 'quantity', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '本期合同计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'contract_tp', hAlign: 2, width: 60, type: 'Number'},
|
|
|
+ {title: '本期数量变更|数量', colSpan: '3|1', rowSpan: '1|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'qc_tp', hAlign: 2, width: 60, type: 'Number'},
|
|
|
+ {title: '|变更令', colSpan: '|1', rowSpan: '|1', field: 'bgl_code', hAlign: 2, width: 60, formatter: '@'},
|
|
|
+ {title: '本期完成计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'gather_qty', hAlign: 2, width: 60, type: 'Number'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'gather_tp', hAlign: 2, width: 60, type: 'Number'},
|
|
|
+ {title: '截止本期合同计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, type: 'Number'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'end_contract_tp', hAlign: 2, width: 60, type: 'Number'},
|
|
|
+ {title: '截止本期数量变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'end_qc_qty', hAlign: 2, width: 60, type: 'Number'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'end_qc_tp', hAlign: 2, width: 60, type: 'Number'},
|
|
|
+ {title: '截止本期完成计量|数量', colSpan: '3|1', rowSpan: '1|1', field: 'end_gather_qty', hAlign: 2, width: 60, type: 'Number'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'end_gather_tp', hAlign: 2, width: 60, type: 'Number'},
|
|
|
+ {title: '|完成率(%)', colSpan: '|1', rowSpan: '|1', field: 'end_gather_percent', hAlign: 2, width: 60, type: 'Number'},
|
|
|
+ {title: '图(册)号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 100, formatter: '@'},
|
|
|
+ {title: '本期批注', colSpan: '1', rowSpan: '2', field: 'postil', hAlign: 0, width: 100, formatter: '@'},
|
|
|
+ {title: '备注', colSpan: '1', rowSpan: '2', field: 'memo', hAlign: 0, width: 100, formatter: '@'},
|
|
|
+ ],
|
|
|
+ headRows: 2,
|
|
|
+ headRowHeight: [25, 25],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: 'bold 10px 微软雅黑',
|
|
|
+ font: '10px 微软雅黑'
|
|
|
+ };
|
|
|
+ if (!xmjSheet.zh_tree) return;
|
|
|
+ for (const node of xmjSheet.zh_tree.nodes) {
|
|
|
+ data.push({
|
|
|
+ code: node.code, b_code: node.b_code, name: node.name, unit: node.unit,
|
|
|
+ unit_price: node.unit_price, quantity: node.quantity, total_price: node.total_price,
|
|
|
+ contract_tp: node.contract_tp, qc_tp: node.qc_tp, gather_tp: node.gather_tp,
|
|
|
+ end_contract_tp: node.end_contract_tp, end_qc_tp: node.end_qc_tp, end_gather_tp: node.end_gather_tp,
|
|
|
+ end_gather_percent: node.end_gather_percent,
|
|
|
+ drawing_code: node.drawing_code, postil: node.postil, memo: node.memo
|
|
|
+ });
|
|
|
+ if (node.unitTree) {
|
|
|
+ for (const unitNode of node.unitTree.nodes) {
|
|
|
+ data.push({
|
|
|
+ code: unitNode.code, b_code: unitNode.b_code,
|
|
|
+ name: unitNode.pos_name ? unitNode.pos_name : unitNode.name, unit: unitNode.unit,
|
|
|
+ unit_price: unitNode.unit_price, quantity: unitNode.quantity, total_price: unitNode.total_price,
|
|
|
+ contract_qty: unitNode.contract_qty, contract_tp: unitNode.contract_tp,
|
|
|
+ qc_qty: unitNode.qc_qty, qc_tp: unitNode.qc_tp,
|
|
|
+ gather_qty: unitNode.gather_qty, gather_tp: unitNode.gather_tp,
|
|
|
+ end_contract_qty: unitNode.end_contract_qty, end_contract_tp: unitNode.end_contract_tp,
|
|
|
+ end_qc_qty: unitNode.end_qc_qty, end_qc_tp: unitNode.end_qc_tp,
|
|
|
+ end_gather_qty: unitNode.end_gather_qty, end_gather_tp: unitNode.end_gather_tp,
|
|
|
+ end_gather_percent: unitNode.end_gather_percent,
|
|
|
+ drawing_code: unitNode.drawing_code, postil: unitNode.postil_merge, memo: unitNode.memo
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SpreadExcelObj.exportSimpleXlsxSheet(setting, data, $('h2')[0].innerHTML + "-部位台账.xlsx");
|
|
|
+ });
|
|
|
});
|