Bläddra i källkod

feat: 后台定额库编辑器,安装增加费大窗口,右上窗口“分册章节”新增右键“删除章节”

vian 2 år sedan
förälder
incheckning
8a7d2bf238

+ 1 - 1
modules/ration_repository/controllers/installation_controller.js

@@ -19,7 +19,7 @@ class InstallationController extends BaseController {
 
   updateSection(req, res) {
     let data = JSON.parse(req.body.data);
-    installationDao.updateSection(data.updateData, function (err, data) {
+    installationDao.updateSection(data.updateData, data.libID, function (err, data) {
       callback(req, res, err, "", data);
     });
   }

+ 6 - 1
modules/ration_repository/models/installation.js

@@ -56,8 +56,9 @@ class InstallationDao{
         }
     }*/
 
-    async updateSection(updateData, callback){
+    async updateSection(updateData, libID, callback){
         try{
+            const delIDs = [];
             for(let data of updateData){
                 if(data.updateType === 'new'){
                     await installSectionModel.create(data.updateData);
@@ -66,9 +67,13 @@ class InstallationDao{
                     await installSectionModel.update({ID: data.updateData.ID}, data.updateData);
                 }
                 else {
+                    delIDs.push(data.updateData.ID);
                     await installSectionModel.remove({ID: data.updateData.ID});
                 }
             }
+            if (delIDs.length) {
+                await rationItemModel.updateMany({rationRepId: libID}, {$pull: { rationInstList: { sectionId: { $in: delIDs } } }});
+            }
             callback(0, null);
         }
         catch(err){

+ 18 - 5
web/maintain/ration_repository/js/installation.js

@@ -69,19 +69,19 @@ $(document).ready(function () {
       for (let i = 0, len = sels.length; i < len; i++) {
         let sel = sels[i];
         //delete
-        if (sel.colCount === me.setting.header.length) {
+        // if (sel.colCount === me.setting.header.length) {
           for (let j = 0, jLen = sel.rowCount; j < jLen; j++) {
             let row = sel.row + j;
             let section = me.cache[row];
             //有数据,删除数据
             if (me.isDef(section)) {
-              sePostData.push({ updateType: me.updateType.update, updateData: { ID: section.ID, deleted: true } });
+              sePostData.push({ updateType: me.updateType.del, updateData: { ID: section.ID, deleted: true } });
               fiPostData.push({ updateType: me.updateType.update, updateData: { ID: fi.currentFeeItem.ID, $pull: { section: { ID: section.ID } } } });
             }
           }
           //front delete
           me.cache.splice(sel.row, sel.rowCount);
-        }
+        // }
       }
       //update currentSection
       me.currentSection = fi.getCurrentData(me.sheet, me.cache);
@@ -394,7 +394,7 @@ let sectionObj = {
   sheet: null,
   cache: [],
   currentSection: null,
-  updateType: { update: "update", new: "new" },
+  updateType: { update: "update", new: "new", del: 'delete' },
   deleteType: "section",
   setting: {
     header: [
@@ -496,6 +496,19 @@ let sectionObj = {
                   $("#sectionTreeModal").modal("show");
                 },
               },
+              del: {
+                name: "删除章节",
+                disabled: function () {
+                  const inValidCell = !commonUtil.isDef(target.row) || !commonUtil.isDef(target.col);
+                  const inValidData = target.row >= me.cache.length;
+                  return locked || inValidCell || inValidData;
+                },
+                icon: "fa-times",
+                callback: function (key, opt) {
+                  curDeleteType = me.deleteType;
+                  $("#delAlert").modal("show");
+                },
+              },
             },
           };
         } else {
@@ -647,7 +660,7 @@ let sectionObj = {
     me.workBook.commandManager().setShortcutKey("sectionDel", GC.Spread.Commands.Key.del, false, false, false, false);
   },
   updateSection: function (updateData, callback) {
-    CommonAjax.post("/rationRepository/api/updateSection", { updateData: updateData }, function (rstData) {
+    CommonAjax.post("/rationRepository/api/updateSection", { updateData: updateData, libID: feeItemObj.rationRepId }, function (rstData) {
       if (callback) {
         callback();
       }