peng.peng 2 years ago
parent
commit
e58c8cd9ed
  1. 80
      api/app/lib/controllers/patrolManage/patrolRecord.js
  2. 1
      api/app/lib/middlewares/authenticator.js
  3. 7
      api/app/lib/routes/patrolManage/patrolRecord.js
  4. 3
      weapp/app.json
  5. 1
      weapp/common.js
  6. 1
      weapp/images/inspection-report.svg
  7. 66
      weapp/package/inspectionReport/inspectionReport.js
  8. 3
      weapp/package/inspectionReport/inspectionReport.json
  9. 2
      weapp/package/inspectionReport/inspectionReport.wxml
  10. 1
      weapp/package/inspectionReport/inspectionReport.wxss
  11. 20
      weapp/package/troubleshooting/index.js
  12. 21
      weapp/package/troubleshooting/index.wxml
  13. 6
      weapp/pages/overview/overview.js
  14. 6
      weapp/pages/overview/overview.wxml

80
api/app/lib/controllers/patrolManage/patrolRecord.js

@ -136,6 +136,30 @@ async function findPatrolRecord (ctx, next) {
}
}
async function findPatrolRecordUnlicensed(ctx, next) {
let rslt = [];
let error = { name: 'FindError', message: '获取巡检记录失败' };
try {
const models = ctx.fs.dc.models;
const { startTime, endTime } = ctx.query;
const options = {
where: {}
}
if (startTime && endTime) {
options.where.inspectionTime = { $between: [startTime, endTime] };
}
rslt = await models.PatrolRecord.findAll(options);
ctx.status = 200;
ctx.body = rslt;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
"message": "获取巡检记录失败"
}
}
}
async function addPatrolRecord (ctx, next) {
let error = { name: 'addError', message: '新增巡检记录失败' };
const transaction = await ctx.fs.dc.orm.transaction();
@ -192,7 +216,7 @@ async function getPatrolRecordIssueHandle (ctx) {
let findOption = {
where: {
$or: []
},
include: [{
model: models.PatrolRecord
@ -201,22 +225,59 @@ async function getPatrolRecordIssueHandle (ctx) {
if (type == 'backlog') {
// 待办
let stateArr = []
if (userInfo) {
}
// let stateArr = []
if (userInfo && userInfo.userResources.includes('ZHIDINGJIHUA')) {
// stateArr.push(1)
findOption.where['$or'].push({ state: 1 })
findOption.where['$or'].push({ state: 3 })
}
findOption.where['$or'].push({ state: 2, approvePerson: { id: userId } })
findOption.where['$or'].push({ state: 4, repairPerson: { id: userId } })
findOption.where['$or'].push({ state: 5, checkPerson: { id: userId } })
findOption.where['$or'].push({ state: 7, repairPerson: { id: userId } })
findOption.where = {
...findOption.where,
}
} else if (type == 'haveDone') {
// 已办
findOption.where['$or'].push({ state: { $notIn: [1, 2] }, creator: { id: userId } })
findOption.where['$or'].push({ state: { $gt: 2 }, approvePerson: { id: userId } })
findOption.where['$or'].push({ state: { $gt: 4, $ne: 7 }, repairPerson: { id: userId } })
findOption.where['$or'].push({ state: { $gt: 5 }, checkPerson: { id: userId } })
findOption.where = {
...findOption.where,
}
}
const res = await models.findAll(findOption)
const res = await models.PatrolRecordIssueHandle.findAll(findOption)
ctx.status = 200;
ctx.body = {}
ctx.body = res
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
async function getPatrolRecordIssueHandleById (ctx) {
try {
const { models } = ctx.fs.dc;
const { id } = ctx.params
const res = await models.PatrolRecordIssueHandle.findOne({
where: {
},
include: [{
model: models.PatrolRecord
}]
})
ctx.status = 200;
ctx.body = res
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
@ -270,9 +331,10 @@ function editPatrolRecordIssueHandle (opts) {
module.exports = {
findPatrolRecord,
findPatrolRecordUnlicensed,
addPatrolRecord,
getPatrolRecordIssueHandle,
getPatrolRecordIssueHandleById,
addPatrolRecordIssueHandle,
editPatrolRecordIssueHandle
}

1
api/app/lib/middlewares/authenticator.js

@ -59,6 +59,7 @@ let isPathExcluded = function (opts, path, method) {
let excludeOpts = opts.exclude || [];
excludeOpts.push({ p: '/login', o: 'POST' });
excludeOpts.push({ p: '/logout', o: 'PUT' });
excludeOpts.push({ p: '/patrolRecord/unlicensed', o: 'GET' });
excludes = new ExcludesUrls(excludeOpts);
}
let excluded = excludeAll || excludes.isExcluded(path, method);

7
api/app/lib/routes/patrolManage/patrolRecord.js

@ -7,12 +7,19 @@ module.exports = function (app, router, opts) {
// 小程序端查点位最新一条数据:startTime、endTime、alarm不传
router.get('/patrolRecord/:patrolPlanId/:startTime/:endTime/:alarm/:pointId', patrolRecord.findPatrolRecord);
app.fs.api.logAttr['GET/patrolRecord/unlicensed'] = { content: '获取巡检记录', visible: true };
// 获取巡检记录,免token,用与生成巡检报告
router.get('/patrolRecord/unlicensed', patrolRecord.findPatrolRecordUnlicensed);
app.fs.api.logAttr['POST/patrolRecord/add'] = { content: '新增巡检记录', visible: true }
router.post('/patrolRecord/add', patrolRecord.addPatrolRecord);
app.fs.api.logAttr['GET/patrolRecord/issue/handle'] = { content: '获取维修处理计划', visible: true };
router.get('/patrolRecord/issue/handle', patrolRecord.getPatrolRecordIssueHandle)
app.fs.api.logAttr['GET/patrolRecord/issue/handle/:id'] = { content: '以id获取维修处理信息', visible: true };
router.get('/patrolRecord/issue/handle/:id', patrolRecord.getPatrolRecordIssueHandleById)
app.fs.api.logAttr['POST/patrolRecord/issue/handle'] = { content: '增加维修处理计划', visible: true };
router.post('/patrolRecord/issue/handle', patrolRecord.addPatrolRecordIssueHandle(opts))

3
weapp/app.json

@ -15,7 +15,8 @@
"startInspection/startInspection",
"inspectionInput/inspectionInput",
"troubleshooting/index",
"troubleshooting/shootingForm/index"
"troubleshooting/shootingForm/index",
"inspectionReport/inspectionReport"
]
}
],

1
weapp/common.js

@ -3,6 +3,7 @@ const { baseUrl } = app.globalData;
// 全局配置 请求拦截, 长时间
const buildRequest = (type, url, data) => {
console.log(type, url, data);
return new Promise((resolve, reject) => {
if (url.indexOf('token') == -1) {
let token = wx.getStorageSync('token');

1
weapp/images/inspection-report.svg

@ -0,0 +1 @@
<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1742" height="128" width="128"><path d="M947.330443 280.886557L740.015166 73.57128c-13.659654-13.659654-35.779673-13.648391-49.42704 0L71.584942 692.57344c-13.648391 13.648391-13.659654 35.767386 0 49.42704l207.315277 207.315277c13.659654 13.659654 35.779673 13.648391 49.42704 0l619.00216-619.00216c13.649415-13.647367 13.661702-35.767386 0.001024-49.42704zM303.614763 875.175196L145.726527 717.28696l39.749276-39.749276 27.055146 27.055146c13.659654 13.659654 35.779673 13.648391 49.42704 0 13.648391-13.648391 13.659654-35.767386 0-49.427041l-27.055146-27.055145 39.749276-39.749276 27.055146 27.055145c13.659654 13.659654 35.779673 13.648391 49.42704 0 13.648391-13.648391 13.659654-35.767386 0-49.428064l-27.055146-27.055146 39.749276-39.749276 27.055146 27.055146c13.659654 13.659654 35.779673 13.648391 49.42704 0 13.648391-13.648391 13.660678-35.767386 0-49.428064l-27.055146-27.055146 39.749276-39.749276 27.055146 27.055146c13.659654 13.659654 35.779673 13.648391 49.42704 0 13.648391-13.648391 13.660678-35.767386 0-49.428064l-27.055145-27.055146 39.749276-39.749276 27.055146 27.055146c13.659654 13.659654 35.779673 13.648391 49.42704 0 13.648391-13.648391 13.659654-35.767386 0-49.42704l-27.055146-27.055146 39.738013-39.738013 27.055146 27.055145c13.659654 13.660678 35.779673 13.648391 49.42704 0 13.648391-13.648391 13.659654-35.767386 0-49.42704l-27.055146-27.055146 34.52439-34.524389 157.888236 157.888237-569.571024 569.574095z" fill="#3E3A39" p-id="1743"></path></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

66
weapp/package/inspectionReport/inspectionReport.js

@ -0,0 +1,66 @@
// package/inspectionReport/inspectionReport.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

3
weapp/package/inspectionReport/inspectionReport.json

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

2
weapp/package/inspectionReport/inspectionReport.wxml

@ -0,0 +1,2 @@
<!--package/inspectionReport/inspectionReport.wxml-->
<text>package/inspectionReport/inspectionReport.wxml</text>

1
weapp/package/inspectionReport/inspectionReport.wxss

@ -0,0 +1 @@
/* package/inspectionReport/inspectionReport.wxss */

20
weapp/package/troubleshooting/index.js

@ -1,6 +1,7 @@
// package/bindTroubleshooting/index.js
import { getPatrolRecordIssueHandle } from "../../utils/getApiUrl";
import { Request } from "../../common";
const moment = require("../../utils/moment");
Page({
@ -8,7 +9,7 @@ Page({
* 页面的初始数据
*/
data: {
// hidden: true,
dataList: [],
currentTab: '0',
// 筛选选择
structList: ['a', 'b', 'c'],
@ -41,8 +42,18 @@ Page({
},
getData (params) {
Request.get(getPatrolRecordIssueHandle, {}).then(res => {
Request.get(getPatrolRecordIssueHandle(), {
...params,
}).then(res => {
console.log(res);
this.setData({
dataList: res.map(r => {
return {
...r,
createTime: r.createTime ? moment(r.createTime).format('YYYY-MM-DD HH:mm:ss') : '--'
}
})
})
})
},
@ -108,7 +119,10 @@ Page({
* 生命周期函数--监听页面初次渲染完成
*/
onReady () {
console.log(123);
this.getData({
type: 'backlog'
});
},
/**

21
weapp/package/troubleshooting/index.wxml

@ -44,18 +44,27 @@
</view>
<view style="height:100vh - 98rpx; padding-top:24rpx; overflow:auto">
<van-cell-group inset class="mission-card">
<view wx:for="{{dataList}}">
<view class="mission-card-title">
<span>asd</span>
<span>{{item.PatrolRecord.points.project.name}}</span>
<van-button type="info" round bind:tap="toShootingForm" data-shootingid="{{5}}">
按钮
{{
item.state == 1 ?'制定计划':
item.state == 2 ?'审批计划':
item.state == 3 ?'修改计划':
item.state == 4 ?'维修处理':
item.state == 5 ?'质检验收':
item.state == 6 ?'驳回重修':'查看详情'
}}
</van-button>
</view>
<van-field value="输入框已禁用" label="点位名称" readonly border="{{ false }}" />
<van-field value="输入框已禁用" label="异常等级" readonly border="{{ false }}" />
<van-field value="输入框已禁用" label="任务下发时间" readonly border="{{ false }}" />
<van-field value="{{item.PatrolRecord.points.itemData.name}}" label="点位名称" readonly border="{{ false }}" />
<van-field value="{{item.PatrolRecord.points.itemData.name}}" label="异常等级" readonly border="{{ false }}" />
<van-field value="{{ item.createTime}}" label="任务下发时间" readonly border="{{ false }}" />
</view>
</van-cell-group>
<!-- 暂无数据 -->
<view hidden="{{hidden}}">
<view wx:if="{{!dataList.length}}">
<image class="noData" src="../../images/noData.png"></image>
<view class="noTxt">暂无数据~</view>
</view>

6
weapp/pages/overview/overview.js

@ -21,6 +21,12 @@ Page({
})
},
bindInspectionReport() {
wx.navigateTo({
url: '/package/inspectionReport/inspectionReport',
})
},
/**
* 生命周期函数--监听页面加载
*/

6
weapp/pages/overview/overview.wxml

@ -10,9 +10,9 @@
<view class="txt">问题处理</view>
<image class="right" src="/images/right.svg"></image>
</view>
<!-- <view class="box">
<image class="logo" src="/images/tabBar/icon_menu.png"></image>
<view class="box" bindtap="bindInspectionReport">
<image class="logo" src="/images/inspection-report.svg"></image>
<view class="txt">巡检报告</view>
<image class="right" src="/images/right.svg"></image>
</view> -->
</view>
</view>
Loading…
Cancel
Save