const app = getApp() Page({ data: { popupShow: false, popupType: 'preDiagnosisReportDate', // 确认绑定曾经扫码医生 popupParams: {}, fold1: true, fold2: true, fold3: true, fold4: true, fold5: true, fold6: true, fold7: true, fold8: true, fold9: true, fold10: true, // form examId: '', period: '1', beginDate: '', endDate: '', isBloodRoutine: 2, isBiochemical: 2, alt: '', ast: '', bilirubin: '', isCFIxActivity: 2, clottingFactor: '', isCFIxInhibitor: 2, cFII: '', isHepatitisB: 2, hbsAg: '', hbvDNA: '', isHepatitisC: 2, hcvAntibody: '', hcvRNA: '', isHivAntibody: 2, hiv: '', isAfp: 2, afp: '', isAav: 2, aav: '', isOther: 2, otherInfo: '', attachmentList1: [], attachmentList2: [], attachmentList3: [], attachmentList4: [], attachmentList5: [], attachmentList6: [], attachmentList7: [], attachmentList8: [], attachmentList9: [], attachmentList10: [], formKeys: [ 'beginDate', 'endDate', 'isBloodRoutine', 'isBiochemical', 'alt', 'ast', 'bilirubin', 'isCFIxActivity', 'clottingFactor', 'isCFIxInhibitor', 'cFII', 'isHepatitisB', 'hbsAg', 'hbvDNA', 'isHepatitisC', 'hcvAntibody', 'hcvRNA', 'isHivAntibody', 'hiv', 'isAfp', 'afp', 'isAav', 'aav', 'isOther', 'otherInfo', ], dict: { result: {}, number: {}, }, }, onLoad(options) { this.setData({ examId: options.examid || '', period: options.period || '1', }) }, onShow() { const { formKeys, period } = this.data const examinationCache = wx.getStorageSync(`examinationCache${period}`) app.waitLogin().then(() => { this.getDict() if (examinationCache) { const reset = formKeys.reduce((pre, cur) => { pre[cur] = examinationCache[cur] || '' return pre }, {}) this.setData({ ...reset, }) } else { this.getDetail() } }) }, onUnload() { this.updateSave() }, onHide() { this.updateSave() }, getDict() { wx.ajax({ method: 'GET', url: '?r=wtx/treatment/get-dict', data: {}, }).then((res) => { this.setData({ dict: res, }) }) }, getDetail() { const { examId, formKeys } = this.data wx.ajax({ method: 'GET', url: '?r=wtx/treatment/get-examination-info', data: { examId: examId, }, }).then((res) => { const reset = formKeys.reduce((pre, cur) => { pre[cur] = res[cur] || '' return pre }, {}) this.setData({ ...reset, attachmentList1: res.attachmentList[1] || [], attachmentList2: res.attachmentList[2] || [], attachmentList3: res.attachmentList[3] || [], attachmentList4: res.attachmentList[4] || [], attachmentList5: res.attachmentList[5] || [], attachmentList6: res.attachmentList[6] || [], attachmentList7: res.attachmentList[7] || [], attachmentList8: res.attachmentList[8] || [], attachmentList9: res.attachmentList[9] || [], attachmentList10: res.attachmentList[10] || [], }) }) }, handleToggleFold(e: any) { const { fold } = e.currentTarget.dataset this.setData({ [fold]: !this.data[fold], }) }, handleToggleCheck(e: any) { const { check, fold } = e.currentTarget.dataset let foldValue = this.data[fold] if (!this.data[check]) { foldValue = false } this.setData({ [check]: this.data[check] == 1 ? 2 : 1, [fold]: foldValue, }) this.updateSave() }, handleSelect(e: any) { const { key, value } = e.currentTarget.dataset this.setData({ [key]: value, }) this.updateSave() }, updateSave() { const { formKeys, period, examId, ...reset } = this.data const form = formKeys.reduce((pre, cur) => { pre[cur] = reset[cur] return pre }, {}) const storageKey = `examinationCache${period}` wx.setStorageSync(storageKey, form) wx.ajax({ method: 'POST', url: '?r=wtx/treatment/save-examination', data: { examId, period, ...form, }, }).then(() => { wx.removeStorageSync(storageKey) }) }, setFile(e: any) { console.log('DEBUGPRINT[63]: index.ts:189: e=', e) const { type, key } = e.currentTarget.dataset const detail = e.detail || [] detail.forEach((item: any) => {}) }, }) export {}