Browse Source

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost

zhangweicheng 7 years ago
parent
commit
7c468b206e

+ 1 - 1
web/building_saas/main/html/main.html

@@ -163,7 +163,7 @@
                                               </p>
                                               <p>
                                                   <label class="title">子目生成方式:</label>
-                                                  <select id="child-display-format">
+                                                  <select id="child-display-format" disabled="disabled">
                                                       <option value="1" selected="selected">编号+定额名称</option>
                                                       <option value="2">序号+定额名称</option>
                                                   </select>

+ 51 - 13
web/building_saas/main/js/views/character_content_view.js

@@ -753,20 +753,23 @@ let pageCCOprObj = {
         });
     },
     /**
-     * 根据配置转换清单项目特征
+     * 根据配置设置清单项目特征
      *
      * @param {Object} node - 选中的node节点
      * @param {Object} setting - 设置
      * @return {void}
      */
-    buildCharacterBySetting: function(node, setting) {
+    setCharacterBySetting: function(node, setting) {
         let contentArray = [];
         // 特征部分
         const itemCharacter = node.data.itemCharacter;
+        // 内容数据
+        const itemJob = node.data.jobContent;
 
-        if (itemCharacter === undefined || itemCharacter.length <= 0) {
+        if (itemCharacter === undefined || itemCharacter.length <= 0 || itemJob === undefined || itemJob.length <= 0) {
             return;
         }
+
         let characterArray = [];
         for (const tmp of itemCharacter) {
             if (tmp.eigenvalue === undefined || tmp.eigenvalue.length <= 0) {
@@ -797,10 +800,6 @@ let pageCCOprObj = {
         }
 
         // 内容部分
-        const itemJob = node.data.jobContent;
-        if (itemJob === undefined || itemJob.length <= 0) {
-            return;
-        }
         let jobArray = [];
         for (const tmp of itemJob) {
             // 匹配设置的序号格式
@@ -827,21 +826,23 @@ let pageCCOprObj = {
                 break;
             case "3":
                 // 项目特征
-                contentArray.push(characterArray);
+                contentArray.push.apply(contentArray, characterArray);
                 break;
             case "4":
                 // 工作内容
-                contentArray.push(jobArray);
+                contentArray.push.apply(contentArray, jobArray);
                 break;
             case "5":
                 // 定额子目
+                const rationChapter = this.getRationChapter(node, setting);
+                contentArray.push.apply(contentArray, rationChapter);
                 break;
         }
         // 显示格式
         switch (setting.displayFormat) {
             case "1":
                 // 换行分隔
-                content = contentArray.join('\r\n');
+                content = contentArray.join("\r\n");
                 break;
             case "2":
                 // 逗号分隔
@@ -853,18 +854,30 @@ let pageCCOprObj = {
                 break;
         }
         // 添加到对应位置
+        let saveObj = {};
         switch (setting.position) {
             case "1":
                 // 添加到项目特征列
-                node.data.itemCharacterText = content;
+                saveObj = {field: 'itemCharacterText', text: content};
+                // 更新到数据库
+                pageCCOprObj.updateCharacterContent(pageCCOprObj.currentFindSet,
+                    {field: 'itemCharacter', updateArr: itemCharacter}, saveObj, characterOprObj);
                 break;
             case "2":
                 // 添加到清单名称列
-                node.data.name = content;
+                const column = this.mainActiveCell.col !== undefined ? this.mainActiveCell.col : -1;
+                let colSetting = projectObj.mainController.setting.cols[column];
+                if (colSetting !== undefined) {
+                    projectObj.project.Bills.updateField(node.source, 'name', content, true);
+                    projectObj.mainController.refreshTreeNode([node]);
+                }
                 break;
             case "3":
                 // 添加到工作内容列
-                node.data.jobContentText = content;
+                saveObj =  {field: 'jobContentText', text: content};
+                // 更新到数据库
+                pageCCOprObj.updateCharacterContent(pageCCOprObj.currentFindSet,
+                    {field: 'jobContent', updateArr: itemJob}, saveObj, contentOprObj);
                 break;
         }
 
@@ -895,4 +908,29 @@ let pageCCOprObj = {
         }
         return serialNo;
     },
+    /**
+     * 查找选中的树节点中定额子目数据
+     *
+     * @param {Object} selectNode - 选中的节点
+     * @param {Object} setting - 设置
+     * @return {Array} - 返回定额子目数组
+     */
+    getRationChapter: function(selectNode, setting) {
+        let result = [];
+        if (selectNode.children === undefined || selectNode.children.length <= 0) {
+            return result;
+        }
+        // 查找对应的定额数据
+        let count = 1;
+        for (const tmp of selectNode.children) {
+            if (tmp.sourceType !== 'ration') {
+                continue;
+            }
+            const serialNo = this.formatSerialNumber(setting.serialType, count.toString());
+            result.push(serialNo + tmp.data.code + ':' + tmp.data.name);
+            count++;
+        }
+
+        return result;
+    },
 }

+ 6 - 1
web/building_saas/main/js/views/project_view.js

@@ -343,6 +343,12 @@ var projectObj = {
         // 检查输入类型等
         let value = projectObj.checkSpreadEditingText(info.editingText, colSetting);
         projectObj.updateCellValue(node, value, colSetting);
+
+        // 自动行高
+        const autoHeight = project.property.displaySetting.autoHeight;
+        if (autoHeight) {
+            this.mainSpread.getActiveSheet().autoFitRow(info.row);
+        }
     },
     mainSpreadRangeChanged: function (sender, info) {
         let project = projectObj.project, setting = projectObj.mainController.setting;
@@ -415,7 +421,6 @@ var projectObj = {
                     if (col.data.field === 'name' || col.data.field === 'itemCharacterText' ||
                         col.data.field === 'jobContentText' || col.data.field === 'adjustState') {
                         if (!autoHeight) {
-                            col.data.autoFitRow();
                             col.showHint = true;
                         } else {
                             col.showHint = false;

+ 26 - 4
web/building_saas/main/js/views/sub_view.js

@@ -135,9 +135,7 @@ $("#use-to-current").click(function() {
         displayFormat,
     };
     let selectedNode = projectObj.mainController.tree.selected;
-    pageCCOprObj.buildCharacterBySetting(selectedNode, setting);
-    // console.log(changeNode);
-    projectObj.mainController.refreshTreeNode([selectedNode], false);
+    pageCCOprObj.setCharacterBySetting(selectedNode, setting);
 });
 // 添加位置选择
 $("#add-position").change(function() {
@@ -150,7 +148,7 @@ $("#add-position").change(function() {
             // 当“添加位置”是“分别添加到对应列”,则“添加内容”恢复默认“无”,且灰显;“显示格式”恢复默认“换行分隔”,且灰显。
             addContentEle.val('');
             addContentEle.attr('disabled', 'disabled');
-            displayFormatEle.val(1);
+            displayFormatEle.val(2);
             displayFormatEle.attr('disabled', 'disabled');
             console.log('hello');
             break;
@@ -160,6 +158,30 @@ $("#add-position").change(function() {
             break;
     }
 });
+// 添加内容选择
+$("#add-content").change(function() {
+    const selected = $(this).children(":selected").val();
+    const characterFormatEle = $("#character-format");
+    const childDisplayFormatEle = $("#child-display-format");
+
+    switch (selected) {
+        case '4':
+            // 当“添加内容”是“定额子目”或“工作内容”,则“特征生成方式”灰显,不需选择;否则有效可选。
+            characterFormatEle.attr('disabled', 'disabled');
+            characterFormatEle.val(2);
+            break;
+        case '5':
+            // 当“添加内容”是“定额子目”或“工作内容”,则“特征生成方式”灰显,不需选择;否则有效可选。
+            characterFormatEle.attr('disabled', 'disabled');
+            characterFormatEle.val(2);
+            // 当“添加内容”是“定额子目”,则“子目生成方式”有效可选;否则灰显,不需选择。
+            childDisplayFormatEle.removeAttr('disabled');
+            break;
+        default:
+            childDisplayFormatEle.attr('disabled', 'disabled');
+            break;
+    }
+});
 
 // 子目生成方式选择事件
 $("#child-display-format").change(function() {