Browse Source

概算控制相关

MaiXinRong 3 years ago
parent
commit
5adcc36526
4 changed files with 12 additions and 10 deletions
  1. 2 1
      app/public/js/budget_detail.js
  2. 2 2
      app/service/budget.js
  3. 4 3
      app/service/pos.js
  4. 4 4
      app/view/budget/detail.ejs

+ 2 - 1
app/public/js/budget_detail.js

@@ -604,7 +604,7 @@ $(document).ready(() => {
             readOnly: true,
         },
         cellDoubleClick: !readOnly ? stdLibCellDoubleClick : null,
-        page: 'ledger',
+        page: 'budget',
     };
     const stdGclSetting = {
         selector: '#std-gcl',
@@ -635,6 +635,7 @@ $(document).ready(() => {
             readOnly: true,
         },
         cellDoubleClick: !readOnly ? stdLibCellDoubleClick : null,
+        page: 'budget',
     };
     // 展开收起标准清单
     $('a', 'ul.right-nav').bind('click', function (e) {

+ 2 - 2
app/service/budget.js

@@ -96,8 +96,8 @@ module.exports = app => {
 
                 // 获取合同支付模板 并添加到标段
                 await this.ctx.service.budgetGu.initByTemplate(conn, operate.insertId, budgetStd.gu_template_id);
-                await this.ctx.service.budgetGai.initByTemplate(conn, operate.insertId, budgetStd.gu_template_id);
-                await this.ctx.service.budgetYu.initByTemplate(conn, operate.insertId, budgetStd.gu_template_id);
+                await this.ctx.service.budgetGai.initByTemplate(conn, operate.insertId, budgetStd.gai_template_id);
+                await this.ctx.service.budgetYu.initByTemplate(conn, operate.insertId, budgetStd.yu_template_id);
                 await conn.commit();
                 return await this.getDataById(operate.insertId);
             } catch (error) {

+ 4 - 3
app/service/pos.js

@@ -184,6 +184,7 @@ module.exports = app => {
             if (data.sgfh_qty !== undefined || data.sjcl_qty !== undefined || data.qtcl_qty !== undefined) {
                 const op = await this.getDataById(data.id);
                 const bills = await this.ctx.service.ledger.getDataById(op.lid);
+                if (!bills) throw '数据错误';
                 const billsPos = await this.getAllDataByCondition({where: {tid: tid, lid: op.lid} });
 
                 const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, bills.unit);
@@ -309,11 +310,11 @@ module.exports = app => {
         }
 
         async _deletePosData(tid, data) {
-            if (!data || data.length === 0) {
-                throw '提交数据错误';
-            }
+            if (!data || data.length === 0) throw '提交数据错误';
 
             const pos = await this.getPosData({tid: tid, id: data});
+            if (!pos || pos.length === 0) throw '删除的计量单元不存在';
+
             const bills = await this.ctx.service.ledger.getDataById(pos[0].lid);
             const billsPos = await this.getAllDataByCondition({ where: {tid: tid, lid: bills.id} });
             const updateBills = {id: bills.id, sgfh_qty: null, sjcl_qty: null, qtcl_qty: null, quantity: null};

+ 4 - 4
app/view/budget/detail.ejs

@@ -70,8 +70,8 @@
                         <div class="sjs-bar-2">
                             <div class="pb-1">
                                 <select class="form-control form-control-sm">
-                                    <% for (const c of stdChapters) { %>
-                                    <option value="<%- c.id %>" <% if (stdChapters.indexOf(c) === 0) { %>selected<% } %>><%- c.name %></option>
+                                    <% for (const [i, c] of stdChapters.entries()) { %>
+                                    <option value="<%- c.id %>" <%- (i===0 ? ' selected' : '') %>><%- c.name %></option>
                                     <% } %>
                                 </select>
                             </div>
@@ -84,8 +84,8 @@
                         <div class="sjs-bar-3">
                             <div class="pb-1">
                                 <select class="form-control form-control-sm">
-                                    <% for (const b of stdBills) { %>
-                                    <option value="<%- b.id %>" <% if (stdBills.indexOf(b) === 0) { %>selected<% } %>><%- b.name %></option>
+                                    <% for (const [i, b] of stdBills.entries()) { %>
+                                    <option value="<%- b.id %>" <%- (i===0 ? ' selected' : '') %>><%- b.name %></option>
                                     <% } %>
                                 </select>
                             </div>