zhongzewei 7 lat temu
rodzic
commit
417bdc38c1

+ 15 - 0
modules/pm/controllers/pm_controller.js

@@ -159,6 +159,21 @@ module.exports = {
             callback(req, res, err, message, data);
         });
     },
+    defaultSettings: async function(req, res){
+        try{
+            let data = JSON.parse(req.body.data);
+            let projectID = data.projectID;
+            let defaultSettingSc = await ProjectsData.defaultSettings(req.session.sessionUser.id, req.session.sessionCompilation._id, projectID);
+            if(!defaultSettingSc){
+                throw '恢复失败';
+            }
+            res.json({error: 0, message: '恢复成功', data: null});
+        }
+        catch(error){
+            console.log(error);
+            res.json({error: 1, message: error, data: null});
+        }
+    },
  /*   copyProjects: function (req, res) {
         let data = JSON.parse(req.body.data);
         ProjectsData.copyUserProjects(req.session.sessionUser.id, req.session.sessionCompilation._id, data.updateData, function (err, message, data) {

+ 32 - 0
modules/pm/models/project_model.js

@@ -14,6 +14,7 @@ import {
     calcOptions,
     tenderSetting
 } from './project_property_template';
+import optionSetting from '../../options/models/optionTypes';
 import fixedFlag from '../../common/const/bills_fixed';
 let FeeRateFiles = mongoose.model('fee_rate_file');
 let counter = require("../../../public/counter/counter.js");
@@ -30,6 +31,9 @@ let BillsModel = require("../../main/models/bills").model;
 let _ = require('lodash');
 
 let Projects = mongoose.model('projects');
+let mainColLibModel = mongoose.model('std_main_col_lib');
+let projSettingModel = mongoose.model('proj_setting');
+let optionModel = mongoose.model('options');
 let projectType = {
     folder: 'Folder',
     tender: 'Tender',
@@ -778,6 +782,34 @@ ProjectsDAO.prototype.getBasicInfo = async function (projectID) {
     return constructionProject.property.basicInformation;
 };
 
+//恢复默认系统设置
+ProjectsDAO.prototype.defaultSettings = async function (userID, compilationId, projectID) {
+    let project = await Projects.findOne({ID: projectID});
+    if(!project){
+        return false;
+    }
+    let cloneProperty = _.cloneDeep(project.property);
+    //关于计算
+    cloneProperty.billsCalcMode = 0;
+    cloneProperty.zanguCalcMode = 0;
+    cloneProperty.calcOptions = calcOptions;
+    //清单工程量精度
+    cloneProperty.billsQuantityDecimal = billsQuantityDecimal;
+    //小数位数
+    cloneProperty.decimal = defaultDecimal;
+    //呈现选项
+    cloneProperty.displaySetting = displaySetting;
+    //列设置
+    let stdColLib = await mainColLibModel.findOne({ID: project.property.colLibID});
+    if(stdColLib){
+        await projSettingModel.update({projectID: projectID}, {$set: {main_tree_col: stdColLib.main_tree_col}});
+    }
+    //系统选项
+    await optionModel.update({user_id: userID, compilation_id: compilationId}, {$set: {options: optionSetting}});
+    await Projects.update({ID: projectID}, {$set: {property: cloneProperty}});
+    return true;
+};
+
 
 
 module.exports ={    project: new ProjectsDAO(),

+ 1 - 0
modules/pm/routes/pm_route.js

@@ -48,6 +48,7 @@ module.exports = function (app) {
     pmRouter.post('/getUnitFile', pmController.getUnitFileList);
     pmRouter.post('/getFeeRateFile', pmController.getFeeRateFileList);
     pmRouter.post('/updateFiles', pmController.updateFiles);
+    pmRouter.post('/defaultSettings', pmController.defaultSettings);
     //GC
     pmRouter.post('/getGCDatas', pmController.getGCDatas);
     pmRouter.post('/recGC', pmController.recGC);

+ 1 - 1
web/building_saas/complementary_glj_lib/html/tools-gongliaoji.html

@@ -107,8 +107,8 @@
                     <h5 class="text-danger" id="alertGljTxt">编号和类型不可为空!是否取消操作?</h5>
                 </div>
                 <div class="modal-footer">
-                    <button type="button" class="btn btn-secondary" id="aleCanceBtn" data-dismiss="modal">取消</button>
                     <a href="javascript: void(0);" id="aleConfBtn" class="btn btn-danger" data-dismiss="modal">确认</a>
+                    <button type="button" class="btn btn-secondary" id="aleCanceBtn" data-dismiss="modal">取消</button>
                 </div>
             </div>
         </div>

+ 151 - 96
web/building_saas/complementary_glj_lib/js/glj.js

@@ -212,6 +212,7 @@ let repositoryGljObj = {
         me.workBook = sheetOpr.buildSheet(container, me.setting, 30);
         sheetCommonObj.spreadDefaultStyle(me.workBook);
         me.repositoryGljDelOpr();
+        me.onContextmenuOpr();
         me.bindEnterKey();
         me.setUnitCombo(me.workBook.getActiveSheet(), me.setting.header);
         me.workBook.getActiveSheet().bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
@@ -333,26 +334,30 @@ let repositoryGljObj = {
         //混凝土202、砂浆203、配合比204、机械3
         if(typeof info.oldSelections || info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
             let row = info.newSelections[0].row;
-            sheetOpr.cleanSheet(that.workBook.getSheet(0), that.setting, -1);
-            me.workBook.focus(true);
-            me.currentComponent = [];
-            that.workBook.getSheet(0).setRowCount(5);
-            if(row < me.currentCache.length){
-                //标记当前工料机
-                me.currentGlj = me.currentCache[row];
-                if(allowComponent.includes(me.currentCache[row].gljType)){
-                    //展示数据
-                    if(me.currentGlj.component.length > 0){
-                        me.currentComponent = me.getCurrentComponent(me.currentGlj.component);
-                        if(me.currentComponent.length > 0){
-                            sheetOpr.showData(that.workBook.getSheet(0), that.setting, me.currentComponent);
-                        }
+            me.initSel(row);
+        }
+    },
+    initSel: function (row) {
+        let me = repositoryGljObj, that = gljComponentOprObj;
+        sheetOpr.cleanData(that.workBook.getSheet(0), that.setting, -1);
+        me.workBook.focus(true);
+        me.currentComponent = [];
+        that.workBook.getSheet(0).setRowCount(5);
+        if(row < me.currentCache.length){
+            //标记当前工料机
+            me.currentGlj = me.currentCache[row];
+            if(allowComponent.includes(me.currentCache[row].gljType)){
+                //展示数据
+                if(me.currentGlj.component.length > 0){
+                    me.currentComponent = me.getCurrentComponent(me.currentGlj.component);
+                    if(me.currentComponent.length > 0){
+                        sheetOpr.showData(that.workBook.getSheet(0), that.setting, me.currentComponent);
                     }
                 }
             }
-            else{
-                me.currentGlj = null;
-            }
+        }
+        else{
+            me.currentGlj = null;
         }
     },
     onEnterCell: function (sender, args) {
@@ -374,19 +379,19 @@ let repositoryGljObj = {
                 let focusToCol;
                 function getFocusToCol (me){
                     if(!me.addGljObj[me.setting.header[0].dataCode]){
-                        $('#alertGljTxt').text('编号不能为空,继续增加工料机?');
+                        $('#alertGljTxt').text('编号不能为空,继续增加人材机?');
                         return 0;
                     }
                     else if(!me.addGljObj[me.setting.header[1].dataCode]){
-                        $('#alertGljTxt').text('名称不能为空,继续增加工料机?');
+                        $('#alertGljTxt').text('名称不能为空,继续增加人材机?');
                         return 1;
                     }
                     else if(!me.addGljObj[me.setting.header[3].dataCode]){
-                        $('#alertGljTxt').text('计量单位不能为空,继续增加工料机?');
+                        $('#alertGljTxt').text('计量单位不能为空,继续增加人材机?');
                         return 3;
                     }
                     else if(!me.addGljObj[me.setting.header[5].dataCode]){
-                        $('#alertGljTxt').text('类型不能为空,继续增加工料机?');
+                        $('#alertGljTxt').text('类型不能为空,继续增加人材机?');
                         return 5;
                     }
                     else {
@@ -579,103 +584,153 @@ let repositoryGljObj = {
             me.mixUpdateRequest(updateArr, addArr, []);
         }
     },
-    repositoryGljDelOpr: function () {
+    delGljs: function (sels) {
         let me = repositoryGljObj;
-        me.workBook.commandManager().register('repositoryGljDel', function () {
-            let sheet = me.workBook.getSheet(0),
-                updateArr = [], removeArr = [],
-                tempRemoveArr= [],
-                refGljCodes = [], //已被引用的工料机
-                updateBasePrcArr = [],//删除基价单位后重新计算
-                sels = sheet.getSelections(),
-                canUpdate = false,
-                cacheSection = me.currentCache;
-            if(sels.length > 0 && cacheSection.length > 0){
-                for(let i = 0; i < sels.length; i++){
-                    if(sels[i].colCount === me.setting.header.length){
-                        for(let j = 0; j < sels[i].rowCount; j++){
-                            if(sels[i].row + j < cacheSection.length){
-                                //删除了已被引用成组成物的工料机,重新计算所有引用此组成物的工料机的单价、组成物数组
-                                let updateGljs = me.getUpdateGljs(cacheSection[sels[i].row + j], true);
-                                if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
-                                    for(let i = 0; i < updateGljs.updateArr.length; i++){
-                                        updateArr.push(updateGljs.updateArr[i]);
-                                    }
-                                    for(let i = 0; i < updateGljs.updateBasePrcArr.length; i++){
-                                        updateBasePrcArr.push(updateGljs.updateBasePrcArr[i]);
-                                    }
+        let sheet = me.workBook.getSheet(0),
+            updateArr = [], removeArr = [],
+            tempRemoveArr= [],
+            refGljCodes = [], //已被引用的工料机
+            updateBasePrcArr = [],//删除基价单位后重新计算
+            canUpdate = false,
+            cacheSection = me.currentCache;
+        if(sels.length > 0 && cacheSection.length > 0){
+            for(let i = 0; i < sels.length; i++){
+                if(sels[i].colCount === me.setting.header.length){
+                    for(let j = 0; j < sels[i].rowCount; j++){
+                        if(sels[i].row + j < cacheSection.length){
+                            //删除了已被引用成组成物的工料机,重新计算所有引用此组成物的工料机的单价、组成物数组
+                            let updateGljs = me.getUpdateGljs(cacheSection[sels[i].row + j], true);
+                            if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
+                                for(let i = 0; i < updateGljs.updateArr.length; i++){
+                                    updateArr.push(updateGljs.updateArr[i]);
+                                }
+                                for(let i = 0; i < updateGljs.updateBasePrcArr.length; i++){
+                                    updateBasePrcArr.push(updateGljs.updateBasePrcArr[i]);
                                 }
-                                removeArr.push(cacheSection[sels[i].row + j].ID);
-                                //tempRemoveArr.push({ID: cacheSection[sels[i].row + j].ID, code: cacheSection[sels[i].row + j].code});
-                                //删除后重新计算引用了此工料机的定额单价
-                                updateBasePrcArr.push({gljId: cacheSection[sels[i].row + j].ID, gljType: cacheSection[sels[i].row + j].gljType, basePrice: 0, delete: 1});
                             }
+                            removeArr.push(cacheSection[sels[i].row + j].ID);
+                            //tempRemoveArr.push({ID: cacheSection[sels[i].row + j].ID, code: cacheSection[sels[i].row + j].code});
+                            //删除后重新计算引用了此工料机的定额单价
+                            updateBasePrcArr.push({gljId: cacheSection[sels[i].row + j].ID, gljType: cacheSection[sels[i].row + j].gljType, basePrice: 0, delete: 1});
                         }
                     }
-                    else{
-                        let maxCol = sels[i].col + sels[i].colCount - 1;
-                        if(sels[i].col >= 2 && maxCol <= 4){
-                            for(let j = 0; j < sels[i].rowCount; j++){
-                                if(sels[i].row + j < cacheSection.length){
-                                    let updateObj = cacheSection[sels[i].row + j];
-                                    for(let col = sels[i].col; col <= maxCol; col++){
-                                        if(me.setting.header[col].dataCode === 'basePrice'){
-                                            //如果类型不为混凝土、砂浆、配合比、机械,才可删除单价 basePrice = 0
-                                            if(!allowComponent.includes(updateObj.gljType)){
-                                                canUpdate = true;
-                                                updateObj[me.setting.header[col].dataCode] = 0;
-                                                updateBasePrcArr.push({gljId: updateObj.ID, gljType: updateObj.gljType, basePrice: 0});
-                                            }
-                                        }
-                                        else{
+                }
+                else{
+                    let maxCol = sels[i].col + sels[i].colCount - 1;
+                    if(sels[i].col >= 2 && maxCol <= 4){
+                        for(let j = 0; j < sels[i].rowCount; j++){
+                            if(sels[i].row + j < cacheSection.length){
+                                let updateObj = cacheSection[sels[i].row + j];
+                                for(let col = sels[i].col; col <= maxCol; col++){
+                                    if(me.setting.header[col].dataCode === 'basePrice'){
+                                        //如果类型不为混凝土、砂浆、配合比、机械,才可删除单价 basePrice = 0
+                                        if(!allowComponent.includes(updateObj.gljType)){
                                             canUpdate = true;
-                                            updateObj[me.setting.header[col].dataCode] = '';
+                                            updateObj[me.setting.header[col].dataCode] = 0;
+                                            updateBasePrcArr.push({gljId: updateObj.ID, gljType: updateObj.gljType, basePrice: 0});
                                         }
                                     }
-                                    if(canUpdate){
-                                        updateArr.push(updateObj);
+                                    else{
+                                        canUpdate = true;
+                                        updateObj[me.setting.header[col].dataCode] = '';
                                     }
                                 }
+                                if(canUpdate){
+                                    updateArr.push(updateObj);
+                                }
                             }
                         }
-                        //编号、名称、类型不可为空
-                        else{
-                            if(sels[i].row < cacheSection.length){
-                                let text = '', cantNullStr =['编码', '名称', '类型'];
-                                for(let col = sels[i].col; col <= sels[i].col + sels[i].colCount -1; col++){
-                                    if(cantNullStr.indexOf(me.setting.header[col].headerName) !== -1){
-                                        text += me.setting.header[col].headerName + " ";
-                                    }
+                    }
+                    //编号、名称、类型不可为空
+                    else{
+                        if(sels[i].row < cacheSection.length){
+                            let text = '', cantNullStr =['编码', '名称', '类型'];
+                            for(let col = sels[i].col; col <= sels[i].col + sels[i].colCount -1; col++){
+                                if(cantNullStr.indexOf(me.setting.header[col].headerName) !== -1){
+                                    text += me.setting.header[col].headerName + " ";
                                 }
-                                $('#alertText').text(text + "不可为空!");
-                                $('#codeAlertBtn').click();
-                                $('#codAleConfBtn').click(function () {
-                                });
-                                $('#codAleClose').click(function () {
-                                });
                             }
+                            $('#alertText').text(text + "不可为空!");
+                            $('#codeAlertBtn').click();
+                            $('#codAleConfBtn').click(function () {
+                            });
+                            $('#codAleClose').click(function () {
+                            });
                         }
                     }
                 }
-                if(removeArr.length > 0 || updateArr.length > 0){
-                    //删除警告
-                    $('#alertGljTxt').text('可能已有定额引用了当前工料机,导致定额查找不到此工料机。确定要删除吗?');
-                    $('#gljAlertBtn').click();
-                    //确认
-                    $('#aleConfBtn').click(function () {
-                        me.mixUpdateRequest(updateArr, [], removeArr);
-                        /*if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
-                            me.updateRationBasePrcRq(updateBasePrcArr);
-                        }*/
-                    });
-                }
             }
-
+            if(removeArr.length > 0 || updateArr.length > 0){
+                //删除警告
+                $('#alertGljTxt').text('可能已有定额引用了当前工料机,导致定额查找不到此工料机。确定要删除吗?');
+                $('#gljAlertBtn').click();
+                //确认
+                $('#aleConfBtn').unbind('click');
+                $('#aleConfBtn').bind('click', function () {
+                    me.mixUpdateRequest(updateArr, [], removeArr);
+                    /*if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
+                     me.updateRationBasePrcRq(updateBasePrcArr);
+                     }*/
+                });
+            }
+        }
+    },
+    repositoryGljDelOpr: function () {
+        let me = repositoryGljObj;
+        me.workBook.commandManager().register('repositoryGljDel', function () {
+            let sels = me.workBook.getActiveSheet().getSelections();
+            me.delGljs(sels);
         });
-
         me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
         me.workBook.commandManager().setShortcutKey('repositoryGljDel', GC.Spread.Commands.Key.del, false, false, false, false);
     },
+    onContextmenuOpr: function () {
+        let me = repositoryGljObj;
+        $.contextMenu({
+            selector: '#GLJListSheet',
+            build: function($triggerElement, e){
+                //控制允许右键菜单在哪个位置出现
+                let sheet = me.workBook.getSheet(0);
+                let offset = $("#GLJListSheet").offset(),
+                    x = e.pageX - offset.left,
+                    y = e.pageY - offset.top;
+                let target = sheet.hitTest(x, y);
+                let sel = sheet.getSelections()[0];
+                if(sel.row === -1){
+                    sel.row = 0;
+                }
+                if(sel.col === -1){
+                    sel.col = 0;
+                }
+                if(target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){//在表格内
+                    me.initSel(target.row);
+                    if(sel.row > target.row || sel.row + sel.rowCount - 1 < target.row ||
+                        sel.col > target.col || sel.col + sel.colCount - 1 < target.col ){
+                        sheet.setActiveCell(target.row, target.col);
+                    }
+                    return {
+                        callback: function(){},
+                        items: {
+                            "delete": {
+                                name: "删除",
+                                disabled: function () {
+                                    return !(me.currentCache && me.currentCache[target.row]);
+                                },
+                                icon: "fa-remove",
+                                callback: function (key, opt) {
+                                    let curSel = _.cloneDeep(sheet.getSelections()[0]);
+                                    curSel.colCount = me.setting.header.length;
+                                    me.delGljs([curSel]);
+                                }}
+                        }
+                    };
+                }
+                else{
+                    return false;
+                }
+            }
+        });
+    },
     validUpdateObj: function (pasteObj, rowIdx) {
         let rst = {updateGlj: [], updateBasePrcArr: []}, backUpObj = {},
             me = repositoryGljObj,

+ 3 - 0
web/building_saas/css/main.css

@@ -399,6 +399,9 @@ a{
 .custom-file-input:lang(zh) ~ .custom-file-label::after {
     content: "浏览";
 }
+.custom-file-input{
+    cursor: pointer;
+}
 
 .message-box {
     position:absolute;

+ 3 - 1
web/building_saas/main/html/main.html

@@ -731,7 +731,7 @@
                                 </div>
                                 <!--系统选项-->
                                 <div class="tab-pane fade" id="system-setting" role="tabpanel">
-                                    <div class="modal-auto-height">
+                                    <div class="modal-auto-height" style="overflow: hidden">
                                         <fieldset class="form-group">
                                             <div class="form-check">
                                                 <label class="form-check-label">
@@ -746,6 +746,7 @@
                                                 </label>
                                             </div>
                                         </fieldset>
+                                            <label style="margin-top: 320px">将影响所有建设项目</label>
                                     </div>
                                 </div>
                             </div>
@@ -753,6 +754,7 @@
                     </div>
                 </div>
                 <div class="modal-footer">
+                    <a href="javascript:void(0);" class="btn btn-primary" id="property_default" data-dismiss="modal">恢复默认系统设置</a>
                     <a href="javascript:void(0);" class="btn btn-primary" id="property_ok" data-dismiss="modal">确定</a>
                     <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                 </div>

+ 8 - 0
web/building_saas/main/js/views/project_view.js

@@ -2125,6 +2125,14 @@ $('#recColSetting').click(function () {
     });
 });
 
+//恢复默认系统设置
+$('#property_default').click(function () {
+    let project = projectObj.project,
+        projectID = project.ID();
+    CommonAjax.post('/pm/api/defaultSettings', {user_id: userID, projectID: projectID}, function (rstData) {
+        window.location.href = `/main?project=${projectID}`;
+    });
+});
 $('#property_ok').click(function () {
     let project = projectObj.project,
         projectID = project.ID(),

+ 5 - 1
web/common/html/header.html

@@ -1,5 +1,9 @@
 <nav class="navbar navbar-expand-lg p-0 d-flex">
-    <a style="text-decoration: none" href="/pm" class="header-logo">
+    <% if(controller === 'boot'){ %>
+    <a style="text-decoration: none" href="javascript:void(0);" class="header-logo">
+    <% }else { %>
+        <a style="text-decoration: none" href="/pm" class="header-logo">
+    <% } %>
         <div class="v-title">纵横云计价</div>
         <div class="p-title"><%= versionName %></div>
     </a>

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

@@ -58,7 +58,7 @@ function showError(msg, element) {
     if (element !== null) {
         element.parent().addClass('has-danger');
     }
-    let html = '<div class="form-control-feedback">' + msg + '</div>';
+    let html = '<div class="form-control-feedback" style="color: red">' + msg + '</div>';
     if (element.siblings('.form-control-feedback').length > 0) {
         element.siblings('.form-control-feedback').text(msg);
     } else {