Browse Source

feat: 后台增加公路类型设置

zhangweicheng 1 year ago
parent
commit
e0c91e0c31

+ 1 - 0
modules/all_models/compilation.js

@@ -101,6 +101,7 @@ let modelSchema = {
         default: 12 // 总部id
     },
     defaultLocation:String,//默认工程所在地
+    type:String,//编办类型
     freeUse:Boolean
 };
 mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));

+ 23 - 0
modules/users/controllers/compilation_controller.js

@@ -76,6 +76,7 @@ class CompilationController extends BaseController {
             compilationList: compilationList,
             categoryList: categoryList,
             locationList: locationList,
+            typeList: [{label:'建设工程',value:'building'},{label:'公路建设',value:'highway'},{label:'公路养护',value:'yanghu'},{label:'成本测算',value:'cost'}],
             selectedCompilation: selectedCompilation,
             title: config[process.env.NODE_ENV].title ? config[process.env.NODE_ENV].title : '养护云版',
             layout: 'users/views/layout/layout',
@@ -813,6 +814,28 @@ class CompilationController extends BaseController {
         }
     }
 
+       /**
+   * 更改编办默认工程所在工
+   *
+   * @param request
+   * @param response
+   * @return {Promise.<void>}
+   */
+       async changeCompilation(request, response) {
+        let compilationId = request.body.id;
+        let update = request.body.update;
+        try {
+            let compilationModel = new CompilationModel();
+            let result = await compilationModel.updateById(compilationId, update);
+            if (result) {
+                response.json({ error: 0, message: '', data: null });
+            } else {
+                response.json({ error: 1, message: '更新数据错误', data: null });
+            }
+        } catch (error) {
+            response.json({ error: 1, message: '更新数据错误', data: null });
+        }
+    }
 
     /**
     * 更改编办默认工程所在工

+ 1 - 1
modules/users/models/compilation_model.js

@@ -44,7 +44,7 @@ class CompilationModel extends BaseModel {
             "rough_valuation.id": 1, "rough_valuation.name": 1, "rough_valuation.enable": 1,
             "bill_valuation.id": 1, "bill_valuation.name": 1, "bill_valuation.enable": 1,
             "estimation_valuation.id": 1, "estimation_valuation.name": 1, "estimation_valuation.enable": 1,
-            "bill_valuation.fileTypes": 1
+            "bill_valuation.fileTypes": 1,type:1
         } : fields;
         // 一定要查询序号,然后排序输出
         field.serialNumber = 1;

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

@@ -37,6 +37,7 @@ module.exports = function (app) {
 
     router.post('/changeCategory', compilationController.auth, compilationController.init, compilationController.changeCategory);
     router.post('/changeLocation', compilationController.auth, compilationController.init, compilationController.changeLocation);
+    router.post('/changeCompilation', compilationController.auth, compilationController.init, compilationController.changeCompilation);
     router.post('/changeFreeUse', compilationController.auth, compilationController.init, compilationController.changeFreeUse);
     router.post('/setEdition', compilationController.auth, compilationController.init, compilationController.setEdition);
     router.post('/setSerialNumber', compilationController.auth, compilationController.init, compilationController.setSerialNumber);

+ 15 - 0
web/users/js/compilation.js

@@ -594,6 +594,21 @@ $(document).ready(function () {
         });
     })
 
+       // 选择编办类型
+       $('#type-select').change(function () {
+        $.ajax({
+            url: '/compilation/changeCompilation',
+            type: 'post',
+            data: { id: id, update:{type: $(this).val()} },
+            dataType: "json",
+            success: function (response) {
+                if (response.error !== 0) {
+                    alert('更改失败');
+                }
+            }
+        });
+    })
+
     // 修改是否提供免费版
     $('#freeUse').change(function (val) {
         $.ajax({

+ 8 - 0
web/users/views/compilation/index.html

@@ -300,6 +300,14 @@
                             <% }) %>
                     </select>
                 </td></tr>
+                <tr><td><p>编办类型</p>
+                    <select class="form-control" style="width:200px" id="type-select">
+                        <option value=""></option>
+                        <% typeList.forEach(function(type) { %>
+                            <option value="<%= type.value %>" <% if (selectedCompilation.type !== undefined && type.value === selectedCompilation.type) { %>selected="selected"<% } %> ><%= type.label %></option>
+                            <% }) %>
+                    </select>
+                </td></tr>
                 <tr>
                     <td>
                         <p><span> 提供免费版:</span> <input type="checkbox" id="freeUse"  <% if (selectedCompilation.freeUse) { %> checked <% } %>></p>