信达小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

511 lines
13 KiB

6 months ago
import dayjs from 'dayjs'
5 months ago
const app = getApp<IAppOption>()
6 months ago
let echarts: any = null
Page({
data: {
type: '1',
BeginMonth: '',
EndMonth: '',
5 months ago
fields: {
1: 'day',
2: 'month',
3: 'year',
},
5 months ago
list: [],
pagination: {
page: 1,
pages: 1,
count: 1,
},
6 months ago
},
chartComponent1: null as any,
chartComponent2: null as any,
chartComponent3: null as any,
2 months ago
chartComponent4: null as any,
chartComponent5: null as any,
chartComponent6: null as any,
6 months ago
async onLoad() {
echarts = await require.async('../../../gift/compontnts/echart/echarts.js')
this.chartComponent1 = this.selectComponent('#chart1')
this.chartComponent2 = this.selectComponent('#chart2')
this.chartComponent3 = this.selectComponent('#chart3')
2 months ago
this.chartComponent4 = this.selectComponent('#chart4')
this.chartComponent5 = this.selectComponent('#chart5')
this.chartComponent6 = this.selectComponent('#chart6')
6 months ago
5 months ago
app.waitLogin({ type: [1] }).then(() => {
this.handleChangeType()
this.getList()
})
},
6 months ago
handleChangeType(e?: WechatMiniprogram.CustomEvent) {
let type = ''
if (e) {
5 months ago
type = e.detail.index + 1
}
else {
6 months ago
type = this.data.type
}
let EndMonth = ''
let BeginMonth = ''
if (type == '1') {
EndMonth = dayjs().format('YYYY-MM-DD')
BeginMonth = dayjs().subtract(6, 'd').format('YYYY-MM-DD')
}
else if (type == '2') {
6 months ago
EndMonth = dayjs().format('YYYY-MM')
BeginMonth = dayjs().subtract(1, 'M').format('YYYY-MM')
}
else if (type == '3') {
6 months ago
EndMonth = dayjs().format('YYYY')
BeginMonth = dayjs().subtract(1, 'y').format('YYYY')
}
6 months ago
this.setData({
page: 0,
type,
6 months ago
Num: '5',
EndMonth,
BeginMonth,
})
5 months ago
this.getChatData()
2 months ago
this.getHormoneData()
6 months ago
},
handleChange() {
this.getChatData()
},
5 months ago
getChatData() {
const { type, BeginMonth, EndMonth } = this.data
wx.ajax({
method: 'GET',
url: '?r=xd/qol/graph',
data: {
DateType: type,
StartDate: BeginMonth,
EndDate: EndMonth,
count: 0,
6 months ago
},
5 months ago
}).then((res) => {
const list0: any[] = []
const list1: any[] = []
const list2: any[] = []
res.list.forEach((item: any) => {
list0.push({
Date: item.Date,
value: item.TotalScore,
})
list1.push({
Date: item.Date,
value: item.VisionScore,
})
list2.push({
Date: item.Date,
value: item.AppearanceScore,
})
})
this.initChart(list0, 'chartComponent1')
this.initChart(list1, 'chartComponent2')
this.initChart(list2, 'chartComponent3')
})
},
2 months ago
getHormoneData() {
const { type, BeginMonth, EndMonth } = this.data
wx.ajax({
method: 'GET',
url: '?r=xd/hormone-dosage/graph',
data: {
DateType: type,
StartDate: BeginMonth,
EndDate: EndMonth,
count: 0,
},
}).then((res) => {
const list4: any[] = []
const list5: any[] = []
const list6: any[] = []
res.forEach((item: any) => {
list4.push({
Date: item.recordDate,
value: item.medicationMethod == 1 ? item.dosage : '',
})
list5.push({
Date: item.recordDate,
value: item.medicationMethod == 2 ? item.dosage : '',
})
list6.push({
Date: item.recordDate,
value: item.medicationMethod == 3 ? item.dosage : '',
})
})
this.initChartHormone(list4, 'chartComponent4', '#1ec580')
this.initChartHormone(list5, 'chartComponent5', '#B982FF')
this.initChartHormone(list6, 'chartComponent6', '#FFA300')
})
},
5 months ago
initChart(defaultList = [] as any[], key) {
6 months ago
return new Promise((reslove) => {
5 months ago
this[key].init((canvas, width, height, dpr) => {
6 months ago
const chart = echarts.init(canvas, null, {
width,
height,
devicePixelRatio: dpr, // new
})
canvas.setChart(chart)
const option: any = {
tooltip: {
show: false,
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
confine: true,
backgroundColor: 'rgba(0, 0, 0, 0.5)',
textStyle: {
color: '#fff',
fontSize: 10,
},
order: 'seriesDesc',
},
grid: {
top: '30',
left: '0',
right: '0',
bottom: '10',
containLabel: true,
},
xAxis: [
{
type: 'category',
axisTick: {
show: false,
inside: true,
length: 1,
alignWithLabel: true,
lineStyle: {
type: 'dotted',
color: '#D8D8D8',
width: 4,
cap: 'round',
},
},
axisLine: {
lineStyle: {
color: '#8C8C8C',
type: 'dashed',
},
},
splitLine: {
show: true,
showMinLine: false,
lineStyle: {
type: 'dotted',
color: 'rgba(137, 141, 151, 0.23)',
},
},
data: defaultList.map(item => dayjs(item.Date).format('MM-DD')),
6 months ago
},
],
yAxis: [
{
type: 'value',
minInterval: 20,
max: 100,
axisLine: {
show: false,
lineStyle: {
type: 'solid',
color: 'rgba(161, 164, 172, 1)',
},
},
splitLine: {
show: true,
showMinLine: false,
lineStyle: {
type: 'dotted',
color: 'rgba(137, 141, 151, 0.23)',
},
},
},
],
series: [
{
name: '总分',
data: defaultList.length ? defaultList.map(item => item.value) : [25],
6 months ago
barWidth: '16',
label: {
show: true,
position: 'top',
color: '#B982FF',
fontSize: 14,
6 months ago
},
type: 'line',
symbolSize: 4,
5 months ago
showSymbol: defaultList.length >= 1,
6 months ago
connectNulls: true,
z: 10,
itemStyle: {
color: '#B982FF',
},
markLine: {
symbol: ['none', 'none'],
data: [
{
name: '达标区',
yAxis: 80,
label: {
formatter: '{b}',
position: 'insideMiddle',
color: '#24D8C8',
fontSize: '10',
},
lineStyle: {
cap: '',
color: '#34D7C7',
type: 'dashed',
},
},
],
},
markArea: {
itemStyle: {
color: 'rgba(37,217,200,0.19)',
},
data: [
[
{
yAxis: 80,
},
{
yAxis: 100,
},
],
],
},
},
],
dataZoom: {
type: 'inside', // 有type这个属性,滚动条在最下面,也可以不行,写y:36,这表示距离顶端36px,一般就是在图上面。
startValue: 0,
endValue: 4,
filterMode: 'none',
},
}
chart.setOption(option)
reslove(chart)
return chart
})
})
},
2 months ago
initChartHormone(defaultList = [] as any[], key, color) {
return new Promise((reslove) => {
this[key].init((canvas, width, height, dpr) => {
const chart = echarts.init(canvas, null, {
width,
height,
devicePixelRatio: dpr, // new
})
canvas.setChart(chart)
const option: any = {
tooltip: {
show: false,
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
confine: true,
backgroundColor: 'rgba(0, 0, 0, 0.5)',
textStyle: {
color: '#fff',
fontSize: 10,
},
order: 'seriesDesc',
},
grid: {
top: '30',
left: '0',
right: '0',
bottom: '10',
containLabel: true,
},
xAxis: [
{
type: 'category',
axisTick: {
show: false,
inside: true,
length: 1,
alignWithLabel: true,
lineStyle: {
type: 'dotted',
color: '#D8D8D8',
width: 4,
cap: 'round',
},
},
axisLine: {
lineStyle: {
color: '#8C8C8C',
type: 'dashed',
},
},
splitLine: {
show: true,
showMinLine: false,
lineStyle: {
type: 'dotted',
color: 'rgba(137, 141, 151, 0.23)',
},
},
data: defaultList.map(item => dayjs(item.Date).format('MM-DD')),
},
],
yAxis: [
{
type: 'value',
minInterval: 20,
min: 0,
axisLine: {
show: false,
lineStyle: {
type: 'solid',
color: 'rgba(161, 164, 172, 1)',
},
},
splitLine: {
show: true,
showMinLine: false,
lineStyle: {
type: 'dotted',
color: 'rgba(137, 141, 151, 0.23)',
},
},
},
],
series: [
{
name: '总分',
data: defaultList.length ? defaultList.map(item => item.value) : [25],
barWidth: '16',
label: {
show: true,
position: 'top',
color,
fontSize: 14,
},
type: 'line',
symbolSize: 4,
showSymbol: defaultList.length >= 1,
connectNulls: true,
z: 10,
itemStyle: {
color,
},
},
],
dataZoom: {
type: 'inside', // 有type这个属性,滚动条在最下面,也可以不行,写y:36,这表示距离顶端36px,一般就是在图上面。
startValue: 0,
endValue: 4,
filterMode: 'none',
},
}
chart.setOption(option)
reslove(chart)
return chart
})
})
},
5 months ago
getList(newPage = 1) {
wx.ajax({
method: 'GET',
url: '?r=xd/qol/list',
data: {
page: newPage,
},
}).then((res) => {
let list = res.page == 1 ? res.list : [...this.data.list, ...res.list]
this.setData({
list,
5 months ago
pagination: {
page: res.page,
pages: res.pages,
count: res.count,
},
})
})
},
onReachBottom() {
const { page, pages } = this.data.pagination
if (pages > page) {
this.getList(page + 1)
}
},
handleDelete(e) {
const { id, index } = e.currentTarget.dataset
const { list } = this.data
wx.showModal({
title: '确认删除吗?',
confirmColor: '#8c75d0',
5 months ago
success: (res) => {
if (res.confirm) {
wx.ajax({
method: 'POST',
url: '?r=xd/qol/delete',
data: {
Id: id,
},
}).then(() => {
this.setData({
list: list.filter((_item, i) => i !== index),
})
})
}
},
})
},
handleDetail(e) {
const { id } = e.currentTarget.dataset
wx.navigateTo({
url: `/patient/pages/qolAdd/index?id=${id}`,
})
},
handleQol() {
wx.navigateTo({
url: '/patient/pages/qol/index',
})
},
2 months ago
handleHormoneDetail(e) {
const { index } = e.currentTarget.dataset
const { list } = this.data
const form: any = list[index]
wx.navigateTo({
url: `/patient/pages/hormonesResult/index?medicationMethod=${form.medicationMethod}&oralMonth=${form.oralMonthName}&injectionWeek=${form.injectionWeek}&injectionTimes=${form.injectionTimes}&dosage=${form.dosage}&report=1`,
})
},
handleHome() {
wx.reLaunch({
url: '/patient/pages/index/index',
})
},
5 months ago
handleBack() {
wx.navigateBack({
fail() {
wx.reLaunch({
url: '/patient/pages/index/index',
})
},
})
5 months ago
},
6 months ago
})
export {}