فهرست منبع

清单指引编辑器插入行插入子项

zhongzewei 6 سال پیش
والد
کامیت
debd77de4b

+ 6 - 0
web/maintain/billsGuidance_lib/css/main.css

@@ -300,3 +300,9 @@ body {
     background:#fff;
     border-bottom:1px solid #ddd
 }
+div.resize{
+    height: 6px;
+    background: #f7f7f9;
+    width: 100%;
+    cursor: s-resize;
+}

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

@@ -51,7 +51,7 @@
                           <textarea class="form-control"></textarea>
                       </div>
                   </div>
-                    <div class="main-side col-lg-4 p-" style="margin: 0; padding: 0;">
+                    <div class="main-side col-lg-4 p-" style="margin: 0; padding: 0;" id="de">
                         <div class="sidebar-tools-bar container-fluid tools-bar-height-q">
                             <div class="p-1 row">
                                 <div class="col-5 p-0">
@@ -79,6 +79,7 @@
                             <div class="main-data-top" id="sectionSpread">
                             </div>
                         </div>
+                        <div class="resize" id="deResize"></div>
                         <div class="bottom-content">
                             <div class="main-data-bottom" id="rationSpread"></div>
                         </div>

+ 240 - 7
web/maintain/billsGuidance_lib/js/billsGuidance.js

@@ -193,7 +193,7 @@ const billsGuidance = (function () {
                 if(ration.headers[args.col].dataCode === 'name'){
                     let insertDatas = getInsertRations([args.row]);
                     if(insertDatas.length > 0){
-                        insert(insertDatas);
+                        insert(insertDatas, false);
                     }
                 }
             }
@@ -748,8 +748,8 @@ const billsGuidance = (function () {
         }
     }
     //项目指引插入,支持一次插入多条数据
-    //@param {Array}datas {Function}callback @return {void}
-    function insert(datas, callback = null){
+    //@param {Array}datas {Boolean}tobeChild(插入成为子项) {Function}callback @return {void}
+    function insert(datas, tobeChild, callback = null){
         $.bootstrapLoading.start();
         let sheet = guideItem.workBook.getActiveSheet();
         let controller = bills.tree.selected.guidance.controller;
@@ -763,7 +763,7 @@ const billsGuidance = (function () {
                 billsID: bills.tree.selected.getID()
             };
             //定额类型插入当前工作内容焦点行,
-            if(selected && selected.data.type === itemType.job && datas[i].type === itemType.ration){
+            if(selected && ((selected.data.type === itemType.job && datas[i].type === itemType.ration) || tobeChild)){
                 newNodeData.ParentID = selected.getID();
                 newNodeData.NextSiblingID = -1;
             }
@@ -774,7 +774,7 @@ const billsGuidance = (function () {
             //第一个节点
             if(i === 0){
                 //非插入成子节点,更新选中节点NestSiblingID
-                if(selected && !(selected.data.type === itemType.job && datas[i].type === itemType.ration)){
+                if(selected && !((selected.data.type === itemType.job && datas[i].type === itemType.ration) || tobeChild)){
                     updateDatas.push({updateType: updateType.update, findData: {ID: selected.getID()}, updateData: {NextSiblingID: newDataIndex[i].ID}});
                 }
             }
@@ -1188,6 +1188,28 @@ const billsGuidance = (function () {
                                     let pasteNode = bills.tree.selected.guidance.tree.items[target.row];
                                     pasteBlock(pasteNode);
                                 }},
+                            "insertSibling": {
+                                name: '插入行',
+                                disabled: function () {
+                                    let node = bills.tree.selected.guidance.tree.items[target.row];
+                                    return !node || node.data.type !== itemType.job;
+                                },
+                                icon: "fa-arrow-left",
+                                callback: function (key, opt) {
+                                    insert([{type: itemType.job, name: ''}], false);
+                                }
+                            },
+                            "insertChild": {
+                                name: '插入子项',
+                                disabled: function () {
+                                    let node = bills.tree.selected.guidance.tree.items[target.row];
+                                    return !node || node.data.type !== itemType.job || !allJobChildren(node);
+                                },
+                                icon: 'fa-arrow-left',
+                                callback: function (key, opt) {
+                                    insert([{type: itemType.job, name: ''}], true);
+                                }
+                            }
                         }
                     };
                 }
@@ -1197,11 +1219,204 @@ const billsGuidance = (function () {
             }
         });
     }
+    //拖动相关
+    let mouseMoveCount = 0;
+    let rationLibResizeEles = {};
+    rationLibResizeEles.id = '#de';
+    rationLibResizeEles.resize = $('#deResize');
+    rationLibResizeEles.nearElement = $('#de').find('.top-content');
+    rationLibResizeEles.nearSpread = $('#sectionSpread');
+    rationLibResizeEles.farElement = $('#de').find('.bottom-content');
+    rationLibResizeEles.farSpread = $('#rationSpread');
+    rationLibResizeEles.nav = null;
+
+    function setDefaultSize(tag,eles,type) {
+        let o_nearSize = 5;
+        let o_farSize = 2;
+        if(type == 'height'){
+            let headerHeight = $(".header").height();
+            let toolsbarHeight = $(".sidebar-tools-bar").height();
+            let resizeHeight = 6;
+            let totalHeight = $(window).height() - headerHeight - toolsbarHeight - resizeHeight;
+            const navSize = eles.nav ? eles.nav[type]() + 4 : 0;
+            totalHeight = totalHeight - navSize;
+            let nearSize = (o_nearSize/(o_nearSize + o_farSize))* totalHeight;
+            eles.nearSpread[type](nearSize);
+            eles.nearElement[type](nearSize);
+            eles.farSpread[type](totalHeight - nearSize);
+            eles.farElement[type](totalHeight - nearSize);
+        }
+    }
+    function setSizeWithPercent(tag,eles,nearSize,farSize,type) {
+        nearSize = parseFloat(nearSize);
+        farSize = parseFloat(farSize);
+        if(type !== 'width') {
+            let headerHeight = $(".header").height();
+            let toolsbarHeight = $(".sidebar-tools-bar").height();
+            let resizeHeight = 6;
+            let totalHeight = $(window).height() - headerHeight - toolsbarHeight - resizeHeight;
+            const navSize = eles.nav ? eles.nav[type]() + 4 : 0;
+            totalHeight = totalHeight - navSize;
+            nearSize = (nearSize/(nearSize + farSize))* totalHeight;
+            eles.nearSpread[type](nearSize);
+            eles.nearElement[type](nearSize);
+            eles.farSpread[type](totalHeight - nearSize);
+            eles.farElement[type](totalHeight - nearSize);
+        }
+    }
+    /**
+     * 读取设置的高度
+     *
+     * @param {String} tag - 顶层div的id
+     * @param {function} callback - 回调函数
+     * @return {void}
+     */
+
+    function loadSize(eles, type, callback) {
+        let tag = eles.id;
+        if (tag === '') {
+            return;
+        }
+        if(type !== 'height' && type !== 'width'){
+            return;
+        }
+        let o_nearSize = eles.nearSpread[type]();
+        let o_farSize = eles.farSpread[type]();
+        let nearSize = getLocalCache(`near${type}:${tag}`);
+        let farSize = getLocalCache(`far${type}:${tag}`);
+        if (nearSize === null || farSize === null) {
+            setDefaultSize(tag,eles,type);
+        }else {
+            setSizeWithPercent(tag,eles,nearSize,farSize,type)//zhang 2018-06-04 改成按百分比设置
+        }
+        callback();
+    }
+    /**
+     * 拖动更改div大小
+     *
+     * @param {Object} eles - id:存储本地的标记 resize:拖动条 nearElement:左上外层div nearSpread:左上spread farElement:右下外层div evFixedSize:造价书左右拖动用
+     * @param {Object} limit - min/max
+     * @param {String} type - height/width
+     * @param {function} callback - 成功后执行
+     * @return {void}
+     */
+    function slideResize(eles, limit, type, callback) {
+        if(type !== 'height' && type !== 'width'){
+            return;
+        }
+        //nearElement:左上, farElement:右下
+        let startP = 0;
+        let drag = false;
+        const resizeElement = eles.resize;
+        const nElement = eles.nearElement;
+        const fElement = eles.farElement;
+        const navContentEle = eles.nav ? eles.nav : null;
+        let nEleSize = 0;
+        let fEleSize = 0;
+        let navSize = 0;
+        let nEleChangeSize = 0;
+        let fEleChangeSize = 0;
+
+        // 鼠标点下时
+        resizeElement.mousedown(function(e) {
+            drag = true;
+            startP = type === 'height' ? e.clientY : e.clientX;
+            // 获取左(上)部分的宽度(高度)
+            nEleSize = nElement[type]();
+            // 获取右(下)部分的宽度(高度)
+            fEleSize = fElement[type]();
+            // nav宽(高度)部分
+            if(navContentEle){
+                navSize = navContentEle[type]() + 4;
+            }
+            resizeElement.tooltip('hide');
+        });
+
+        // 鼠标移动
+        $("body").mousemove(function(e) {
+            if (drag) {
+                let moveSize = type === 'height' ? e.clientY - startP : e.clientX - startP;
+                // 判断拖动范围不能超出
+                nEleChangeSize = nEleSize + moveSize;
+                nEleChangeSize = nEleChangeSize < limit.min ? limit.min : nEleChangeSize;
+                nEleChangeSize = nEleChangeSize > limit.max ? limit.max + 9 : nEleChangeSize;
+
+                fEleChangeSize = fEleSize - moveSize;
+                fEleChangeSize = fEleChangeSize < limit.min ? limit.min : fEleChangeSize;
+                fEleChangeSize = fEleChangeSize > limit.max ? limit.max + 9 : fEleChangeSize;
+
+                if(type === 'width'){
+                    let rePercent = getResizeWidthPercent(nEleChangeSize, fEleChangeSize);
+                    eles.nearElement.css(type, rePercent.nearPercent);
+                    eles.farElement.css(type, rePercent.farPercent);
+                }
+                else{
+                    eles.nearSpread[type](nEleChangeSize);
+                    eles.nearElement[type](nEleChangeSize);
+                    eles.farSpread[type](fEleChangeSize - navSize);
+                    eles.farElement[type](fEleChangeSize - navSize);
+                }
+                //实时刷新页面
+                mouseMoveCount+=Math.abs(moveSize);//取移动的决对值
+                if(mouseMoveCount >=5){//当累计移动超过5个像素时,才刷新,减少刷新次数
+                    if(callback) callback();
+                    mouseMoveCount = 0;
+                }
+            }
+        });
+
+        // 鼠标弹起
+        $("body").mouseup(function(e) {
+            if (drag) {
+                callback();
+                drag = false;
+                // 存入本地缓存
+                const id = eles.id;
+                nEleChangeSize = nEleChangeSize >= limit.max ? limit.max + 9  : nEleChangeSize;
+                fEleChangeSize = fEleChangeSize >= limit.max ? limit.max + 9  : fEleChangeSize;
+                setLocalCache(`near${type}:${id}`, nEleChangeSize);
+                setLocalCache(`far${type}:${id}`, fEleChangeSize);
+            }
+        });
+    }
+    /**
+     * 读取设置的高度
+     *
+     * @param {String} tag - 顶层div的id
+     * @param {function} callback - 回调函数
+     * @return {void}
+     */
+    function loadSize(eles, type, callback) {
+        let tag = eles.id;
+        if (tag === '') {
+            return;
+        }
+        if(type !== 'height' && type !== 'width'){
+            return;
+        }
+        let o_nearSize = eles.nearSpread[type]();
+        let o_farSize = eles.farSpread[type]();
+        let nearSize = getLocalCache(`near${type}:${tag}`);
+        let farSize = getLocalCache(`far${type}:${tag}`);
+        if (nearSize === null || farSize === null) {
+            setDefaultSize(tag,eles,type);//zhang 2018-05-21
+            /* eles.nearSpread[type](o_nearSize);
+             eles.farSpread[type](o_farSize);*/
+        }else {
+            setSizeWithPercent(tag,eles,nearSize,farSize,type)//zhang 2018-06-04 改成按百分比设置
+        }
+        if(type === 'width'){//使用百分比
+            let rePercent = getResizeWidthPercent(nearSize ? nearSize : o_nearSize, farSize ? farSize : o_farSize);
+            eles.nearElement.css(type, rePercent.nearPercent);
+            eles.farElement.css(type, rePercent.farPercent);
+        }
+        callback();
+    }
     //初始化个按钮点击
     //@return {void}
     function initBtn(){
         $('#insert').click(function () {
-            insert([{type: itemType.job, name: ''}]);
+            insert([{type: itemType.job, name: ''}], false);
         });
         $('#delConfirm').click(function () {
             del();
@@ -1226,7 +1441,7 @@ const billsGuidance = (function () {
             let checkedRows = getCheckedRationRows();
             let insertDatas = getInsertRations(checkedRows);
             if(insertDatas.length > 0){
-                insert(insertDatas, function () {
+                insert(insertDatas, false, function () {
                     //清空选择
                     clearCheckedRation(checkedRows);
                 });
@@ -1287,6 +1502,16 @@ const billsGuidance = (function () {
                 });
             }
         });
+        //定额高度拖动调整
+        slideResize(rationLibResizeEles, {min: 147, max: 680}, 'height', function() {
+            //autoFlashHeight();
+            if(section.workBook){
+                section.workBook.refresh();
+            }
+            if(ration.workBook){
+                ration.workBook.refresh();
+            }
+        });
     }
     //初始化视图
     //@param {void} @return {void}
@@ -1296,6 +1521,14 @@ const billsGuidance = (function () {
         getLibWithBills(libID);
         initBtn();
         initContextMenu();
+        loadSize(rationLibResizeEles, 'height', function () {
+            if(section.workBook){
+                section.workBook.refresh();
+            }
+            if(ration.workBook){
+                ration.workBook.refresh();
+            }
+        });
     }
 
 

+ 3 - 3
web/maintain/billsGuidance_lib/js/global.js

@@ -1,7 +1,7 @@
 /*全局自适应高度*/
 function autoFlashHeight(){
     var headerHeight = $(".header").height();
-    var topContentHeight = $('#rationSearchResult').is(':visible') ? 0 : 370;
+    var topContentHeight = $('#rationSearchResult').is(':visible') ? 0 : $('.top-content').height();
     var toolsBar = $(".toolsbar").height();
     var toolsBarHeightQ = $(".tools-bar-height-q").height();
     $(".content").height($(window).height()-headerHeight);
@@ -10,8 +10,8 @@ function autoFlashHeight(){
     $(".side-content").height($(window).height()-headerHeight);
     $(".poj-list").height($(window).height()-headerHeight);
     $(".form-list").height($(window).height()-headerHeight-50);
-    $('.main-top-content').height(($(window).height()-headerHeight-toolsBar)*0.7);
-    $('.main-bottom-content').height(($(window).height()-headerHeight-toolsBar)*0.3);
+    $('.main-top-content').height(($(window).height()-headerHeight-toolsBar)*0.85);
+    $('.main-bottom-content').height(($(window).height()-headerHeight-toolsBar)*0.15);
     $('.main-bottom-content').find('textarea').height($('.main-bottom-content').height() - 20);
     $('.main-bottom-content').find('textarea').width($('.main-bottom-content').width() - 25);
     $(".main-data").height($('.main-top-content').height());