1. 优化了一些交互,中药药品编辑交互

2. dev和生产环境统一鉴别
This commit is contained in:
李琦
2026-05-30 13:53:14 +08:00
parent 6d93314222
commit 27202c0740
31 changed files with 6610 additions and 0 deletions

23
utils/wxListKey.js Normal file
View File

@@ -0,0 +1,23 @@
/**
* 微信小程序 v-for :key 仅支持简单属性访问,不支持模板表达式。
* 在 JS 中为列表项预生成 _wxKey 后,模板使用 :key="item._wxKey"
*/
export function withWxKey(list, idField = 'id', fallbackPrefix = 'i') {
return (list || []).map((item, index) => ({
...item,
_wxKey: item[idField] != null && item[idField] !== ''
? String(item[idField])
: `${fallbackPrefix}${index}`,
}))
}
/** 单条消息/列表项补全 _wxKey用于 push、$set 等增量更新) */
export function ensureWxKey(item, idField = 'id', fallback) {
if (!item || typeof item !== 'object') return item
if (item._wxKey != null && item._wxKey !== '') return item
const id = item[idField]
return {
...item,
_wxKey: id != null && id !== '' ? String(id) : String(fallback),
}
}