wui-components-v2 1.2.43 → 1.2.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/wui-user/wui-user.vue +35 -17
- package/package.json +1 -1
|
@@ -94,14 +94,6 @@ const cellGroupStyle = computed(() => ({
|
|
|
94
94
|
const dialog = useDialog()
|
|
95
95
|
const toast = useGlobalToast()
|
|
96
96
|
|
|
97
|
-
// 从实体字段映射(fieldMap)中读取字段值,与参考模板中用户实体字段保持一致
|
|
98
|
-
function readUserField(fieldMap: Record<string, any>, key: string): string {
|
|
99
|
-
const val = fieldMap?.[key]
|
|
100
|
-
if (val === undefined || val === null) return ''
|
|
101
|
-
// 实体字段可能是 "编码@R@名称" 形式,取展示名称
|
|
102
|
-
return typeof val === 'string' && val.includes('@R@') ? val.split('@R@')[1] || val.split('@R@')[0] : String(val)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
97
|
const storeUser = useUser().getUserInfo()
|
|
106
98
|
const userInfo = ref({
|
|
107
99
|
name: storeUser.name,
|
|
@@ -116,13 +108,30 @@ async function fetchUserInfo() {
|
|
|
116
108
|
try {
|
|
117
109
|
const res = await getUserConfig()
|
|
118
110
|
if (res?.status !== 'success' || !res.user) return
|
|
119
|
-
const
|
|
111
|
+
const user = res.user
|
|
112
|
+
// user.name / user.nickName 为顶层字段,直接读取
|
|
120
113
|
userInfo.value = {
|
|
121
|
-
name:
|
|
122
|
-
nickName:
|
|
123
|
-
tenantName:
|
|
124
|
-
|
|
125
|
-
|
|
114
|
+
name: user.name || userInfo.value.name,
|
|
115
|
+
nickName: user.nickName || userInfo.value.nickName,
|
|
116
|
+
tenantName: userInfo.value.tenantName,
|
|
117
|
+
}
|
|
118
|
+
// 查询用户实体,实体字段为中文 key(姓名/账号/维修厂等),
|
|
119
|
+
// sourceId 为用户实体 x4u6aJ6IQQ,按实体 code 字段匹配当前用户 id
|
|
120
|
+
const sourceId = 'x4u6aJ6IQQ'
|
|
121
|
+
if (user.id) {
|
|
122
|
+
const entityRes = await req({
|
|
123
|
+
url: `/v3/mstruc/data?sourceId=${sourceId}&depth=1&pageNo=1&pageSize=1&c_code_equals=${user.id}&c_标记删除_equals=否`,
|
|
124
|
+
method: 'GET',
|
|
125
|
+
})
|
|
126
|
+
const list = entityRes?.entities || entityRes?.data?.entities || []
|
|
127
|
+
const entity = list[0]
|
|
128
|
+
if (entity) {
|
|
129
|
+
userInfo.value = {
|
|
130
|
+
name: entity['姓名'] || userInfo.value.name,
|
|
131
|
+
nickName: entity['账号'] || userInfo.value.nickName,
|
|
132
|
+
tenantName: entity['维修厂'] || userInfo.value.tenantName,
|
|
133
|
+
}
|
|
134
|
+
}
|
|
126
135
|
}
|
|
127
136
|
} catch (error) {
|
|
128
137
|
console.error('获取用户信息失败:', error)
|
|
@@ -134,13 +143,22 @@ const showVersion = ref(false) // 更新版本开关
|
|
|
134
143
|
const showSensorConfig = ref(false) // 传感器配置弹窗开关
|
|
135
144
|
const listenDuration = ref(2) // 单次听音时长,默认2秒
|
|
136
145
|
const sensor = ref(0) // 传感器在线状态 1:在线 0:离线
|
|
137
|
-
|
|
146
|
+
// 传感器编号:优先外部传入 prop,其次本地缓存 sensorCode,再尝试从 userInfo 缓存读取
|
|
147
|
+
const sensorCode = ref(
|
|
148
|
+
props.sensorCode ||
|
|
149
|
+
uni.getStorageSync('sensorCode') ||
|
|
150
|
+
uni.getStorageSync('userInfo')?.sensorCode ||
|
|
151
|
+
''
|
|
152
|
+
)
|
|
138
153
|
|
|
139
154
|
onShow(() => {
|
|
140
155
|
// 组件内部获取用户信息(租户名称等),保持独立
|
|
141
156
|
fetchUserInfo()
|
|
142
157
|
if (!props.sensorCode) {
|
|
143
|
-
sensorCode.value =
|
|
158
|
+
sensorCode.value =
|
|
159
|
+
uni.getStorageSync('sensorCode') ||
|
|
160
|
+
uni.getStorageSync('userInfo')?.sensorCode ||
|
|
161
|
+
''
|
|
144
162
|
}
|
|
145
163
|
if (props.showSensorStatus) {
|
|
146
164
|
getSensorInfo()
|
|
@@ -155,7 +173,7 @@ function resolveSensorStatus(res: any): number {
|
|
|
155
173
|
}
|
|
156
174
|
|
|
157
175
|
// 获取传感器在线信息
|
|
158
|
-
|
|
176
|
+
async function getSensorInfo(cli?: string) {
|
|
159
177
|
let code = sensorCode.value
|
|
160
178
|
let newCode = code ? code.slice(3) : ''
|
|
161
179
|
if (!newCode) return
|