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

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

@ -1,6 +1,6 @@
'use strict';
async function findPatrolRecord(ctx, next) {
async function findPatrolRecord (ctx, next) {
let rslt = [];
let error = { name: 'FindError', message: '获取巡检记录失败' };
try {
@ -136,7 +136,7 @@ async function findPatrolRecord(ctx, next) {
}
}
async function addPatrolRecord(ctx, next) {
async function addPatrolRecord (ctx, next) {
let error = { name: 'addError', message: '新增巡检记录失败' };
const transaction = await ctx.fs.dc.orm.transaction();
try {
@ -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,8 +183,51 @@ 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) {
function addPatrolRecordIssueHandle (opts) {
return async function (ctx, next) {
const models = ctx.fs.dc.models;
@ -197,7 +246,7 @@ function addPatrolRecordIssueHandle(opts) {
// 修改维修处理计划
function editPatrolRecordIssueHandle(opts) {
function editPatrolRecordIssueHandle (opts) {
return async function (ctx, next) {
try {
@ -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) {

26
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') {
this.setData({
page: 0,
dataList: []
}, () => {
// this.getPatrolPlan();
})
} else if (e.currentTarget.dataset.current == '1') {
// this.getPatrolRecord();
}
this.setData({
page: 0,
dataList: []
}, () => {
this.getData({
type: e.currentTarget.dataset.current == '0' ? 'backlog' : 'haveDone'
});
})
},
getData (params) {
Request.get(getPatrolRecordIssueHandle, {}).then(res => {
console.log(res);
})
},
// 筛选选择

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",

18
weapp/utils/getApiUrl.js

@ -1,34 +1,38 @@
// 登录
exports.loginUrl = () => {
return `/login`
return `/login`
}
// 登出
exports.logoutUrl = () => {
return `/logout`
return `/logout`
}
// 获取巡检总览
exports.getProjectList = () => {
return `/projectList`
return `/projectList`
}
// 获取巡检计划
exports.getPatrolPlan = () => {
return `/patrolPlan`
return `/patrolPlan`
}
// 开始巡检录入
exports.addPatrolRecord = () => {
return `/patrolRecord/add`
return `/patrolRecord/add`
}
// 获取巡检记录
exports.getPatrolRecord = (patrolPlanId, startTime, endTime, alarm, pointId) => {
return `/patrolRecord/${patrolPlanId}/${startTime}/${endTime}/${alarm}/${pointId}`
return `/patrolRecord/${patrolPlanId}/${startTime}/${endTime}/${alarm}/${pointId}`
}
// 获取巡检模板
exports.getPatrolTemplate = (id) => {
return `/patrolTemplate?id=${id}`
return `/patrolTemplate?id=${id}`
}
exports.getPatrolRecordIssueHandle = (id) => {
return `/patrolRecord/issue/handle`
}
Loading…
Cancel
Save