|
@@ -49,11 +49,11 @@ module.exports = app => {
|
|
|
// 获取版本信息
|
|
|
const versionList = await ctx.service.version.getAllDataByCondition({ orders: [['id', 'desc']], limit: 5, offset: 0 });
|
|
|
// 获取项目通知
|
|
|
- const msgList = await ctx.service.message.getMsgList(ctx.session.sessionProject.id);
|
|
|
+ const msgList = await ctx.service.message.getMsgList(ctx.session.sessionProject.id, ctx.subProject.id);
|
|
|
const userPermission = pa !== undefined && pa.permission !== '' ? JSON.parse(pa.permission) : null;
|
|
|
const userMsgPermission = userPermission !== null && userPermission.project_msg !== undefined && parseInt(userPermission.project_msg) === 1;
|
|
|
// 获取系统通知
|
|
|
- const sysMsgList = await ctx.service.message.getMsgList(ctx.session.sessionProject.id, 1, 0, 2);
|
|
|
+ const sysMsgList = await ctx.service.message.getMsgList(ctx.session.sessionProject.id, '', 1, 0, 2);
|
|
|
// 获取系统维护信息
|
|
|
const maintainData = await ctx.service.maintain.getDataById(1);
|
|
|
// 获取各个审批的次数及最后的审批时间
|
|
@@ -144,7 +144,7 @@ module.exports = app => {
|
|
|
try {
|
|
|
const page = ctx.page;
|
|
|
|
|
|
- const msgId = parseInt(ctx.params.id) || 0;
|
|
|
+ const msgId = parseInt(ctx.params.mid) || 0;
|
|
|
|
|
|
let msgInfo = msgId ? await ctx.service.message.getDataById(msgId) : null;
|
|
|
|
|
@@ -159,19 +159,19 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
const total = type === 1 ?
|
|
|
- await ctx.service.message.count({ project_id: ctx.session.sessionProject.id, type }) :
|
|
|
+ await ctx.service.message.count({ project_id: ctx.session.sessionProject.id, spid: [ctx.subProject.id, ''], type }) :
|
|
|
await ctx.service.message.count({ status: 1, type });
|
|
|
|
|
|
const limit = 5;
|
|
|
const offset = limit * (this.ctx.page - 1);
|
|
|
|
|
|
- const msgList = await ctx.service.message.getMsgList(ctx.session.sessionProject.id, limit, offset, type);
|
|
|
+ const msgList = await ctx.service.message.getMsgList(ctx.session.sessionProject.id, ctx.subProject.id, limit, offset, type);
|
|
|
|
|
|
const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
|
|
|
const userPermission = pa !== undefined && pa.permission !== '' ? JSON.parse(pa.permission) : null;
|
|
|
const userMsgPermission = userPermission !== null && userPermission.project_msg !== undefined && parseInt(userPermission.project_msg) === 1;
|
|
|
|
|
|
- if (!msgId) {
|
|
|
+ if (!msgInfo) {
|
|
|
msgInfo = msgList[0];
|
|
|
}
|
|
|
// 分页相关
|
|
@@ -193,7 +193,7 @@ module.exports = app => {
|
|
|
console.log(error);
|
|
|
this.log(error);
|
|
|
ctx.session.postError = error.toString();
|
|
|
- ctx.redirect('/dashboard');
|
|
|
+ ctx.redirect('/sp/' + ctx.subProject.id + '/dashboard');
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -204,7 +204,7 @@ module.exports = app => {
|
|
|
* @return {void}
|
|
|
*/
|
|
|
async msgAdd(ctx) {
|
|
|
- let id = ctx.params.id;
|
|
|
+ let id = ctx.params.mid;
|
|
|
id = parseInt(id);
|
|
|
try {
|
|
|
if (isNaN(id) || id < 0) {
|
|
@@ -237,14 +237,14 @@ module.exports = app => {
|
|
|
*/
|
|
|
async msgSet(ctx) {
|
|
|
try {
|
|
|
- let id = ctx.params.id;
|
|
|
+ let id = ctx.params.mid;
|
|
|
id = parseInt(id);
|
|
|
if (isNaN(id) || id < 0) {
|
|
|
throw '参数错误';
|
|
|
}
|
|
|
const rule = ctx.service.message.rule();
|
|
|
ctx.helper.validate(rule);
|
|
|
- const result = await ctx.service.message.save(id, ctx.request.body, ctx.session.sessionUser, ctx.session.sessionProject.id);
|
|
|
+ const result = await ctx.service.message.save(id, ctx.request.body, ctx.session.sessionUser, ctx.session.sessionProject.id, ctx.subProject.id);
|
|
|
if (result) {
|
|
|
// 新增的项目通知会发送微信模版消息通知客户
|
|
|
if (id === 0) {
|
|
@@ -275,7 +275,7 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- ctx.redirect('/dashboard/msg');
|
|
|
+ ctx.redirect('/sp/' + ctx.subProject.id + '/dashboard/msg');
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.log(error);
|
|
@@ -291,7 +291,7 @@ module.exports = app => {
|
|
|
*/
|
|
|
async msgDelete(ctx) {
|
|
|
try {
|
|
|
- let id = ctx.params.id;
|
|
|
+ let id = ctx.params.mid;
|
|
|
id = parseInt(id);
|
|
|
if (isNaN(id) || id <= 0) {
|
|
|
throw '参数错误';
|
|
@@ -302,7 +302,7 @@ module.exports = app => {
|
|
|
}
|
|
|
const result = await ctx.service.message.deleteMsg(msgInfo.id);
|
|
|
if (result) {
|
|
|
- ctx.redirect('/dashboard/msg');
|
|
|
+ ctx.redirect('/sp/' + ctx.subProject.id + '/dashboard/msg');
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.log(error);
|
|
@@ -333,7 +333,7 @@ module.exports = app => {
|
|
|
let stream;
|
|
|
try {
|
|
|
const responseData = { err: 0, msg: '', data: {} };
|
|
|
- const mid = ctx.params.id || 0;
|
|
|
+ const mid = ctx.params.mid || 0;
|
|
|
if (!mid) throw '参数有误';
|
|
|
const parts = this.ctx.multipart({
|
|
|
autoFields: true,
|
|
@@ -391,7 +391,7 @@ module.exports = app => {
|
|
|
*/
|
|
|
async msgDeleteFile(ctx) {
|
|
|
try {
|
|
|
- const mid = ctx.params.id || 0;
|
|
|
+ const mid = ctx.params.mid || 0;
|
|
|
const responseData = { err: 0, msg: '', data: {} };
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
const fileInfo = await ctx.service.messageAtt.getDataById(data.id);
|