Browse Source

相关库费用定额筛选

zhongzewei 6 years ago
parent
commit
0cdd9fc820

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

@@ -6,6 +6,7 @@
  * @compilation
  */
 import BaseController from "../../common/base/base_controller";
+import CompilationModel from '../../users/models/compilation_model';
 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";
@@ -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

@@ -2,17 +2,29 @@
  * Created by zhang on 2018/9/11.
  */
 import BaseController from "../../common/base/base_controller";
+import CompilationModel from '../../users/models/compilation_model';
 let config = require("../../../config/config.js");
 import calcProgramFacade from "../facade/calc_program_facade";
 
 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

@@ -2,17 +2,29 @@
  * Created by zhang on 2018/9/10.
  */
 import BaseController from "../../common/base/base_controller";
+import CompilationModel from '../../users/models/compilation_model';
 let config = require("../../../config/config.js");
 import feeRateFacade from "../facade/fee_rate_facade";
 
 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);

+ 17 - 0
modules/ration_repository/controllers/repository_views_controller.js

@@ -2,6 +2,7 @@
  * 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');
@@ -9,8 +10,24 @@ const rationLibModel = mongoose.model('std_ration_lib_map');
 const fs = require('fs');
 class ViewsController extends BaseController{
     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',
             {
+                rationLibs: rationLibs,
+                allNames: allNames,
+                compilationList: compilationList,
                 userAccount: req.session.managerData.username,
                 userID: req.session.managerData.userID,
                 LicenseKey:config.getLicenseKey(process.env.NODE_ENV)

+ 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">

+ 120 - 738
web/maintain/ration_repository/js/main.js

@@ -2,678 +2,126 @@
  * Created by Syusuke on 2017/3/17.
  */
 
-//暂时不在养护云中开放,已以工具形式开放(打包了自己一份工程)
-//转换excel相关
-//Excel中人材机的数据不存在合并列
-const TransferExcel = (function () {
-    const $transferModal = $('#transfer');
-    const $file = $('#transfer-file');
-    const $transfer = $('#transferConfirm');
-    const $exportSpread = $('#exportSpread');
-    let exportSpread = null;
-    let transferData = [];
-    //--以防需要可配置的情况
-    const fixedCount = 4; //固定列数(顺序号、项目、单位、代号)
-    const beginCol = 0;//起始的列
-    //固定的这几列的列号映射是动态的,因为有一些子表,这些列进行了合并列的处理
-    let colMapping = {
-        serialNo: 0,
-        name: 1,
-        unit: 2,
-        code: 3,
-        consumeAmt: 4, //消耗量开始的列
-    };
-    //---
-    function isUnDef(v) {
-        return typeof v === 'undefined' || v === null;
-    }
-    //取消所有空格
-    function trimAll(v) {
-        return typeof v === 'string' ? v.replace(/\s/g, '') : v;
-    }
-    //单元格是否有数据
-    function cellHasData(cell) {
-        return cell && cell.value;
-    }
-    //行是否有数据
-    //@param {Object}rowData(行数据) {Array}deduct(排除的列)
-    function rowHasData(rowData, deduct = null) {
-        for (let col in rowData) {
-            if (deduct && deduct.includes(col)) {
-                continue;
-            }
-            let cell = rowData[col];
-            if (cell && cell.value) {
-                return true;
-            }
-        }
-        return false;
-    }
-    //行为列头行 //第一列为数值,且后面其他列有数据(不单纯认为是第二列,因为怕有合并序号列)
-    function headerRow(rowData) {
-        return rowData[0] && rowData[0].value && /^\d+$/.test(rowData[0].value) && rowHasData(rowData, ['0']);
-
-    }
-    //去除定额子表数组中的空行(有的表格是在 单位:xx 下面还跟着一些垃圾数据,导致subRation的range范围判定变大了,但是四列后面的数据是空的)
-    function simplifyRationTable(arr) {
-        let target = [];
-        for (let subArr of arr) {
-            let emptyRow = subArr.every(function (ele) {
-                return ele === null;
-            });
-            if (emptyRow) {
-                continue;
-            }
-            target.push(subArr);
-        }
-        return target;
-    }
-    //将二维数组转换成每个元素都有值的二维数据(去没值元素,因为前四列有可能合并列)
-    function simplifyGljTable(arr) {
-        let target = [];
-        for (let subArr of arr) {
-            let subTarget = [];
-            for (let ele of subArr) {
-                if (ele !== null) {
-                    subTarget.push(ele);
-                }
-            }
-            target.push(subTarget);
+$(function () {
+    let preDeleteId = null;
+    let deleteCount = 0;
+    let selCompilationId,
+        compilationsArr = [];
+    $('#del').on('hidden.bs.modal', function () {
+        deleteCount = 0;
+    });
+    //添加
+    $('#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();
+        if(libName.trim().length === 0){
+            alert('名称不可为空!');
+            $('#libNameTxt').val('')
         }
-        return target;
-    }
-    //获取前固定四列的动态列映射(解决这几列可能有合并列的问题)
-    function getColMapping(rowData, colCount) {
-        function getUndefinedField(obj) {
-            let needFields = ['serialNo', 'name', 'unit', 'code', 'consumeAmt'];
-            for (let field of needFields) {
-                if (!obj.hasOwnProperty(field)) {
-                    return field;
-                }
-            }
-            return null;
+        else if(allNames.indexOf(libName) !== -1){
+            alert('此定额库已存在!');
+            $('#libNameTxt').val('')
         }
-        //假定序号列为第一列
-        let mapping = {serialNo: 0};
-        for (let i = 1; i < colCount; i++) {
-            let col = beginCol + i,
-                cell = rowData[col];
-            //还没设置的字段(必须要有的是serialNo, name, unit, code, consumeAmt)
-            if (cell && cell.value) {
-                let field = getUndefinedField(mapping);
-                if (field) {
-                    mapping[field] = col;
-                }
-                if (typeof mapping.consumeAmt !== 'undefined') {
-                    return mapping;
-                }
-            }
+        else if(compilationName.trim().length === 0){
+            alert('编办不可为空!');
         }
-        return null;
-    }
-    
-    //获取表头定额名称数据(最后一行为定额末位编码)
-    //合并的单元格处理:为了更好的让定额获得对应的定额名称,将合并单元格做填值处理, eg: [a]['合并'] = [a][a]
-    //@param {Object}dataTable {Object}range(表头的范围,row, col, rowCount, colCount) {Array}spans(spread解析Excel后的合并数组)
-    //@return {Array}
-    function getSubRationTable(dataTable, range, spans) {
-        let subTable = [];
-        for (let i = 0; i < range.rowCount; i++) {
-            subTable.push(Array(range.colCount).fill(null));
+        else if(gljLibName.trim().length === 0){
+            alert("请选择工料机库!");
         }
-        //获取合并的单元格填充数据
-        let fillArr = [];
-        for (let i = 0; i < range.rowCount; i++) {
-            let row = range.row + i;
-            if (!dataTable[row]) {
-                continue;
-            }
-            for (let j = 0; j < range.colCount; j++) {
-                let col = range.col + j;
-                let cell = dataTable[row][col];
-                //只有有值的单元格,判断合并才有意义,有值且合并列的单元格,每列的值认为都是一样的
-                if (cellHasData(cell)) {
-                    //是否合并了单元格
-                    let span = spans.find(function (data) {
-                        return data.row === row && data.col === col;
-                    });
-                    //这个fillData给subData填值用
-                    let fillData = {value: trimAll(cell.value), range: {row: i, col: j}};
-                    if (span) {
-                        fillData.range.rowCount = span.rowCount;
-                        fillData.range.colCount = span.colCount;
-                    } else {
-                        fillData.range.rowCount = 1;
-                        fillData.range.colCount = 1;
-                    }
-                    fillArr.push(fillData);
-                }
-            }
+        else{
+            let newRationLib = {};
+            newRationLib.dispName = libName;
+            newRationLib.compilationId = compilationId;
+            newRationLib.compilationName = compilationName;
+            newRationLib.gljLib = gljLibId;
+            newRationLib.creator = userAccount;
+            newRationLib.appType = "建筑";
+            $('#libNameTxt').val('');
+            createRationLib(newRationLib);
         }
-        //将数据填充到subData中
-        for (let fillData of fillArr) {
-            //合并行不需要向下填值(否则会重复)
-            let row = fillData.range.row;
-            //合并列需要向右填值
-            for (let j = 0; j < fillData.range.colCount; j++) {
-                let col = fillData.range.col + j;
-                subTable[row][col] = trimAll(fillData.value);
-            }
+    });
+    //重命名
+    $("#showArea").on("click", "[data-target = '#edit']", function(){
+        let renameId = $(this).parent().parent().attr("id");
+        $('#renameText').val($(this).parent().parent().find('td:first-child').text());
+        $("#renameA").attr("renameId", renameId);
+    });
+    $("#renameA").click(function(){
+        let newName = $("#renameText").val();
+        let libId = $(this).attr("renameId");
+        let jqSel = "#" + libId + " td:first" + " a";
+        let orgName = $(jqSel).text();
+        if(newName.trim().length === 0){
+            alert("名称不可为空!");
+            $("#renameText").val('');
         }
-        return simplifyRationTable(subTable);
-    }
-    //获取工料机子表数据(序号至最末消耗量)
-    //@param {Object}dataTable {Object}range(工料机子表的范围,row, col, rowCount, colCount)
-    //@return {Array}
-    function getSubGljTable(dataTable, range) {
-        let gljTable = [];
-        for (let i = 0; i < range.rowCount; i++) {
-            gljTable.push(Array(range.colCount).fill(null));
+        else if(allNames.indexOf(newName) !== -1){
+            alert("该定额库已存在!");
+            $("#renameText").val('');
         }
-        for (let i = 0; i < range.rowCount; i++) {
-            let row = range.row + i;
-            if (!dataTable[row]) {
-                continue;
-            }
-            for (let j = 0; j < range.colCount; j++) {
-                let col = range.col + j;
-                let cell = dataTable[row][col];
-                if (cellHasData(cell)) {
-                    gljTable[i][j] = cell.value;
-                }
-            }
+        else{
+            renameRationLib({ID: libId, newName: newName, orgName: orgName});
         }
-        //工料机数据每个单元格应该都有值,没有的为合并列造成,这里将没值的单元格去除
+    });
+    $('#edit').on('shown.bs.modal', function () {
+        setTimeout(function () {
+            $('#renameText').focus();
+        }, 100);
+    });
 
-        return simplifyGljTable(gljTable);
-    }
-    /*
-    * 从原本的excel中提取数据
-    * 需要的数据结构:eg: [{code: '1-1-1', name: '伐树', unit: '表列单位', subTable: [{subGlj: [], subRation: []}]}]
-    * subTable为定额数据对应的子表数据,其中有定额名称子表、工料机子表
-    * */
-    function extractDataFromExcel(sheetData) {
-        let dataTable = sheetData.data.dataTable,
-            spans = sheetData.spans;
-        //行数据是定额行 eg: 1-1-1 人工挖土方
-        //@param {Number}row
-        //@return {Object || Null} eg: {code: '1-1-1', name: '人工挖土方'}
-        function rationRow(row) {
-            let cell = dataTable[row][beginCol];
-            if (!cell || !cell.value || typeof cell.value !== 'string') {
-                return false;
-            }
-            let v = trimAll(cell.value);
-            //[\-,—,一] 这里是因为pdf转出来的excel(需要转换的excel)会吧"-"显示成各种奇怪的横杆
-            //第一数值限制在3位以内,防止有: 2019-05-01等日期干扰
-            let reg = /^(\d{1,3}[\-,_,—,一]{1}\d+[\-,_,—,一]{1}\d+)(\w{0,}[\u4e00-\u9fa5]{1,})/;
-            let match = reg.exec(v);
-            if (match && match.length === 3 && match[0] && match[1] && match[2]) {
-                return {code: match[1].replace(/[_,—,一]/g, '-'), name: match[2]};
-            }
-            return null;
-        }
-        //单位数据行 eg: 单位:表列单位
-        //@return {String || Null} eg: '表列单位'
-        function unitRow(row) {
-            let cell = dataTable[row][beginCol];
-            if (!cell || !cell.value || typeof cell.value !== 'string') {
-                return false;
-            }
-            let v = trimAll(cell.value);
-            let reg = /单位[\:, :]([\w+, \u4e00-\u9fa5]{0,})/;
-            let match = reg.exec(v);
-            if (match && match.length === 2 && match[0] && match[1]) {
-                return match[1];
-            }
-            return null;
-        }
-        //行数据是人材机数据行
-        //表头后,某行第一列为数值,第二列有值,则该行为紧接着表头的人材机数据行
-        //@return {Boolean}
-        function rowIsGlj(rowData) {
-            let numberCell = rowData[colMapping.serialNo],
-                valueCell = rowData[colMapping.name];
-            return numberCell && numberCell.value && /^\d+$/.test(numberCell.value) && valueCell && Boolean(valueCell.value);
-        }
-        //连续有数据的列数(每个子表格中工料机的数据列数)
-        //由于序号、项目、单位、代号可能存在合并列,因此从消耗量列(消耗量列不会合并列,消耗量对应的列号已在getColMapping获取)开始统计
-        function getDataCount(row) {
-            let consumeAmtCol = colMapping.consumeAmt;
-            for (let col = consumeAmtCol; col < sheetData.columnCount; col++) {
-                let cell = dataTable[row][col];
-                if (!cell || !cell.value) {
-                    return col;
-                }
-            }
-            return sheetData.columnCount;
-        }
-        //获取表格的子表范围(定额名称表头范围、工料机数据范围)
-        //遇到单位:xx行rowA后,获取紧跟其后的表格,该表格最少要有一行工料机数据行rowB,表头范围则为rowA至rowB
-        //@param {Number}beginRow
-        function getTableRange(beginRow) {
-            let hasTHead = false,
-                hasTable = false,
-                hasMapping = false; //是否获取过固定列映射
-            let range = {
-                subRation: {},
-                subGlj: {},
-            };
-            for (let row = beginRow; row < sheetData.rowCount; row++) {
-                if (!dataTable[row]) {
-                    continue;
-                }
-                //第一个有数据的行,为表头第一行
-                if (rowHasData(dataTable[row]) && !hasTHead) {
-                    hasTHead = true;
-                    range.subRation.row = row;
-                }
-                //获取当前子表的固定列映射
-                if (hasTHead && !hasTable && !hasMapping && headerRow(dataTable[row])) {
-                    hasMapping = true;
-                    colMapping = getColMapping(dataTable[row], sheetData.columnCount);
-                    if (!colMapping) {
-                        return null;
-                    }
-                }
-                //第一条工料机数据行
-                if (hasTHead && !hasTable && colMapping && rowIsGlj(dataTable[row])) {
-                    hasTable = true;
-                    range.subGlj.row = row;
-                    range.subGlj.col = 0;
-                    range.subRation.col = colMapping.consumeAmt;
-                    range.subRation.rowCount = range.subGlj.row - range.subRation.row;
-                    range.subGlj.colCount = getDataCount(row);
-                    range.subRation.colCount = range.subGlj.colCount - colMapping.consumeAmt;
-                }
-                if (hasTable && !rowIsGlj(dataTable[row])) {
-                    range.subGlj.rowCount = row - range.subGlj.row;
-                    return range;
-                }
-                if (hasTable && (row === sheetData.rowCount - 1 || !dataTable[row + 1])) {
-                    range.subGlj.rowCount = row - range.subGlj.row + 1;
-                    return range;
-                }
-            }
-            return null;
-        }
-        //分析整个表
-        let extractData = [];
-        //定额行后必须要跟着单位行
-        let hasUnit = false;
-        for (let row = 0; row < sheetData.rowCount; row++) {
-            if (!dataTable[row] || !rowHasData(dataTable[row])) {
-                continue;
-            }
-            let rationData = rationRow(row);
-            if (rationData) {
-                if (!hasUnit) {
-                    extractData.pop();
-                }
-                hasUnit = false;
-                //转换数据数组的每个元素,为定额基本数据:不完整的code、不完整的name、unit、和子表门构成
-                //subTable: [{subRation: [], subGlj: []}],subRation为每个子表表头数据(排除掉了顺序号至代号),
-                //subGlj为每个子表工料机数据
-                let basicData = {
-                    code: rationData.code,
-                    name: rationData.name,
-                    unit: null,
-                    subTable: []
-                };
-                extractData.push(basicData);
-            }
-            let unitData = unitRow(row);
-            if (unitData) {
-                hasUnit = true;
-                let thisBasicData = extractData[extractData.length - 1];
-                if (thisBasicData) {
-                    if (!thisBasicData.unit) {
-                        thisBasicData.unit = unitData;
-                    }
-                    //获取表格数据
-                    let range = getTableRange(row + 1);
-                    if (range) {
-                        let subRationTable = getSubRationTable(dataTable, range.subRation, spans),
-                            subGljTable = getSubGljTable(dataTable, range.subGlj);
-                        thisBasicData.subTable.push({subRation: subRationTable, subGlj: subGljTable});
-                        //跳过其中的行
-                        row = range.subGlj.row + range.subGlj.rowCount - 1;
-                    }
-                }
-            }
-        }
-        return extractData;
-    }
-    /*
-    * 转换数据,将提取出来的数据转换成另外一种数据结构,便于转化Excel的结构
-    * 需要的数据结构: eg: [{code: '1-1-1-1', name: '伐树xxx', unit: '表列单位', gljList: [{code,name,unit,comsumeAmt}]}]
-    * */
-    function transferDataFromExtract(extractData) {
-        //从一个提取的数据(1定额数据及其子表数据)中获取一份转换数据
-        function transfer(source) {
-            //以完整定额编码为属性,因为1个定额可能会有多张子表,且完整定额编码相同,子工料机不同,方便直接添加后续的工料机
-            let temp = {},
-                target = [];
-            let basicCode = source.code,
-                basicName = source.name,
-                basicUnit = source.unit;
-            //处理消耗量,可能有(3.5) 和 - 的情况, 处理:(3.5) => 3.5  - => 0
-            function handleConsumeAmt(consumeAmt) {
-                if (typeof consumeAmt === 'string') {
-                    consumeAmt = trimAll(consumeAmt);
-                    consumeAmt = consumeAmt.replace(/[\-,_,—,一,\(,\),(,)]/g, '');
-                    if (!consumeAmt) {
-                        return 0;
-                    }
-                }
-                return consumeAmt;
-            }
-            //从工料机子表中获取工料机数据, index为定额编码对应的下标索引
-            function getGljList(gljTable, index) {
-                let gljList = [];
-                //获取的工料机对应列
-                let gljColMapping = {
-                    name: 1,
-                    unit: 2,
-                    code: 3,
-                    consumeAmtCol: fixedCount + index
-                };
-                for (let rowData of gljTable) {
-                    //工料机数据必须要有名称、单位、编码
-                    if (!rowData[gljColMapping.name] ||
-                        !rowData[gljColMapping.unit] ||
-                        !rowData[gljColMapping.code]) {
-                        continue;
-                    }
-                    let consumeAmt = isUnDef(rowData[gljColMapping.consumeAmtCol]) ? 0 : handleConsumeAmt(rowData[gljColMapping.consumeAmtCol]);
-                    gljList.push({
-                        name: rowData[gljColMapping.name],
-                        unit: rowData[gljColMapping.unit],
-                        code: rowData[gljColMapping.code],
-                        consumeAmt: consumeAmt,
-                    });
-                }
-                return gljList;
-            }
-            //拼接定额工料机数据
-            for (let table of source.subTable) {
-                let rationTable = table.subRation;
-                if (!rationTable || rationTable.length === 0) {
-                    continue;
-                }
-                let lastRationCodes = rationTable.pop(); //定额子表,最后一行是末位定额编码
-                for (let i = 0; i < lastRationCodes.length; i++) {
-                    let lastCode = lastRationCodes[i];
-                    //拼接定额编码
-                    let compleCode = `${basicCode}-${lastCode}`,
-                        gljList = getGljList(table.subGlj, i);
-                    if (!temp[compleCode]) { //该定额不存在
-                        temp[compleCode] = {
-                            code: compleCode,
-                            unit: basicUnit,
-                            name: basicName,
-                            gljList: gljList
-                        };
-                    } else { //该定额已存在,则追加工料机
-                        temp[compleCode].gljList = temp[compleCode].gljList.concat(gljList);
-                    }
-                    //拼接定额名称
-                    for (let rationNameRow of rationTable) {
-                        if (rationNameRow[i]) {
-                            temp[compleCode].name += ` ${rationNameRow[i]}`;
-                        }
-                    }
-                }
-            }
-            //将temp对象转换为数据
-            for (let code in temp) {
-                target.push(temp[code]);
-            }
-            return target;
+    $('#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;
         }
-        let transferData = [];
-        for (let data of extractData) {
-            let unitTargetData = transfer(data);
-            transferData = transferData.concat(unitTargetData);
+        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');
         }
-        return transferData;
-    }
-    //导入Excel
-    function exportToExcel(transferData, fileName) {
+    });
+    //全部计算
+    $("#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();
-        setTimeout(function () {
-            if (exportSpread) {
-                exportSpread.destroy();
-            }
-            exportSpread = new GC.Spread.Sheets.Workbook($exportSpread[0], {sheetCount: 1});
-            let sheet = exportSpread.getSheet(0);
-            sheet.suspendPaint();
-            sheet.suspendEvent();
-            //往表格填值
-            let curRow = 0,
-                fillCol = {
-                    code: 1,
-                    name: 2,
-                    unit: 3,
-                    consumeAmt: 4
-                };
-            function getRowCount() {
-                let count = 0;
-                for (let data of transferData) {
-                    count += 1 + data.gljList.length;
-                }
-                return count;
-            }
-            sheet.setRowCount(getRowCount());
-            for (let data of transferData) {
-                sheet.setValue(curRow, 0, '定额');
-                sheet.setValue(curRow, fillCol.code, data.code);
-                sheet.setValue(curRow, fillCol.name, data.name);
-                sheet.setValue(curRow, fillCol.unit, data.unit);
-                curRow++;
-                for (let glj of data.gljList) {
-                    sheet.setValue(curRow, fillCol.code, glj.code);
-                    sheet.setValue(curRow, fillCol.name, glj.name);
-                    sheet.setValue(curRow, fillCol.unit, glj.unit);
-                    sheet.setValue(curRow, fillCol.consumeAmt, glj.consumeAmt);
-                    curRow++;
-                }
-            }
-            sheet.resumeEvent();
-            sheet.resumePaint();
-            let json = exportSpread.toJSON();
-            let excelIo = new GC.Spread.Excel.IO();
-            excelIo.save(json, function(blob) {
-                saveAs(blob, fileName);
-                $.bootstrapLoading.end();
-                $transferModal.modal('hide');
-            }, function(e) {
-                $.bootstrapLoading.end();
-                $transferModal.modal('hide');
-                console.log(e);
-            });
-        }, 200);
-    }
-    function eventListener() {
-        $transferModal.on('hidden.bs.modal', function () {
-            $file.val('');
-            transferData = [];
-        });
-        //导入excel,提取并转换定额数据
-        $file.change(function () {
-            $transfer.addClass('disabled');
-            let file = $(this)[0];
-            let excelFile = file.files[0];
-            if(excelFile) {
-                let xlsReg = /xls$/g;
-                if(excelFile.name && xlsReg.test(excelFile.name)){
-                    alert('请选择xlsx文件');
-                    $(this).val('');
-                    return;
-                }
-                $.bootstrapLoading.start();
-                $('#loadingPage').css('z-index', '2000');
-                //前端解析excel数据
-                let excelIo = new GC.Spread.Excel.IO();
-                let sDate = +new Date();
-                excelIo.open(excelFile, function (json) {
-                    console.log(json);
-                    let extractData = extractDataFromExcel(json.sheets.Sheet1);
-                    transferData = transferDataFromExtract(extractData);
-                    console.log(`解析Excel文件时间:${+new Date() - sDate}`);
-                    $.bootstrapLoading.end();
-                    $transfer.removeClass('disabled');
-                }, function (e) {
-                    $.bootstrapLoading.end();
-                    $transfer.removeClass('disabled');
-                    alert(e.errorMessage);
-                });
-            }
-        });
-        //确认转换,导出转换的Excel
-        $transfer.click(function () {
-            if (!transferData || transferData.length === 0) {
-                //没有转换数据
-                alert('没有转换数据');
-                return;
-            }
-            let fileName = '转换数据.xlsx';
-            if ($file[0].files && $file[0].files[0] && $file[0].files[0].name) {
-                fileName = '转换数据' + $file[0].files[0].name;
-            }
-            exportToExcel(transferData, fileName);
+        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')
         });
-    }
-
-    return {eventListener}
-})();
-
-$(function () {
-    //TransferExcel.eventListener();
-
-    let dispNameArr;
-    let preDeleteId = null;
-    let deleteCount = 0;
-    let selCompilationId,
-        compilationsArr = [];
-    $('#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();
-            if(libName.trim().length === 0){
-                alert('名称不可为空!');
-                $('#libNameTxt').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.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());
-            $("#renameA").attr("renameId", renameId);
-        });
-        $("#renameA").click(function(){
-            let newName = $("#renameText").val();
-            let libId = $(this).attr("renameId");
-            let jqSel = "#" + libId + " td:first" + " a";
-            let orgName = $(jqSel).text();
-            if(newName.trim().length === 0){
-                alert("名称不可为空!");
-                $("#renameText").val('');
-            }
-            else if(dispNameArr.indexOf(newName) !== -1){
-                alert("该定额库已存在!");
-                $("#renameText").val('');
-            }
-            else{
-                renameRationLib({ID: libId, newName: newName, orgName: orgName}, 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 () {
-            $('#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}, 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')
-            });
-        });
 
-    });
     getCompilationList(function (data) {
         compilationsArr = data.compilation;
     });
@@ -788,7 +236,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('确认是否将此库的章节树设置成该费用定额下补充定额章节树模板?');
@@ -800,7 +248,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 () {
@@ -810,50 +258,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 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>"+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 transfer-excel' data-toggle='modal' data-target='#transfer' href='javacript:void(0);' data-id='"+ id +"' title='转换Excel'><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>");
-                    $("#tempId").attr("id", id);
-                }
-            }
-            callback(dispNames);
-        }
-    });
-}
 function getCompilationList(callback){
     $.ajax({
         type: 'post',
-        url: 'api/getCompilationList',
+        url: '/rationRepository/api/getCompilationList',
         dataType: 'json',
         success: function (result) {
             //addoptions
@@ -900,75 +308,49 @@ 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;
-                dispNamesArr.push(libName);
-                $("#showArea").append(
-                    "<tr id='"+id+"'>" +
-                    "<td><a href='/rationRepository/ration?repository=" + id +"'>"+libName+"</a></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 transfer-excel' data-toggle='modal' data-target='#transfer' href='javacript:void(0);' data-id='"+ id +"' title='转换Excel'><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>");
-            }
-            $('#cancelBtn').click();
+            window.location.href = location.href;
         }
     })
 }
-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) {
             if(!result.error){
                 let jqSel = "#" + renameObj.ID + " td:first" + " a";
                 $(jqSel).text(renameObj.newName);
-                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('');
         }
     })
 }
-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();

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

@@ -33,11 +33,46 @@
         <div id="exportSpread" style="display: none"></div>
         <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 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.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>
@@ -283,6 +318,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>
@@ -300,8 +339,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>

+ 1 - 1
web/users/views/tool/index.html

@@ -268,7 +268,7 @@
             curTrigger = uploadType.upgradeGuide;
             $('#upload .modal-title').text('上传升级说明');
             $('#upload').modal('show');
-        })
+        });
         $('#upload').on('hide.bs.modal', function () {
             $('#upload-file').val('');
         });