Browse Source

(*) 非巡检人不能进行巡检操作

master
liujiangyong 2 years ago
parent
commit
bc3c84f47d
  1. 7
      api/app/lib/controllers/patrolPlan/patrolPlan.js
  2. 3
      weapp/package/polling/polling.js
  3. 3
      weapp/package/startInspection/startInspection.js

7
api/app/lib/controllers/patrolPlan/patrolPlan.js

@ -3,12 +3,14 @@
async function getPatrolPlan(ctx, next) { async function getPatrolPlan(ctx, next) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { limit, page } = ctx.query; const { limit, page, userId } = ctx.query;
let userWhere = {};
let options = { let options = {
include: [{ include: [{
required: true, required: true,
model: models.User, model: models.User,
attributes: ['id', 'name'], attributes: ['id', 'name'],
where: userWhere,
include: [{ include: [{
required: true, required: true,
model: models.Department, model: models.Department,
@ -26,6 +28,9 @@ async function getPatrolPlan(ctx, next) {
if (page && limit) { if (page && limit) {
options.offset = Number(page) * Number(limit); options.offset = Number(page) * Number(limit);
} }
if (userId) {
userWhere.id = userId;
}
let res = await models.PatrolPlan.findAndCountAll(options); let res = await models.PatrolPlan.findAndCountAll(options);
ctx.status = 200; ctx.status = 200;
ctx.body = res; ctx.body = res;

3
weapp/package/polling/polling.js

@ -43,7 +43,8 @@ Page({
wx.showLoading({ wx.showLoading({
title: '加载中', title: '加载中',
}) })
Request.get(getPatrolPlan(), { limit, page }).then(res => { const userInfo = wx.getStorageSync('userInfo');
Request.get(getPatrolPlan(), { limit, page, userId: userInfo.id }).then(res => {
if (res.rows.length == 0) { if (res.rows.length == 0) {
that.setData({ that.setData({
dataList: res.rows, dataList: res.rows,

3
weapp/package/startInspection/startInspection.js

@ -395,7 +395,8 @@ Page({
wx.showLoading({ wx.showLoading({
title: '加载中', title: '加载中',
}) })
Request.get(getPatrolPlan(), {}).then(res => { const userInfo = wx.getStorageSync('userInfo');
Request.get(getPatrolPlan(), { userId: userInfo.id }).then(res => {
wx.hideLoading(); wx.hideLoading();
const pointPlan = res.rows.filter(plan => { const pointPlan = res.rows.filter(plan => {
for (const point of plan.points) { for (const point of plan.points) {

Loading…
Cancel
Save