Explorar el Código

feat:在分享页面,将分段文件“拷贝”到目标建设项目时,需判断项目类型相同

vian hace 5 años
padre
commit
20ce9a6925
Se han modificado 2 ficheros con 15 adiciones y 13 borrados
  1. 1 0
      modules/pm/controllers/pm_controller.js
  2. 14 13
      web/building_saas/pm/js/pm_share.js

+ 1 - 0
modules/pm/controllers/pm_controller.js

@@ -736,6 +736,7 @@ module.exports = {
                     if (proj.projType === projType.tender) {
                         // 设置项目类别
                         proj.valuationType = proj.property.valuationType === 'bill' ? '预算' : '工程量清单';
+                        proj._valuationType = proj.property.valuationType;
                         //设置工程专业
                         proj.feeStandardName = proj.property.feeStandardName || '';
                         //设置计税方法

+ 14 - 13
web/building_saas/pm/js/pm_share.js

@@ -867,7 +867,7 @@ const pmShare = (function () {
         }
         for (let node of items) {
             if (node.children.length === 0) {//project
-                rst.push({ ID: node.data.ID, fileHierarchyName: getFileHierarchyName(node) })
+                rst.push({ ID: node.data.ID, fileHierarchyName: getFileHierarchyName(node), valuationType: node.data.property.valuationType || '' })
             }
         }
         return rst;
@@ -877,26 +877,26 @@ const pmShare = (function () {
     function setCopyModal() {
         //获取建设项目
         let projQuery = { $or: [{ deleteInfo: null }, { 'deleteInfo.deleted': false }], projType: { $in: [projectType.project, projectType.folder] }, userID: userID };
-        CommonAjax.post('/pm/api/getProjectsByQuery', { user_id: userID, query: projQuery, options: '-_id -property' }, function (rstData) {
+        CommonAjax.post('/pm/api/getProjectsByQuery', { user_id: userID, query: projQuery, options: '-_id' }, function (rstData) {
             let fileHierarchyData = getFileHierarchyInfo(rstData);
-            $('#copyShare_selectProj').empty();
-            for (let proj of fileHierarchyData) {
-                let opt = $('<option>').val(proj.ID).text(proj.fileHierarchyName);
-                $('#copyShare_selectProj').append(opt);
-            }
-            //初始选择
-            /*if(fileHierarchyData.length > 0){
-                setEng(fileHierarchyData[0].ID);
-            }*/
+            const html = fileHierarchyData.reduce((acc, proj) =>
+                acc += `<option value="${proj.ID}" data-valuation="${proj.valuationType}">${proj.fileHierarchyName}</option>`
+                , '');
+            $('#copyShare_selectProj').html(html);
         });
     }
     //拷贝分享的工程
     //@param {Object}selected {Number}parentID @return {void}
-    async function copyShareProject(selected, projID) {
+    async function copyShareProject(selected, projID, projValuationType) {
         try {
             if (!projID || !selected) {
                 return;
             }
+            // 复制到的目标建设项目项目类型与当前文件项目类型相同才可复制(目标建设项目为空也能复制到,兼容旧项目)
+            const tenderValuationType = selected.data._valuationType || null;
+            if (projValuationType && projValuationType !== tenderValuationType) {
+                return alert('当前分段与目标建设项目的项目类型不同,请选择其他建设项目进行复制。');
+            }
             let copyMap = { copy: null, update: null };
             let newName = getCopyName(selected);
             //获取建设项目的分段
@@ -1095,7 +1095,8 @@ const pmShare = (function () {
                 $('#copyShareProj-info').show();
                 return;
             }
-            copyShareProject(tree.selected, parseInt(selProj));
+            const valuationType = $('#copyShare_selectProj').find('option:selected').data('valuation') || null;
+            copyShareProject(tree.selected, parseInt(selProj), valuationType);
         });
         //清除分享
         $('#cancelShareConfirm').click(function () {