|
|
|
|
const app = getApp<IAppOption>()
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
data: {
|
|
|
|
|
// 搜索关键词
|
|
|
|
|
keyword: '',
|
|
|
|
|
|
|
|
|
|
// 筛选条件
|
|
|
|
|
jumpStatus: 0, // 0-全部,1-已跳转
|
|
|
|
|
enrollStatus: 0, // 0-全部,1-已入组
|
|
|
|
|
timeType: 0, // 0-跳转时间,1-入组时间
|
|
|
|
|
jumpStartTime: '',
|
|
|
|
|
jumpEndTime: '',
|
|
|
|
|
enrollStartTime: '',
|
|
|
|
|
enrollEndTime: '',
|
|
|
|
|
|
|
|
|
|
// 患者列表(模拟数据,接口上线后删除)
|
|
|
|
|
patientList: [
|
|
|
|
|
{
|
|
|
|
|
id: 100,
|
|
|
|
|
patientId: 10,
|
|
|
|
|
patientName: '患者A',
|
|
|
|
|
patientAvatar: '',
|
|
|
|
|
phone: '138****8888',
|
|
|
|
|
indicationName: '银屑病',
|
|
|
|
|
pharmacyName: '国大药房(XX店)',
|
|
|
|
|
bindTime: 1700000000,
|
|
|
|
|
bindTimeFormatted: '2023/11/14 22:13:20',
|
|
|
|
|
jumpStatus: 1,
|
|
|
|
|
jumpTime: 1700000100,
|
|
|
|
|
jumpTimeFormatted: '2023/11/14 22:15:00',
|
|
|
|
|
enrollStatus: 1,
|
|
|
|
|
enrollTime: 1700000200,
|
|
|
|
|
enrollTimeFormatted: '2023/11/14 22:16:40',
|
|
|
|
|
materialStatus: 2,
|
|
|
|
|
},
|
|
|
|
|
] as any[],
|
|
|
|
|
totalCount: 1,
|
|
|
|
|
|
|
|
|
|
// 分页
|
|
|
|
|
page: 1,
|
|
|
|
|
pageSize: 20,
|
|
|
|
|
loading: false,
|
|
|
|
|
hasMore: true,
|
|
|
|
|
pagination: {
|
|
|
|
|
count: 1,
|
|
|
|
|
page: 1,
|
|
|
|
|
pages: 1,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 弹窗
|
|
|
|
|
popupShow: false,
|
|
|
|
|
popupType: '',
|
|
|
|
|
popupParams: {},
|
|
|
|
|
},
|
|
|
|
|
onLoad() {
|
|
|
|
|
// 药店端患者列表页面,仅允许药店人员访问
|
|
|
|
|
app.waitLogin({ types: [4] }).then(() => {
|
|
|
|
|
// TODO: 接口上线后取消注释
|
|
|
|
|
// this.getPatientList()
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 获取患者列表
|
|
|
|
|
getPatientList() {
|
|
|
|
|
if (this.data.loading || !this.data.hasMore) return
|
|
|
|
|
|
|
|
|
|
this.setData({ loading: true })
|
|
|
|
|
|
|
|
|
|
// 根据时间类型判断传递哪个时间参数
|
|
|
|
|
const { timeType, jumpStartTime, jumpEndTime, enrollStartTime, enrollEndTime } = this.data
|
|
|
|
|
const params: any = {
|
|
|
|
|
keyword: this.data.keyword,
|
|
|
|
|
jumpStatus: this.data.jumpStatus,
|
|
|
|
|
enrollStatus: this.data.enrollStatus,
|
|
|
|
|
page: this.data.page,
|
|
|
|
|
pageSize: this.data.pageSize,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 时间类型:0-跳转时间,1-入组时间
|
|
|
|
|
if (timeType === 0) {
|
|
|
|
|
// 跳转时间
|
|
|
|
|
if (jumpStartTime) params.jumpStartTime = jumpStartTime
|
|
|
|
|
if (jumpEndTime) params.jumpEndTime = jumpEndTime
|
|
|
|
|
} else {
|
|
|
|
|
// 入组时间
|
|
|
|
|
if (enrollStartTime) params.enrollStartTime = enrollStartTime
|
|
|
|
|
if (enrollEndTime) params.enrollEndTime = enrollEndTime
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '/app/pharmacist/pharmacist/patient-list',
|
|
|
|
|
data: params,
|
|
|
|
|
}).then((res: any) => {
|
|
|
|
|
const list = (res.list || []).map((item: any) => ({
|
|
|
|
|
...item,
|
|
|
|
|
bindTimeFormatted: item.bindTime ? this.formatDate(item.bindTime) : '-',
|
|
|
|
|
jumpTimeFormatted: item.jumpTime ? this.formatDate(item.jumpTime) : '',
|
|
|
|
|
enrollTimeFormatted: item.enrollTime ? this.formatDate(item.enrollTime) : '',
|
|
|
|
|
}))
|
|
|
|
|
const total = res.total || 0
|
|
|
|
|
const currentPage = this.data.page
|
|
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
|
patientList: [...this.data.patientList, ...list],
|
|
|
|
|
totalCount: total,
|
|
|
|
|
page: currentPage + 1,
|
|
|
|
|
hasMore: list.length >= this.data.pageSize,
|
|
|
|
|
loading: false,
|
|
|
|
|
pagination: {
|
|
|
|
|
count: total,
|
|
|
|
|
page: currentPage,
|
|
|
|
|
pages: Math.ceil(total / this.data.pageSize) || 1,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
this.setData({ loading: false })
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 格式化日期
|
|
|
|
|
formatDate(timestamp: number): string {
|
|
|
|
|
const date = new Date(timestamp * 1000)
|
|
|
|
|
const year = date.getFullYear()
|
|
|
|
|
const month = String(date.getMonth() + 1).padStart(2, '0')
|
|
|
|
|
const day = String(date.getDate()).padStart(2, '0')
|
|
|
|
|
const hours = String(date.getHours()).padStart(2, '0')
|
|
|
|
|
const minutes = String(date.getMinutes()).padStart(2, '0')
|
|
|
|
|
const seconds = String(date.getSeconds()).padStart(2, '0')
|
|
|
|
|
return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`
|
|
|
|
|
},
|
|
|
|
|
// 搜索患者
|
|
|
|
|
handleSearch(e: WechatMiniprogram.CustomEvent) {
|
|
|
|
|
this.setData({
|
|
|
|
|
keyword: e.detail.value,
|
|
|
|
|
page: 1,
|
|
|
|
|
patientList: [],
|
|
|
|
|
hasMore: true,
|
|
|
|
|
})
|
|
|
|
|
this.getPatientList()
|
|
|
|
|
},
|
|
|
|
|
// 跳转状态筛选
|
|
|
|
|
handleJumpStatusChange(e: WechatMiniprogram.CustomEvent) {
|
|
|
|
|
const jumpStatus = e.detail.value === '1' ? 1 : 0
|
|
|
|
|
this.setData({
|
|
|
|
|
jumpStatus,
|
|
|
|
|
page: 1,
|
|
|
|
|
patientList: [],
|
|
|
|
|
hasMore: true,
|
|
|
|
|
})
|
|
|
|
|
this.getPatientList()
|
|
|
|
|
},
|
|
|
|
|
// 入组状态筛选
|
|
|
|
|
handleEnrollStatusChange(e: WechatMiniprogram.CustomEvent) {
|
|
|
|
|
const enrollStatus = e.detail.value === '1' ? 1 : 0
|
|
|
|
|
this.setData({
|
|
|
|
|
enrollStatus,
|
|
|
|
|
page: 1,
|
|
|
|
|
patientList: [],
|
|
|
|
|
hasMore: true,
|
|
|
|
|
})
|
|
|
|
|
this.getPatientList()
|
|
|
|
|
},
|
|
|
|
|
// 时间类型切换
|
|
|
|
|
handleTimeTypeChange(e: WechatMiniprogram.CustomEvent) {
|
|
|
|
|
const timeType = e.detail.value === '1' ? 1 : 0
|
|
|
|
|
this.setData({
|
|
|
|
|
timeType,
|
|
|
|
|
page: 1,
|
|
|
|
|
patientList: [],
|
|
|
|
|
hasMore: true,
|
|
|
|
|
})
|
|
|
|
|
this.getPatientList()
|
|
|
|
|
},
|
|
|
|
|
// 跳转开始时间选择
|
|
|
|
|
handleJumpStartTimeChange(e: WechatMiniprogram.CustomEvent) {
|
|
|
|
|
const jumpStartTime = e.detail.value
|
|
|
|
|
if (this.data.jumpEndTime && jumpStartTime > this.data.jumpEndTime) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '开始时间不能大于结束时间',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.setData({
|
|
|
|
|
jumpStartTime,
|
|
|
|
|
page: 1,
|
|
|
|
|
patientList: [],
|
|
|
|
|
hasMore: true,
|
|
|
|
|
})
|
|
|
|
|
this.getPatientList()
|
|
|
|
|
},
|
|
|
|
|
// 跳转结束时间选择
|
|
|
|
|
handleJumpEndTimeChange(e: WechatMiniprogram.CustomEvent) {
|
|
|
|
|
const jumpEndTime = e.detail.value
|
|
|
|
|
if (this.data.jumpStartTime && jumpEndTime < this.data.jumpStartTime) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '结束时间不能小于开始时间',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.setData({
|
|
|
|
|
jumpEndTime,
|
|
|
|
|
page: 1,
|
|
|
|
|
patientList: [],
|
|
|
|
|
hasMore: true,
|
|
|
|
|
})
|
|
|
|
|
this.getPatientList()
|
|
|
|
|
},
|
|
|
|
|
// 入组开始时间选择
|
|
|
|
|
handleEnrollStartTimeChange(e: WechatMiniprogram.CustomEvent) {
|
|
|
|
|
const enrollStartTime = e.detail.value
|
|
|
|
|
if (this.data.enrollEndTime && enrollStartTime > this.data.enrollEndTime) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '开始时间不能大于结束时间',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.setData({
|
|
|
|
|
enrollStartTime,
|
|
|
|
|
page: 1,
|
|
|
|
|
patientList: [],
|
|
|
|
|
hasMore: true,
|
|
|
|
|
})
|
|
|
|
|
this.getPatientList()
|
|
|
|
|
},
|
|
|
|
|
// 入组结束时间选择
|
|
|
|
|
handleEnrollEndTimeChange(e: WechatMiniprogram.CustomEvent) {
|
|
|
|
|
const enrollEndTime = e.detail.value
|
|
|
|
|
if (this.data.enrollStartTime && enrollEndTime < this.data.enrollStartTime) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '结束时间不能小于开始时间',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.setData({
|
|
|
|
|
enrollEndTime,
|
|
|
|
|
page: 1,
|
|
|
|
|
patientList: [],
|
|
|
|
|
hasMore: true,
|
|
|
|
|
})
|
|
|
|
|
this.getPatientList()
|
|
|
|
|
},
|
|
|
|
|
// 页面上拉触底事件
|
|
|
|
|
onReachBottom() {
|
|
|
|
|
if (this.data.loading || !this.data.hasMore) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.getPatientList()
|
|
|
|
|
},
|
|
|
|
|
// 查看详情
|
|
|
|
|
handleInfo(e: WechatMiniprogram.CustomEvent) {
|
|
|
|
|
const { id } = e.currentTarget.dataset
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: `/doctor/pages/stat/index?id=${id}`,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 上传材料
|
|
|
|
|
handleUpload(e: WechatMiniprogram.CustomEvent) {
|
|
|
|
|
const { id } = e.currentTarget.dataset
|
|
|
|
|
this.setData({
|
|
|
|
|
popupShow: true,
|
|
|
|
|
popupType: 'upload',
|
|
|
|
|
popupParams: { patientId: id },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 弹窗确认
|
|
|
|
|
handlePopupOk(e: WechatMiniprogram.CustomEvent) {
|
|
|
|
|
this.setData({
|
|
|
|
|
popupShow: false,
|
|
|
|
|
})
|
|
|
|
|
// 刷新列表
|
|
|
|
|
this.setData({
|
|
|
|
|
page: 1,
|
|
|
|
|
patientList: [],
|
|
|
|
|
hasMore: true,
|
|
|
|
|
})
|
|
|
|
|
this.getPatientList()
|
|
|
|
|
},
|
|
|
|
|
// 弹窗取消
|
|
|
|
|
handlePopupCancel() {
|
|
|
|
|
this.setData({
|
|
|
|
|
popupShow: false,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export {}
|