Browse Source

1. 中间计量,审批人修改数据后,刷新界面,数据丢失
2. 变更概况,不应显示未审批完成、作废的变更令
3. 变更概况,先调用,再取消调用变更令。变更概况,本期使用无法过滤该变更令,变更清单本期使用不应勾选
4. 其他

MaiXinRong 5 years ago
parent
commit
a526f13a3c

+ 1 - 1
app/public/js/stage.js

@@ -1381,7 +1381,7 @@ $(document).ready(() => {
                         }
                         if (checkEmpty) {
                             if (sd.quantity) {
-                                if (!sd.end_gather_qty || checkZero(sd.end_gather_qty)) match = true;
+                                if (!sd.end_gather_qty || ZhCalc.sub(sd.quantity, sd.end_gather_qty) > 0) match = true;
                             }
                         }
                         if (keyword && keyword !== '' && sd.name && sd.name.indexOf(keyword) === -1) match = false;

+ 2 - 2
app/public/js/stage_change.js

@@ -87,7 +87,7 @@ $(document).ready(() => {
     const billsSpreadSetting = {
         cols: [
             {title: '本期使用', colSpan: '1', rowSpan: '1', field: '', hAlign: 1, width: 40, formatter: '@', readOnly: true, cellType: 'image', img: function (data) {
-                if (!checkZero(data.cur_qty)) {
+                if (data.cur_qty && !checkZero(data.cur_qty)) {
                     return $('#icon-ok')[0];
                 } else {
                     return null;
@@ -194,7 +194,7 @@ $(document).ready(() => {
         filterUsedBills: function (isFilter) {
             const bills = SpreadJsObj.getSortData(billsSpread.getActiveSheet());
             for (const b of bills) {
-                b.visible = !isFilter || !checkZero(b.cur_qty);
+                b.visible = !isFilter ||(b.cur_qty && !checkZero(b.cur_qty));
             }
             SpreadJsObj.refreshTreeRowVisible(billsSpread.getActiveSheet());
         }

+ 3 - 0
app/public/js/stage_compare.js

@@ -113,6 +113,9 @@ $(document).ready(function () {
     const scPos = new MasterPosData(scPosSetting);
 
     postData(window.location.pathname + '/load', {main: true, roles: scRoles}, function (result) {
+        for (const r of scRoles) {
+            if (r != 0) $('input[audit-order=' + r + ']')[0].checked = true;
+        }
         scTree.loadDatas(result.main.ledger);
         scPos.loadDatas(result.main.pos);
         for (const aData of result.roles) {

+ 9 - 8
app/service/stage_change.js

@@ -10,6 +10,7 @@
 
 const defaultPid = -1; // 非pid
 const audit = require('../const/audit');
+const timesLen = 100;
 
 module.exports = app => {
 
@@ -258,13 +259,13 @@ module.exports = app => {
                         '  FROM ' + this.ctx.service.changeAuditList.tableName + ' As cb' +
                         '  LEFT JOIN ' + this.tableName + ' As c ON cb.id = c.cbid ' +
                         '  INNER JOIN (' +
-                        '    SELECT MAX(`stimes`) As `stimes`, MAX(`sorder`) As `sorder`, `lid`, `pid`, `cbid`, sChange.`sid`, `cid` ' +
+                        '    SELECT  MAX(`stimes` * ' + timesLen + ' + `sorder`) As `flow`, `lid`, `pid`, `cbid`, sChange.`sid`, `cid` ' +
                         '      FROM ' + this.tableName + ' As sChange' +
                         '      LEFT JOIN ' + this.ctx.service.stage.tableName + ' As s ON sChange.sid = s.id' +
                         '      WHERE sChange.tid = ? AND cid = ?' + filter +
                         '      GROUP By `lid`, `pid`, `cbid`, sChange.`sid`' +
                         '  ) As m' +
-                        '  ON c.stimes = m.stimes And c.sorder = m.sorder And c.`cbid` = m.`cbid` AND c.`sid` = m.`sid` And c.`cid` = m.`cid`' +
+                        '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.flow And c.`cbid` = m.`cbid` AND c.`sid` = m.`sid` And c.`cid` = m.`cid`' +
                         '  WHERE cb.cid = ?' +
                         '  GROUP By c.`cbid`';
             const sqlParam = [tid, cid, cid];
@@ -286,11 +287,11 @@ module.exports = app => {
                         '    p.name As `p_name`, p.drawing_code As `p_drawing_code`, p.`quantity` As `p_qty`' +
                         '  FROM ' + this.tableName + ' As c ' +
                         '  INNER JOIN ( ' +
-                        '    SELECT MAX(`stimes`) As `stimes`, MAX(`sorder`) As `sorder`, `lid`, `pid`, `cbid` From ' + this.tableName +
+                        '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `flow`, `lid`, `pid`, `cbid` From ' + this.tableName +
                         '      WHERE sid = ? And cid = ?' +
                         '      GROUP By `lid`, `pid`, `cbid`' +
                         '  ) As m ' +
-                        '  ON c.stimes = m.stimes And c.sorder = m.sorder And c.lid = m.lid And c.pid = m.pid And c.cbid = m.cbid' +
+                        '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.flow And c.lid = m.lid And c.pid = m.pid And c.cbid = m.cbid' +
                         '  LEFT JOIN ' + this.ctx.service.ledger.tableName + ' As l ON c.lid = l.id' +
                         '  LEFT JOIN ' + this.ctx.service.pos.tableName + ' As p ON c.pid = p.id';
             const sqlParam = [sid, cid];
@@ -305,15 +306,15 @@ module.exports = app => {
         async getStageUsedChangeId(sid) {
             const sql = 'SELECT c.`cid` FROM ' + this.tableName + ' As c' +
                         '  INNER JOIN (' +
-                        '    SELECT MAX(`stimes`) As `stimes`, MAX(`sorder`) As `sorder`, `lid`, `pid`, `cbid` From ' + this.tableName +
-                        '      WHERE sid = ? And not ISNULL(qty)' +
+                        '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `flow`, `lid`, `pid`, `cbid` From ' + this.tableName +
+                        '      WHERE sid = ?' +
                         '      GROUP By `lid`, `pid`, `cbid`' +
                         '  ) As m' +
-                        '  ON c.stimes = m.stimes And c.sorder = m.sorder And c.lid = m.lid And c.pid = m.pid And c.cbid = m.cbid' +
+                        '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.flow And c.lid = m.lid And c.pid = m.pid And c.cbid = m.cbid' +
                         '  GROUP BY c.`cid`';
             const sqlParam = [sid];
             const result = await this.db.query(sql, sqlParam);
-            return this._.map(result, 'cid');
+            return this._.map(this._.filter(result, 'qty'), 'cid');
         }
     }
 

+ 5 - 1
app/service/stage_detail.js

@@ -135,6 +135,10 @@ module.exports = app => {
                     await this.db.update(this.tableName, newData);
                     return newData;
                 } else {
+                    data.code = org.code;
+                    data.name = org.name;
+                    data.unit = org.unit;
+                    data.unit_price = org.unit_price;
                     data.uuid = org.uuid;
                     data.tid = this.ctx.tender.id;
                     data.sid = this.ctx.stage.id;
@@ -170,7 +174,7 @@ module.exports = app => {
                             await transaction.update(this.tableName, d);
                             result.push(d);
                         } else {
-                            const nd = this._.assign(od, data);
+                            const nd = this._.assign(od, d);
                             nd.times = this.ctx.stage.curTimes;
                             nd.order = this.ctx.stage.curOrder;
                             await transaction.insert(this.tableName, nd);

+ 1 - 0
app/service/stage_pos.js

@@ -353,6 +353,7 @@ module.exports = app => {
                     said: this.ctx.session.sessionUser.accountId,
                     times: this.ctx.stage.curTimes,
                     order: this.ctx.stage.curOrder,
+                    contract_qty: orgPos.contract_qty,
                     qc_qty: qty,
                 });
             }

+ 2 - 2
app/view/stage/compare_modal.ejs

@@ -9,9 +9,9 @@
             <div class="modal-body">
                 <table class="table table-sm">
                     <tr><th>审批人</th><th width="90">选择</th></tr>
-                    <% for (const a of ctx.stage.auditors) { %>
+                    <% for (const [i, a] of ctx.stage.auditors.entries()) { %>
                     <% if (a.status === auditConst.status.checked || a.aid === ctx.session.sessionUser.accountId) { %>
-                    <tr auditorId="<%- a.aid %>"><td><%- a.name %></td><td><input type="checkbox"></td></tr>
+                    <tr auditorId="<%- a.aid %>"><td><%- a.name %></td><td><input type="checkbox" audit-order="<%- i + 1 %>"></td></tr>
                     <% } %>
                     <% } %>
                 </table>

+ 10 - 10
app/view/stage/detail.ejs

@@ -12,16 +12,16 @@
             </div>
             <div class="ml-auto">
                 <!--完成中间计量-->
-                <% if (!ctx.stage.readOnly && ctx.stage.check_detail) { %>
-                <% 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 { %>
-                <% if (ctx.stage.user_id = ctx.session.sessionUser.accountId) {%>
-                <span class="text-success" id="locked-hint">请继续完成上报审批。如需修改计量,点击 <a href="/tender/<%- ctx.tender.id %>/measure/stage/<%- ctx.stage.order %>/detail/unlock">编辑</a></span>
-                <% } else { %>
-                <span class="text-success" id="locked-hint">已完成,请继续完成「上报审批」 <a href="/tender/<%- ctx.tender.id %>/measure/stage/<%- ctx.stage.order %>/detail/unlock">解锁编辑</a></span>
-                <% } %>
-                <% } %>
+                <% 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 { %>
+                        <% if (ctx.stage.user_id = ctx.session.sessionUser.accountId) {%>
+                        <span class="text-success" id="locked-hint">请继续完成上报审批。如需修改计量,点击 <a href="/tender/<%- ctx.tender.id %>/measure/stage/<%- ctx.stage.order %>/detail/unlock">编辑</a></span>
+                        <% } 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>