소스 검색

feat: 清单库增加右键功能“计算规则转移补注”

vian 1 개월 전
부모
커밋
3bcdf07cc6

+ 9 - 0
modules/bills_lib/controllers/bills_lib_controllers.js

@@ -168,6 +168,15 @@ module.exports = {
             callback(req, res, err, message, datas);
         });
     },
+    transferRecharge: async function (req, res) {
+        try {
+            let data = JSON.parse(req.body.data);
+            await billsLibDao.transferRecharge(data.billsLibId);
+            callback(req, res, 0, 'success', null);
+        } catch (error) {
+            callback(req, res, 1, error.message, null);
+        }
+    },
     getJobContent: function (req, res) {
         let data = JSON.parse(req.body.data);
         billsLibDao.getJobContent(data, function (err, message, jobs) {

+ 3 - 0
modules/bills_lib/controllers/bills_permissionController.js

@@ -69,6 +69,9 @@ class billsPermContr extends baseController {
     isUsed(req, res) {
         billsController.isUsed(req, res);
     }
+    transferRecharge(req, res) {
+        billsController.transferRecharge(req, res);
+    }
     /*
      * 导入标准清单(确定节点结构:深度数组)
      * */

+ 18 - 0
modules/bills_lib/models/bills_lib_interfaces.js

@@ -13,6 +13,7 @@ let moment = require("moment");
 let billsGuidanceLib = mongoose.model("std_billsGuidance_lib");
 const engLibModel = mongoose.model("engineering_lib");
 let uuid = require("uuid");
+let _ = require("lodash");
 let billsLibDao = function () { };
 
 billsLibDao.prototype.copyLib = async function (userName, libName, fromLibId) {
@@ -2570,6 +2571,23 @@ billsLibDao.prototype.isUsed = function (data, callback) {
   }
 };
 
+// 计算规则转移补注
+billsLibDao.prototype.transferRecharge = async function (billsLibId) {
+  const bills = await Bills.find({ billsLibId }).lean('-_id ID recharge ruleText');
+  const bulks = [];
+  bills.forEach(bill => {
+    if (bill.ruleText) {
+      bulks.push({ updateOne: { filter: { ID: bill.ID }, update: { $set: { recharge: `<p>${bill.ruleText}</p>`, ruleText: '' } } } });
+    }
+  });
+  const chunks = _.chunk(bulks, 1000);
+  for (const chunk of chunks) {
+    if (chunk.length) {
+      await Bills.bulkWrite(chunk);
+    }
+  }
+};
+
 //--------------JobContent------------------
 
 billsLibDao.prototype.getJobContent = function (gJobData, callback) {

+ 1 - 0
modules/bills_lib/routes/bills_lib_routes.js

@@ -60,6 +60,7 @@ module.exports = function (app) {
     billsRouter.post('/pasteRel', billsContr.auth, billsContr.init, billsContr.pasteRel);
     billsRouter.post("/deleteBills", billsContr.auth, billsContr.init, billsContr.deleteBills);
     billsRouter.post("/isUsed", billsContr.auth, billsContr.init, billsContr.isUsed);
+    billsRouter.post("/transferRecharge", billsContr.auth, billsContr.init, billsContr.transferRecharge);
 
     billsRouter.post("/getJobContent", jobsContr.auth, jobsContr.init, jobsContr.getJobContent);
     billsRouter.post("/createJobContent", jobsContr.auth, jobsContr.init, jobsContr.createJobContent);

+ 6 - 6
modules/ration_repository/models/ration_item.js

@@ -42,7 +42,7 @@ async function getIDMapping(counterName, data) {
 
 // 拷贝分类树
 async function copyClassData(sourceLibID, targetLibID) {
-    const sourceClassData = await stdRationSectionBackupModel.find({ rationRepId: sourceLibID }, '-_id').lean();
+    const sourceClassData = await stdRationSectionModel.find({ rationRepId: sourceLibID }, '-_id').lean();
     const IDMapping = await getIDMapping(counter.moduleName.rationTree, sourceClassData);
     const insertData = sourceClassData.map(item => ({
         ...item,
@@ -59,7 +59,7 @@ async function copyClassData(sourceLibID, targetLibID) {
 
 // 拷贝子目换算
 async function copyCoeData(sourceLibID, targetLibID) {
-    const sourceCoeData = await stdCoeBackupModel.find({ libID: sourceLibID }, '-_id').lean();
+    const sourceCoeData = await stdCoeModel.find({ libID: sourceLibID }, '-_id').lean();
     const IDMapping = await getIDMapping(counter.moduleName.coeList, sourceCoeData);
     const insertData = sourceCoeData.map(item => ({
         ...item,
@@ -75,11 +75,11 @@ async function copyCoeData(sourceLibID, targetLibID) {
 
 // 拷贝定额库
 rationItemDAO.prototype.copyLib = async function (sourceLibID, targetLibID, sourceGLJLibID, targetGLJLibID) {
-    const sourceRationData = await rationItemBackupModel.find({ rationRepId: sourceLibID }, '-_id').lean();
+    const sourceRationData = await rationItemModel.find({ rationRepId: sourceLibID }, '-_id').lean();
     const rationIDMapping = await getIDMapping(counter.moduleName.rations, sourceRationData);
     const classIDMapping = await copyClassData(sourceLibID, targetLibID);
     const coeIDMapping = await copyCoeData(sourceLibID, targetLibID);
-    const sourceGLJData = await stdGLJItemModelBackup.find({ repositoryId: sourceGLJLibID }, '-_id code ID').lean();
+    const sourceGLJData = await stdGLJItemModel.find({ repositoryId: sourceGLJLibID }, '-_id code ID').lean();
     const sourceGLJCodeMapping = {};
     sourceGLJData.forEach(glj => sourceGLJCodeMapping[glj.code] = glj.ID);
     const targetGLJData = await stdGLJItemModel.find({ repositoryId: targetGLJLibID }, '-_id code ID').lean();
@@ -115,7 +115,7 @@ rationItemDAO.prototype.copyLib = async function (sourceLibID, targetLibID, sour
 }
 
 rationItemDAO.prototype.handleGLJCode = async function (rationLibID, gljLibID) {
-    const rations = await _rationItemModelBackup.find({ rationRepId: rationLibID }, 'ID rationGljList').lean();
+    const rations = await rationItemModel.find({ rationRepId: rationLibID }, 'ID rationGljList').lean();
     const gljs = await stdGLJItemModel.find({ repositoryId: gljLibID }, 'ID code').lean();
     const gljMap = {};
     gljs.forEach(glj => gljMap[glj.ID] = glj.code);
@@ -134,7 +134,7 @@ rationItemDAO.prototype.handleGLJCode = async function (rationLibID, gljLibID) {
         }
     });
     if (bulks.length) {
-        await _rationItemModelBackup.bulkWrite(bulks);
+        await rationItemModel.bulkWrite(bulks);
     }
 }
 

+ 1 - 1
modules/std_glj_lib/controllers/viewsController.js

@@ -33,7 +33,7 @@ class ViewsController extends BaseController {
             let absoluteUrl = compilation.overWriteUrl ? req.app.locals.rootDir + compilation.overWriteUrl : req.app.locals.rootDir;
             overWriteUrl = fs.existsSync(absoluteUrl) && fs.statSync(absoluteUrl).isFile() ? compilation.overWriteUrl : null;
         }
-        // await gljDao.copyLib(7,24); //UAT 部颁2018 -> 部颁2018计价标准
+        // await gljDao.copyLib(37, 58); //UAT 部颁2018 -> 部颁2018计价标准
         // await gljDao.copyLib(7,25); //PROD 部颁2018 -> 部颁2018计价标准
         // await gljDao.copyLib(7,26); //PROD 部颁2018 -> 河南养护工料机库2022
 

+ 2 - 2
modules/std_glj_lib/models/gljModel.js

@@ -95,7 +95,7 @@ class GljDao extends OprDao {
     }
 
     async copyClassData(sourceLibID, targetLibID) {
-        const sourceClassData = await gljClassModelBackup.find({ repositoryId: sourceLibID }, '-_id').lean();
+        const sourceClassData = await gljClassModel.find({ repositoryId: sourceLibID }, '-_id').lean();
         const insertData = sourceClassData.map(item => ({
             ...item,
             repositoryId: targetLibID
@@ -106,7 +106,7 @@ class GljDao extends OprDao {
     }
 
     async copyGLJData(sourceLibID, targetLibID) {
-        const sourceGLJData = await gljModelBackup.find({ repositoryId: sourceLibID }, '-_id').lean();
+        const sourceGLJData = await gljModel.find({ repositoryId: sourceLibID }, '-_id').lean();
         const IDMapping = {};
         const countData = await counter.counterDAO.getIDAfterCount(counter.moduleName.GLJ, sourceGLJData.length);
         const countIdx = countData.sequence_value - (sourceGLJData.length - 1);

+ 12 - 12
web/maintain/bills_lib/scripts/bills_lib_ajax.js

@@ -15,7 +15,7 @@ var mainAjax = {
           $option.val(result.data[i]._id);
           $("#compilationSels").append($option); //
         }
-        $("#compilationSels").on("change", function () {});
+        $("#compilationSels").on("change", function () { });
       },
     });
   },
@@ -189,7 +189,7 @@ var billsAjax = {
         if (!result.error) {
           $(".navbar-text").append(
             "<a href='stdBillsmain'>清单规则</a><i class='fa fa-angle-right fa-fw'></i>" +
-              result.data[0].billsLibName
+            result.data[0].billsLibName
           );
         }
       },
@@ -394,7 +394,7 @@ var billsAjax = {
         }),
       },
       dataType: "json",
-      success: function (result) {},
+      success: function (result) { },
     });
   },
   updateSectionInfo: function (data, callback) {
@@ -424,7 +424,7 @@ var billsAjax = {
         }),
       },
       dataType: "json",
-      success: function (result) {},
+      success: function (result) { },
     });
   },
   updateSerialNo: function (billsLibId, billsId, updateArr, field, callback) {
@@ -527,7 +527,7 @@ var billsAjax = {
         }),
       },
       dataType: "json",
-      success: function (result) {},
+      success: function (result) { },
     });
   },
   pasteRel: function (
@@ -627,7 +627,7 @@ var jobsAjax = {
         }),
       },
       dataType: "json",
-      success: function (result) {},
+      success: function (result) { },
     });
   },
   deleteJobContent: function (lastOperator, billsLibId, ids) {
@@ -642,7 +642,7 @@ var jobsAjax = {
         }),
       },
       dataType: "json",
-      success: function (result) {},
+      success: function (result) { },
     });
   },
   pasteJobs: function (lastOperator, billsLibId, pasteDatas, callback) {
@@ -782,7 +782,7 @@ var designsAjax = {
         }),
       },
       dataType: "json",
-      success: function (result) {},
+      success: function (result) { },
     });
   },
   deleteDesignContent: function (lastOperator, billsLibId, ids) {
@@ -797,7 +797,7 @@ var designsAjax = {
         }),
       },
       dataType: "json",
-      success: function (result) {},
+      success: function (result) { },
     });
   },
   pasteDesigns: function (lastOperator, billsLibId, pasteDatas, callback) {
@@ -941,7 +941,7 @@ var itemsAjax = {
         }),
       },
       dataType: "json",
-      success: function (result) {},
+      success: function (result) { },
     });
   },
   updateValue: function (
@@ -966,7 +966,7 @@ var itemsAjax = {
         }),
       },
       dataType: "json",
-      success: function (reslut) {},
+      success: function (reslut) { },
     });
   },
   deleteItemCharacter: function (lastOperator, billsLibId, ids) {
@@ -981,7 +981,7 @@ var itemsAjax = {
         }),
       },
       dataType: "json",
-      success: function (result) {},
+      success: function (result) { },
     });
   },
   pasteItems: function (lastOperator, billsLibId, pasteDatas, callback) {

+ 21 - 0
web/maintain/bills_lib/scripts/db_controller.js

@@ -259,6 +259,17 @@ const pasteBlock = async (controller) => {
   $.bootstrapLoading.end();
 }
 
+// 计算规则转移补注
+const transferRecharge = async () => {
+  try {
+    $.bootstrapLoading.end();
+    await ajaxPost('/stdBillsEditor/transferRecharge', { billsLibId });
+    window.location.reload();
+  } catch (error) {
+    alert(error.message);
+  }
+  $.bootstrapLoading.end();
+}
 
 // 右键
 const onContextmenuOpr = (workBook, controller) => {
@@ -306,6 +317,16 @@ const onContextmenuOpr = (workBook, controller) => {
                 pasteBlock(controller);
               },
             },
+            handleRecharge: {
+              name: "计算规则转移补注",
+              disabled: function () {
+                return locked;
+              },
+              icon: "fa-exchange",
+              callback: function (key, opt) {
+                transferRecharge();
+              },
+            },
           },
         };
       } else {