123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- function getGxbyText(data) {
- const def = thirdParty.gxby.find(function (x) {
- return x.value === data.gxby_status;
- });
- return def ? def.name : '';
- }
- function getDaglText(data) {
- const def = thirdParty.dagl.find(function (x) {
- return x.value === data.dagl_status;
- });
- return def ? def.name : '';
- }
- const ckBillsSpread = window.location.pathname + '-billsSelect';
- $(document).ready(() => {
- autoFlashHeight();
- let searchLedger;
- const settleTreeSetting = {
- id: 'tree_id',
- pid: 'tree_pid',
- order: 'tree_order',
- level: 'tree_level',
- fullPath: 'tree_full_path',
- isLeaf: 'tree_is_leaf',
- rootId: -1,
- keys: ['id', 'tid', 'tree_id'],
- stageId: 'id',
- autoExpand: 3,
- markExpandKey: 'settle-select-expand',
- markExpandSubKey: window.location.pathname.split('/')[2],
- calcFields: ['total_price', 'cur_contract_tp', 'cur_qc_tp', 'cur_gather_tp', 'cur_correct_tp'],
- calcFun: function(node) {
- if (!node.children || node.children.length === 0) {
- node.cur_gather_qty = ZhCalc.add(node.cur_contract_qty, node.cur_qc_qty);
- if (node.cur_contract_qty) {
- node.cur_correct_tp = ZhCalc.add(node.cur_qc_tp, ZhCalc.mul(node.cur_contract_qty, node.unit_price, tenderInfo.decimal.tp));
- } else {
- node.cur_correct_tp = node.cur_gather_tp;
- }
- }
- node.cur_gather_tp = ZhCalc.add(node.cur_contract_tp, node.cur_qc_tp);
- node.cur_gather_percent = ZhCalc.mul(ZhCalc.div(node.cur_gather_tp, node.cur_final_tp), 100, 2);
- node.cur_correct_percent = ZhCalc.mul(ZhCalc.div(node.cur_correct_tp, node.cur_final_tp), 100, 2);
- }
- };
- const settleTree = createNewPathTree('stage', settleTreeSetting);
- const settlePosSetting = {
- id: 'id', ledgerId: 'lid',
- calcFun: function(pos) {
- pos.cur_gather_qty = ZhCalc.add(pos.cur_contract_qty, pos.cur_qc_qty);
- pos.sum = ZhCalc.add(pos.end_qc_qty, pos.quantity);
- pos.cur_gather_percent = ZhCalc.mul(ZhCalc.div(pos.cur_gather_qty, pos.sum), 100, 2);
- }
- };
- const settlePos = new StagePosData(settlePosSetting);
- const slSpread = SpreadJsObj.createNewSpread($('#settle-bills')[0]);
- const slSheet = slSpread.getActiveSheet();
- slSheet.frozenColumnCount(billsSpreadSetting.cols.findIndex(x => { return x.field === 'total_price'; }) + 1);
- slSheet.options.frozenlineColor = '#93b5e4';
- const ratioCol = billsSpreadSetting.cols.find(x => {return x.field === 'cur_final_1_percent' || x.field === 'cur_correct_1_percent'});
- if (ratioCol) ratioCol.field = tenderInfo.display.stage.correct ? 'cur_correct_1_percent' : 'cur_final_1_percent';
- billsSpreadSetting.getColor = function (sheet, data, row, col, defaultColor) {
- if (!data) return defaultColor;
- if (data.children && data.children.length > 0) return defaultColor;
- if (col.field === 'gxby') {
- const def = thirdParty.gxby.find(function (x) {
- return x.value === data.gxby_status;
- });
- if (def && def.color) return def.color;
- } else if (col.field === 'dagl') {
- const def = thirdParty.dagl.find(function (x) {
- return x.value === data.dagl_status;
- });
- if (def && def.color) return def.color;
- }
- };
- sjsSettingObj.setFxTreeStyle(billsSpreadSetting, sjsSettingObj.FxTreeStyle.jz);
- sjsSettingObj.set3FCols(billsSpreadSetting.cols, [
- {field: 'gxby', getValue: getGxbyText, url_field: 'gxby_url'},
- {field: 'dagl', getValue: getDaglText, url_field: 'dagl_url'},
- ]);
- SpreadJsObj.initSheet(slSheet, billsSpreadSetting);
- const spSpread = SpreadJsObj.createNewSpread($('#settle-pos')[0]);
- const spSheet = spSpread.getActiveSheet();
- spSheet.frozenColumnCount(posSpreadSetting.cols.findIndex(x => { return x.field === 'total_price'; }) + 1);
- spSheet.options.frozenlineColor = '#93b5e4';
- posSpreadSetting.getColor = function (sheet, data, row, col, defaultColor) {
- if (!data) return defaultColor;
- if (col.field === 'gxby') {
- const def = thirdParty.gxby.find(function (x) {
- return x.value === data.gxby_status;
- });
- if (def && def.color) return def.color;
- } else if (col.field === 'dagl') {
- const def = thirdParty.dagl.find(function (x) {
- return x.value === data.dagl_status;
- });
- if (def && def.color) return def.color;
- }
- };
- sjsSettingObj.set3FCols(posSpreadSetting.cols, [
- {field: 'gxby', getValue: getGxbyText, url_field: 'gxby_url'},
- {field: 'dagl', getValue: getDaglText, url_field: 'dagl_url'},
- ]);
- SpreadJsObj.initSheet(spSheet, posSpreadSetting);
- const settleBillsObj = {
- loadRelaData: function() {
- SpreadJsObj.saveTopAndSelect(slSheet, ckBillsSpread);
- SpreadJsObj.resetTopAndSelect(spSheet);
- settlePosObj.loadCurPosData();
- },
- selectionChanged: function(e, info) {
- if (!info.oldSelections || !info.oldSelections[0] || info.newSelections[0].row !== info.oldSelections[0].row) {
- settleBillsObj.loadRelaData();
- }
- },
- topRowChanged(e, info) {
- SpreadJsObj.saveTopAndSelect(info.sheet, ckBillsSpread);
- },
- };
- slSpread.bind(spreadNS.Events.SelectionChanged, settleBillsObj.selectionChanged);
- slSpread.bind(spreadNS.Events.TopRowChanged, settleBillsObj.topRowChanged);
- const settlePosObj = {
- loadCurPosData: function() {
- const billsNode = SpreadJsObj.getSelectObject(slSheet);
- if (billsNode) {
- spSheet.zh_setting.readOnly = readOnly;
- const posRange = settlePos.getLedgerPos(billsNode.lid) || [];
- SpreadJsObj.loadSheetData(spSheet, SpreadJsObj.DataType.Data, posRange, readOnly);
- } else {
- spSheet.zh_setting.readOnly = true;
- SpreadJsObj.loadSheetData(spSheet, SpreadJsObj.DataType.Data, [], true);
- }
- }
- };
- postData('load', {filter: 'settleBills;settlePos;tag'}, function(result) {
- settleTree.loadDatas(result.settleBills);
- treeCalc.calculateAll(settleTree);
- settlePos.loadDatas(result.settlePos);
- settlePos.calculateAll();
- SpreadJsObj.loadSheetData(slSheet, SpreadJsObj.DataType.Tree, settleTree);
- SpreadJsObj.loadTopAndSelect(slSpread.getActiveSheet(), ckBillsSpread);
- settlePosObj.loadCurPosData();
- });
- // 展开收起工具栏
- $('a', '.right-nav').bind('click', function () {
- const tab = $(this), tabPanel = $(tab.attr('content'));
- if (!tab.hasClass('active')) {
- $('a', '.side-menu').removeClass('active');
- $('.tab-content .tab-select-show').removeClass('active');
- tab.addClass('active');
- tabPanel.addClass('active');
- showSideTools(tab.hasClass('active'));
- if (tab.attr('content') === '#search' && !searchLedger) {
- searchLedger = $.billsSearch({
- selector: '#search',
- searchSpread: slSpread,
- searchOver: true,
- searchEmpty: true,
- 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},
- {title: '数量', field: 'quantity', hAlign: 2, width: 50},
- ],
- emptyRows: 0,
- headRows: 1,
- headRowHeight: [32],
- headColWidth: [30],
- defaultRowHeight: 21,
- headerFont: '12px 微软雅黑',
- font: '12px 微软雅黑',
- selectedBackColor: '#fffacd',
- readOnly: true,
- },
- afterLocated: function () {
- settlePosObj.loadCurPosData();
- },
- });
- searchLedger.spread.refresh();
- }
- } else {
- tab.removeClass('active');
- tabPanel.removeClass('active');
- showSideTools(tab.hasClass('active'));
- }
- slSpread.refresh();
- spSpread.refresh();
- });
- $.subMenu({
- menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
- toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
- key: 'menu.1.0.0',
- miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
- callback: function (info) {
- if (info.mini) {
- $('.panel-title').addClass('fluid');
- $('#sub-menu').removeClass('panel-sidebar');
- } else {
- $('.panel-title').removeClass('fluid');
- $('#sub-menu').addClass('panel-sidebar');
- }
- autoFlashHeight();
- }
- });
- });
|