Selaa lähdekoodia

设计量明细,相关问题

MaiXinRong 2 kuukautta sitten
vanhempi
commit
3225f0ce5e

+ 0 - 2
app/controller/ledger_controller.js

@@ -175,7 +175,6 @@ module.exports = app => {
 
 
                 await this.layout('ledger/explode.ejs', renderData, 'ledger/explode_modal.ejs');
                 await this.layout('ledger/explode.ejs', renderData, 'ledger/explode_modal.ejs');
             } catch (err) {
             } catch (err) {
-                console.log(err);
                 ctx.log(err);
                 ctx.log(err);
                 this.postError(err, '标段数据错误');
                 this.postError(err, '标段数据错误');
                 // await this.redirect('/dashboard');
                 // await this.redirect('/dashboard');
@@ -215,7 +214,6 @@ module.exports = app => {
          * @return {Promise<void>}
          * @return {Promise<void>}
          */
          */
         async _base(ctx, type, data) {
         async _base(ctx, type, data) {
-            console.log(1);
             if (isNaN(data.id) || data.id <= 0) throw '数据错误';
             if (isNaN(data.id) || data.id <= 0) throw '数据错误';
             if (type !== 'add') {
             if (type !== 'add') {
                 if (isNaN(data.count) || data.count <= 0) data.count = 1;
                 if (isNaN(data.count) || data.count <= 0) data.count = 1;

+ 3 - 1
app/public/js/ledger.js

@@ -992,7 +992,9 @@ $(document).ready(function() {
                 }
                 }
                 if (result.detail) {
                 if (result.detail) {
                     posCalcDetail.detail.updateDatas({ update: result.detail });
                     posCalcDetail.detail.updateDatas({ update: result.detail });
-                    posCalcDetail.reloadCurDetailData();
+                    posCalcDetail.loadCurDetailData();
+                } else if (updateData.postType === 'extra') {
+                    posCalcDetail.loadCurDetailData();
                 }
                 }
             }, function() {
             }, function() {
                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
                 SpreadJsObj.reLoadRowData(info.sheet, info.row);

+ 8 - 5
app/public/js/pos_calc_tmpl.js

@@ -305,13 +305,16 @@ $(document).ready(() => {
         const getCurTemplate = function() {
         const getCurTemplate = function() {
             return curTemplate;
             return curTemplate;
         };
         };
-        const getTemplateCaptionHtml = function(template) {
+        const getTemplateCaptionInnerHtml = function(template) {
             const usedHtml = template.used_count > 0 ? '<i class="ml-1 fa fa-lock text-danger"></i>' : '';
             const usedHtml = template.used_count > 0 ? '<i class="ml-1 fa fa-lock text-danger"></i>' : '';
-            return `<div class="d-flex justify-content-between align-items-center table-file" templateId="${template.id}"><div>${template.name}${usedHtml}</div>` +
+            return `<div>${template.name}${usedHtml}</div>` +
                 '    <div class="btn-group-table" style="display: none;">\n' +
                 '    <div class="btn-group-table" style="display: none;">\n' +
                 '    <a href="javascript: void(0);" class="mr-1" data-toggle="tooltip" data-placement="bottom" data-original-title="编辑" name="renameTemplate"><i class="fa fa-pencil fa-fw"></i></a>\n' +
                 '    <a href="javascript: void(0);" class="mr-1" data-toggle="tooltip" data-placement="bottom" data-original-title="编辑" name="renameTemplate"><i class="fa fa-pencil fa-fw"></i></a>\n' +
                 '    <a href="javascript: void(0);" class="mr-1" data-toggle="tooltip" data-placement="bottom" data-original-title="删除" name="delTemplate"><i class="fa fa-trash-o fa-fw text-danger"></i></a>\n' +
                 '    <a href="javascript: void(0);" class="mr-1" data-toggle="tooltip" data-placement="bottom" data-original-title="删除" name="delTemplate"><i class="fa fa-trash-o fa-fw text-danger"></i></a>\n' +
-                '</div></div>';
+                '</div>';
+        };
+        const getTemplateCaptionHtml = function(template) {
+            return `<div class="d-flex justify-content-between align-items-center table-file" templateId="${template.id}">` + getTemplateCaptionInnerHtml(template) + '</div>';
         };
         };
         const getTemplateHtml = function(template) {
         const getTemplateHtml = function(template) {
             const html = [];
             const html = [];
@@ -344,7 +347,7 @@ $(document).ready(() => {
             });
             });
         };
         };
         if (templates.length > 0) setCurTemplate(templates[0]);
         if (templates.length > 0) setCurTemplate(templates[0]);
-        return { setCurTemplate, getCurTemplate, addTemplate, delTemplate, renameTemplate, getTemplateCaptionHtml }
+        return { setCurTemplate, getCurTemplate, addTemplate, delTemplate, renameTemplate, getTemplateCaptionHtml, getTemplateCaptionInnerHtml }
     })(templateList);
     })(templateList);
 
 
     $('body').on('click', '.table-file', function(e) {
     $('body').on('click', '.table-file', function(e) {
@@ -388,7 +391,7 @@ $(document).ready(() => {
         const template = templateList.find(x => { return x.id === templateId; });
         const template = templateList.find(x => { return x.id === templateId; });
         if (!template) return;
         if (!template) return;
 
 
-        $(`.table-file[templateId=${templateId}]`).html(templateObj.getTemplateCaptionHtml(template));
+        $(`.table-file[templateId=${templateId}]`).html(templateObj.getTemplateCaptionInnerHtml(template));
     });
     });
     $('body').on('click', 'a[name=delTemplate]', function(e) {
     $('body').on('click', 'a[name=delTemplate]', function(e) {
         e.stopPropagation();
         e.stopPropagation();

+ 1 - 1
app/service/ledger.js

@@ -881,7 +881,7 @@ module.exports = app => {
                     await conn.insert(this.service.ledgerExtra.tableName, { id: data.id, tid, calc_template: data.calc_template });
                     await conn.insert(this.service.ledgerExtra.tableName, { id: data.id, tid, calc_template: data.calc_template });
                 }
                 }
                 // 重算所有数据
                 // 重算所有数据
-                await this.ctx.service.posCalcDetail.resetBillsCalcTemplate(conn, data.id, data.calc_template);
+                const calc = await this.ctx.service.posCalcDetail.resetBillsCalcTemplate(conn, data.id, data.calc_template);
                 await conn.commit();
                 await conn.commit();
             } catch (err) {
             } catch (err) {
                 await conn.rollback();
                 await conn.rollback();

+ 2 - 2
app/service/pos_calc_detail.js

@@ -51,7 +51,7 @@ module.exports = app => {
             }
             }
         }
         }
         _reCalcQty(data, template) {
         _reCalcQty(data, template) {
-            const result = { id: data.id, expr: template.calc_expr };
+            const result = { id: data.id, expr: template.calc_expr.qty || '' };
             for (const nf of numField) {
             for (const nf of numField) {
                 result[nf] = this.ctx.helper.round(data[nf] || 0, this.getDecimal(template.decimal, nf));
                 result[nf] = this.ctx.helper.round(data[nf] || 0, this.getDecimal(template.decimal, nf));
                 result.expr = result.expr.replace(new RegExp(nf, 'gm'), data[nf] || 0);
                 result.expr = result.expr.replace(new RegExp(nf, 'gm'), data[nf] || 0);
@@ -290,7 +290,7 @@ module.exports = app => {
                     detailUpdateDatas.push(ud);
                     detailUpdateDatas.push(ud);
                     pQty = this.ctx.helper.add(ud.qty, pQty);
                     pQty = this.ctx.helper.add(ud.qty, pQty);
                 }
                 }
-                const up = { id: p.id, sgfh_qty: this.ctx.helper.round(pQty, precision.value) };
+                const up = { id: p.id, sgfh_qty: this.ctx.helper.round(pQty, precision.value), sgfh_expr: '' };
                 up.quantity = this.ctx.helper.sum([up.sgfh_qty, p.sjcl_qty, p.qtcl_qty]);
                 up.quantity = this.ctx.helper.sum([up.sgfh_qty, p.sjcl_qty, p.qtcl_qty]);
                 posUpdateData.push(up);
                 posUpdateData.push(up);
                 bQty = this.ctx.helper.add(bQty, up.sgfh_qty);
                 bQty = this.ctx.helper.add(bQty, up.sgfh_qty);