zhaobing’ 1 year ago
parent
commit
88df733e95
  1. 9
      api/app/lib/controllers/device/index.js
  2. 1
      weapp/app.json
  3. 2
      weapp/package/riskManagement/riskManagement.js
  4. 2
      weapp/package/riskManagement/riskManagement.wxml
  5. 145
      weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.js
  6. 9
      weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.json
  7. 49
      weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.wxml
  8. 71
      weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.wxss
  9. 6
      weapp/package/subSystem/subSystem.js
  10. 2
      weapp/package/subSystem/subSystem.wxml

9
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 }
}
}
}

1
weapp/app.json

@ -22,6 +22,7 @@
"inspectionReport/inspectionReport",
"pointsStatus/pointsStatus",
"subSystem/subSystem",
"subSystem/dayPatrolInfo/dayPatrolInfo",
"riskManagement/riskManagement",
"riskManagement/riskCalendar/riskCalendar",
"deviceBigdataGraph/deviceBigdataGraph",

2
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');
},
/**

2
weapp/package/riskManagement/riskManagement.wxml

@ -21,7 +21,7 @@
<view class="card-title">历史风险趋势</view>
</view>
<view class="chart">
<ec-canvas id="risk-trend-chart" canvas-id="risk-trend-chart" ec="{{ ec }}"></ec-canvas>
<ec-canvas id="risk-trend-chart-dom" canvas-id="risk-trend-chart" ec="{{ ec }}"></ec-canvas>
</view>
</view>

145
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() {
}
})

9
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"
}
}

49
weapp/package/subSystem/dayPatrolInfo/dayPatrolInfo.wxml

@ -0,0 +1,49 @@
<!--package/subSystem/dayPatrolInfo/dayPatrolInfo.wxml-->
<view class="day-patrol-info">
<view class="card" style="margin-bottom: 10px">
<view class="card-top flex flex-between">
<view class="card-left flex">
<image class="card-icon" src="/images/right_icon.png" />
<view class="title">今日问题分布</view>
</view>
<image src="/images/right_card_bg.png" class="card-bg" />
</view>
<view wx:for="{{[1,2,3,4]}}" class="problem-box flex">
<view class="problem-title text---">类型1:</view>
<progress
style="width: 70%;"
percent="{{80}}"
stroke-width="8"
show-info
font-size="14"
border-radius="4"
/>
</view>
</view>
<view class="card" style="margin-bottom: 10px">
<view class="card-top flex flex-between">
<view class="card-left flex">
<image class="card-icon" src="/images/right_icon.png" />
<view class="title">今日待检分布</view>
</view>
<view class="card-right">总次数:{{50}}次</view>
<image src="/images/right_card_bg.png" class="card-bg" />
</view>
<view class="pie-chart-box">
<ec-canvas id="need-chart-dom" canvas-id="need-chart" ec="{{ needEc }}"></ec-canvas>
</view>
</view>
<view class="card" style="margin-bottom: 10px">
<view class="card-top flex flex-between">
<view class="card-left flex">
<image class="card-icon" src="/images/right_icon.png" />
<view class="title">今日已检分布</view>
</view>
<view class="card-right">总次数:{{50}}次</view>
<image src="/images/right_card_bg.png" class="card-bg" />
</view>
<view class="pie-chart-box">
<ec-canvas id="already-chart-dom" canvas-id="already-chart" ec="{{ alreadyEc }}"></ec-canvas>
</view>
</view>
</view>

71
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;
}

6
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')}`,
})
},
/**
* 生命周期函数--监听页面加载
*/

2
weapp/package/subSystem/subSystem.wxml

@ -36,6 +36,6 @@
<image src="/images/shape2.png" class="imgStyle"></image>
<view class="yearMonth">{{currentYear+'年'+currentMonth+'月'}}</view>
</view>
<van-calendar max-date="{{lastDay}}" v-model="selectedDate" readonly show-title="{{false}}" show-subtitle="{{false}}" poppable="{{ false }}" show-confirm="{{ false }}" default-date="{{selectedDate}}" formatter="{{formatter}}" color="#0000FF" class="calendar" />
<van-calendar max-date="{{lastDay}}" v-model="selectedDate" show-title="{{false}}" show-subtitle="{{false}}" poppable="{{ false }}" show-confirm="{{ false }}" default-date="{{selectedDate}}" formatter="{{formatter}}" bind:select="onDateSelect" color="#0000FF" class="calendar" />
</view>
</view>
Loading…
Cancel
Save