武田基因病B开发环境
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.
 
 
 

294 lines
5.7 KiB

import dayjs from 'dayjs'
const app = getApp<IAppOption>()
Page({
data: {
popupShow: false,
popupType: 'casesAddComplete',
popupParams: {} as any,
end: dayjs().format('YYYY-MM-DD'),
current: 0,
// form
diagnosisTime: '',
weight: '',
clottingFactor: '',
treatmentPlan: '',
fixExposureDay: '',
beforeFixHistory: '',
beforeLiverHistory: '',
liverRecord: '',
drinkingHistory: '',
allergyHistory: '',
allergyRecord: '',
isNotGlucocorticoid: '',
medicalHistoryInfo: '',
remark: '',
bleedingParts: [],
formKeys: [
'diagnosisTime',
'weight',
'clottingFactor',
'treatmentPlan',
'fixExposureDay',
'beforeFixHistory',
'beforeLiverHistory',
'liverRecord',
'drinkingHistory',
'allergyHistory',
'allergyRecord',
'isNotGlucocorticoid',
'medicalHistoryInfo',
'remark',
'bleedingParts',
],
dict: {
treatmentPlan: {},
dataHaveNo: {},
drink: {},
parts: {} as any,
},
parts: [
{
top: '94',
left: '-14',
active: false,
},
{
top: '78',
left: '28',
active: false,
},
{
top: '88',
left: '72',
active: false,
},
{
top: '78',
left: '126',
active: false,
},
{
top: '78',
left: '184',
active: false,
},
{
top: '88',
left: '238',
active: false,
},
{
top: '78',
left: '284',
active: false,
},
{
top: '94',
left: '324',
active: false,
},
{
top: '194',
left: '122',
active: false,
},
{
top: '194',
left: '190',
active: false,
},
{
top: '296',
left: '122',
active: false,
},
{
top: '296',
left: '190',
active: false,
},
{
top: '364',
left: '122',
active: false,
},
{
top: '364',
left: '190',
active: false,
},
{
top: '396',
left: '104',
active: false,
},
{
top: '396',
left: '206',
active: false,
},
],
},
onShow() {
const casesCache = wx.getStorageSync('casesCache')
app.waitLogin().then(() => {
this.getDict()
if (casesCache) {
const { formKeys } = this.data
const reset = formKeys.reduce((pre, cur) => {
pre[cur] = casesCache[cur] || ''
return pre
}, {})
this.setData({
...reset,
})
} else {
this.getDetail()
}
})
},
onUnload() {
this.updateSave()
},
onHide() {
this.updateSave()
},
getDict() {
wx.ajax({
method: 'GET',
url: '?r=wtx/treatment/get-dict',
data: {},
}).then((res) => {
this.setData({
dict: res,
})
})
},
getDetail() {
const { formKeys, parts } = this.data
wx.ajax({
method: 'GET',
url: '?r=wtx/treatment/get-medical-history-info',
data: {},
}).then((res) => {
const reset = formKeys.reduce((pre, cur) => {
pre[cur] = res[cur] || ''
return pre
}, {})
const bleedingParts = res.lastBleedingInfo.bleedingPartList.map((item: any) => {
parts[item.bleedingPart - 1].active = true
return {
name: item.bleedingPartName,
id: item.bleedingPart,
}
})
this.setData({
...reset,
remark: res.lastBleedingInfo.remark,
bleedingParts,
parts,
})
})
},
handleSelect(e) {
const { key, value } = e.currentTarget.dataset
this.setData({
[`${key}`]: value,
})
},
handlePartSelect(e) {
const { index } = e.currentTarget.dataset
const {
dict: { parts: partsDict },
parts,
} = this.data
parts[index].active = !parts[index].active
const bleedingParts = parts.reduce((pre, cur, index) => {
if (cur.active) {
pre.push({
name: partsDict[index + 1],
id: index + 1,
})
}
return pre
}, [] as any)
this.setData({
parts,
bleedingParts,
})
},
updateSave(e = false) {
let back = false
if (e) {
back = (e as any).currentTarget.dataset.back
}
const { formKeys, ...reset } = this.data
const form: any = formKeys.reduce((pre, cur) => {
pre[cur] = reset[cur]
return pre
}, {})
wx.setStorageSync('casesCache', form)
wx.ajax({
method: 'POST',
url: '?r=wtx/treatment/save-medical-history-info',
data: {
...form,
lastBleedingInfo: JSON.stringify({
remark: form.remark,
bleedingParts: form.bleedingParts.map((item: any) => item.id),
}),
},
}).then(() => {
wx.removeStorageSync('casesCache')
if (back) {
this.setData({
popupShow: true,
popupType: 'casesAddComplete',
popupParams: { close: true },
})
}
})
},
handleBack() {
wx.navigateBack()
},
handleSwiperChange(e) {
this.setData({
current: e.detail.current,
})
},
handlePrev(e) {
const { value } = e.currentTarget.dataset
this.setData({
current: value,
})
},
handleNext(e) {
const { value } = e.currentTarget.dataset
this.setData({
current: value,
})
},
handlePopupCancel() {
const { popupType } = this.data
if (popupType === 'casesAddComplete') {
wx.navigateBack()
this.setData({
popupShow: false,
popupType: '',
popupParams: {},
})
}
},
})
export {}