ソースを参照

修改工程专业

zhangweicheng 6 年 前
コミット
71a6ac28cb

+ 7 - 5
modules/all_models/engineering_lib.js

@@ -60,12 +60,14 @@ let modelSchema = {
     valuationID:{type:String,index: true},
     //工程专业名称
     name:String,
+    //费用标准
+    feeName:String,
     //前端是否显示
-    visible:{
-        type: Boolean,
-        default: false
-    },
-    engineering:Number
+    visible:{type: Boolean, default: false},
+    //取费专业
+    engineering:Number,
+    //是否计算安装增加费
+    isInstall:{type: Boolean, default: false}
 };
 mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));
 

+ 1 - 1
modules/common/const/bills_fixed.js

@@ -47,7 +47,7 @@ const fixedFlagList = [
     {name: "措施项目", value: fixedFlag.MEASURE},
     {name: "施工技术措施项目", value: fixedFlag.CONSTRUCTION_TECH},
     {name: "安全文明施工按实计算费用", value: fixedFlag.SAFETY_CONSTRUCTION_ACTUAL},
-    {name: "施工组织措施专项费用", value: fixedFlag.CONSTRUCTION_ORGANIZATION},
+    {name: "施工组织措施项目", value: fixedFlag.CONSTRUCTION_ORGANIZATION},
     {name: "安全文明施工专项费用", value: fixedFlag.SAFETY_CONSTRUCTION},
     {name: "其他项目", value: fixedFlag.OTHER},
     {name: "暂列金额", value: fixedFlag.PROVISIONAL},

+ 40 - 4
modules/users/controllers/compilation_controller.js

@@ -100,10 +100,10 @@ class CompilationController extends BaseController {
             if (!valuationId) {
                 throw '新增计价规则失败';
             }
-            //添加标准工程专业
-            let engineeringLibModel = new EngineeringLibModel();
+            //添加标准工程专业  2018-08-24 不自动添加标准工程了
+            /*let engineeringLibModel = new EngineeringLibModel();
             let stdEngs = await engineeringLibModel.addStdLib(valuationId);
-            console.log(stdEngs);
+            console.log(stdEngs);*/
         } catch (error) {
             console.log(error);
             responseData.err = 1;
@@ -285,9 +285,35 @@ class CompilationController extends BaseController {
         response.redirect(request.headers.referer);
     }
 
+    /**
+     * 通过工程专业ID删除工程专业
+     * @param request
+     * @param response
+     * @returns {Promise.<void>}
+     */
+    async deleteEngineer(request,response){
+        let result={
+            error:0
+        };
+        try {
+            let data = request.body.data;
+            data = JSON.parse(data);
+            if(data.id ){
+                let engineeringLibModel = new EngineeringLibModel();
+                result.data = await engineeringLibModel.deleteById(data.id,true);
+            }else {
+                throw new Error("提交数据有误");
+            }
+        }catch (err){
+            console.log(err);
+            result.error=1;
+            result.message = err.message;
+        }
+        response.json(result);
+    }
 
     /**
-     * 保存工程专业信息-用于异步操作
+     * 修改保存工程专业信息-用于异步操作
      * @param request
      * @param response
      * @returns {Promise.<void>}
@@ -576,6 +602,16 @@ class CompilationController extends BaseController {
         }
     }
 
+    async addEngineer(request,response){
+        let engineeringLibModel = new EngineeringLibModel();
+        try {
+            await engineeringLibModel.addEngineer(request.body);
+        }catch (error) {
+            console.log(error);
+        }
+        response.redirect(request.headers.referer);
+    }
+
 }
 
 export default CompilationController;

+ 5 - 0
modules/users/models/engineering_lib_model.js

@@ -77,6 +77,11 @@ class EngineeringLibModel extends BaseModel {
         return result;
     }
 
+    async addEngineer(data){
+        data.glj_col = {showAdjustPrice:false};
+        let result = await this.db.create(data);
+        return result;
+    }
 
     /**
      * 新增标准库

+ 2 - 0
modules/users/routes/compilation_route.js

@@ -26,9 +26,11 @@ module.exports = function (app) {
     router.post('/add-valuation', compilationController.auth, compilationController.init, compilationController.addValuation);
     router.post('/save-valuation', compilationController.auth, compilationController.init, compilationController.saveValuation);
     router.post('/update-engineer', compilationController.auth, compilationController.init, compilationController.updateEngineer);
+    router.post('/delete-engineer', compilationController.auth, compilationController.init, compilationController.deleteEngineer);
     router.post('/save-lib', compilationController.auth, compilationController.init, compilationController.saveEngineering);
     router.post('/valuation/:section/enable', compilationController.auth, compilationController.init, compilationController.enableSwitch);
     router.post('/template/:section/:id/:engineering/update', compilationController.auth, compilationController.init, compilationController.updateBillsTemplate);
+    router.post('/addEngineer', compilationController.auth, compilationController.init, compilationController.addEngineer);
 
     app.use("/compilation", router);
 };

+ 1 - 1
public/web/commonAlert.js

@@ -17,7 +17,7 @@ window.alert = function(str) {
 $(document).ready(function() {
     !function loadHintBox(){
         $("body").append('<div id = "hintBox_container"></div>');
-        $("#hintBox_container").load("../../public/scHintBox.html");
+        $("#hintBox_container").load("/public/scHintBox.html");
     }();
 
 })

+ 11 - 0
web/users/css/custom.css

@@ -0,0 +1,11 @@
+
+.engineeringInput::-webkit-outer-spin-button,
+.engineeringInput::-webkit-inner-spin-button {
+  -webkit-appearance: none;
+}
+.engineeringInput {
+  -moz-appearance: textfield;
+}
+.btn-link:focus, .btn-link:hover{
+  text-decoration: none
+}

+ 43 - 10
web/users/js/compilation.js

@@ -315,6 +315,26 @@ $(document).ready(function() {
 
     });
 
+    //添加工程专业
+    $("#addEngineerConfirm").click(async function() {
+        if($('#name').val() == ''){
+            $("#nameError").show();
+            return;
+        }
+        if($('#feeName').val() == ''){
+            $("#feeNameError").show();
+            return;
+        }
+        if($('#engineeringInput').val() == ''){
+            $("#engineeringError").show();
+            return;
+        }
+        $("#addEngineerConfirm").attr("disabled",true);//防止重复提交
+        $("#addEngineerForm").submit();
+
+
+    });
+    //
 
 });
 
@@ -597,7 +617,7 @@ function switchChange(element) {
     return !currentStatus;
 }
 
-function editEngineerName(selector) {
+function editEngineer(selector) {
     let engineerName =  $(selector).prev("span").text();
     let parentDiv = $(selector).parent("div");
     parentDiv.next("div").find("input").val(engineerName);
@@ -605,23 +625,36 @@ function editEngineerName(selector) {
     parentDiv.next("div").show();
 }
 
-function confirmName(selector,engineerID) {
+function confirmUpdate(selector,engineerID) {
     let inputDiv = $(selector).parents(".input_group_div");
-    let oldEngineerName =  inputDiv.prev("div").find("span").text();
-    let newEngineerName = $(selector).parent(".input-group-btn").prev("input").val();
-    if(newEngineerName === "" || newEngineerName == oldEngineerName||!engineerID){
+    let input = $(selector).parent(".input-group-btn").prev("input");
+    let oldValue = inputDiv.prev("div").find("span").text();
+    let newValue = input.val();
+    let key = input.attr("name");
+    if(newValue == "" || newValue==oldValue || !engineerID){
         inputDiv.prev("div").show();
         inputDiv.hide();
         return;
     }
+     let updateData = {};
+     updateData[key] = newValue;
+     updateEngineer(engineerID,updateData,function () {
+        inputDiv.prev("div").find("span").text(newValue);
+     });
+     inputDiv.prev("div").show();
+     inputDiv.hide();
+}
 
-    updateEngineer(engineerID,{name:newEngineerName},function () {
-        inputDiv.prev("div").find("span").text(newEngineerName);
-    });
-    inputDiv.prev("div").show();
-    inputDiv.hide();
+function deleteEngineerClick(engineerID) {
+    console.log(engineerID);
+    hintBox.infoBox('操作确认', '是否删除所选工程专业?', 2, async function () {
+        console.log(engineerID+'删除')
+    }, function () {
+        console.log('取消')
+    },['确定','取消'],false);
 }
 
+
 function engineerVisibleChange(checkBox,engineerID) {
     if(engineerID){
         updateEngineer(engineerID,{visible:checkBox.checked});

+ 62 - 10
web/users/views/compilation/add.html

@@ -27,18 +27,19 @@
                         </div>
                     </div>
                     <div class="col-md-12">
-                        <legend>
+                        <legend style="margin-bottom: 0px;">
                             工程专业
                         </legend>
+                        <a class="btn btn-link btn-sm"  data-toggle="modal" data-target="#addEngineer">添加</a>
                         <table class="table engineer_table">
                             <thead>
                             <tr>
-                                <th>工程名称</th>
+                                <th>工程专业</th>
+                                <th>费用标准</th>
+                                <th>定额取费专业</th>
                                 <th>标准清单</th>
                                 <th>定额库</th>
                                 <th>人材机库</th>
-                                <th>费率标准</th>
-                                <th>人工系数</th>
                                 <th>前台显示</th>
                                 <th>操作</th>
                             </tr>
@@ -47,22 +48,36 @@
                                 <% engineeringList.forEach(function(engineering) {%>
                                 <tr >
                                     <td>
-                                        <div><span><%= engineering.name %></span> <a onclick='editEngineerName(this)'><i class="glyphicon glyphicon-pencil"></i></a></div>
+                                        <div><span><%= engineering.name %></span> <a onclick='editEngineer(this)'><i class="glyphicon glyphicon-pencil"></i></a></div>
                                         <div class="input-group input-group-sm input_group_div" style="width:200px;display: none">
-                                            <input class="form-control">
+                                            <input class="form-control" name="name">
                                             <div class="input-group-btn">
-                                                <button type="button" class="btn btn-success" onclick='confirmName(this,"<%= engineering._id.toString()%>")'>
+                                                <button type="button" class="btn btn-success" onclick='confirmUpdate(this,"<%= engineering._id.toString()%>")'>
                                                     <span class="glyphicon glyphicon-ok"></span></button>
                                             </div>
                                         </div>
                                     </td>
+                                    <td><div><span><%= engineering.feeName %></span> <a onclick='editEngineer(this)'><i class="glyphicon glyphicon-pencil"></i></a></div>
+                                        <div class="input-group input-group-sm input_group_div" style="width:200px;display: none">
+                                            <input class="form-control" name="feeName">
+                                            <div class="input-group-btn">
+                                                <button type="button" class="btn btn-success" onclick='confirmUpdate(this,"<%= engineering._id.toString()%>")'>
+                                                    <span class="glyphicon glyphicon-ok"></span></button>
+                                            </div>
+                                        </div></td>
+                                    <td><div><span><%= engineering.engineering %></span> <a onclick='editEngineer(this)'><i class="glyphicon glyphicon-pencil"></i></a></div>
+                                        <div class="input-group input-group-sm input_group_div" style="width:200px;display: none">
+                                            <input class="form-control engineeringInput" type="number" name="engineering">
+                                            <div class="input-group-btn">
+                                                <button type="button" class="btn btn-success" onclick='confirmUpdate(this,"<%= engineering._id.toString()%>")'>
+                                                    <span class="glyphicon glyphicon-ok"></span></button>
+                                            </div>
+                                        </div></td>
                                     <td><%= engineering.bill_lib.length %></td>
                                     <td><%= engineering.ration_lib.length %></td>
                                     <td><%= engineering.glj_lib.length %></td>
-                                    <td><%= engineering.fee_lib.length %></td>
-                                    <td><%= engineering.artificial_lib.length %></td>
                                     <td><label><input type="checkbox"  <% if (engineering.visible) { %>checked<% } %>  onclick='engineerVisibleChange(this,"<%= engineering._id.toString()%>")'> 显示</label></td>
-                                    <td><a href="/compilation/<%= section %>/<%= valuationId %>/<%= engineering._id.toString()%>">编辑</a></td>
+                                    <td><a class="btn-link" href="/compilation/<%= section %>/<%= valuationId %>/<%= engineering._id.toString()%>">编辑</a>/<a onclick="deleteEngineerClick('<%= engineering._id.toString()%>')" class='btn btn-link btn-sm' style="padding: 0px">删除</a></td>
                                 </tr>
                                 <% }) %>
                             </tbody>
@@ -75,6 +90,43 @@
         </div>
     </div>
 </div>
+
+<!--添加工程专业窗口-->
+<div class="modal fade in" id="addEngineer"  role="dialog" tabindex="-1">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
+                <h4 class="modal-title">添加新的工程专业</h4>
+            </div>
+            <div class="modal-body">
+                <form id="addEngineerForm" method="post" action="/compilation/addEngineer" enctype="application/x-www-form-urlencoded21">
+                    <div class="form-group">
+                        <label>工程专业</label>
+                        <input class="form-control" type="text" name ="name" id="name" placeholder="请输入工程专业名称">
+                        <small class="form-text text-danger" id="nameError" style="display: none">请输入工程专业名称。</small>
+                    </div>
+                    <div class="form-group">
+                        <label>费用标准</label>
+                        <input class="form-control" type="text" name ="feeName" id="feeName" placeholder="请输入费用标准">
+                        <small class="form-text text-danger" id="feeNameError" style="display: none">请输入费用标准。</small>
+                    </div>
+                    <div class="form-group">
+                        <label>定额取费专业</label>
+                        <input class="form-control engineeringInput" type="number" name ="engineering" id="engineeringInput" placeholder="请输入定额取费专业">
+                        <small class="form-text text-danger" id="engineeringError" style="display: none">请输入定额取费专业。</small>
+                    </div>
+                    <input type="hidden" name="valuationID" value="<%= valuationId %>">
+                </form>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
+                <button type="button" class="btn btn-primary" id="addEngineerConfirm">确定添加</button>
+            </div>
+        </div>
+    </div>
+</div>
+<script src="/public/web/commonAlert.js"></script>
 <script type="text/javascript" src="/public/web/common_ajax.js"></script>
 <script type="text/javascript" src="/web/users/js/compilation.js"></script>
 <%include ../compilation/modal.html %>

+ 1 - 0
web/users/views/layout/layout.html

@@ -10,6 +10,7 @@
     <link rel="stylesheet" href="/lib/font-awesome/font-awesome.min.css">
     <link rel="stylesheet" href="/web/users/css/bootstrap.min.css">
     <link rel="stylesheet" href="/web/users/css/style.css">
+    <link rel="stylesheet" href="/web/users/css/custom.css">
     <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.sc.css" type="text/css">
     <script src="/lib/jquery/jquery.min.js"></script>
     <script src="/web/users/js/lib/bootstrap.min.js"></script>