Compare commits
2
Commits
55cdeae1ba
...
e0f201f15c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0f201f15c | ||
|
|
1dfda24645 |
@@ -55,13 +55,16 @@ Page({
|
||||
rawUser: null as Record<string, any> | null,
|
||||
isEdit: false,
|
||||
queryError: false,
|
||||
today: '',
|
||||
},
|
||||
|
||||
onLoad(options: Record<string, string>) {
|
||||
targetSn = decodeURIComponent(options.sn || '')
|
||||
console.log(targetSn);
|
||||
editId = decodeURIComponent(options.id || '')
|
||||
this.setData({ isEdit: !!editId })
|
||||
const now = new Date()
|
||||
const today = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`
|
||||
this.setData({ isEdit: !!editId, today })
|
||||
if (editId) {
|
||||
this._loadEditUser(editId)
|
||||
}
|
||||
@@ -295,6 +298,28 @@ Page({
|
||||
this.setData({ 'form.weight': e.detail.value })
|
||||
},
|
||||
|
||||
/** 身高失焦校验:不在 50-250 则清空 */
|
||||
onHeightBlur() {
|
||||
const height = this.data.form.height.trim()
|
||||
if (!height) return
|
||||
const h = parseFloat(height)
|
||||
if (isNaN(h) || h < 50 || h > 250) {
|
||||
wx.showToast({ title: '身高需在50-250cm之间', icon: 'none' })
|
||||
this.setData({ 'form.height': '' })
|
||||
}
|
||||
},
|
||||
|
||||
/** 体重失焦校验:不在 20-300 则清空 */
|
||||
onWeightBlur() {
|
||||
const weight = this.data.form.weight.trim()
|
||||
if (!weight) return
|
||||
const w = parseFloat(weight)
|
||||
if (isNaN(w) || w < 20 || w > 300) {
|
||||
wx.showToast({ title: '体重需在20-300kg之间', icon: 'none' })
|
||||
this.setData({ 'form.weight': '' })
|
||||
}
|
||||
},
|
||||
|
||||
/** 复用已有信息:关弹框直接提交 */
|
||||
onConfirmModalConfirm() {
|
||||
this.setData({ showConfirmModal: false })
|
||||
@@ -329,10 +354,6 @@ Page({
|
||||
wx.showToast({ title: '请先查询员工信息', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!height || isNaN(heightNum) || heightNum <= 0) {
|
||||
wx.showToast({ title: '请填写身高', icon: 'none' })
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if (!name.trim()) {
|
||||
wx.showToast({ title: '请填写昵称', icon: 'none' })
|
||||
@@ -346,10 +367,16 @@ Page({
|
||||
wx.showToast({ title: '请填写出生年月', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!height || isNaN(heightNum) || heightNum <= 0) {
|
||||
wx.showToast({ title: '请填写身高', icon: 'none' })
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 身高体重范围校验(员工/家庭用户共用)
|
||||
if (!height || isNaN(heightNum) || heightNum < 50 || heightNum > 250) {
|
||||
wx.showToast({ title: '身高需在50-250cm之间', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (weight && (isNaN(weightNum) || weightNum < 20 || weightNum > 300)) {
|
||||
wx.showToast({ title: '体重需在20-300kg之间', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
// 家庭用户新增:身份证查询报错 → 重新查询,成功后再提交
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
</view>
|
||||
<view class="form-control">
|
||||
<view class="form-input-wrap">
|
||||
<input class="form-input form-input-with-suffix" type="digit" maxlength="5" placeholder="请填写身高" placeholder-class="form-placeholder" value="{{ form.height }}" bind:input="onHeightInput" />
|
||||
<input class="form-input form-input-with-suffix" type="digit" maxlength="5" placeholder="请填写身高" placeholder-class="form-placeholder" value="{{ form.height }}" bind:input="onHeightInput" bind:blur="onHeightBlur" />
|
||||
<text class="form-suffix form-suffix-inside">cm</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -87,7 +87,7 @@
|
||||
<view class="form-label"><text class="label-text">体重</text></view>
|
||||
<view class="form-control">
|
||||
<view class="form-input-wrap">
|
||||
<input class="form-input form-input-with-suffix" type="digit" maxlength="6" placeholder="请填写体重" placeholder-class="form-placeholder" value="{{ form.weight }}" bind:input="onWeightInput" />
|
||||
<input class="form-input form-input-with-suffix" type="digit" maxlength="6" placeholder="请填写体重" placeholder-class="form-placeholder" value="{{ form.weight }}" bind:input="onWeightInput" bind:blur="onWeightBlur" />
|
||||
<text class="form-suffix form-suffix-inside">kg</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -142,7 +142,7 @@
|
||||
<text class="label-star">*</text>
|
||||
</view>
|
||||
<view class="form-control">
|
||||
<picker mode="date" value="{{ birthday }}" bindchange="onBirthdayChange">
|
||||
<picker mode="date" value="{{ birthday }}" end="{{ today }}" bindchange="onBirthdayChange">
|
||||
<view class="form-picker {{ birthday ? '' : 'form-picker-placeholder' }}">{{ birthday || '请选择出生年月' }}</view>
|
||||
</picker>
|
||||
</view>
|
||||
@@ -157,7 +157,7 @@
|
||||
</view>
|
||||
<view class="form-control">
|
||||
<view class="form-input-wrap">
|
||||
<input class="form-input form-input-with-suffix" type="digit" maxlength="5" placeholder="请填写身高" placeholder-class="form-placeholder" value="{{ form.height }}" bind:input="onHeightInput" />
|
||||
<input class="form-input form-input-with-suffix" type="digit" maxlength="5" placeholder="请填写身高" placeholder-class="form-placeholder" value="{{ form.height }}" bind:input="onHeightInput" bind:blur="onHeightBlur" />
|
||||
<text class="form-suffix form-suffix-inside">cm</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -166,7 +166,7 @@
|
||||
<view class="form-label"><text class="label-text">体重</text></view>
|
||||
<view class="form-control">
|
||||
<view class="form-input-wrap">
|
||||
<input class="form-input form-input-with-suffix" type="digit" maxlength="6" placeholder="请填写体重" placeholder-class="form-placeholder" value="{{ form.weight }}" bind:input="onWeightInput" />
|
||||
<input class="form-input form-input-with-suffix" type="digit" maxlength="6" placeholder="请填写体重" placeholder-class="form-placeholder" value="{{ form.weight }}" bind:input="onWeightInput" bind:blur="onWeightBlur" />
|
||||
<text class="form-suffix form-suffix-inside">kg</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -123,6 +123,28 @@ Page({
|
||||
this.setData({ weight: e.detail.value })
|
||||
},
|
||||
|
||||
/** 身高失焦校验:不在 50-250 则清空 */
|
||||
onHeightBlur() {
|
||||
const height = this.data.height.trim()
|
||||
if (!height) return
|
||||
const h = parseFloat(height)
|
||||
if (isNaN(h) || h < 50 || h > 250) {
|
||||
wx.showToast({ title: '身高需在50-250cm之间', icon: 'none' })
|
||||
this.setData({ height: '' })
|
||||
}
|
||||
},
|
||||
|
||||
/** 体重失焦校验:不在 20-300 则清空 */
|
||||
onWeightBlur() {
|
||||
const weight = this.data.weight.trim()
|
||||
if (!weight) return
|
||||
const w = parseFloat(weight)
|
||||
if (isNaN(w) || w < 20 || w > 300) {
|
||||
wx.showToast({ title: '体重需在20-300kg之间', icon: 'none' })
|
||||
this.setData({ weight: '' })
|
||||
}
|
||||
},
|
||||
|
||||
async onSubmit() {
|
||||
const { name, idCard, height, weight } = this.data
|
||||
const heightNum = parseFloat(height)
|
||||
@@ -136,8 +158,12 @@ Page({
|
||||
wx.showToast({ title: '请填写正确的身份证号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!height || isNaN(heightNum) || heightNum <= 0) {
|
||||
wx.showToast({ title: '请填写身高', icon: 'none' })
|
||||
if (!height || isNaN(heightNum) || heightNum < 50 || heightNum > 250) {
|
||||
wx.showToast({ title: '身高需在50-250cm之间', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (weight && (isNaN(weightNum) || weightNum < 20 || weightNum > 300)) {
|
||||
wx.showToast({ title: '体重需在20-300kg之间', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,8 @@
|
||||
placeholder-class="form-placeholder"
|
||||
value="{{ height }}"
|
||||
disabled="{{ readonly }}"
|
||||
bind:input="onHeightInput" />
|
||||
bind:input="onHeightInput"
|
||||
bind:blur="onHeightBlur" />
|
||||
<text class="form-suffix form-suffix-inside">cm</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -99,7 +100,8 @@
|
||||
placeholder-class="form-placeholder"
|
||||
value="{{ weight }}"
|
||||
disabled="{{ readonly }}"
|
||||
bind:input="onWeightInput" />
|
||||
bind:input="onWeightInput"
|
||||
bind:blur="onWeightBlur" />
|
||||
<text class="form-suffix form-suffix-inside">kg</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user