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.
140 lines
2.9 KiB
140 lines
2.9 KiB
1 month ago
|
import dayjs from 'dayjs'
|
||
|
|
||
|
const _app = getApp<IAppOption>()
|
||
|
|
||
|
// pages/story/a.ts
|
||
|
Component({
|
||
|
/**
|
||
|
* 组件的属性列表
|
||
|
*/
|
||
|
properties: {
|
||
|
show: {
|
||
|
type: Boolean,
|
||
|
value: false,
|
||
|
},
|
||
|
params: {
|
||
|
type: Object,
|
||
|
value: undefined,
|
||
|
},
|
||
|
},
|
||
|
|
||
|
observers: {
|
||
|
show() {
|
||
|
if (this.data.params) {
|
||
|
this.setData({
|
||
|
...this.data.params,
|
||
|
})
|
||
|
this.handleDateChange()
|
||
|
} else {
|
||
|
this.setData({
|
||
|
visitDateName: '',
|
||
|
visitDate: '',
|
||
|
hormone: 2,
|
||
|
traditionalInhibitor: 2,
|
||
|
gammaGlobulin: 2,
|
||
|
plasmaExchange: 2,
|
||
|
bCellInhibitor: 2,
|
||
|
fcRnAntagonists: 2,
|
||
|
c5ComplementInhibitor: 2,
|
||
|
chineseMedicine: 2,
|
||
|
other: 2,
|
||
|
recordId: '',
|
||
|
})
|
||
|
}
|
||
|
},
|
||
|
},
|
||
|
data: {
|
||
|
currentDate: dayjs().format('YYYY-MM-DD'),
|
||
|
|
||
|
visitDateName: '',
|
||
|
visitDate: '',
|
||
|
hormone: 2,
|
||
|
traditionalInhibitor: 2,
|
||
|
gammaGlobulin: 2,
|
||
|
plasmaExchange: 2,
|
||
|
bCellInhibitor: 2,
|
||
|
fcRnAntagonists: 2,
|
||
|
c5ComplementInhibitor: 2,
|
||
|
chineseMedicine: 2,
|
||
|
other: 2,
|
||
|
recordId: '',
|
||
|
},
|
||
|
|
||
|
methods: {
|
||
|
handleDateChange() {
|
||
|
this.setData({
|
||
|
visitDateName: dayjs(this.data.visitDate).format('YYYY年MM月DD日'),
|
||
|
})
|
||
|
},
|
||
|
handleSelect(e) {
|
||
|
const { name } = e.currentTarget.dataset
|
||
|
const value = this.data[name]
|
||
|
this.setData({
|
||
|
[name]: value === 2 ? 1 : 2,
|
||
|
})
|
||
|
},
|
||
|
submit() {
|
||
|
const { visitDate, recordId } = this.data
|
||
|
const params = {
|
||
|
visitDate,
|
||
|
recordId,
|
||
|
}
|
||
|
if(!visitDate){
|
||
|
wx.showToast({
|
||
|
title: '请选择复诊日期',
|
||
|
icon: 'none',
|
||
|
})
|
||
|
return
|
||
|
}
|
||
|
const selectKeys = [
|
||
|
'hormone',
|
||
|
'traditionalInhibitor',
|
||
|
'gammaGlobulin',
|
||
|
'plasmaExchange',
|
||
|
'bCellInhibitor',
|
||
|
'fcRnAntagonists',
|
||
|
'c5ComplementInhibitor',
|
||
|
'chineseMedicine',
|
||
|
'other',
|
||
|
]
|
||
|
selectKeys.forEach((item) => {
|
||
|
params[item] = this.data[item]
|
||
|
})
|
||
|
const onlySelect = selectKeys.some((item) => {
|
||
|
return this.data[item] === 1
|
||
|
})
|
||
|
if (!onlySelect) {
|
||
|
wx.showToast({
|
||
|
title: '请至少选择一种复诊后的方案',
|
||
|
icon: 'none',
|
||
|
})
|
||
|
return
|
||
|
}
|
||
|
wx.ajax({
|
||
|
method: 'POST',
|
||
|
url: '?r=xd/re-visit/save-record',
|
||
|
data: params,
|
||
|
}).then(() => {
|
||
|
if (recordId) {
|
||
|
wx.showToast({
|
||
|
icon: 'none',
|
||
|
title: '编辑成功',
|
||
|
})
|
||
|
} else {
|
||
|
wx.showToast({
|
||
|
icon: 'none',
|
||
|
title: '添加成功',
|
||
|
})
|
||
|
}
|
||
|
this.handleCancel()
|
||
|
this.triggerEvent('refresh', params)
|
||
|
})
|
||
|
},
|
||
|
handleCancel() {
|
||
|
this.setData({
|
||
|
show: false,
|
||
|
})
|
||
|
},
|
||
|
},
|
||
|
})
|