武田基因病B开发环境
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.

148 lines
2.9 KiB

const app = getApp<IAppOption>()
Page({
data: {
popupShow: false,
popupType: 'inhibitors',
popupParams: {},
recordId: '',
period: '',
recordDate: '',
drugId: '',
drugName: '',
type: '',
dosage: '',
dosageUnit: '',
2 weeks ago
dosageUnitName: '',
dosageUnitIndex: 0,
2 weeks ago
drugUnitList: [] as any,
dict: {
drugTypeList: {},
drugUnitList: {},
drugList: {},
},
},
onLoad(options) {
console.log('DEBUGPRINT[71]: index.ts:29: options=', options)
this.setData({
period: options.period,
})
app.waitLogin({ type: 1 }).then(() => {
this.getDict()
if (options.id) {
this.getDetail(options.id)
}
})
},
getDict() {
wx.ajax({
method: 'GET',
url: '?r=wtx/treatment/get-dict',
data: {},
}).then((res) => {
2 weeks ago
this.setData({
dict: res,
drugUnitList: Object.entries(res.drugUnitList).map(([key, value]) => {
console.log('DEBUGPRINT[75]: index.ts:45: key=', key)
return {
id: key,
value,
}
}),
})
})
},
getDetail(id: string) {
wx.ajax({
method: 'GET',
url: '?r=wtx/immune/get-detail',
data: { recordId: id },
}).then((res) => {
this.setData({
...res,
})
})
},
handleDrug() {
2 weeks ago
const { dict } = this.data
this.setData({
popupShow: true,
popupType: 'inhibitors',
popupParams: {
close: true,
2 weeks ago
list: dict.drugList,
},
})
},
2 weeks ago
handleSelect(e) {
const { id } = e.currentTarget.dataset
this.setData({
type: id,
})
},
handleChange(e: any) {
const index = e.detail.value
const { drugUnitList } = this.data
const { id, value } = drugUnitList[index]
this.setData({
dosageUnit: id,
dosageUnitName: value,
dosageUnitIndex: index,
})
},
handlePopupOk(e) {
const { popupType } = this.data
if (popupType === 'inhibitors') {
const { id, name, content } = e.detail
this.setData({
drugId: id,
drugName: name === '其他' ? content : name,
})
}
this.setData({
popupShow: false,
})
},
handlePopupCancel() {
this.setData({
popupShow: false,
})
},
2 weeks ago
handleSubmit() {
const { recordId, period, recordDate, drugId, drugName, type, dosage, dosageUnit } = this.data
wx.ajax({
method: 'POST',
url: '?r=wtx/immune/save-record',
data: {
recordId,
period,
recordDate,
drugId,
drugName,
type,
dosage,
dosageUnit,
},
}).then(() => {
this.handleBack()
})
},
handleDel() {
const { recordId } = this.data
wx.ajax({
method: 'GET',
url: '?r=wtx/immune/del',
data: { recordId },
}).then(() => {
this.handleBack()
})
},
handleBack() {
wx.navigateBack()
},
})
export {}