MaiXinRong 1 year ago
parent
commit
7807e284f8
1 changed files with 37 additions and 0 deletions
  1. 37 0
      app/public/js/revise_price.js

+ 37 - 0
app/public/js/revise_price.js

@@ -267,6 +267,25 @@ $(document).ready(() => {
                 setPriceHint(revisePrice.data.length > 0);
             });
         },
+        addRevisePrices(datas) {
+            const add = [];
+            for (const data of datas) {
+                const op = revisePrice.data.find(x => {
+                    return x.b_code === data.b_code && x.name === x.name && x.unit === x.unit && checkZero(ZhCalc.sub(x.org_price, data.unit_price)) && (!x.rela_lid || !x.rela_cid);
+                });
+                if (op) {
+                    toastr.warning('已存在该单价调整');
+                    SpreadJsObj.locateData(priceSheet, op);
+                    return;
+                }
+                add.push({ b_code: data.b_code, name: data.name, unit: data.unit, unit_price: data.unit_price });
+            }
+            postData(window.location.pathname + '/update', { add }, result => {
+                revisePrice.loadUpdateData(result);
+                SpreadJsObj.reLoadSheetData(priceSheet);
+                setPriceHint(revisePrice.data.length > 0);
+            });
+        },
         /**
          * 删除按钮响应事件
          * @param sheet
@@ -587,6 +606,24 @@ $(document).ready(() => {
                     const gcl = SpreadJsObj.getSelectObject(info.sheet);
                     priceOprObj.addRevisePrice(gcl);
                 });
+
+                $.contextMenu({
+                    selector: setting.selector,
+                    build: function ($trigger, e) {
+                        const target = SpreadJsObj.safeRightClickSelection($trigger, e, priceSpread);
+                        return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
+                    },
+                    items: {
+                        del: {
+                            name: '添加',
+                            icon: 'fa-remove',
+                            callback: function (key, opt) {
+                                const datas = [];
+                                priceOprObj.addRevisePrices(datas);
+                            },
+                        },
+                    },
+                });
             }
             const self = this;
             this.spread.bind(spreadNS.Events.SelectionChanged, function (e, info) {