|
@@ -267,7 +267,7 @@ function calculateStagePosData(datas) {
|
|
|
}
|
|
|
|
|
|
$(document).ready(() => {
|
|
|
- let spec;
|
|
|
+ let spec, ledgerSearch, gclSearch;
|
|
|
autoFlashHeight();
|
|
|
initSpreadSettingWithRoles([]);
|
|
|
const billsSpread = SpreadJsObj.createNewSpread($('#bills-spread')[0]);
|
|
@@ -334,6 +334,25 @@ $(document).ready(() => {
|
|
|
leafXmjSpread.refresh();
|
|
|
}
|
|
|
});
|
|
|
+ // 工具栏resizer
|
|
|
+ $.divResizer({
|
|
|
+ select: '#tz-right-spr',
|
|
|
+ callback: function () {
|
|
|
+ billsSpread.refresh();
|
|
|
+ posSpread.refresh();
|
|
|
+ window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
|
|
|
+ if (ledgerSearch) ledgerSearch.spread.refresh();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $.divResizer({
|
|
|
+ select: '#gcl-right-spr',
|
|
|
+ callback: function () {
|
|
|
+ gclSpread.refresh();
|
|
|
+ leafXmjSpread.refresh();
|
|
|
+ window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
|
|
|
+ if (gclSearch) gclSearch.spread.refresh();
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
const cTree = createNewPathTree('master', {
|
|
|
id: 'ledger_id',
|
|
@@ -517,6 +536,175 @@ $(document).ready(() => {
|
|
|
});
|
|
|
})('a[name=showLevel]', billsSheet);
|
|
|
|
|
|
+ // 展开收起工具栏
|
|
|
+ const showTzSideTools = function (show) {
|
|
|
+ const left = $('#tz-left-view'), right = $('#tz-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();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const showGclSideTools = function (show) {
|
|
|
+ const left = $('#gcl-left-view'), right = $('#gcl-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();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ $('a', '#tz-side-menu').bind('click', function (e) {
|
|
|
+ e.preventDefault();
|
|
|
+ const tab = $(this), tabPanel = $(tab.attr('content'));
|
|
|
+ // 展开工具栏、切换标签
|
|
|
+ if (!tab.hasClass('active')) {
|
|
|
+ // const close = $('.active', '#side-menu').length === 0;
|
|
|
+ $('a', '#tz-side-menu').removeClass('active');
|
|
|
+ $('.tab-content .tab-select-show.tab-pane.active').removeClass('active');
|
|
|
+ tab.addClass('active');
|
|
|
+ tabPanel.addClass('active');
|
|
|
+ // $('.tab-content .tab-pane').removeClass('active');
|
|
|
+ showTzSideTools(tab.hasClass('active'));
|
|
|
+ if (tab.attr('content') === '#tz-search') {
|
|
|
+ if (!ledgerSearch) {
|
|
|
+ ledgerSearch = $.ledgerSearch({
|
|
|
+ selector: '#tz-search',
|
|
|
+ ledger: { billsTree: cTree, pos: cPos },
|
|
|
+ resultSpreadSetting: {
|
|
|
+ cols: [
|
|
|
+ {title: '项目节编号', field: 'code', hAlign: 0, width: 90, formatter: '@'},
|
|
|
+ {title: '清单编号', field: 'b_code', hAlign: 0, width: 80, formatter: '@'},
|
|
|
+ {title: '名称', field: 'name', width: 150, hAlign: 0, formatter: '@'},
|
|
|
+ {title: '单位', field: 'unit', width: 50, hAlign: 1, formatter: '@'},
|
|
|
+ {title: '单价', field: 'unit_price', hAlign: 2, width: 50},
|
|
|
+ ],
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [32],
|
|
|
+ headColWidth: [30],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ selectedBackColor: '#fffacd',
|
|
|
+ readOnly: true,
|
|
|
+ },
|
|
|
+ locate: function(cur) {
|
|
|
+ if (!cur.lid) return;
|
|
|
+
|
|
|
+ SpreadJsObj.locateTreeNode(billsSheet, cur.lid, true);
|
|
|
+ loadPosData();
|
|
|
+ if (cur.pid && cur.pid !== -1) {
|
|
|
+ const pIndex = posSheet.zh_data.findIndex(x => { return x.id === cur.pid; });
|
|
|
+ SpreadJsObj.locateRow(posSheet, pIndex);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
+ ledgerSearch.spread.refresh();
|
|
|
+ }
|
|
|
+ } else { // 收起工具栏
|
|
|
+ tab.removeClass('active');
|
|
|
+ tabPanel.removeClass('active');
|
|
|
+ showTzSideTools(tab.hasClass('active'));
|
|
|
+ }
|
|
|
+ billsSpread.refresh();
|
|
|
+ posSpread.refresh();
|
|
|
+ });
|
|
|
+ $('a', '#gcl-side-menu').bind('click', function (e) {
|
|
|
+ e.preventDefault();
|
|
|
+ const tab = $(this), tabPanel = $(tab.attr('content'));
|
|
|
+ // 展开工具栏、切换标签
|
|
|
+ if (!tab.hasClass('active')) {
|
|
|
+ // const close = $('.active', '#side-menu').length === 0;
|
|
|
+ $('a', '#gcl-side-menu').removeClass('active');
|
|
|
+ $('.tab-content .tab-select-show.tab-pane.active').removeClass('active');
|
|
|
+ tab.addClass('active');
|
|
|
+ tabPanel.addClass('active');
|
|
|
+ // $('.tab-content .tab-pane').removeClass('active');
|
|
|
+ showGclSideTools(tab.hasClass('active'));
|
|
|
+ if (tab.attr('content') === '#gcl-search') {
|
|
|
+ if (!gclSearch) {
|
|
|
+ gclSearch = $.gclSearch({
|
|
|
+ selector: '#gcl-search',
|
|
|
+ gcl: { bills: gclGatherData, getBillsXmj: function(node){ return node.leafXmjs; } },
|
|
|
+ searchField: { bills: ['b_code', 'name'], xmj: ['code', 'dwgc', 'fbgc', 'fxgc', 'jldy', 'bwmx'], },
|
|
|
+ resultSpreadSetting: {
|
|
|
+ cols: [
|
|
|
+ {title: '清单编号', field: 'b_code', hAlign: 0, width: 80, formatter: '@'},
|
|
|
+ {title: '项目节编号', field: 'code', hAlign: 0, width: 80, formatter: '@'},
|
|
|
+ {title: '名称', field: 'name', width: 120, hAlign: 0, formatter: '@'},
|
|
|
+ {title: '单位', field: 'unit', width: 50, hAlign: 1, formatter: '@'},
|
|
|
+ {title: '单价', field: 'unit_price', hAlign: 2, width: 50},
|
|
|
+ {title: '单位工程', colSpan: '1', rowSpan: '2', field: 'dwgc', hAlign: 0, width: 80, formatter: '@'},
|
|
|
+ {title: '分部工程', colSpan: '1', rowSpan: '2', field: 'fbgc', hAlign: 0, width: 80, formatter: '@'},
|
|
|
+ {title: '分项工程', colSpan: '1', rowSpan: '2', field: 'fxgc', hAlign: 0, width: 80, formatter: '@'},
|
|
|
+ {title: '细目', colSpan: '1', rowSpan: '2', field: 'jldy', hAlign: 0, width: 80, formatter: '@'},
|
|
|
+ {title: '计量单元', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 80, formatter: '@'},
|
|
|
+ ],
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [32],
|
|
|
+ headColWidth: [30],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ selectedBackColor: '#fffacd',
|
|
|
+ readOnly: true,
|
|
|
+ },
|
|
|
+ locate: function(cur) {
|
|
|
+ if (!cur.bid) return;
|
|
|
+
|
|
|
+ const bIndex = gclSheet.zh_data.findIndex(x => { return x.id === cur.bid; });
|
|
|
+ SpreadJsObj.locateRow(gclSheet, bIndex);
|
|
|
+ loadLeafXmjData();
|
|
|
+ if (cur.xid && cur.xid !== -1) {
|
|
|
+ const xIndex = leafXmjSheet.zh_data.findIndex(x => { return x.id === cur.xid; });
|
|
|
+ SpreadJsObj.locateRow(leafXmjSheet, xIndex);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
+ gclSearch.spread.refresh();
|
|
|
+ }
|
|
|
+ } else { // 收起工具栏
|
|
|
+ tab.removeClass('active');
|
|
|
+ tabPanel.removeClass('active');
|
|
|
+ showGclSideTools(tab.hasClass('active'));
|
|
|
+ }
|
|
|
+ gclSpread.refresh();
|
|
|
+ leafXmjSpread.refresh();
|
|
|
+ });
|
|
|
+
|
|
|
$('#exportExcel').click(function () {
|
|
|
const exportLedger = function () {
|
|
|
const data = [];
|