From fd1e0d6ed90e48ab483d365aebf21da535ce3323 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Wed, 1 Mar 2023 17:26:04 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=BE=85=E5=8A=9E=E3=80=81=E5=B7=B2=E5=8A=9E=E4=BA=8B=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/patrolManage/patrolRecord.js | 26 ++++++++++++++----- weapp/common.js | 1 + weapp/package/troubleshooting/index.js | 9 +++++-- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/api/app/lib/controllers/patrolManage/patrolRecord.js b/api/app/lib/controllers/patrolManage/patrolRecord.js index d6a18cf..1c6cfcf 100644 --- a/api/app/lib/controllers/patrolManage/patrolRecord.js +++ b/api/app/lib/controllers/patrolManage/patrolRecord.js @@ -192,7 +192,7 @@ async function getPatrolRecordIssueHandle (ctx) { let findOption = { where: { - + $or: [] }, include: [{ model: models.PatrolRecord @@ -201,22 +201,34 @@ 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; diff --git a/weapp/common.js b/weapp/common.js index a8abae1..3153dd6 100644 --- a/weapp/common.js +++ b/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'); diff --git a/weapp/package/troubleshooting/index.js b/weapp/package/troubleshooting/index.js index dd2f714..537377b 100644 --- a/weapp/package/troubleshooting/index.js +++ b/weapp/package/troubleshooting/index.js @@ -41,7 +41,9 @@ Page({ }, getData (params) { - Request.get(getPatrolRecordIssueHandle, {}).then(res => { + Request.get(getPatrolRecordIssueHandle(), { + ...params, + }).then(res => { console.log(res); }) }, @@ -108,7 +110,10 @@ Page({ * 生命周期函数--监听页面初次渲染完成 */ onReady () { - + console.log(123); + this.getData({ + type: 'backlog' + }); }, /** From 0443001aca18aab0b2aa99aa60d8ccd9924fa6bc Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Thu, 2 Mar 2023 09:23:21 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BB=A5id=E8=8E=B7=E5=8F=96=E7=BB=B4?= =?UTF-8?q?=E4=BF=AE=E5=A4=84=E7=90=86=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/patrolManage/patrolRecord.js | 26 ++++++++++++++++++ .../lib/routes/patrolManage/patrolRecord.js | 3 +++ weapp/package/troubleshooting/index.js | 11 +++++++- weapp/package/troubleshooting/index.wxml | 27 ++++++++++++------- 4 files changed, 57 insertions(+), 10 deletions(-) diff --git a/api/app/lib/controllers/patrolManage/patrolRecord.js b/api/app/lib/controllers/patrolManage/patrolRecord.js index 1c6cfcf..6112c66 100644 --- a/api/app/lib/controllers/patrolManage/patrolRecord.js +++ b/api/app/lib/controllers/patrolManage/patrolRecord.js @@ -238,6 +238,31 @@ async function getPatrolRecordIssueHandle (ctx) { } } +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; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } +} + // 新建维修处理计划成功 function addPatrolRecordIssueHandle (opts) { return async function (ctx, next) { @@ -284,6 +309,7 @@ module.exports = { findPatrolRecord, addPatrolRecord, getPatrolRecordIssueHandle, + getPatrolRecordIssueHandleById, addPatrolRecordIssueHandle, editPatrolRecordIssueHandle diff --git a/api/app/lib/routes/patrolManage/patrolRecord.js b/api/app/lib/routes/patrolManage/patrolRecord.js index 8fd68ba..2c21e7a 100644 --- a/api/app/lib/routes/patrolManage/patrolRecord.js +++ b/api/app/lib/routes/patrolManage/patrolRecord.js @@ -13,6 +13,9 @@ module.exports = function (app, router, opts) { 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)) diff --git a/weapp/package/troubleshooting/index.js b/weapp/package/troubleshooting/index.js index 537377b..cd58877 100644 --- a/weapp/package/troubleshooting/index.js +++ b/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'], @@ -45,6 +46,14 @@ Page({ ...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') : '--' + } + }) + }) }) }, diff --git a/weapp/package/troubleshooting/index.wxml b/weapp/package/troubleshooting/index.wxml index 45c5093..e1f991f 100644 --- a/weapp/package/troubleshooting/index.wxml +++ b/weapp/package/troubleshooting/index.wxml @@ -44,18 +44,27 @@ - - asd - - 按钮 - + + + {{item.PatrolRecord.points.project.name}} + + {{ + item.state == 1 ?'制定计划': + item.state == 2 ?'审批计划': + item.state == 3 ?'修改计划': + item.state == 4 ?'维修处理': + item.state == 5 ?'质检验收': + item.state == 6 ?'驳回重修':'查看详情' + }} + + + + + - - - - - + \ No newline at end of file