From ddd06d6ab77a3643ed7ab4dd7d72e69f7b9fec19 Mon Sep 17 00:00:00 2001 From: "peng.peng" Date: Mon, 23 Oct 2023 16:50:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=EF=BC=88*=EF=BC=89=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=82=B9=E4=BD=8D=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/device/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api/app/lib/controllers/device/index.js b/api/app/lib/controllers/device/index.js index 0765c2f..a84fb43 100644 --- a/api/app/lib/controllers/device/index.js +++ b/api/app/lib/controllers/device/index.js @@ -119,10 +119,17 @@ function editDevice(opts) { function deleteDevice(opts) { return async function (ctx, next) { + let message = '删除设备失败' try { const models = ctx.fs.dc.models; const { id } = ctx.params; if (id) { + let exitPointDevice = await models.PointDevice.findOne({ where: { deviceId: { $in: id.split(',') } } }) + if (exitPointDevice) { + message = '该设备已绑定点位 无法删除!' + throw new Error(message) + } + await models.Device.destroy({ where: { id: { $in: id.split(',') } @@ -137,7 +144,7 @@ function deleteDevice(opts) { } catch (error) { ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; - ctx.body = { message: '删除设备失败' } + ctx.body = { message: message } } } } From 5d2fb67387d82662c3a28faa78ff7ded023df498 Mon Sep 17 00:00:00 2001 From: liujiangyong Date: Mon, 23 Oct 2023 16:57:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E6=AF=8F=E6=97=A5=E5=B7=A1?= =?UTF-8?q?=E6=A3=80UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- weapp/app.json | 1 + .../package/riskManagement/riskManagement.js | 2 +- .../riskManagement/riskManagement.wxml | 2 +- .../subSystem/dayPatrolInfo/dayPatrolInfo.js | 145 ++++++++++++++++++ .../dayPatrolInfo/dayPatrolInfo.json | 9 ++ .../dayPatrolInfo/dayPatrolInfo.wxml | 49 ++++++ .../dayPatrolInfo/dayPatrolInfo.wxss | 71 +++++++++ weapp/package/subSystem/subSystem.js | 6 + weapp/package/subSystem/subSystem.wxml | 2 +- 9 files changed, 284 insertions(+), 3 deletions(-) create mode 100644 weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.js create mode 100644 weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.json create mode 100644 weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.wxml create mode 100644 weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.wxss diff --git a/weapp/app.json b/weapp/app.json index 25c523a..bd34db5 100644 --- a/weapp/app.json +++ b/weapp/app.json @@ -22,6 +22,7 @@ "inspectionReport/inspectionReport", "pointsStatus/pointsStatus", "subSystem/subSystem", + "subSystem/dayPatrolInfo/dayPatrolInfo", "riskManagement/riskManagement", "riskManagement/riskCalendar/riskCalendar", "deviceBigdataGraph/deviceBigdataGraph", diff --git a/weapp/package/riskManagement/riskManagement.js b/weapp/package/riskManagement/riskManagement.js index 5b361c9..d3c7df3 100644 --- a/weapp/package/riskManagement/riskManagement.js +++ b/weapp/package/riskManagement/riskManagement.js @@ -139,7 +139,7 @@ Page({ * 生命周期函数--监听页面初次渲染完成 */ onReady() { - this.ecComponent = this.selectComponent('#risk-trend-chart'); + this.ecComponent = this.selectComponent('#risk-trend-chart-dom'); }, /** diff --git a/weapp/package/riskManagement/riskManagement.wxml b/weapp/package/riskManagement/riskManagement.wxml index 62627cd..08a1cdc 100644 --- a/weapp/package/riskManagement/riskManagement.wxml +++ b/weapp/package/riskManagement/riskManagement.wxml @@ -21,7 +21,7 @@ 历史风险趋势 - + diff --git a/weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.js b/weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.js new file mode 100644 index 0000000..4d6dd6d --- /dev/null +++ b/weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.js @@ -0,0 +1,145 @@ +// package/subSystem/dayPatrolInfo/dayPatrolInfo.js +import * as echarts from '../../components/ec-canvas/echarts'; + +const setPieOptions = ((chart, data) => { + const option = { + grid: { + top: '0%', + left: '3%', + right: '4%', + bottom: '3%', + containLabel: true + }, + tooltip: { + trigger: 'item' + }, + legend: { + top: 'bottom', + }, + series: [ + { + type: 'pie', + radius: ['30%', '55%'], + // avoidLabelOverlap: false, + emphasis: { + label: { + show: true, + fontWeight: 'bold' + } + }, + data: data + } + ] + }; + chart.setOption(option); +}) + +Page({ + + /** + * 页面的初始数据 + */ + data: { + needEc: { lazyLoad: true }, + alreadyEc: { lazyLoad: true }, + }, + + // 今日待检分布图表 + initNeedChart: function (data) { + this.needEcComponent.init((canvas, width, height, dpr) => { + const chart = echarts.init(canvas, null, { + width: width, + height: height, + devicePixelRatio: dpr // new + }); + setPieOptions(chart, data) + return chart; + }); + }, + + // 今日已检分布图表 + initAlreadyChart: function (data) { + this.alreadyEcComponent.init((canvas, width, height, dpr) => { + const chart = echarts.init(canvas, null, { + width: width, + height: height, + devicePixelRatio: dpr // new + }); + setPieOptions(chart, data) + return chart; + }); + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + wx.setNavigationBarTitle({ title: options.day }) + setTimeout(() => { + this.initNeedChart([ + { value: 1048, name: 'Search Engine' }, + { value: 735, name: 'Direct' }, + { value: 580, name: 'Email' }, + { value: 580, name: 'Email2' }, + { value: 580, name: 'Email3' }, + ]) + this.initAlreadyChart([ + { value: 1048, name: 'Search Engine' }, + { value: 735, name: 'Direct' }, + { value: 580, name: 'Email' }, + { value: 580, name: 'Email2' }, + { value: 580, name: 'Email3' }, + ]) + }, 1000) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + this.needEcComponent = this.selectComponent('#need-chart-dom'); + this.alreadyEcComponent = this.selectComponent('#already-chart-dom'); + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.json b/weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.json new file mode 100644 index 0000000..d3df100 --- /dev/null +++ b/weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.json @@ -0,0 +1,9 @@ +{ + "navigationBarBackgroundColor": "#006BE3", + "navigationBarTextStyle": "white", + "navigationBarTitleText": "", + "enablePullDownRefresh": false, + "usingComponents": { + "ec-canvas": "../../components/ec-canvas/ec-canvas" + } +} \ No newline at end of file diff --git a/weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.wxml b/weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.wxml new file mode 100644 index 0000000..61c57e0 --- /dev/null +++ b/weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.wxml @@ -0,0 +1,49 @@ + + + + + + + 今日问题分布 + + + + + 类型1: + + + + + + + + 今日待检分布 + + 总次数:{{50}}次 + + + + + + + + + + + 今日已检分布 + + 总次数:{{50}}次 + + + + + + + diff --git a/weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.wxss b/weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.wxss new file mode 100644 index 0000000..ddd1ace --- /dev/null +++ b/weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.wxss @@ -0,0 +1,71 @@ +.day-patrol-info { + height: 100%; + background-image: linear-gradient(179deg, #006BE3 0%, #4E87FF 16%, #4e87ff00 93%); + padding: 0 15px 15px; +} + +.card { + box-sizing: border-box; + background: #FFFFFF; + box-shadow: 2px 2px 11px 0 #00000008, 0 0 4px 0 #00000012; + border-radius: 4px; +} + +.card-top { + height: 68px; + background-image: linear-gradient(0deg, #F3F7FF 84%, #DBE6FF 100%); + border-radius: 4px; + position: relative; +} + +.card-bg { + position: absolute; + top: 0; + right: 11px; + width: 115px; + height: 67px; +} + +.card-left { + margin-left: 23px; + font-weight: 500; + font-size: 16px; + color: #000000d9; +} + +.card-right { + margin-right: 18px; + color: #1684FF; +} + +.card-icon { + width: 30px; + height: 30px; + margin-right: 8px; +} + +.problem-box { + width: 100%; + height: 58px; + padding: 18px; + border-top: 1px solid rgb(238, 237, 237); + box-sizing: border-box; +} + +.problem-title { + width: 30%; + font-size: 14px; + color: #383A3B; +} + +.t-class-label { + font-size: 14px; + color: #383A3B; +} + +.pie-chart-box { + box-sizing: border-box; + width: 100%; + height: 280px; + padding: 0 10px 10px; +} \ No newline at end of file diff --git a/weapp/package/subSystem/subSystem.js b/weapp/package/subSystem/subSystem.js index 4fd2068..e280e74 100644 --- a/weapp/package/subSystem/subSystem.js +++ b/weapp/package/subSystem/subSystem.js @@ -68,6 +68,12 @@ Page({ }); }, + onDateSelect(e) { + wx.navigateTo({ + url: `/package/subSystem/dayPatrolInfo/dayPatrolInfo?day=${moment(e.detail).format('YYYY-MM-DD')}`, + }) + }, + /** * 生命周期函数--监听页面加载 */ diff --git a/weapp/package/subSystem/subSystem.wxml b/weapp/package/subSystem/subSystem.wxml index 0d26260..54b1b6f 100644 --- a/weapp/package/subSystem/subSystem.wxml +++ b/weapp/package/subSystem/subSystem.wxml @@ -36,6 +36,6 @@ {{currentYear+'年'+currentMonth+'月'}} - + \ No newline at end of file