|
@@ -1135,7 +1135,49 @@ $(document).ready(function() {
|
|
|
return readOnly;
|
|
|
},
|
|
|
callback: function (key, opt) {
|
|
|
- $('#upload-ledger').modal('show');
|
|
|
+ importExcel.doImport({
|
|
|
+ template: {
|
|
|
+ hint: '0号台账',
|
|
|
+ url: '/template/导入分项清单EXCEL格式.xls',
|
|
|
+ },
|
|
|
+ callback: function (sheet) {
|
|
|
+ postDataCompress(window.location.pathname + '/upload-excel', sheet, function (result) {
|
|
|
+ ledgerTree.loadDatas(result.bills);
|
|
|
+ treeCalc.calculateAll(ledgerTree);
|
|
|
+ SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), 'tree', ledgerTree);
|
|
|
+ pos.loadDatas(result.pos);
|
|
|
+ posOperationObj.loadCurPosData();
|
|
|
+ }, null);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //$('#upload-ledger').modal('show');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 'importGclBills2Xmj': {
|
|
|
+ name: '导入工程量清单至项目节',
|
|
|
+ icon: 'fa-file-excel-o',
|
|
|
+ disabled: function (key, opt) {
|
|
|
+ const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
|
|
|
+ return readOnly
|
|
|
+ || (node.children && node.children.length > 0)
|
|
|
+ || (!_.isNil(node.b_code) && node.b_code !== '');
|
|
|
+ },
|
|
|
+ callback: function (key, opt) {
|
|
|
+ importExcel.doImport({
|
|
|
+ template: {
|
|
|
+ hint: '工程量清单',
|
|
|
+ url: '/template/导入工程量清单EXCEL格式.xls',
|
|
|
+ },
|
|
|
+ callback: function (sheet) {
|
|
|
+ postDataCompress(window.location.pathname + '/upload-excel', sheet, function (result) {
|
|
|
+ ledgerTree.loadDatas(result.bills);
|
|
|
+ treeCalc.calculateAll(ledgerTree);
|
|
|
+ SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), 'tree', ledgerTree);
|
|
|
+ pos.loadDatas(result.pos);
|
|
|
+ posOperationObj.loadCurPosData();
|
|
|
+ }, null);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
'exportExcel': {
|
|
@@ -2206,69 +2248,6 @@ $(document).ready(function() {
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
- // 选择excel文件后,加载全部sheet
|
|
|
- $('#upload-ledger-file').change(function () {
|
|
|
- if (this.files.length === 0) {
|
|
|
- $('#upload-ledger-sheets').html('').hide();
|
|
|
- return;
|
|
|
- }$('#upload-ledger-sheets').hide();
|
|
|
- try {
|
|
|
- $('#select-excel-loading').show();
|
|
|
- xlsxUtils.import(this.files[0], (excelData) => {
|
|
|
- if (excelData.SheetNames.length > 0) {
|
|
|
- const html = [];
|
|
|
- html.push('<hr></hr>');
|
|
|
- html.push('<h6>选择导入的工作表</h6>');
|
|
|
- for (const iName in excelData.SheetNames) {
|
|
|
- const name = excelData.SheetNames[iName];
|
|
|
- html.push('<div class="card p-2 mb-2">');
|
|
|
- html.push('<div class="form-check">');
|
|
|
- html.push('<input class="form-check-input" type="radio" name="sheetName" id="excel-sheet' + iName + '"', (iName == 0 ? ' checked=""' : ''), ' value="' + name + '"', '>');
|
|
|
- html.push('<label class="form-check-label" for="excel-sheet' + iName + '">', name, '</label>');
|
|
|
- html.push('</div>');
|
|
|
- html.push('</div>');
|
|
|
- }
|
|
|
- $('#upload-ledger-sheets').html(html.join('')).show();
|
|
|
- $('.mb-2.p-2').mouseenter(function () {
|
|
|
- $(this).addClass('border-primary');
|
|
|
- });
|
|
|
- $('.mb-2.p-2').mouseleave(function () {
|
|
|
- $(this).removeClass('border-primary');
|
|
|
- })
|
|
|
- } else {
|
|
|
- toastr.info('选择的Excel无有效数据,请重新选择');
|
|
|
- $('#upload-ledger-sheets').hide();
|
|
|
- }
|
|
|
- $('#select-excel-loading').hide();
|
|
|
- });
|
|
|
- } catch(err) {
|
|
|
- $('#select-excel-loading').hide();
|
|
|
- toastr.error('加载excel异常,请刷新当前页面');
|
|
|
- $('#upload-ledger-sheets').hide();
|
|
|
- }
|
|
|
- });
|
|
|
- // 上传excel内容,并导入
|
|
|
- $('#upload-ledger-ok').click(function () {
|
|
|
- const sheetName = $('input[name=sheetName]:checked').val();
|
|
|
- if (sheetName) {
|
|
|
- const sheet = {
|
|
|
- rows: xlsxUtils.getSheetByName(sheetName, {header: 1}),
|
|
|
- merge: xlsxUtils._wb.Sheets[sheetName]["!merges"]
|
|
|
- };
|
|
|
- postDataCompress(window.location.pathname + '/upload-excel', sheet, function (result) {
|
|
|
- ledgerTree.loadDatas(result.bills);
|
|
|
- treeCalc.calculateAll(ledgerTree);
|
|
|
- SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), 'tree', ledgerTree);
|
|
|
- pos.loadDatas(result.pos);
|
|
|
- posOperationObj.loadCurPosData();
|
|
|
- $('#upload-ledger').modal('hide');
|
|
|
- }, null);
|
|
|
- }
|
|
|
- });
|
|
|
- $('#upload-ledger').bind('hidden.bs.modal', function () {
|
|
|
- $('#upload-ledger-file').val('');
|
|
|
- $('#upload-ledger-sheets').html('');
|
|
|
- });
|
|
|
|
|
|
$('#hideSp').click(function () {
|
|
|
$('#sp-list2').modal('hide');
|