Browse Source

1. 台账分解Bug
2. 台账分解modal独立

MaiXinRong 7 năm trước cách đây
mục cha
commit
c02c3d25db

+ 1 - 1
app/controller/ledger_controller.js

@@ -67,7 +67,7 @@ module.exports = app => {
                     ledger: JSON.stringify(ledgerData),
                     tenderList,
                 };
-                await this.layout('ledger/explode.ejs', renderData);
+                await this.layout('ledger/explode.ejs', renderData, 'ledger/explode_modal.ejs');
             }
         }
 

+ 1 - 0
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -169,6 +169,7 @@ const SpreadJsObj = {
     initSheet: function (sheet, setting) {
         sheet.zh_setting = setting;
         this.initSheetHeader(sheet);
+        sheet.setRowCount(sheet.zh_setting.emptyRows);
         sheet.extendCellType = {};
     },
     /**

+ 11 - 11
app/service/ledger.js

@@ -834,7 +834,7 @@ module.exports = app => {
             try {
                 const sData = await this.transaction.update(this.tableName, { id: selectData.id, order: selectData.order - 1 });
                 const pData = await this.transaction.update(this.tableName, { id: preData.id, order: preData.order + 1 });
-                this.transaction.commit();
+                await this.transaction.commit();
             } catch (err) {
                 await this.transaction.rollback();
                 throw err;
@@ -868,7 +868,7 @@ module.exports = app => {
             try {
                 const sData = await this.transaction.update(this.tableName, { id: selectData.id, order: selectData.order + 1 });
                 const pData = await this.transaction.update(this.tableName, { id: nextData.id, order: nextData.order - 1 });
-                this.transaction.commit();
+                await this.transaction.commit();
             } catch (err) {
                 await this.transaction.rollback();
                 throw err;
@@ -993,13 +993,13 @@ module.exports = app => {
             try {
                 // 选中节点--父节点 选中节点为firstChild时,修改is_leaf
                 if (selectData.order === 1) {
-                    this.transaction.update(this.tableName, {
+                    await this.transaction.update(this.tableName, {
                         id: parentData.id,
                         is_leaf: true,
                         total_price: 0
                     });
                 } else {
-                    this.transaction.update(this.tableName, {
+                    await this.transaction.update(this.tableName, {
                         id: parentData.id,
                         total_price: await this.addUpChildren(tenderId, selectData.ledger_pid, selectData.order, '<')
                     });
@@ -1063,7 +1063,7 @@ module.exports = app => {
                 literal: 'Replace',
             });
             const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'update');
-            const data = this.transaction.query(sql, sqlParam);
+            const data = await this.transaction.query(sql, sqlParam);
 
             return data;
         }
@@ -1118,9 +1118,9 @@ module.exports = app => {
                     }
                     await this.transaction.update(this.tableName, updateData2);
                 }
-                this.transaction.commit();
+                await this.transaction.commit();
             } catch (err) {
-                this.transaction.rollback();
+                await this.transaction.rollback();
                 throw err;
             }
 
@@ -1242,9 +1242,9 @@ module.exports = app => {
                     const updateData = this._filterUpdateInvalidField(updateNode.id, data);
                     await this.transaction.update(this.tableName, updateData);
                 }
-                this.transaction.commit();
+                await this.transaction.commit();
             } catch (err) {
-                this.transaction.rollback();
+                await this.transaction.rollback();
                 throw err;
             }
 
@@ -1459,9 +1459,9 @@ module.exports = app => {
                     await this.transaction.update(this.tableName, updateData);
                 }
                 await this._increCalcParent(tenderId, updateMap);
-                this.transaction.commit();
+                await this.transaction.commit();
             } catch (err) {
-                this.transaction.rollback();
+                await this.transaction.rollback();
                 throw err;
             }
 

+ 0 - 26
app/view/layout/modal.ejs

@@ -40,29 +40,3 @@
     </div>
 </div>
 
-<!--上传签约清单-->
-<div class="modal fade" id="upload-deal" data-backdrop="static" enctype="multipart/form-data">
-    <div class="modal-dialog" role="document">
-        <div class="modal-content">
-            <div class="modal-header">
-                <h5 class="modal-title">上传签约清单</h5>
-            </div>
-            <div class="modal-body">
-                <div class="form-group">
-                    <label for="exampleFormControlFile1">Excel模板</label>
-                    <div class="form-control"><a id="downloadDealTemplate" href="/deal/download/template.xls" class="btn btn-sm btn-link">下载</a></div>
-                </div>
-                <div class="form-group">
-                    <label for="exampleFormControlFile1">上传签约清单Excel文件</label>
-                    <div class="form-control"><input type="file" class="form-control-file" id="deal-bills-file"></div>
-                </div>
-            </div>
-            <div class="modal-footer">
-                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
-                <button type="button" class="btn btn-primary" id="upload-deal-bills">确认上传</button>
-            </div>
-        </div>
-    </div>
-</div>
-
-

+ 61 - 0
app/view/ledger/explode_modal.ejs

@@ -0,0 +1,61 @@
+<!--上传签约清单-->
+<div class="modal fade" id="upload-deal" data-backdrop="static" enctype="multipart/form-data">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">上传签约清单</h5>
+            </div>
+            <div class="modal-body">
+                <div class="form-group">
+                    <label for="exampleFormControlFile1">Excel模板</label>
+                    <div class="form-control"><a id="downloadDealTemplate" href="/deal/download/template.xls" class="btn btn-sm btn-link">下载</a></div>
+                </div>
+                <div class="form-group">
+                    <label for="exampleFormControlFile1">上传签约清单Excel文件</label>
+                    <div class="form-control"><input type="file" class="form-control-file" id="deal-bills-file"></div>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
+                <button type="button" class="btn btn-primary" id="upload-deal-bills">确认上传</button>
+            </div>
+        </div>
+    </div>
+</div>
+<!--批量添加子项弹窗-->
+<div class="modal fade" id="batch" data-backdrop="static">
+    <div class="modal-dialog modal-lg" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">批量插入子项</h5>
+            </div>
+            <div class="modal-body">
+                <div class="row">
+                    <div class="col-6">
+                        <h6 class="row"><span class="col">部位数量复合表</span>
+                            <div class="input-group input-group-sm col-5 align-self-end">
+                                <div class="input-group-prepend">
+                                    <span class="input-group-text" id="basic-addon1">起始编号</span>
+                                </div>
+                                <input type="num" class="form-control form-control-sm"  step="1" value="1">
+                            </div></h6>
+                        <div class="batch-l-t">
+                        </div>
+                        <h6>清单编号</h6>
+                        <div class="batch-l-b">
+                        </div>
+                    </div>
+                    <div class="col-6">
+                        <h6>签约清单</h6>
+                        <div id="batch-deal-spread" class="batch-r">
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                <button type="button" class="btn btn-primary" >确定</button>
+            </div>
+        </div>
+    </div>
+</div>

+ 26 - 0
test/app/service/deal_bills.test.js

@@ -0,0 +1,26 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Mai
+ * @date
+ * @version
+ */
+
+const { app, assert } = require('egg-mock/bootstrap');
+const excel = require('node-xlsx');
+
+describe('test/app/service/ledger.test.js', () => {
+    it('clear history test data', function* () {
+        const ctx = app.mockContext();
+        const file = app.baseDir  + '/test/app/test_file/deal-load-test.xls';
+        const sheets = excel.parse(fileName), testTenderId = 3;
+
+        const result = yield ctx.service.dealBills.importData(sheets[0], testTenderId);
+        assert(result.length === 1);
+        const bills = result[0];
+        assert(bills.code === '101-1');
+        assert(bills.tender_id === testTenderId);
+    });
+});

+ 13 - 5
test/app/service/ledger.test.js

@@ -7,6 +7,8 @@
  */
 'use strict';
 
+const excel = require('node-xlsx');
+
 /*const testNodeData = [
     { ledger_id: 1, ledger_pid: -1, order: 1, level: 1, full_path: '1', code: '1', is_leaf: false },
     { ledger_id: 2, ledger_pid: 1, order: 1, level: 2, full_path: '1.2', code: '1-1', is_leaf: false },
@@ -334,7 +336,6 @@ describe('test/app/service/ledger.test.js', () => {
         const ctx = app.mockContext();
         // 选中 1-1-2 升级
         const resultData = yield ctx.service.ledger.upLevelNode(testTenderId, 13);
-        console.log(resultData);
         assert(resultData);
         assert(resultData.update.length === 6);
 
@@ -376,7 +377,6 @@ describe('test/app/service/ledger.test.js', () => {
         const ctx = app.mockContext();
         // 选中1-3 降级
         const resultData = yield ctx.service.ledger.downLevelNode(testTenderId, 4);
-        console.log(resultData);
         // 1-3/1-3-1/1-4修改
         assert(resultData.update.length === 3);
 
@@ -900,7 +900,7 @@ describe('test/app/service/ledger.test.js', () => {
         const ctx = app.mockContext();
 
         // 从标准库添加1-4-2-1
-        const condition1 = { list_id: 1, code: '1-4-2-1'}
+        const condition1 = { list_id: 1, code: '1-4-2-1'};
         const libData1 = yield ctx.service.stdChapter.getDataByCondition(condition1);
         assert(libData1);
         const stdData1 = yield ctx.service.stdChapter.getDataByDataId(1, libData1.chapter_id);
@@ -912,7 +912,7 @@ describe('test/app/service/ledger.test.js', () => {
         assert(!result1.update || result1.update.length === 0);
         assert(!result1.expand || result1.expand.length === 0);
         // 从标准库添加1-4-2-1-2
-        const condition2 = { list_id: 1, code: '1-4-2-1-2'}
+        const condition2 = { list_id: 1, code: '1-4-2-1-2'};
         const libData2 = yield ctx.service.stdChapter.getDataByCondition(condition2);
         assert(libData2);
         const stdData2 = yield ctx.service.stdChapter.getDataByDataId(1, libData2.chapter_id);
@@ -926,7 +926,7 @@ describe('test/app/service/ledger.test.js', () => {
         assert(!result2.update[0].is_leaf);
         assert(result2.expand.length === 4);
         // 从标准库添加1-4-2-1-1
-        const condition3 = { list_id: 1, code: '1-4-2-1-1'}
+        const condition3 = { list_id: 1, code: '1-4-2-1-1'};
         const libData3 = yield ctx.service.stdChapter.getDataByCondition(condition3);
         assert(libData3);
         const stdData3 = yield ctx.service.stdChapter.getDataByDataId(1, libData3.chapter_id);
@@ -957,6 +957,14 @@ describe('test/app/service/ledger.test.js', () => {
         assert(result3 && result3.toFixed(8) == 60.00007146);
     });
 
+    // it('test ImportExcelData', function* () {
+    //     const ctx = app.mockContext();
+    //
+    //     const file = ctx.app.baseDir + '/test/app/test_file/ledger-upload-test.xls';
+    //     const sheets = excel.parse(file);
+    //     const result = yield ctx.service.
+    // });
+
     // 小数位数策略示例:
     /*  先加总再保留3位小数:
         1                                        35.585

test/app/test_file/deal-uploat-test.xls → test/app/test_file/deal-upload-test.xls