Browse Source

Merge branch '1.0.0_online' of http://smartcost.f3322.net:3000/SmartCost/ConstructionOperation into 1.0.0_online

TonyKang 6 years ago
parent
commit
4d3d7dcffa

+ 5 - 0
modules/all_models/compilation.js

@@ -67,6 +67,11 @@ let modelSchema = {
     consumeAmtProperties: {
         type: Array,
         default: []
+    },
+    // cld 办事处id
+    categoryID: {
+        type: Number,
+        default: 12 // 总部id
     }
 };
 mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));

+ 67 - 0
modules/common/const/category_const.js

@@ -0,0 +1,67 @@
+'use strict';
+
+/**
+ * CLD 办事处常量
+ *
+ * @author EllisRan.
+ * @date 2018/9/25
+ * @version
+ */
+
+const category = {
+    ANHUI: 2,
+    GANSU: 3,
+    GUANGDONG: 4,
+    GUANGXI: 5,
+    JIANGXI: 6,
+    SICHUAN: 7,
+    CHONGQING: 8,
+    NEIMENG: 9,
+    ZHEJIANG: 10,
+    SHANDONG: 11,
+    ZONGBU: 12,
+    YUNNAN: 13,
+    GUIZHOU: 14,
+    BEIJING: 15,
+    FUJIAN: 16,
+    HAINAN: 17,
+    HEBEI: 18,
+    HENAN: 19,
+    HEILONGJIANG: 20,
+    HUBEI: 21,
+    HUNAN: 22,
+    JILIN: 23,
+    JIANGSU: 24,
+    LIAONING: 25,
+    NINGXIA: 26
+};
+
+const categoryList = [
+    {id: category.ANHUI, name: '安徽办'},
+    {id: category.GANSU, name: '甘肃办'},
+    {id: category.GUANGDONG, name: '广东办'},
+    {id: category.GUANGXI, name: '广西办'},
+    {id: category.JIANGXI, name: '江西办'},
+    {id: category.SICHUAN, name: '四川办'},
+    {id: category.CHONGQING, name: '重庆办'},
+    {id: category.NEIMENG, name: '内蒙办'},
+    {id: category.ZHEJIANG, name: '浙江办'},
+    {id: category.SHANDONG, name: '山东办'},
+    {id: category.ZONGBU, name: '总部'},
+    {id: category.YUNNAN, name: '云南办'},
+    {id: category.GUIZHOU, name: '贵州办'},
+    {id: category.BEIJING, name: '北京办'},
+    {id: category.FUJIAN, name: '福建办'},
+    {id: category.HAINAN, name: '海南办'},
+    {id: category.HEBEI, name: '河北办'},
+    {id: category.HENAN, name: '河南办'},
+    {id: category.HEILONGJIANG, name: '黑龙江办'},
+    {id: category.HUBEI, name: '湖北办'},
+    {id: category.HUNAN, name: '湖南办'},
+    {id: category.JILIN, name: '吉林办'},
+    {id: category.JIANGSU, name: '江苏办'},
+    {id: category.LIAONING, name: '辽宁办'},
+    {id: category.NINGXIA, name: '宁夏办'}
+];
+
+export {category as default, categoryList as List};

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

@@ -22,6 +22,7 @@ const billsGuidanceFc = require('../../std_billsGuidance_lib/facade/facades');
 import mainColFacade from "../../main_col_lib/facade/main_col_facade";
 import billTemplateFacade from "../../bills_template_lib/facade/bills_template_facade";
 import projectFeatureFacade from "../../project_feature_lib/facade/project_feature_facade";
+import {default as category, List as categoryList} from "../../common/const/category_const.js";
 let config = require("../../../config/config.js");
 const fs = require('fs');
 
@@ -64,6 +65,7 @@ class CompilationController extends BaseController {
         let renderData = {
             id: id,
             compilationList: compilationList,
+            categoryList: categoryList,
             selectedCompilation: selectedCompilation,
             layout: 'users/views/layout/layout',
             LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
@@ -633,6 +635,30 @@ class CompilationController extends BaseController {
         response.redirect(request.headers.referer);
     }
 
+    /**
+     * 更改编办所属办事处信息
+     *
+     * @param request
+     * @param response
+     * @return {Promise.<void>}
+     */
+    async changeCategory(request, response) {
+        let valuationId = request.body.id;
+        let category = request.body.category;
+        category = parseInt(category);
+        try {
+            let compilationModel = new CompilationModel();
+            let result = await compilationModel.updateCategory(valuationId, category);
+            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});
+        }
+    }
+
 }
 
 export default CompilationController;

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

@@ -36,7 +36,7 @@ class CompilationModel extends BaseModel {
      */
     async getCompilationList(fields = null) {
         // 筛选字段
-        let field = fields == null ?{_id: 1, name: 1, is_release: 1, description: 1,overWriteUrl: 1, "ration_valuation.id": 1, "ration_valuation.name": 1, "ration_valuation.enable": 1,
+        let field = fields == null ?{_id: 1, name: 1, is_release: 1, categoryID: 1, description: 1,overWriteUrl: 1, "ration_valuation.id": 1, "ration_valuation.name": 1, "ration_valuation.enable": 1,
             "bill_valuation.id": 1, "bill_valuation.name": 1, "bill_valuation.enable": 1}:fields;
         let compilationData = await this.findDataByCondition({name: {$ne: ''}}, field, false);
 
@@ -348,6 +348,17 @@ class CompilationModel extends BaseModel {
         return result.ok === 1;
     }
 
+    /*
+     * 设置CLD办事处信息
+     *
+     * @param {String} compilationId
+     * @param {int} category
+     * @return {Promise}
+     * */
+    async updateCategory(compilationId, category) {
+        return await this.updateById(compilationId, {categoryID: category});
+    }
+
 }
 
 export default CompilationModel;

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

@@ -31,5 +31,7 @@ module.exports = function (app) {
     router.post('/template/:section/:id/:engineering/update', compilationController.auth, compilationController.init, compilationController.updateBillsTemplate);
     router.post('/addEngineer', compilationController.auth, compilationController.init, compilationController.addEngineer);
 
+    router.post('/changeCategory', compilationController.auth, compilationController.init, compilationController.changeCategory);
+
     app.use("/compilation", router);
 };

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

@@ -373,6 +373,21 @@ $(document).ready(function() {
     });
     //
 
+    // CLD 办事处选择
+    $('#category-select').change(function () {
+        $.ajax({
+            url: '/compilation/changeCategory',
+            type: 'post',
+            data: {id: id, category: $(this).val()},
+            dataType: "json",
+            success: function(response) {
+                if (response.error !== 0) {
+                    alert('更改失败');
+                }
+            }
+        });
+    })
+
 });
 
 /**

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

@@ -100,6 +100,13 @@
             <table class="table">
                 <tr><td><p>软件版本介绍</p><textarea id="description" class="form-control" placeholder="请简要描述改版本"><%= selectedCompilation.description%></textarea></td></tr>
                 <tr><td><span>重写路径:</span><input class="form-control" type="text" id="overWriteUrl" value="<%= selectedCompilation.overWriteUrl%>"></td></tr>
+                <tr><td><p>显示办事处销售信息</p>
+                    <select class="form-control" style="width:200px" id="category-select">
+                        <% categoryList.forEach(function(category) { %>
+                        <option value="<%= category.id %>" <% if (selectedCompilation.categoryID !== undefined && category.id === selectedCompilation.categoryID) { %>selected="selected"<% } %> ><%= category.name %></option>
+                        <% }) %>
+                    </select>
+                </td></tr>
             </table>
         </div>
         <input type="hidden" name="id" value="<%= selectedCompilation._id %>" id="compilation-id">