peng.peng 1 year ago
parent
commit
6c9d7a6478
  1. 150
      api/app/lib/controllers/device/index.js
  2. 34
      api/app/lib/controllers/patrolManage/patrolRecord.js
  3. 30
      api/app/lib/controllers/projectRegime/projectSituation.js
  4. 14
      api/app/lib/index.js
  5. 23
      api/app/lib/routes/device/index.js
  6. 4
      api/app/lib/routes/patrolManage/patrolRecord.js
  7. 44
      weapp/app.js
  8. 30
      weapp/app.json
  9. 60
      weapp/app.wxss
  10. 32
      weapp/custom-tab-bar/index.js
  11. 3
      weapp/custom-tab-bar/index.json
  12. 8
      weapp/custom-tab-bar/index.wxml
  13. 38
      weapp/custom-tab-bar/index.wxss
  14. BIN
      weapp/images/check.png
  15. 0
      weapp/images/elevator.png
  16. BIN
      weapp/images/sevenDays.png
  17. BIN
      weapp/images/tabBar/icon_home.png
  18. BIN
      weapp/images/tabBar/icon_home_active.png
  19. BIN
      weapp/images/workbench/expert_systems.png
  20. BIN
      weapp/images/workbench/issues.png
  21. BIN
      weapp/images/workbench/report.png
  22. BIN
      weapp/images/xunjian.png
  23. 284
      weapp/package/components/ec-canvas/ec-canvas.js
  24. 1
      weapp/package/components/ec-canvas/ec-canvas.json
  25. 4
      weapp/package/components/ec-canvas/ec-canvas.wxml
  26. 4
      weapp/package/components/ec-canvas/ec-canvas.wxss
  27. 45
      weapp/package/components/ec-canvas/echarts.js
  28. 111
      weapp/package/components/ec-canvas/wx-canvas.js
  29. 2
      weapp/package/homePage/homePage.wxml
  30. 1
      weapp/package/homePage/homePage.wxss
  31. 2
      weapp/package/riskManagement/riskCalendar/riskCalendar.js
  32. 9
      weapp/package/riskManagement/riskCalendar/riskCalendar.json
  33. 2
      weapp/package/riskManagement/riskCalendar/riskCalendar.wxml
  34. 1
      weapp/package/riskManagement/riskCalendar/riskCalendar.wxss
  35. 126
      weapp/package/riskManagement/riskManagement.js
  36. 9
      weapp/package/riskManagement/riskManagement.json
  37. 41
      weapp/package/riskManagement/riskManagement.wxml
  38. 76
      weapp/package/riskManagement/riskManagement.wxss
  39. 242
      weapp/package/subSystem/subSystem.js
  40. 8
      weapp/package/subSystem/subSystem.json
  41. 35
      weapp/package/subSystem/subSystem.wxml
  42. 70
      weapp/package/subSystem/subSystem.wxss
  43. 239
      weapp/pages/home/home.js
  44. 59
      weapp/pages/home/home.wxml
  45. 24
      weapp/pages/home/home.wxss
  46. 294
      weapp/pages/index/index.js
  47. 2
      weapp/pages/index/index.wxss
  48. 229
      weapp/pages/login/login.js
  49. 170
      weapp/pages/myInfo/myInfo.js
  50. 209
      weapp/pages/myInfo/myInfo.wxss
  51. 166
      weapp/pages/overview/overview.js
  52. 107
      weapp/pages/workbench/workbench.js
  53. 6
      weapp/pages/workbench/workbench.json
  54. 9
      weapp/pages/workbench/workbench.wxml
  55. 33
      weapp/pages/workbench/workbench.wxss
  56. 2
      weapp/project.config.json
  57. 3
      weapp/project.private.config.json
  58. 6
      weapp/utils/getApiUrl.js

150
api/app/lib/controllers/device/index.js

@ -0,0 +1,150 @@
'use strict';
const moment = require('moment')
function getDeviceList(opts) {
return async function (ctx, next) {
const models = ctx.fs.dc.models;
const { page, limit, name } = ctx.query;
const Op = ctx.fs.dc.ORM.Op;
let errMsg = { message: '获取设备失败' }
try {
let searchWhere = {}
let option = {
where: searchWhere,
order: [["id", "desc"]],
include: [{ model: models.PointDevice }]
}
if (name) {
searchWhere.name = { $like: `%${name}%` };
}
option.where = searchWhere
let limit_ = limit || 10;
let page_ = page || 1;
let offset = (page_ - 1) * limit_;
if (limit && page) {
option.limit = limit_
option.offset = offset
}
const res = await models.Device.findAndCount(option);
ctx.status = 200;
ctx.body = res;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = errMsg
}
}
}
// 新增设备
function addDevice(opts) {
let message = '新建设备失败'
return async function (ctx, next) {
const models = ctx.fs.dc.models;
try {
if (Array.isArray(ctx.request.body)) {
const names = ctx.request.body.map(s => s.name)
const checkName = await models.Device.findOne({ where: { name: { $in: names } } });
if (checkName) {
message = checkName.name + '名称已存在'
throw new Error(message)
} else {
await models.Device.bulkCreate(ctx.request.body)
ctx.status = 204;
ctx.body = { message: '批量导入设备成功' }
}
} else {
const { name } = ctx.request.body
const checkName = await models.Device.findOne({ where: { name } });
if (checkName) {
message = '该设备名称已存在'
throw new Error(message)
} else {
let rslt = ctx.request.body;
await models.Device.create(Object.assign({}, rslt))
ctx.status = 204;
ctx.body = { message: '新建设备成功' }
}
}
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = { message: message }
}
}
}
// 修改设备
function editDevice(opts) {
let message = '新建设备失败'
return async function (ctx, next) {
try {
const models = ctx.fs.dc.models;
const { id } = ctx.params;
const body = ctx.request.body;
const { name } = ctx.request.body;
const checkName = await models.Device.findOne({ where: { id: { $not: id }, name } });
if (checkName) {
message = '该设备名称已存在'
throw new Error(message)
} else {
await models.Device.update(
body,
{ where: { id: id, } }
)
ctx.status = 204;
ctx.body = { message: '修改设备成功' }
}
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = { message: message }
}
}
}
// 删除设备
function deleteDevice(opts) {
return async function (ctx, next) {
try {
const models = ctx.fs.dc.models;
const { id } = ctx.params;
if (id) {
await models.Device.destroy({
where: {
id: { $in: id.split(',') }
}
})
ctx.status = 204;
ctx.body = { message: '删除设备成功' }
} else {
throw new Error('参数异常!')
}
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = { message: '删除设备失败' }
}
}
}
module.exports = {
getDeviceList,
addDevice,
editDevice,
deleteDevice
}

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

@ -412,6 +412,37 @@ function editPatrolRecordIssueHandle(opts) {
}
}
}
//查询子系统的当月的巡检和维修
function getSubSystemPatrolAbout(opts) {
return async function (ctx, next){
try{
let rslt=[]
const models = ctx.fs.dc.models;
const {STime,ETime,keywords}=ctx.query
let generalInclude = [{model: models.PatrolRecordIssueHandle},{model:models.Project,where:{subType :{$like: `%${keywords}%`}}}]
rslt=await models.PatrolRecord.findAll({
where:{inspectionTime: { $between: [STime, ETime] }},
include:generalInclude
})
let userInfo = ctx.fs.api.userInfo;
rslt = rslt.filter(f => f)
if (userInfo.username != 'SuperAdmin') {
if (userInfo.structure) {
rslt = rslt.filter(s => userInfo.structure.find(x => x == s.points.project.id))
} else {
rslt = []
}
}
ctx.status = 200;
ctx.body = rslt
}catch(error){
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = { message: '子系统查询巡检记录失败' }
}
}
}
//
Array.prototype.group = function (callback, thisArg = null) {
// 参数合法性判断
@ -441,5 +472,6 @@ module.exports = {
getPatrolRecordIssueHandle,
getPatrolRecordIssueHandleById,
addPatrolRecordIssueHandle,
editPatrolRecordIssueHandle
editPatrolRecordIssueHandle,
getSubSystemPatrolAbout
}

30
api/app/lib/controllers/projectRegime/projectSituation.js

@ -55,10 +55,10 @@ async function postAddProject(ctx, next) {
const models = ctx.fs.dc.models;
let userInfo = ctx.fs.api.userInfo;
const data = ctx.request.body;
const { img, longitude, latitude, name, type, describe } = data
const { img, longitude, latitude, name, type, describe, subType } = data
let errMsg = data.id ? '结构物编辑失败' : '结构物新增失败'
let project = { img, longitude, latitude, name, type, describe, userId: userInfo.id }
let project = { img, longitude, latitude, name, type, describe, userId: userInfo.id, subType }
const alikeProject = await models.Project.findOne({
where: {
@ -225,8 +225,21 @@ async function addPosition(ctx, next) {
})
}
const pointDevicesNow = await models.PointDevice.findAll({ pointId: data.id })
let deleteIds = pointDevicesNow.filter(s => !data.devices.find(x => x == s.deviceId)).map(v => v.deviceId)
let addPointDevices = data.devices.filter(s => !pointDevicesNow.find(x => x.deviceId == s)).map(v => {
return { deviceId: v, pointId: data.id }
})
await models.PointDevice.destroy({ where: { deviceId: { $in: deleteIds }, pointId: data.id } })
await models.PointDevice.bulkCreate(addPointDevices)
} else {
await models.Point.create(pointData)
const point = await models.Point.create(pointData)
const pointDevices = []
data.devices.map(s => {
pointDevices.push({ deviceId: s, pointId: point.dataValues.id })
})
await models.PointDevice.bulkCreate(pointDevices)
}
ctx.status = 204;
@ -251,7 +264,14 @@ async function position(ctx, next) {
},
include: [{
model: models.Point,
},],
include: [{
model: models.PointDevice,
attributes: ["deviceId"],
include: [{
model: models.Device,
}]
}]
}],
}
if (limit) {
options.limit = Number(limit)
@ -342,6 +362,8 @@ async function delPosition(ctx, next) {
}
})
await models.PointDevice.destroy({ where: { pointId: id } })
ctx.status = 204;
} catch (error) {

14
api/app/lib/index.js

@ -56,12 +56,16 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq
const { Department, User, UserResource, Resource, Project, Point,
PatrolPlan, PatrolRecord, ReportInfo, PatrolPlanUser,
CheckItems, CheckItemsGroup,
PatrolTemplate, PatrolTemplateCheckItems, PatrolRecordIssueHandle
PatrolTemplate, PatrolTemplateCheckItems, PatrolRecordIssueHandle,
Device, PointDevice
} = dc.models;
PatrolRecord.belongsTo(PatrolPlan, { foreignKey: 'patrolPlanId', targetKey: 'id' });
PatrolPlan.hasMany(PatrolRecord, { foreignKey: 'patrolPlanId', sourceKey: 'id' });
PatrolRecord.belongsTo(Project, { foreignKey: 'projectId', targetKey: 'id' });
Project.hasMany(PatrolRecord, { foreignKey: 'projectId', sourceKey: 'id' });
PatrolRecordIssueHandle.belongsTo(PatrolRecord, { foreignKey: 'patrolRecordId', targetKey: 'id' });
PatrolRecord.hasMany(PatrolRecordIssueHandle, { foreignKey: 'patrolRecordId', sourceKey: 'id' });
@ -93,7 +97,7 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq
PatrolPlan.belongsTo(Project, { foreignKey: 'structureId', targetKey: 'id' });
Project.hasMany(PatrolPlan, { foreignKey: 'structureId', sourceKey: 'id' });
PatrolPlan.belongsToMany(User, { through: PatrolPlanUser, foreignKey: 'patrolPlanId', otherKey: 'userId' });
PatrolPlan.belongsToMany(User, { through: PatrolPlanUser, foreignKey: 'patrolPlanId', otherKey: 'userId' });
User.belongsToMany(PatrolPlan, { through: PatrolPlanUser, foreignKey: 'userId', otherKey: 'patrolPlanId' });
ReportInfo.belongsTo(Project, { foreignKey: 'projectId', targetKey: 'id' });
@ -101,4 +105,10 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq
CheckItems.belongsTo(CheckItemsGroup, { foreignKey: 'groupId', targetKey: 'id' });
CheckItemsGroup.hasMany(CheckItems, { foreignKey: 'groupId', sourceKey: 'id' });
PointDevice.belongsTo(Point, { foreignKey: 'pointId', targetKey: 'id' });
Point.hasMany(PointDevice, { foreignKey: 'pointId', sourceKey: 'id' });
PointDevice.belongsTo(Device, { foreignKey: 'deviceId', targetKey: 'id' });
Device.hasMany(PointDevice, { foreignKey: 'deviceId', sourceKey: 'id' });
};

23
api/app/lib/routes/device/index.js

@ -0,0 +1,23 @@
'use strict';
const device = require('../../controllers/device/index');
module.exports = function (app, router, opts, AuthCode) {
app.fs.api.logAttr['POST/device'] = { content: '增加设备信息', visible: true };
router.post('/device', device.addDevice(opts))
// 修改设备信息
app.fs.api.logAttr['PUT/device/:id'] = { content: '修改设备信息', visible: true };
router.put('/device/:id', device.editDevice(opts))
// 删除设备信息
app.fs.api.logAttr['DEL/device/:id'] = { content: '删除设备信息', visible: true };
router.del('/device/:id', device.deleteDevice(opts))
// 获取设备信息列表
app.fs.api.logAttr['GET/device'] = { content: '获取设备信息列表', visible: true };
router.get('/device', device.getDeviceList(opts));
};

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

@ -30,4 +30,8 @@ module.exports = function (app, router, opts) {
// 修改维修处理计划
app.fs.api.logAttr['PUT/patrolRecord/issue/handle/:id'] = { content: '修改维修处理计划', visible: true };
router.put('/patrolRecord/issue/handle/:id', patrolRecord.editPatrolRecordIssueHandle(opts))
//子系统巡检记录
app.fs.api.logAttr['GET/patrolRecord/subSystemPatrolAbout'] = { content: '子系统查询巡检记录', visible: true };
router.get('/patrolRecord/subSystemPatrolAbout', patrolRecord.getSubSystemPatrolAbout(opts))
};

44
weapp/app.js

@ -14,7 +14,49 @@ App({
// 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' //获取位置信息
key: 'ODQBZ-3FZAU-6VIVL-2XXNM-F7CP7-WVFCY', //获取位置信息
inspecterList: [ // 巡检人员tabBar / app.json 也要写
{
"pagePath": "/pages/index/index",
"iconPath": "/images/tabBar/icon_polling.png",
"selectedIconPath": "/images/tabBar/icon_polling_active.png",
"text": "巡检总览"
},
{
"pagePath": "/pages/overview/overview",
"iconPath": "/images/tabBar/icon_menu.png",
"selectedIconPath": "/images/tabBar/icon_menu_active.png",
"text": "工作台"
},
{
"pagePath": "/pages/myInfo/myInfo",
"iconPath": "/images/tabBar/icon_person.png",
"selectedIconPath": "/images/tabBar/icon_person_active.png",
"text": "我的"
}
],
managerList: [ // 管理人员tabBar / app.json 也要写
{
"pagePath": "/pages/home/home",
"iconPath": "/images/tabBar/icon_polling.png",
"selectedIconPath": "/images/tabBar/icon_polling_active.png",
"text": "首页"
},
{
"pagePath": "/pages/workbench/workbench",
"iconPath": "/images/tabBar/icon_menu.png",
"selectedIconPath": "/images/tabBar/icon_menu_active.png",
"text": "工作台"
},
{
"pagePath": "/pages/myInfo/myInfo",
"iconPath": "/images/tabBar/icon_person.png",
"selectedIconPath": "/images/tabBar/icon_person_active.png",
"text": "我的"
}
],
},
onShow (e) {
// 检查是否有更新

30
weapp/app.json

@ -4,7 +4,9 @@
"pages/login/login",
"pages/myInfo/myInfo",
"pages/overview/overview",
"pages/home/home"
"pages/home/home",
"custom-tab-bar/index",
"pages/workbench/workbench"
],
"subPackages": [
{
@ -19,7 +21,9 @@
"troubleshooting/shootingForm/index",
"inspectionReport/inspectionReport",
"pointsStatus/pointsStatus",
"homePage/homePage"
"subSystem/subSystem",
"riskManagement/riskManagement",
"riskManagement/riskCalendar/riskCalendar"
]
}
],
@ -29,6 +33,7 @@
"navigationBarTextStyle": "white"
},
"tabBar": {
"custom": true,
"color": "#000000",
"selectedColor": "#2F54FF",
"borderStyle": "black",
@ -40,12 +45,6 @@
"selectedIconPath": "images/tabBar/icon_polling_active.png",
"text": "巡检总览"
},
{
"pagePath": "pages/home/home",
"iconPath": "images/tabBar/icon_polling.png",
"selectedIconPath": "images/tabBar/icon_polling_active.png",
"text": "首页"
},
{
"pagePath": "pages/overview/overview",
"iconPath": "images/tabBar/icon_menu.png",
@ -57,6 +56,18 @@
"iconPath": "images/tabBar/icon_person.png",
"selectedIconPath": "images/tabBar/icon_person_active.png",
"text": "我的"
},
{
"pagePath": "pages/home/home",
"iconPath": "/images/tabBar/icon_home.png",
"selectedIconPath": "/images/tabBar/icon_home_active.png",
"text": "首页"
},
{
"pagePath": "pages/workbench/workbench",
"iconPath": "images/tabBar/icon_menu.png",
"selectedIconPath": "images/tabBar/icon_menu_active.png",
"text": "工作台"
}
]
},
@ -69,5 +80,6 @@
"getLocation"
],
"sitemapLocation": "sitemap.json",
"lazyCodeLoading": "requiredComponents"
"lazyCodeLoading": "requiredComponents",
"usingComponents": {}
}

60
weapp/app.wxss

@ -1,19 +1,53 @@
/**app.wxss**/
.page {
/* vant 全局CSS变量 */
/* DropdownMenu */
--dropdown-menu-background-color: transparent;
--dropdown-menu-box-shadow: none;
--dropdown-menu-title-active-text-color: #1684FF;
--dropdown-menu-option-active-color: #1684FF;
/* vant 全局CSS变量 */
/* DropdownMenu */
--dropdown-menu-background-color: transparent;
--dropdown-menu-box-shadow: none;
--dropdown-menu-title-active-text-color: #1684FF;
--dropdown-menu-option-active-color: #1684FF;
}
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
/* 弹性布局 */
.flex {
display: flex;
justify-content: center;
align-items: center;
}
.flex-start {
justify-content: flex-start;
}
.flex-col {
flex-direction: column;
}
.flex-between {
justify-content: space-between;
}
.flex-evenly {
justify-content: space-evenly;
}
.flex-wrap {
flex-wrap: wrap;
}
/* 字体省略号 */
.text--- {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

32
weapp/custom-tab-bar/index.js

@ -0,0 +1,32 @@
Component({
data: {
selected: 0,
color: "#7A7E83",
selectedColor: "#1070E8",
list: []
},
attached () {
let userRole = wx.getStorageSync('userRole');
// 0 表示普通用户 1表示管理员
console.log('userRole', userRole);
if (userRole && userRole.includes('管理')) {
this.setData({
list: getApp().globalData.managerList
})
} else {
this.setData({
list: getApp().globalData.inspecterList
})
}
},
methods: {
switchTab (e) {
const data = e.currentTarget.dataset
const url = data.path
// this.setData({
// selected: data.index
// })
wx.switchTab({ url })
}
}
})

3
weapp/custom-tab-bar/index.json

@ -0,0 +1,3 @@
{
"component": true
}

8
weapp/custom-tab-bar/index.wxml

@ -0,0 +1,8 @@
<!-- miniprogram/custom-tab-bar/index.wxml -->
<view class="tab-bar">
<view class="tab-bar-border"></view>
<view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab">
<image src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></image>
<view style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</view>
</view>
</view>

38
weapp/custom-tab-bar/index.wxss

@ -0,0 +1,38 @@
.tab-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 48px;
background: white;
display: flex;
padding-bottom: env(safe-area-inset-bottom);
}
.tab-bar-border {
background-color: rgba(0, 0, 0, 0.33);
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 1px;
transform: scaleY(0.5);
}
.tab-bar-item {
flex: 1;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.tab-bar-item image {
width: 27px;
height: 27px;
}
.tab-bar-item view {
font-size: 10px;
}

BIN
weapp/images/check.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

0
weapp/images/elevator'.png → weapp/images/elevator.png

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
weapp/images/sevenDays.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
weapp/images/tabBar/icon_home.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
weapp/images/tabBar/icon_home_active.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 B

BIN
weapp/images/workbench/expert_systems.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
weapp/images/workbench/issues.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
weapp/images/workbench/report.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
weapp/images/xunjian.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

284
weapp/package/components/ec-canvas/ec-canvas.js

@ -0,0 +1,284 @@
import WxCanvas from './wx-canvas';
import * as echarts from './echarts';
let ctx;
function compareVersion(v1, v2) {
v1 = v1.split('.')
v2 = v2.split('.')
const len = Math.max(v1.length, v2.length)
while (v1.length < len) {
v1.push('0')
}
while (v2.length < len) {
v2.push('0')
}
for (let i = 0; i < len; i++) {
const num1 = parseInt(v1[i])
const num2 = parseInt(v2[i])
if (num1 > num2) {
return 1
} else if (num1 < num2) {
return -1
}
}
return 0
}
Component({
properties: {
canvasId: {
type: String,
value: 'ec-canvas'
},
ec: {
type: Object
},
forceUseOldCanvas: {
type: Boolean,
value: false
}
},
data: {
isUseNewCanvas: false
},
ready: function () {
// Disable prograssive because drawImage doesn't support DOM as parameter
// See https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.drawImage.html
echarts.registerPreprocessor(option => {
if (option && option.series) {
if (option.series.length > 0) {
option.series.forEach(series => {
series.progressive = 0;
});
}
else if (typeof option.series === 'object') {
option.series.progressive = 0;
}
}
});
if (!this.data.ec) {
console.warn('组件需绑定 ec 变量,例:<ec-canvas id="mychart-dom-bar" '
+ 'canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>');
return;
}
if (!this.data.ec.lazyLoad) {
this.init();
}
},
methods: {
init: function (callback) {
const version = wx.getSystemInfoSync().SDKVersion
const canUseNewCanvas = compareVersion(version, '2.9.0') >= 0;
const forceUseOldCanvas = this.data.forceUseOldCanvas;
const isUseNewCanvas = canUseNewCanvas && !forceUseOldCanvas;
this.setData({ isUseNewCanvas });
if (forceUseOldCanvas && canUseNewCanvas) {
console.warn('开发者强制使用旧canvas,建议关闭');
}
if (isUseNewCanvas) {
// console.log('微信基础库版本大于2.9.0,开始使用<canvas type="2d"/>');
// 2.9.0 可以使用 <canvas type="2d"></canvas>
this.initByNewWay(callback);
} else {
const isValid = compareVersion(version, '1.9.91') >= 0
if (!isValid) {
console.error('微信基础库版本过低,需大于等于 1.9.91。'
+ '参见:https://github.com/ecomfe/echarts-for-weixin'
+ '#%E5%BE%AE%E4%BF%A1%E7%89%88%E6%9C%AC%E8%A6%81%E6%B1%82');
return;
} else {
console.warn('建议将微信基础库调整大于等于2.9.0版本。升级后绘图将有更好性能');
this.initByOldWay(callback);
}
}
},
initByOldWay(callback) {
// 1.9.91 <= version < 2.9.0:原来的方式初始化
ctx = wx.createCanvasContext(this.data.canvasId, this);
const canvas = new WxCanvas(ctx, this.data.canvasId, false);
if (echarts.setPlatformAPI) {
echarts.setPlatformAPI({
createCanvas: () => canvas,
});
} else {
echarts.setCanvasCreator(() => canvas);
};
// const canvasDpr = wx.getSystemInfoSync().pixelRatio // 微信旧的canvas不能传入dpr
const canvasDpr = 1
var query = wx.createSelectorQuery().in(this);
query.select('.ec-canvas').boundingClientRect(res => {
if (typeof callback === 'function') {
this.chart = callback(canvas, res.width, res.height, canvasDpr);
}
else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
this.chart = this.data.ec.onInit(canvas, res.width, res.height, canvasDpr);
}
else {
this.triggerEvent('init', {
canvas: canvas,
width: res.width,
height: res.height,
canvasDpr: canvasDpr // 增加了dpr,可方便外面echarts.init
});
}
}).exec();
},
initByNewWay(callback) {
// version >= 2.9.0:使用新的方式初始化
const query = wx.createSelectorQuery().in(this)
query
.select('.ec-canvas')
.fields({ node: true, size: true })
.exec(res => {
const canvasNode = res[0].node
this.canvasNode = canvasNode
const canvasDpr = wx.getSystemInfoSync().pixelRatio
const canvasWidth = res[0].width
const canvasHeight = res[0].height
const ctx = canvasNode.getContext('2d')
const canvas = new WxCanvas(ctx, this.data.canvasId, true, canvasNode)
if (echarts.setPlatformAPI) {
echarts.setPlatformAPI({
createCanvas: () => canvas,
loadImage: (src, onload, onerror) => {
if (canvasNode.createImage) {
const image = canvasNode.createImage();
image.onload = onload;
image.onerror = onerror;
image.src = src;
return image;
}
console.error('加载图片依赖 `Canvas.createImage()` API,要求小程序基础库版本在 2.7.0 及以上。');
// PENDING fallback?
}
})
} else {
echarts.setCanvasCreator(() => canvas)
}
if (typeof callback === 'function') {
this.chart = callback(canvas, canvasWidth, canvasHeight, canvasDpr)
} else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
this.chart = this.data.ec.onInit(canvas, canvasWidth, canvasHeight, canvasDpr)
} else {
this.triggerEvent('init', {
canvas: canvas,
width: canvasWidth,
height: canvasHeight,
dpr: canvasDpr
})
}
})
},
canvasToTempFilePath(opt) {
if (this.data.isUseNewCanvas) {
// 新版
const query = wx.createSelectorQuery().in(this)
query
.select('.ec-canvas')
.fields({ node: true, size: true })
.exec(res => {
const canvasNode = res[0].node
opt.canvas = canvasNode
wx.canvasToTempFilePath(opt)
})
} else {
// 旧的
if (!opt.canvasId) {
opt.canvasId = this.data.canvasId;
}
ctx.draw(true, () => {
wx.canvasToTempFilePath(opt, this);
});
}
},
touchStart(e) {
if (this.chart && e.touches.length > 0) {
var touch = e.touches[0];
var handler = this.chart.getZr().handler;
handler.dispatch('mousedown', {
zrX: touch.x,
zrY: touch.y,
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {}
});
handler.dispatch('mousemove', {
zrX: touch.x,
zrY: touch.y,
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {}
});
handler.processGesture(wrapTouch(e), 'start');
}
},
touchMove(e) {
if (this.chart && e.touches.length > 0) {
var touch = e.touches[0];
var handler = this.chart.getZr().handler;
handler.dispatch('mousemove', {
zrX: touch.x,
zrY: touch.y,
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {}
});
handler.processGesture(wrapTouch(e), 'change');
}
},
touchEnd(e) {
if (this.chart) {
const touch = e.changedTouches ? e.changedTouches[0] : {};
var handler = this.chart.getZr().handler;
handler.dispatch('mouseup', {
zrX: touch.x,
zrY: touch.y,
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {}
});
handler.dispatch('click', {
zrX: touch.x,
zrY: touch.y,
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {}
});
handler.processGesture(wrapTouch(e), 'end');
}
}
}
});
function wrapTouch(event) {
for (let i = 0; i < event.touches.length; ++i) {
const touch = event.touches[i];
touch.offsetX = touch.x;
touch.offsetY = touch.y;
}
return event;
}

1
weapp/package/homePage/homePage.json → weapp/package/components/ec-canvas/ec-canvas.json

@ -1,3 +1,4 @@
{
"component": true,
"usingComponents": {}
}

4
weapp/package/components/ec-canvas/ec-canvas.wxml

@ -0,0 +1,4 @@
<!-- 新的:接口对其了H5 -->
<canvas wx:if="{{isUseNewCanvas}}" type="2d" class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas>
<!-- 旧的 -->
<canvas wx:else class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas>

4
weapp/package/components/ec-canvas/ec-canvas.wxss

@ -0,0 +1,4 @@
.ec-canvas {
width: 100%;
height: 100%;
}

45
weapp/package/components/ec-canvas/echarts.js

File diff suppressed because one or more lines are too long

111
weapp/package/components/ec-canvas/wx-canvas.js

@ -0,0 +1,111 @@
export default class WxCanvas {
constructor(ctx, canvasId, isNew, canvasNode) {
this.ctx = ctx;
this.canvasId = canvasId;
this.chart = null;
this.isNew = isNew
if (isNew) {
this.canvasNode = canvasNode;
}
else {
this._initStyle(ctx);
}
// this._initCanvas(zrender, ctx);
this._initEvent();
}
getContext(contextType) {
if (contextType === '2d') {
return this.ctx;
}
}
// canvasToTempFilePath(opt) {
// if (!opt.canvasId) {
// opt.canvasId = this.canvasId;
// }
// return wx.canvasToTempFilePath(opt, this);
// }
setChart(chart) {
this.chart = chart;
}
addEventListener() {
// noop
}
attachEvent() {
// noop
}
detachEvent() {
// noop
}
_initCanvas(zrender, ctx) {
zrender.util.getContext = function () {
return ctx;
};
zrender.util.$override('measureText', function (text, font) {
ctx.font = font || '12px sans-serif';
return ctx.measureText(text);
});
}
_initStyle(ctx) {
ctx.createRadialGradient = () => {
return ctx.createCircularGradient(arguments);
};
}
_initEvent() {
this.event = {};
const eventNames = [{
wxName: 'touchStart',
ecName: 'mousedown'
}, {
wxName: 'touchMove',
ecName: 'mousemove'
}, {
wxName: 'touchEnd',
ecName: 'mouseup'
}, {
wxName: 'touchEnd',
ecName: 'click'
}];
eventNames.forEach(name => {
this.event[name.wxName] = e => {
const touch = e.touches[0];
this.chart.getZr().handler.dispatch(name.ecName, {
zrX: name.wxName === 'tap' ? touch.clientX : touch.x,
zrY: name.wxName === 'tap' ? touch.clientY : touch.y,
preventDefault: () => {},
stopImmediatePropagation: () => {},
stopPropagation: () => {}
});
};
});
}
set width(w) {
if (this.canvasNode) this.canvasNode.width = w
}
set height(h) {
if (this.canvasNode) this.canvasNode.height = h
}
get width() {
if (this.canvasNode)
return this.canvasNode.width
return 0
}
get height() {
if (this.canvasNode)
return this.canvasNode.height
return 0
}
}

2
weapp/package/homePage/homePage.wxml

@ -1,2 +0,0 @@
<!--package/homePage/homePage.wxml-->
<text>package/homePage/homePage.wxml</text>

1
weapp/package/homePage/homePage.wxss

@ -1 +0,0 @@
/* package/homePage/homePage.wxss */

2
weapp/package/homePage/homePage.js → weapp/package/riskManagement/riskCalendar/riskCalendar.js

@ -1,4 +1,4 @@
// package/homePage/homePage.js
// package/riskManagement/riskCalendar/riskCalendar.js
Page({
/**

9
weapp/package/riskManagement/riskCalendar/riskCalendar.json

@ -0,0 +1,9 @@
{
"navigationBarBackgroundColor": "#1979ff",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "故障日历",
"enablePullDownRefresh": false,
"usingComponents": {
"ec-canvas": "../../components/ec-canvas/ec-canvas"
}
}

2
weapp/package/riskManagement/riskCalendar/riskCalendar.wxml

@ -0,0 +1,2 @@
<!--package/riskManagement/riskCalendar/riskCalendar.wxml-->
<text>package/riskManagement/riskCalendar/riskCalendar.wxml</text>

1
weapp/package/riskManagement/riskCalendar/riskCalendar.wxss

@ -0,0 +1 @@
/* package/riskManagement/riskCalendar/riskCalendar.wxss */

126
weapp/package/riskManagement/riskManagement.js

@ -0,0 +1,126 @@
// package/riskManagement/riskManagement.js
import * as echarts from '../components/ec-canvas/echarts';
function setOption(chart, data) {
const option = {
grid: {
top: '5%',
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [
{
data: data,
type: 'line'
}
]
};
chart.setOption(option);
}
Page({
/**
* 页面的初始数据
*/
data: {
ec: {
// onInit: initChart,
lazyLoad: true, // 将 lazyLoad 设为 true 后,需要手动初始化图表
},
isLoaded: false,
list: [1,2,3]
},
// 初始化图表
initChart: function (data) {
this.ecComponent.init((canvas, width, height, dpr) => {
// 获取组件的 canvas、width、height 后的回调函数
// 在这里初始化图表
const chart = echarts.init(canvas, null, {
width: width,
height: height,
devicePixelRatio: dpr // new
});
setOption(chart, data);
// 将图表实例绑定到 this 上,可以在其他成员函数中访问
this.chart = chart;
this.setData({
isLoaded: true,
});
// 注意这里一定要返回 chart 实例,否则会影响事件处理等
return chart;
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// 请求数据
setTimeout(() => {
this.initChart([250, 300, 100, 147, 260, 123, 311])
}, 1000)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
this.ecComponent = this.selectComponent('#risk-trend-chart');
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

9
weapp/package/riskManagement/riskManagement.json

@ -0,0 +1,9 @@
{
"navigationBarBackgroundColor": "#006BE3",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "故障风险管理",
"enablePullDownRefresh": false,
"usingComponents": {
"ec-canvas": "../components/ec-canvas/ec-canvas"
}
}

41
weapp/package/riskManagement/riskManagement.wxml

@ -0,0 +1,41 @@
<!-- package / riskManagement / riskManagement.wxml -->
<view class="risk-management">
<view class="icon"><text class="icon-text">故障统计</text></view>
<view class="flex flex-between">
<view class="title-item flex flex-col">
<view>本月上报风险</view>
<view><text class="title-num">{{86}}</text><text class="title-unit">个</text></view>
</view>
<view class="title-item flex flex-col">
<view>故障风险管理</view>
<view><text class="title-num">{{300}}</text><text class="title-unit">个</text></view>
</view>
</view>
<view class="card">
<view class="flex flex-start">
<!-- <image src="" class="card-img" /> -->
<view class="card-img" style="background: blue;"></view>
<view class="card-title">历史风险趋势</view>
</view>
<view class="chart">
<ec-canvas id="risk-trend-chart" canvas-id="risk-trend-chart" ec="{{ ec }}"></ec-canvas>
</view>
</view>
<view class="card">
<view class="flex flex-between">
<!-- <image src="" class="card-img" /> -->
<view class="flex">
<view class="card-img" style="background: blue;"></view>
<view class="card-title">故障排行榜</view>
</view>
<view class="card-link">查看详情 ></view>
</view>
<view>【故障次数统计】</view>
<view class="list" wx:for="{{list}}">
<view class="list-title">设备{{item}}</view>
</view>
</view>
</view>

76
weapp/package/riskManagement/riskManagement.wxss

@ -0,0 +1,76 @@
/* package/riskManagement/riskManagement.wxss */
.risk-management {
height: 100vh;
background-image: linear-gradient(179deg, #006BE3 0%, #4E87FF 16%, #4e87ff00 93%);
padding: 0 15px;
}
.icon {
width: 61px;
height: 31.86px;
background-image: linear-gradient(0deg, #EAF2FF 5%, #2578F0 100%);
box-shadow: 0 3px 4px 1px #bfdbfa4f;
}
.icon-text {
width: 48px;
height: 17px;
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: 12px;
color: #FFFFFF;
}
.title-item {
width: 150px;
color: #ffffffd9;
}
.title-num {
font-size: 20px;
color: #FFFFFF;
}
.title-unit {
font-size: 10px;
color: #FFFFFE;
margin-left: 10px;
}
.card {
background: #FFFFFF;
box-shadow: 2px 2px 11px 0 #00000008, 0 0 4px 0 #00000012;
border-radius: 4px;
padding: 12px;
margin-top: 12px;
}
.card-img {
width: 18px;
height: 18px;
margin-right: 13px;
}
.card-title {
font-weight: 500;
font-size: 16px;
color: #383A3B;
}
.card-link {
font-weight: 500;
font-size: 14px;
color: #1684FF;
}
.chart {
width: 100%;
height: 195px;
margin-top: 20px;
}
.list {
margin-top: 10px;
padding: 10px 7px;
background-color: #F1F7FF;
}

242
weapp/package/subSystem/subSystem.js

@ -0,0 +1,242 @@
// package/subSystem/subSystem.js
import * as echarts from '../components/ec-canvas/echarts';
import {
getSubSystemPatrolAbout
} from "../../utils/getApiUrl";
import {
Request
} from "../../common";
const moment = require("../../utils/moment");
Page({
initECharts(option) {
this.ecComponent.init((canvas, width, height, dpr) => {
const chart = echarts.init(canvas, null, {
width: width,
height: height,
devicePixelRatio: dpr,
});
// 设置图表的配置
chart.setOption(option);
// 将 ECharts 实例保存在数据中
this.chart = chart;
// 返回 ECharts 实例
return chart;
});
},
/**
* 页面的初始数据
*/
data: {
ec: {
// lazyLoad: true, // 延迟加载 ECharts
},
date: '',
show: true,
currentPatrolCount: 0, //当月巡检次数
currentRepairCount: 0, //当月维修次数
level1Count: 0, //轻微
level2Count: 0, //中度
level3Count: 0, //严重
selectedDate: new Date(), // 设置默认选中的日期为当前日期
formatter(day) {
return day;
},
},
onDisplay() {
this.setData({
show: true
});
},
onClose() {
this.setData({
show: false
});
},
onConfirm(event) {
this.setData({
show: false,
date: this.formatDate(event.detail),
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
const {windowHeight}=wx.getSystemInfoSync()
const pageHeight=windowHeight - 48
const that=this
wx.showLoading({
title: '加载中'
})
// const that = this;
wx.setNavigationBarTitle({
title: options.key,
});
//加载初始化数据
that.getSubSystemPatrolAbout(options)
//初始化图表的配置项
// 其他渲染逻辑
// 创建一个 Date 对象来获取当前日期
const currentDate = new Date();
// 获取当前年份
const currentYear = currentDate.getFullYear();
// 获取当前月份(注意,月份是从 0 到 11 表示,所以需要加 1)
const currentMonth = currentDate.getMonth() + 1;
// 获取当前月份的第一天和最后一天
const nextMonth = new Date().getMonth() + 1;
const firstDay = new Date().setDate(1);
const lastDay = new Date().setMonth(nextMonth, 1) - 86400000;
// 更新数据,将年份和月份传递给 WXML 页面
that.setData({
currentYear: currentYear,
currentMonth: currentMonth,
lastDay: lastDay,
firstDay: firstDay,
pageHeight:pageHeight+'px'
});
wx.hideLoading()
},
//过滤轻微,中度,重度的巡检个数
filterLevelCount:function(list,level){
return list?.filter(i => {
const content = i?.points?.inspectContent
if (content) {
for (let key in content) {
if (content.hasOwnProperty(key)) {
const subObject = content[key];
return subObject.level===level
}
}
}
})?.length
},
getSubSystemPatrolAbout: function (options) {
let that = this;
//当月开始时间
const STime = moment().startOf('month').format('YYYY-MM-DD')
//当月结束时间
const ETime = moment().endOf('month').format('YYYY-MM-DD')
//子系统关键字
let keywords = options.key
// keywords = '管廊'
const query = {
STime,
ETime,
keywords
}
Request.get(getSubSystemPatrolAbout(query)).then(res => {
if (res) {
//巡查内容
that.setData({
currentRepairCount: res?.filter(i => i?.patrolRecordIssueHandles[0]?.yanshoushijian && parseInt(moment(i?.patrolRecordIssueHandles[0]?.yanshoushijian).format('YYYYMMDD')) === parseInt(moment().format('YYYYMMDD'))).length || 0,
currentPatrolCount: res.length,
level1Count: that.filterLevelCount(res,'轻微')||0,
level2Count: that.filterLevelCount(res,'中度')||0,
level3Count: that.filterLevelCount(res,'严重')||0,
formatter:function(e){
res?.map(i=>{
if(moment(i.inspectionTime).format('YYYY-MM-DD')==moment(e.date).format('YYYY-MM-DD')){
if( i.patrolRecordIssueHandles.length==0){
e.bottomInfo = '.';e.className = 'greenClass'
}else if( i.patrolRecordIssueHandles.length&& i?.patrolRecordIssueHandles[0]?.yanshoushijian && parseInt(moment(i?.patrolRecordIssueHandles[0]?.yanshoushijian).format('YYYYMMDD')) === parseInt(moment().format('YYYYMMDD'))){
e.bottomInfo = '.';e.className = 'yellowClass'
}
}
})
return e
}
})
that.ecComponent = that.selectComponent('#mychart-dom-pie');
console.log('that.level1Count',this.data.level2Count)
var option = {
backgroundColor: "#ffffff",
legend: {
bottom: 10,
left: 'center',
},
series: [{
label: {
normal: {
fontSize: 14
}
},
type: 'pie',
center: ['50%', '50%'],
radius: ['20%', '40%'],
data:[ {name:'轻微',value:that.data.level1Count},
{name:'中度',value:that.data.level2Count},
{name:'重度',value:that.data.level3Count}]
}]
};
that.initECharts(option);
wx.hideLoading()
} else {
wx.hideLoading();
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
getSubSystemPatrolAbout()
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

8
weapp/package/subSystem/subSystem.json

@ -0,0 +1,8 @@
{
"usingComponents": {
"ec-canvas": "../components/ec-canvas/ec-canvas",
"van-calendar": "@vant/weapp/calendar/index"
}
}

35
weapp/package/subSystem/subSystem.wxml

@ -0,0 +1,35 @@
<!--package/subSystem/subSystem.wxml-->
<!--总览图-->
<view style="display: flex;justify-content: space-around;margin-bottom: 10px; padding-top: 10px; background-image: linear-gradient(179deg, #006BE3 0%, #4E87FF 16%, #4e87ff00 93%);">
<view>
<view>本月巡检次数</view>
<view class="number">{{currentPatrolCount}}</view>
</view>
<view>
<view>本月维修次数</view>
<view class="number">{{currentRepairCount}}</view>
</view>
</view>
<!--饼图-->
<view class="card" >
<ec-canvas id="mychart-dom-pie" canvas-id="mychart-pie" ec="{{ ec }}"></ec-canvas>
</view>
<!--巡检日历-->
<view class="card heightStyle">
<view class="header">
<view class="xunjian">巡检日历</view>
<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" />
</view>

70
weapp/package/subSystem/subSystem.wxss

@ -0,0 +1,70 @@
/* package/subSystem/subSystem.wxss */
.number{
width: 40px;
height: 26px;
font-family: D-DINExp;
font-weight: DINExp;
font-size: 24px;
color: #FFFFFF;
letter-spacing: 0;
}
.card {
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: 16px;
color: #333333;
background-color: #fff;
border: 1px solid #ddd;
border-radius: 8px;
/* padding: 10px 10px; */
margin: 5px 5px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
/* width: 300px; */
height: 300px;
}
.heightStyle{
height: auto;
}
.xunjian{
width: 64px;
height: 22px;
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: 16px;
color: #000000d9;
letter-spacing: 0;
}
.yearMonth{
width: 85px;
height: 20px;
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: 14px;
color: #1684FF;
letter-spacing: 0;
text-align: right;
}
.header{
display: flex;
justify-content: space-around;
margin-bottom: 10px;
margin-top:10px;
}
.yellowClass .van-calendar__bottom-info{
font-size: 50px;
color:yellow;
}
.greenClass .van-calendar__bottom-info{
font-size: 50px;
color:green;
}

239
weapp/pages/home/home.js

@ -1,66 +1,179 @@
// pages/home/home.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
import { getPatrolRecord } from "../../utils/getApiUrl";
import { Request } from "../../common";
const moment = require("../../utils/moment");
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
Page({
jumpToSubSystem (options) {
const key = options.currentTarget.dataset.key;
wx.navigateTo({
url: `/package/subSystem/subSystem?key=${key}`,
})
},
/**
* 页面的初始数据
*/
data: {
sevenDaysCount:0,//过去七天的巡检次数
sevenDaysQuestionCount:0,//过去七天发现问题个数
sevenDaysHandleCount:0,//过去七天问题解决个数
allCount:0,//总的巡检次数
allQuestionCount:0,//总的发现问题个数
allHandleCount:0,//总的问题解决个数
todayRecord: [], // 今日巡检记录
markers: [],
pageHeight:0,//屏幕高度
isShowCallout: false,
itemList:[{
picPath:'/images/conduct.png',
itemName:'指挥中心'
},
{
picPath:'/images/waterSupply.png',
itemName:'给水仓'
},
{
picPath:'/images/pipeGallery.png',
itemName:'管廊本体'
},
{
picPath:'/images/elevator.png',
itemName:'电梯系统'
},
{
picPath:'/images/power.png',
itemName:'供配电系统'
},
{
picPath:'/images/gas.png',
itemName:'燃气仓'
},
{
picPath:'/images/security.png',
itemName:'安防系统'
},
{
picPath:'/images/highTension.png',
itemName:'高压电力仓'
},
{
picPath:'/images/electricalStorageRoom.png',
itemName:'电气仓'
},
{
picPath:'/images/lightningProtection.png',
itemName:'防雷与接地'
}
],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad (options) {
const userInfo=wx.getStorageSync('userInfo');
const {windowHeight}=wx.getSystemInfoSync()
const pageHeight=windowHeight - 48
const promiseArr = [];
const that = this;
var data = {
"datas": [
{
"id": 1,
"imgurl": "/images/avatar.png"
},
{
"id": 2,
"imgurl": "/images/card_bg.png"
}
]
};
wx.showLoading({ title: '加载中' })
promiseArr.push(Request.get(getPatrolRecord('all', moment('1970-1-1').format('YYYY-MM-DD') + ' 00:00:00', moment('2099-12-31').format('YYYY-MM-DD') + ' 23:59:59', 'null', 'null')));
Promise.all(promiseArr).then(res => {
wx.hideLoading()
//与自己相关的所有巡检记录
const list=res[0]?.filter(item=>item?.points?.user.id===userInfo.id)||[]
//过去七天的所有巡检记录
const sevenDaysList=list?.filter(item=>
{
const recordDate = moment(date, 'YYYY-MM-DD'); // 解析日期
const daysDifference = moment().diff(recordDate, 'days'); // 计算日期差
// 返回近七天内的记录
return daysDifference >= 0 && daysDifference < 7;
}
)||[]
that.setData({
allCount:list.length || 0,
allQuestionCount:list?.filter(i=>i.patrolRecordIssueHandles>0)?.length || 0,
allHandleCount:list?.filter(i => i?.patrolRecordIssueHandles[0]?.yanshoushijian && parseInt(moment(i?.patrolRecordIssueHandles[0]?.yanshoushijian).format('YYYYMMDD')) === parseInt(moment().format('YYYYMMDD'))).length || 0,
sevenDaysCount:sevenDaysList.length||0,
sevenDaysQuestionCount:sevenDaysList?.filter(i=>i.patrolRecordIssueHandles>0)?.length || 0,
sevenDaysHandleCount:sevenDaysList?.filter(i => i?.patrolRecordIssueHandles[0]?.yanshoushijian && parseInt(moment(i?.patrolRecordIssueHandles[0]?.yanshoushijian).format('YYYYMMDD')) === parseInt(moment().format('YYYYMMDD'))).length || 0,
pageHeight:pageHeight+'px',
swiperData:data.datas
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow () {
const userInfo = wx.getStorageSync('userInfo');
if (!userInfo || !userInfo.id) {
wx.reLaunch({
url: '/pages/login/login'
});
} else {
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
this.getTabBar().setData({
selected: 0
})
}
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage () {
}
})

59
weapp/pages/home/home.wxml

@ -1,5 +1,58 @@
<!--pages/home/home.wxml-->
<view>
<image src="/images/email.svg" />
<view style="height:{{pageHeight}} ; overflow: auto;">
<!--轮播图-->
<view class="card">
<swiper class="home-swiper" indicator-dots="true" autoplay="{{true}}" interval="{{2000}}" duration="{{500}}">
<block wx:for-items="{{swiperData}}">
<swiper-item>
<image src="{{item.imgurl}}" class="slide-image" />
</swiper-item>
</block>
</swiper>
</view>
<!--子系统列表-->
<view class="list card" style="display: flex; flex-wrap: wrap;">
<view style="min-width: 25%; margin: 10px 0px;text-align: center;" wx:for="{{itemList}}" wx:for-item="item" wx:key="*this" data-key="{{item.itemName}}" bindtap="jumpToSubSystem">
<image src="{{item.picPath}}" style="width: 29.97px;height: 28.93px;" />
<view>{{item.itemName}}</view>
</view>
</view>
<!--最近7天统计-->
<view class="card">
最近7天统计
<view style="background-image:url('/images/sevenDays.png');width: 100%; height: 99px; background-repeat: no-repeat;display: flex">
<view>
<image src="/images/check.png" style="width:36px;height:36px;margin:40px 10px 20px 10px" />
</view>
<view style="margin:40px 10px 20px 10px">
<view>巡检次数</view>
<view>{{sevenDaysCount}}次</view>
</view>
</view>
<view style="display: flex; justify-content: space-around;">
<view style="margin:10px 0px;">发现问题个数</view>
<view style="margin:10px 0px;">{{sevenDaysQuestionCount}}个</view>
<view style="margin:10px 0px;">问题处理个数</view>
<view style="margin:10px 0px;">{{sevenDaysHandleCount}}个</view>
</view>
</view>
<!--总巡巡检统计-->
<view class="card">
总巡巡检统计
<view style="background-image:url('/images/xunjian.png');width: 100%; height: 99px; background-repeat: no-repeat;display: flex;">
<view>
<image src="/images/check.png" style="width:36px;height:36px;margin:40px 10px 20px 10px" />
</view>
<view style="margin:40px 10px 20px 10px">
<view>巡检次数</view>
<view>{{allCount}}次</view>
</view>
</view>
<view style="display: flex; justify-content: space-around;">
<view style="margin:10px 0px;">发现问题个数</view>
<view style="margin:10px 0px;">{{allQuestionCount}}个</view>
<view style="margin:10px 0px;">问题处理个数</view>
<view style="margin:10px 0px;">{{allHandleCount}}个</view>
</view>
</view>
</view>
<text>pages/home/home.wxml</text>

24
weapp/pages/home/home.wxss

@ -1 +1,25 @@
/* pages/home/home.wxss */
.list {
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 12px;
color: #333333;
letter-spacing: 0;
}
.card {
background-color: #fff;
border: 1px solid #ddd;
border-radius: 8px;
/* padding: 10px; */
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
margin: 10px;
}
.home-swiper {
width: 95%;
/* height: 360rpx; */
}
/* .slide-image {
width: 100%;
height: 100%;
} */

294
weapp/pages/index/index.js

@ -5,146 +5,158 @@ const moment = require("../../utils/moment");
Page({
/**
* 页面的初始数据
*/
data: {
project: [],
todayRecord: [], // 今日巡检记录
markers: [],
isShowCallout: false,
},
setMarkers(project, todayRecord) {
const markers = project.map(p => {
let todayCount = 0;
todayRecord.forEach(r => {
if (r.projectId === p.id) { todayCount += 1 }
})
return {
id: p.id,
latitude: p.latitude,
longitude: p.longitude,
name: p.name,
iconPath: '/images/gis.png',
width: 29,
height: 44,
callout: {
content: `${p.name}\n今日巡检:${todayCount}`,
padding: 10,
display: this.data.isShowCallout ? 'ALWAYS' : 'BYCLICK',
borderColor: '#1684FF',
borderWidth: 1,
},
}
})
this.setData({ markers })
},
// 获取结构物和今日巡检次数
getData() {
const that = this;
wx.showLoading({ title: '加载中' })
const promiseArr = [];
promiseArr.push(Request.get(getProjectList(), {}));
promiseArr.push(Request.get(getPatrolRecord('all', moment().format('YYYY-MM-DD') + ' 00:00:00', moment().format('YYYY-MM-DD') + ' 23:59:59', 'null', 'null')));
Promise.all(promiseArr).then(res => {
wx.hideLoading()
that.setData({
project: res[0].rows,
todayRecord: res[1]
})
that.setMarkers(res[0].rows, res[1]);
// 缩放视野展示所有 markers
const mapCtx = wx.createMapContext('mapDom')
mapCtx.includePoints({
points: res[0].rows,
padding: [40, 40, 40, 40]
})
})
},
showCallout() {
this.setData(
{ isShowCallout: !this.data.isShowCallout },
() => { this.setMarkers(this.data.markers, this.data.todayRecord); }
);
},
onRefresh() {
this.getData();
},
onMarkerTap(e) {
const describe = this.data.project.find(p => p.id === e.detail.markerId).describe || '';
wx.navigateTo({url: `/package/pointsStatus/pointsStatus?projectId=${e.detail.markerId}&describe=${describe}`})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const userInfo = wx.getStorageSync('userInfo');
if (!userInfo || !userInfo.id) {
wx.reLaunch({
url: '/pages/login/login'
});
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
const userInfo = wx.getStorageSync('userInfo');
if (!userInfo || !userInfo.id) {
wx.reLaunch({
url: '/pages/login/login'
});
} else {
this.getData();
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面的初始数据
*/
data: {
project: [],
todayRecord: [], // 今日巡检记录
markers: [],
isShowCallout: false,
},
setMarkers(project, todayRecord) {
const markers = project.map(p => {
let todayCount = 0;
todayRecord.forEach(r => {
if (r.projectId === p.id) { todayCount += 1 }
})
return {
id: p.id,
latitude: p.latitude,
longitude: p.longitude,
name: p.name,
iconPath: '/images/gis.png',
width: 29,
height: 44,
callout: {
content: `${p.name}\n今日巡检:${todayCount}`,
padding: 10,
display: this.data.isShowCallout ? 'ALWAYS' : 'BYCLICK',
borderColor: '#1684FF',
borderWidth: 1,
},
}
})
this.setData({ markers })
},
// 获取结构物和今日巡检次数
getData() {
const that = this;
wx.showLoading({ title: '加载中' })
const promiseArr = [];
promiseArr.push(Request.get(getProjectList(), {}));
promiseArr.push(Request.get(getPatrolRecord('all', moment().format('YYYY-MM-DD') + ' 00:00:00', moment().format('YYYY-MM-DD') + ' 23:59:59', 'null', 'null')));
Promise.all(promiseArr).then(res => {
wx.hideLoading()
that.setData({
project: res[0].rows,
todayRecord: res[1]
})
that.setMarkers(res[0].rows, res[1]);
// 缩放视野展示所有 markers
const mapCtx = wx.createMapContext('mapDom')
mapCtx.includePoints({
points: res[0].rows,
padding: [40, 40, 40, 40]
})
})
},
showCallout() {
this.setData(
{ isShowCallout: !this.data.isShowCallout },
() => { this.setMarkers(this.data.markers, this.data.todayRecord); }
);
},
onRefresh() {
this.getData();
},
onMarkerTap(e) {
const describe = this.data.project.find(p => p.id === e.detail.markerId).describe || '';
wx.navigateTo({ url: `/package/pointsStatus/pointsStatus?projectId=${e.detail.markerId}&describe=${describe}` })
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const userInfo = wx.getStorageSync('userInfo');
if (!userInfo || !userInfo.id) {
wx.reLaunch({
url: '/pages/login/login'
});
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
const userInfo = wx.getStorageSync('userInfo');
if (!userInfo || !userInfo.id) {
wx.reLaunch({
url: '/pages/login/login'
});
return
}
const userRole = wx.getStorageSync('userRole');
if (userRole && userRole.includes('管理')) {
wx.reLaunch({
url: '/pages/home/home'
});
return
}
this.getData();
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
this.getTabBar().setData({
selected: 0
})
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
}
})

2
weapp/pages/index/index.wxss

@ -1,7 +1,7 @@
/* pages/index/index.wxss */
.map {
width: 100vw;
height: 100vh;
height: calc(100vh - 82px);
}
.action-box {

229
weapp/pages/login/login.js

@ -4,129 +4,142 @@ import { Request } from "../../common";
Page({
/**
* 页面的初始数据
*/
data: {
scene: null,
},
// 登录
getLogin: function (e) {
if (e.detail.value.username.length == 0 || e.detail.value.password == 0) {
wx.showToast({
title: '请输入账号密码',
icon: 'none',
})
return
}
wx.showLoading()
Request.post(loginUrl(), {
"username": e.detail.value.username,
"password": e.detail.value.password
}).then((res) => {
if (!res.authorized) {
wx.showToast({ title: "登录失败", icon: "none" });
return;
}
wx.setStorageSync('token', res.token);
wx.setStorageSync("userInfo", res);
getApp().globalData.userInfo = res
wx.hideLoading()
if (this.data.scene) {
wx.redirectTo({
url: `/package/inspectionInput/inspectionInput?scene=${this.data.scene}`,
/**
* 页面的初始数据
*/
data: {
scene: null,
},
// 登录
getLogin: function (e) {
if (e.detail.value.username.length == 0 || e.detail.value.password == 0) {
wx.showToast({
title: '请输入账号密码',
icon: 'none',
})
return
}
wx.showLoading()
Request.post(loginUrl(), {
"username": e.detail.value.username,
"password": e.detail.value.password
}).then((res) => {
if (!res.authorized) {
wx.showToast({ title: "登录失败", icon: "none" });
return;
}
wx.setStorageSync('token', res.token);
wx.setStorageSync("userInfo", res);
getApp().globalData.userInfo = res
wx.setStorageSync('userRole', res.role)
wx.hideLoading()
if (this.data.scene) {
wx.redirectTo({
url: `/package/inspectionInput/inspectionInput?scene=${this.data.scene}`,
})
return;
}
console.log(res.role);
setTimeout(() => {
console.log(`跳转`);
if (res.role.includes('管理')) {
wx.switchTab({
url: '/pages/home/home',
})
} else {
wx.switchTab({
url: '/pages/index/index',
})
}
}, 1000)
})
return;
}
wx.switchTab({
url: '/pages/index/index',
})
})
},
bindForget() {
wx.showModal({
title: '温馨提示',
content: '请联系管理员:18888888888',
confirmText: '拨打电话',
confirmColor: '#488EFF',
cancelColor: '#488EFF',
success(res) {
if (res.confirm) {
wx.makePhoneCall({
phoneNumber: "18888888888",
success: function () {
console.log("拨打电话成功!")
},
fail: function () {
console.log("拨打电话失败!")
},
bindForget () {
wx.showModal({
title: '温馨提示',
content: '请联系管理员:18888888888',
confirmText: '拨打电话',
confirmColor: '#488EFF',
cancelColor: '#488EFF',
success (res) {
if (res.confirm) {
wx.makePhoneCall({
phoneNumber: "18888888888",
success: function () {
console.log("拨打电话成功!")
},
fail: function () {
console.log("拨打电话失败!")
}
})
}
}
})
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad (options) {
let that = this;
const { scene } = options;
if (scene) {
that.setData({
scene
})
}
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
let that = this;
const { scene } = options;
if (scene) {
that.setData({
scene
})
}
},
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady () {
},
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
/**
* 生命周期函数--监听页面显示
*/
onShow () {
},
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
/**
* 生命周期函数--监听页面隐藏
*/
onHide () {
},
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
/**
* 生命周期函数--监听页面卸载
*/
onUnload () {
},
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh () {
},
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom () {
},
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
/**
* 用户点击右上角分享
*/
onShareAppMessage () {
}
}
})

170
weapp/pages/myInfo/myInfo.js

@ -4,99 +4,103 @@ import { Request } from "../../common";
Page({
/**
* 页面的初始数据
*/
data: {
},
bindClick() {
wx.navigateTo({
url: '/package/basic/basic',
})
},
// 登出
logout() {
wx.showModal({
title: '切换用户',
content: '将退出当前用户,重新登录',
confirmText: '切换用户',
confirmColor: '#1979ff',
success: res => {
if (res.confirm) {
wx.showLoading()
Request.put(logoutUrl(), {}).then((res) => {
wx.clearStorage();
getApp().globalData.userInfo = null;
wx.reLaunch({
url: '../login/login',
/**
* 页面的初始数据
*/
data: {
},
bindClick () {
wx.navigateTo({
url: '/package/basic/basic',
})
},
// 登出
logout () {
wx.showModal({
title: '切换用户',
content: '将退出当前用户,重新登录',
confirmText: '切换用户',
confirmColor: '#1979ff',
success: res => {
if (res.confirm) {
wx.showLoading()
Request.put(logoutUrl(), {}).then((res) => {
wx.clearStorage();
getApp().globalData.userInfo = null;
wx.reLaunch({
url: '../login/login',
})
wx.hideLoading()
})
}
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad (options) {
let that = this;
let userInfo = wx.getStorageSync('userInfo');
that.setData({
userInfo
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow () {
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
this.getTabBar().setData({
selected: 2
})
wx.hideLoading()
})
}
}
})
},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
let that = this;
let userInfo = wx.getStorageSync('userInfo');
that.setData({
userInfo
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide () {
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload () {
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh () {
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom () {
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
},
/**
* 用户点击右上角分享
*/
onShareAppMessage () {
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
}
})

209
weapp/pages/myInfo/myInfo.wxss

@ -1,175 +1,176 @@
/* pages/myInfo/myInfo.wxss */
page {
background-color: #F7F7FA;
background-color: #F7F7FA;
}
.over-ellipsis {
text-overflow: ellipsis;
overflow: hidden;
word-break: break-all;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
word-break: break-all;
white-space: nowrap;
}
.bg {
position: absolute;
left: -25%;
width: 150%;
height: 145px;
background-color: #1979ff;
border-bottom-left-radius: 100%;
border-bottom-right-radius: 100%;
background-image: linear-gradient(0deg, #4E87FF, #1979ff 100%);
z-index: -1;
position: absolute;
left: -25%;
width: 150%;
height: 145px;
background-color: #1979ff;
border-bottom-left-radius: 100%;
border-bottom-right-radius: 100%;
background-image: linear-gradient(0deg, #4E87FF, #1979ff 100%);
z-index: -1;
}
/* 容器 */
.box {
padding: 30rpx;
font-family: 'PingFang SC-Medium';
padding-top: 42rpx;
padding: 30rpx;
font-family: 'PingFang SC-Medium';
}
.header-item-container {
width: 100%;
height: 165px;
border-radius: 10rpx;
background-size: 100% 165px;
width: 100%;
height: 165px;
border-radius: 10rpx;
background-size: 100% 165px;
}
.info-box {
width: 100%;
height: 127px;
display: flex;
justify-content: space-between;
width: 100%;
height: 127px;
display: flex;
justify-content: space-between;
}
.avatar {
width: 54px;
min-width: 54px;
height: 54px;
padding: 16px;
margin-bottom: 30px;
width: 54px;
min-width: 54px;
height: 54px;
padding: 16px;
margin-bottom: 30px;
}
.info {
height: 100%;
min-width: 55%;
max-width: 60%;
display: flex;
flex-direction: column;
justify-content: space-evenly;
height: 100%;
min-width: 55%;
max-width: 60%;
display: flex;
flex-direction: column;
justify-content: space-evenly;
}
.userName {
font-size: 36rpx;
font-weight: 600;
font-size: 36rpx;
font-weight: 600;
}
.contact {
display: flex;
align-items: center;
min-width: 190px;
display: flex;
align-items: center;
min-width: 190px;
}
.contact .icon {
width: 20px;
min-width: 20px;
height: 20px;
width: 20px;
min-width: 20px;
height: 20px;
}
.contact .text {
min-width: 170px;
margin-left: 8px;
font-size: 14px;
color: #00000080;
min-width: 170px;
margin-left: 8px;
font-size: 14px;
color: #00000080;
}
.post {
border: 1px solid #006BE3;
border-radius: 100px 0 0 100px;
min-width: 30px;
max-width: 60px;
height: 25px;
line-height: 25px;
color: #006BE3;
font-size: 14px;
padding: 0 7px;
margin-top: 20px;
border: 1px solid #006BE3;
border-radius: 100px 0 0 100px;
min-width: 30px;
max-width: 60px;
height: 25px;
line-height: 25px;
color: #006BE3;
font-size: 14px;
padding: 0 7px;
margin-top: 20px;
}
.dept-box {
height: 36px;
display: flex;
align-items: center;
justify-content: flex-end;
height: 36px;
display: flex;
align-items: center;
justify-content: flex-end;
}
.dept-box .dept {
font-size: 14px;
color: #FFFFFF;
margin-right: 10px;
font-size: 14px;
color: #FFFFFF;
margin-right: 10px;
}
.company {
font-size: 28rpx;
font-family: "PingFang SC";
color: rgb(138, 138, 138);
margin-top: 14rpx;
font-size: 28rpx;
font-family: "PingFang SC";
color: rgb(138, 138, 138);
margin-top: 14rpx;
}
.body-container {
width: 100%;
background: rgb(255, 255, 255);
border-radius: 10rpx;
flex-direction: column;
display: flex;
margin-top: 30rpx;
margin-bottom: 30rpx;
width: 100%;
background: rgb(255, 255, 255);
border-radius: 10rpx;
flex-direction: column;
display: flex;
margin-top: 30rpx;
margin-bottom: 30rpx;
}
.body-item {
height: 110rpx;
flex-direction: row;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 30rpx;
border-bottom: 1px solid #EFEFF4;
height: 110rpx;
flex-direction: row;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 30rpx;
border-bottom: 1px solid #EFEFF4;
}
.body-info {
font-size: 32rpx;
font-family: "PingFang SC";
font-weight: 600;
font-size: 32rpx;
font-family: "PingFang SC";
font-weight: 600;
}
.body-number {
font-size: 30rpx;
font-family: "PingFang SC";
color: rgb(138, 138, 138);
font-size: 30rpx;
font-family: "PingFang SC";
color: rgb(138, 138, 138);
}
.foot-container {
position: absolute;
bottom: 50px;
width: 90%;
height: 42px;
border: 1px solid #006BE3;
border-radius: 24px;
position: absolute;
bottom: 140px;
width: 90%;
height: 42px;
border: 1px solid #006BE3;
border-radius: 24px;
}
.foot-item {
font-weight: 600;
font-size: 16px;
color: #006BE3;
text-align: center;
line-height: 42px;
font-weight: 600;
font-size: 16px;
color: #006BE3;
text-align: center;
line-height: 42px;
}
.right {
width: 32rpx;
height: 32rpx;
display: block;
float: right;
margin: 38rpx 40rpx;
width: 32rpx;
height: 32rpx;
display: block;
float: right;
margin: 38rpx 40rpx;
}

166
weapp/pages/overview/overview.js

@ -1,85 +1,89 @@
// pages/overview/overview.js
Page({
/**
* 页面的初始数据
*/
data: {
},
// 巡检
bindPolling() {
wx.navigateTo({
url: '/package/polling/polling',
})
},
bindTroubleshooting() {
wx.navigateTo({
url: '/package/troubleshooting/index',
})
},
bindInspectionReport() {
wx.navigateTo({
url: '/package/inspectionReport/inspectionReport',
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
/**
* 页面的初始数据
*/
data: {
},
// 巡检
bindPolling () {
wx.navigateTo({
url: '/package/polling/polling',
})
},
bindTroubleshooting () {
wx.navigateTo({
url: '/package/troubleshooting/index',
})
},
bindInspectionReport () {
wx.navigateTo({
url: '/package/inspectionReport/inspectionReport',
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow () {
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
this.getTabBar().setData({
selected: 1
})
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage () {
}
})

107
weapp/pages/workbench/workbench.js

@ -0,0 +1,107 @@
// pages/workbench/workbench.js
Page({
/**
* 页面的初始数据
*/
data: {
itemList: [
{
iconPath: '/images/workbench/report.png',
text: '故障及风险管理',
page: '/package/riskManagement/riskManagement'
},
{
iconPath: '/images/workbench/report.png',
text: '设备大数据图谱',
page: '/package/riskManagement/riskCalendar/riskCalendar'
},
{
iconPath: '/images/workbench/report.png',
text: '智能诊断',
page: '/package/riskManagement/riskManagement'
},
{
iconPath: '/images/workbench/expert_systems.png',
text: '专家系统',
page: '/package/riskManagement/riskManagement'
},
{
iconPath: '/images/workbench/report.png',
text: '巡检报告',
page: '/package/riskManagement/riskManagement'
},
{
iconPath: '/images/workbench/issues.png',
text: '发现问题',
page: '/package/riskManagement/riskManagement'
},
]
},
navigator(e) {
wx.navigateTo({
url: e.currentTarget.dataset.page,
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
this.getTabBar().setData({
selected: 1
})
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

6
weapp/pages/workbench/workbench.json

@ -0,0 +1,6 @@
{
"navigationBarBackgroundColor": "#1979ff",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "控制台",
"enablePullDownRefresh": false
}

9
weapp/pages/workbench/workbench.wxml

@ -0,0 +1,9 @@
<!-- pages/workbench/workbench.wxml -->
<view class="workbench-page">
<view class="workbench">
<view class="workbench-item" wx:for="{{itemList}}" data-page="{{item.page}}" bindtap="navigator">
<image src="{{item.iconPath}}" class="item-img" />
<View class="item-text">{{item.text}}</View>
</view>
</view>
</view>

33
weapp/pages/workbench/workbench.wxss

@ -0,0 +1,33 @@
/* pages/workbench/workbench.wxss */
.workbench-page {
width: 100vw;
height: 100vh;
background-color: #EDF1F8;
}
.workbench {
display: flex;
flex-wrap: wrap;
justify-content: space-evenly;
align-items: flex-start;
}
.workbench-item {
width: 166px;
height: 138px;
background: #FFFFFF;
border-radius: 8px;
margin-top: 12px;
}
.item-img {
width: 40px;
height: 40px;
margin: 16px 0px 44px 12px;
}
.item-text {
font-size: 16px;
color: #333333;
margin-left: 12px;
}

2
weapp/project.config.json

@ -47,7 +47,7 @@
},
"compileType": "miniprogram",
"libVersion": "2.19.4",
"appid": "wx79ff58f03d17f24d",
"appid": "wxdd82ae635b22ccdb",
"projectname": "miniprogram-92",
"condition": {},
"editorSetting": {

3
weapp/project.private.config.json

@ -31,5 +31,6 @@
}
]
}
}
},
"libVersion": "2.29.2"
}

6
weapp/utils/getApiUrl.js

@ -38,6 +38,12 @@ exports.addPatrolRecord = () => {
exports.getPatrolRecord = (patrolPlanId, startTime, endTime, alarm, pointId) => {
return `/patrolRecord/${patrolPlanId}/${startTime}/${endTime}/${alarm}/${pointId}`
}
//获取子系统的巡检记录
exports.getSubSystemPatrolAbout = (query) => {
const { STime, ETime,keywords } = query;
return `/patrolRecord/subSystemPatrolAbout?STime=${STime}&ETime=${ETime}&keywords=${keywords}`
}
// 获取点位最新一条巡检记录
exports.getdPointCurPatrolRecord = (pointId) => {
return `/patrolRecord/${pointId}/cur`

Loading…
Cancel
Save