fix(addMember): 员工编号查询结果保存完整数据,提交时作为 base 合并
员工 tab 提交时使用 employeeQueryResult(getUserInfoByWkno 返回的完整数据) 作为 payload base,确保 userId、deviceId 等字段不丢失。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
24fda6becc
commit
9b669aa486
@@ -114,6 +114,8 @@ Page({
|
|||||||
employeeNotFound: false,
|
employeeNotFound: false,
|
||||||
/** 部门展示文案 */
|
/** 部门展示文案 */
|
||||||
unitDisplay: '',
|
unitDisplay: '',
|
||||||
|
/** 员工编号查询返回的完整数据,提交时作为 base 合并 */
|
||||||
|
employeeQueryResult: null as Record<string, any> | null,
|
||||||
},
|
},
|
||||||
|
|
||||||
/** tabs 切换:清空查询结果、重置表单 */
|
/** tabs 切换:清空查询结果、重置表单 */
|
||||||
@@ -124,6 +126,7 @@ Page({
|
|||||||
employeeQueried: false,
|
employeeQueried: false,
|
||||||
employeeNotFound: false,
|
employeeNotFound: false,
|
||||||
unitDisplay: '',
|
unitDisplay: '',
|
||||||
|
employeeQueryResult: null,
|
||||||
readonly: false,
|
readonly: false,
|
||||||
hasQueried: false,
|
hasQueried: false,
|
||||||
serverResult: null,
|
serverResult: null,
|
||||||
@@ -147,6 +150,7 @@ Page({
|
|||||||
employeeQueried: false,
|
employeeQueried: false,
|
||||||
employeeNotFound: false,
|
employeeNotFound: false,
|
||||||
unitDisplay: '',
|
unitDisplay: '',
|
||||||
|
employeeQueryResult: null,
|
||||||
'form.name': '',
|
'form.name': '',
|
||||||
'form.gender': '',
|
'form.gender': '',
|
||||||
'form.age': '',
|
'form.age': '',
|
||||||
@@ -177,6 +181,7 @@ Page({
|
|||||||
employeeQueried: true,
|
employeeQueried: true,
|
||||||
employeeNotFound: true,
|
employeeNotFound: true,
|
||||||
unitDisplay: '',
|
unitDisplay: '',
|
||||||
|
employeeQueryResult: null,
|
||||||
'form.name': '',
|
'form.name': '',
|
||||||
'form.gender': '',
|
'form.gender': '',
|
||||||
'form.age': '',
|
'form.age': '',
|
||||||
@@ -191,6 +196,7 @@ Page({
|
|||||||
this.setData({
|
this.setData({
|
||||||
employeeQueried: true,
|
employeeQueried: true,
|
||||||
employeeNotFound: false,
|
employeeNotFound: false,
|
||||||
|
employeeQueryResult: result,
|
||||||
unitDisplay: [result.secondDepart, result.thirdDepart].filter(Boolean).join(' / '),
|
unitDisplay: [result.secondDepart, result.thirdDepart].filter(Boolean).join(' / '),
|
||||||
'form.name': result.realname || '',
|
'form.name': result.realname || '',
|
||||||
'form.idCard': idCard,
|
'form.idCard': idCard,
|
||||||
@@ -207,6 +213,7 @@ Page({
|
|||||||
employeeQueried: true,
|
employeeQueried: true,
|
||||||
employeeNotFound: true,
|
employeeNotFound: true,
|
||||||
unitDisplay: '',
|
unitDisplay: '',
|
||||||
|
employeeQueryResult: null,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
@@ -462,15 +469,17 @@ Page({
|
|||||||
|
|
||||||
const userInfo = wx.getStorageSync('userInfo')
|
const userInfo = wx.getStorageSync('userInfo')
|
||||||
const connectDeviceInfoRaw = wx.getStorageSync('connectDeviceInfo')
|
const connectDeviceInfoRaw = wx.getStorageSync('connectDeviceInfo')
|
||||||
const serverResult = this.data.serverResult
|
|
||||||
|
|
||||||
const baseSpread = userType === 'family' ? (this.data.selectedMember ?? {}) : {}
|
// 员工:以查询接口返回为 base;家庭:以选中的已有用户 + 身份证查询结果为 base
|
||||||
|
const baseSpread = userType === 'employee'
|
||||||
|
? (this.data.employeeQueryResult ?? {})
|
||||||
|
: { ...(this.data.selectedMember ?? {}), ...(this.data.serverResult ?? {}) }
|
||||||
|
|
||||||
const birthday = this.data.birthday
|
const birthday = this.data.birthday
|
||||||
const finalSex = userType === 'family' ? sex : this.data.form.sex
|
const finalSex = userType === 'family' ? sex : this.data.form.sex
|
||||||
|
|
||||||
const payload: Record<string, any> = {
|
const payload: Record<string, any> = {
|
||||||
...(baseSpread),
|
...(baseSpread),
|
||||||
...(serverResult ?? {}),
|
|
||||||
dataType: userType === 'family' ? 1 : 0,
|
dataType: userType === 'family' ? 1 : 0,
|
||||||
parentUserId: userInfo?.userId ?? '',
|
parentUserId: userInfo?.userId ?? '',
|
||||||
sn: lefuService.deviceInfo?.serialNumber ?? '',
|
sn: lefuService.deviceInfo?.serialNumber ?? '',
|
||||||
|
|||||||
Reference in New Issue
Block a user