Browse Source

计量台账,部位明细,新增期

MaiXinRong 6 years ago
parent
commit
4ab917e480
6 changed files with 40 additions and 10 deletions
  1. 2 2
      app/const/spread.js
  2. 23 1
      app/extend/helper.js
  3. 11 5
      app/service/pos.js
  4. 2 0
      app/view/stage/detail.ejs
  5. 1 1
      app/view/stage/index.ejs
  6. 1 1
      app/view/stage/pay.ejs

+ 2 - 2
app/const/spread.js

@@ -201,7 +201,7 @@ const stageCl = {
             {title: '|完成', colSpan: '|1', rowSpan: '|1', field: 'end_gather_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '本期批注', colSpan: '1', rowSpan: '2', field: 'postil', hAlign: 0, width: 80, formatter: '@', cellType: 'autoTip'},
             {title: '图册号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
-            {title: '添加期数', colSpan: '1', rowSpan: '2', field: 'add_stage', hAlign:1, width: 80, readOnly: true},
+            {title: '添加期数', colSpan: '1', rowSpan: '2', field: 'add_stage_order', hAlign:1, width: 80, readOnly: true},
         ],
         emptyRows: 3,
         headRows: 2,
@@ -259,7 +259,7 @@ const stageNoCl = {
             {title: '|完成', colSpan: '|1', rowSpan: '|1', field: 'end_gather_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '本期批注', colSpan: '1', rowSpan: '2', field: 'postil', hAlign: 0, width: 80, formatter: '@', cellType: 'autoTip'},
             {title: '图册号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
-            {title: '添加期数', colSpan: '1', rowSpan: '2', field: 'add_stage', hAlign:1, width: 80, readOnly: true},
+            {title: '添加期数', colSpan: '1', rowSpan: '2', field: 'add_stage_order', hAlign:1, width: 80, readOnly: true},
         ],
         emptyRows: 3,
         headRows: 2,

+ 23 - 1
app/extend/helper.js

@@ -730,5 +730,27 @@ module.exports = {
         for (const r of rela) {
             loadFields(r.data, r.fields, r.prefix, r.relaId);
         }
-    }
+    },
+    whereSql (where, as) {
+        if (!where) {
+            return '';
+        }
+
+        const wheres = [];
+        const values = [];
+        for (const key in where) {
+            const value = where[key];
+            if (Array.isArray(value)) {
+                wheres.push('?? IN (?)');
+            } else {
+                wheres.push('?? = ?');
+            }
+            values.push((as && as !== '') ? as + '.' + key : key);
+            values.push(value);
+        }
+        if (wheres.length > 0) {
+            return this.ctx.app.mysql.format(' WHERE ' + wheres.join(' AND '), values);
+        }
+        return '';
+    },
 };

+ 11 - 5
app/service/pos.js

@@ -23,11 +23,17 @@ module.exports = app => {
         }
 
         async getPosData(condition) {
-            return await this.db.select(this.tableName, {
-                where: condition,
-                columns: ['id', 'tid', 'lid', 'name', 'quantity', 'drawing_code', 'sgfh_qty', 'sjcl_qty', 'qtcl_qty', 'in_time', 'porder'],
-                order: [['porder', 'ASC']],
-            });
+            const sql = 'SELECT p.id, p.tid, p.lid, p.name, p.quantity, p.drawing_code, p.sgfh_qty, p.sjcl_qty, p.qtcl_qty, p.porder, s.order As add_stage_order ' +
+                '  FROM ' + this.tableName + ' p ' +
+                '  LEFT JOIN ' + this.ctx.service.stage.tableName + ' s' +
+                '  ON add_stage = s.id'
+                + this.ctx.helper.whereSql(condition, 'p');
+            return await this.db.query(sql);
+            // return await this.db.select(this.tableName, {
+            //     where: condition,
+            //     columns: ['id', 'tid', 'lid', 'name', 'quantity', 'drawing_code', 'sgfh_qty', 'sjcl_qty', 'qtcl_qty', 'in_time', 'porder', 'add_stage'],
+            //     order: [['porder', 'ASC']],
+            // });
         }
 
         async getPosDataByIds(ids) {

+ 2 - 0
app/view/stage/detail.ejs

@@ -11,11 +11,13 @@
             </div>
             <div class="ml-auto">
                 <!--完成中间计量-->
+                <% if (!ctx.stage.readOnly) { %>
                 <% if (ctx.stage.check_detail) { %>
                 <a href="javascirpt: void(0);" data-toggle="modal" data-target="#done" class="btn btn-success btn-sm pull-right">完成本期中间计量</a>
                 <% } else { %>
                 <span class="text-success" id="locked-hint">已完成,请继续完成「上报审批」 <a href="/tender/<%- ctx.tender.id %>/measure/stage/<%- ctx.stage.order %>/detail/unlock">解锁编辑</a></span>
                 <% } %>
+                <% } %>
             </div>
         </div>
     </div>

+ 1 - 1
app/view/stage/index.ejs

@@ -34,7 +34,7 @@
             </div>
             <div class="ml-auto">
                 <!--完成中间计量-->
-                <% if (!ctx.stage.check_detail) { %>
+                <% if (!ctx.stage.check_detail && !ctx.stage.readOnly) { %>
                 <span class="text-success" id="locked-hint">已完成,请继续完成「上报审批」 <a href="/tender/<%- ctx.tender.id %>/measure/stage/<%- ctx.stage.order %>/detail/unlock">解锁编辑</a></span>
                 <% } %>
             </div>

+ 1 - 1
app/view/stage/pay.ejs

@@ -20,7 +20,7 @@
             </div>
             <div class="ml-auto">
                 <!--完成中间计量-->
-                <% if (!ctx.stage.check_detail) { %>
+                <% if (!ctx.stage.check_detail && !ctx.stage.readOnly) { %>
                 <span class="text-success" id="locked-hint">已完成,请继续完成「上报审批」 <a href="/tender/<%- ctx.tender.id %>/measure/stage/<%- ctx.stage.order %>/detail/unlock">解锁编辑</a></span>
                 <% } %>
             </div>