|
@@ -861,23 +861,148 @@ $(document).ready(() => {
|
|
|
Cookies.set('stage-col-visible', JSON.stringify(customDisplay), 7*24*60*60*1000);
|
|
|
$('#row-view').modal('hide');
|
|
|
});
|
|
|
- // 展开收起附件
|
|
|
- $('#fujianTab').click(function () {
|
|
|
- const obj = $(this), main = $('#main-view'), tool = $('#tools-view'), fujian = $('#fujian');
|
|
|
- if (obj.hasClass('active')) {
|
|
|
- main.attr('class', 'c-body col-12');
|
|
|
- tool.hide();
|
|
|
+
|
|
|
+ class SearchLedger {
|
|
|
+ constructor(obj, mainSpread) {
|
|
|
+ const self = this;
|
|
|
+ this.obj = obj;
|
|
|
+ this.mainSpread = mainSpread;
|
|
|
+ this.spreadSetting = {
|
|
|
+ cols: [
|
|
|
+ {title: '项目节编号', field: 'code', hAlign: 0, width: 120, formatter: '@'},
|
|
|
+ {title: '清单编号', field: 'b_code', hAlign: 0, width: 80, formatter: '@'},
|
|
|
+ {title: '名称', field: 'name', width: 230, hAlign: 0, formatter: '@'},
|
|
|
+ {title: '单位', field: 'unit', width: 50, hAlign: 1, formatter: '@'},
|
|
|
+ {title: '单价', field: 'unit_price', hAlign: 2, width: 50},
|
|
|
+ {title: '数量', field: 'quantity', hAlign: 2, width: 50},
|
|
|
+ {title: '完成率(%)', field: 'complete_percent', hAlign: 2, width: 70},
|
|
|
+ ],
|
|
|
+ emptyRows: 3,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [40],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ readOnly: true
|
|
|
+ };
|
|
|
+ this.spread = SpreadJsObj.createNewSpread($('#search-result', this.obj)[0]);
|
|
|
+ SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
|
|
|
+
|
|
|
+ $('#searchLedger', this.obj).bind('click', function () {
|
|
|
+ const keyword = $('#keyword', self.obj).val();
|
|
|
+ if (keyword !== '') {
|
|
|
+ $('#over', obj)[0].checked = false;
|
|
|
+ $('#empty', obj)[0].checked = false;
|
|
|
+ this.searchResult = [];
|
|
|
+ const sortData = SpreadJsObj.getSortData(self.mainSpread.getActiveSheet());
|
|
|
+ for (const node of sortData) {
|
|
|
+ if ((node.code && node.code.indexOf(keyword) > -1) ||
|
|
|
+ node.b_code && node.b_code.indexOf(keyword) > -1 ||
|
|
|
+ node.name && node.name.indexOf(keyword) > -1) {
|
|
|
+ this.searchResult.push(node);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', this.searchResult);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $('#over', this.obj).bind('change', function () {
|
|
|
+ this.searchResult = [];
|
|
|
+ const sortData = SpreadJsObj.getSortData(self.mainSpread.getActiveSheet());
|
|
|
+ for (const node of sortData) {
|
|
|
+ if (node.children && node.children.length > 0) continue;
|
|
|
+ if (node.end_gather_qty) {
|
|
|
+ if (!node.quantity || Math.abs(node.end_gather_qty) > Math.abs(node.quantity)) {
|
|
|
+ this.searchResult.push(node);
|
|
|
+ }
|
|
|
+ } else if (node.end_gather_tp) {
|
|
|
+ if (!node.total_price || Math.abs(node.end_gather_tp) > Math.abs(node.total_price)) {
|
|
|
+ this.searchResult.push(node);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', this.searchResult);
|
|
|
+ });
|
|
|
+ $('#empty', this.obj).bind('change', function () {
|
|
|
+ this.searchResult = [];
|
|
|
+ const sortData = SpreadJsObj.getSortData(self.mainSpread.getActiveSheet());
|
|
|
+ for (const node of sortData) {
|
|
|
+ if (node.children && node.children.length > 0) continue;
|
|
|
+ if (node.quantity) {
|
|
|
+ if (!node.end_gather_qty || checkZero(node.end_gather_qty)) {
|
|
|
+ this.searchResult.push(node);
|
|
|
+ }
|
|
|
+ } else if (node.total_price) {
|
|
|
+ if (!node.end_gather_tp || checkZero(node.end_gather_tp)) {
|
|
|
+ this.searchResult.push(node);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', this.searchResult);
|
|
|
+ });
|
|
|
+ this.spread.getActiveSheet().bind(GC.Spread.Sheets.Events.CellDoubleClick, function (e, info) {
|
|
|
+ const sheet = info.sheet;
|
|
|
+ const data = sheet.zh_data;
|
|
|
+ if (!data) { return }
|
|
|
+
|
|
|
+ const curBills = data[info.row];
|
|
|
+ if (!curBills) { return }
|
|
|
+
|
|
|
+ SpreadJsObj.locateTreeNode(self.mainSpread.getActiveSheet(), curBills.ledger_id);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let searchLedger;
|
|
|
+ $.divResizer({
|
|
|
+ select: '#right-spr',
|
|
|
+ callback: function () {
|
|
|
slSpread.refresh();
|
|
|
spSpread.refresh();
|
|
|
- obj.removeClass('active');
|
|
|
- fujian.removeClass('active');
|
|
|
+ if (searchLedger) {
|
|
|
+ searchLedger.spread.refresh();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 展开收起附件
|
|
|
+ $('a', '.side-menu').bind('click', function () {
|
|
|
+ //const main = $('#main-view'), tool = $('#tools-view');
|
|
|
+ const tab = $(this), tabPanel = $(tab.attr('content'));
|
|
|
+ const showTools = function (show) {
|
|
|
+ const left = $('#main-view'), right = $('#tools-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 {
|
|
|
+ right.hide();
|
|
|
+ left.css('width', '100%');
|
|
|
+ }
|
|
|
+ };
|
|
|
+ if (!tab.hasClass('active')) {
|
|
|
+ $('a', '.side-menu').removeClass('active');
|
|
|
+ $('.tab-content .tab-pane').removeClass('active');
|
|
|
+ tab.addClass('active');
|
|
|
+ tabPanel.addClass('active');
|
|
|
+ showTools(tab.hasClass('active'));
|
|
|
+ if (tab.attr('content') === '#search' && !searchLedger) {
|
|
|
+ searchLedger = new SearchLedger($('#search'), slSpread);
|
|
|
+ searchLedger.spread.refresh();
|
|
|
+ }
|
|
|
} else {
|
|
|
- main.attr('class', 'c-body col-8');
|
|
|
- tool.show();
|
|
|
- slSpread.refresh();
|
|
|
- spSpread.refresh();
|
|
|
- obj.addClass('active');
|
|
|
- fujian.addClass('active');
|
|
|
+ tab.removeClass('active');
|
|
|
+ tabPanel.removeClass('active');
|
|
|
+ showTools(tab.hasClass('active'));
|
|
|
}
|
|
|
+ slSpread.refresh();
|
|
|
+ spSpread.refresh();
|
|
|
});
|
|
|
});
|