| | |
| | | // pages/gradereport/gradereport.js |
| | | import bLoadingStatus from '../../../base/behaviors/bLoadingStatus' |
| | | import bLoadingToast from '../../../base/behaviors/bLoadingToast' |
| | | import bLoadingStatus from '../../../base/behaviors/bLoadingStatus'; |
| | | import bLoadingToast from '../../../base/behaviors/bLoadingToast'; |
| | | |
| | | const echarts = require("../../../component/ec-canvas/echarts") |
| | | const assessmentService = require("../../../service/assessmentservice") |
| | | const moment = require('../../../utils/moment.min') |
| | | const app = getApp() |
| | | const echarts = require('../../../component/ec-canvas/echarts'); |
| | | const assessmentService = require('../../../service/assessmentservice'); |
| | | const moment = require('../../../utils/moment.min'); |
| | | const app = getApp(); |
| | | |
| | | function setOption(chart, data) { |
| | | var option = { |
| | |
| | | // textBorderWidth: 1 |
| | | }, |
| | | subtextStyle: { |
| | | fontFamily: "微软雅黑", |
| | | fontFamily: '微软雅黑', |
| | | fontSize: 10, |
| | | color: 'black', |
| | | textBorderColor: 'black', |
| | |
| | | color: ['white'], |
| | | tooltip: {}, |
| | | legend: { |
| | | show: false |
| | | show: false, |
| | | }, |
| | | radar: { |
| | | radius: '60%', |
| | | axisName: { |
| | | color: 'white' |
| | | color: 'white', |
| | | }, |
| | | shape: 'polygon', |
| | | axisLine: { |
| | |
| | | lineStyle: { |
| | | color: 'white', |
| | | type: 'dashed', |
| | | join: 'round' |
| | | } |
| | | join: 'round', |
| | | }, |
| | | }, |
| | | axisLabel: { |
| | | show: false |
| | | show: false, |
| | | }, |
| | | splitLine: { |
| | | show: true, |
| | | color: 'white' |
| | | color: 'white', |
| | | }, |
| | | splitArea: { |
| | | show: true, |
| | | areaStyle: { |
| | | color: ['#4ca796', '#63c5b3', '#74DFCB', '#76E6D2', '#75ECD7'], |
| | | } |
| | | }, |
| | | indicator: data.indicator |
| | | }, |
| | | series: [{ |
| | | name: "得分", |
| | | type: "radar", |
| | | indicator: data.indicator, |
| | | }, |
| | | series: [ |
| | | { |
| | | name: '得分', |
| | | type: 'radar', |
| | | areaStyle: { |
| | | color: 'white', |
| | | opacity: 0.9 |
| | | opacity: 0.9, |
| | | }, |
| | | label: { |
| | | show: false, |
| | | position: 'inside' |
| | | position: 'inside', |
| | | }, |
| | | data: [{ |
| | | data: [ |
| | | { |
| | | value: data.value, |
| | | name: "得分" |
| | | }] |
| | | }], |
| | | name: '得分', |
| | | }, |
| | | ], |
| | | }, |
| | | ], |
| | | // grid: { |
| | | // x: 30, |
| | | // y: 30, |
| | |
| | | */ |
| | | data: { |
| | | ec: { |
| | | lazyLoad: true |
| | | lazyLoad: true, |
| | | }, |
| | | creditText: '----------------------', |
| | | gradeDetails: [{ |
| | | gradeDetails: [ |
| | | { |
| | | name: '自评得分', |
| | | detail: '--' |
| | | }, { |
| | | detail: '--', |
| | | }, |
| | | { |
| | | name: '风险排名', |
| | | detail: '--' |
| | | }, { |
| | | detail: '--', |
| | | }, |
| | | { |
| | | name: '风险等级', |
| | | detail: '--' |
| | | }, { |
| | | detail: '--', |
| | | }, |
| | | { |
| | | name: '自评周期', |
| | | detail: '--' |
| | | }, { |
| | | detail: '--', |
| | | }, |
| | | { |
| | | name: '自评时间', |
| | | detail: '--' |
| | | }], |
| | | detail: '--', |
| | | }, |
| | | ], |
| | | |
| | | //失分的类型 |
| | | losePointsItem: [], |
| | | losePoints: [{ |
| | | losePoints: [ |
| | | { |
| | | baseRule: '', |
| | | name: '', |
| | | itemlist: [{ |
| | | itemlist: [ |
| | | { |
| | | ruleName: '----', |
| | | score: '--', |
| | | remark: '------------' |
| | | },{ |
| | | remark: '------------', |
| | | }, |
| | | { |
| | | ruleName: '----', |
| | | score: '--', |
| | | remark: '------------' |
| | | }] |
| | | }] |
| | | remark: '------------', |
| | | }, |
| | | ], |
| | | }, |
| | | ], |
| | | }, |
| | | |
| | | /** |
| | |
| | | onLoad: function (options) { |
| | | if (options.period) { |
| | | this.setData({ |
| | | period: options.period |
| | | }) |
| | | period: options.period, |
| | | }); |
| | | } else { |
| | | let now = moment() |
| | | let now = moment(); |
| | | //根据当前时间获取评估周期YYYY/M-M |
| | | let period = `${now.year()}/${now.month()+1}-${now.month()+1}` |
| | | let period = `${now.year()}/${now.month() + 1}-${now.month() + 1}`; |
| | | this.setData({ |
| | | period: period |
| | | }) |
| | | period: period, |
| | | }); |
| | | } |
| | | }, |
| | | |
| | |
| | | */ |
| | | onReady: function () { |
| | | this.ecComponent = this.selectComponent('#mychart-dom-radar'); |
| | | this.initChart() |
| | | this.initChart(); |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow: function () { |
| | | |
| | | }, |
| | | onShow: function () {}, |
| | | |
| | | initChart: function () { |
| | | var data = { |
| | | score: '--', |
| | | level: '一般', |
| | | indicator: [{ |
| | | name: "法规", |
| | | max: 100 |
| | | }, { |
| | | name: "管理", |
| | | max: 100 |
| | | }, { |
| | | name: "承诺", |
| | | max: 100 |
| | | }, { |
| | | name: "守法", |
| | | max: 100 |
| | | }, { |
| | | name: "设备", |
| | | max: 100 |
| | | }], |
| | | value: [100, 100, 80, 5, 67, 82] |
| | | } |
| | | indicator: [ |
| | | { |
| | | name: '法规', |
| | | max: 100, |
| | | }, |
| | | { |
| | | name: '管理', |
| | | max: 100, |
| | | }, |
| | | { |
| | | name: '承诺', |
| | | max: 100, |
| | | }, |
| | | { |
| | | name: '守法', |
| | | max: 100, |
| | | }, |
| | | { |
| | | name: '设备', |
| | | max: 100, |
| | | }, |
| | | ], |
| | | value: [100, 100, 80, 5, 67, 82], |
| | | }; |
| | | this.ecComponent.init((canvas, width, height, dpr) => { |
| | | // 获取组件的 canvas、width、height 后的回调函数 |
| | | // 在这里初始化图表 |
| | | const chart = echarts.init(canvas, null, { |
| | | width: width, |
| | | height: height, |
| | | devicePixelRatio: dpr // new |
| | | devicePixelRatio: dpr, // new |
| | | }); |
| | | // setOption(chart, data); |
| | | |
| | | // 将图表实例绑定到 this 上,可以在其他成员函数(如 dispose)中访问 |
| | | this.chart = chart; |
| | | |
| | | this.getDetail() |
| | | this.getDetail(); |
| | | |
| | | // 注意这里一定要返回 chart 实例,否则会影响事件处理等 |
| | | return chart; |
| | |
| | | }, |
| | | |
| | | getDetail() { |
| | | var that = this |
| | | this.setData({loading: true}) |
| | | assessmentService.getDetail(app.globalData.accessToken.userId, this.data.period, { |
| | | var that = this; |
| | | this.setData({ loading: true }); |
| | | assessmentService.getDetail( |
| | | app.globalData.accessToken.userId, |
| | | this.data.period, |
| | | { |
| | | success(data) { |
| | | let creditText = data.creditText |
| | | let year = data.period.split('/')[0] |
| | | let month = data.period.split('/')[1].split('-')[0] |
| | | let gradeDetails = [{ |
| | | let creditText = data.creditText; |
| | | let year = data.period.split('/')[0]; |
| | | let month = data.period.split('/')[1].split('-')[0]; |
| | | let gradeDetails = [ |
| | | { |
| | | name: '自评得分', |
| | | detail: data.score |
| | | }, { |
| | | detail: data.score, |
| | | }, |
| | | { |
| | | name: '风险排名', |
| | | detail: data.rank |
| | | }, { |
| | | detail: data.rank, |
| | | }, |
| | | { |
| | | name: '风险等级', |
| | | detail: data.level |
| | | }, { |
| | | detail: data.level, |
| | | }, |
| | | { |
| | | name: '自评周期', |
| | | detail: `${year}年${month}月` |
| | | }, { |
| | | detail: `${year}年${month}月`, |
| | | }, |
| | | { |
| | | name: '自评时间', |
| | | detail: moment(data.time).format("YYYY-MM-DD HH:mm") |
| | | }] |
| | | let losePointsItem = [] |
| | | let losePoints = [] |
| | | for (const key in data.loseScore) { |
| | | const s = data.loseScore[key]; |
| | | detail: moment(data.time).format('YYYY-MM-DD HH:mm'), |
| | | }, |
| | | ]; |
| | | const { |
| | | pointsItem: losePointsItem, |
| | | points: losePoints, |
| | | } = that.parsePoint(data.loseScore); |
| | | const { pointsItem, points } = that.parsePoint(data.scoring); |
| | | let classPoints = { |
| | | score: data.score, |
| | | level: data.level, |
| | | indicator: [], |
| | | value: [], |
| | | }; |
| | | data.classScore.forEach(c => { |
| | | classPoints.indicator.push({ |
| | | name: c.first, |
| | | max: c.second, |
| | | }); |
| | | classPoints.value.push(c.third); |
| | | }); |
| | | |
| | | that.setData({ |
| | | creditText, |
| | | gradeDetails, |
| | | losePoints, |
| | | losePointsItem, |
| | | pointsItem, |
| | | points, |
| | | }); |
| | | setOption(that.chart, classPoints); |
| | | }, |
| | | complete() { |
| | | that.setData({ loading: false }); |
| | | }, |
| | | }, |
| | | ); |
| | | }, |
| | | |
| | | parsePoint(itemList) { |
| | | const pointsItem = []; |
| | | const points = []; |
| | | for (const key in itemList) { |
| | | const s = itemList[key]; |
| | | if (Object.keys(s).length > 0) { |
| | | losePointsItem.push(key) |
| | | pointsItem.push(key); |
| | | for (const key1 in s) { |
| | | const rule = s[key1]; |
| | | let p = { |
| | | baseRule: key, |
| | | name: key1, |
| | | itemlist: [] |
| | | } |
| | | itemlist: [], |
| | | }; |
| | | rule.forEach(r => { |
| | | // fixme : 此处暂时将【餐饮】类型的企业评估建议的第一句话删除 |
| | | if (app.globalData.userInfo.extension2 === '1') { |
| | | const i = r.third.indexOf(',') |
| | | r.third = r.third.slice(i+1) |
| | | r.third = r.third.replaceAll('你', '您') |
| | | const i = r.third.indexOf(','); |
| | | r.third = r.third.slice(i + 1); |
| | | r.third = r.third.replaceAll('你', '您'); |
| | | } |
| | | p.itemlist.push({ |
| | | ruleName: r.first, |
| | | score: r.second, |
| | | remark: r.third |
| | | }) |
| | | remark: r.third, |
| | | }); |
| | | losePoints.push(p) |
| | | } |
| | | } |
| | | } |
| | | let classPoints = { |
| | | score: data.score, |
| | | level: data.level, |
| | | indicator: [], |
| | | value: [] |
| | | } |
| | | data.classScore.forEach(c => { |
| | | classPoints.indicator.push({ |
| | | name: c.first, |
| | | max: c.second |
| | | }) |
| | | classPoints.value.push(c.third) |
| | | }); |
| | | points.push(p); |
| | | } |
| | | } |
| | | } |
| | | |
| | | that.setData({ |
| | | creditText: creditText, |
| | | gradeDetails: gradeDetails, |
| | | losePoints: losePoints, |
| | | losePointsItem: losePointsItem |
| | | }) |
| | | setOption(that.chart, classPoints) |
| | | return { pointsItem, points }; |
| | | }, |
| | | complete() { |
| | | that.setData({loading: false}) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }); |