|
|
|
const app = getApp<IAppOption>()
|
|
|
|
import { calc } from 'a-calc'
|
|
|
|
|
|
|
|
Page({
|
|
|
|
data: {
|
|
|
|
injectionDate: '',
|
|
|
|
injectionWeight: '',
|
|
|
|
|
|
|
|
injectionDrugs: '',
|
|
|
|
injectionNum: '',
|
|
|
|
},
|
|
|
|
onLoad() {
|
|
|
|
app.waitLogin({ type: 1 }).then(() => {
|
|
|
|
app.mpBehavior({ PageName: 'PG_BBMH901INFUSIONLOG_VISIT' })
|
|
|
|
this.getDetail()
|
|
|
|
})
|
|
|
|
},
|
|
|
|
handleInput(e) {
|
|
|
|
const { key, length } = e.currentTarget.dataset
|
|
|
|
const value = e.detail.value
|
|
|
|
this.setData({
|
|
|
|
[`${key}`]: this.validateInput(value, length),
|
|
|
|
})
|
|
|
|
},
|
|
|
|
validateInput(val, integerLimit) {
|
|
|
|
let num = val.toString()
|
|
|
|
// 清除“数字”和“.”以外的字符
|
|
|
|
num = num.replace(/[^\d.]/g, '')
|
|
|
|
// 只保留第一个.,清除多余的
|
|
|
|
num = num.replace(/\.{2,}/g, '.')
|
|
|
|
// 限制整数位位数
|
|
|
|
const index = num.indexOf('.')
|
|
|
|
if (index !== -1) {
|
|
|
|
num = num.slice(0, index + integerLimit + 1)
|
|
|
|
} else {
|
|
|
|
num = num.slice(0, integerLimit)
|
|
|
|
}
|
|
|
|
// 限制小数位位数
|
|
|
|
const decimalIndex = num.indexOf('.')
|
|
|
|
if (decimalIndex !== -1) {
|
|
|
|
num = num.slice(0, decimalIndex + 3)
|
|
|
|
}
|
|
|
|
return num
|
|
|
|
},
|
|
|
|
handleWeight(e) {
|
|
|
|
const value = e.detail.value
|
|
|
|
if (value) {
|
|
|
|
const injectionDrugs = calc(`${value} * 1.25 | =0 ~+`)
|
|
|
|
const injectionNum = calc(`${value} * 1.25 / 2 | =0 ~+`)
|
|
|
|
this.setData({
|
|
|
|
injectionDrugs,
|
|
|
|
injectionNum,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
handleChangeDate(e) {
|
|
|
|
const value = e.detail.value
|
|
|
|
wx.ajax({
|
|
|
|
method: 'POST',
|
|
|
|
url: '?r=wtx/treatment/save-injection-date',
|
|
|
|
data: {
|
|
|
|
injectionDate: value,
|
|
|
|
},
|
|
|
|
}).then((res) => {
|
|
|
|
console.log('res: ', res)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getDetail() {
|
|
|
|
wx.ajax({
|
|
|
|
method: 'GET',
|
|
|
|
url: '?r=wtx/treatment/get-injection-info',
|
|
|
|
data: {},
|
|
|
|
}).then((res) => {
|
|
|
|
this.setData({
|
|
|
|
...res,
|
|
|
|
injectionDate: res.injectionDate || '',
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
handleBack() {
|
|
|
|
app.mpBehavior({ PageName: 'BTN_BBMH901INFUSIONLOG_CANCELBUTTON_CLICK' })
|
|
|
|
wx.navigateBack()
|
|
|
|
},
|
|
|
|
handleSubmit() {
|
|
|
|
app.mpBehavior({ PageName: 'BTN_SUBMITBUTTON_CLICK' })
|
|
|
|
const { injectionDate, injectionWeight } = this.data
|
|
|
|
if (!injectionDate) {
|
|
|
|
wx.showToast({
|
|
|
|
title: '请选择输注时间',
|
|
|
|
icon: 'none',
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (!injectionWeight) {
|
|
|
|
wx.showToast({
|
|
|
|
title: '请输入体重',
|
|
|
|
icon: 'none',
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
wx.ajax({
|
|
|
|
method: 'POST',
|
|
|
|
url: '?r=wtx/treatment/save-injection-info',
|
|
|
|
data: {
|
|
|
|
injectionWeight,
|
|
|
|
},
|
|
|
|
}).then(() => {
|
|
|
|
wx.navigateBack()
|
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
export {}
|