Browse Source

Merge branch '1.0.0_online' of http://smartcost.f3322.net:3000/SmartCost/ConstructionOperation into 1.0.0_online

TonyKang 6 years atrás
parent
commit
7444e461bc

+ 37 - 0
modules/all_models/compleRation_coe.js

@@ -0,0 +1,37 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Zhong
+ * @date 2018/10/23
+ * @version
+ */
+
+/*
+* 补充定额库用户新增子目换算
+* 用户ID与费用定额ID绑定子目换算
+* */
+
+import mongoose from 'mongoose';
+const Schema = mongoose.Schema;
+const coeSchema = new Schema({
+    coeType: String,                // 系数类型
+    gljCode: String,                //要调整的人材机编码
+    gljName: String,
+    operator: String,               // 运算符(*、+、-、=)
+    amount: String,                 // 调整的量
+    _id: false
+});
+
+const coeListSchema = new Schema({
+    userId: String,
+    compilationId: String,
+    ID: String,                         // uuid
+    serialNo: Number,                  //编号
+    name: String,                       // 名称
+    content: String,                    // 说明
+    coes: [coeSchema]
+}, {versionKey: false});
+
+mongoose.model('complementary_ration_coe_list', coeListSchema, 'complementary_ration_coe_list');

+ 29 - 0
modules/all_models/compleRation_installFeeItem.js

@@ -0,0 +1,29 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Zhong
+ * @date 2018/10/23
+ * @version
+ */
+
+/*
+* 补充定额库用户新增安装增加费费用项
+*
+* */
+const mongoose = require('mongoose');
+const Schema = mongoose.Schema;
+//补充安装增加费-费用项
+const installFeeItemSchema = new Schema({
+    userId: String,
+    compilationId: String,
+    ID: String,
+    feeItem: String, //费用项
+    feeType: String, //费用类型
+    position: String, //记取位置
+    section: [],
+    deleted: false
+}, {versionKey: false});
+
+mongoose.model('complementary_ration_installation', installFeeItemSchema, 'complementary_ration_installation');

+ 42 - 0
modules/all_models/compleRation_installSection.js

@@ -0,0 +1,42 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Zhong
+ * @date 2018/10/23
+ * @version
+ */
+
+/*
+* 补充定额库用户新增安装增加费分册章节
+*
+*
+* */
+
+const mongoose = require('mongoose');
+const Schema = mongoose.Schema;
+//安装增加费-费用规则
+const feeRuleSchema = new Schema({
+    ID: String,
+    code: String,
+    rule: String,
+    base: String,
+    feeRate: Number,
+    labour: Number,
+    material: Number,
+    machine: Number
+});
+
+//补充安装增加费-分册章节
+const installSectionSchema = new Schema({
+    userId: String,
+    compilationId: String,
+    ID: String,
+    feeItemId: String,
+    name: String,
+    feeRule: [feeRuleSchema],
+    deleted: false
+}, {versionKey: false});
+
+mongoose.model('complementary_ration_installationSection', installSectionSchema, 'complementary_ration_installationSection');

+ 34 - 0
modules/all_models/comple_section_template.js

@@ -0,0 +1,34 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Zhong
+ * @date 2018/10/23
+ * @version
+ */
+
+/*
+* 我的补充定额库章节树模板,一个费用定额有一个模板
+* 模板的生成目前由手工生成(借助定额库编辑器的章节树编辑)
+* 新用户第一次进入某费用定额的补充定额库时,拷贝模板给该用户
+*
+* */
+
+import mongoose from 'mongoose';
+
+const Schema = mongoose.Schema;
+const compleRationSectionTemp = new Schema({
+    compilationId: String,
+    name: String,
+    ID: Number,
+    ParentID: Number,
+    NextSiblingID: Number,
+    //以下预留结构,以防后续需要默认数据
+    explanation: String,//说明
+    ruleText: String,//计算规则,
+    jobContentSituation: String,//工作内容适用情况,ALL适用本项全部定额,PARTIAL适用本项部分定额
+    annotationSituation: String,//附注适用情况,ALL适用本项全部定额,PARTIAL适用本项部分定额
+});
+
+mongoose.model('complementary_ration_section_templates', compleRationSectionTemp, 'complementary_ration_section_templates');

+ 6 - 4
web/maintain/ration_repository/dinge.html

@@ -315,7 +315,8 @@
                         </button>
                     </div>
                     <div class="modal-body">
-                        <form>
+                        <div id="editJobCodeSpread" style="height: 300px"></div>
+                        <!--<form>
                             <div class="form-group">
                                 <label>编码</label>
                                 <div class="form-control">
@@ -323,7 +324,7 @@
                                     </div>
                                 </div>
                             </div>
-                        </form>
+                        </form>-->
                     </div>
                     <div class="modal-footer">
                         <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
@@ -370,7 +371,8 @@
                         </button>
                     </div>
                     <div class="modal-body">
-                        <form>
+                        <div id="editAnnoCodeSpread" style="height: 300px;"></div>
+                        <!--<form>
                             <div class="form-group">
                                 <label>编码</label>
                                 <div class="form-control">
@@ -378,7 +380,7 @@
                                     </div>
                                 </div>
                             </div>
-                        </form>
+                        </form>-->
                     </div>
                     <div class="modal-footer">
                         <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>

+ 107 - 6
web/maintain/ration_repository/js/annotation.js

@@ -3,6 +3,8 @@
  */
 //附注
 let annotationOprObj = {
+    workBook: null,
+    container: $('#editAnnoCodeSpread'),
     situations: {ALL: 'ALL', PARTIAL: 'PARTIAL', NONE: 'NONE'},
     currentSituation: null,//本项适用情况
     radios: $("input[name = 'fzRadios']"),
@@ -12,6 +14,60 @@ let annotationOprObj = {
     currentAnnotation: null,
     addCon: $('#fzAddCon'),//勾选编码模态框
     updateCon: $('#fzUpdateCon'),//编辑编码模态框
+    setting: {
+        header:[
+            {headerName:"编码",headerWidth:240,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
+            {headerName:"选择",headerWidth:40,dataCode:"select", hAlign: "center", vAlign: "center"},
+        ],
+    },
+    buildSheet: function () {
+        let me = this;
+        me.workBook = sheetCommonObj.buildSheet(me.container[0], me.setting, 30);
+        me.workBook.refresh();
+        me.workBook.bind(GC.Spread.Sheets.Events.ButtonClicked, me.onButtonClick);
+        let sheet = me.workBook.getSheet(0);
+        sheet.options.isProtected = true;
+        sheet.getRange(-1, 0, -1, 1).locked(true);
+        sheet.getRange(-1, 1, -1, 1).locked(false);
+    },
+    renderSheet: function (func) {
+        let me = this;
+        let sheet = me.workBook.getSheet(0);
+        sheet.suspendPaint();
+        sheet.suspendEvent();
+        if (func) {
+            func();
+        }
+        sheet.resumePaint();
+        sheet.resumeEvent();
+    },
+    onButtonClick: function (sender, args) {
+        if (args.sheet.isEditing()) {
+            args.sheet.endEdit();
+        }
+    },
+    showData: function (datas) {
+        let me = this,
+            sheet = me.workBook.getSheet(0),
+            headers = me.setting.header;
+        let fuc = function () {
+            sheet.setRowCount(datas.length);
+            //复选框
+            let checkBoxType = new GC.Spread.Sheets.CellTypes.CheckBox();
+            sheet.setCellType(-1, 1, checkBoxType);
+            for(let col = 0, cLen = headers.length; col < cLen; col++){
+                if(headers[col].formatter){
+                    sheet.setFormatter(-1, col, headers[col].formatter);
+                }
+                sheet.getRange(-1, col, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign[headers[col]['hAlign']]);
+                sheet.getRange(-1, col, -1, 1).vAlign(GC.Spread.Sheets.VerticalAlign[headers[col]['vAlign']]);
+                for(let row = 0, rLen = datas.length; row < rLen; row++){
+                    sheet.setValue(row, col, datas[row][headers[col]['dataCode']]);
+                }
+            }
+        };
+        me.renderSheet(fuc);
+    },
     clickUpdate: function (txtarea) {//解决编辑完后在未失去焦点的时候直接定额章节树
         let me = annotationOprObj;
         if(txtarea.is(':focus')){
@@ -120,9 +176,17 @@ let annotationOprObj = {
         let txtarea = $(obj.parent().parent().children().children()[1]);
         let annotation = txtarea.val();
         if(annotation.trim().length > 0){
-            let codesObj = me.getAddCodes(jobContentOprObj.currentRationItems);
-            me.buildCheckCodesCon(me.addCon, codesObj.checkedCodes, codesObj.disabledCodes)
-            obj.attr('data-target', '#fzEditBianma');
+            /*let codesObj = me.getAddCodes(jobContentOprObj.currentRationItems);
+            me.buildCheckCodesCon(me.addCon, codesObj.checkedCodes, codesObj.disabledCodes)*/
+            obj.attr('data-target', '#fzEditBianmaQ');
+            if (!me.workBook) {
+                setTimeout(function () {
+                    me.buildSheet();
+                    me.showData(me.getShowDatas(jobContentOprObj.currentRationItems, []));
+                }, 200);
+            } else {
+                me.showData(me.getShowDatas(jobContentOprObj.currentRationItems, []));
+            }
         }
         else{
             obj.attr('data-target', '');
@@ -131,7 +195,30 @@ let annotationOprObj = {
     },
     onclickFuncEdit: function (obj) {
         let me = annotationOprObj;
-        me.buildEditableCodesCon(jobContentOprObj.currentRationItems, me.updateCon, me.getUpdateCodes(obj));
+        //me.buildEditableCodesCon(jobContentOprObj.currentRationItems, me.updateCon, me.getUpdateCodes(obj));
+        if (!me.workBook) {
+            setTimeout(function () {
+                me.buildSheet();
+                me.showData(me.getShowDatas(jobContentOprObj.currentRationItems, me.getUpdateCodes(obj)));
+            }, 200);
+        } else {
+            me.showData(me.getShowDatas(jobContentOprObj.currentRationItems, me.getUpdateCodes(obj)));
+        }
+    },
+    //获取弹出选择编码的数据
+    getShowDatas: function (rationItems, codes) {
+        let rst = [];
+        for(let i = 0, len = codes.length; i < len; i++){
+            rst.push({code: codes[i], select: true});
+        }
+        for(let i = 0, len = rationItems.length; i < len; i++){
+            if(!codes.includes(rationItems[i].code)){
+                if (typeof rationItems[i].annotation === 'undefined' || rationItems[i].annotation.toString().trim().length <= 0) {
+                    rst.push({code: rationItems[i].code, select: false});
+                }
+            }
+        }
+        return rst;
     },
     //获取编码td中的编码
     getUpdateCodes: function (jq) {
@@ -207,7 +294,21 @@ let annotationOprObj = {
         return rst;
     },
     //获取选择后的编码窗口的编码及状态
-    getCodesAfterS: function (checkNodes) {
+    getCodesAfterS: function () {
+        let rst = {checked: [], unchecked: []};
+        let sheet = this.workBook.getSheet(0);
+        for(let i = 0; i < sheet.getRowCount(); i++){
+            let code = sheet.getValue(i, 0),
+                checked = sheet.getValue(i, 1);
+            if (checked) {
+                rst.checked.push(code);
+            } else {
+                rst.unchecked.push(code);
+            }
+        }
+        return rst;
+    },
+   /* getCodesAfterS: function (checkNodes) {
         let rst = {checked: [], unchecked: []};
         for(let i = 0, len = checkNodes.length; i < len; i++){
             if(checkNodes[i].checked){
@@ -218,7 +319,7 @@ let annotationOprObj = {
             }
         }
         return rst;
-    },
+    },*/
     setRadiosChecked: function (situation, radios) {
         let me = annotationOprObj;
         if(situation === me.situations.ALL){

+ 107 - 6
web/maintain/ration_repository/js/jobContent.js

@@ -3,6 +3,8 @@
  */
 //工作内容
 let jobContentOprObj = {
+    workBook: null,
+    container: $('#editJobCodeSpread'),
     situations: {ALL: 'ALL', PARTIAL: 'PARTIAL', NONE: 'NONE'},//所有ALL(包括未定义本项工作内容)、部分PARTIA,不可用NONE(无定额时)
     currentSituation: null,//本项适用情况
     currentTreeNode: null,
@@ -20,6 +22,60 @@ let jobContentOprObj = {
         me.preTreeNode = preNode;
         me.currentTreeNode = currentNode;
     },
+    setting: {
+        header:[
+            {headerName:"编码",headerWidth:240,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
+            {headerName:"选择",headerWidth:40,dataCode:"select", hAlign: "center", vAlign: "center"},
+        ],
+    },
+    buildSheet: function () {
+        let me = this;
+        me.workBook = sheetCommonObj.buildSheet(me.container[0], me.setting, 30);
+        me.workBook.refresh();
+        me.workBook.bind(GC.Spread.Sheets.Events.ButtonClicked, me.onButtonClick);
+        let sheet = me.workBook.getSheet(0);
+        sheet.options.isProtected = true;
+        sheet.getRange(-1, 0, -1, 1).locked(true);
+        sheet.getRange(-1, 1, -1, 1).locked(false);
+    },
+    renderSheet: function (func) {
+        let me = this;
+        let sheet = me.workBook.getSheet(0);
+        sheet.suspendPaint();
+        sheet.suspendEvent();
+        if (func) {
+            func();
+        }
+        sheet.resumePaint();
+        sheet.resumeEvent();
+    },
+    onButtonClick: function (sender, args) {
+        if (args.sheet.isEditing()) {
+            args.sheet.endEdit();
+        }
+    },
+    showData: function (datas) {
+        let me = this,
+            sheet = me.workBook.getSheet(0),
+            headers = me.setting.header;
+        let fuc = function () {
+            sheet.setRowCount(datas.length);
+            //复选框
+            let checkBoxType = new GC.Spread.Sheets.CellTypes.CheckBox();
+            sheet.setCellType(-1, 1, checkBoxType);
+            for(let col = 0, cLen = headers.length; col < cLen; col++){
+                if(headers[col].formatter){
+                    sheet.setFormatter(-1, col, headers[col].formatter);
+                }
+                sheet.getRange(-1, col, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign[headers[col]['hAlign']]);
+                sheet.getRange(-1, col, -1, 1).vAlign(GC.Spread.Sheets.VerticalAlign[headers[col]['vAlign']]);
+                for(let row = 0, rLen = datas.length; row < rLen; row++){
+                    sheet.setValue(row, col, datas[row][headers[col]['dataCode']]);
+                }
+            }
+        };
+        me.renderSheet(fuc);
+    },
     clickUpdate: function (txtarea) {//解决编辑完后在未失去焦点的时候直接定额章节树
         let me = jobContentOprObj;
         if(txtarea.is(':focus')){
@@ -129,9 +185,17 @@ let jobContentOprObj = {
         let txtarea = $(obj.parent().parent().children().children()[1]);
         let jobContent = txtarea.val();
         if(jobContent.trim().length > 0){//工作内容不为空才可添加编码
-            let codesObj = me.getAddCodes(me.currentRationItems);
-            me.buildCheckCodesCon(me.addCon, codesObj.checkedCodes, codesObj.disabledCodes)
-            obj.attr('data-target', '#editBianma');
+           /* let codesObj = me.getAddCodes(me.currentRationItems);
+            me.buildCheckCodesCon(me.addCon, codesObj.checkedCodes, codesObj.disabledCodes)*/
+            obj.attr('data-target', '#editBianmaQ');
+            if (!me.workBook) {
+                setTimeout(function () {
+                    me.buildSheet();
+                    me.showData(me.getShowDatas(me.currentRationItems, []));
+                }, 200);
+            } else {
+                me.showData(me.getShowDatas(me.currentRationItems, []));
+            }
         }
         else{
             obj.attr('data-target', '');
@@ -140,7 +204,30 @@ let jobContentOprObj = {
     },
     onclickFuncEdit: function (obj) {
         let me = jobContentOprObj;
-        me.buildEditableCodesCon(me.currentRationItems, me.updateCon, me.getUpdateCodes(obj));
+        //me.buildEditableCodesCon(me.currentRationItems, me.updateCon, me.getUpdateCodes(obj));
+        if (!me.workBook) {
+            setTimeout(function () {
+                me.buildSheet();
+                me.showData(me.getShowDatas(me.currentRationItems, me.getUpdateCodes(obj)));
+            }, 200);
+        } else {
+            me.showData(me.getShowDatas(me.currentRationItems, me.getUpdateCodes(obj)));
+        }
+    },
+    //获取弹出选择编码的数据
+    getShowDatas: function (rationItems, codes) {
+        let rst = [];
+        for(let i = 0, len = codes.length; i < len; i++){
+            rst.push({code: codes[i], select: true});
+        }
+        for(let i = 0, len = rationItems.length; i < len; i++){
+            if(!codes.includes(rationItems[i].code)){
+                if (typeof rationItems[i].jobContent === 'undefined' || rationItems[i].jobContent.toString().trim().length <= 0) {
+                    rst.push({code: rationItems[i].code, select: false});
+                }
+            }
+        }
+        return rst;
     },
     //获取编码td中的编码
     getUpdateCodes: function (jq) {
@@ -216,7 +303,7 @@ let jobContentOprObj = {
         return rst;
     },
     //获取选择后的编码窗口的编码及状态
-    getCodesAfterS: function (checkNodes) {
+    /*getCodesAfterS: function (checkNodes) {
         let rst = {checked: [], unchecked: []};
         for(let i = 0, len = checkNodes.length; i < len; i++){
             if(checkNodes[i].checked){
@@ -227,6 +314,20 @@ let jobContentOprObj = {
             }
         }
         return rst;
+    },*/
+    getCodesAfterS: function () {
+        let rst = {checked: [], unchecked: []};
+        let sheet = this.workBook.getSheet(0);
+        for(let i = 0; i < sheet.getRowCount(); i++){
+            let code = sheet.getValue(i, 0),
+                checked = sheet.getValue(i, 1);
+            if (checked) {
+                rst.checked.push(code);
+            } else {
+                rst.unchecked.push(code);
+            }
+        }
+        return rst;
     },
     setRadiosChecked: function (situation, radios) {
         let me = jobContentOprObj;
@@ -361,7 +462,7 @@ let jobContentOprObj = {
     bindUpdateConBtn: function () {
         let me = jobContentOprObj;
         return function () {
-            let codesObj = me.getCodesAfterS(me.updateCon.children().children().children());
+            let codesObj = me.getCodesAfterS();
             let updateC = me.getUpdateArr(codesObj.checked, me.currentJobContent),
                 updateUnC = me.getUpdateArr(codesObj.unchecked, ''),
                 updateArr = updateC.concat(updateUnC);

+ 29 - 4
web/maintain/ration_repository/js/ration.js

@@ -587,12 +587,13 @@ let rationOprObj = {
                     me.getRationItems(me.currentSectionId);
                 } else {
                     let cacheSection = me.updateCache(addArr, updateArr, removeIds, result);
-                    cacheSection.sort(function(a, b){
+                    me.sortByCode(cacheSection);
+                    /*cacheSection.sort(function(a, b){
                         let rst = 0;
                         if (a.code > b.code) rst = 1
                         else if (a.code < b.code) rst = -1;
                         return rst;
-                    });
+                    });*/
                     //add
                     let curRow = me.workBook.getActiveSheet().getActiveRowIndex();
                     me.rationSelInit(curRow);
@@ -730,7 +731,31 @@ let rationOprObj = {
         sectionTreeObj.workBook.focus(true);
     },
     sortByCode: function(arr){
-        function compare(){
+        arr.sort(function (a, b) {
+            let rst = 0;
+            let splitA = a.code.split('-'),
+                splitB = b.code.split('-');
+            if(splitA[0] > splitB[0]){
+                rst = 1;
+            }
+            else if(splitA[0] < splitB[0]){
+                rst = -1;
+            }
+            else {
+                if(splitA[1] && splitB[1]){
+                    let floatA = parseFloat(splitA[1]),
+                        floatB = parseFloat(splitB[1]);
+                    if(floatA > floatB){
+                        rst = 1;
+                    }
+                    else if(floatA < floatB){
+                        rst = -1;
+                    }
+                }
+            }
+            return rst;
+        });
+        /*function compare(){
             return function (a, b) {
                 let rst = 0;
                 if (a.code > b.code) {
@@ -742,7 +767,7 @@ let rationOprObj = {
                 return rst;
             }
         }
-        arr.sort(compare());
+        arr.sort(compare());*/
     },
     saveInString(datas){
         for(let i = 0, len = datas.length; i < len; i++){

+ 1 - 1
web/maintain/ration_repository/js/ration_glj.js

@@ -351,7 +351,7 @@ var rationGLJOprObj = {
                 }
                 //rationCoe表
                 else if(me.sheet.getParent().getActiveSheetIndex() === 2 && target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){
-                    let currentCache = raCoe.isDef(raCoe.cache["_Coe_" + raCoe.curRation.ID])  ? raCoe.cache["_Coe_" + raCoe.curRation.ID] : [];
+                    let currentCache = raCoe.curRation && raCoe.isDef(raCoe.cache["_Coe_" + raCoe.curRation.ID])  ? raCoe.cache["_Coe_" + raCoe.curRation.ID] : [];
                     sheet.setActiveCell(target.row, target.col);
                     //控制按钮是否可用
                     let upDis = false,

+ 2 - 1
web/maintain/ration_repository/js/section_tree.js

@@ -340,7 +340,7 @@ let sectionTreeObj = {
             me.upMove(me.tree.selected);
         });
     },
-    
+
     insert: function () {
         let me = sectionTreeObj;
         me.insertBtn.addClass('disabled');
@@ -614,6 +614,7 @@ let sectionTreeObj = {
     },
     //模仿默认点击
     initSelection: function (node) {
+        node.tree.selected = node ? node : null;
         let me = this;
         if(!me.isDef(node)){
             sheetCommonObj.cleanSheet(rationOprObj.workBook.getActiveSheet(), rationOprObj.setting, -1);