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.
218 lines
4.8 KiB
218 lines
4.8 KiB
import http from '../../../utils/api'
|
|
const baseUrl = require('../../../utils/baseUrl')
|
|
Page({
|
|
data: {
|
|
diagnosisList: [],
|
|
// 弹窗相关
|
|
showPlanPopup: false,
|
|
consultationId: null,
|
|
baseUrl:baseUrl,
|
|
planForm: {
|
|
title: '', // 新增方案标题
|
|
diagnosis: '',
|
|
treatmentMethod: '',
|
|
treatmentDesc: '',
|
|
precautions: ''
|
|
}
|
|
},
|
|
|
|
onLoad: function() {
|
|
// 页面加载时可做一些初始化
|
|
},
|
|
|
|
onShow: function() {
|
|
this.getwzd()
|
|
},
|
|
|
|
// 获取问诊列表
|
|
getwzd() {
|
|
http.wzd({
|
|
data: {},
|
|
success: res => {
|
|
console.log('问诊列表:', res);
|
|
this.setData({
|
|
diagnosisList: res.rows || []
|
|
})
|
|
},
|
|
fail: err => {
|
|
console.error('获取问诊列表失败', err);
|
|
wx.showToast({
|
|
title: '加载失败',
|
|
icon: 'none'
|
|
});
|
|
}
|
|
})
|
|
},
|
|
|
|
// 制定方案(打开弹窗)
|
|
bindPlan(e) {
|
|
const consultationId = e.currentTarget.dataset.id;
|
|
console.log('当前咨询ID:', consultationId);
|
|
|
|
// 重置表单(包含title字段)
|
|
this.setData({
|
|
consultationId: consultationId,
|
|
planForm: {
|
|
title: '',
|
|
diagnosis: '',
|
|
treatmentMethod: '',
|
|
treatmentDesc: '',
|
|
precautions: ''
|
|
},
|
|
showPlanPopup: true
|
|
});
|
|
},
|
|
|
|
// 关闭弹窗
|
|
closePlanPopup() {
|
|
this.setData({
|
|
showPlanPopup: false,
|
|
consultationId: null
|
|
});
|
|
},
|
|
|
|
// 表单输入处理函数
|
|
onTitleInput(e) {
|
|
this.setData({
|
|
'planForm.title': e.detail.value
|
|
});
|
|
},
|
|
|
|
onDiagnosisInput(e) {
|
|
this.setData({
|
|
'planForm.diagnosis': e.detail.value
|
|
});
|
|
},
|
|
|
|
onTreatmentMethodInput(e) {
|
|
this.setData({
|
|
'planForm.treatmentMethod': e.detail.value
|
|
});
|
|
},
|
|
|
|
onTreatmentDescInput(e) {
|
|
this.setData({
|
|
'planForm.treatmentDesc': e.detail.value
|
|
});
|
|
},
|
|
|
|
onPrecautionsInput(e) {
|
|
this.setData({
|
|
'planForm.precautions': e.detail.value
|
|
});
|
|
},
|
|
|
|
// 提交方案
|
|
submitPlan() {
|
|
const { title, diagnosis, treatmentMethod, treatmentDesc } = this.data.planForm;
|
|
const consultationId = this.data.consultationId;
|
|
|
|
// 必填校验(包含标题)
|
|
if (!title || !title.trim()) {
|
|
wx.showToast({
|
|
title: '请填写方案标题',
|
|
icon: 'none',
|
|
duration: 2000
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (!diagnosis || !diagnosis.trim()) {
|
|
wx.showToast({
|
|
title: '请填写诊断结果',
|
|
icon: 'none',
|
|
duration: 2000
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (!treatmentMethod || !treatmentMethod.trim()) {
|
|
wx.showToast({
|
|
title: '请填写治疗方式',
|
|
icon: 'none',
|
|
duration: 2000
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (!treatmentDesc || !treatmentDesc.trim()) {
|
|
wx.showToast({
|
|
title: '请填写治疗方案描述',
|
|
icon: 'none',
|
|
duration: 2000
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (!consultationId) {
|
|
wx.showToast({
|
|
title: '咨询ID缺失,请重试',
|
|
icon: 'none'
|
|
});
|
|
return;
|
|
}
|
|
|
|
// 显示加载
|
|
wx.showLoading({
|
|
title: '提交中...',
|
|
mask: true
|
|
});
|
|
|
|
// 构建提交数据(包含title)
|
|
const submitData = {
|
|
consultationId: consultationId,
|
|
title: title.trim(), // 新增标题字段
|
|
diagnosis: diagnosis.trim(),
|
|
treatmentMethod: treatmentMethod.trim(),
|
|
treatmentDesc: treatmentDesc.trim(),
|
|
precautions: this.data.planForm.precautions?.trim() || ''
|
|
};
|
|
|
|
console.log('提交数据:', submitData);
|
|
|
|
// 调用API
|
|
http.fazdAdd({
|
|
data: submitData,
|
|
success: (res) => {
|
|
wx.hideLoading();
|
|
// 根据实际接口返回结构调整判断条件
|
|
if (res.code === 200 || res.code === 0 || res.success) {
|
|
wx.showToast({
|
|
title: '方案提交成功',
|
|
icon: 'success',
|
|
duration: 2000
|
|
});
|
|
|
|
// 关闭弹窗
|
|
this.closePlanPopup();
|
|
|
|
// 刷新列表(可选)
|
|
setTimeout(() => {
|
|
this.getwzd();
|
|
}, 500);
|
|
} else {
|
|
wx.showToast({
|
|
title: res.msg || '提交失败',
|
|
icon: 'none'
|
|
});
|
|
}
|
|
},
|
|
fail: (err) => {
|
|
wx.hideLoading();
|
|
console.error('提交失败', err);
|
|
wx.showToast({
|
|
title: '网络错误,请重试',
|
|
icon: 'none'
|
|
});
|
|
}
|
|
});
|
|
},
|
|
|
|
// 查看详情
|
|
viewDetail: function(e) {
|
|
const data = e.currentTarget.dataset.value;
|
|
wx.navigateTo({
|
|
url: `/pagesA/pages/askingSyDetails/askingSyDetails?data=${encodeURIComponent(JSON.stringify(data))}`,
|
|
});
|
|
}
|
|
});
|