Browse Source

接口设置调整

MaiXinRong 3 years ago
parent
commit
fa55696a8d
3 changed files with 21 additions and 8 deletions
  1. 1 1
      app/controller/setting_controller.js
  2. 3 2
      app/service/s2b_proj.js
  3. 17 5
      app/view/setting/s2b.ejs

+ 1 - 1
app/controller/setting_controller.js

@@ -821,7 +821,7 @@ module.exports = app => {
                 const responseData = { err: 0, msg: '', data: null };
                 switch (data.type) {
                     case 'gxby':
-                        responseData.data = await this.ctx.service.s2bProj.updateGxbyStatus(projectId, data.status, data.limit);
+                        responseData.data = await this.ctx.service.s2bProj.updateGxbyStatus(projectId, data.status, data.limit, data.ratio);
                         break;
                     case 'dagl':
                         responseData.data = await this.ctx.service.s2bProj.updateDaglStatus(projectId, data.status, data.limit, data.ratio);

+ 3 - 2
app/service/s2b_proj.js

@@ -43,11 +43,12 @@ module.exports = app => {
             this.ctx.session.sessionProject.dagl_status = s2bProj ? s2bProj.dagl_status : thirdPartyConst.dagl;
         }
 
-        async updateGxbyStatus(pid, status, limit) {
+        async updateGxbyStatus(pid, status, limit, ratio) {
             const sp = await this.getDataByPid(pid);
             const gs = sp.gxby_status.find(x => { return x.value === status; });
             if (!gs) throw '提交数据错误';
-            gs.limit = limit;
+            if (limit !== undefined && limit !== null) gs.limit = limit;
+            if (ratio !== undefined && ratio !== null) gs.ratio = this.ctx.helper.round(ratio, 2);
             await this.db.update(this.tableName, { gxby_status: JSON.stringify(sp.gxby_status) }, { where: { pid } });
             return gs;
         }

+ 17 - 5
app/view/setting/s2b.ejs

@@ -18,7 +18,7 @@
                             <div class="col-4">
                                 <legend>工序报验</legend>
                                 <table class="table table-hover table-bordered">
-                                    <thead><tr><th>值</th><th>名称</th><th>允许计量</th></tr></thead>
+                                    <thead><tr><th>值</th><th>名称</th><th>允许计量</th><th>计量比例</th></tr></thead>
                                     <tbody id="gxby_list">
                                     <% for (const s of ctx.session.sessionProject.gxby_status) { %>
                                     <tr>
@@ -30,6 +30,18 @@
                                                 <label class="form-check-label" for="inlineCheckbox-g<%- s.value %>"></label>
                                             </div>
                                         </td>
+                                        <% if (s.ratio === undefined) { %>
+                                        <td>-</td>
+                                        <% } else { %>
+                                        <td>
+                                            <div class="input-group input-group-sm" style="width:90px">
+                                                <input type="number" class="form-control" max="100" min="0" step="2" value="<%- s.ratio || 0 %>" status="<%- s.value %>" onchange="updateStatusRatio(this, 'gxby');">
+                                                <div class="input-group-append">
+                                                    <span class="input-group-text">%</span>
+                                                </div>
+                                            </div>
+                                        </td>
+                                        <% } %>
                                     </tr>
                                     <% } %>
                                     </tbody>
@@ -49,12 +61,12 @@
                                                 <label class="form-check-label" for="inlineCheckbox-d<%- s.value %>"></label>
                                             </div>
                                         </td>
-                                        <% if (s.value === 0) { %>
+                                        <% if (s.ratio === undefined) { %>
                                         <td>-</td>
                                         <% } else { %>
                                         <td>
                                             <div class="input-group input-group-sm" style="width:90px">
-                                                <input type="number" class="form-control" max="100" min="0" step="2" value="<%- s.ratio || 0 %>" status="<%- s.value %>" onchange="updateStatusRatio(this);">
+                                                <input type="number" class="form-control" max="100" min="0" step="2" value="<%- s.ratio || 0 %>" status="<%- s.value %>" onchange="updateStatusRatio(this, 'dagl');">
                                                 <div class="input-group-append">
                                                     <span class="input-group-text">%</span>
                                                 </div>
@@ -138,8 +150,8 @@
             obj.checked = !obj.checked;
         });
     }
-    const updateStatusRatio = function (obj) {
-        const data = { type: 'dagl' };
+    const updateStatusRatio = function (obj, type) {
+        const data = { type };
         data.status = parseInt(obj.getAttribute('status'));
         try {
             data.ratio = parseFloat(obj.value);