|
|
@@ -8,15 +8,19 @@ 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{
|
|
|
- async redirectMain(req, res){
|
|
|
- let filter = req.query.filter ? {compilationId: req.query.filter} : null;
|
|
|
- let allLibs = await rationLibModel.find({}, {_id: 0, recentOpr: 0}),
|
|
|
+const rationItem = require('../models/ration_item');
|
|
|
+
|
|
|
+class ViewsController extends BaseController {
|
|
|
+ async redirectMain(req, res) {
|
|
|
+ await rationItem.copyLib(246, 251, 172, 172);
|
|
|
+ await rationItem.copyLib(247, 252, 172, 172);
|
|
|
+ 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 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';
|
|
|
@@ -32,7 +36,7 @@ class ViewsController extends BaseController{
|
|
|
userID: req.session.managerData.userID
|
|
|
});
|
|
|
}
|
|
|
- async redirectRation(req, res){
|
|
|
+ async redirectRation(req, res) {
|
|
|
const repId = req.query.repository;
|
|
|
const locked = req.query.locked || 'true';
|
|
|
const redirectGlj = `/rationRepository/lmm?repository=${repId}&locked=${locked}`;
|
|
|
@@ -40,12 +44,12 @@ class ViewsController extends BaseController{
|
|
|
const redirectInstallation = `/rationRepository/installation?repository=${repId}&locked=${locked}`;
|
|
|
let overWriteUrl = null;
|
|
|
let priceProperties = [];
|
|
|
- let stdRationLib = await rationLibModel.findOne({ID: repId});
|
|
|
- if(stdRationLib){
|
|
|
- let compilation = await compilationModel.findOne({_id: mongoose.Types.ObjectId(stdRationLib.compilationId)});
|
|
|
+ let stdRationLib = await rationLibModel.findOne({ ID: repId });
|
|
|
+ if (stdRationLib) {
|
|
|
+ let compilation = await compilationModel.findOne({ _id: mongoose.Types.ObjectId(stdRationLib.compilationId) });
|
|
|
priceProperties = compilation.priceProperties ? compilation.priceProperties : [];
|
|
|
let absoluteUrl = compilation.overWriteUrl ? req.app.locals.rootDir + compilation.overWriteUrl : req.app.locals.rootDir;
|
|
|
- overWriteUrl = fs.existsSync(absoluteUrl) && fs.statSync(absoluteUrl).isFile()? compilation.overWriteUrl : null;
|
|
|
+ overWriteUrl = fs.existsSync(absoluteUrl) && fs.statSync(absoluteUrl).isFile() ? compilation.overWriteUrl : null;
|
|
|
}
|
|
|
res.render('maintain/ration_repository/dinge.html',
|
|
|
{
|
|
|
@@ -54,12 +58,12 @@ class ViewsController extends BaseController{
|
|
|
redirectGlj: redirectGlj,
|
|
|
redirectCoe: redirectCoe,
|
|
|
redirectInstallation: redirectInstallation,
|
|
|
- LicenseKey:config.getLicenseKey(process.env.NODE_ENV),
|
|
|
+ LicenseKey: config.getLicenseKey(process.env.NODE_ENV),
|
|
|
priceProperties: JSON.stringify(priceProperties),
|
|
|
overWriteUrl: overWriteUrl
|
|
|
});
|
|
|
}
|
|
|
- async redirectGlj(req, res){
|
|
|
+ async redirectGlj(req, res) {
|
|
|
const repId = req.query.repository;
|
|
|
const locked = req.query.locked || 'true';
|
|
|
const redirectRation = `/rationRepository/ration?repository=${repId}&locked=${locked}`;
|
|
|
@@ -67,12 +71,12 @@ class ViewsController extends BaseController{
|
|
|
const redirectInstallation = `/rationRepository/installation?repository=${repId}&locked=${locked}`;
|
|
|
let overWriteUrl = null;
|
|
|
let priceProperties = [];
|
|
|
- let stdRationLib = await rationLibModel.findOne({ID: repId});
|
|
|
- if(stdRationLib){
|
|
|
- let compilation = await compilationModel.findOne({_id: mongoose.Types.ObjectId(stdRationLib.compilationId)});
|
|
|
+ let stdRationLib = await rationLibModel.findOne({ ID: repId });
|
|
|
+ if (stdRationLib) {
|
|
|
+ let compilation = await compilationModel.findOne({ _id: mongoose.Types.ObjectId(stdRationLib.compilationId) });
|
|
|
priceProperties = compilation.priceProperties ? compilation.priceProperties : [];
|
|
|
let absoluteUrl = compilation.overWriteUrl ? req.app.locals.rootDir + compilation.overWriteUrl : req.app.locals.rootDir;
|
|
|
- overWriteUrl = fs.existsSync(absoluteUrl) && fs.statSync(absoluteUrl).isFile()? compilation.overWriteUrl : null;
|
|
|
+ overWriteUrl = fs.existsSync(absoluteUrl) && fs.statSync(absoluteUrl).isFile() ? compilation.overWriteUrl : null;
|
|
|
}
|
|
|
res.render('maintain/ration_repository/gongliao.html',
|
|
|
{
|
|
|
@@ -81,12 +85,12 @@ class ViewsController extends BaseController{
|
|
|
redirectRation: redirectRation,
|
|
|
redirectCoe: redirectCoe,
|
|
|
redirectInstallation: redirectInstallation,
|
|
|
- LicenseKey:config.getLicenseKey(process.env.NODE_ENV),
|
|
|
+ LicenseKey: config.getLicenseKey(process.env.NODE_ENV),
|
|
|
priceProperties: JSON.stringify(priceProperties),
|
|
|
rationLib: stdRationLib
|
|
|
});
|
|
|
}
|
|
|
- redirectCoeList(req, res){
|
|
|
+ redirectCoeList(req, res) {
|
|
|
const repId = req.query.repository;
|
|
|
const locked = req.query.locked || 'true';
|
|
|
const redirectGlj = `/rationRepository/lmm?repository=${repId}&locked=${locked}`;
|
|
|
@@ -99,16 +103,16 @@ class ViewsController extends BaseController{
|
|
|
redirectGlj: redirectGlj,
|
|
|
redirectRation: redirectRation,
|
|
|
redirectInstallation: redirectInstallation,
|
|
|
- LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
|
|
|
+ LicenseKey: config.getLicenseKey(process.env.NODE_ENV)
|
|
|
});
|
|
|
}
|
|
|
- async redirectInstallation(req, res){
|
|
|
+ async redirectInstallation(req, res) {
|
|
|
const repId = req.query.repository;
|
|
|
const locked = req.query.locked || 'true';
|
|
|
const redirectGlj = `/rationRepository/lmm?repository=${repId}&locked=${locked}`;
|
|
|
const redirectCoe = `/rationRepository/coeList?repository=${repId}&locked=${locked}`;
|
|
|
const redirectRation = `/rationRepository/ration?repository=${repId}&locked=${locked}`;
|
|
|
- let stdRationLib = await rationLibModel.findOne({ID: repId});
|
|
|
+ let stdRationLib = await rationLibModel.findOne({ ID: repId });
|
|
|
res.render('maintain/ration_repository/anzhuang.html',
|
|
|
{
|
|
|
userAccount: req.session.managerData.username,
|
|
|
@@ -116,7 +120,7 @@ class ViewsController extends BaseController{
|
|
|
redirectGlj: redirectGlj,
|
|
|
redirectCoe: redirectCoe,
|
|
|
redirectRation: redirectRation,
|
|
|
- LicenseKey:config.getLicenseKey(process.env.NODE_ENV),
|
|
|
+ LicenseKey: config.getLicenseKey(process.env.NODE_ENV),
|
|
|
rationLib: stdRationLib
|
|
|
});
|
|
|
}
|