Browse Source

feat: 对某些编办限制新建建设项目 (##4794)

vian 1 năm trước cách đây
mục cha
commit
a04033689e

+ 44 - 44
modules/pm/controllers/pm_controller.js

@@ -79,7 +79,7 @@ module.exports = {
         });
     },
     getProjects: async function (req, res) {
-         await ProjectsData.getUserProjects(req.session.sessionUser.id, req.session.sessionCompilation._id, function(err, message, projects){
+        await ProjectsData.getUserProjects(req.session.sessionUser.id, req.session.sessionCompilation._id, function (err, message, projects) {
             if (projects) {
                 callback(req, res, err, message, projects);
             } else {
@@ -156,7 +156,7 @@ module.exports = {
                                 specialResult.newFeeLibID = engineering.tax_group[0].fee_lib.id;
                             }
                             specialResult.billLibs = engineering.bill_lib;
-                            
+
                         }
                     }
                 }
@@ -191,7 +191,7 @@ module.exports = {
         asyncTool.parallel(functions, function (err, result) {
             {
                 if (!err) {
-                    res.json({ error: 0, message: err, data: specialResult});
+                    res.json({ error: 0, message: err, data: specialResult });
                 } else {
                     res.json({ error: 1, message: err, data: null });
                 }
@@ -273,8 +273,8 @@ module.exports = {
                 projInfo.shareState = await pm_facade.getShareState(projectID, userID);
             }
             // 获取项目所属用户
-            projInfo.owner = await userModel.findOne({_id: mongoose.Types.ObjectId(project.userID)}, 'real_name mobile').lean();
-            projInfo.opener = await userModel.findOne({_id: mongoose.Types.ObjectId(userID)}, 'real_name mobile').lean();
+            projInfo.owner = await userModel.findOne({ _id: mongoose.Types.ObjectId(project.userID) }, 'real_name mobile').lean();
+            projInfo.opener = await userModel.findOne({ _id: mongoose.Types.ObjectId(userID) }, 'real_name mobile').lean();
             callback('', consts.projectConst.PROJECT_INFO, project);
         }, function (err) {
             callback(err, consts.projectConst.PROJECT_INFO, {});
@@ -303,7 +303,7 @@ module.exports = {
                 }
                 //读取建设项目的基本信息
                 let basicInfo = await ProjectsData.getBasicInfo(projectID);
-                if(basicInfo !== null){
+                if (basicInfo !== null) {
                     projInfo.property.basicInformation = basicInfo;
                 }
                 //获取单位工程完整目录结构
@@ -344,9 +344,9 @@ module.exports = {
                 compilationName: sessionCompilation.name,
                 versionName: request.session.compilationVersion,
 
-                title:getTitle(request.headers.host) 
+                title: getTitle(request.headers.host)
             };
-    
+
             response.render('building_saas/pm/html/blank-project.html', renderData);
         } else {
             let compilationModel = new CompilationModel();
@@ -356,54 +356,54 @@ module.exports = {
             sessionCompilation = request.session.sessionCompilation;
             //更新用户的使用过的费用定额列表
             let isFirst = await pm_facade.isFirst(request.session.sessionUser.id, compilationData._id.toString());
-            
+
             let engineeringLibModel = new EngineeringLibModel();
-    
+
             // 建议估算
             let suggestionValuation = sessionCompilation.suggestion_valuation !== undefined ?
                 sessionCompilation.suggestion_valuation : [];
             suggestionValuation = await engineeringLibModel.getLib(suggestionValuation);
-    
+
             // 可行性估算
             let feasibilityValuation = sessionCompilation.feasibility_valuation !== undefined ?
                 sessionCompilation.feasibility_valuation : [];
             feasibilityValuation = await engineeringLibModel.getLib(feasibilityValuation);
-    
+
             // 估算
             let estimationValuation = sessionCompilation.estimation_valuation !== undefined ?
                 sessionCompilation.estimation_valuation : [];
-                estimationValuation = await engineeringLibModel.getLib(estimationValuation);
-    
+            estimationValuation = await engineeringLibModel.getLib(estimationValuation);
+
             // 概算
             let roughValuation = sessionCompilation.rough_valuation !== undefined ?
                 sessionCompilation.rough_valuation : [];
             roughValuation = await engineeringLibModel.getLib(roughValuation);
-            
+
             // 清单计价
             let billValuation = sessionCompilation.bill_valuation !== undefined ?
                 sessionCompilation.bill_valuation : [];
             billValuation = await engineeringLibModel.getLib(billValuation);
-    
+
             // 定额计价
             let rationValuation = sessionCompilation.ration_valuation !== undefined ?
                 sessionCompilation.ration_valuation : [];
             rationValuation = await engineeringLibModel.getLib(rationValuation);
-    
+
             if (sessionCompilation.name === '四川养护(2013)' || sessionCompilation.name === '部颁2018计价标准') {
                 billValuation = rationValuation;
             }
-    
+
             let absoluteUrl = compilationData.overWriteUrl ? request.app.locals.rootDir + compilationData.overWriteUrl : request.app.locals.rootDir;
             let overWriteUrl = fs.existsSync(absoluteUrl) && fs.statSync(absoluteUrl).isFile() ? compilationData.overWriteUrl : null;
             //欢迎页显示控制
-            let [isShow,context,showTime] = await pm_facade.getWelcomeInfo(sessionCompilation._id,request.session.sessionUser,request.session.compilationVersion.includes('学习'));
+            let [isShow, context, showTime] = await pm_facade.getWelcomeInfo(sessionCompilation._id, request.session.sessionUser, request.session.compilationVersion.includes('学习'));
             const unreadShareList = await pm_facade.getUnreadShareListByCompilation(request.session.sessionUser.id, sessionCompilation._id);
             let renderData = {
                 unreadShareList: JSON.stringify(unreadShareList),
                 isFirst: isFirst,
-                isShow:isShow,
-                context:context,
-                showTime:showTime,
+                isShow: isShow,
+                context: context,
+                showTime: showTime,
                 userAccount: request.session.userAccount,
                 userID: request.session.sessionUser.id,
                 isFree,
@@ -419,12 +419,12 @@ module.exports = {
                 adminLevelType: JSON.stringify(AdminLevelType),
                 compilationName: sessionCompilation.name,
                 versionName: request.session.compilationVersion,
-                socketPort:config[process.env.NODE_ENV].socketPort?config[process.env.NODE_ENV].socketPort:5500,
-                LicenseKey:config.getLicenseKey(process.env.NODE_ENV),
+                socketPort: config[process.env.NODE_ENV].socketPort ? config[process.env.NODE_ENV].socketPort : 5500,
+                LicenseKey: config.getLicenseKey(process.env.NODE_ENV),
                 cloudTitle: config.prod_sc.title,
-                title:getTitle(request.headers.host) 
+                title: getTitle(request.headers.host)
             };
-    
+
             response.render('building_saas/pm/html/project-management.html', renderData);
         }
     },
@@ -500,7 +500,7 @@ module.exports = {
         }
     },
 
-    getGC: async function(req, res) {
+    getGC: async function (req, res) {
         const userID = req.session.sessionUser.id;
         const compilationId = req.session.sessionCompilation._id;
         try {
@@ -574,14 +574,14 @@ module.exports = {
                 for (let i = 0, len = gc_tenderFiles.length; i < len; i++) {
                     let gc_t = gc_tenderFiles[i];
                     let theProj = _projs[prefix + gc_t.ParentID] || null;
-                    if(!theProj){
+                    if (!theProj) {
                         let tempProjs = await ProjectsData.getProjectsByIds(userID, compilatoinId, [gc_t.ParentID]);
-                        if(tempProjs.length > 0 && tempProjs[0].projType === projType.project){
+                        if (tempProjs.length > 0 && tempProjs[0].projType === projType.project) {
                             theProj = _projs[prefix + gc_t.ParentID] = tempProjs[0]._doc;
                             buildProj(theProj);
                         }
                     }
-                    if(theProj) {
+                    if (theProj) {
                         theProj.children.push(gc_t);
                     }
                 }
@@ -1022,7 +1022,7 @@ module.exports = {
         };
         try {
             data.session = req.session;
-            result = await redirectToImportServer(data,"importProject",req);
+            result = await redirectToImportServer(data, "importProject", req);
         } catch (err) {
             console.log(err);
             result.error = 1;
@@ -1031,19 +1031,19 @@ module.exports = {
         res.json(result);
     },
     copyConstructionProject: async function (req, res) {
-      let data = JSON.parse(req.body.data);
-      let result = {
-          error: 0
-      };
-      try {
-          data.session = req.session;
-          result.data = await redirectToImportServer(data, "copyConstructionProject", req);
-      } catch (err) {
-          console.log(err);
-          result.error = 1;
-          result.message = err.message;
-      }
-      res.json(result);
+        let data = JSON.parse(req.body.data);
+        let result = {
+            error: 0
+        };
+        try {
+            data.session = req.session;
+            result.data = await redirectToImportServer(data, "copyConstructionProject", req);
+        } catch (err) {
+            console.log(err);
+            result.error = 1;
+            result.message = err.message;
+        }
+        res.json(result);
     },
     importProcessChecking: async function (req, res) {
         let result = {

+ 24 - 0
web/building_saas/pm/html/project-management.html

@@ -475,6 +475,30 @@
         </div>
     </div>
 </div>
+<!-- 停止新建 -->
+<div class="modal fade" id="stop-create-dialog" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">提示</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <p>尊敬的用户:</p>
+                <p>请使用<a href="https://dsk.smartcost.com.cn/">大司空云计价</a>编制新项目,现版本已停止新建项目。</p>
+                <p>请联系当地客服免费升级账号:</p>
+                <p>当地服务热线:<a id="stop-create-contact" href="javascript:void(0);">联系</a>当地客服</p>
+                <p>全国服务热线:0756-3850888,企业QQ:800003850</p>
+            </div>
+            <div class="modal-footer">
+                <a href="javascript:void(0);" class="btn btn-primary" data-dismiss="modal" id="stop-create-confirm">确定</a>
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+            </div>
+        </div>
+    </div>
+</div>
 <!--弹出重命名-->
 <div class="modal fade" id="rename-dialog" data-backdrop="static">
     <div class="modal-dialog" role="document">

+ 125 - 119
web/building_saas/pm/js/pm_newMain.js

@@ -321,7 +321,13 @@ const projTreeObj = {
         return projTreeObj.getAddBtnDisabled(projectType.project);
       },
       callback: function (key, opt) {
-        $("#add-project-dialog").modal("show");
+        const names = ['重庆养护(2018)', '内蒙古养护(2019)', '甘肃养护(2021)', '内蒙古高速公路养护(2022)', '内蒙古高速公路养护(2022)'];
+        const stopCreate = compilationData && names.includes(compilationData.name);
+        if (stopCreate) {
+          $('#stop-create-dialog').modal('show');
+        } else {
+          $('#add-project-dialog').modal('show');
+        }
       },
     },
     addTender: {
@@ -1188,8 +1194,8 @@ const projTreeObj = {
         data.engineeringCost = data.engineeringCost ? data.engineeringCost : 0;
         data.unitPriceFile =
           data.property &&
-          data.property.unitPriceFile &&
-          data.property.unitPriceFile.name
+            data.property.unitPriceFile &&
+            data.property.unitPriceFile.name
             ? data.property.unitPriceFile.name
             : "";
         data.feeRateFile =
@@ -1223,7 +1229,7 @@ const projTreeObj = {
       shareImgWidth = 13,
       shareImgHeight = 13;
     let defaultHeight = 18; // 单元格默认高度
-    let TreeNodeCellType = function () {};
+    let TreeNodeCellType = function () { };
     TreeNodeCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
     // 自动行高处理 此函数在每次调用autoFitRow后调用,返回的值作为新的单元格高度
     // 在单元格设置为自动行高后,单元格的内容有空格时,spreadjs会将空格认为是换行,会导致高度计算不正确,因此在setCellValue中处理空格
@@ -1240,9 +1246,9 @@ const projTreeObj = {
       const node = me.tree.items[context.row];
       const nodeIndent = node
         ? (node.depth() + 1) * indent +
-          node.depth() * levelIndent +
-          imgWidth +
-          5
+        node.depth() * levelIndent +
+        imgWidth +
+        5
         : 0;
       const cellWidth = context.sheet.getCell(-1, context.col).width();
       const textLength = this.getAutoFitWidth(...arguments);
@@ -1494,7 +1500,7 @@ const projTreeObj = {
         return (
           hitinfo.x > centerX + halfBoxLength &&
           hitinfo.x <
-            centerX + halfBoxLength + imgWidth + indent / 2 + 3 + textLength
+          centerX + halfBoxLength + imgWidth + indent / 2 + 3 + textLength
         );
       }
       if (hitinfo.sheet.name() === "projectSheet") {
@@ -1571,9 +1577,9 @@ const projTreeObj = {
       let node = me.tree.items[hitinfo.row];
       let nodeIndent = node
         ? (node.depth() + 1) * indent +
-          node.depth() * levelIndent +
-          imgWidth +
-          3
+        node.depth() * levelIndent +
+        imgWidth +
+        3
         : 0;
       let textLength = this.getAutoFitWidth(value, text, acStyle, zoom, {
         sheet: hitinfo.sheet,
@@ -1628,8 +1634,8 @@ const projTreeObj = {
       if (node.data.projType === projectType.tender) {
         value =
           node.data.property &&
-          node.data.property.unitPriceFile &&
-          node.data.property.unitPriceFile.name
+            node.data.property.unitPriceFile &&
+            node.data.property.unitPriceFile.name
             ? node.data.property.unitPriceFile.name
             : "";
       }
@@ -1637,8 +1643,8 @@ const projTreeObj = {
       if (node.data.projType === projectType.tender) {
         value =
           node.data.property &&
-          node.data.property.feeFile &&
-          node.data.property.feeFile.name
+            node.data.property.feeFile &&
+            node.data.property.feeFile.name
             ? node.data.property.feeFile.name
             : "";
       }
@@ -2013,8 +2019,7 @@ const projTreeObj = {
         );
       } else {
         alert(
-          `当前的建设项目中已经有相同名字的${
-            from == "feeRateFile" ? "费率" : "单价"
+          `当前的建设项目中已经有相同名字的${from == "feeRateFile" ? "费率" : "单价"
           }文件!`
         );
       }
@@ -2354,9 +2359,8 @@ function changeValuationType(type) {
     if (valuation === null) {
       continue;
     }
-    html += `<option ${i === targetData.length - 1 ? "selected" : ""} value="${
-      valuation.id
-    }">${valuation.name}</option>`;
+    html += `<option ${i === targetData.length - 1 ? "selected" : ""} value="${valuation.id
+      }">${valuation.name}</option>`;
   }
   $("#valuation").html(html);
   let engineeringList = getEngineeringList();
@@ -3339,9 +3343,8 @@ function AddProject() {
 function _getOptionDivDomStr(value, rdName, labelName, id, isChecked) {
   return `
         <div class="custom-control custom-radio custom-control-inline">
-            <input type="radio" value="${value}" name="${rdName}" ${
-    isChecked ? "checked" : ""
-  } id="${id}" class="custom-control-input">
+            <input type="radio" value="${value}" name="${rdName}" ${isChecked ? "checked" : ""
+    } id="${id}" class="custom-control-input">
             <label class="custom-control-label" for="${id}">${labelName}</label>
         </div>
     `;
@@ -3352,108 +3355,103 @@ function initProjectOptSet($target) {
   const html = `<div class="form-group row">
                         <label for="staticEmail" class="col-auto col-form-label col-form-label-sm">项目类型</label>
                         <div class="col">
-                            ${
-                              COMPILATION_NAME.includes("公路造价")
-                                ? ` 
+                            ${COMPILATION_NAME.includes("公路造价")
+      ? ` 
                                 ${_getOptionDivDomStr(
-                                  SUGGESTION,
-                                  "valuation-type",
-                                  "建议估算",
-                                  "type-suggestion",
-                                  true
-                                )}
+        SUGGESTION,
+        "valuation-type",
+        "建议估算",
+        "type-suggestion",
+        true
+      )}
                                 ${_getOptionDivDomStr(
-                                  FEASIBILITY,
-                                  "valuation-type",
-                                  "可行性估算",
-                                  "type-feasibility",
-                                  false
-                                )}
+        FEASIBILITY,
+        "valuation-type",
+        "可行性估算",
+        "type-feasibility",
+        false
+      )}
                                 ${_getOptionDivDomStr(
-                                  ROUGH,
-                                  "valuation-type",
-                                  "概算",
-                                  "type-rough",
-                                  false
-                                )}
+        ROUGH,
+        "valuation-type",
+        "概算",
+        "type-rough",
+        false
+      )}
                             `
-                                : ""
-                            }
-                            ${
-                              COMPILATION_NAME.includes(
-                                "内蒙古高速公路日常养护估算(2021)"
-                              )
-                                ? `
+      : ""
+    }
+                            ${COMPILATION_NAME.includes(
+      "内蒙古高速公路日常养护估算(2021)"
+    )
+      ? `
                                 ${_getOptionDivDomStr(
-                                  ESTIMATION,
-                                  "valuation-type",
-                                  "估算",
-                                  "type-suggestion",
-                                  true
-                                )}
+        ESTIMATION,
+        "valuation-type",
+        "估算",
+        "type-suggestion",
+        true
+      )}
                                 `
-                                : ``
-                            }
-                            ${
-                              COMPILATION_NAME.includes("四川养护(2013)") ||
-                              COMPILATION_NAME.includes("部颁2018计价标准")
-                                ? `
+      : ``
+    }
+                            ${COMPILATION_NAME.includes("四川养护(2013)") ||
+      COMPILATION_NAME.includes("部颁2018计价标准")
+      ? `
                                 ${_getOptionDivDomStr(
-                                  BILL_BUDGET,
-                                  "valuation-type",
-                                  "清单预算",
-                                  "type-bill_budget",
-                                  true
-                                )}
+        BILL_BUDGET,
+        "valuation-type",
+        "清单预算",
+        "type-bill_budget",
+        true
+      )}
                                 `
-                                : ``
-                            }
-                            ${
-                              COMPILATION_NAME !==
-                                "内蒙古高速公路日常养护估算(2021)" &&
-                              COMPILATION_NAME !== "四川养护(2013)" &&
-                              COMPILATION_NAME !== "部颁2018计价标准"
-                                ? `
-                                ${
-                                  !COMPILATION_NAME.includes("部颁2018计价标准")
-                                    ? _getOptionDivDomStr(
-                                        BUDGET,
-                                        "valuation-type",
-                                        "预算",
-                                        "type-budget",
-                                        !COMPILATION_NAME.includes("公路造价")
-                                      )
-                                    : ""
-                                }
+      : ``
+    }
+                            ${COMPILATION_NAME !==
+      "内蒙古高速公路日常养护估算(2021)" &&
+      COMPILATION_NAME !== "四川养护(2013)" &&
+      COMPILATION_NAME !== "部颁2018计价标准"
+      ? `
+                                ${!COMPILATION_NAME.includes("部颁2018计价标准")
+        ? _getOptionDivDomStr(
+          BUDGET,
+          "valuation-type",
+          "预算",
+          "type-budget",
+          !COMPILATION_NAME.includes("公路造价")
+        )
+        : ""
+      }
                                 ${_getOptionDivDomStr(
-                                  BOQ,
-                                  "valuation-type",
-                                  "工程量清单",
-                                  "type-boq",
-                                  COMPILATION_NAME.includes("部颁2018计价标准")
-                                )}
+        BOQ,
+        "valuation-type",
+        "工程量清单",
+        "type-boq",
+        COMPILATION_NAME.includes("部颁2018计价标准")
+      )}
                                 `
-                                : ``
-                            }
+      : ``
+    }
                         </div>
                     </div>
                     <div class="form-group row hide-area" id="boq-type">
                         <label for="staticEmail" class="col-auto col-form-label col-form-label-sm">清单类型</label>
                         <div class="col">
                             ${_getOptionDivDomStr(
-                              BID_INVITATION,
-                              "boq-type-input",
-                              "招标",
-                              "boq-type-tender",
-                              false
-                            )}
+      BID_INVITATION,
+      "boq-type-input",
+      "招标",
+      "boq-type-tender",
+      false
+    )}
                             ${_getOptionDivDomStr(
-                              BID_SUBMISSION,
-                              "boq-type-input",
-                              "投标",
-                              "boq-type-bidder",
-                              true
-                            )}
+      BID_SUBMISSION,
+      "boq-type-input",
+      "投标",
+      "boq-type-bidder",
+      true
+    )}
                         </div>
                     </div>`;
   //const $children = $(html);
@@ -4242,6 +4240,15 @@ function AddTender() {
       .children("option:selected")
       .text();
     //let newTab = window.open('about:blank');
+    let tempProj = getNodeByName(projName, tempProjs);
+    if (!tempProj) {
+      const names = ['重庆养护(2018)', '内蒙古养护(2019)', '甘肃养护(2021)', '内蒙古高速公路养护(2022)', '内蒙古高速公路养护(2022)'];
+      const stopCreate = compilationData && names.includes(compilationData.name);
+      if (stopCreate) {
+        $('#stop-create-dialog').modal('show');
+        return;
+      }
+    }
     $.bootstrapLoading.start();
     let callback = function (tenderNode) {
       $("#add-tender-dialog").modal("hide");
@@ -4722,9 +4729,8 @@ function getEngineeringHtml(engineeringList) {
     if (engLibNames.includes(tmp.lib.name)) {
       continue;
     }
-    result += `<option ${i === 0 ? "selected" : ""} value="${tmp.lib.name}">${
-      tmp.lib.name
-    }</option>`;
+    result += `<option ${i === 0 ? "selected" : ""} value="${tmp.lib.name}">${tmp.lib.name
+      }</option>`;
     engLibNames.push(tmp.lib.name);
   }
   return result;
@@ -4760,8 +4766,8 @@ function getProperty(projectInfo) {
     .removeAttr("checked", "checked");
   $(
     "input[name='tender_valuation_type'][value='" +
-      projectProperty.valuationType +
-      "']"
+    projectProperty.valuationType +
+    "']"
   )
     .attr("checked", "checked")
     .removeAttr("disabled", "disabled");
@@ -4787,7 +4793,7 @@ function getUnitFile(parentID, callback) {
     error: function () {
       alert("数据传输错误!");
     },
-    beforeSend: function () {},
+    beforeSend: function () { },
     success: function (response) {
       if (response.error === 1) {
         alert("获取失败!");
@@ -4820,7 +4826,7 @@ function getFeeRateFile(parentID, callback) {
     error: function () {
       alert("数据传输错误!");
     },
-    beforeSend: function () {},
+    beforeSend: function () { },
     success: function (response) {
       if (response.error === 1) {
         alert("获取失败!");
@@ -5060,8 +5066,8 @@ function set_file_table(target, poj_tenders, fileList, type) {
     let usedHtml =
       usedObj.usedCount > 0
         ? '<td class="text-center"><a href="javascript:void(0);">' +
-          usedObj.usedCount +
-          "</a></td>"
+        usedObj.usedCount +
+        "</a></td>"
         : '<td class="text-center">' + usedObj.usedCount + "</td>";
     let unitPriceEditHtml =
       type === fileType.unitPriceFile
@@ -5376,8 +5382,8 @@ function doAfterImport(projectDatas) {
     data.feeStandardName =
       (data.property && data.property.feeStandardName) || ""; //工程专业列显示用
     let parent = projTreeObj.tree.items.find(
-        (node) => node.data.ID === data.ParentID
-      ),
+      (node) => node.data.ID === data.ParentID
+    ),
       next = projTreeObj.tree.items.find(
         (node) => node.data.ID === data.NextSiblingID
       );