Explorar o código

标准工料机加上类似补充工料机的右键菜单功能

zhongzewei %!s(int64=7) %!d(string=hai) anos
pai
achega
7528284608

+ 2 - 2
public/web/sheet/sheet_common.js

@@ -286,8 +286,8 @@ var sheetCommonObj = {
     setDynamicCombo: function (sheet, beginRow, col, rowCount, items, itemsHeight, itemsType) {
     setDynamicCombo: function (sheet, beginRow, col, rowCount, items, itemsHeight, itemsType) {
         let me = this;
         let me = this;
         sheet.suspendPaint();
         sheet.suspendPaint();
+        let combo = me.getDynamicCombo();
         for(let i = 0, len = rowCount; i < len; i++){
         for(let i = 0, len = rowCount; i < len; i++){
-            let combo = me.getDynamicCombo();
             if(itemsHeight) combo.itemHeight(itemsHeight);
             if(itemsHeight) combo.itemHeight(itemsHeight);
             if(itemsType === 'value') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
             if(itemsType === 'value') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
             else if(itemsType === 'text') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
             else if(itemsType === 'text') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
@@ -298,8 +298,8 @@ var sheetCommonObj = {
     },
     },
     setStaticCombo: function (sheet, beginRow, col, rowCount, items, itemsHeight, itemsType) {
     setStaticCombo: function (sheet, beginRow, col, rowCount, items, itemsHeight, itemsType) {
         sheet.suspendPaint();
         sheet.suspendPaint();
+        let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
         for(let i = 0, len = rowCount; i < len; i++){
         for(let i = 0, len = rowCount; i < len; i++){
-            let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
             if(itemsHeight) combo.itemHeight(itemsHeight);
             if(itemsHeight) combo.itemHeight(itemsHeight);
             if(itemsType === 'value') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
             if(itemsType === 'value') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
             else if(itemsType === 'text') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
             else if(itemsType === 'text') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);

+ 91 - 3
web/maintain/std_glj_lib/html/gongliao.html

@@ -10,8 +10,10 @@
     <link rel="stylesheet" href="/web/maintain/std_glj_lib/css/main.css">
     <link rel="stylesheet" href="/web/maintain/std_glj_lib/css/main.css">
     <link rel="stylesheet" href="/lib/font-awesome/font-awesome.min.css">
     <link rel="stylesheet" href="/lib/font-awesome/font-awesome.min.css">
     <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.excel2013lightGray.10.0.1.css" type="text/css">
     <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.excel2013lightGray.10.0.1.css" type="text/css">
+    <link rel="stylesheet" href="/lib/jquery-contextmenu/jquery.contextMenu.css" type="text/css">
     <style type="text/css">
     <style type="text/css">
         .ztree li span.button.add{margin-right:2px;background-position:-144px 0;vertical-align:top;*vertical-align:middle}
         .ztree li span.button.add{margin-right:2px;background-position:-144px 0;vertical-align:top;*vertical-align:middle}
+        .modal-lg{max-width: 1000px}
     </style>
     </style>
     <!--zTree-->
     <!--zTree-->
   	<link rel="stylesheet" href="/lib/ztree/css/zTreeStyle.css" type="text/css">
   	<link rel="stylesheet" href="/lib/ztree/css/zTreeStyle.css" type="text/css">
@@ -150,7 +152,43 @@
             </div>
             </div>
         </div>
         </div>
     </div>
     </div>
-
+    <!--弹出组成物-->
+    <button id="componentBtn" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#component" style="display: none"></button>
+    <div class="modal fade" id="component" data-backdrop="static">
+        <div class="modal-dialog modal-lg" role="document" id="modalCon">
+            <div class="modal-content" >
+                <div class="modal-header">
+                    <h5 class="modal-title">选择组成物</h5>
+                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">&times;</span>
+                    </button>
+                </div>
+                <div class="modal-body">
+                    <div class="row">
+                        <div class="col-4">
+                            <div  class="modal-auto-height" id="componentTreeDiv" style="overflow: hidden">
+                                <!--<div class="print-list">-->
+                                <div style="width: 100%; height: 100%; overflow: auto">
+                                    <ul id="componentTree" class="ztree"></ul>
+                                </div>
+                                <!--</div>-->
+                            </div>
+                        </div>
+                        <div class="col-8">
+                            <div class="row">
+                                <div class="modal-auto-height col-12" style="overflow: hidden" id="componentSheet">
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" id="componentsCacnel" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                    <a href="javascript:void(0);" id="componentsConf" class="btn btn-primary">确定</a>
+                </div>
+            </div>
+        </div>
+    </div>
     <button id="gljAlertBtn" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#gljAlert" style="display: none"></button>
     <button id="gljAlertBtn" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#gljAlert" style="display: none"></button>
     <button id="codeAlertBtn" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#codeAlert" style="display: none"></button>
     <button id="codeAlertBtn" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#codeAlert" style="display: none"></button>
     <div class="modal fade" id="gljAlert" data-backdrop="static" style="display: none;" aria-hidden="true">
     <div class="modal fade" id="gljAlert" data-backdrop="static" style="display: none;" aria-hidden="true">
@@ -195,6 +233,8 @@
 
 
     <!-- JS. -->
     <!-- JS. -->
     <script src="/lib/jquery/jquery.min.js"></script>
     <script src="/lib/jquery/jquery.min.js"></script>
+    <script src="/lib/jquery-contextmenu/jquery.contextMenu.min.js"></script>
+    <script src="/lib/jquery-contextmenu/jquery.ui.position.js"></script>
     <script src="/lib/tether/tether.min.js"></script>
     <script src="/lib/tether/tether.min.js"></script>
     <script src="/lib/bootstrap/bootstrap.min.js"></script>
     <script src="/lib/bootstrap/bootstrap.min.js"></script>
     <script src="/web/maintain/std_glj_lib/js/global.js"></script>
     <script src="/web/maintain/std_glj_lib/js/global.js"></script>
@@ -208,6 +248,7 @@
     <script type="text/javascript" src="/public/web/QueryParam.js"></script>
     <script type="text/javascript" src="/public/web/QueryParam.js"></script>
     <script type="text/javascript" src="/web/maintain/std_glj_lib/js/glj.js"></script>
     <script type="text/javascript" src="/web/maintain/std_glj_lib/js/glj.js"></script>
     <script type="text/javascript" src="/web/maintain/std_glj_lib/js/gljComponent.js"></script>
     <script type="text/javascript" src="/web/maintain/std_glj_lib/js/gljComponent.js"></script>
+    <script type="text/javascript" src="/web/maintain/std_glj_lib/js/components.js"></script>
     <script type="text/javascript" src="/public/web/ztree_common.js"></script>
     <script type="text/javascript" src="/public/web/ztree_common.js"></script>
     <script type="text/javascript" src="/public/web/sheet/sheet_common.js"></script>
     <script type="text/javascript" src="/public/web/sheet/sheet_common.js"></script>
     <script type="text/javascript" src="/web/maintain/std_glj_lib/js/sheetsOpr.js"></script>
     <script type="text/javascript" src="/web/maintain/std_glj_lib/js/sheetsOpr.js"></script>
@@ -253,9 +294,56 @@
                 onClick: gljTypeTreeOprObj.onClick
                 onClick: gljTypeTreeOprObj.onClick
             }
             }
         };
         };
+        //组成物弹出窗口组成物分类树
+        let componentSetting = {
+            view: {
+                //addHoverDom: gljTypeTreeOprObj.addHoverDom,
+                //removeHoverDom: gljTypeTreeOprObj.removeHoverDom,
+                expandSpeed: "",
+                selectedMulti: false
+            },
+            edit: {
+                enable: false,
+                editNameSelectAll: true,
+                showRemoveBtn: true,
+                showRenameBtn: true,
+                removeTitle: "删除节点",
+                renameTitle: "更改名称"
+            },
+            data: {
+                keep: {
+                    parent:true,
+                    leaf:true
+                },
+                key: {
+                    children: "items",
+                    name: "Name"
+                },
+                simpleData: {
+                    enable: false,
+                    idKey: "ID",
+                    pIdKey: "ParentID",
+                    rootPId: -1
+                }
+            },
+            callback:{
+                onClick: componentTypeTreeOprObj.onClick
+            }
+        };
         $(document).ready(function(){
         $(document).ready(function(){
-            pageOprObj.initPage($("#GLJListSheet")[0], $('#gljComponentSheet')[0]);
-            //repositoryGljObj.buildSheet($("#GLJListSheet")[0]);
+            //解决spreadjs sheet初始化没高度宽度
+            $('#modalCon').width($(window).width()*0.5);
+            $('#componentTreeDiv').height($(window).height() - 300);
+            $("#componentSheet").height($("#componentTreeDiv").height()-21.6);
+            $("#componentSheet").width($('#modalCon').width() * 0.63);
+            pageOprObj.initPage($("#GLJListSheet")[0], $('#gljComponentSheet')[0], $('#componentSheet')[0]);
+        });
+        //组成物弹出窗大小设置
+        $(window).resize(function () {
+            $('#modalCon').width($(window).width()*0.5);
+            $('#componentTreeDiv').height($(window).height() - 300);
+            $("#componentSheet").height($("#componentTreeDiv").height()-21.6);
+            $("#componentSheet").width($('#modalCon').width()* 0.63);
         });
         });
   	</SCRIPT>
   	</SCRIPT>
 </body>
 </body>

+ 200 - 0
web/maintain/std_glj_lib/js/components.js

@@ -0,0 +1,200 @@
+/**
+ * Created by Zhong on 2017/10/16.
+ */
+/*
+ 弹出组成物窗口 组成物表
+ * */
+let componentOprObj = {
+    treeObj:null,
+    rootNode: null,//分类树根节点
+    workBook: null,
+    selectedList: [],//选中的组成物
+    setting: {
+        owner: "components",
+        header: [
+            {headerName:"选择", headerWidth: 40, dataCode: "select", hAlign: "center", vAlign: "center"},
+            {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
+            {headerName:"名称",headerWidth:120,dataCode:"name", dataType: "String", hAlign: "left", vAlign: "center"},
+            {headerName:"规格型号",headerWidth:80,dataCode:"specs", dataType: "String", hAlign: "center", vAlign: "center"},
+            {headerName:"单位",headerWidth:80,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
+            {headerName:"单价",headerWidth:80,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
+            {headerName:"类型",headerWidth:80,dataCode:"gljType", dataType: "String",  hAlign: "center", vAlign: "center"}
+        ]
+    },
+    buildSheet: function (container) {
+        let me = componentOprObj;
+        me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
+        me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
+        me.workBook.getSheet(0).setFormatter(-1, 1, "@", GC.Spread.Sheets.SheetArea.viewport);
+        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
+        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
+        me.workBook.bind(GC.Spread.Sheets.Events.ButtonClicked, me.onButtonClicked);//复选框点击事件
+        me.workBook.getSheet(0).getRange(-1, 0, -1, 1).cellType(new GC.Spread.Sheets.CellTypes.CheckBox());
+        me.componentsBtnOpr($('#componentsConf'));
+    },
+    onClipboardPasting: function (sender, args) {
+        args.cancel = true;
+    },
+    onCellEditStart: function (sender, args) {
+        args.cancel = true;
+    },
+    onButtonClicked: function (sender, args) {
+        let me = componentOprObj, re = repositoryGljObj;
+        let val = args.sheet.getValue(args.row, args.col);
+        let thisComponent = me.currentCache[args.row];
+        thisComponent.isChecked = val;
+        if(args.sheet.isEditing()){
+            args.sheet.endEdit(true);
+        }
+        else{
+            //维护选中组成物列表
+            if(val === true){
+                let isExist = false;
+                for(let i = 0, len = me.selectedList.length; i < len; i++){
+                    if(me.selectedList[i].ID === thisComponent.ID){
+                        isExist = true;
+                        break;
+                    }
+                }
+                if(!isExist){
+                    me.selectedList.push(thisComponent);
+                }
+            }
+            else if(val === false){
+                for(let i = 0, len = me.selectedList.length; i < len; i++){
+                    if(me.selectedList[i].ID === thisComponent.ID){
+                        me.selectedList.splice(i, 1);
+                        break;
+                    }
+                }
+            }
+        }
+    },
+    setShowGljList: function (gljList, clearChecked) {
+        //初始为所有工料机,机械类型可添加机械组成物、机上人工,混凝土,砂浆、配合比可添加普通材料
+        let machineArr = [302, 303];
+        let materialArr = [202, 203, 204];//混凝土、砂浆、配合比, 201普通材料
+        let that = repositoryGljObj, me = componentOprObj;
+        for(let i = 0; i < gljList.length; i++){
+            if(that.currentGlj.gljType === 301 && machineArr.indexOf(gljList[i].gljType) !== -1 ||
+                materialArr.indexOf(that.currentGlj.gljType) !== -1 && gljList[i].gljType === 201){
+                let isExist = false;
+                for(let j = 0; j < that.currentComponent.length; j++){
+                    if(that.currentComponent[j].ID === gljList[i].ID){
+                        isExist = true;
+                        break;
+                    }
+                }
+                if(!isExist){
+                    if(clearChecked){
+                        gljList[i].isChecked = false;
+                    }
+                }
+                else {
+                    gljList[i].isChecked = true;
+                }
+                me.showGljList.push(gljList[i]);
+            }
+        }
+    },
+    //初始默认radio
+    initRadio: function () {
+        let that = repositoryGljObj, me = componentOprObj;
+        //初始化组成物列表
+        me.selectedList = [].concat(that.currentComponent);
+        //初始为所有工料机,机械类型可添加机械组成物,混凝土,砂浆、配合比可添加普通材料
+        me.showGljList = [];
+        me.setShowGljList(that.gljList, true);
+        that.sortGlj(me.showGljList);
+
+    },
+    getParentCache: function (nodes) {
+        let me = componentOprObj, rst = [];
+        for(let i = 0; i < me.showGljList.length; i++){
+            if(nodes.indexOf(me.showGljList[i].gljClass) !== -1){
+                rst.push(me.showGljList[i]);
+            }
+        }
+        rst.sort(function (a, b) {
+            let rst = 0;
+            if(a.code > b.code) rst = 1;
+            else if(a.code < b.code)rst = -1;
+            return rst;
+        });
+        return rst;
+    },
+    getCache: function() {
+        let me = componentOprObj, rst = [];
+        for (let i = 0; i < me.showGljList.length; i++) {
+            if (me.showGljList[i].gljClass == me.gljCurTypeId) {
+                rst.push(me.showGljList[i]);
+            }
+        }
+        return rst;
+    },
+    showGljItems: function(data, type) {
+        let me = componentOprObj, re = repositoryGljObj;
+        if (me.workBook) {
+            let cacheSection = [];
+            let pArr = re.parentNodeIds["_pNodeId_" + type];
+            for (let i = 0; i < data.length; i++) {
+                if (pArr && pArr.indexOf(data[i].gljClass) >= 0) {
+                    cacheSection.push(data[i]);
+                } else if (type == data[i].gljClass) {
+                    cacheSection.push(data[i]);
+                }
+            }
+            sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
+            sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, cacheSection, re.distTypeTree);
+            me.workBook.getSheet(0).setRowCount(cacheSection.length);
+            cacheSection = null;
+        }
+    },
+    //组成物窗口按钮操作
+    componentsBtnOpr: function (conf) {//确定、取消、关闭按钮
+        let me = componentOprObj, that = gljComponentOprObj, re = repositoryGljObj;
+        conf.click(function () {
+            //添加选择添加的组成物
+            let updateArr = [];
+            let newComponent = [];
+            for(let i = 0, len = me.selectedList.length; i < len; i++){
+                let isExist = false;
+                for(let j = 0, jLen = re.currentGlj.component.length; j < jLen; j++){
+                    if(me.selectedList[i].ID === re.currentGlj.component[j].ID){
+                        newComponent.push({ID: me.selectedList[i].ID, consumeAmt: re.currentGlj.component[j].consumeAmt});
+                        isExist = true;
+                        break;
+                    }
+                }
+                if(!isExist){
+                    newComponent.push({ID: me.selectedList[i].ID, consumeAmt: 0});
+                }
+            }
+            re.currentGlj.component = newComponent;
+            let gljBasePrc = that.reCalGljBasePrc(re.getCurrentComponent(re.currentGlj.component));
+            if(gljBasePrc !== re.currentGlj.basePrice){
+                re.currentGlj.basePrice = gljBasePrc;
+                re.reshowGljBasePrc(re.currentGlj);
+            }
+            updateArr.push(re.currentGlj);
+            that.updateComponent(updateArr);
+            $('#componentsCacnel').click();
+        });
+    }
+};
+
+let componentTypeTreeOprObj = {
+    onClick: function(event,treeId,treeNode) {
+        let me = componentOprObj, re = repositoryGljObj, that = gljComponentOprObj, gljTypeId = treeNode.ID;
+        if(me.gljCurTypeId !== treeNode.ID){
+            me.gljCurTypeId = treeNode.ID;
+            if (re.parentNodeIds["_pNodeId_" + treeNode.ID]) {
+                me.currentOprParent = 1;
+                me.currentCache = me.getParentCache(re.parentNodeIds["_pNodeId_" + treeNode.ID]);
+            } else {
+                me.currentCache = me.getCache();
+            }
+        }
+        me.showGljItems(me.showGljList, gljTypeId);
+    }
+}

+ 14 - 5
web/maintain/std_glj_lib/js/glj.js

@@ -4,12 +4,13 @@
 let pageOprObj = {
 let pageOprObj = {
     gljLibName : null,
     gljLibName : null,
     gljLibId: null,
     gljLibId: null,
-    initPage : function(container, containerComponent) {
+    initPage : function(container, containerComponent, containerC) {
         let me = this, gljLibId = getQueryString("gljLibId");//获取定额库参数
         let me = this, gljLibId = getQueryString("gljLibId");//获取定额库参数
         me.gljLibId = gljLibId;
         me.gljLibId = gljLibId;
         repositoryGljObj.getGljLib(gljLibId, function () {
         repositoryGljObj.getGljLib(gljLibId, function () {
             repositoryGljObj.buildSheet(container);
             repositoryGljObj.buildSheet(container);
             gljComponentOprObj.buildSheet(containerComponent);
             gljComponentOprObj.buildSheet(containerComponent);
+            componentOprObj.buildSheet(containerC);
             //获得定额库中引用此工料机库中的,所有被定额所套的工料机的ID
             //获得定额库中引用此工料机库中的,所有被定额所套的工料机的ID
             //repositoryGljObj.getRationGljIds(gljLibId);
             //repositoryGljObj.getRationGljIds(gljLibId);
             repositoryGljObj.getGljDistType(function () {
             repositoryGljObj.getGljDistType(function () {
@@ -132,6 +133,7 @@ let repositoryGljObj = {
             success:function(result,textStatus,status){
             success:function(result,textStatus,status){
                 if(status.status == 200) {
                 if(status.status == 200) {
                     zTreeHelper.createTree(result.data, gljSetting, "repositoryTree", me);
                     zTreeHelper.createTree(result.data, gljSetting, "repositoryTree", me);
+                    zTreeHelper.createTree(result.data, componentSetting, "componentTree", componentOprObj);
                     if (result.data && result.data.length > 0) {
                     if (result.data && result.data.length > 0) {
                         me.gljCurTypeId = result.data[0].ID;
                         me.gljCurTypeId = result.data[0].ID;
                     } else {
                     } else {
@@ -163,6 +165,7 @@ let repositoryGljObj = {
                     me.currentGlj = me.gljList.length > 0 ? me.gljList[0] : null;//初始
                     me.currentGlj = me.gljList.length > 0 ? me.gljList[0] : null;//初始
                     let rootNode = me.treeObj.getNodes()[0];
                     let rootNode = me.treeObj.getNodes()[0];
                     if(rootNode && rootNode.isParent && rootNode.isFirstNode){
                     if(rootNode && rootNode.isParent && rootNode.isFirstNode){
+                        componentOprObj.rootNode = rootNode;
                         me.treeObj.selectNode(rootNode);
                         me.treeObj.selectNode(rootNode);
                         gljTypeTreeOprObj.onClick(null, 'repositoryTree', rootNode);
                         gljTypeTreeOprObj.onClick(null, 'repositoryTree', rootNode);
                     }
                     }
@@ -674,11 +677,12 @@ let repositoryGljObj = {
                             }
                             }
                         }
                         }
                     }
                     }
-                    tempObj.gljType = me.distTypeTree.comboDatas[i].value;
-                    tempObj.shortName = me.distTypeTree.distTypes[me.distTypeTree.prefix + tempObj.gljType].data.shortName;
+                    tempObj.component = tempObj.gljType === me.distTypeTree.comboDatas[i].value ? tempObj.component : [];
                     if(me.allowComponent.indexOf(tempObj.gljType) !== -1){
                     if(me.allowComponent.indexOf(tempObj.gljType) !== -1){
-                        tempObj.basePrice = 0;
+                        tempObj.basePrice = tempObj.gljType === me.distTypeTree.comboDatas[i].value ? tempObj.basePrice : 0;
                     }
                     }
+                    tempObj.gljType = me.distTypeTree.comboDatas[i].value;
+                    tempObj.shortName = me.distTypeTree.distTypes[me.distTypeTree.prefix + tempObj.gljType].data.shortName;
                     break;
                     break;
                 }
                 }
             }
             }
@@ -905,7 +909,6 @@ let repositoryGljObj = {
             info.sheet.resumePaint();
             info.sheet.resumePaint();
         }
         }
         if (updateArr.length > 0 || addArr.length > 0) {
         if (updateArr.length > 0 || addArr.length > 0) {
-            console.log(addArr);
             me.mixUpdateRequest(updateArr, addArr, []);
             me.mixUpdateRequest(updateArr, addArr, []);
         }
         }
         if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
         if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
@@ -961,6 +964,12 @@ let repositoryGljObj = {
                         me.currentCache = me.getCache();
                         me.currentCache = me.getCache();
                     }
                     }
                     me.showGljItems(me.gljList, me.gljCurTypeId);
                     me.showGljItems(me.gljList, me.gljCurTypeId);
+                    //getCurrentGlj
+                    let row = me.workBook.getSheet(0).getSelections()[0].row;
+                    me.currentGlj = row < me.currentCache.length ? me.currentCache[row] : null;
+                    me.currentComponent = me.currentGlj ?  me.getCurrentComponent(me.currentGlj.component) : [];
+                    sheetCommonObj.cleanData(gljComponentOprObj.workBook.getSheet(0), gljComponentOprObj.setting, -1);
+                    sheetsOprObj.showData(gljComponentOprObj.workBook.getSheet(0), gljComponentOprObj.setting, me.currentComponent);
                 }
                 }
             },
             },
             error:function(err){
             error:function(err){

+ 78 - 1
web/maintain/std_glj_lib/js/gljComponent.js

@@ -25,6 +25,7 @@ let gljComponentOprObj = {
         sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
         sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
 
 
         me.gljComponentDelOpr();
         me.gljComponentDelOpr();
+        me.onContextmenuOpr();
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
@@ -128,6 +129,81 @@ let gljComponentOprObj = {
         me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
         me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
         me.workBook.commandManager().setShortcutKey('gljComponentDel', GC.Spread.Commands.Key.del, false, false, false, false);
         me.workBook.commandManager().setShortcutKey('gljComponentDel', GC.Spread.Commands.Key.del, false, false, false, false);
     },
     },
+    onContextmenuOpr: function () {
+        let me = gljComponentOprObj, that = repositoryGljObj, co = componentOprObj;
+        $.contextMenu({
+            selector: '#gljComponentSheet',
+            build: function($triggerElement, e){
+                //控制允许右键菜单在哪个位置出现
+                let sheet = me.workBook.getSheet(0);
+                let offset = $("#gljComponentSheet").offset(),
+                    x = e.pageX - offset.left,
+                    y = e.pageY - offset.top;
+                let target = sheet.hitTest(x, y);
+                if(target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){//在表格内
+                    sheet.setActiveCell(target.row, target.col);
+                    //getCurrentGlj
+                    let thatRow = that.workBook.getSheet(0).getSelections()[0].row;
+                    that.currentGlj = thatRow < that.currentCache.length ? that.currentCache[thatRow] : null;
+                    that.currentComponent = that.currentGlj ?  that.getCurrentComponent(that.currentGlj.component) : [];
+                    //控制按钮是否可用
+                    let insertDis = false,
+                        delDis = false;
+                    if(!(that.currentGlj && that.allowComponent.indexOf(that.currentGlj.gljType) !== -1)){
+                        insertDis = true;
+                    }
+                    if(!that.currentGlj || typeof that.currentComponent === 'undefined' || (typeof that.currentComponent !== 'undefined' && target.row >= that.currentComponent.length)){//右键定位在有组成物的行,删除键才显示可用
+                        delDis = true;
+                    }
+                    return {
+                        callback: function(){},
+                        items: {
+                            "insert": {name: "插入", disabled: insertDis, icon: "fa-sign-in", callback: function (key, opt) {
+                                //默认radio所有工料机
+                                co.initRadio();
+                                co.gljCurTypeId = null;
+                                //默认点击树根节点
+                                if(co.rootNode){
+                                    co.treeObj.selectNode(co.rootNode);
+                                    componentTypeTreeOprObj.onClick(null, 'componentTree', co.rootNode);
+                                }
+                                //弹出窗口
+                                $('#componentBtn').click();
+                            }},
+                            "delete": {name: "删除", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {
+                                //删除
+                                let deleteObj = that.currentComponent[target.row];
+                                let gljComponent = that.currentGlj.component;
+                                let updateArr = [], updateBasePrcArr = [];
+                                //更新当前工料机的组成物列表
+                                for(let i = 0, len = gljComponent.length; i < len; i++){
+                                    if(gljComponent[i].ID === deleteObj.ID){
+                                        gljComponent.splice(i, 1);
+                                        break;
+                                    }
+                                }
+                                //重新计算工料机
+                                let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(gljComponent));
+                                if(gljBasePrc !== that.currentGlj.basePrice){
+                                    that.currentGlj.basePrice = gljBasePrc;
+                                    that.reshowGljBasePrc(that.currentGlj);
+                                    updateBasePrcArr.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
+                                }
+                                updateArr.push(that.currentGlj);
+                                me.updateComponent(updateArr);
+                                if(updateBasePrcArr.length > 0 && that.rationLibs.length > 0){
+                                    that.updateRationBasePrcRq(updateBasePrcArr);
+                                }
+                            }}
+                        }
+                    };
+                }
+                else{
+                    return false;
+                }
+            }
+        });
+    },
     onCellEditStart: function(sender, args) {
     onCellEditStart: function(sender, args) {
         let me = gljComponentOprObj, that = repositoryGljObj;
         let me = gljComponentOprObj, that = repositoryGljObj;
         let rObj = me.getRowData(args.sheet, args.row, me.setting);
         let rObj = me.getRowData(args.sheet, args.row, me.setting);
@@ -274,7 +350,7 @@ let gljComponentOprObj = {
         let me = gljComponentOprObj;
         let me = gljComponentOprObj;
         let maxCol = info.cellRange.col + info.cellRange.colCount - 1;
         let maxCol = info.cellRange.col + info.cellRange.colCount - 1;
         //复制的列数超过正确的列数,不可复制
         //复制的列数超过正确的列数,不可复制
-        if(info.cellRange.col !== 0 || info.cellRange.col !== 4 || info.cellRange.colCount > 1){
+        if(info.cellRange.col !== 0 && info.cellRange.col !== 4 || info.cellRange.colCount > 1){
             args.cancel = true;
             args.cancel = true;
         }
         }
     },
     },
@@ -282,6 +358,7 @@ let gljComponentOprObj = {
         let me = gljComponentOprObj, that = repositoryGljObj, updateArr = [] ,materialComponent = [202, 203, 204], machineComponent = [302, 303],
         let me = gljComponentOprObj, that = repositoryGljObj, updateArr = [] ,materialComponent = [202, 203, 204], machineComponent = [302, 303],
             component = that.currentGlj.component, newComponent = [], concatComponent = [], isChange = false, updateBasePrc = [];
             component = that.currentGlj.component, newComponent = [], concatComponent = [], isChange = false, updateBasePrc = [];
         let items = sheetCommonObj.analyzePasteData(me.setting, info);
         let items = sheetCommonObj.analyzePasteData(me.setting, info);
+        console.log(items);
         let gljCache = that.gljList;
         let gljCache = that.gljList;
         if(info.cellRange.col === 0){
         if(info.cellRange.col === 0){
             for(let i = 0; i < items.length; i++){
             for(let i = 0; i < items.length; i++){

+ 5 - 0
web/maintain/std_glj_lib/js/sheetsOpr.js

@@ -50,6 +50,11 @@ let sheetsOprObj = {
                     let distTypeVal =  distTypeTree.distTypes[distTypeTree.prefix + data[row].gljType].data.fullName;
                     let distTypeVal =  distTypeTree.distTypes[distTypeTree.prefix + data[row].gljType].data.fullName;
                     sheet.setValue(row, col, distTypeVal, ch);
                     sheet.setValue(row, col, distTypeVal, ch);
                 }
                 }
+                else if(setting.header[col].dataCode === 'select'){
+                    if(data[row].isChecked === true){
+                        sheet.getCell(row, col).value(1);
+                    }
+                }
                 else {
                 else {
                     sheet.setValue(row, col, data[row][setting.header[col].dataCode], ch);
                     sheet.setValue(row, col, data[row][setting.header[col].dataCode], ch);
                     sheet.setTag(row, 0, data[row].ID, ch);
                     sheet.setTag(row, 0, data[row].ID, ch);