Bladeren bron

项目管理

zhangweicheng 6 jaren geleden
bovenliggende
commit
f2dc2b64d5

+ 1 - 1
gulpfile.js

@@ -276,7 +276,7 @@ gulp.task('main_css',function () {
     return css(mainOptions);
 })
 
-gulp.task('main_inject',['main_minify','main_css'],function () {
+gulp.task('main_inject',['main_minify'],function () {//,'main_css'
     return inject(mainOptions);
 })
 

+ 3 - 0
modules/glj/controllers/glj_controller.js

@@ -277,6 +277,9 @@ class GLJController extends BaseController {
      * @return {void}
      */
     async getProjectInfo(request, response) {
+        if(typeof request.body.data == "string"){
+            request.body = JSON.parse(request.body.data)
+        }
         let projectId = request.body.project_id;
         let rootProjectID = request.body.rootProjectID;
         projectId = parseInt(projectId);

+ 1 - 1
public/web/common_ajax.js

@@ -173,7 +173,7 @@ async function ajaxPost(url, data) {
             cache: false,
             timeout: 50000,
             success: function(result){
-                if (result.error === 0) {
+                if (result.error === 0 || result.err ===0) {
                     resolve(result.data);
                 } else {
                     alert('error: ' + result.message);

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

@@ -7,7 +7,7 @@
     <meta http-equiv="x-ua-compatible" content="ie=edge">
     <title><%= projectData.name !== undefined ? projectData.name : '造价书' %>-纵横建筑云计价</title>
 
-    <!-- inject:css -->
+
     <link rel="stylesheet" href="/lib/jquery-ui/jquery-ui.css" type="text/css">
     <link rel="stylesheet" href="/lib/bootstrap/css/bootstrap.min.css">
     <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.sc.css" type="text/css">
@@ -24,7 +24,7 @@
     <link rel="stylesheet" href="/lib/spreadjs/views/gc.spread.views.dataview.10.0.0.css">
     <!-- jquery.contextmenu -->
    <!-- <link rel="stylesheet" href="/lib/jquery-contextmenu/jquery.contextMenu.css" type="text/css">-->
-    <!-- endinject -->
+   
     <link rel="shortcut icon" href="/web/building_saas/css/favicon.ico">
     <link rel="icon" type="image/gif" href="/web/building_saas/css/animated_favicon1.gif">
     <style type="text/css">

+ 1 - 1
web/building_saas/main/js/views/zmhs_view.js

@@ -153,7 +153,7 @@ let zmhs_obj = {
         this.coeSheet.getCell(i, 2, GC.Spread.Sheets.SheetArea.viewport).locked(false);
         let options = coe.option_codes.split("|");
         let combo = sheetCommonObj.getDynamicCombo(true);
-        combo.itemHeight(options.length).items(options);
+        combo.items(options);//itemHeight(options.length).
         this.coeSheet.setCellType(i, 2, combo, GC.Spread.Sheets.SheetArea.viewport);
         this.coeSheet.setValue(i, 2, coe.select_code);
 

+ 70 - 0
web/building_saas/pm/html/project-management.html

@@ -614,6 +614,76 @@
         </div>
     </div>
 </div>
+
+<!--弹出 批量替换单价文件-->
+<div class="modal fade" id="m_replace_file" data-backdrop="static">
+    <div class="modal-dialog modal-lg" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title" id="mr_title">批量替换单价文件</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <input type="hidden" id="mr_from">
+            <div class="modal-body">
+                <div class="row">
+                    <div class="col-6">
+                        <h5>选择项目</h5>
+                        <div class="modal-auto-height">
+                            <div id="replaceSpread" style="height: 100%"></div>
+                        </div>
+                        <div class="custom-control custom-checkbox">
+                            <input type="checkbox" class="custom-control-input" id="customCheck1">
+                            <label class="custom-control-label" for="customCheck1">自动勾选同专业工程</label>
+                        </div>
+                    </div>
+                    <div class="col-6">
+                        <h5>更换为</h5>
+                        <div class="form-group">
+                            <div class="custom-control custom-radio custom-control-inline">
+                                <input type="radio" id="customRadioInline33" name="select_from" value="0" class="custom-control-input" checked>
+                                <label class="custom-control-label" for="customRadioInline33">从本建设项目中选择</label>
+                            </div>
+                            <div class="custom-control custom-radio custom-control-inline">
+                                <input type="radio" id="customRadioInline44" name="select_from" value="1" class="custom-control-input">
+                                <label class="custom-control-label" for="customRadioInline44">从其他建设项目中复制</label>
+                            </div>
+                        </div>
+                        <!--从本建设项目中选择-->
+                        <label id="project_name">9.21<!--本建设项目名称--></label>
+                        <div class="form-group" id = "fromProject">
+                            <select class="form-control" id="currentOptions">
+                                <option>测试5单价文件</option><!--单价文件-->
+                            </select>
+                        </div>
+                        <!--从其他建设项目中复制-->
+                        <div id = "fromOther">
+                            <div class="form-group" >
+                                <label>选择建设项目</label>
+                                <select class="form-control" id="otherProject" >
+                                    <option>10.9建筑例题内测</option><!--建设项目-->
+                                </select>
+                            </div>
+                            <div class="form-group">
+                                <select class="form-control" id="otherFileOptions">
+                                    <option>10.9建筑例题内测单价文件</option><!--建设项目下单价文件-->
+                                </select>
+                                <span class="form-text text-muted">你选择的单价文件将复制一份至新项目,不会影响原建设项目的单价文件。</span>
+                            </div>
+                        </div>
+
+                    </div>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                <a href="" class="btn btn-primary mr-3">确定</a>
+            </div>
+        </div>
+    </div>
+</div>
+
 <!--弹出删除 单价/费率 文件-->
 <div class="modal fade" id="del-wj" data-backdrop="static">
     <div class="modal-dialog" role="document">

+ 185 - 11
web/building_saas/pm/js/pm_newMain.js

@@ -55,8 +55,10 @@ const projTreeObj = {
     tree: null,
     workBook: null,
     copyToWorkBook:null,
+    replaceWorkBook:null,
     copySelected:null,
     preSelection: null,
+    changeInfo:null,
     setting: {
         tree: {
             id: 'ID',
@@ -116,7 +118,28 @@ const projTreeObj = {
             allowUserDragFill: false,
             scrollbarMaxAlign : true,
             showDragDropTip:false
-        }},
+        }
+    },
+    replaceSetting:{
+        header: [
+            {name: '工程列表', dataCode: 'name', width: 250, vAlign: 'center', hAlign: 'left'},
+            {name: '选择', dataCode: 'selected', width: 50, vAlign: 'center', cellType:'checkBox'}
+        ],
+        //选中行颜色
+        style: {
+            defalutBackColor: 'White',
+            selectedColor: '#BBFFFF'
+        },
+        options: {
+            tabStripVisible:  false,
+            allowCopyPasteExcelStyle : false,
+            allowExtendPasteRange: false,
+            allowUserDragDrop : false,
+            allowUserDragFill: false,
+            scrollbarMaxAlign : true,
+            showDragDropTip:false
+        }
+    },
     renderSheetFuc: function (sheet, fuc) {
         sheet.suspendPaint();
         sheet.suspendEvent();
@@ -137,6 +160,7 @@ const projTreeObj = {
         sheet.bind(_events.EditStarting, this.onCellEditing);
         sheet.bind(_events.ClipboardPasting,this.onCellEditing);
         workBook.bind(_events.DragDropBlock, this.onDragDropBlock);
+        workBook.bind(GC.Spread.Sheets.Events.ButtonClicked, this.changeFileClick)
     },
     buildHeader: function (sheet, headers) {
         let me = this;
@@ -472,6 +496,14 @@ const projTreeObj = {
         let me = projTreeObj;
         me.initSelection(args.newSelections[0], args.oldSelections[0],args.sheet);
     },
+    changeFileClick:async function (sender,args) {
+        if(args.sheet.name() == "projectSheet"){
+            await projTreeObj.initFileChangePage(projTreeObj.setting.header[args.col].dataCode);
+            $("#mr_from").val(projTreeObj.setting.header[args.col].dataCode);
+            $("#project_name").text(projTreeObj.tree.selected.data.name);
+            $('#m_replace_file').modal('show');
+        }
+    },
     onDragDropBlock : function (sender,args) {//拖动移动项目位置
         let selected = projTreeObj.tree.selected;
         let targetNode = projTreeObj.tree.items[args.toRow];
@@ -837,7 +869,7 @@ const projTreeObj = {
             function withingClickArea(){
                 return hitinfo.x > centerX + halfBoxLength && hitinfo.x < centerX + halfBoxLength + imgWidth + indent/2+3 + textLength;
             }
-            if(hitinfo.sheet.name() != "copyToSheet"){//如果是复制到sheet,不用执行
+            if(hitinfo.sheet.name() === "projectSheet"){//只有项目管理界面才执行
                 //单项文件,进入造价书界面
                  if(node.data.projType === projectType.tender && withingClickArea()){
                     let timeoutTime = 200;
@@ -909,10 +941,11 @@ const projTreeObj = {
         }
         return new TreeNodeCellType();
     },
-    setCellValue: function (cell, node,sheet) {
+    setCellValue: function (cell, node,sheet,setting) {
         //const sheet = this.workBook.getActiveSheet();
+        if(!setting) setting = this.setting;
         const {row, col} = cell;
-        let dataCode = this.setting.header[col]['dataCode'];
+        let dataCode = setting.header[col]['dataCode'];
         let value = '';
         if(dataCode === 'unitPriceFile'){
             if(node.data.projType === projectType.tender){
@@ -932,9 +965,10 @@ const projTreeObj = {
         }
         sheet.setValue(row, col, value);
     },
-    showTreeData: function (nodes, headers,sheet) {
+    showTreeData: function (nodes, setting,sheet) {
+        let headers = setting.header;
         let me = this;
-        let tree = sheet.name() == "copyToSheet"?me.copyTree:me.tree;
+        let tree = nodes.length>0?nodes[0].tree:me.tree;//sheet.name() == "copyToSheet"?me.copyTree:me.tree;
         let fuc = function(){
             sheet.setRowCount(0);
             sheet.setRowCount(nodes.length);
@@ -944,8 +978,16 @@ const projTreeObj = {
                 for(let j = 0; j < headers.length; j++){
                     sheet.getRange(-1, j, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign[headers[j]['hAlign']]);
                     sheet.getRange(-1, j, -1, 1).vAlign(GC.Spread.Sheets.VerticalAlign[headers[j]['vAlign']]);
-                    me.setCellValue({row: i, col: j}, nodes[i],sheet);
+                    if(headers[j].cellType == "checkBox"){
+                        sheet.setCellType(i, j,new GC.Spread.Sheets.CellTypes.CheckBox(),GC.Spread.Sheets.SheetArea.viewport);
+                        sheet.getCell(i, j).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
+                    }
+                    me.setCellValue({row: i, col: j}, nodes[i],sheet,setting);
                     let dataCode = headers[j].dataCode;
+                    if(nodes[i].data.projType == "Tender" && (dataCode=="feeRateFile" || dataCode == "unitPriceFile")) {
+                        sheet.setCellType(i, j,sheetCommonObj.getSelectButton(headers[j].width),GC.Spread.Sheets.SheetArea.viewport);
+                        sheet.getCell(i, j,GC.Spread.Sheets.SheetArea.viewport).locked(false);
+                    }
                     //sheet.setValue(i, j, nodes[i]['data'][dataCode]);
                 }
                 sheet.getCell(i, 1,GC.Spread.Sheets.SheetArea.viewport).locked(true);
@@ -1018,6 +1060,95 @@ const projTreeObj = {
         }
 
     },
+    initFileChangePage:async function (from) {
+        let title = from == "unitPriceFile" ?"批量替换单价文件":"批量替换费率文件";
+        $("#mr_title").text(title);
+        this.initHtmlByFromRadio();
+        let result = from == "unitPriceFile"?await this.setUnitFileChangeFileData():await this.setFeeRateChangeFileData();
+        console.log(result);
+        this.changeInfo = result;
+        this.loadFileOptions(this.changeInfo,from);
+
+    },
+    setFeeRateChangeFileData:async function(){
+        //userID
+        let node = projTreeObj.tree.selected;
+        let data={"user_id":userID, "projectID":node.data.ID, "rootProjectID":node.data.property.rootProjectID};
+        let result = await ajaxPost("/feeRates/getChangeInfo",data);
+        this.getFileListWithPath(result.others);
+        return result;
+
+    },
+    setUnitFileChangeFileData:async function(){
+        let node = projTreeObj.tree.selected;
+        let data ={"project_id":node.data.ID,"rootProjectID":node.data.property.rootProjectID};
+        let result = await ajaxPost("/glj/get-project-info",data);
+        this.getFileListWithPath(result.other);
+        console.log(result);
+        //数据结构不一样,这里做一下转换
+        let t_result = {
+            currentProject:{
+                ID:node.data.ID,
+                currentOptions:result.self,
+            },
+            others:result.other
+        }
+        return t_result;
+
+
+    },
+
+
+
+    getFileListWithPath:function (list) {
+        for(let n of list){
+            let node = projTreeObj.tree.findNode(n.ID);
+            if(node) n.name = getPathName(node);
+        }
+
+        function getPathName(node) {
+            if(node.parent && node.parent.data){
+                return getPathName(node.parent)+"\\"+node.data.name
+            }else {
+                return node.data?node.data.name:"";
+            }
+        }
+
+    },
+    loadFileOptions:function (data,from) {
+        let idField = "ID",optionField ="optionList";
+        if(from == "unitPriceFile"){
+            idField = 'id';
+            optionField = 'unitPriceList'
+        }
+        $('#currentOptions').empty();
+        for(let c of data.currentProject.currentOptions){
+            var option =  $("<option>").val(c[idField]).text(c.name);
+            $('#currentOptions').append(option);
+        }
+        $('#otherProject').empty();
+        for(let p of data.others){
+            var option =  $("<option>").val(p.ID).text(p.name);
+            $('#otherProject').append(option);
+        }
+        $('#otherFileOptions').empty();
+        if(data.others.length>0){
+            for(let f of data.others[0][optionField]){
+                var option =  $("<option>").val(f[idField]).text(f.name);
+                $('#otherFileOptions').append(option);
+            }
+        }
+    },
+    initHtmlByFromRadio:function () {
+        var radioV= $("input[name='select_from']:checked").val();
+        if(radioV == "0"){
+            $("#fromProject").show();
+            $("#fromOther").hide();
+        } else {
+            $("#fromProject").hide();
+            $("#fromOther").show();
+        }
+    },
     initCopyToSpread:function () {
         let me = this;
         me.copyToWorkBook =  projTreeObj.buildSheet(me.copyToWorkBook,'copyToSpread',me.copyToSetting);
@@ -1029,11 +1160,27 @@ const projTreeObj = {
             datas.push(i.data);
         }
         me.copyTree  = pmTree.createNew(projTreeObj.setting, datas);
-        me.showTreeData(me.copyTree.items, me.copyToSetting.header, sheet);
+        me.showTreeData(me.copyTree.items, me.copyToSetting, sheet);
         me.copySelected = null;
         let initSel = sheet.getSelections()[0] ? sheet.getSelections()[0] : {row: 0, rowCount: 1};
         projTreeObj.initSelection(initSel,null,sheet);
     },
+    initReplaceSpread:function () {
+        let me = this;
+        me.replaceWorkBook =  projTreeObj.buildSheet(me.replaceWorkBook,'replaceSpread',me.replaceSetting);
+        let sheet = me.replaceWorkBook.getActiveSheet();
+        sheet.options.isProtected = true;
+        sheet.name('replaceSheet');
+        let datas = [];
+        for(let i of me.tree.items){
+            datas.push(i.data);
+        }
+        me.replaceTree  = pmTree.createNew(projTreeObj.setting, datas);
+        me.showTreeData(me.replaceTree.items, me.replaceSetting, sheet);
+
+    },
+
+
     insert: function (data, parent, next) {
         let preNode = this.tree.items[this.preSelection.row];
         let node = this.tree.addNodeData(data, parent, next);
@@ -1547,11 +1694,19 @@ $(document).ready(function() {
     });*/
 
     $('#copy-to-dialog').on('shown.bs.modal', function () {
-        console.log('shown copy to ');
         projTreeObj.initCopyToSpread();
        // copytoZTree = ConvertTreeToZtree(projTreeObj.tree, $('#treeDemo2'), null);
     });
 
+    $('#m_replace_file').on('shown.bs.modal', function () {
+        // projTreeObj.tree.selected
+        projTreeObj.initReplaceSpread();
+    });
+    $("input[name='select_from']").each(function(){
+        $(this).click(function(){
+            projTreeObj.initHtmlByFromRadio();
+        });
+    });
     // 复制到操作
     $("#copy-to-confirm").click(function() {
         let originalNode = projTreeObj.tree.selected;
@@ -1654,7 +1809,6 @@ $(document).ready(function() {
         }else {
             $('#taxType_div').show();
         }
-        console.log(taxTypeArray);
     }
 
     function getStdCalcProgramFiles(){
@@ -1733,9 +1887,10 @@ function initProjects(callback) {
             projTreeObj.tree.selected = projTreeObj.tree.items[0];
             projTreeObj.workBook = projTreeObj.buildSheet(projTreeObj.workBook,'projSpread',projTreeObj.setting);
             projTreeObj.workBook.getSheet(0).frozenColumnCount(2);
+            projTreeObj.workBook.getSheet(0).name('projectSheet');
             sheetCommonObj.spreadDefaultStyle(projTreeObj.workBook);
             projTreeObj.sumEngineeringCost();
-            projTreeObj.showTreeData(projTreeObj.tree.items, projTreeObj.setting.header, projTreeObj.workBook.getActiveSheet());
+            projTreeObj.showTreeData(projTreeObj.tree.items, projTreeObj.setting, projTreeObj.workBook.getActiveSheet());
             //初始选择
             let initSel = projTreeObj.workBook.getSheet(0).getSelections()[0] ? projTreeObj.workBook.getSheet(0).getSelections()[0] : {row: 0, rowCount: 1};
             projTreeObj.initSelection(initSel,null,projTreeObj.workBook.getActiveSheet());
@@ -3483,6 +3638,25 @@ $('#allowCopy').change(function () {
     }
 });
 
+//批量替换文件,切换建设项目
+$('#otherProject').change(function(){
+    let optionList = [],idField = 'ID';
+    var newVal = $(this).val();
+    var projects = projTreeObj.changeInfo.others;
+    var selected = _.find(projects,{ID:parseInt(newVal)});
+    if($("#mr_from").val() =="unitPriceFile"){
+        idField = 'id';
+        optionList = selected.unitPriceList;
+    }else {
+        optionList =  selected.optionList;
+    }
+    $('#otherFileOptions').empty();
+    for(let f of optionList){
+        let option =  $("<option>").val(f[idField]).text(f.name);
+        $('#otherFileOptions').append(option);
+    }
+});
+
 //分享给...界面确认
 $('#shareToConfirm').click(function () {
     let selected = projTreeObj.tree.selected;