修改界面中,临时提交
This commit is contained in:
@@ -15,6 +15,8 @@ Page({
|
||||
},
|
||||
totalPrice: '0.00',
|
||||
showOrderPopup: false,
|
||||
profiles: [], // 健康档案里已保存的就诊人
|
||||
selectedProfileId: '', // 当前选中的就诊人档案 ID,为空表示手动填写
|
||||
patientName: '',
|
||||
patientPhone: '',
|
||||
province: '',
|
||||
@@ -48,6 +50,13 @@ Page({
|
||||
this.loadServiceDetail(serviceId)
|
||||
},
|
||||
|
||||
onShow() {
|
||||
// 从"新增就诊人"页面返回时,弹窗还开着就刷新一次可选的就诊人
|
||||
if (this.data.showOrderPopup) {
|
||||
this.loadProfiles()
|
||||
}
|
||||
},
|
||||
|
||||
loadServiceDetail(id) {
|
||||
const app = getApp()
|
||||
let service = null
|
||||
@@ -86,8 +95,57 @@ Page({
|
||||
this.setData({
|
||||
patientName: user.profile?.name || '',
|
||||
patientPhone: user.profile?.mobile || '',
|
||||
selectedProfileId: '',
|
||||
showOrderPopup: true
|
||||
})
|
||||
|
||||
this.loadProfiles()
|
||||
},
|
||||
|
||||
// 读取已保存的就诊人,供弹窗内一键选择
|
||||
loadProfiles() {
|
||||
API.healthProfile.getMyProfiles({
|
||||
page: 1,
|
||||
pageSize: 20
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code !== 0) {
|
||||
return
|
||||
}
|
||||
const list = ((res.data && res.data.list) || []).map((item) => ({
|
||||
_id: item._id,
|
||||
name: item.profile?.name || '',
|
||||
mobile: item.profile?.mobile || ''
|
||||
}))
|
||||
this.setData({
|
||||
profiles: list
|
||||
})
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('获取就诊人列表失败', err)
|
||||
})
|
||||
},
|
||||
|
||||
// 选择就诊人:自动带入姓名与联系电话
|
||||
onSelectProfile(e) {
|
||||
const id = e.currentTarget.dataset.id
|
||||
const profile = this.data.profiles.find((item) => item._id === id)
|
||||
if (!profile) {
|
||||
return
|
||||
}
|
||||
|
||||
this.setData({
|
||||
selectedProfileId: id,
|
||||
patientName: profile.name,
|
||||
patientPhone: profile.mobile
|
||||
})
|
||||
},
|
||||
|
||||
// 跳转到健康档案新增就诊人
|
||||
goToAddProfile() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/health/profileedit'
|
||||
})
|
||||
},
|
||||
|
||||
closeOrderPopup() {
|
||||
@@ -96,15 +154,18 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
// 手动修改姓名/电话后,不再与所选档案对应,清空选择避免存档信息不一致
|
||||
onPatientNameChange(e) {
|
||||
this.setData({
|
||||
patientName: e.detail.value
|
||||
patientName: e.detail.value,
|
||||
selectedProfileId: ''
|
||||
})
|
||||
},
|
||||
|
||||
onPatientPhoneChange(e) {
|
||||
this.setData({
|
||||
patientPhone: e.detail.value
|
||||
patientPhone: e.detail.value,
|
||||
selectedProfileId: ''
|
||||
})
|
||||
},
|
||||
|
||||
@@ -256,6 +317,11 @@ Page({
|
||||
}
|
||||
}
|
||||
|
||||
// 选择了已保存的就诊人时,一并记录档案 ID
|
||||
if (this.data.selectedProfileId) {
|
||||
orderData.healthProfileId = this.data.selectedProfileId
|
||||
}
|
||||
|
||||
wx.showLoading({
|
||||
title: '提交中...'
|
||||
})
|
||||
@@ -292,6 +358,7 @@ Page({
|
||||
|
||||
resetForm() {
|
||||
this.setData({
|
||||
selectedProfileId: '',
|
||||
patientName: '',
|
||||
patientPhone: '',
|
||||
province: '',
|
||||
|
||||
Reference in New Issue
Block a user