zhongzewei 6 лет назад
Родитель
Сommit
1ee0139d60

+ 13 - 1
modules/bills_template_lib/controllers/bills_template_controller.js

@@ -9,6 +9,7 @@ import BaseController from "../../common/base/base_controller";
 import billsTemplateFacade from "../facade/bills_template_facade";
 import {default as BillsFixedFlagConst, List as BillsFixedFlagList} from "../../common/const/bills_fixed.js";
 import {default as BillsTypeFlagConst, List as BillsTypeFlagList} from "../../common/const/bills_type.js";
+import CompilationModel from '../../users/models/compilation_model';
 let config = require("../../../config/config.js");
 
 class BillsTemplateController extends BaseController {
@@ -21,12 +22,23 @@ class BillsTemplateController extends BaseController {
      * @return {void}
      */
     async main(request, response) {
-        let templateLibs = await billsTemplateFacade.getAllLibs();
+        let filter = request.query.filter ? {compilationId: request.query.filter} : null;
+        let templateLibs = await billsTemplateFacade.getAllLibs(filter);
+        let compilationModel = new CompilationModel();
+        let compilationList = await compilationModel.getCompilationList({_id: 1, name: 1});
+        compilationList.unshift({_id: 'all', name: '所有'});
+        let activeCompilation = compilationList.find(compilation => compilation._id.toString() === request.query.filter);
+        if (activeCompilation) {
+            activeCompilation.active = 'active';
+        } else {
+            compilationList[0].active = 'active'
+        }
         let randerData = {
             title:'清单模板',
             userAccount: request.session.managerData.username,
             userID: request.session.managerData.userID,
             templateLibs:templateLibs,
+            compilationList: compilationList,
             layout: 'maintain/common/html/layout',
             LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
         };

+ 4 - 1
modules/bills_template_lib/facade/bills_template_facade.js

@@ -62,7 +62,10 @@ async function getLibByID(ID) {
     return await billTemplateLibModel.findOne({ID:ID});
 }
 
-async function getAllLibs() {
+async function getAllLibs(filter = null) {
+    if (filter) {
+        return await billTemplateLibModel.find(filter);
+    }
     return await billTemplateLibModel.find();
 }
 

+ 13 - 1
modules/calc_program_lib/controllers/calc_program_controller.js

@@ -4,15 +4,27 @@
 import BaseController from "../../common/base/base_controller";
 let config = require("../../../config/config.js");
 import calcProgramFacade from "../facade/calc_program_facade";
+import CompilationModel from '../../users/models/compilation_model';
 
 class CalcProgramController extends BaseController {
     async main(request, response) {
-        let calcProgramLibs = await calcProgramFacade.findByCondition({}, {templates: 0}, false);
+        let compilationModel = new CompilationModel();
+        let compilationList = await compilationModel.getCompilationList({_id: 1, name: 1});
+        compilationList.unshift({_id: 'all', name: '所有'});
+        let activeCompilation = compilationList.find(compilation => compilation._id.toString() === request.query.filter);
+        if (activeCompilation) {
+            activeCompilation.active = 'active';
+        } else {
+            compilationList[0].active = 'active'
+        }
+        let filter = request.query.filter ? {compilationId: request.query.filter} : {};
+        let calcProgramLibs = await calcProgramFacade.findByCondition(filter, {templates: 0}, false);
         let randerData = {
             title: '计算程序模板库',
             userAccount: request.session.managerData.username,
             userID: request.session.managerData.userID,
             calcProgramLibs: calcProgramLibs,
+            compilationList: compilationList,
             layout: 'maintain/common/html/layout'
         };
         response.render("maintain/calc_program_lib/html/main", randerData);

+ 13 - 1
modules/fee_rate_lib/controllers/fee_rate_controller.js

@@ -4,15 +4,27 @@
 import BaseController from "../../common/base/base_controller";
 let config = require("../../../config/config.js");
 import feeRateFacade from "../facade/fee_rate_facade";
+import CompilationModel from '../../users/models/compilation_model';
 
 class FeeRateController extends BaseController{
     async main(request, response) {
-        let feeRateLibs = await feeRateFacade.findByCondition({},{rates:0},false);
+        let compilationModel = new CompilationModel();
+        let compilationList = await compilationModel.getCompilationList({_id: 1, name: 1});
+        compilationList.unshift({_id: 'all', name: '所有'});
+        let activeCompilation = compilationList.find(compilation => compilation._id.toString() === request.query.filter);
+        if (activeCompilation) {
+            activeCompilation.active = 'active';
+        } else {
+            compilationList[0].active = 'active'
+        }
+        let filter = request.query.filter ? {compilationId: request.query.filter} : {};
+        let feeRateLibs = await feeRateFacade.findByCondition(filter,{rates:0},false);
         let randerData = {
             title:'费率标准库',
             userAccount: request.session.managerData.username,
             userID: request.session.managerData.userID,
             feeRateLibs:feeRateLibs,
+            compilationList: compilationList,
             layout: 'maintain/common/html/layout'
         };
         response.render("maintain/fee_rate_lib/html/main", randerData);

+ 18 - 1
modules/ration_repository/controllers/repository_views_controller.js

@@ -2,15 +2,32 @@
  * Created by Zhong on 2017/8/3.
  */
 import BaseController from "../../common/base/base_controller";
+import CompilationModel from '../../users/models/compilation_model';
 let config = require("../../../config/config.js");
 import mongoose from 'mongoose';
 const compilationModel = mongoose.model('compilation');
 const rationLibModel = mongoose.model('std_ration_lib_map');
 const fs = require('fs');
 class ViewsController extends BaseController{
-    redirectMain(req, res){
+    async redirectMain(req, res){
+        let filter = req.query.filter ? {compilationId: req.query.filter} : null;
+        let allLibs = await rationLibModel.find({}, {_id: 0, recentOpr: 0}),
+            rationLibs = allLibs.filter(lib => filter && lib.compilationId === filter.compilationId || !filter),
+            allNames = allLibs.map(lib => lib.dispName);
+        let compilationModel = new CompilationModel();
+        let compilationList = await compilationModel.getCompilationList({_id: 1, name: 1});
+        compilationList.unshift({_id: 'all', name: '所有'});
+        let activeCompilation = compilationList.find(compilation => compilation._id.toString() === req.query.filter);
+        if (activeCompilation) {
+            activeCompilation.active = 'active';
+        } else {
+            compilationList[0].active = 'active'
+        }
         res.render('maintain/ration_repository/main.html',
             {
+                allNames: allNames,
+                rationLibs: rationLibs,
+                compilationList: compilationList,
                 userAccount: req.session.managerData.username,
                 userID: req.session.managerData.userID
             });

+ 1 - 1
modules/ration_repository/models/repository_map.js

@@ -177,7 +177,7 @@ rationRepositoryDao.prototype.getRationLib = function(libId, callback) {
 };
 
 rationRepositoryDao.prototype.getDisplayRationLibs = function(callback) {
-    rationRepository.find({"deleted": false}, function(err, data){
+    rationRepository.find(filter, function(err, data){
         if (err) {
             callback( 'Error', null);
         } else {

+ 14 - 0
web/maintain/bill_template_lib/html/main.html

@@ -2,6 +2,20 @@
     <div class="content">
         <div class="container-fluid">
             <div class="row">
+                <div class="col-md-2">
+                    <div class="list-group mt-3">
+                        <% for (let compilation of compilationList) { %>
+                        <% if (compilation._id === 'all') { %>
+                        <a href="/billsTemplate/main" class="list-group-item list-group-item-action <%= compilation.active %>">
+                            所有
+                        </a>
+                        <% } else { %>
+                        <a id="<%= compilation._id %>" href="/billsTemplate/main/?filter=<%= compilation._id %>" class="list-group-item list-group-item-action <%= compilation.active %>">
+                            <%= compilation.name %>
+                        </a>
+                        <% }} %>
+                    </div>
+                </div>
                 <div class="col-md-8">
                     <div class="warp-p2 mt-3">
                         <table class="table table-hover table-bordered">

+ 14 - 0
web/maintain/calc_program_lib/html/main.html

@@ -2,6 +2,20 @@
     <div class="content">
         <div class="container-fluid">
             <div class="row">
+                <div class="col-md-2">
+                    <div class="list-group mt-3">
+                        <% for (let compilation of compilationList) { %>
+                        <% if (compilation._id === 'all') { %>
+                        <a href="/calcProgram/main" class="list-group-item list-group-item-action <%= compilation.active %>">
+                            所有
+                        </a>
+                        <% } else { %>
+                        <a id="<%= compilation._id %>" href="/calcProgram/main/?filter=<%= compilation._id %>" class="list-group-item list-group-item-action <%= compilation.active %>">
+                            <%= compilation.name %>
+                        </a>
+                        <% }} %>
+                    </div>
+                </div>
                 <div class="col-md-8">
                     <div class="warp-p2 mt-3">
                         <table class="table table-hover table-bordered">

+ 14 - 0
web/maintain/fee_rate_lib/html/main.html

@@ -2,6 +2,20 @@
     <div class="content">
         <div class="container-fluid">
             <div class="row">
+                <div class="col-md-2">
+                <div class="list-group mt-3">
+                    <% for (let compilation of compilationList) { %>
+                    <% if (compilation._id === 'all') { %>
+                    <a href="/feeRate/main" class="list-group-item list-group-item-action <%= compilation.active %>">
+                        所有
+                    </a>
+                    <% } else { %>
+                    <a id="<%= compilation._id %>" href="/feeRate/main?filter=<%= compilation._id %>" class="list-group-item list-group-item-action <%= compilation.active %>">
+                        <%= compilation.name %>
+                    </a>
+                    <% }} %>
+                </div>
+            </div>
                 <div class="col-md-8">
                     <div class="warp-p2 mt-3">
                         <table class="table table-hover table-bordered">

+ 130 - 200
web/maintain/ration_repository/js/main.js

@@ -3,7 +3,6 @@
  */
 
 $(function () {
-    let dispNameArr;
     let preDeleteId = null;
     let deleteCount = 0;
     let selCompilationId,
@@ -11,128 +10,125 @@ $(function () {
     $('#del').on('hidden.bs.modal', function () {
         deleteCount = 0;
     });
-    getAllRationLib(function (dispNames) {
-        dispNameArr = dispNames;
-        //添加
-        $('#addBtn').click(function () {
-            let compilationName = $('#compilationSels option:selected').text();
-            let compilationId = $('#compilationSels option:selected').val();
-            let gljLibName = $('#gljLibSels option:selected').text();
-            let gljLibId = $('#gljLibSels option:selected').val();
-            let libName = $('#libNameTxt').val();
-            let libCode = $('#libCode').val().trim();
-            if(libName.trim().length === 0){
-                alert('名称不可为空!');
-                $('#libNameTxt').val('')
-            } else if (!libCode) {
-                alert('定额编号不可为空');
-                $('#libCode').val('');
-            } else if(dispNames.indexOf(libName) !== -1){
-                alert('此定额库已存在!');
-                $('#libNameTxt').val('')
-            } else if(compilationName.trim().length === 0){
-                alert('编办不可为空!');
-            } else if(gljLibName.trim().length === 0){
-                alert("请选择工料机库!");
-            } else{
-                let newRationLib = {};
-                newRationLib.dispName = libName;
-                newRationLib.libCode = libCode; //定额编号,标准数据导出xml需要
-                newRationLib.compilationId = compilationId;
-                newRationLib.compilationName = compilationName;
-                newRationLib.gljLib = gljLibId;
-                newRationLib.creator = userAccount;
-                newRationLib.appType = "建筑";
-                $('#libNameTxt').val('');
-                createRationLib(newRationLib, dispNameArr);
-            }
-        });
-        //重命名
-        $("#showArea").on("click", "[data-target = '#edit']", function(){
-            let renameId = $(this).parent().parent().attr("id");
-            $('#renameText').val($(this).parent().parent().find('td:first-child').text());
-            $('#renameCode').val($(this).parent().parent().find('td:eq(1)').text());
-            $("#renameA").attr("renameId", renameId);
-        });
-        $("#renameA").click(function(){
-            let newName = $("#renameText").val();
-            let newLibCode = $('#renameCode').val().trim();
-            let libId = $(this).attr("renameId");
-            let jqSel = "#" + libId + " td:first" + " a";
-            let orgName = $(jqSel).text();
-            let filterName = dispNameArr.filter(function (v) {
-                return v === newName;
-            });
-            if(newName.trim().length === 0){
-                alert("名称不可为空!");
-                $("#renameText").val('');
-            } else if (!newLibCode) {
-                alert('定额编号不可为空!');
-                $('#renameCode').val('');
-            } else if(filterName.length > 0 && newName !== orgName){
-                alert("该定额库已存在!");
-                $("#renameText").val('');
-            } else{
-                renameRationLib({ID: libId, newName: newName, orgName: orgName, newLibCode: newLibCode}, dispNameArr);
-            }
-        });
-        $('#edit').on('shown.bs.modal', function () {
-            setTimeout(function () {
-                $('#renameText').focus();
-            }, 100);
-        });
-
-        $('#add').on('shown.bs.modal', function () {
-            setTimeout(function () {
-                $('#libNameTxt').focus();
-            }, 100);
-        });
-        $('#add').on('hidden.bs.modal', function () {
+    //添加
+    $('#addBtn').click(function () {
+        let compilationName = $('#compilationSels option:selected').text();
+        let compilationId = $('#compilationSels option:selected').val();
+        let gljLibName = $('#gljLibSels option:selected').text();
+        let gljLibId = $('#gljLibSels option:selected').val();
+        let libName = $('#libNameTxt').val();
+        let libCode = $('#libCode').val().trim();
+        if(libName.trim().length === 0){
+            alert('名称不可为空!');
+            $('#libNameTxt').val('')
+        } else if (!libCode) {
+            alert('定额编号不可为空');
+            $('#libCode').val('');
+        } else if(allNames.indexOf(libName) !== -1){
+            alert('此定额库已存在!');
+            $('#libNameTxt').val('')
+        } else if(compilationName.trim().length === 0){
+            alert('编办不可为空!');
+        } else if(gljLibName.trim().length === 0){
+            alert("请选择工料机库!");
+        } else{
+            let newRationLib = {};
+            newRationLib.dispName = libName;
+            newRationLib.libCode = libCode; //定额编号,标准数据导出xml需要
+            newRationLib.compilationId = compilationId;
+            newRationLib.compilationName = compilationName;
+            newRationLib.gljLib = gljLibId;
+            newRationLib.creator = userAccount;
+            newRationLib.appType = "建筑";
             $('#libNameTxt').val('');
+            createRationLib(newRationLib);
+        }
+    });
+    //重命名
+    $("#showArea").on("click", "[data-target = '#edit']", function(){
+        let renameId = $(this).parent().parent().attr("id");
+        $('#renameText').val($(this).parent().parent().find('td:first-child').text());
+        $('#renameCode').val($(this).parent().parent().find('td:eq(1)').text());
+        $("#renameA").attr("renameId", renameId);
+    });
+    $("#renameA").click(function(){
+        let newName = $("#renameText").val();
+        let newLibCode = $('#renameCode').val().trim();
+        let libId = $(this).attr("renameId");
+        let jqSel = "#" + libId + " td:first" + " a";
+        let orgName = $(jqSel).text();
+        let filterName = allNames.filter(function (v) {
+            return v === newName;
         });
-        //删除
-        $("#showArea").on("click", "[data-target = '#del']", function(){
-            let deleteId = $(this).parent().parent().attr("id");
-            $("#deleteA").attr("deleteId", deleteId);
-            let delLibName = $(`#${deleteId}`).find('td:first').text();
-            $('#del').find('.modal-body h5').text(`准备删除 “${delLibName}”,会导致已引用此库的地方出错,确定要删除吗?`);
-        });
-        $("#deleteA").click(function(){
-            let deleteId = $(this).attr("deleteId");
-            if(preDeleteId && preDeleteId !== deleteId){
-                deleteCount = 0;
-            }
-            preDeleteId = deleteId;
-            deleteCount++;
-            let jqSel = "#" + deleteId + " td:first" + " a";
-            let libName = $(jqSel).text();
-            if(deleteCount === 3){
-                deleteCount = 0;
-                removeRationLib({libId: deleteId, libName: libName}, dispNameArr);
-                $('#del').modal('hide');
-            }
-        });
-        //全部计算
-        $("#showArea").on("click", "[data-target = '#reCalcAll']", function(){
-            let recalcId = $(this).parent().parent().attr("id");
-            $("#reCalcConfirm").attr("recalcId", recalcId);
-        });
-        $("#reCalcConfirm").click(function(){
-            $('#reCalcConfirm').addClass('disabled');
-            $.bootstrapLoading.start();
-            let recalcId = $(this).attr("recalcId");
-            CommonAjax.post('/rationRepository/api/reCalcAll', {rationRepId: recalcId}, function (rstData) {
-                $.bootstrapLoading.end();
-                $('#reCalcAll').modal('hide');
-                $('#reCalcConfirm').removeClass('disabled');
-            }, function () {
-                $.bootstrapLoading.end();
-                $('#reCalcAll').modal('hide');
-                $('#reCalcConfirm').removeClass('disabled')
-            });
-        });
+        if(newName.trim().length === 0){
+            alert("名称不可为空!");
+            $("#renameText").val('');
+        } else if (!newLibCode) {
+            alert('定额编号不可为空!');
+            $('#renameCode').val('');
+        } else if(filterName.length > 0 && newName !== orgName){
+            alert("该定额库已存在!");
+            $("#renameText").val('');
+        } else{
+            renameRationLib({ID: libId, newName: newName, orgName: orgName, newLibCode: newLibCode});
+        }
+    });
+    $('#edit').on('shown.bs.modal', function () {
+        setTimeout(function () {
+            $('#renameText').focus();
+        }, 100);
+    });
 
+    $('#add').on('shown.bs.modal', function () {
+        setTimeout(function () {
+            $('#libNameTxt').focus();
+        }, 100);
+    });
+    $('#add').on('hidden.bs.modal', function () {
+        $('#libNameTxt').val('');
     });
+    //删除
+    $("#showArea").on("click", "[data-target = '#del']", function(){
+        let deleteId = $(this).parent().parent().attr("id");
+        $("#deleteA").attr("deleteId", deleteId);
+        let delLibName = $(`#${deleteId}`).find('td:first').text();
+        $('#del').find('.modal-body h5').text(`准备删除 “${delLibName}”,会导致已引用此库的地方出错,确定要删除吗?`);
+    });
+    $("#deleteA").click(function(){
+        let deleteId = $(this).attr("deleteId");
+        if(preDeleteId && preDeleteId !== deleteId){
+            deleteCount = 0;
+        }
+        preDeleteId = deleteId;
+        deleteCount++;
+        let jqSel = "#" + deleteId + " td:first" + " a";
+        let libName = $(jqSel).text();
+        if(deleteCount === 3){
+            deleteCount = 0;
+            removeRationLib({libId: deleteId, libName: libName});
+            $('#del').modal('hide');
+        }
+    });
+    //全部计算
+    $("#showArea").on("click", "[data-target = '#reCalcAll']", function(){
+        let recalcId = $(this).parent().parent().attr("id");
+        $("#reCalcConfirm").attr("recalcId", recalcId);
+    });
+    $("#reCalcConfirm").click(function(){
+        $('#reCalcConfirm').addClass('disabled');
+        $.bootstrapLoading.start();
+        let recalcId = $(this).attr("recalcId");
+        CommonAjax.post('/rationRepository/api/reCalcAll', {rationRepId: recalcId}, function (rstData) {
+            $.bootstrapLoading.end();
+            $('#reCalcAll').modal('hide');
+            $('#reCalcConfirm').removeClass('disabled');
+        }, function () {
+            $.bootstrapLoading.end();
+            $('#reCalcAll').modal('hide');
+            $('#reCalcConfirm').removeClass('disabled')
+        });
+    });
+
     getCompilationList(function (data) {
         compilationsArr = data.compilation;
     });
@@ -247,7 +243,7 @@ $(function () {
     });
     $('#compilations').change(function () {
         selCompilationId = $(this).select().val();
-        CommonAjax.get(`api/sectionTemplateCount/${selCompilationId}`, function (rstData) {
+        CommonAjax.get(`/rationRepository/api/sectionTemplateCount/${selCompilationId}`, function (rstData) {
             rstData.data.count > 0 ?
                 $('#templateText').text('该费用定额下已有定额章节树模板数据,是否确认覆盖数据?') :
                 $('#templateText').text('确认是否将此库的章节树设置成该费用定额下补充定额章节树模板?');
@@ -259,7 +255,7 @@ $(function () {
             return false;
         }
         $.bootstrapLoading.start();
-        CommonAjax.post('api/initSectionTemplate', {rationLibId: rationRepId, compilationId: selCompilationId}, function () {
+        CommonAjax.post('/rationRepository/api/initSectionTemplate', {rationLibId: rationRepId, compilationId: selCompilationId}, function () {
             $.bootstrapLoading.end();
             $('#template').modal('hide');
         }, function () {
@@ -269,50 +265,10 @@ $(function () {
     });
 });
 
-function getAllRationLib(callback){
-    $.ajax({
-        type: 'post',
-        url: 'api/getRationDisplayNames',
-        dataType: 'json',
-        success: function (result) {
-            let dispNames = [];
-            if(result.data.length > 0){
-                for(let i = 0; i < result.data.length; i++){
-                    storageUtil.setSessionCache("RationGrp","repositoryID_" + result.data[i].ID, result.data[i].dispName);
-                    if(result.data[i].gljLib){
-                        storageUtil.setSessionCache("gljLib","repositoryID_" + result.data[i].ID, result.data[i].gljLib);
-                    }
-                    let id = result.data[i].ID;
-                    let libName = result.data[i].dispName;
-                    let libCode = result.data[i].libCode ? result.data[i].libCode : '';
-                    let createDate = result.data[i].createDate.split(' ')[0];
-                    let compilationName = result.data[i].compilationName;
-                    dispNames.push(result.data[i].dispName);
-                    $("#showArea").append(
-                        "<tr id='"+id+"'>" +
-                        "<td><a href='/rationRepository/ration?repository=" + id +"'>"+libName+"</a></td>" +
-                        "<td>"+libCode+"</td>" +
-                        "<td>"+compilationName+" </td>" +
-                        "<td>"+createDate+" </td>" +
-                        "<td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
-                        "<i class='fa fa-pencil-square-o'></i></a> <a href='javascript:void(0);' data-toggle='modal' data-target='#del' class='text-danger' title='删除'>" +
-                        "<i class='fa fa-remove'></i></a>" +
-                        " <a href='javascript:void(0);' data-toggle='modal' data-target='#reCalcAll' title='全部计算'><i class='fa fa-calculator'></i></a></td>"+
-                        "<td><a class='btn btn-secondary btn-sm import-source' href='javacript:void(0);' data-id='"+ id +"' title='导入原始数据'><i class='fa fa-sign-in fa-rotate-90'></i>导入</a></td>" +
-                        "<td><a class='btn btn-success btn-sm export' href='javacript:void(0);' data-toggle='modal' data-id='"+ id +"' data-target='#emport' title='导出内部数据'><i class='fa fa-sign-out fa-rotate-270'></i>导出</a> " +
-                        "<a class='btn btn-secondary btn-sm import-data' href='javacript:void(0);' data-id='"+ id +"' title='导入内部数据'><i class='fa fa-sign-in fa-rotate-90'></i>导入</a></td>" +
-                        "<td><a class='btn btn-secondary btn-sm set-comple' href='javacript:void(0);' data-id='"+ id +"' title='将章节树设为补充模板数据'><i class='fa fa-sign-in fa-rotate-90'></i>设置</a></td>" +
-                        "</tr>");
-                }
-            }
-            callback(dispNames);
-        }
-    });
-}
 function getCompilationList(callback){
     $.ajax({
         type: 'post',
-        url: 'api/getCompilationList',
+        url: '/rationRepository/api/getCompilationList',
         dataType: 'json',
         success: function (result) {
             //addoptions
@@ -359,48 +315,22 @@ function getGljLibOps(compilationId, gljLibs){
     return rst;
 }
 
-function createRationLib(rationObj, dispNamesArr){
+function createRationLib(rationObj){
     $.ajax({
         type: 'post',
-        url: 'api/addRationRepository',
+        url: '/rationRepository/api/addRationRepository',
         data: {rationRepObj: JSON.stringify(rationObj)},
         dataType: 'json',
         success: function (result) {
-            if(result.data){
-                storageUtil.setSessionCache("RationGrp","repositoryID_" + result.data.ID, result.data.dispName);
-                if(result.data.gljLib){
-                    storageUtil.setSessionCache("gljLib","repositoryID_" + result.data.ID, result.data.gljLib);
-                }
-                let id = result.data.ID;
-                let libName = result.data.dispName;
-                let createDate = result.data.createDate.split(' ')[0];
-                let compilationName = result.data.compilationName;
-                let libCode = result.data.libCode ? result.data.libCode : '';
-                dispNamesArr.push(libName);
-                $("#showArea").append(
-                    "<tr id='"+id+"'>" +
-                    "<td><a href='/rationRepository/ration?repository=" + id +"'>"+libName+"</a></td>" +
-                    "<td>"+libCode+" </td>" +
-                    "<td>"+compilationName+" </td>" +
-                    "<td>"+createDate+" </td>" +
-                    "<td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
-                    "<i class='fa fa-pencil-square-o'></i></a> <a href='javascript:void(0);' data-toggle='modal' data-target='#del' class='text-danger' title='删除'>" +
-                    "<i class='fa fa-remove'></i></a>" +
-                    " <a href='javascript:void(0);' data-toggle='modal' data-target='#reCalcAll' title='全部计算'><i class='fa fa-calculator'></i></a>"+
-                    "<td><a class='btn btn-secondary btn-sm import-source' href='javacript:void(0);' data-id='"+ id +"' title='导入原始数据'><i class='fa fa-sign-in fa-rotate-90'></i>导入</a></td>" +
-                    "<td><a class='btn btn-success btn-sm export' href='javacript:void(0);' data-toggle='modal' data-id='"+ id +"' data-target='#emport' title='导出内部数据'><i class='fa fa-sign-out fa-rotate-270'></i>导出</a> " +
-                    "<a class='btn btn-secondary btn-sm import-data' href='javacript:void(0);' data-id='"+ id +"' title='导入内部数据'><i class='fa fa-sign-in fa-rotate-90'></i>导入</a></td>" +
-                    "<td><a class='btn btn-secondary btn-sm set-comple' href='javacript:void(0);' data-id='"+ id +"' title='将章节树设为补充模板数据'><i class='fa fa-sign-in fa-rotate-90'></i>设置</a></td>" +
-                    "</tr>");
-            }
+            window.location.href = location.href;
             $('#cancelBtn').click();
         }
     })
 }
-function renameRationLib(renameObj, dispNames){
+function renameRationLib(renameObj){
     $.ajax({
         type: 'post',
-        url: 'api/editRationLibs',
+        url: '/rationRepository/api/editRationLibs',
         data: {oprtor: userAccount, renameObj: JSON.stringify(renameObj)},
         dataType: 'json',
         success: function (result) {
@@ -408,9 +338,9 @@ function renameRationLib(renameObj, dispNames){
                 let jqSel = "#" + renameObj.ID + " td:first" + " a";
                 $(jqSel).text(renameObj.newName);
                 $(`#${renameObj.ID} td:eq(1)`).text(renameObj.newLibCode);
-                let index = dispNames.indexOf(renameObj.orgName);
-                dispNames.splice(index, 1);
-                dispNames.splice(index, 0, renameObj.newName);
+                let index = allNames.indexOf(renameObj.orgName);
+                allNames.splice(index, 1);
+                allNames.splice(index, 0, renameObj.newName);
             }
             $('#editCancelBtn').click();
             $('#renameText').val('');
@@ -418,19 +348,19 @@ function renameRationLib(renameObj, dispNames){
         }
     })
 }
-function removeRationLib(delObj, dispNames){
+function removeRationLib(delObj){
     $.bootstrapLoading.start();
     $.ajax({
         type: 'post',
-        url: 'api/deleteRationLibs',
+        url: '/rationRepository/api/deleteRationLibs',
         data: {oprtor: userAccount, libId: delObj.libId},
         dataType: 'json',
         success: function (result) {
             if(!result.error){
                 var jqSel = "#"+ delObj.libId;
                 $(jqSel).remove();
-                let index = dispNames.indexOf(delObj.libName);
-                dispNames.splice(index, 1);
+                let index = allNames.indexOf(delObj.libName);
+                allNames.splice(index, 1);
                 $('#delCancelBtn').click();
             }
             $.bootstrapLoading.end();

+ 40 - 3
web/maintain/ration_repository/main.html

@@ -32,11 +32,47 @@
         <div class="content">
             <div class="container-fluid">
                 <div class="row">
+                    <div class="col-md-2">
+                        <div class="list-group mt-3">
+                            <% for (let compilation of compilationList) { %>
+                            <% if (compilation._id === 'all') { %>
+                            <a href="/rationRepository/main" class="list-group-item list-group-item-action <%= compilation.active %>">
+                                所有
+                            </a>
+                            <% } else { %>
+                            <a id="<%= compilation._id %>" href="/rationRepository/main/?filter=<%= compilation._id %>" class="list-group-item list-group-item-action <%= compilation.active %>">
+                                <%= compilation.name %>
+                            </a>
+                            <% }} %>
+                        </div>
+                    </div>
                   <div class="col-md-8">
                     <div class="warp-p2 mt-3">
                       <table class="table table-hover table-bordered">
                         <thead><tr><th>定额库名称</th><th>定额编号</th><th width="160">费用定额</th><th width="160">添加时间</th><th width="90">操作</th><th width="90">原始数据</th><th width="150">内部数据</th><th width="90">补充模板</th></tr></thead>
                         <tbody id="showArea">
+                        <% for(let lib of rationLibs){ %>
+                        <tr id="<%= lib.ID %>">
+                            <td><a href="/rationRepository/ration?repository=<%= lib.ID%>"><%= lib.dispName%></a></td>
+                            <td><%= lib.libCode%></td>
+                            <td><%= lib.compilationName%></td>
+                            <td><%= moment(lib.createDate).format('YYYY-MM-DD')%></td>
+                            <td>
+                                <a href="javacript:void(0);" data-toggle="modal" data-target="#edit" title="编辑"><i class="fa fa-pencil-square-o"></i></a>
+                                <a href="javacript:void(0);" data-toggle="modal" data-target="#del" class="text-danger" title="删除"><i class="fa fa-remove"></i></a>
+                            </td>
+                            <td>
+                                <a class="btn btn-secondary btn-sm import-source" href="javacript:void(0);" data-id="<%= lib.ID %>" title="导入原始数据"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
+                            </td>
+                            <td>
+                                <a class="btn btn-success btn-sm export" href="javacript:void(0);" data-toggle="modal" data-id="<%= lib.ID %>" data-target="#emport" title="导出内部数据"><i class="fa fa-sign-out fa-rotate-270"></i>导出</a>
+                                <a class="btn btn-secondary btn-sm import-data" href="javacript:void(0);" data-id="<%= lib.ID %>" title="导入内部数据"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
+                            </td>
+                            <td>
+                                <a class="btn btn-secondary btn-sm set-comple" href="javacript:void(0);" data-id="<%= lib.ID %>" title="将章节树设为补充模板数据"><i class="fa fa-sign-in fa-rotate-90"></i>设置</a>
+                            </td>
+                        </tr>
+                        <% } %>
                         </tbody>
                       </table>
                     </div>
@@ -262,6 +298,10 @@
         </div>
     </div>
     <!-- JS. -->
+    <script type="text/javascript">
+        let allNames = '<%= allNames %>'.split(',');
+        let userAccount = '<%=userAccount %>';
+    </script>
     <script src="/lib/jquery/jquery.min.js"></script>
     <script src="/lib/tether/tether.min.js"></script>
     <script src="/lib/bootstrap/bootstrap.min.js"></script>
@@ -275,8 +315,5 @@
     <script type="text/javascript" src="/web/maintain/ration_repository/js/main.js"></script>
     <script type="text/javascript" src="/public/web/storageUtil.js"></script>
 </body>
-<script type="text/javascript">
-    let userAccount = '<%=userAccount %>';
-</script>
 
 </html>