瀏覽代碼

只针对项目节清单设置全部计价和不计价

ellisran 7 月之前
父節點
當前提交
34a23076bf
共有 1 個文件被更改,包括 51 次插入4 次删除
  1. 51 4
      app/public/js/change_information.js

+ 51 - 4
app/public/js/change_information.js

@@ -2399,6 +2399,37 @@ $(document).ready(() => {
             }
             return;
         };
+        xmjSpreadObj.setAllValuation = function (is_valuation) {
+            const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
+            if (!select) {
+                toastr.error('未选中清单');
+                return;
+            }
+            if (!select.children || select.children.length === 0) {
+                toastr.warning('暂无清单无法设置清单计价');
+                return;
+            }
+            const needChangeList = _.filter(select.children, { is_valuation: is_valuation ? 0 : 1 });
+            if (needChangeList.length === 0) {
+                toastr.warning('全部已设置清单'+ (is_valuation ? '' : '不') +'计价');
+                return;
+            }
+            const realNeedChangeList = [];
+            for (const nc of needChangeList) {
+                if (_.findIndex(changeUsedData, { cbid: nc.id }) === -1) {
+                    realNeedChangeList.push(nc.id);
+                }
+            }
+            if (realNeedChangeList.length === 0) {
+                toastr.warning('全部已设置清单'+ (is_valuation ? '' : '不') +'计价');
+                return;
+            }
+            postData(window.location.pathname + '/save', { type:'set_all_valuation', ids: realNeedChangeList, is_valuation }, function (result) {
+                changeList = result;
+                const [newChangeList, updateOrderList] = changeSpreadObj.makeNewChangeList();
+                changeSpreadObj.reloadSheet(newChangeList);
+            });
+        };
 
         // 表达式判断
         $('#xmj-camount-expr').change(function () {
@@ -2735,18 +2766,34 @@ $(document).ready(() => {
                 },
                 sprEdit: '----',
                 'allNotValuation': {
-                    name: '设置全部清单不计价',
+                    name: '设置全部不计价',
                     icon: 'fa-magic',
                     callback: function (key, opt) {
-                        changeSpreadObj.setAllValuation(0);
+                        xmjSpreadObj.setAllValuation(0);
                     },
+                    disabled: function (key, opt) {
+                        const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
+                        if (select.children && select.children.length > 0) {
+                            return false;
+                        } else {
+                            return true;
+                        }
+                    }
                 },
                 'allValuation': {
-                    name: '设置全部清单计价',
+                    name: '设置全部计价',
                     icon: 'fa-magic',
                     callback: function (key, opt) {
-                        changeSpreadObj.setAllValuation(1);
+                        xmjSpreadObj.setAllValuation(1);
                     },
+                    disabled: function (key, opt) {
+                        const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
+                        if (select.children && select.children.length > 0) {
+                            return false;
+                        } else {
+                            return true;
+                        }
+                    }
                 },
             }
         });