浏览代码

模板重命名

chenshilong 7 年之前
父节点
当前提交
01d83003c2

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

@@ -911,6 +911,11 @@ let analyzer = {
             i++;
         };
         return name + i;
+    },
+    templateNameIsExist: function (name) {
+        if (projectObj.project.calcProgram.compiledTemplateMaps[name])
+            return true
+        else return false;
     }
 };
 

+ 11 - 1
web/building_saas/main/js/models/main_consts.js

@@ -268,7 +268,17 @@ const cpFeeTypes = [
     {type: 'adjustLabour', name: '调整人工费'},
     {type: 'adjustMachineLabour', name: '调整机上人工费'},
     {type: 'estimate', name: '暂估费'},
-    {type: 'common', name: '工程造价'}
+    {type: 'common', name: '工程造价'},
+    {type: 'fee1', name: '费用1'}//,
+    // {type: 'fee2', name: '费用2'},
+    // {type: 'fee3', name: '费用3'},
+    // {type: 'fee4', name: '费用4'},
+    // {type: 'fee5', name: '费用5'},
+    // {type: 'fee6', name: '费用6'},
+    // {type: 'fee7', name: '费用7'},
+    // {type: 'fee8', name: '费用8'},
+    // {type: 'fee9', name: '费用9'}
+
 ];
 
 const engineeringType = {

+ 48 - 1
web/building_saas/main/js/views/calc_program_manage.js

@@ -139,7 +139,7 @@ let calcProgramManage = {
             items: {
                 "copyTemplate": {
                     name: "另存为",
-                    icon: 'fa-sign-in',
+                    icon: 'copy',
                     callback: function (key, opt) {
                         $.bootstrapLoading.start();
                         let template = calcProgramManage.getSelectionInfo().template;
@@ -174,6 +174,52 @@ let calcProgramManage = {
                         });
                     }
                 },
+                "reNameTemplate": {
+                    name: "重命名...",
+                    icon: 'edit',
+                    disabled: function () {
+                        let custom = calcProgramManage.getSelectionInfo().template.custom;
+                        let canReName = custom ? custom : false;
+                        return !canReName;
+                    },
+                    callback: function (key, opt) {
+                        $.bootstrapLoading.start();
+                        let template = calcProgramManage.getSelectionInfo().template;
+                        let idx = calcProgramManage.mainSpread.getActiveSheet().getActiveRowIndex();
+
+                        let newName = prompt("请输入新的模板名称:", template.name);
+                        if (!newName || (newName && newName == template.name)) {
+                            $.bootstrapLoading.end();
+                            return;
+                        };
+
+                        while (analyzer.templateNameIsExist(newName)){
+                            alert(`“${newName}”已存在,请重新输入!`);
+                            newName = prompt("请输入新的模板名称:", template.name);
+                        };
+
+                        if (!newName || (newName && newName == template.name)) {
+                            $.bootstrapLoading.end();
+                            return;
+                        };
+
+                        template.name = newName;
+
+                        let data = {
+                            'projectID': projectObj.project.ID(),
+                            'ID': template.ID,
+                            'name': template.name
+                        };
+                        calcProgramManage.updateTemplate(data, function (rst) {
+                            if (rst){
+                                projectObj.project.calcProgram.compileTemplate(template);
+                                sheetCommonObj.showData(calcProgramManage.mainSpread.getSheet(0), calcProgramManage.mainSetting, calcProgramManage.datas);
+                                $.bootstrapLoading.end();
+                            }
+                            else $.bootstrapLoading.end();
+                        });
+                    }
+                },
                 "spr1": '--------',
                 "deleteTemplate": {
                     name: '删除',
@@ -244,6 +290,7 @@ let calcProgramManage = {
                         });
                     }
                 },
+                "spr1": '--------',
                 "deleteCalcItem": {
                     name: '删除行',
                     icon: 'fa-remove',