浏览代码

修改版本管理为编办管理

caiaolin 7 年之前
父节点
当前提交
8120a03435

+ 3 - 3
config/menu.js

@@ -49,9 +49,9 @@ let menuData = {
         }
     },
     'version': {
-        title: '版本管理',
-        url: '/version',
-        name: 'version',
+        title: '编办管理',
+        url: '/compilation',
+        name: 'compilation',
         iconClass: 'glyphicon glyphicon-tag'
     },
     'tool': {

+ 3 - 3
modules/common/std/schemas/std_bills_lib_lists.js

@@ -18,9 +18,9 @@ let modelSchema = {
     createDate: String,
     // 名称
     billsLibName: String,
-    // 地区/省份字段
-    localeType: {
-        type: Number,
+    // 编办id
+    compilationId: {
+        type: String,
         index: true
     },
     // 是否被删除

+ 3 - 3
modules/common/std/schemas/std_ration_lib_map.js

@@ -19,9 +19,9 @@ let modelSchema = {
     dispName: String,
     // app类型
     appType: Number,
-    // 地区/省份类型
-    localeType: {
-        type: Number,
+    // 编办id
+    compilationId: {
+        type: String,
         index: true
     },
     descr: String,

+ 9 - 5
modules/common/std/std_bills_lib_lists_model.js

@@ -24,9 +24,10 @@ class STDBillsLibListsModel extends BaseModel {
     /**
      * 获取标准清单
      *
+     * @param {String} compilationId
      * @return {Promise}
      */
-    async getBillList() {
+    async getBillList(compilationId) {
         let result = false;
         let billLib = await this.findDataByCondition({deleted: false}, null, false);
         if (billLib.length <= 0) {
@@ -34,13 +35,16 @@ class STDBillsLibListsModel extends BaseModel {
         }
 
         // 整理数据
-        let billList = {};
+        let billList = [];
         for(let tmp of billLib) {
             let tmpRation = {id: tmp.billsLibId, name: tmp.billsLibName};
-            if (billList[tmp.localeType] === undefined) {
-                billList[tmp.localeType] = [tmpRation];
+            if (compilationId !== tmp.compilationId) {
+                continue;
+            }
+            if (billList.length <= 0) {
+                billList = [tmpRation];
             } else {
-                billList[tmp.localeType].push(tmpRation);
+                billList.push(tmpRation);
             }
         }
 

+ 9 - 5
modules/common/std/std_ration_lib_map_model.js

@@ -24,9 +24,10 @@ class STDRationLibMapModel extends BaseModel {
     /**
      * 获取定额库
      *
+     * @param {String} compilationId
      * @return {Promise}
      */
-    async getRationLib() {
+    async getRationLib(compilationId) {
         let result = false;
         let rationLib = await this.findDataByCondition({deleted: false}, null, false);
         if (rationLib.length <= 0) {
@@ -34,13 +35,16 @@ class STDRationLibMapModel extends BaseModel {
         }
 
         // 整理数据
-        let rationData = {};
+        let rationData = [];
         for(let tmp of rationLib) {
             let tmpRation = {id: tmp.ID, name: tmp.dispName};
-            if (rationData[tmp.localeType] === undefined) {
-                rationData[tmp.localeType] = [tmpRation];
+            if (compilationId !== tmp.compilationId) {
+                continue;
+            }
+            if (rationData.length <= 0) {
+                rationData = [tmpRation];
             } else {
-                rationData[tmp.localeType].push(tmpRation);
+                rationData.push(tmpRation);
             }
         }
 

+ 47 - 49
modules/users/controllers/version_controller.js

@@ -1,21 +1,20 @@
 /**
- * 版本控制控制器
+ * 编办控制控制器
  *
  * @author CaiAoLin
  * @date 2017/7/28
- * @version
+ * @compilation
  */
 import BaseController from "../../common/base/base_controller";
-import VersionModel from "../models/version_model";
+import CompilationModel from "../models/compilation_model";
 import STDRationLibMapModel from "../../common/std/std_ration_lib_map_model";
 import STDBillLibListsModel from "../../common/std/std_bills_lib_lists_model";
-import {default as ProvinceConst, List as ProvinceList} from "../../common/const/province_const";
 import {default as EngineeringConst, List as EngineeringList} from "../../common/const/engineering";
 
-class VersionController extends BaseController {
+class CompilationController extends BaseController {
 
     /**
-     * 版本控制页面
+     * 编办管理控制页面
      *
      * @param {object} request
      * @param {object} response
@@ -24,25 +23,25 @@ class VersionController extends BaseController {
     async index(request, response) {
         let id = request.query.id;
 
-        let versionList = [];
-        let selectedVersion = {};
+        let compilationList = [];
+        let selectedCompilation = {};
         try {
-            let versionModel = new VersionModel();
-            versionList = await versionModel.getVersionList();
+            let compilationModel = new CompilationModel();
+            compilationList = await compilationModel.getCompilationList();
 
-            if (versionList.length <= 0) {
+            if (compilationList.length <= 0) {
                 throw '没有数据';
             }
             // 循环查找数据
-            for (let tmp of versionList) {
+            for (let tmp of compilationList) {
                 if (tmp._id.toString() === id) {
-                    selectedVersion = tmp;
+                    selectedCompilation = tmp;
                     break;
                 }
             }
 
-            selectedVersion = Object.keys(selectedVersion).length <= 0 ? versionList[0] : selectedVersion;
-            request.session.selectedVersion = selectedVersion;
+            selectedCompilation = Object.keys(selectedCompilation).length <= 0 ? compilationList[0] : selectedCompilation;
+            request.session.selectedCompilation = selectedCompilation;
 
         } catch (error) {
             console.log(error);
@@ -50,12 +49,12 @@ class VersionController extends BaseController {
 
         let renderData = {
             id: id,
-            versionList: versionList,
-            selectedVersion: selectedVersion,
+            compilationList: compilationList,
+            selectedCompilation: selectedCompilation,
             layout: 'users/views/layout/layout'
         };
 
-        response.render('users/views/version/index', renderData);
+        response.render('users/views/compilation/index', renderData);
     }
 
     /**
@@ -83,8 +82,8 @@ class VersionController extends BaseController {
                 name: name,
             };
 
-            let versionModel = new VersionModel();
-            let result = await versionModel.addValuation(id, section, insertData);
+            let compilationModel = new CompilationModel();
+            let result = await compilationModel.addValuation(id, section, insertData);
 
             if (!result) {
                 throw '新增计价规则失败';
@@ -106,29 +105,29 @@ class VersionController extends BaseController {
      * @return {void}
      */
     async editValuation(request, response) {
-        let selectedVersion = request.session.selectedVersion;
+        let selectedCompilation = request.session.selectedCompilation;
         let valuationId = request.params.id;
         let section = request.params.section;
 
         let billList = {};
         let rationList = {};
-        let versionList = [];
+        let compilationList = [];
         let valuationData = {};
         let valuationList = {};
         try {
-            let versionModel = new VersionModel();
-            versionList = await versionModel.getVersionList();
+            let compilationModel = new CompilationModel();
+            compilationList = await compilationModel.getCompilationList();
 
             // 获取标准清单
             let stdBillLibListsModel = new STDBillLibListsModel();
-            billList = await stdBillLibListsModel.getBillList();
+            billList = await stdBillLibListsModel.getBillList(selectedCompilation._id);
 
             // 获取定额库
             let stdRationLibMapModel = new STDRationLibMapModel();
-            rationList = await stdRationLibMapModel.getRationLib();
+            rationList = await stdRationLibMapModel.getRationLib(selectedCompilation._id);
 
             // 获取对应的计价规则数据
-            [valuationData, valuationList] = await versionModel.getValuation(selectedVersion._id, valuationId, section);
+            [valuationData, valuationList] = await compilationModel.getValuation(selectedCompilation._id, valuationId, section);
             if (Object.keys(valuationData).length <= 0) {
                 throw '不存在数据';
             }
@@ -138,19 +137,18 @@ class VersionController extends BaseController {
         }
 
         let renderData = {
-            versionList: versionList,
+            compilationList: compilationList,
             billList: JSON.stringify(billList),
             rationList: JSON.stringify(rationList),
-            province: JSON.stringify(ProvinceList),
             engineeringList: EngineeringList,
-            selectedVersion: selectedVersion,
+            selectedCompilation: selectedCompilation,
             valuationData: valuationData,
             valuationList: valuationList,
             valuationId: valuationId,
             section: section,
             layout: 'users/views/layout/layout'
         };
-        response.render('users/views/version/add', renderData);
+        response.render('users/views/compilation/add', renderData);
     }
 
     /**
@@ -167,8 +165,8 @@ class VersionController extends BaseController {
                 throw 'id参数错误';
             }
 
-            let versionModel = new VersionModel();
-            let result = await versionModel.saveValuation(valuationId, request.body);
+            let compilationModel = new CompilationModel();
+            let result = await compilationModel.saveValuation(valuationId, request.body);
 
             if (!result) {
                 throw '保存失败';
@@ -191,15 +189,15 @@ class VersionController extends BaseController {
     async deleteValuation(request, response) {
         let id = request.params.id;
         let section = request.params.section;
-        let selectedVersion = request.session.selectedVersion;
+        let selectedCompilation = request.session.selectedCompilation;
 
         try {
             if (id === undefined || id === '' || section === undefined || section === '') {
                 throw '参数错误';
             }
 
-            let versionModel = new VersionModel();
-            let result = versionModel.deleteValuation(selectedVersion._id, id, section);
+            let compilationModel = new CompilationModel();
+            let result = compilationModel.deleteValuation(selectedCompilation._id, id, section);
 
             if (!result) {
                 throw '删除失败';
@@ -229,11 +227,11 @@ class VersionController extends BaseController {
             msg: ''
         };
         try {
-            let versionModel = new VersionModel();
-            let result = await versionModel.switchEnable(id, section, enable);
+            let compilationModel = new CompilationModel();
+            let result = await compilationModel.switchEnable(id, section, enable);
 
             if (!result) {
-                throw '新增版本失败';
+                throw '新增编办失败';
             }
         } catch (error) {
             console.log(error);
@@ -245,7 +243,7 @@ class VersionController extends BaseController {
     }
 
     /**
-     * 发布/取消版本
+     * 发布/取消编办
      *
      * @param {object} request
      * @param {object} response
@@ -261,11 +259,11 @@ class VersionController extends BaseController {
             msg: ''
         };
         try {
-            let versionModel = new VersionModel();
-            let result = await versionModel.release(id, release);
+            let compilationModel = new CompilationModel();
+            let result = await compilationModel.release(id, release);
 
             if (!result) {
-                throw '发布版本失败';
+                throw '发布编办失败';
             }
         } catch (error) {
             console.log(error);
@@ -277,13 +275,13 @@ class VersionController extends BaseController {
     }
 
     /**
-     * 新增版本操作
+     * 新增编办操作
      *
      * @param {object} request
      * @param {object} response
      * @return {void}
      */
-    async addVersion(request, response) {
+    async addCompilation(request, response) {
         let name = request.body.name;
         let responseData = {
             err: 0,
@@ -296,11 +294,11 @@ class VersionController extends BaseController {
                 creator: sessionManager.userID
             };
 
-            let versionModel = new VersionModel();
-            let result = await versionModel.add(insertData);
+            let compilationModel = new CompilationModel();
+            let result = await compilationModel.add(insertData);
 
             if (!result) {
-                throw '新增版本失败';
+                throw '新增编办失败';
             }
         } catch (error) {
             console.log(error);
@@ -313,4 +311,4 @@ class VersionController extends BaseController {
 
 }
 
-export default VersionController;
+export default CompilationController;

+ 28 - 28
modules/users/models/version_model.js

@@ -1,14 +1,14 @@
 /**
- * 版本管理业务逻辑模型
+ * 编办管理业务逻辑模型
  *
  * @author CaiAoLin
  * @date 2017/7/28
  * @version
  */
 import BaseModel from "../../common/base/base_model";
-import VersionSchema from "./schemas/version";
+import CompilationSchema from "./schemas/compilation";
 
-class VersionModel extends BaseModel {
+class CompilationModel extends BaseModel {
 
     /**
      * 允许的块
@@ -24,22 +24,22 @@ class VersionModel extends BaseModel {
      */
     constructor() {
         let parent = super();
-        parent.model = VersionSchema;
+        parent.model = CompilationSchema;
         parent.init();
     }
 
     /**
-     * 获取版本列表
+     * 获取编办列表
      *
      * @return {Promise}
      */
-    async getVersionList() {
+    async getCompilationList() {
         // 筛选字段
         let field = {_id: 1, name: 1, is_release: 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};
-        let versionData = await this.findDataByCondition({name: {$ne: ''}}, field, false);
+        let compilationData = await this.findDataByCondition({name: {$ne: ''}}, field, false);
 
-        return versionData === null ? [] : versionData;
+        return compilationData === null ? [] : compilationData;
     }
 
     /**
@@ -60,7 +60,7 @@ class VersionModel extends BaseModel {
     }
 
     /**
-     * 新增版本
+     * 新增编办
      *
      * @param {Object} data
      * @return {Promise}
@@ -87,8 +87,8 @@ class VersionModel extends BaseModel {
      */
     async addValuation(id, section, data) {
         let condition = {_id: id};
-        let versionData = await this.findDataByCondition(condition);
-        if (versionData === null || versionData.name === undefined) {
+        let compilationData = await this.findDataByCondition(condition);
+        if (compilationData === null || compilationData.name === undefined) {
             throw '没有找到对应的数据';
         }
 
@@ -198,31 +198,31 @@ class VersionModel extends BaseModel {
     /**
      * 获取计价规则数据
      *
-     * @param {String} versionId
+     * @param {String} compilationId
      * @param {String} id
      * @param {String} section
      * @return {Promise|Array}
      */
-    async getValuation(versionId, id, section) {
+    async getValuation(compilationId, id, section) {
         if (this.sectionList.indexOf(section) < 0) {
             throw '数据有误';
         }
-        let versionData = await this.findDataByCondition({_id: versionId});
-        if (Object.keys(versionData).length <= 0) {
-            throw '版本数据有误';
+        let compilationData = await this.findDataByCondition({_id: compilationId});
+        if (Object.keys(compilationData).length <= 0) {
+            throw '编办数据有误';
         }
         let result = {};
         let sectionString = section + '_valuation';
 
-        for(let valuation of versionData[sectionString]) {
+        for(let valuation of compilationData[sectionString]) {
             if (valuation._id.toString() === id) {
                 result = valuation;
                 break;
             }
         }
 
-        return [result, versionData[sectionString]];
-        /* 数据库获取版本
+        return [result, compilationData[sectionString]];
+        /* 数据库获取编办
         let condition = {_id: versionId};
         let childCondition = {};
         childCondition[sectionString] = {$elemMatch: {_id: id}};
@@ -236,13 +236,13 @@ class VersionModel extends BaseModel {
     /**
      * 删除计价规则
      *
-     * @param {String} versionId
+     * @param {String} compilationId
      * @param {String} valuationId
      * @param {String} section
      * @return {Promise}
      */
-    async deleteValuation(versionId, valuationId, section) {
-        let condition = {_id: versionId};
+    async deleteValuation(compilationId, valuationId, section) {
+        let condition = {_id: compilationId};
         let sectionString = section + '_valuation';
         let deleteData = {};
         deleteData[sectionString] = {_id: valuationId};
@@ -254,24 +254,24 @@ class VersionModel extends BaseModel {
     }
 
     /**
-     * 发布版本
+     * 发布编办
      *
      * @param {String} id
      * @param {Number} status
      * @return {Promise}
      */
     async release(id, status) {
-        // 如果是发布版本则需要判断配置的内容是否满足发布条件
+        // 如果是发布编办则需要判断配置的内容是否满足发布条件
         if (status) {
-            let versionData = await this.findDataByCondition({_id: id});
+            let compilationData = await this.findDataByCondition({_id: id});
             // 最少需要有一个计价规则存在
-            if (versionData.bill_valuation.length <= 0 && versionData.ration_valuation.length <= 0) {
+            if (compilationData.bill_valuation.length <= 0 && compilationData.ration_valuation.length <= 0) {
                 throw '至少需要一个计价规则';
             }
 
             // 判断是否全部禁止
             let hasEnable = false;
-            let valuationList = versionData.bill_valuation.concat(versionData.ration_valuation);
+            let valuationList = compilationData.bill_valuation.concat(compilationData.ration_valuation);
             for (let valuation of valuationList) {
                 if (valuation.enable) {
                     hasEnable = true;
@@ -293,4 +293,4 @@ class VersionModel extends BaseModel {
 
 }
 
-export default VersionModel;
+export default CompilationModel;

+ 2 - 2
modules/users/models/schemas/version.js

@@ -1,5 +1,5 @@
 /**
- * 版本管理数据模型
+ * 编办管理数据模型
  *
  * @author CaiAoLin
  * @date 2017/7/28
@@ -8,7 +8,7 @@
 import mongoose from "mongoose";
 
 let Schema = mongoose.Schema;
-let collectionName = 'version';
+let collectionName = 'compilation';
 let childrenSchema = new Schema({
     // 计价名称
     name: String,

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

@@ -0,0 +1,27 @@
+/**
+ * 版本管理路由
+ *
+ * @author CaiAoLin
+ * @date 2017/7/28
+ * @version
+ */
+import Express from "express";
+import CompilationController from "../controllers/compilation_controller";
+
+const router = Express.Router();
+const compilationController = new CompilationController();
+
+module.exports = function (app) {
+    // action定义区域
+    router.get('/', compilationController.auth, compilationController.init, compilationController.index);
+    router.get('/valuation/:section/:id', compilationController.auth, compilationController.init, compilationController.editValuation);
+    router.get('/valuation/:section/delete/:id', compilationController.auth, compilationController.init, compilationController.deleteValuation);
+
+    router.post('/release', compilationController.auth, compilationController.init, compilationController.release);
+    router.post('/add', compilationController.auth, compilationController.init, compilationController.addCompilation);
+    router.post('/add-valuation', compilationController.auth, compilationController.init, compilationController.addValuation);
+    router.post('/save-valuation', compilationController.auth, compilationController.init, compilationController.saveValuation);
+    router.post('/valuation/:section/enable', compilationController.auth, compilationController.init, compilationController.enableSwitch);
+
+    app.use("/compilation", router);
+};

+ 0 - 27
modules/users/routes/version_route.js

@@ -1,27 +0,0 @@
-/**
- * 版本管理路由
- *
- * @author CaiAoLin
- * @date 2017/7/28
- * @version
- */
-import Express from "express";
-import VersionController from "../controllers/version_controller";
-
-const router = Express.Router();
-const versionController = new VersionController();
-
-module.exports =function (app) {
-    // action定义区域
-    router.get('/', versionController.auth, versionController.init, versionController.index);
-    router.get('/valuation/:section/:id', versionController.auth, versionController.init, versionController.editValuation);
-    router.get('/valuation/:section/delete/:id', versionController.auth, versionController.init, versionController.deleteValuation);
-
-    router.post('/release', versionController.auth, versionController.init, versionController.release);
-    router.post('/add', versionController.auth, versionController.init, versionController.addVersion);
-    router.post('/add-valuation', versionController.auth, versionController.init, versionController.addValuation);
-    router.post('/save-valuation', versionController.auth, versionController.init, versionController.saveValuation);
-    router.post('/valuation/:section/enable', versionController.auth, versionController.init, versionController.enableSwitch);
-
-    app.use("/version", router);
-};

+ 34 - 60
web/users/js/version.js

@@ -1,5 +1,5 @@
 /**
- * 版本管理相关js
+ * 编办管理相关js
  *
  * @author CaiAoLin
  * @date 2017/7/28
@@ -9,11 +9,11 @@ $(document).ready(function() {
     let isAdding = false;
     let model = '';
     let section = 'bill';
-    let id = $("#version-id").val();
+    let id = $("#compilation-id").val();
 
     // 计价规则页面初始化数据
     if ($("#section").length > 0) {
-        initVersion();
+        initCompilation();
     }
 
     // 计价类型选择
@@ -21,14 +21,14 @@ $(document).ready(function() {
         section = $(this).attr("aria-controls");
     });
 
-    // 新增版本
-    $("#add-version").click(function() {
+    // 新增编办
+    $("#add-compilation").click(function() {
         try {
             let [name, standardBill, rationLib, standardBillString, rationLibString] = getAndValidData(model);
 
-            let url = '/version/add';
+            let url = '/compilation/add';
             if (model === 'all') {
-                // 新增版本操作
+                // 新增编办操作
                 $.ajax({
                     url: url,
                     type: 'post',
@@ -76,7 +76,7 @@ $(document).ready(function() {
                 let tmpHtml = '<p class="form-control-static">' + removeHtml + addLib.name +
                     '<input type="hidden" data-id="'+ addLib.id +'" name=\'' + model + '_lib\' value=\'' + JSON.stringify(addLib) + '\'>' + '</p>';
                 $("." + model + "-list").append(tmpHtml);
-                $('#addversion').modal('hide');
+                $('#addcompilation').modal('hide');
             }
 
         } catch (error) {
@@ -96,7 +96,7 @@ $(document).ready(function() {
             }
 
             $.ajax({
-                url: '/version/add-valuation',
+                url: '/compilation/add-valuation',
                 type: 'post',
                 data: {name: name, id: id, section: section},
                 error: function() {
@@ -121,58 +121,31 @@ $(document).ready(function() {
         }
     });
 
-    // 选择省份后读取数据
-    $("select[name='standard_bill_province'],select[name='ration_lib_province']").change(function() {
-        let name = $(this).attr('name');
-
-        let billListData = billList === undefined ? [] : JSON.parse(billList);
-        let rationLibData = rationList === undefined ? [] : JSON.parse(rationList);
-        if (billListData.length <= 0 || rationLibData.length <= 0) {
-            return false;
-        }
-        let sourceData = name === 'standard_bill_province' ? billListData : rationLibData;
-        let selectedId = $(this).val();
-        if (sourceData[selectedId] === undefined) {
-            return false;
-        }
-        let defaultString = name === 'standard_bill_province' ? '请选择标准清单' : '请选择定额库';
-        let html = '<option value="">' + defaultString + '</option>';
-        for(let tmp of sourceData[selectedId]) {
-            let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
-            html += tmpHtml;
-        }
-
-        // 渲染
-        let targetSelector = name === 'standard_bill_province' ? $("select[name='standard_bill']") : $("select[name='ration_lib']");
-        targetSelector.children('option').remove();
-        targetSelector.html(html);
-    });
-
     // 添加
-    $(".add-version").click(function() {
+    $(".add-compilation").click(function() {
         model = $(this).data('model');
         switch (model) {
             case 'all':
                 $("#name-area").show();
                 $("#bill-area").hide();
                 $("#ration-area").hide();
-                $("#add-version-title").text('添加新版本');
+                $("#add-compilation-title").text('添加新编办');
                 break;
             case 'bill':
                 $("#name-area").hide();
                 $("#bill-area").show();
                 $("#ration-area").hide();
-                $("#add-version-title").text('添加标准清单');
+                $("#add-compilation-title").text('添加标准清单');
                 break;
             case 'ration':
                 $("#name-area").hide();
                 $("#bill-area").hide();
                 $("#ration-area").show();
-                $("#add-version-title").text('添加定额库');
+                $("#add-compilation-title").text('添加定额库');
                 break;
         }
 
-        $("#addversion").modal('show');
+        $("#addcompilation").modal('show');
     });
 
     // 保存计价规则
@@ -195,7 +168,7 @@ $(document).ready(function() {
             return false;
         }
         $.ajax({
-            url: '/version/valuation/' + section + '/enable',
+            url: '/compilation/valuation/' + section + '/enable',
             type: 'post',
             dataType: "json",
             data: {id: id, enable: goingChangeStatus},
@@ -216,7 +189,7 @@ $(document).ready(function() {
         });
     });
 
-    // 发布版本
+    // 发布编办
     $("#release").click(function() {
         let id = $(this).data("id");
         let status = $(this).data("status");
@@ -226,7 +199,7 @@ $(document).ready(function() {
         }
 
         $.ajax({
-            url: '/version/release',
+            url: '/compilation/release',
             type: 'post',
             data: {id: id, status: status},
             dataType: "json",
@@ -256,28 +229,29 @@ $(document).ready(function() {
  *
  * @return {void|boolean}
  */
-function initVersion() {
-    if (province === undefined) {
-        alert('初始化失败!');
-        return false;
-    }
+function initCompilation() {
+    let billListData = billList === undefined ? [] : JSON.parse(billList);
+    let rationLibData = rationList === undefined ? [] : JSON.parse(rationList);
 
-    province = JSON.parse(province);
-    if (province.length <= 0) {
-        alert('省份数据加载失败!');
+    if (billListData.length <= 0 || rationLibData.length <= 0) {
         return false;
     }
-
-    let billProvinceElement = $("select[name='standard_bill_province']");
-    let rationProvinceElement = $("select[name='ration_lib_province']");
+    // 标准清单
     let html = '';
-    for (let tmp of province) {
+    for(let tmp of billListData) {
+        let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
+        html += tmpHtml;
+    }
+    $("select[name='standard_bill']").children("option").first().after(html);
+
+    // 定额库
+    html = '';
+    for(let tmp of rationLibData) {
         let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
+    $("select[name='ration_lib']").children("option").first().after(html);
 
-    billProvinceElement.children('option').first().after(html);
-    rationProvinceElement.children('option').first().after(html);
 }
 
 /**
@@ -287,12 +261,12 @@ function initVersion() {
  * @return {Array}
  */
 function getAndValidData(model) {
-    let name = $("input[name='version_name']").val();
+    let name = $("input[name='compilation_name']").val();
     let standardBill = $("select[name='standard_bill']").children("option:selected").val();
     let rationLib = $("select[name='ration_lib']").children("option:selected").val();
 
     if (name === '' && model === 'all') {
-        throw '版本名字不能为空';
+        throw '编办名字不能为空';
     }
 
     if ( model === 'bill' && (standardBill === '' || standardBill === undefined)) {

+ 13 - 8
web/users/views/version/add.html

@@ -2,19 +2,25 @@
 <div class="panel-content">
     <div class="panel-title">
         <div class="title-main">
-            <h2>重庆版<span class="text-muted pull-right">已发布 2017-08-04</span><a href="javascript:void(0);" class="btn btn-primary btn-sm pull-right" id="save">发布版本</a></h2>
+            <h2>
+                <%= selectedCompilation.name %>
+                <% if(selectedCompilation.is_release) {%>
+                <span class="text-muted" style="margin-left: 5px;">已发布 <%= moment(selectedCompilation.update_time).format('YYYY-MM-DD')%></span>
+                <% } %>
+                <a href="javascript:void(0);" data-id="<%= selectedCompilation._id %>" data-status="<%= selectedCompilation.is_release ? 0 : 1 %>" class="btn btn-primary btn-sm pull-right" id="release"><% if(selectedCompilation.is_release) {%>取消<% }else{ %>发布<% } %>版本</a>
+            </h2>
         </div>
     </div>
     <div class="content-wrap">
         <div class="c-header" style="padding:0">
             <ul class="nav nav-tabs">
                 <% valuationList.forEach(function(valuation) { %>
-                <li role="presentation" <% if (valuation._id.toString() === valuationId) { %>class="active"<% } %>><a href="/version/valuation/<%= section %>/<%= valuation._id %>"><%= valuation.name %></a></li>
+                <li role="presentation" <% if (valuation._id.toString() === valuationId) { %>class="active"<% } %>><a href="/compilation/valuation/<%= section %>/<%= valuation._id %>"><%= valuation.name %></a></li>
                 <% }) %>
             </ul>
         </div>
         <div class="c-body">
-            <form method="post" action="/version/save-valuation" enctype="application/x-www-form-urlencoded21">
+            <form method="post" action="/compilation/save-valuation" enctype="application/x-www-form-urlencoded21">
                 <div class=" row">
                     <div class="col-md-4">
                         <div class="form-group">
@@ -22,7 +28,7 @@
                             <div class="input-group">
                                 <input type="text" class="form-control" value="<%= valuationData.name %>" name="name">
                                 <span class="input-group-btn">
-                                     <button class="btn btn-default" type="button" id="save-valuation">保存</button>
+                                     <button class="btn btn-default" type="button" id="save-valuation">保存全部</button>
                                 </span>
                             </div>
                         </div>
@@ -58,7 +64,7 @@
                                 <% }) %>
                                 <% } %>
                             </div>
-                            <a class="btn btn-link btn-sm add-version" href="javascript:void(0)" data-model="bill">添加</a>
+                            <a class="btn btn-link btn-sm add-compilation" href="javascript:void(0)" data-model="bill">添加</a>
                         </div>
                         <div class="form-group">
                             <label>定额库</label>
@@ -75,7 +81,7 @@
                                 <% }) %>
                                 <% } %>
                             </div>
-                            <a href="#" class="btn btn-link btn-sm add-version" data-model="ration">添加</a>
+                            <a href="#" class="btn btn-link btn-sm add-compilation" data-model="ration">添加</a>
                         </div>
                     </div>
                     <div class="col-md-8">
@@ -92,8 +98,7 @@
     </div>
 </div>
 <script type="text/javascript">
-    let province = '<%- province %>';
     let billList = '<%- billList %>';
     let rationList = '<%- rationList %>';
 </script>
-<script type="text/javascript" src="/web/users/js/version.js"></script>
+<script type="text/javascript" src="/web/users/js/compilation.js"></script>

+ 16 - 0
web/users/views/compilation/common.html

@@ -0,0 +1,16 @@
+<div class="panel-sidebar">
+    <div class="panel-title">
+        <div class="title-bar">
+            <h2><a class="pull-right add-compilation" title="添加新编办" href="javascript:void(0)" data-model="all"><span class="glyphicon glyphicon-plus"></span></a>编办管理</h2>
+        </div>
+    </div>
+    <div class="scrollbar-auto">
+        <div class="nav-box">
+            <ul class="nav-list list-unstyled" id="version-select">
+                <% compilationList.forEach(function (compilation){ %>
+                <li <% if(selectedCompilation._id.toString() === compilation._id.toString()) { %>class="active"<% } %>><a href="/compilation?id=<%= compilation._id %>"><span><%= compilation.name %></span><% if (!compilation.is_release) { %><span class="text-muted">(未发布)</span><% } %></a></li>
+                <% }) %>
+            </ul>
+        </div>
+    </div>
+</div>

+ 15 - 15
web/users/views/version/index.html

@@ -1,14 +1,14 @@
 <%include ./common.html %>
 <div class="panel-content">
-    <% if(Object.keys(selectedVersion).length > 0) {%>
+    <% if(Object.keys(selectedCompilation).length > 0) {%>
     <div class="panel-title">
         <div class="title-main">
             <h2>
-                <%= selectedVersion.name %>
-                <% if(selectedVersion.is_release) {%>
-                <span class="text-muted" style="margin-left: 5px;">已发布 <%= moment(selectedVersion.update_time).format('YYYY-MM-DD')%></span>
+                <%= selectedCompilation.name %>
+                <% if(selectedCompilation.is_release) {%>
+                <span class="text-muted" style="margin-left: 5px;">已发布 <%= moment(selectedCompilation.update_time).format('YYYY-MM-DD')%></span>
                 <% } %>
-                <a href="javascript:void(0);" data-id="<%= selectedVersion._id %>" data-status="<%= selectedVersion.is_release ? 0 : 1 %>" class="btn btn-primary btn-sm pull-right" id="release"><% if(selectedVersion.is_release) {%>取消<% }else{ %>发布<% } %>版本</a>
+                <a href="javascript:void(0);" data-id="<%= selectedCompilation._id %>" data-status="<%= selectedCompilation.is_release ? 0 : 1 %>" class="btn btn-primary btn-sm pull-right" id="release"><% if(selectedCompilation.is_release) {%>取消<% }else{ %>发布<% } %>编办</a>
             </h2>
         </div>
     </div>
@@ -31,8 +31,8 @@
                     </tr>
                     </thead>
                     <tbody>
-                    <% if (selectedVersion.bill_valuation.length > 0) { %>
-                    <% selectedVersion.bill_valuation.forEach(function(bill) { %>
+                    <% if (selectedCompilation.bill_valuation.length > 0) { %>
+                    <% selectedCompilation.bill_valuation.forEach(function(bill) { %>
                     <tr>
                         <td><%= bill.name %></td>
                         <td>
@@ -49,8 +49,8 @@
                             <% } %>
                         </td>
                         <td>
-                            <a href="/version/valuation/bill/<%= bill.id %>" class="btn btn-sm">编辑</a>
-                            <a href="/version/valuation/bill/delete/<%= bill.id %>" class="btn btn-sm text-danger">删除</a>
+                            <a href="/compilation/valuation/bill/<%= bill.id %>" class="btn btn-sm">编辑</a>
+                            <a href="/compilation/valuation/bill/delete/<%= bill.id %>" class="btn btn-sm text-danger">删除</a>
                         </td>
                     </tr>
                     <% }) %>
@@ -69,8 +69,8 @@
                     </tr>
                     </thead>
                     <tbody>
-                    <% if (selectedVersion.ration_valuation.length > 0) { %>
-                    <% selectedVersion.ration_valuation.forEach(function(ration) { %>
+                    <% if (selectedCompilation.ration_valuation.length > 0) { %>
+                    <% selectedCompilation.ration_valuation.forEach(function(ration) { %>
                     <tr>
                         <td><%= ration.name %></td>
                         <td>
@@ -87,8 +87,8 @@
                             <% } %>
                         </td>
                         <td>
-                            <a href="/version/valuation/ration/<%= ration.id %>" class="btn btn-sm">编辑</a>
-                            <a href="/version/valuation/ration/delete/<%= ration.id %>" class="btn btn-sm text-danger">删除</a>
+                            <a href="/compilation/valuation/ration/<%= ration.id %>" class="btn btn-sm">编辑</a>
+                            <a href="/compilation/valuation/ration/delete/<%= ration.id %>" class="btn btn-sm text-danger">删除</a>
                         </td>
                     </tr>
                     <% }) %>
@@ -97,8 +97,8 @@
                 </table>
             </div>
         </div>
-        <input type="hidden" name="id" value="<%= selectedVersion._id %>" id="version-id">
+        <input type="hidden" name="id" value="<%= selectedCompilation._id %>" id="compilation-id">
         <% } %>
 	</div>
 </div>
-<script type="text/javascript" src="/web/users/js/version.js"></script>
+<script type="text/javascript" src="/web/users/js/compilation.js"></script>

+ 8 - 18
web/users/views/version/modal.html

@@ -1,25 +1,20 @@
-<!-- 弹窗新增版本 -->
-<div class="modal fade" id="addversion" tabindex="-1" role="dialog">
+<!-- 弹窗新增编办 -->
+<div class="modal fade" id="addcompilation" tabindex="-1" role="dialog">
     <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">&times;</span></button>
-                <h4 class="modal-title" id="add-version-title">添加新版本</h4>
+                <h4 class="modal-title" id="add-compilation-title">添加新编办</h4>
             </div>
             <div class="modal-body">
                 <div class="form-group" id="name-area">
-                    <label>版本名称</label>
-                    <input class="form-control" placeholder="" name="version_name">
+                    <label>编办名称</label>
+                    <input class="form-control" placeholder="" name="compilation_name">
                 </div>
                 <div class="form-group" id="bill-area">
                     <label>标准清单</label>
                     <div class="row">
-                        <div class="col-xs-4">
-                            <select class="form-control" name="standard_bill_province">
-                                <option value="">请选择省份</option>
-                            </select>
-                        </div>
-                        <div class="col-xs-8">
+                        <div class="col-xs-12">
                             <select class="form-control" name="standard_bill">
                                 <option value="">请选择标准清单</option>
                             </select>
@@ -29,12 +24,7 @@
                 <div class="form-group" id="ration-area">
                     <label>定额库</label>
                     <div class="row">
-                        <div class="col-xs-4">
-                            <select class="form-control" name="ration_lib_province">
-                                <option value="">请选择省份</option>
-                            </select>
-                        </div>
-                        <div class="col-xs-8">
+                        <div class="col-xs-12">
                             <select class="form-control" name="ration_lib">
                                 <option value="">请选择定额库</option>
                             </select>
@@ -44,7 +34,7 @@
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
-                <button type="button" class="btn btn-primary" id="add-version">确定添加</button>
+                <button type="button" class="btn btn-primary" id="add-compilation">确定添加</button>
             </div>
         </div>
     </div>

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

@@ -98,5 +98,5 @@
         </div>
     </div>
 </div>
-<%include ../version/modal.html %>
+<%include ../compilation/modal.html %>
 </body>

+ 0 - 16
web/users/views/version/common.html

@@ -1,16 +0,0 @@
-<div class="panel-sidebar">
-    <div class="panel-title">
-        <div class="title-bar">
-            <h2><a class="pull-right add-version" title="添加新版本" href="javascript:void(0)" data-model="all"><span class="glyphicon glyphicon-plus"></span></a>版本管理</h2>
-        </div>
-    </div>
-    <div class="scrollbar-auto">
-        <div class="nav-box">
-            <ul class="nav-list list-unstyled" id="version-select">
-                <% versionList.forEach(function (version){ %>
-                <li <% if(selectedVersion._id.toString() === version._id.toString()) { %>class="active"<% } %>><a href="/version?id=<%= version._id %>"><span><%= version.name %></span><% if (!version.is_release) { %><span class="text-muted">(未发布)</span><% } %></a></li>
-                <% }) %>
-            </ul>
-        </div>
-    </div>
-</div>