import dayjs from 'dayjs' const filterColumns = {} const app = getApp() Page({ data: { active: 0, list: [] as any[], total: 0, pagination: { page: 1, pages: 1, count: 1, }, // form Search: '', HasAdl: 0, DoubleStandard: 0, AdlTime: 0, AdlScore: [] as any, AdlScoreChange: [], AdlScoreChangeType: 0, AdlScoreChangeMax: '', AdlScoreChangeMin: '', SteroidDailyDose: [] as any, SteroidDailyDoseChange: [] as any, IsThisWeekAdl: 0, PharyngealSymptoms: 0, AntibodyType: 0, ThyroidAbnormal: 0, PreviousConvulsion: 0, TraditionalImmunosuppressant: 0, MedicalInsuranceType: 0, BindStartDate: '', BindEndDate: '', HasAdlIndex: 0, HasAdlName: '全部', DoubleStandardIndex: 0, DoubleStandardName: '全部', AdlTimeIndex: 0, AdlTimeName: '全部', ...filterColumns, }, onLoad(options) { this.setData({ BindStartDate: options.BindStartDate || '', BindEndDate: options.BindEndDate || '', HasAdl: Number(options.HasAdl || ''), DoubleStandard: Number(options.DoubleStandard || ''), AdlScore: options.AdlScore ? options.AdlScore.split('-').map(Number) : [], SteroidDailyDose: options.SteroidDailyDose ? options.SteroidDailyDose.split('-').map(Number) : [], IsThisWeekAdl: Number(options.IsThisWeekAdl || ''), }) }, onShow() { app.waitLogin().then((_res) => { app.mpBehavior({ doctor:true, PageName: 'PG_DoctorPatientList' }) this.getList() app.getUserInfo(2).then((userInfo) => { this.setData({ userInfo, }) }) }) }, handleReset() { this.setData({ Search: '', HasAdl: 0, HasAdlIndex: 0, HasAdlName: '全部', DoubleStandard: 0, DoubleStandardIndex: 0, DoubleStandardName: '全部', AdlTime: 0, AdlTimeName: '全部', AdlScore: [], AdlScoreChange: [], AdlScoreChangeType: 0, AdlScoreChangeMax: '', AdlScoreChangeMin: '', SteroidDailyDose: [], SteroidDailyDoseChange: [], IsThisWeekAdl: 0, PharyngealSymptoms: 0, AntibodyType: 0, ThyroidAbnormal: 0, PreviousConvulsion: 0, TraditionalImmunosuppressant: 0, MedicalInsuranceType: 0, BindStartDate: '', BindEndDate: '', }) this.getList() }, handleTapSearch() { app.mpBehavior({ doctor:true, PageName: 'BTN_DoctorPatientListSearch' }) }, handleNav(e) { const { active } = e.currentTarget.dataset this.setData({ active, }) this.handleSearch() }, handleSearch() { this.getList() }, getList(newPage = 1) { const { active } = this.data const params = { search: this.data.Search, } const url = { 0: '?r=zd/doctor/patient/get-my-list', 1: '?r=zd/doctor/patient/get-my-list&IsEDC=1', }[active] as string wx.ajax({ method: 'GET', url, data: { page: newPage, ...params, }, }).then((res) => { res.list.forEach((item) => { if (item.BecomePatientTime) { item.BecomePatientTime = dayjs(item.BecomePatientTime).format('YYYY-MM-DD') } }) const list = res.page === 1 ? res.list : [...this.data.list, ...res.list] this.setData({ total: res.count, list, pagination: { page: res.page, pages: res.pages, count: res.count, }, }) }) }, onReachBottom() { const { page, pages } = this.data.pagination if (pages > page) { this.getList(page + 1) } }, handlePickerChange(e: any) { const { key } = e.currentTarget.dataset const index = e.detail.value const data = this.data[`${key}Column`] this.setData({ [`${key}Index`]: index, [`${key}Name`]: data[index].value, [`${key}`]: data[index].id, }) this.handleSearch() }, handleRadio(e: any) { const { key, index } = e.currentTarget.dataset const data = this.data[`${key}Column`] this.setData({ [`${key}`]: data[index].id, [`${key}Name`]: data[index].value, [`${key}Index`]: index, }) }, handleCheckbox(e: any) { const { index, key } = e.currentTarget.dataset const data = this.data[`${key}Column`] const oldValue = this.data[`${key}`] const value = oldValue.includes(data[index].id) ? oldValue.filter((item: any) => item !== data[index].id) : [...oldValue, data[index].id] this.setData({ [`${key}`]: data[index].id ? value : [], }) }, handleDetail(e: any) { app.mpBehavior({ doctor:true, PageName: 'BTN_DoctorPatientList' }) const { index } = e.currentTarget.dataset const item = this.data.list[index] wx.navigateTo({ url: `/pages/d_patientDetail/index?id=${item.PatientId}`, }) }, handleSend(e) { app.mpBehavior({ doctor:true, PageName: 'BTN_DoctorPatientListSendMessage' }) const { index } = e.currentTarget.dataset wx.navigateTo({ url: `/pages/d_interactiveDoctor/index?patientId=${this.data.list[index].PatientId}`, }) }, handleSendGroup() { wx.navigateTo({ url: '/pages/d_taskList/index', }) }, onShareAppMessage() { return { title: '重症肌无力加油站,重拾生活掌控感!', path: '/pages/d_patient/index', } }, handleBack() { wx.navigateBack() }, })