优化设备配置流程,重构用户增删改查及信息下发逻辑
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
05b388020b
commit
f89f0f9531
@@ -81,6 +81,16 @@ Component({
|
||||
this.setData({ workNo: e.detail.value });
|
||||
},
|
||||
|
||||
// 监听身高输入
|
||||
onHeightInput(e) {
|
||||
this.setData({ 'userInfo.height': e.detail.value });
|
||||
},
|
||||
|
||||
// 监听体重输入
|
||||
onWeightInput(e) {
|
||||
this.setData({ 'userInfo.weight': e.detail.value });
|
||||
},
|
||||
|
||||
// 根据工号查询用户信息
|
||||
searchUser() {
|
||||
let workNo = this.data.workNo.trim();
|
||||
@@ -105,9 +115,11 @@ Component({
|
||||
icon: "none"
|
||||
})
|
||||
}
|
||||
}).catch(() => {
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
this.setData({ userInfo: null });
|
||||
wx.showToast({
|
||||
title: "查询失败,请重试",
|
||||
title: (err && err.message) || "查询失败",
|
||||
icon: "none"
|
||||
})
|
||||
})
|
||||
@@ -122,21 +134,24 @@ Component({
|
||||
})
|
||||
return;
|
||||
}
|
||||
let sn = app.globalData.ppScale.device.mac.replace(/:/g, '');
|
||||
let user = this.data.userInfo;
|
||||
$.ajax("weighingScale/v2/edit/user", {
|
||||
sn,
|
||||
realname: user.realname,
|
||||
sex: user.sex,
|
||||
birthday: user.birthday,
|
||||
height: user.height,
|
||||
weight: user.weight
|
||||
}, "POST", true, "正在添加...").then(res => {
|
||||
let userInfo = this.data.userInfo;
|
||||
// 校验身高
|
||||
if (!userInfo.height) {
|
||||
wx.showToast({ title: "请输入身高", icon: "none" });
|
||||
return;
|
||||
}
|
||||
// 校验体重
|
||||
if (!userInfo.weight) {
|
||||
wx.showToast({ title: "请输入体重", icon: "none" });
|
||||
return;
|
||||
}
|
||||
userInfo.sn = app.globalData.ppScale.device.mac.replace(/:/g, '')
|
||||
$.ajax("weighingScale/v2/edit/user", userInfo, "POST", true, "正在添加...").then(res => {
|
||||
wx.showToast({
|
||||
title: "添加成功",
|
||||
icon: "success"
|
||||
})
|
||||
this.triggerEvent('returnDate', { userInfo: user });
|
||||
this.triggerEvent('returnDate', { userInfo });
|
||||
this.closeModal();
|
||||
}).catch(() => {
|
||||
wx.showToast({
|
||||
|
||||
@@ -11,43 +11,68 @@
|
||||
<view class="input">
|
||||
<view>工号:</view>
|
||||
<view>
|
||||
<input type="text" placeholder="输入工号自动显示员工信息" value="{{workNo}}" bindinput="onWorkNoInput" bindconfirm="searchUser" />
|
||||
<input type="text" maxlength="8" placeholder="输入工号自动显示员工信息" value="{{workNo}}" bindinput="onWorkNoInput" bindconfirm="searchUser" />
|
||||
</view>
|
||||
<!-- <view class="searchBtn" bind:tap="searchUser">查询</view>-->
|
||||
</view>
|
||||
<view class="only">
|
||||
<view>姓名:</view>
|
||||
<view>
|
||||
<view>{{userInfo.realname || ''}}</view>
|
||||
<view>
|
||||
<block wx:if="{{userInfo}}">
|
||||
{{userInfo.realname || ''}}
|
||||
</block>
|
||||
<block wx:else>
|
||||
<text style="color: #808080;">请先输入工号</text>
|
||||
</block>
|
||||
</view>
|
||||
<view></view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="only">
|
||||
<view>性别:</view>
|
||||
<view>
|
||||
<view>{{userInfo.sex === 1 ? '男' : userInfo.sex === 2 ? '女' : ''}}</view>
|
||||
<view>
|
||||
<block wx:if="{{userInfo}}">
|
||||
{{userInfo.sex === 1 ? '男' : userInfo.sex === 2 ? '女' : ''}}
|
||||
</block>
|
||||
<block wx:else>
|
||||
<text style="color: #808080;">请先输入工号</text>
|
||||
</block>
|
||||
</view>
|
||||
<view></view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="only">
|
||||
<view>生日:</view>
|
||||
<view>
|
||||
<view>{{userInfo.birthday || ''}}</view>
|
||||
<view>
|
||||
<block wx:if="{{userInfo}}">
|
||||
{{userInfo.birthday || ''}}
|
||||
</block>
|
||||
<block wx:else>
|
||||
<text style="color: #808080;">请先输入工号</text>
|
||||
</block>
|
||||
</view>
|
||||
<view></view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="only">
|
||||
<view class="inputUnit">
|
||||
<view>身高:</view>
|
||||
<view>
|
||||
<view>{{userInfo.height || ''}}</view>
|
||||
<view wx:if="{{userInfo.height}}">cm</view>
|
||||
<view>
|
||||
<input type="digit" value="{{userInfo.height || ''}}" bindinput="onHeightInput" placeholder="请输入身高" />
|
||||
</view>
|
||||
<view>cm</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="only">
|
||||
<view class="inputUnit">
|
||||
<view>体重:</view>
|
||||
<view>
|
||||
<view>{{userInfo.weight || ''}}</view>
|
||||
<view wx:if="{{userInfo.weight}}">kg</view>
|
||||
<view>
|
||||
<input type="digit" value="{{userInfo.weight || ''}}" bindinput="onWeightInput" placeholder="请输入体重" />
|
||||
</view>
|
||||
<view>kg</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -55,7 +55,8 @@
|
||||
}
|
||||
|
||||
.only,
|
||||
.input {
|
||||
.input,
|
||||
.inputUnit {
|
||||
width: 100%;
|
||||
height: 104rpx;
|
||||
display: flex;
|
||||
@@ -64,14 +65,16 @@
|
||||
}
|
||||
|
||||
.only>view:nth-of-type(1),
|
||||
.input>view:nth-of-type(1) {
|
||||
.input>view:nth-of-type(1),
|
||||
.inputUnit>view:nth-of-type(1) {
|
||||
color: #333333;
|
||||
height: 104rpx;
|
||||
font-size: 32rpx;
|
||||
line-height: 104rpx;
|
||||
}
|
||||
|
||||
.only>view:nth-of-type(2) {
|
||||
.only>view:nth-of-type(2),
|
||||
.inputUnit>view:nth-of-type(2) {
|
||||
flex: 1;
|
||||
width: 0;
|
||||
height: 104rpx;
|
||||
@@ -84,7 +87,8 @@
|
||||
border: 1rpx solid #E6E6EA;
|
||||
}
|
||||
|
||||
.only>view:nth-of-type(2)>view:nth-of-type(1) {
|
||||
.only>view:nth-of-type(2)>view:nth-of-type(1),
|
||||
.inputUnit>view:nth-of-type(2)>view:nth-of-type(1) {
|
||||
flex: 1;
|
||||
width: 0;
|
||||
color: #252535;
|
||||
@@ -94,7 +98,8 @@
|
||||
line-height: 100rpx;
|
||||
}
|
||||
|
||||
.only>view:nth-of-type(2)>view:nth-of-type(2) {
|
||||
.only>view:nth-of-type(2)>view:nth-of-type(2),
|
||||
.inputUnit>view:nth-of-type(2)>view:nth-of-type(2) {
|
||||
color: #77849E;
|
||||
height: 28rpx;
|
||||
font-size: 28rpx;
|
||||
@@ -110,7 +115,8 @@
|
||||
border: 1rpx solid #E6E6EA;
|
||||
}
|
||||
|
||||
.input>view:nth-of-type(2) input {
|
||||
.input>view:nth-of-type(2) input,
|
||||
.inputUnit>view:nth-of-type(2)>view:nth-of-type(1) input {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: #252535;
|
||||
@@ -118,6 +124,10 @@
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.inputUnit>view:nth-of-type(2) {
|
||||
|
||||
}
|
||||
|
||||
.searchBtn {
|
||||
color: #FFFFFF;
|
||||
width: 120rpx;
|
||||
|
||||
Reference in New Issue
Block a user