Browse Source

编办信息中新增版本号字段

lishihao 3 years ago
parent
commit
5d8a0dc564

+ 2 - 0
modules/all_models/compilation.js

@@ -55,6 +55,8 @@ let modelSchema = {
     overWriteUrl:String,
     //例题建设项目ID
     example: Array,
+    // 版本号
+    edition:String,
     // 发布时间
     release_time: {
         type: Number,

+ 12 - 1
modules/users/controllers/compilation_controller.js

@@ -66,7 +66,6 @@ class CompilationController extends BaseController {
 
             selectedCompilation = Object.keys(selectedCompilation).length <= 0 ? compilationList[0] : selectedCompilation;
             request.session.selectedCompilation = selectedCompilation;
-
         } catch (error) {
             console.log(error);
         }
@@ -582,6 +581,18 @@ class CompilationController extends BaseController {
             response.json({err: 1, msg: err, data: null});
         }
     }
+    async setEdition(request, response){
+        let compilationId = request.body.id;
+        let edition = request.body.edition;
+        try{
+            let compilationModel = new CompilationModel();
+            await compilationModel.setEdition(compilationId, edition);
+            response.json({err: 0, msg: '', data: null});
+        }
+        catch (err){
+            response.json({err: 1, msg: err, data: null});
+        }
+    }
     async setOverWriteUrl(request, response){
         let compilationId = request.body.id;
         let overWriteUrl = request.body.overWriteUrl;

+ 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, release_time:1,categoryID: 1, description: 1,overWriteUrl: 1,example: 1, "ration_valuation.id": 1, "ration_valuation.name": 1, "ration_valuation.enable": 1,
+        let field = fields == null ?{_id: 1, name: 1, is_release: 1, release_time:1,categoryID: 1, description: 1,overWriteUrl: 1,example: 1,edition: 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);
 
@@ -137,6 +137,17 @@ class CompilationModel extends BaseModel {
     async setDescription(compilationId, description){
         return await this.updateById(compilationId, {description: description});
     }
+
+    /*
+    * 设置版本号
+    *
+    * @param {String} compilationId
+    * @param {String} edition
+    * @return {Promise}
+    * */
+   async setEdition(compilationId, edition){
+    return await this.updateById(compilationId, {edition: edition});
+}
     /*
         设置代码覆盖路径
      */

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

@@ -21,6 +21,7 @@ module.exports = function (app) {
     router.post('/release', compilationController.auth, compilationController.init, compilationController.release);
     router.post('/add', compilationController.auth, compilationController.init, compilationController.addCompilation);
     router.post('/setDescription', compilationController.auth, compilationController.init, compilationController.setDescription);
+    router.post('/setEdition', compilationController.auth, compilationController.init, compilationController.setEdition);
     router.post('/setOverWriteUrl', compilationController.auth, compilationController.init, compilationController.setOverWriteUrl);
     router.post('/setExample', compilationController.auth, compilationController.init, compilationController.setExample);
     router.post('/add-valuation', compilationController.auth, compilationController.init, compilationController.addValuation);

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

@@ -423,6 +423,22 @@ $(document).ready(function() {
         });
     });
 
+    //更改版本号
+    $('#edition').change(function () {
+        let edition = $(this).val();
+        $.ajax({
+            url: '/compilation/setEdition',
+            type: 'post',
+            dataType: "json",
+            data: {id: id, edition: edition},
+            success: function(response) {
+                if (response.err !== 0) {
+                    alert('更改失败');
+                }
+            }
+        });
+    });
+
     //更改代码覆盖路径
     $('#overWriteUrl').change(function () {
         let overWriteUrl = $(this).val();
@@ -467,6 +483,9 @@ $(document).ready(function() {
         });
     });
 
+    
+
+
     // 计价规则启用/禁止
     $(".enable").click(function() {
         let goingChangeStatus = switchChange($(this));

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

@@ -108,6 +108,7 @@
                         <% }) %>
                     </select>
                 </td></tr>
+                <tr><td><span>版本号:</span><input class="form-control" type="text" id="edition" value="<%= selectedCompilation.edition%>"></td></tr>
             </table>
         </div>
         <input type="hidden" name="id" value="<%= selectedCompilation._id %>" id="compilation-id">