123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- $(document).ready(function() {
- autoFlashHeight();
- class BillsObj {
- constructor() {
- this.spread = SpreadJsObj.createNewSpread($('#bills-spread')[0]);
- this.sheet = this.spread.getActiveSheet();
- this.treeSetting = {
- id: 'tree_id',
- pid: 'tree_pid',
- order: 'tree_order',
- level: 'tree_level',
- rootId: -1,
- autoExpand: 3,
- markExpandKey: 'bills-expand',
- markExpandSubKey: window.location.pathname.split('/')[2],
- calcFields: ['cur_tp', 'pre_tp', 'end_tp'],
- };
- this.spreadSetting = {
- baseCols: [
- {title: '编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 70, formatter: '@'},
- {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 185, formatter: '@'},
- {title: '规格', colSpan: '1', rowSpan: '2', field: 'spec', hAlign: 0, width: 150, formatter: '@'},
- {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 50, formatter: '@', cellType: 'unit'},
- {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number'},
- ],
- extraCols: [
- {title: '%s|数量', colSpan: '2|1', rowSpan: '1|1', field: '{%s}_qty{%d}', hAlign: 2, width: 60, type: 'Number', },
- {title: '|金额', colSpan: '|1', rowSpan: '|1', field: '{%s}_tp{%d}', hAlign: 2, width: 60, type: 'Number', },
- ],
- emptyRows: 3,
- headRows: 2,
- headRowHeight: [25, 25],
- defaultRowHeight: 21,
- headerFont: '12px 微软雅黑',
- font: '12px 微软雅黑',
- };
- this.tree = createNewPathTree('ledger', this.treeSetting);
- this.ckBillsSpread = window.location.pathname + '-billsSelect';
- this.initSpread();
- }
- refreshSpreadSetting(roles) {
- this.spreadSetting.cols = [];
- for (const col of this.spreadSetting.baseCols) {
- this.spreadSetting.cols.push(col);
- }
- // todo 根据参与审批的人加载数据
- }
- initSpread(roles = []) {
- this.refreshSpreadSetting(roles);
- SpreadJsObj.initSheet(this.sheet, this.spreadSetting);
- }
- loadData(datas, roles, history) {
- // todo 整理数据
- this.initSpread(roles);
- this.tree.loadDatas(datas);
- treeCalc.calculateAll(this.tree);
- SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Tree, this.tree);
- SpreadJsObj.loadTopAndSelect(this.sheet, this.ckBillsSpread);
- }
- }
- const billsObj = new BillsObj();
- // 加载安全生产费数据
- postData('load', { filter: 'bills;audit;history' }, function(result) {
- billsObj.loadData(result.bills);
- });
- // 导航Menu
- $.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();
- billsObj.spread.refresh();
- }
- });
- // 显示层次
- (function (select, sheet) {
- $(select).click(function () {
- if (!sheet.zh_tree) return;
- const tag = $(this).attr('tag');
- const tree = sheet.zh_tree;
- setTimeout(() => {
- showWaitingView();
- switch (tag) {
- case "1":
- case "2":
- case "3":
- case "4":
- tree.expandByLevel(parseInt(tag));
- SpreadJsObj.refreshTreeRowVisible(sheet);
- break;
- case "last":
- tree.expandByCustom(() => { return true; });
- SpreadJsObj.refreshTreeRowVisible(sheet);
- break;
- }
- closeWaitingView();
- }, 100);
- });
- })('a[name=showLevel]', billsObj.sheet);
- });
|