peng.peng 2 years ago
parent
commit
b80059cc67
  1. 52
      api/app/lib/controllers/patrolManage/patrolRecord.js
  2. 3
      api/app/lib/routes/patrolManage/patrolRecord.js
  3. 14
      weapp/app.js
  4. 20
      weapp/package/troubleshooting/index.js
  5. 3
      weapp/package/troubleshooting/index.json
  6. 3
      weapp/package/troubleshooting/shootingForm/index.json
  7. 4
      weapp/utils/getApiUrl.js

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

@ -151,8 +151,14 @@ async function addPatrolRecord(ctx, next) {
const lastInspectionTime = pointRecord.length ? pointRecord[0].dataValues.inspectionTime : null;
let record = { patrolPlanId, lastInspectionTime, inspectionTime, points, alarm, pointId }
await models.PatrolRecord.create(record, transaction);
const recordRes = await models.PatrolRecord.create(record, transaction);
if (alarm) {
await models.PatrolRecord.create({
patrolRecordId: recordRes.id,
state: 1,
}, transaction);
}
// 更新巡检次数统计
const curPlanRecord = await models.PatrolRecord.findAndCountAll({
where: { patrolPlanId }
@ -177,6 +183,49 @@ async function addPatrolRecord(ctx, next) {
}
}
async function getPatrolRecordIssueHandle (ctx) {
try {
const { models } = ctx.fs.dc;
const { userId, userInfo } = ctx.fs.api
const { type, } = ctx.query
let findOption = {
where: {
},
include: [{
model: models.PatrolRecord
}]
}
if (type == 'backlog') {
// 待办
let stateArr = []
if (userInfo) {
}
findOption.where = {
...findOption.where,
}
} else if (type == 'haveDone') {
// 已办
}
const res = await models.findAll(findOption)
ctx.status = 200;
ctx.body = {}
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
// 新建维修处理计划成功
function addPatrolRecordIssueHandle (opts) {
return async function (ctx, next) {
@ -222,6 +271,7 @@ function editPatrolRecordIssueHandle(opts) {
module.exports = {
findPatrolRecord,
addPatrolRecord,
getPatrolRecordIssueHandle,
addPatrolRecordIssueHandle,
editPatrolRecordIssueHandle

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

@ -10,6 +10,9 @@ module.exports = function (app, router, opts) {
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['POST/patrolRecord/issue/handle'] = { content: '增加维修处理计划', visible: true };
router.post('/patrolRecord/issue/handle', patrolRecord.addPatrolRecordIssueHandle(opts))

14
weapp/app.js

@ -3,9 +3,17 @@ App({
onLaunch () { },
globalData: {
userInfo: null,
baseUrl: 'http://10.8.30.112:4900', //api 本地环境
webUrl: "http://10.8.30.112:5900/", //web 本地环境
imgUrl: 'http://10.8.30.112:5900/_file-server/', //文件 本地环境
baseUrl: 'http://10.8.30.112:4900', //api 镇江本地环境
webUrl: "http://10.8.30.112:5900/", //web 镇江本地环境
imgUrl: 'http://10.8.30.112:5900/_file-server/', //文件 镇江本地环境
// baseUrl: 'http://10.8.16.102:4900', //api 南昌本地环境
// webUrl: "http://10.8.16.102:5900/", //web 南昌本地环境
// imgUrl: 'http://10.8.16.102:5900/_file-server/', //文件 南昌本地环境
// baseUrl: 'http://127.0.0.1:6015', //api 测试环境
// webUrl: "http://127.0.0.1:6014/", //web 测试环境
// imgUrl: 'http://127.0.0.1:6014/_file-server/', //文件 本测试环境
key: 'ODQBZ-3FZAU-6VIVL-2XXNM-F7CP7-WVFCY' //获取位置信息
},
onShow (e) {

20
weapp/package/troubleshooting/index.js

@ -1,4 +1,7 @@
// package/bindTroubleshooting/index.js
import { getPatrolRecordIssueHandle } from "../../utils/getApiUrl";
import { Request } from "../../common";
Page({
/**
@ -23,15 +26,24 @@ Page({
currentTab: e.currentTarget.dataset.current
})
if (e.currentTarget.dataset.current == '0') {
} else if (e.currentTarget.dataset.current == '1') {
}
this.setData({
page: 0,
dataList: []
}, () => {
// this.getPatrolPlan();
this.getData({
type: e.currentTarget.dataset.current == '0' ? 'backlog' : 'haveDone'
});
})
},
getData (params) {
Request.get(getPatrolRecordIssueHandle, {}).then(res => {
console.log(res);
})
} else if (e.currentTarget.dataset.current == '1') {
// this.getPatrolRecord();
}
},
// 筛选选择

3
weapp/package/troubleshooting/index.json

@ -1,4 +1,7 @@
{
"navigationBarBackgroundColor": "#1979ff",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "问题处理",
"usingComponents": {
"van-button": "@vant/weapp/button/index",
"van-field": "@vant/weapp/field/index",

3
weapp/package/troubleshooting/shootingForm/index.json

@ -1,4 +1,7 @@
{
"navigationBarBackgroundColor": "#1979ff",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "问题处理",
"usingComponents": {
"van-button": "@vant/weapp/button/index",
"van-field": "@vant/weapp/field/index",

4
weapp/utils/getApiUrl.js

@ -32,3 +32,7 @@ exports.getPatrolRecord = (patrolPlanId, startTime, endTime, alarm, pointId) =>
exports.getPatrolTemplate = (id) => {
return `/patrolTemplate?id=${id}`
}
exports.getPatrolRecordIssueHandle = (id) => {
return `/patrolRecord/issue/handle`
}
Loading…
Cancel
Save