|
|
|
const app = getApp<IAppOption>()
|
|
|
|
|
|
|
|
Page({
|
|
|
|
data: {
|
|
|
|
popupShow: false,
|
|
|
|
popupType: 'casesAddComplete',
|
|
|
|
popupParams: {} as any,
|
|
|
|
|
|
|
|
currentFinish: true,
|
|
|
|
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: {},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
handleFinish() {
|
|
|
|
this.setData({
|
|
|
|
currentFinish: true,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
handleBack() {
|
|
|
|
wx.navigateBack()
|
|
|
|
},
|
|
|
|
handlePrev() {
|
|
|
|
if (!this.data.currentFinish) return
|
|
|
|
this.setData({
|
|
|
|
currentFinish: false,
|
|
|
|
current: this.data.current - 1,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
handleNext() {
|
|
|
|
if (!this.data.currentFinish) return
|
|
|
|
this.setData({
|
|
|
|
currentFinish: false,
|
|
|
|
current: this.data.current + 1,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
handlePopupCancel() {
|
|
|
|
const { popupType } = this.data
|
|
|
|
if (popupType === 'casesAddComplete') {
|
|
|
|
wx.navigateBack()
|
|
|
|
this.setData({
|
|
|
|
popupShow: false,
|
|
|
|
popupType: '',
|
|
|
|
popupParams: {},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
export {}
|