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.

209 lines
4.8 KiB

1 week ago
const app = getApp<IAppOption>()
Page({
data: {
popupShow: false,
2 days ago
popupType: 'popup2',
1 week ago
popupParams: {
2 days ago
position: 'center',
close: true,
1 week ago
} as any,
topicShow: false,
replayShow: true,
id: '',
visitDate: '',
1 week ago
fileList: [] as any[],
isUpdatePrescription: 0,
isUpdateSurgery: 0,
remark: '',
isEdit: false,
},
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) {
this.setData({ visitDate: e.detail.value })
},
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 })
1 week ago
},
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()
})
}
1 week ago
},
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() {
1 week ago
this.setData({
topicShow: false,
1 week ago
})
},
handleBack() {
wx.navigateBack()
1 week ago
},
})
export {}