Bladeren bron

Merge branch 'master' of http://192.168.1.41:3000/SmartCost/ConstructionCost

TonyKang 3 jaren geleden
bovenliggende
commit
084b43a53f

+ 3 - 3
modules/pm/facade/pm_facade.js

@@ -2583,7 +2583,7 @@ async function doDownLoadAndImport(privateDownloadUrl, info) {
               }
           } catch (error) {
               console.log(error.message);
-              doc.errorMsg = "导入失败,请检查文件!";
+              doc.errorMsg = error.message || "导入失败,请检查文件!";
               doc.status = "error";
           } finally {
               await importLogsModel.update({ key: info.key }, doc);
@@ -2968,8 +2968,8 @@ async function handleMainProjectDatas(mainData,updateData,userID) {
                 tasks.push({updateOne:{filter : updateData.update.query, update : {NextSiblingID:mainProjectID}}});
             }
             //查看是否重名;
-            let temp = await projectModel.findOne({userID:userID,ParentID:p.ParentID,name:p.name});
-            if(temp) p.name = p.name + '(' + moment(Date.now()).tz("Asia/Shanghai").format('MM-DD HH:mm:ss') + '导入)';
+            let temp = await projectModel.findOne({userID:userID,ParentID:p.ParentID,name:p.name, $or: notDeleted});
+            if(temp) throw new Error(`已存在建设项目“${p.name}”`);
         }else {
             p.ParentID = projectIDMap[p.ParentID];
             p.NextSiblingID = projectIDMap[p.NextSiblingID];

+ 14 - 2
web/building_saas/main/js/controllers/block_controller.js

@@ -617,7 +617,13 @@ let BlockController = {
         }
 
         function createRationData(rationData) {
-            let tem_ration = _.cloneDeep(rationData);
+            let tem_ration = {};
+            for(let key in rationData){
+                if(key.indexOf('function(') !== -1){//有时候会出现field里包含一串 function(e){if(e.length>0)... 这些东西,本地测试又不出现,这里先忽略掉
+                    continue;
+                }
+                tem_ration[key] = rationData[key];
+            }
             //删除旧数据
             delete tem_ration._id;
             delete tem_ration.fees;
@@ -647,7 +653,13 @@ let BlockController = {
 
       function createBillsData(billsData, selected) { //ID、重新生成code
             let Bills = projectObj.project.Bills;
-            let temData = _.cloneDeep(billsData);
+            let temData = {};
+            for(let key in billsData){
+                if(key.indexOf('function(') !== -1){//有时候会出现field里包含一串 function(e){if(e.length>0)... 这些东西,本地测试又不出现,这里先忽略掉
+                    continue;
+                }
+                temData[key] = billsData[key];
+            }
             //删除旧数据
             if(temData.children && temData.children.length>0){//如果是有子项,说明是计算得到的,要删除重新计算,没有子项,但是fees有值,说明是自已输入的,值要一起粘贴
                 delete  temData.fees;

+ 5 - 2
web/building_saas/main/js/models/calc_program.js

@@ -724,7 +724,7 @@ let calcTools = {
       sumTU = undefined;
     } else if (me.isLeafBill(treeNode)) {
       if (projectObj.project.Bills.isEngineerEst(treeNode)) {
-        if (treeNode.data.feesIndex["common"] != undefined) {
+        if (treeNode.data.feesIndex && treeNode.data.feesIndex.common) {
           sumT = treeNode.data.feesIndex["common"].totalFee;
           sumU = treeNode.data.feesIndex["common"].unitFee;
           sumTT = treeNode.data.feesIndex["common"].tenderTotalFee;
@@ -2766,6 +2766,7 @@ class CalcProgram {
   reverseTenderCalc(treeNode, tender) {
     if (tender == tenderTypes.ttReverseRation) {
       if (
+        treeNode.data.feesIndex &&
         treeNode.data.feesIndex.common &&
         treeNode.data.feesIndex.common.tenderUnitFee !=
           treeNode.data.feesIndex.common.unitFee
@@ -2786,6 +2787,7 @@ class CalcProgram {
       } else {
         // 既没有目标金额也没有目标单价,此时要初始化使调价合价=原始综合合价,调价单价=原始综合单价。
         if (
+	  treeNode.data.feesIndex &&
           treeNode.data.feesIndex.common &&
           treeNode.data.feesIndex.common.tenderUnitFee !=
             treeNode.data.feesIndex.common.unitFee
@@ -2795,6 +2797,7 @@ class CalcProgram {
           treeNode.changed = true;
         }
         if (
+	  treeNode.data.feesIndex &&
           treeNode.data.feesIndex.common &&
           treeNode.data.feesIndex.common.tenderTotalFee !=
             treeNode.data.feesIndex.common.totalFee
@@ -2820,7 +2823,7 @@ class CalcProgram {
 
     // 系数=调后单价/调前单价
     let coe = 1;
-    if (treeNode.data.feesIndex.common.totalFee != 0)
+    if (treeNode.data.feesIndex && treeNode.data.feesIndex.common && (treeNode.data.feesIndex.common.totalFee != 0))
       coe = (
         treeNode.data.targetUnitFee / treeNode.data.feesIndex.common.unitFee
       ).toDecimal(decimalObj.process);

+ 0 - 1
web/building_saas/main/js/views/billsElf.js

@@ -959,7 +959,6 @@ const BillsSub = (function() {
         });
     }
     function toggleDiv(action){
-        debugger
        if(action=='hide'){
          $('#QDZY_div').hide(); 
          $('#QDJL_div').hide(); 

+ 2 - 1
web/building_saas/main/js/views/std_ration_lib.js

@@ -837,10 +837,11 @@ function seachRation(){
                 resultSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, rationLibObj.onRationSpreadCellDoubleClick);
             }
             resultSpread.bind(GC.Spread.Sheets.Events.TopRowChanged, rationLibObj.onRationSpreadTopRowChanged);
+            SheetDataHelper.loadSheetHeader(rationSetting, rationLibObj.resultSpread.getActiveSheet());
         }else {
             rationLibObj.resultSpread.refresh();
         }
-        SheetDataHelper.loadSheetHeader(rationSetting, rationLibObj.resultSpread.getActiveSheet());
+        
         SheetDataHelper.loadSheetData(rationSetting, rationLibObj.resultSpread.getActiveSheet(), result);
         rationLibObj.setTagForHint(rationLibObj.resultSpread.getActiveSheet(), result);
         rationLibObj.resultCache = result;

+ 22 - 0
web/building_saas/pm/html/project-management-share.html

@@ -83,4 +83,26 @@
             </div>
         </div>
     </div>
+</div>
+<div class="modal fade" id="share-rename-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">
+                    <div class="form-group">
+                        <input type="text" class="form-control" placeholder="输入名称" id="share-rename-input">
+                        <span class="form-text text-danger" id="share-rename-info" style="display: none;">已存在 “建筑工程1”</span>
+                    </div>
+            </div>
+            <div class="modal-footer">
+                <a href="javascript:void(0);" class="btn btn-primary" id="share-rename-confirm">确定</a>
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+            </div>
+        </div>
+    </div>
 </div>

+ 2 - 1
web/building_saas/pm/html/project-management.html

@@ -769,9 +769,10 @@
                     <div class="form-group row">
                         <label for="staticEmail" class="col-auto col-form-label col-form-label-sm">建设项目</label>
                         <div class="col">
-                            <input type="text" class="form-control form-control-sm" value="建设项目名称" readonly="">
+                            <input type="text" id="import-construction-name" class="form-control form-control-sm" value="建设项目名称">
                         </div>
                     </div>
+                    <p class="form-text text-danger" id="import-construction-name-info" style="display: none;">已存在 “建筑工程1”</p>
                     <div class="form-group row">
                         <label for="staticEmail" class="col-auto col-form-label col-form-label-sm">文件类型</label>
                         <div class="col">

+ 28 - 2
web/building_saas/pm/js/pm_import.js

@@ -276,9 +276,16 @@ const importView = (() => {
             feeFile: { name: curData.name, id: `newFeeRate@@${taxData.fee_lib.id}` }  //新建费率文件
         };
     }
+    function constructionExist() {
+        const name = $("#import-construction-name").val().trim();
+        const sameDepthProjs = getProjs(projTreeObj.tree.selected);
+        return sameDepthProjs.some(node => node.data.name === name);
+    }
+
     function eventListen() {
         //选择文件
         $('#customFile').change(async function () {
+            $("import-construction-name-info").hide();
             let file = $(this)[0].files[0];
             $('#import-confirm').prop('disabled', true);    //确认导入无效
             $('.custom-file-label').text(`${file ? file.name : ''}`);   //设置选择框文本
@@ -303,6 +310,11 @@ const importView = (() => {
                     $('.selFile input[name="fileKind-import"]:eq(0)').prop('checked', true);    //文件类型恢复成投标
                     $('#import-taxType').val('1');  //计税方法显示回默认的一般计税法
                     $('.selFile').show();   //显示建设项目、计价规则
+                    if (constructionExist()) {
+                        $('#import-construction-name').focus();
+                        $("#import-construction-name-info").show();
+                        $("#import-construction-name-info").text(`已存在 “${$("#import-construction-name").val().trim()}”`);
+                    }
                 } catch (err) {
                     console.log(err);
                     showUploadAlert(false, err);
@@ -322,11 +334,24 @@ const importView = (() => {
                 showUploadAlert(false, '不存在有效数据。');
                 return;
             }
-            let projectName = $('.selFile input:eq(0)').val();
-            if (!projectName) {
+            if (!xmlObj.name) {
                 showUploadAlert(false, '不存在有效建设项目。');
                 return;
             }
+
+            const constructionName = $("#import-construction-name").val().trim();
+            if (constructionExist()) {
+                $('#import-construction-name').focus();
+                $("#import-construction-name-info").show();
+                $("#import-construction-name-info").text(`已存在 “${constructionName}”`);
+                return;
+            }
+            if (!constructionName) {
+                $("#import-construction-name-info").text(`建设项目名不可为空`);
+                return;
+            }
+            $("#import-construction-name-info").hide();
+
             //文件类型
             let fileKind = $('.selFile input[name="fileKind-import"]:checked').val();
             if (!fileKind) {
@@ -420,6 +445,7 @@ const importView = (() => {
             }
             let pr = new SCComponent.InitProgressBar();
             try {
+                xmlObj.name = $("#import-construction-name").val().trim();
                 //建设项目设置选择的文件类型和选择的计税方法
                 xmlObj.property.fileKind = tbcObj.fileKind;
                 xmlObj.property.taxType = tbcObj.taxType;

+ 29 - 9
web/building_saas/pm/js/pm_share.js

@@ -812,10 +812,10 @@ const pmShare = (function () {
                       return !(selected && selected.data.allowCopy && selected.data.projType === projectType.project);
                   },
                   callback: function (key, opt) {
-                      if($(".p-title").text().includes('免费')){
+                      /* if($(".p-title").text().includes('免费')){
                         hintBox.versionBox('此功能仅在专业版中提供,免费版可选择单位工程进行拷贝');
                         return;
-                      }
+                      } */
                       copyContructionProject(tree.selected);
                   }
                 },
@@ -965,18 +965,19 @@ const pmShare = (function () {
         }
 
     }
-
+    let projectQueryResult = [];
     //拷贝分享的建设项目
     //@param {Object}selected 
-    async function copyContructionProject(selected){
+    async function copyContructionProject(selected, rename){
       try {
-        let newName = getCopyName(selected);
+        let newName = rename ? rename : getCopyName(selected);
         //获取单项工程的单位工程
         let projectQuery = {$or: [{deleteInfo: null}, {'deleteInfo.deleted': false}], userID: userID,projType: "Project"};
-        const rstData = await ajaxPost('/pm/api/getProjectsByQuery', {user_id: userID, query: projectQuery, options: '-_id -property'}, false, 10000);
-        for(let project of rstData){
+        projectQueryResult = await ajaxPost('/pm/api/getProjectsByQuery', {user_id: userID, query: projectQuery, options: '-_id -property'}, false, 10000);
+        for(let project of projectQueryResult){
             if(project.name === newName){
-                alert("已存在此建设项目");
+                $("#share-rename-dialog").modal('show');
+                $("#share-rename-input").val(newName);
                 return;
             }
         }
@@ -1007,7 +1008,7 @@ const pmShare = (function () {
             node = node.parent;
             userInfo = node.data.userInfo;
         }
-        return `${orgName} (${userInfo.name}分享拷贝)`;
+        return `${orgName}`;
     }
     //清除了该节点后,可能还有该节点的数据在树上(树允许有重复数据),需要更新分享信息
     function updateAfterCancel(userID, projectID) {
@@ -1184,6 +1185,25 @@ const pmShare = (function () {
                 $.bootstrapLoading.end();
             });
         });
+        // 拷贝重命名
+        $('#share-rename-dialog').on('show.bs.modal', () => {
+            $('#share-rename-info').hide();
+            setTimeout(() => {
+                $('#share-rename-input').focus();
+            }, 200)
+        });
+        $('#share-rename-confirm').click(function () {
+            const newName = $('#share-rename-input').val().trim();
+            for(let project of projectQueryResult){
+                if(project.name === newName){
+                    $('#share-rename-info').text(`已存在 “${newName}”`);
+                    $('#share-rename-info').show();
+                    return;
+                }
+            }
+            $("#share-rename-dialog").modal('hide');
+            copyContructionProject(tree.selected, newName);
+        });
     }
 
     return {

File diff suppressed because it is too large
+ 1 - 1
web/users/html/index.html


File diff suppressed because it is too large
+ 1 - 1
web/users/html/login-sms.html


File diff suppressed because it is too large
+ 1 - 1
web/users/html/login-ver.html


File diff suppressed because it is too large
+ 1 - 1
web/users/html/login.html


+ 1 - 1
web/users/html/user-check.html

@@ -63,7 +63,7 @@ html{height:100%;}
         </form>
         <% } %>
 
-       <!--  <div class="text-white fixed-bottom"><p class="text-center mb-1">Copyright © 2019 <a href="https://smartcost.com.cn" target="_blank" class="text-white">珠海纵横创新软件有限公司</a>.All Rights Reserved.<a class="text-white ml-2" href="http://www.miitbeian.gov.cn" target="_blank">粤ICP备14032472号</a></p></div> -->
+       <!--  <div class="text-white fixed-bottom"><p class="text-center mb-1">Copyright © 2019 <a href="https://smartcost.com.cn" target="_blank" class="text-white">珠海纵横创新软件有限公司</a>.All Rights Reserved.<a class="text-white ml-2" href="https://beian.miit.gov.cn" target="_blank">粤ICP备14032472号</a></p></div> -->
     </div>
 
     <!-- JS. -->

+ 1 - 1
web/users/html/user-reg.html

@@ -75,7 +75,7 @@ html{height:100%;}
             </div>
         </form>
 
-       <!--  <div class="text-white fixed-bottom"><p class="text-center mb-1">Copyright © 2019 <a href="https://smartcost.com.cn" target="_blank" class="text-white">珠海纵横创新软件有限公司</a>.All Rights Reserved.<a class="text-white ml-2" href="http://www.miitbeian.gov.cn" target="_blank">粤ICP备14032472号</a></p></div> -->
+       <!--  <div class="text-white fixed-bottom"><p class="text-center mb-1">Copyright © 2019 <a href="https://smartcost.com.cn" target="_blank" class="text-white">珠海纵横创新软件有限公司</a>.All Rights Reserved.<a class="text-white ml-2" href="https://beian.miit.gov.cn" target="_blank">粤ICP备14032472号</a></p></div> -->
     </div>
 
     <!-- JS. -->