123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- $(document).ready(() => {
- autoFlashHeight();
- const xmjSpread = SpreadJsObj.createNewSpread($('#xmj-spread')[0]);
- const xmjSheet = xmjSpread.getActiveSheet();
- const limitItems = limits.map(l => {
- return { value: l.limit_id, text: l.name };
- });
- limitItems.unshift({ value: '', text: '' });
- const setting = {
- cols: [
- { title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 180, formatter: '@', cellType: 'tree', readOnly: true, },
- { title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 360, formatter: '@', readOnly: true, },
- { title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', cellType: 'unit', readOnly: true, },
- { title: '联动计量配置', colSpan: '1', rowSpan: '2', field: 'multi_limit', hAlign: 0, width: 150, cellType: 'customizeCombo', comboItems: limitItems },
- ],
- emptyRows: 0,
- headRows: 2,
- headRowHeight: [25, 25],
- defaultRowHeight: 21,
- headerFont: '12px 微软雅黑',
- font: '12px 微软雅黑',
- };
- sjsSettingObj.setFxTreeStyle(setting, sjsSettingObj.FxTreeStyle.jz);
- SpreadJsObj.initSheet(xmjSheet, setting);
- const xmjTree = createNewPathTree('ledger', {
- id: 'ledger_id',
- pid: 'ledger_pid',
- order: 'order',
- level: 'level',
- rootId: -1,
- keys: ['id', 'tender_id', 'ledger_id'],
- autoExpand: 3,
- });
- const xmjTreeObj = {
- /**
- * 编辑单元格响应事件
- * @param {Object} e
- * @param {Object} info
- */
- editEnded: function (e, info) {
- if (!info.sheet.zh_setting) return;
- const col = info.sheet.zh_setting.cols[info.col];
- if (col.field !== 'multi_limit') return;
- const node = SpreadJsObj.getSelectObject(info.sheet);
- const updateData = { id: node.id, multi_limit: info.editingText || '' };
- if (updateData.multi_limit === node.multi_limit || (!updateData.multi_limit && !node.multi_limit)) return;
- // 更新至服务器
- postData(window.location.pathname + '/update', updateData, function (result) {
- const xmj = xmjTree.nodes.find(x => { return x.id === result.id });
- if (xmj) xmj.multi_limit = result.multi_limit;
- SpreadJsObj.reLoadRowData(info.sheet, info.row, 1);
- }, function() {
- SpreadJsObj.reLoadRowData(info.sheet, info.row, 1);
- });
- },
- };
- xmjSpread.bind(spreadNS.Events.EditEnded, xmjTreeObj.editEnded);
- postData(window.location.pathname + '/load', {filter: 'xmj;limit'}, function(result) {
- result.limit.forEach(l => {
- const rx = result.xmj.find(x => { return x.id === l.id; });
- if (rx) rx.multi_limit = l.multi_limit;
- });
- xmjTree.loadDatas(result.xmj);
- SpreadJsObj.loadSheetData(xmjSheet, SpreadJsObj.DataType.Tree, xmjTree);
- });
- });
|