'use strict'; /** * 指标库-项目节参数 * * @author Mai * @date 2018/4/25 * @version */ $(document).ready(function() { const billsSpread = SpreadJsObj.createNewSpread($('#bills-spread')[0]); const billsSheet = billsSpread.getActiveSheet(); const billsTree = createNewPathTree({ id: 'n_id', pid: 'n_pid', order: 'n_order', level: 'n_level', full_path: 'n_full_path', is_leaf: 'n_is_leaf', rootId: -1, keys: ['id', 'lib_id', 'n_id'], preUrl: '/lib/detail', }); billsTree.loadDatas(bills); SpreadJsObj.initSheet(billsSheet, { cols: [ {title: '项目节编号', field: 'code', width: 120, cellType: 'tree', vAlign: 1, readOnly: true}, {title: '清单编号', field: 'b_code', width: 80, vAlign: 1, readOnly: true}, {title: '名称', field: 'name', width: 200, vAlign: 1, readOnly: true}, {title: '单位', field: 'units', width: 62, vAlign: 1, hAlign: 1, readOnly: true}, {title: '数量1', field: 'dgn_quantity1', width: 60, type: 'Number', vAlign: 1, readOnly: true}, {title: '数量2', field: 'dgn_quantity2', width: 60, type: 'Number', vAlign: 1, readOnly: true}, {title: '金额', field: 'total_price', width: 60, type: 'Number', vAlign: 1, readOnly: true}, ], treeCol: 0, emptyRows: 3, headRows: 2, headRowHeight: [28], defaultRowHeight: 30, }); SpreadJsObj.loadSheetData(billsSheet, 'tree', billsTree); billsSheet.selectionPolicy(0); billsSheet.selectionUnit(1); billsSheet.clearSelection(); billsSheet.setActiveCell(0); setquotaParamIndex(); const spreadNS = GC.Spread.Sheets; //项目节选中 billsSheet.bind(spreadNS.Events.SelectionChanged, function (e, info) { setquotaParamIndex(); }); function setquotaParamIndex() { const billsInfo = billsTree.nodes[billsSheet.getActiveRowIndex()]; $('#codeName').text(billsInfo.name); $('#indexList').html(''); $('#paramList').html(''); if(billsInfo.match_node !== null){ const postUrl = '/lib/getParamAndIndex'; const postInfo = { lib_id: billsInfo.lib_id, node_id: billsInfo.match_node, bills_id: billsInfo.id }; postData(postUrl, postInfo, function (result) { updateIndexHTML(result.indexList); updateParamHTML(result.paramList); }); } } function updateIndexHTML(indexlist) { let index_html = ''; const index_list = indexlist; for(let i in index_list) { index_html += '