|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
|
|
|
|
|
|
const app = getApp<IAppOption>()
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
data: {
|
|
|
|
|
popupShow: false,
|
|
|
|
|
popupType: 'popup2',
|
|
|
|
|
popupParams: {
|
|
|
|
|
position: 'center',
|
|
|
|
|
close: true,
|
|
|
|
|
} as any,
|
|
|
|
|
|
|
|
|
|
topicShow: false,
|
|
|
|
|
replayShow: true,
|
|
|
|
|
|
|
|
|
|
id: '',
|
|
|
|
|
visitDate: '',
|
|
|
|
|
fileList: [] as any[],
|
|
|
|
|
isUpdatePrescription: 0,
|
|
|
|
|
isUpdateSurgery: 0,
|
|
|
|
|
remark: '',
|
|
|
|
|
isEdit: false,
|
|
|
|
|
|
|
|
|
|
endDate: dayjs().format('YYYY-MM-DD'),
|
|
|
|
|
},
|
|
|
|
|
onLoad(options: any) {
|
|
|
|
|
if (options.id) {
|
|
|
|
|
this.setData({ id: options.id, isEdit: true })
|
|
|
|
|
app.waitLogin({ type: 'any' }).then(() => {
|
|
|
|
|
this.getDetail(options.id)
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
app.waitLogin({ type: 'any' }).then(() => {})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getDetail(id: string) {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '?r=psvt/revisit-record/detail',
|
|
|
|
|
data: { id },
|
|
|
|
|
}).then((res: any) => {
|
|
|
|
|
if (!res) return
|
|
|
|
|
const fileList = (res.images || []).map((url: string) => ({
|
|
|
|
|
url,
|
|
|
|
|
fileType: 'image',
|
|
|
|
|
name: url,
|
|
|
|
|
}))
|
|
|
|
|
this.setData({
|
|
|
|
|
visitDate: res.visitDate || '',
|
|
|
|
|
fileList,
|
|
|
|
|
isUpdatePrescription: res.isUpdatePrescription ?? 0,
|
|
|
|
|
isUpdateSurgery: res.isUpdateSurgery ?? 0,
|
|
|
|
|
remark: res.remark || '',
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
onDateChange(e: any) {
|
|
|
|
|
const selectedDate = e.detail.value
|
|
|
|
|
if (dayjs(selectedDate).isAfter(dayjs(), 'day')) {
|
|
|
|
|
wx.showToast({ title: '不能选择未来日期', icon: 'none' })
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.setData({ visitDate: selectedDate })
|
|
|
|
|
},
|
|
|
|
|
handleSetData(e: any) {
|
|
|
|
|
const { fileList } = this.data
|
|
|
|
|
this.setData({
|
|
|
|
|
fileList: [...fileList, ...e.detail],
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleDeleteFile(e: any) {
|
|
|
|
|
const { index } = e.detail
|
|
|
|
|
const { fileList } = this.data
|
|
|
|
|
this.setData({
|
|
|
|
|
fileList: fileList.filter((_, i) => i !== index),
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handlePrescriptionChange(e: any) {
|
|
|
|
|
const { value } = e.currentTarget.dataset
|
|
|
|
|
this.setData({ isUpdatePrescription: value })
|
|
|
|
|
},
|
|
|
|
|
handleSurgeryChange(e: any) {
|
|
|
|
|
const { value } = e.currentTarget.dataset
|
|
|
|
|
this.setData({ isUpdateSurgery: value })
|
|
|
|
|
},
|
|
|
|
|
onRemarkInput(e: any) {
|
|
|
|
|
this.setData({ remark: e.detail.value })
|
|
|
|
|
},
|
|
|
|
|
handleSubmit() {
|
|
|
|
|
const { id, visitDate, fileList, isUpdatePrescription, isUpdateSurgery, remark, isEdit } = this.data
|
|
|
|
|
|
|
|
|
|
if (!visitDate) {
|
|
|
|
|
wx.showToast({ title: '请选择复诊日期', icon: 'none' })
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const images = fileList.map((item: any) => item.url)
|
|
|
|
|
|
|
|
|
|
const data = {
|
|
|
|
|
visitDate,
|
|
|
|
|
images,
|
|
|
|
|
isUpdatePrescription,
|
|
|
|
|
isUpdateSurgery,
|
|
|
|
|
remark,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wx.showLoading({ title: '保存中' })
|
|
|
|
|
|
|
|
|
|
if (isEdit) {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: '?r=psvt/revisit-record/update',
|
|
|
|
|
data: { id: Number(id), ...data },
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
wx.hideLoading()
|
|
|
|
|
wx.showToast({ title: '保存成功', icon: 'success' })
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
wx.navigateBack()
|
|
|
|
|
}, 1000)
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
wx.hideLoading()
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: '?r=psvt/revisit-record/create',
|
|
|
|
|
data,
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
wx.hideLoading()
|
|
|
|
|
wx.showToast({ title: '保存成功', icon: 'success' })
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
wx.navigateBack()
|
|
|
|
|
}, 1000)
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
wx.hideLoading()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handlePopupOk() {
|
|
|
|
|
const { popupType } = this.data
|
|
|
|
|
if (popupType === 'argument') {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: '?r=wtx/user/agree-guest-privacy',
|
|
|
|
|
data: {
|
|
|
|
|
WorkerId: app.globalData.scene?.workerId || '',
|
|
|
|
|
},
|
|
|
|
|
}).then(() => {
|
|
|
|
|
this.setData({
|
|
|
|
|
popupShow: false,
|
|
|
|
|
popupType: '',
|
|
|
|
|
popupParams: {},
|
|
|
|
|
})
|
|
|
|
|
const waitBindDoctorId = app.globalData.waitBindDoctorId
|
|
|
|
|
if (waitBindDoctorId) {
|
|
|
|
|
this.handleBindDoctor(waitBindDoctorId)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if (popupType === 'conformBindDoctorConform') {
|
|
|
|
|
this.setData({
|
|
|
|
|
popupShow: false,
|
|
|
|
|
})
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: '?r=wtx/account/wait-bind-doctor',
|
|
|
|
|
data: {
|
|
|
|
|
doctorId: app.globalData.waitBindDoctorId,
|
|
|
|
|
},
|
|
|
|
|
}).then(() => {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: `/patient/pages/login/index`,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handlePopupCancel() {
|
|
|
|
|
const { popupType } = this.data
|
|
|
|
|
if (popupType === 'argument') {
|
|
|
|
|
wx.exitMiniProgram()
|
|
|
|
|
}
|
|
|
|
|
if (popupType === 'conformBindDoctorConform') {
|
|
|
|
|
this.setData({
|
|
|
|
|
popupShow: false,
|
|
|
|
|
})
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: '?r=wtx/account/wait-bind-doctor',
|
|
|
|
|
data: {
|
|
|
|
|
doctorId: app.globalData.waitBindDoctorId,
|
|
|
|
|
},
|
|
|
|
|
}).then(() => {
|
|
|
|
|
app.globalData.waitBindDoctorId = ''
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handleWechatWork() {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/wechatWork/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
topicClose() {
|
|
|
|
|
this.setData({
|
|
|
|
|
topicShow: false,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleBack() {
|
|
|
|
|
wx.navigateBack()
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export {}
|