Browse Source

自定义标段分类,分类下无值时,新增值bug

MaiXinRong 6 years ago
parent
commit
d04b855d41

+ 1 - 1
app/controller/setting_controller.js

@@ -204,7 +204,7 @@ module.exports = app => {
                 ctx.body = responseData;
             } catch (err) {
                 this.log(err);
-                ctx.body = {err: 1, msg: err instanceof string ? err : '提交数据失败', data: null};
+                ctx.body = {err: 1, msg: err instanceof String ? err : '提交数据失败', data: null};
             }
         }
 

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

@@ -161,13 +161,13 @@ function bindCategoryControl() {
             const list = $('#value-list');
             list.html(getValueHtml(editCate.value) + '<tr id="add-value-row"><td colspan="3"><a href="javascript: void(0);">添加新值</a></td></tr>');
             $('#add-value-row').click(function () {
-                const newID = _.maxBy(editCate.value, function (v) { return v.id; }).id + 1;
+                const newID = editCate.value.length > 0 ? _.maxBy(editCate.value, function (v) { return v.id; }).id + 1 : 1;
                 const newValue = {
                     isNew: true,
                     id: newID,
                     value: '',
                     relaTenders: [],
-                    newTenders: [],
+                    newTenders: editCate.value.length > 0 ? [] : tenders.concat([]),
                 };
                 editCate.value.push(newValue);
                 $(this).before(getValueHtml([newValue]));

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

@@ -686,6 +686,7 @@ $(document).ready(function() {
             tabPanel.hide();
         }
         ledgerSpread.refresh();
+        posSpread.refresh();
     });
 
     class stdLib {

+ 5 - 1
app/service/category_value.js

@@ -85,7 +85,11 @@ module.exports = app => {
                     if (!v.newTenders) { continue }
                     for (const nt of v.newTenders) {
                         const tender = this._.find(tenders, function (t) { return t.id === nt; });
-                        const cate = this._.find(tender.category, function (c) { return c.cid === cid; });
+                        let cate = this._.find(tender.category, function (c) { return c.cid === cid; });
+                        if (!cate) {
+                            cate = {cid: cid};
+                            tender.category.push(cate);
+                        }
                         cate.value = v.id;
                         await this.transaction.update(this.service.tender.tableName, {
                             id: tender.id,