/** * 进度台账相关js * * @author Ellisran * @date 2020/11/6 * @version */ function getTenderId() { return window.location.pathname.split('/')[2]; } $(function () { autoFlashHeight(); // 初始化台账 const ledgerSpread = SpreadJsObj.createNewSpread($('#ledger-spread')[0]); const treeSetting = { id: 'ledger_id', pid: 'ledger_pid', order: 'order', level: 'level', rootId: -1, fullPath: 'full_path', calcFields: ['total_price'] //treeCacheKey: 'ledger_bills_fold' + '_' + getTenderId(), // markFoldKey: 'bills-fold', // markFoldSubKey: window.location.pathname.split('/')[2], }; treeSetting.calcFun = function (node) { node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2); }; const ledgerTree = createNewPathTree('base', treeSetting); const ledgerSpreadSetting = { cols: [ {title: '', colSpan: '1', rowSpan: '2', field: 'is_select', hAlign: 1, width: 40, formatter: '@', cellType: 'checkbox'}, {title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 185, formatter: '@', readOnly: true, cellType: 'tree'}, {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 205, formatter: '@', readOnly: true}, {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 100, formatter: '@', readOnly: true}, {title: '经济指标', colSpan: '1', rowSpan: '2', field: 'dgn_price', hAlign: 2, width: 100, type: 'Number', readOnly: true}, {title: '工程量', colSpan: '1', rowSpan: '2', field: 'dgn_qty1', hAlign: 2, width: 100, type: 'Number', readOnly: true}, {title: '金额', colSpan: '1', rowSpan: '2', field: 'total_price', hAlign: 2, width: 100, type: 'Number', readOnly: true}, ], emptyRows: 0, headRows: 1, headRowHeight: [25, 25], defaultRowHeight: 21, headerFont: '12px 微软雅黑', font: '12px 微软雅黑', readOnly: true, localCache: { key: 'ledger-bills', colWidth: true, } }; sjsSettingObj.setFxTreeStyle(ledgerSpreadSetting, sjsSettingObj.FxTreeStyle.jz); if (thousandth) sjsSettingObj.setTpThousandthFormat(ledgerSpreadSetting); SpreadJsObj.initSheet(ledgerSpread.getActiveSheet(), ledgerSpreadSetting); SpreadJsObj.selChangedRefreshBackColor(ledgerSpread.getActiveSheet()); postData(window.location.pathname + '/load', {}, function (data) { ledgerTree.loadDatas(data); treeCalc.calculateAll(ledgerTree); SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, ledgerTree); }, null, true); // // 显示层次 // (function (select, sheet) { // $(select).click(function () { // const tag = $(this).attr('tag'); // const tree = sheet.zh_tree; // if (!tree) return; // 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; // case "leafXmj": // tree.expandToLeafXmj(); // SpreadJsObj.refreshTreeRowVisible(sheet); // break; // } // }); // })('a[name=showLevel]', ledgerSpread.getActiveSheet()); });