Ver código fonte

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

TonyKang 6 anos atrás
pai
commit
0afa32e141

+ 10 - 0
modules/all_models/compilation.js

@@ -57,6 +57,16 @@ let modelSchema = {
     release_time: {
         type: Number,
         default: 0
+    },
+    //价格属性
+    priceProperties: {
+        type: Array,
+        default: []
+    },
+    //消耗量属性
+    consumeAmtProperties: {
+        type: Array,
+        default: []
     }
 };
 mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));

+ 1 - 1
modules/all_models/stdRation_ration.js

@@ -38,7 +38,7 @@ const rationItemSchema = new Schema({
     materialPrice: Number,
     machinePrice: Number,
     sectionId: Number,
-    rationRepId: Number,
+    rationRepId: {type: Number, index: true},
     caption: String,
     feeType: Number,
     jobContent: String,

+ 2 - 1
modules/ration_repository/controllers/ration_controller.js

@@ -12,10 +12,11 @@ class RationController extends BaseController{
     async getRationItemsByLib(req, res){
         try{
             let data = JSON.parse(req.body.data);
-            let rationItems = await rationItem.getRationItemsByLib(data.rationLibId);
+            let rationItems = await rationItem.getRationItemsByLib(data.rationLibId, data.showHint, data.returnFields);
             callback(req, res, 0, '', rationItems);
         }
         catch(err){
+            console.log(err);
             callback(req, res, 1, err, null);
         }
     }

+ 41 - 2
modules/ration_repository/models/ration_item.js

@@ -9,13 +9,52 @@ let gljDao = require('./glj_repository');
 let rationRepositoryDao = require('./repository_map');
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
 const rationItemModel = mongoose.model('std_ration_lib_ration_items');
+const stdRationLibModel = mongoose.model('std_ration_lib_map');
 const compleRationModel = mongoose.model('complementary_ration_items');
 import STDGLJListModel from '../../std_glj_lib/models/gljModel';
 
 var rationItemDAO = function(){};
 
-rationItemDAO.prototype.getRationItemsByLib = async function (rationRepId) {
-    return await rationItemModel.find({rationRepId: rationRepId, $or: [{isDeleted: null}, {isDeleted: false}]});
+rationItemDAO.prototype.getRationItemsByLib = async function (rationRepId, showHint = null, returnFields = '') {
+    let rationLib = await stdRationLibModel.findOne({ID: rationRepId, deleted: false});
+    if(!rationLib){
+        return [];
+    }
+    let startDate = new Date();
+    let rations = await rationItemModel.find({rationRepId: rationRepId}, returnFields);
+    console.log(`Date: ${new Date() - startDate}====================================`);
+    if(!showHint){
+        return rations;
+    }
+    else {
+        const stdBillsLibListsModel = new STDGLJListModel();
+        const stdGLJData = await stdBillsLibListsModel.getGljItemsByRepId(rationLib.gljLib, '-_id ID code name unit');
+        let gljMapping = {};
+        for(let glj of stdGLJData){
+            gljMapping[glj.ID] = glj;
+        }
+        //设置悬浮
+        for(let ration of rations){
+            let hintsArr = [];
+            for(let rationGlj of ration.rationGljList){
+                let subGlj = gljMapping[rationGlj.gljId];
+                if(subGlj){
+                    hintsArr.push(` ${subGlj.code} ${subGlj.name} ${subGlj.unit} ${rationGlj.consumeAmt}`);
+                }
+            }
+            hintsArr.push(`基价 元 ${ration.basePrice}`);
+            if(ration.jobContent && ration.jobContent.toString().trim() !== ''){
+                hintsArr.push(`工作内容:`);
+                hintsArr = hintsArr.concat(ration.jobContent.split('\n'));
+            }
+            if(ration.annotation && ration.annotation.toString().trim() !== ''){
+                hintsArr.push(`附注:`);
+                hintsArr = hintsArr.concat(ration.annotation.split('\n'));
+            }
+            ration._doc.hint = hintsArr.join('<br>');
+        }
+        return rations;
+    }
 };
 
 rationItemDAO.prototype.sortToNumber = function (datas) {

+ 3 - 3
modules/std_billsGuidance_lib/facade/facades.js

@@ -118,15 +118,15 @@ async function updateBillsGuideLib(data) {
 }
 
 async function getLibWithBills(libID){
-    let guidanceLib = await getBillsGuideLibs({ID: libID, deleted: false});
+    let guidanceLib = await getBillsGuideLibs({ID: libID});
     if(guidanceLib.length === 0){
         throw '不存在此指引库!';
     }
-    let billsLib = await stdBillsLibModel.findOne({billsLibId: guidanceLib[0].billsLibId, deleted: false});
+    let billsLib = await stdBillsLibModel.findOne({billsLibId: guidanceLib[0].billsLibId});
     if(!billsLib){
         throw '引用的清单规则库不存在!';
     }
-    let bills = await stdBillsModel.find({billsLibId: billsLib.billsLibId, deleted: false}, '-_id code name ID NextSiblingID ParentID');
+    let bills = await stdBillsModel.find({billsLibId: billsLib.billsLibId}, '-_id code name ID NextSiblingID ParentID');
     return {guidanceLib: guidanceLib[0], bills};
 }
 

+ 2 - 2
modules/std_glj_lib/models/gljModel.js

@@ -493,8 +493,8 @@ class GljDao  extends OprDao{
         });
     }
 
-    async getGljItemsByRepId(repositoryId){
-         return gljModel.find({"repositoryId": repositoryId});
+    async getGljItemsByRepId(repositoryId, returnFields = ''){
+         return gljModel.find({"repositoryId": repositoryId}, returnFields);
     }
 }
 

+ 2 - 2
modules/users/models/compilation_model.js

@@ -139,7 +139,7 @@ class CompilationModel extends BaseModel {
         condition[sectionString + ".id"] = valuationId;
 
         let updateData = {};
-        updateData[sectionString + ".$.name"] = data.name;
+        updateData[sectionString + ".$.name"] = data.valuationName;
 
         let result = await this.db.update(condition, updateData);
 
@@ -184,7 +184,7 @@ class CompilationModel extends BaseModel {
         }
 
         // 判断名称
-        if (data.name === undefined || data.name === '') {
+        if (data.valuationName === undefined || data.valuationName === '') {
             throw '名称不能为空';
         }
 

+ 1 - 1
public/web/PerfectLoad.js

@@ -21,7 +21,7 @@ jQuery.bootstrapLoading = {
             //提示颜色
             delayTime: 500,
             //页面加载完成后,加载页面渐出速度
-            zindex: 999,
+            zindex: 2000,
             //loading页面层次
             sleep: 0
             //设置挂起,等于0时则无需挂起

+ 65 - 4
public/web/id_tree.js

@@ -607,6 +607,70 @@ var idTree = {
             success = true;
             return success;
         };
+
+        Tree.prototype.m_upLevel = function (nodes) {//原先的父节点变成前一个节点,原先的兄弟节点变成子节点
+            let o_parent = nodes[0].parent;//原来的父节点
+            let o_next = o_parent.nextSibling;//父节点的下一节点
+            let o_pre = nodes[0].preSibling;
+            let o_children = o_parent.children;//旧的所有兄弟节点
+            let children = o_parent.parent?o_parent.parent.children:this.roots;//新的兄弟节点
+            let last;
+            let lastNext;//最后一个选中节点后面的所有兄弟节点变成最后一个节点的子节点
+            for(let i = 0; i<nodes.length;i++){
+                let index = children.indexOf(o_parent) + 1;
+                children.splice(index + i,0,nodes[i]);//往新的父节点的子节点插入节点
+                o_children.splice(nodes[i].siblingIndex(), 1);//旧的数组删除节点
+                if(i == 0){//第一个节点变成原来父节点的下一节点
+                    o_parent.setNextSibling(nodes[i]);
+                    if(o_pre) o_pre.setNextSibling(null); //第一个选中节点的前一节点的下一节点设置为空
+                }
+                nodes[i].setParent(o_parent.parent);
+                last = nodes[i];
+                lastNext = last.nextSibling;
+            }
+            last.setNextSibling(o_next);//最后一个选中的节点的下一个节点设置为原父节点的下一节点
+            if(lastNext){
+                let t_index = o_children.indexOf(lastNext);
+                for(let j = t_index;j <o_children.length;j++ ){//剩下的添加为最后一个选中节点的子节点
+                    last.addChild(o_children[j]);
+                }
+                if(o_children.length > t_index)  o_children.splice(t_index, o_children.length - t_index);//从原先的children中移除
+            }
+            if (o_parent.parent&& !o_parent.parent.expanded)  o_parent.parent.setExpanded(true);
+            tools.sortTreeItems(this);
+            return true;
+        };
+        Tree.prototype.getUpLevelDatas = function (nodes) {
+            //getParentID
+            let o_parentID =  nodes[0].getParentID();
+            let o_children = nodes[0].parent.children;//旧的所有兄弟节点
+            let o_pre = nodes[0].preSibling;
+            let new_parentID = nodes[0].parent.getParentID();
+            let o_nextID = nodes[0].parent.getNextSiblingID();
+            let dataMap = {},updateDatas=[],lastID,lastNext;
+            for(let i = 0; i<nodes.length;i++){
+                if(i == 0){
+                    dataMap[o_parentID] = {"ID":o_parentID,"NextSiblingID":nodes[i].getID()};
+                    if(o_pre) dataMap[o_pre.getID()] = {"ID":o_pre.getID(),"NextSiblingID":-1}; //nodes[i].preSibling.setNextSibling(null);
+                }
+                dataMap[nodes[i].getID()] = {"ID":nodes[i].getID(),"ParentID":new_parentID};
+                lastID = nodes[i].getID();
+                lastNext = nodes[i].nextSibling;
+            }
+            if(dataMap[lastID] !== undefined){
+                dataMap[lastID].NextSiblingID = o_nextID;
+            }
+            if(lastNext){
+                let t_index = o_children.indexOf(lastNext);
+                for(let j = t_index;j <o_children.length;j++ ){//剩下的添加为最后一个选中节点的子节点
+                    dataMap[o_children[j].getID()] = {"ID":o_children[j].getID(),"ParentID":lastID};
+                }
+            }
+            for(let key in dataMap){
+                updateDatas.push({type: 'update', data:dataMap[key]});
+            }
+            return updateDatas;
+        };
         Tree.prototype.m_downLevel = function (nodes) {
             let pre = nodes[0].preSibling ; //第一个节点的前一节点,即会成为新的父节点
             let next ;//最后一个节点的后一节点,会成为pre 的下一个节点
@@ -618,9 +682,7 @@ var idTree = {
                 children.splice(n.siblingIndex(), 1);
                 pre.addChild(n);
             }
-            if (!pre.expanded) {
-                pre.setExpanded(true);
-            }
+            if (!pre.expanded)  pre.setExpanded(true);
             pre.setNextSibling(next);
             last.nextSibling = null;
             tools.sortTreeItems(this);
@@ -645,7 +707,6 @@ var idTree = {
                 updateDatas.push({type: 'update', data:dataMap[key]});
             }
             return updateDatas;
-
         };
 
         Tree.prototype.getDeleteData = function (node) {

+ 14 - 2
public/web/tree_sheet/tree_sheet_controller.js

@@ -157,8 +157,21 @@ var TREE_SHEET_CONTROLLER = {
                 }
             }
         };
+        controller.prototype.m_upLevel = function (nodes) { //多选升级
+            let that = this;
+            if (this.tree.m_upLevel(nodes)) {
+                TREE_SHEET_HELPER.massOperationSheet(that.sheet, function () {
+                    TREE_SHEET_HELPER.refreshNodesVisible([nodes[0]], that.sheet, true);
+                    //that.sheet.showRow(that.tree.selected.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
+                    if (that.event.refreshBaseActn) {
+                        that.event.refreshBaseActn(that.tree);
+                    }
+                });
+            }
+        };
+
         controller.prototype.m_downLevel = function (nodes) { //多选降级
-            var that = this;
+            let that = this;
             if (this.tree.m_downLevel(nodes)) {
                 TREE_SHEET_HELPER.massOperationSheet(that.sheet, function () {
                     TREE_SHEET_HELPER.refreshNodesVisible([nodes[0].parent], that.sheet, true);
@@ -168,7 +181,6 @@ var TREE_SHEET_CONTROLLER = {
                     }
                 });
             }
-
         };
         controller.prototype.upMove = function () {
             var that = this, sels = this.sheet.getSelections();

+ 15 - 5
web/maintain/bill_template_lib/js/bills_template_edit.js

@@ -445,11 +445,21 @@ $(document).ready(function () {
     $('#upLevel').click(function () {
         let me = this;
         $(me).addClass('disabled');
-        var selected = controller.tree.selected, updateData;
-        if (selected) {
-            updateData = selected.getUpLevelData();
-            CommonAjax.post(updateUrl, updateData, function (data) {
-                controller.upLevel();
+        let [dMap,dNodes] = getNodesAndMapFromSheet(controller);
+        let newNodes = [dNodes[0]];
+        if(dNodes.length > 1){//如果是多选,则去掉与第一个节点不同级的节点
+            for(let i = 1;i<dNodes.length;i++){
+                if(dNodes[i].parent == dNodes[0].parent) newNodes.push(dNodes[i])
+            }
+        }
+        let updateDatas =  controller.tree.getUpLevelDatas(newNodes);
+        if(updateDatas.length > 0){
+            CommonAjax.post(updateUrl, updateDatas, function (data) {
+                controller.m_upLevel(newNodes);
+                for(let u of updateDatas){
+                    let node = controller.tree.findNode(u.data.ID);
+                    refreshNodeData(node,u.data);
+                }
                 controller.showTreeData();
                 $(me).removeClass('disabled');
             });

+ 1 - 0
web/maintain/billsGuidance_lib/html/zhiyin.html

@@ -113,6 +113,7 @@
     <script src="/lib/lodash/lodash.js"></script>
     <script src="/public/web/uuid.js"></script>
     <script src="/public/web/sheet/sheet_common.js"></script>
+    <script src="/public/web/sheet/sheet_data_helper.js"></script>
     <script src="/public/web/QueryParam.js"></script>
     <script src="/public/web/common_ajax.js"></script>
     <script src="/web/maintain/billsGuidance_lib/js/global.js"></script>

+ 126 - 4
web/maintain/billsGuidance_lib/js/billsGuidance.js

@@ -326,6 +326,22 @@ const billsGuidance = (function () {
             guideItemInitSel(guideSheet.getActiveRowIndex() ? guideSheet.getActiveRowIndex() : 0);
         }
     }
+    //选中的节点是否全是同层节点
+    //@param {Object}sheet {Array}items @return {Boolean}
+    function itemsSameDepth(sheet, items) {
+        let sels = sheet.getSelections();
+        if(sels.length === 0 || items.length === 0){
+            return false;
+        }
+        let depths = [];
+        for(let i = 0; i < sels[0].rowCount; i++){
+            let row = sels[0].row + i;
+            let node = items[row];
+            if(node){
+                 depths.push(node.depth());
+            }
+        }
+    }
     //节点子项是否全是工作内容
     //@param {Object}node @return {Boolean}
     function allJobChildren(node){
@@ -395,6 +411,7 @@ const billsGuidance = (function () {
     //项目指引表焦点控制
     //@param {Number}row @return {void}
     function guideItemInitSel(row){
+        console.log('et');
         let billsNode = bills.tree.selected;
         let node = null;
         if(billsNode && billsNode.guidance.tree){
@@ -417,6 +434,105 @@ const billsGuidance = (function () {
             buildSheet(module);
         }
     }
+    function tipDivCheck(){
+        setTimeout(function () {
+            let tips = $('#autoTip');
+            if(ration.tipDiv == 'show'){
+                return;
+            } else if(ration.tipDiv == 'hide'&&tips){
+                tips.hide();
+                ration._toolTipElement = null;
+            }
+        },600)
+    }
+    //获取悬浮提示单元格
+    //@param {Object}sheet @return {Object}
+    function getTipCellType(sheet) {
+        let setting = {};
+        let TipCellType = function () {};
+        TipCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
+        TipCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
+            return {
+                x: x,
+                y: y,
+                row: context.row,
+                col: context.col,
+                cellStyle: cellStyle,
+                cellRect: cellRect,
+                sheet: context.sheet,
+                sheetArea: context.sheetArea
+            };
+        };
+        TipCellType.prototype.processMouseEnter = function (hitinfo) {
+            let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
+            let tag = hitinfo.sheet.getTag(hitinfo.row, hitinfo.col);
+            /*     let hintHeight = datas[hitinfo.row] ?
+             datas[hitinfo.row].hintHeight ? datas[hitinfo.row].hintHeight : null
+             : null; //定额库定额悬浮提示位置相关*/
+            if(tag !== undefined && tag){
+                text = tag;
+            }
+            if(sheet && sheet.getParent().qo){
+                setting.pos = SheetDataHelper.getObjPos(sheet.getParent().qo);
+            }
+            if (setting.pos && text && text !== '') {
+                //固定不显示的div,存储文本获取固定div宽度,toolTipElement由于显示和隐藏,获取宽度不正确
+                if(!this._fixedTipElement){
+                    let div = $('#fixedTip')[0];
+                    if (!div) {
+                        div = document.createElement("div");
+                        $(div).css("padding", 5)
+                            .attr("id", 'fixedTip');
+                        $(div).hide();
+                        document.body.insertBefore(div, null);
+                    }
+                    this._fixedTipElement = div;
+                }
+                $(this._fixedTipElement).html(text);
+                if (!this._toolTipElement) {
+                    let div = $('#autoTip')[0];
+                    if (!div) {
+                        div = document.createElement("div");
+                        $(div).css("position", "absolute")
+                            .css("border", "1px #C0C0C0 solid")
+                            .css("box-shadow", "1px 2px 5px rgba(0,0,0,0.4)")
+                            .css("font", "0.9rem Calibri")
+                            .css("background", "white")
+                            .css("padding", 5)
+                            .attr("id", 'autoTip');
+                        $(div).hide();
+                        document.body.insertBefore(div, null);
+                    }
+                    this._toolTipElement = div;
+                    //实时读取位置信息
+                    if(hitinfo.sheet && hitinfo.sheet.getParent().qo){
+                        setting.pos = SheetDataHelper.getObjPos(hitinfo.sheet.getParent().qo);
+                    }
+                    $(this._toolTipElement).html(text);
+                    //定额库定额特殊处理
+                    if($(hitinfo.sheet.getParent().qo).attr('id') === 'rationSpread'){
+                        let divWidth = $(this._fixedTipElement).width(),
+                            divHeight = $(this._fixedTipElement).height();
+                        $(this._toolTipElement).css("top", setting.pos.y  + hitinfo.y - divHeight).css("left", setting.pos.x - divWidth);
+                    }
+                    else{
+                        $(this._toolTipElement).css("top", setting.pos.y + hitinfo.y +15).css("left", setting.pos.x + hitinfo.x + 15);
+                    }
+                    $(this._toolTipElement).show("fast");
+                    ration.tipDiv = 'show';//做个标记
+                }
+            }
+        };
+        TipCellType.prototype.processMouseLeave = function (hininfo) {
+            ration.tipDiv = 'hide';
+            if (this._toolTipElement) {
+                $(this._toolTipElement).hide();
+                this._toolTipElement = null;
+            }
+            tipDivCheck();//延时检查:当tips正在show的时候,就调用了hide方法,会导致tips一直存在,所以设置一个超时处理
+        }
+        return new TipCellType();
+    }
     //输出表数据(定额表)
     //@param {Object}sheet {Array}headers {Array}datas @return {void}
     function showData(sheet, headers, datas){
@@ -424,12 +540,17 @@ const billsGuidance = (function () {
             sheet.setRowCount(datas.length);
             //复选框
             let checkBoxType = new GC.Spread.Sheets.CellTypes.CheckBox();
+            let tipCellType = getTipCellType(sheet);
             sheet.setCellType(-1, 0, checkBoxType);
             for(let col = 0, cLen = headers.length; col < cLen; col++){
                 for(let row = 0, rLen = datas.length; row < rLen; row++){
                     sheet.setValue(row, col, datas[row][headers[col]['dataCode']]);
+                    if(col === 1){
+                        sheet.setTag(row, col, datas[row]['hint']);
+                    }
                 }
             }
+            sheet.setCellType(-1, 1, tipCellType);
         };
         renderSheetFunc(sheet, fuc);
     }
@@ -463,7 +584,7 @@ const billsGuidance = (function () {
         let sectionSheet = section.workBook.getActiveSheet();
         CommonAjax.post('/rationRepository/api/getRationTree', {rationLibId: rationLibId}, function (sectionDatas) {
             //获取所有定额数据
-            CommonAjax.post('/rationRepository/api/getRationItemsByLib', {rationLibId: rationLibId}, function (rstData) {
+            CommonAjax.post('/rationRepository/api/getRationItemsByLib', {rationLibId: rationLibId, showHint: true, returnFields: '-_id code ID sectionId name unit basePrice rationGljList'}, function (rstData) {
                 section.cache = sectionDatas;
                 initTree(section, section.workBook.getActiveSheet(), section.treeSetting, sectionDatas);
                 //初始焦点在第一行(切换库)
@@ -658,7 +779,7 @@ const billsGuidance = (function () {
         //更新父节点
         updateDatas.push({updateType: updateType.update, findData: {ID: selected.getParentID()}, updateData: {NextSiblingID: selected.getID()}});
         //更新选中节点
-        updateDatas.push({udpateType: updateType.update, findData: {ID: selected.getID()},
+        updateDatas.push({updateType: updateType.update, findData: {ID: selected.getID()},
             updateData: {ParentID: selected.parent.getParentID(), NextSiblingID: selected.parent.getNextSiblingID()}});
         if(selected.nextSibling && selected.children.length > 0){
             //更新选中节点最末子节点
@@ -704,7 +825,7 @@ const billsGuidance = (function () {
         updateDatas.push({updateType: updateType.update, findData: {ID: selected.preSibling.getID()}, updateData: {NextSiblingID: selected.getNextSiblingID()}});
         //更新前前节点
         if(selected.preSibling.preSibling){
-            updateDatas.push({udpateType: updateType.update, findData: {ID: selected.preSibling.preSibling.getID()}, updateData: {NextSiblingID: selected.getID()}});
+            updateDatas.push({updateType: updateType.update, findData: {ID: selected.preSibling.preSibling.getID()}, updateData: {NextSiblingID: selected.getID()}});
         }
         //更新选中节点
         updateDatas.push({updateType: updateType.update, findData: {ID: selected.getID()}, updateData: {NextSiblingID: selected.preSibling.getID()}});
@@ -847,8 +968,9 @@ const billsGuidance = (function () {
                 ration.cache = ration.datas;
             }
             else{
+                let reg = new RegExp(searchStr, 'i');
                 ration.cache = _.filter(ration.datas, function (data) {
-                    return data.code.includes(searchStr);
+                    return reg.test(data.code);
                 });
             }
             $('.top-content').hide();

+ 3 - 0
web/maintain/billsGuidance_lib/js/main.js

@@ -106,14 +106,17 @@ const billsGuidanceMain = (function () {
                 }
                 //新建
                 $.bootstrapLoading.start();
+                $('#addY').addClass('disabled');
                 let createData = {type: parseInt(addType.val()), ID: uuid.v1(), name: cName, compilationId: compilationId, compilationName: compilationName, billsLibId: parseInt(billsLibId), billsLibName:billsLibName};
                 let updateData = {updateType: updateType.create, updateData: createData};
                 CommonAjax.post('/billsGuidance/api/updateBillsGuideLib', updateData, function (rstData) {
                     guidanceLibs.push(rstData);
                     addLibToView($('.main').find('tbody'), rstData);
                     $('#add').modal('hide');
+                    $('#addY').removeClass('disabled');
                     $.bootstrapLoading.end();
                 }, function () {
+                    $('#addY').removeClass('disabled');
                     $.bootstrapLoading.end();
                 });
             }

+ 39 - 7
web/maintain/material_replace_lib/js/material_replace_edit.js

@@ -20,7 +20,7 @@ let materialOjb = {
     },
     materialSetting:{
         header: [
-            {headerName: "材料编号", headerWidth: 180, dataCode: "code", dataType: "String"},
+            {headerName: "材料编号", headerWidth: 180, dataCode: "code", dataType: "String",formatter: "@"},
             {headerName: "材料名称", headerWidth: 240, dataCode: "name", dataType: "String",cellType:'tipsCell'},
             {headerName: "规格", headerWidth: 150, dataCode: "specs", hAlign: "left", dataType: "String",cellType:'tipsCell'}
         ],
@@ -41,6 +41,8 @@ let materialOjb = {
         this.billsSheet.name('billsSheet');
         this.billsSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onBillsValueChange);
         this.billsSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onBillsSelectionChange);
+        this.billsSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onBillsRangeChange);
+
         this.initRightClick("billsSpread",this.billsSpread);
 
 
@@ -101,11 +103,39 @@ let materialOjb = {
     },
     refreshSheet:function(){
         sheetCommonObj.showData(this.billsSheet,this.billsSetting,this.billsList);
-        this.billsSheet.setRowCount(this.billsList.length + 1);
+        this.billsSheet.setRowCount(this.billsList.length + 30);
+
+
     },
-    onBillsSelectionChange:function (sander,args) {
+    onBillsSelectionChange:function (sender,args) {
         args.sheet.repaint();
     },
+    onBillsRangeChange:function (sender,args) {
+        let me = materialOjb;
+        let updateDatas = [];
+        if(args.action == GC.Spread.Sheets.RangeChangedAction.paste){
+            for(let c of args.changedCells){
+                let field = me.billsSetting.header[c.col].dataCode;
+                let newValue =  args.sheet.getCell(c.row,c.col).value();
+                if(me.validateBills(field,newValue)){
+                    if(c.row < me.billsList.length){
+                        let data = me.getUpdateData(field,newValue,me.billsList[c.row].code);
+                        if(data) updateDatas.push(data);
+                    }else if(field == 'code'){//如果是在空白行粘贴,并且是编码列,则是新增,其它的忽略;
+                        let data = me.getUpdateData(field,newValue,null);
+                        if(data) updateDatas.push(data);
+                    }
+                }else {
+                    break;
+                }
+            }
+            if(updateDatas.length > 0){
+                me.saveBills(updateDatas);
+                return;
+            }
+        }
+         me.refreshSheet();
+    },
 
     onBillsValueChange: function(sander,args){
         let me = materialOjb;
@@ -126,12 +156,13 @@ let materialOjb = {
 
     validateBills:function (field,value) {
         if(field == 'code'){
+            value = value.toString().replace(/[\s\r\n]/g, "");//去除空格换行等字符;
             if(value.length !== 9){
                 alert("清单长度不正确");
                 return false;
             }
             if(_.find(this.billsList,{'code':value})) {
-                alert("清单已存在");
+                alert("清单:"+value+" 已存在");
                 return false;
             }
         }
@@ -139,10 +170,11 @@ let materialOjb = {
     },
     getUpdateData:function (field,newValue,code) {
         if(field == 'code'){
+            newValue = newValue.toString().replace(/[\s\r\n]/g, "");//去除空格换行等字符;
             if(!isDef(code) || code ==''&&newValue!=null){//说明是新增
                 return {
                     type:'add',
-                    code:newValue.toString(),
+                    code:newValue,
                     libID:$('#libID').val(),
                     billsLibId:parseInt($('#billsLibId').val())
                 }
@@ -150,7 +182,7 @@ let materialOjb = {
                 return {
                     type:'update',
                     oldCode:code.toString(),
-                    newCode:newValue.toString(),
+                    newCode:newValue,
                     libID:$('#libID').val(),
                     billsLibId:parseInt($('#billsLibId').val())
                 }
@@ -192,7 +224,7 @@ let materialOjb = {
     },
     updateCache:function (code,updateData) {
         let bill = _.find(this.billsList,{'code':code});
-        for(let key of updateData){
+        for(let key in updateData){
             bill[key] = updateData[key]
         }
     }

+ 1 - 1
web/users/js/compilation.js

@@ -206,7 +206,7 @@ $(document).ready(function() {
     });
     // 保存计价规则
     $("#save-valuation").click(function() {
-        $("form").submit();
+        $("#saveValuation").submit();
     });
 
     // 移除操作

+ 2 - 2
web/users/views/compilation/add.html

@@ -18,12 +18,12 @@
             </ul>
         </div>
         <div class="c-body">
-            <form action="/compilation/save-valuation" method="post" enctype="application/x-www-form-urlencoded">
+            <form id="saveValuation" action="/compilation/save-valuation" method="post" enctype="application/x-www-form-urlencoded">
                 <div class=" row">
                     <div class="col-md-4">
                         <div class="form-group">
                             <label>名称</label>
-                            <input type="text" class="form-control" name="name" value="<%= valuationData.name %>">
+                            <input type="text" class="form-control" name="valuationName" value="<%= valuationData.name %>">
                         </div>
                     </div>
                     <div class="col-md-12">