123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388 |
- 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, settleAtt;
- 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.pre_gather_qty = ZhCalc.add(node.pre_contract_qty, node.pre_qc_qty);
- node.end_gather_qty = ZhCalc.add(node.end_contract_qty, node.end_qc_qty);
- if (node.end_contract_qty) {
- node.end_correct_tp = ZhCalc.add(node.end_qc_tp, ZhCalc.mul(node.end_contract_qty, node.unit_price, tenderInfo.decimal.tp));
- } else {
- node.end_correct_tp = node.end_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);
- node.pre_gather_tp = ZhCalc.add(node.pre_contract_tp, node.pre_qc_tp);
- node.pre_gather_percent = ZhCalc.mul(ZhCalc.div(node.pre_gather_tp, node.pre_final_tp), 100, 2);
- node.pre_correct_percent = ZhCalc.mul(ZhCalc.div(node.pre_correct_tp, node.pre_final_tp), 100, 2);
- node.end_gather_tp = ZhCalc.add(node.end_contract_tp, node.end_qc_tp);
- node.end_gather_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.end_final_tp), 100, 2);
- node.end_correct_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.end_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.pre_gather_qty = ZhCalc.add(pos.pre_contract_qty, pos.pre_qc_qty);
- pos.end_gather_qty = ZhCalc.add(pos.end_contract_qty, pos.end_qc_qty);
- }
- };
- 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'},
- ]);
- billsSpreadSetting.headColWidth = [50];
- billsSpreadSetting.rowHeader = [
- {
- rowHeaderType: 'tag',
- setting: {
- indent: 16,
- tagSize: 0.8,
- tagFont: '8px 微软雅黑',
- getColor: function (index, data) {
- if (!data) return;
- return billsTag.getBillsTagsColor(data.lid);
- },
- getTagHtml: function (index, data) {
- if (!data) return;
- const getHtml = function (list) {
- if (!list || list.length === 0) return '';
- const html = [];
- for (const l of list) {
- html.push('<div class="row mr-1">');
- html.push(`<div class="col-auto pr-1 ${l.tagClass}">`, '<i class="fa fa-tag"></i>', '</div>');
- html.push('<div class="col p-0">', '<p>', l.comment, '</p>', '</div>');
- html.push('</div>');
- }
- return html.join('');
- };
- return getHtml(billsTag.getBillsTagsInfo(data.lid));
- }
- },
- },
- ];
- billsSpreadSetting.afterLocate = function (node) {
- settleAtt.getCurAttHtml(node);
- };
- 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);
- settleBillsObj.loadRelaAtt();
- 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);
- },
- loadRelaAtt() {
- const node = SpreadJsObj.getSelectObject(slSheet);
- settleAtt.getCurAttHtml(node);
- }
- };
- 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);
- }
- }
- };
- const billsTag = $.billsTag({
- relaTree: settleTree,
- selector: '#bills-tag',
- relaSpread: slSpread,
- updateUrl: window.location.pathname + '/tag',
- key: 'lid',
- treeId: 'tree_id',
- afterModify: function (nodes) {
- SpreadJsObj.repaintNodesRowHeader(slSheet, nodes);
- },
- afterLocated: function () {
- settlePosObj.loadCurPosData();
- },
- afterShow: function () {
- slSpread.refresh();
- if (spSpread) spSpread.refresh();
- },
- });
- const addTag = newTag({ledgerSheet: slSheet, billsTag, key: 'lid'});
- $.contextMenu({
- selector: '#settle-bills',
- build: function ($trigger, e) {
- const target = SpreadJsObj.safeRightClickSelection($trigger, e, slSpread);
- settleBillsObj.loadRelaData();
- return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
- },
- items: {
- tag: {
- name: '书签',
- callback: function (key, opt, menu, e) {
- const node = SpreadJsObj.getSelectObject(slSheet);
- addTag.do(node);
- },
- disabled: function (key, opt) {
- const node = SpreadJsObj.getSelectObject(slSheet);
- return !node;
- }
- }
- }
- });
- postData('load', {filter: 'settleBills;settlePos;tag;att'}, function(result) {
- settleTree.loadDatas(result.settleBills);
- treeCalc.calculateAll(settleTree);
- settlePos.loadDatas(result.settlePos);
- settlePos.calculateAll();
- for (const t of result.tag) {
- t.node = settleTree.nodes.find(x => {return x.lid === t.lid});
- }
- billsTag.loadDatas(result.tag);
- SpreadJsObj.loadSheetData(slSheet, SpreadJsObj.DataType.Tree, settleTree);
- SpreadJsObj.loadTopAndSelect(slSpread.getActiveSheet(), ckBillsSpread);
- settlePosObj.loadCurPosData();
- for (const r of result.att) {
- r.node = settleTree.datas.find(x => {return x.lid === r.lid});
- }
- settleAtt = $.ledger_att({
- selector: '#fujian',
- key: 'lid',
- uploadUrl: 'file/upload',
- deleteUrl: 'file/delete',
- checked: settleComplete,
- zipName: `${tenderName}-计量台账-第${settleOrder}期-附件.zip`,
- readOnly: false, // todo fileUploadPermission,
- locate: function (att) {
- if (!att) return;
- SpreadJsObj.locateTreeNode(slSheet, att.node.tree_id, true);
- settleBillsObj.loadRelaAtt();
- settlePosObj.loadCurPosData();
- }
- });
- settleAtt.loadDatas(result.att);
- settleAtt.getCurAttHtml(SpreadJsObj.getSelectObject(slSheet));
- });
- // 展开收起工具栏
- $('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,
- keyId: 'tree_id',
- 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();
- }
- });
- // 加载上下窗口resizer
- $.divResizer({
- select: '#main-resize',
- callback: function () {
- slSpread.refresh();
- let bcontent = $(".bcontent-wrap") ? $(".bcontent-wrap").height() : 0;
- $(".sp-wrap").height(bcontent-30);
- spSpread.refresh();
- window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
- }
- });
- // 工具栏resizer
- $.divResizer({
- select: '#right-spr',
- callback: function () {
- slSpread.refresh();
- spSpread.refresh();
- window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
- if (searchLedger) searchLedger.spread.refresh();
- }
- });
- // 显示层次
- (function (select, sheet) {
- $(select).click(function () {
- const tag = $(this).attr('tag');
- const tree = sheet.zh_tree;
- if (!tree) return;
- setTimeout(() => {
- showWaitingView();
- 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;
- }
- closeWaitingView();
- }, 100);
- });
- })('a[name=showLevel]', slSheet);
- });
|