黄伟杰 7 days ago
commit 1ad256fae0

@ -356,8 +356,8 @@ export default {
productionLine: '所属产线',
currentMold: '当前在机模具',
deviceStatus: '设备状态',
statusRunning: '运行中',
statusStop: '已停止',
statusRunning: '正常',
statusStop: '停用',
statusFault: '故障',
selectMountMold: '选择待上模模具',
product: '产品',

@ -69,6 +69,7 @@ import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import { getDeviceLedgerList } from '@/api/mes/moldoperate'
import { getDeviceLineTree } from '@/api/mes/deviceLine'
import { getMoldBrandPage } from '@/api/mes/mold'
const { t } = useI18n()
@ -105,65 +106,43 @@ function getStatusLabel(device) {
return map[status] || textValue(device.deviceStatus) || '-'
}
// - fallback
function getCurrentMold(device) {
const deviceId = device?.id
const deviceCode = device?.deviceCode
//
const deviceMoldMap = ref(new Map())
// 1. _mountedMoldInfoMap deviceId deviceCode fallback
async function loadDeviceMolds() {
try {
const map = uni.getStorageSync('_mountedMoldInfoMap') || {}
// id
const key = String(deviceId)
let info = deviceId != null ? map[key] : null
// deviceCode id
if (!info && deviceCode) {
const found = Object.values(map).find((item) => item?.deviceCode === deviceCode)
if (found) info = found
}
//
if (!getCurrentMold._logged) {
getCurrentMold._logged = true
console.log('[deviceSelect] === 调试信息 ===')
console.log('[deviceSelect] storage map keys:', Object.keys(map))
console.log('[deviceSelect] storage map values:', map)
console.log('[deviceSelect] 当前设备 deviceId:', deviceId, 'type:', typeof deviceId, 'key:', key)
console.log('[deviceSelect] 当前设备 deviceCode:', deviceCode)
console.log('[deviceSelect] id匹配结果:', info ? '命中' : '未命中')
if (!info) {
console.log('[deviceSelect] 尝试 deviceCode fallback...')
for (const [k, v] of Object.entries(map)) {
console.log('[deviceSelect] storage[', k, '].deviceCode =', v?.deviceCode, 'vs 设备 code =', deviceCode, '匹配:', v?.deviceCode === deviceCode)
}
const res = await getMoldBrandPage({ pageSize: 100 })
console.log('[deviceSelect] getMoldBrandPage 原始响应:', JSON.stringify(res))
const root = res && res.data !== undefined ? res.data : res
console.log('[deviceSelect] root 类型:', typeof root, 'keys:', Object.keys(root || {}))
const pageData = root?.pageResult || root
const list = Array.isArray(pageData) ? pageData : (Array.isArray(pageData?.list) ? pageData.list : [])
console.log('[deviceSelect] 模具型号总数:', list.length, '前3条:', list.slice(0, 3).map(m => ({ name: m.name, deviceName: m.deviceName })))
const map = new Map()
for (const mold of list) {
const deviceName = mold.deviceName
if (deviceName) {
if (!map.has(deviceName)) map.set(deviceName, [])
map.get(deviceName).push(mold.name || '')
}
// fallback
const saved = uni.getStorageSync('_mountedMoldInfo') || null
console.log('[deviceSelect] 旧版 _mountedMoldInfo:', saved)
console.log('[deviceSelect] 设备台账字段 currentMold:', device?.currentMold, 'moldName:', device?.moldName, 'moldId:', device?.moldId)
}
if (info?.mold) {
return info.mold.name || info.mold.moldName || '-'
}
deviceMoldMap.value = map
console.log('[deviceSelect] 在机模具映射表:', map.size, '个设备, keys:', [...map.keys()])
} catch (e) {
console.warn('[deviceSelect] read _mountedMoldInfoMap error', e)
console.error('loadDeviceMolds error', e)
}
}
// 2. _mountedMoldInfo
let saved = null
try { saved = uni.getStorageSync('_mountedMoldInfo') || null } catch {}
if (saved) {
const idMatch = deviceId != null && String(saved.deviceId) === String(deviceId)
const codeMatch = deviceCode && saved.deviceCode === deviceCode
if (idMatch || codeMatch) {
return saved.mold?.name || saved.mold?.moldName || '-'
}
// -
function getCurrentMold(device) {
if (!device) return t('moldOperate.noMoldOnDevice')
const deviceName = device.deviceName
if (deviceName && deviceMoldMap.value.has(deviceName)) {
const names = deviceMoldMap.value.get(deviceName) || []
return names.join('')
}
// 3. fallback
const staticMold = textValue(device.currentMold || device.moldName || device.moldId)
return staticMold === '-' ? t('moldOperate.noMoldOnDevice') : staticMold
// fallback
return textValue(device.currentMold || device.moldName) || t('moldOperate.noMoldOnDevice')
}
function flattenLineTree(nodes, parentId) {
@ -269,7 +248,7 @@ function handleConfirm() {
}
onShow(async () => {
await Promise.allSettled([loadDevices(), loadLineTree()])
await Promise.allSettled([loadDevices(), loadLineTree(), loadDeviceMolds()])
})
</script>

@ -80,16 +80,6 @@
<text class="grid-label">{{ t('moldOperate.product') }}</text>
<text class="grid-value">{{ textValue(selectedMold.productName) }}</text>
</view>
<view class="grid-cell">
<text class="grid-label">{{ t('moldOperate.mountTime') }}</text>
<text class="grid-value">{{ textValue(selectedMold.mountTime) }}</text>
</view>
</view>
<view class="grid-row">
<view class="grid-cell full-width">
<text class="grid-label">{{ t('moldOperate.useCount') }}</text>
<text class="grid-value highlight">{{ formatUseCount(selectedMold.useCount) }}</text>
</view>
</view>
</view>
@ -117,40 +107,15 @@
<view class="section-bar-line"></view>
<text class="section-title">{{ t('moldOperate.operator') + ' & ' + t('moldOperate.remark') }}</text>
</view>
<view class="card-body-grid">
<view class="form-row">
<view class="form-cell">
<text class="form-label"><text class="required">*</text>{{ t('moldOperate.operator') }}</text>
<view class="select-dropdown" @click="toggleOperatorDropdown">
<view class="dropdown-input">
<text :class="['dropdown-value', { placeholder: !selectedOperator }]">
{{ selectedOperator ? selectedOperator.label : t('moldOperate.placeholderOperator') }}
</text>
<uni-icons type="bottom" size="14" color="#999" class="dropdown-arrow"></uni-icons>
</view>
<view v-if="showOperatorDropdown" class="dropdown-panel">
<scroll-view scroll-y class="dropdown-scroll">
<view
v-for="(item, idx) in operatorOptions"
:key="item.value"
class="dropdown-item"
:class="{ active: selectedOperator?.value === item.value }"
@click.stop="handleSelectOperator(item, idx)"
>
<text class="dropdown-item-text">{{ item.label }}</text>
<uni-icons
v-if="selectedOperator?.value === item.value"
type="checkmarkempty"
size="16"
color="#1f7cff"
></uni-icons>
</view>
<view v-if="!operatorOptions.length" class="dropdown-empty"></view>
</scroll-view>
<view class="card-body-grid">
<view class="form-row">
<view class="form-cell">
<text class="form-label"><text class="required">*</text>{{ t('moldOperate.operator') }}</text>
<view class="dropdown-input readonly-input">
<text class="dropdown-value">{{ currentUserName }}</text>
</view>
</view>
</view>
</view>
<view class="form-row">
<view class="form-cell">
<text class="form-label">{{ t('moldOperate.remark') }}</text>
@ -202,11 +167,17 @@ import { computed, reactive, ref } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import { getLowerMoldList, getDeviceLedgerList, createMoldOperate } from '@/api/mes/moldoperate'
import { getDeviceLedgerList, createMoldOperate } from '@/api/mes/moldoperate'
import { getMoldBrandPage } from '@/api/mes/mold'
import useUserStore from '@/store/modules/user'
import { getDeviceLineTree } from '@/api/mes/deviceLine'
import { getSimpleUserList } from '@/api/system/user'
const { t } = useI18n()
const userStore = useUserStore()
//
const currentUserName = computed(() => userStore.name || '未知用户')
const currentUserId = computed(() => userStore.userId)
const lineInfoMap = ref(new Map()) // deviceLine id { name, parentId, parentChain }
@ -282,10 +253,7 @@ const tempSelectedMoldId = ref(null)
// ---- ----
const remarkText = ref('')
const operatorOptions = ref([])
const selectedOperator = ref(null)
const operatorIndex = ref(-1)
const showOperatorDropdown = ref(false)
// ---- ----
function textValue(v) {
@ -295,12 +263,7 @@ function textValue(v) {
return s || '-'
}
function formatUseCount(count) {
if (count == null) return '-'
const num = Number(count)
if (isNaN(num)) return String(count)
return num.toLocaleString() + ' ' + t('moldOperate.countUnit')
}
function formatTime(time) {
if (!time) return '-'
@ -374,45 +337,20 @@ function findArr(obj, d = 0) {
return []
}
async function loadLowerMolds(deviceId) {
async function loadLowerMolds(deviceName) {
lowerMoldLoading.value = true
try {
// ====== 1ID======
let map = {}
try { map = uni.getStorageSync('_mountedMoldInfoMap') || {} } catch {}
const savedInfo = map[String(deviceId)] || null
console.log('[下模] 持久化在机模具信息 =', savedInfo ? JSON.stringify(savedInfo) : 'null', 'deviceId=', deviceId)
if (savedInfo && savedInfo.mold) {
console.log('[下模] 命中持久化数据, deviceId=', deviceId)
const m = savedInfo.mold
lowerMoldOptions.value = [{
id: m.id,
moldId: m.id,
moldName: m.name || m.moldName || '-',
moldCode: m.code || m.moldCode || '-',
productName: m.productName || '-',
mountTime: formatTime(savedInfo.mountTime),
useCount: '-'
}]
console.log('[下模] 使用持久化数据 =', JSON.stringify(lowerMoldOptions.value[0]))
return
}
console.log('[下模] 未命中持久化数据,进入接口查询')
// ====== 2fallback - ======
let list = []
try {
const res = await getLowerMoldList(deviceId)
const root = (res && res.data !== undefined) ? res.data : res
list = findArr(root)
} catch (apiErr) {
console.warn('[下模] getLowerMoldList 接口异常', apiErr)
}
lowerMoldOptions.value = list
console.log('[下模] loadLowerMolds 返回 list.length =', list.length)
const res = await getMoldBrandPage({ deviceName, pageSize: 100 })
const root = (res && res.data !== undefined) ? res.data : res
const pageData = root?.pageResult || root
const list = Array.isArray(pageData) ? pageData : (Array.isArray(pageData?.list) ? pageData.list : [])
lowerMoldOptions.value = list.map(m => ({
id: m.id,
moldId: m.id,
moldName: m.name || '-',
moldCode: m.code || '-',
productName: m.productName || '-'
}))
} catch (e) {
console.error('loadLowerMolds error', e)
} finally {
@ -450,8 +388,8 @@ function selectDevice(device) {
selectedDevice.value = device || {}
moldsLoaded.value = false
selectedMold.value = {}
if (device?.id) {
loadLowerMolds(device.id).then(() => {
if (device?.deviceName) {
loadLowerMolds(device.deviceName).then(() => {
moldsLoaded.value = true
if (lowerMoldOptions.value.length > 0) {
const first = lowerMoldOptions.value[0]
@ -459,9 +397,7 @@ function selectDevice(device) {
id: first.id || first.moldId,
moldName: first.moldName || first.name,
moldCode: first.moldCode || first.code,
productName: first.productName || '-',
mountTime: first.mountTime || '-',
useCount: first.useCount ?? '-'
productName: first.productName || '-'
}
}
})
@ -475,12 +411,12 @@ function openDevicePicker() {
// ---- ----
function openLowerMoldPicker() {
if (!selectedDevice.value?.id) {
if (!selectedDevice.value?.deviceName) {
uni.showToast({ title: t('moldOperate.validatorDeviceRequired'), icon: 'none' })
return
}
tempSelectedMoldId.value = selectedMold.value ? String(selectedMold.value.id || selectedMold.value.moldId) : null
loadLowerMolds(selectedDevice.value.id).then(() => {
loadLowerMolds(selectedDevice.value.deviceName).then(() => {
lowerMoldPickerRef.value?.open()
})
}
@ -494,9 +430,7 @@ function confirmLowerMoldSelection() {
id: mold.id || mold.moldId,
moldName: mold.moldName || mold.name,
moldCode: mold.moldCode || mold.code,
productName: mold.productName || '-',
mountTime: mold.mountTime || '-',
useCount: mold.useCount ?? '-'
productName: mold.productName || '-'
}
}
lowerMoldPickerRef.value?.close()
@ -504,34 +438,16 @@ function confirmLowerMoldSelection() {
function closeLowerMoldPicker() { lowerMoldPickerRef.value?.close() }
// ---- ----
async function loadOperators() {
try {
const res = await getSimpleUserList()
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
operatorOptions.value = data.map((u) => ({
value: u.id || u.userId,
label: u.nickname || u.userName || u.name || String(u.id || '')
}))
} catch (e) {
console.error('loadOperators error', e)
// ---- ----
function autoSetOperator() {
if (currentUserId.value && currentUserName.value) {
selectedOperator.value = {
value: currentUserId.value,
label: currentUserName.value
}
}
}
function toggleOperatorDropdown() {
showOperatorDropdown.value = !showOperatorDropdown.value
}
function closeOperatorDropdown() {
showOperatorDropdown.value = false
}
function handleSelectOperator(item, idx) {
selectedOperator.value = item
operatorIndex.value = idx
closeOperatorDropdown()
}
function goToHistory() {
uni.navigateTo({ url: '/pages_function/pages/moldoperate/history?type=down' })
}
@ -578,21 +494,11 @@ async function handleConfirm() {
console.log('[下模] 提交参数 =', JSON.stringify(payload))
await createMoldOperate(payload)
uni.showToast({ title: t('functionCommon.createSuccess'), icon: 'success' })
//
if (selectedDevice.value?.id) {
try {
const map = uni.getStorageSync('_mountedMoldInfoMap') || {}
delete map[String(selectedDevice.value.id)]
uni.setStorageSync('_mountedMoldInfoMap', map)
} catch {}
}
//
selectedDevice.value = {}
selectedMold.value = {}
lowerMoldOptions.value = []
remarkText.value = ''
selectedOperator.value = null
operatorIndex.value = -1
} catch (e) {
console.error('[下模] 保存失败 =', e)
const errMsg = e?.msg || (typeof e === 'string' ? e : e?.message) || '系统异常'
@ -608,7 +514,8 @@ function handleCancel() {
}
onShow(async () => {
await Promise.allSettled([loadDevices(), loadLineTree(), loadOperators()])
autoSetOperator()
await Promise.allSettled([loadDevices(), loadLineTree()])
// globalData
const device = getApp().globalData._deviceSelectResult
if (device) {
@ -854,6 +761,11 @@ onShow(async () => {
font-size: 27rpx;
color: #333;
background: #f9fafb;
&.readonly-input {
background: #f8fafc;
border-color: #f0f0f0;
}
}
.dropdown-value {

@ -115,35 +115,8 @@
<view class="form-row">
<view class="form-cell">
<text class="form-label"><text class="required">*</text>{{ t('moldOperate.operator') }}</text>
<!-- 下拉选择器 -->
<view class="select-dropdown" @click="toggleOperatorDropdown">
<view class="dropdown-input">
<text :class="['dropdown-value', { placeholder: !selectedOperator }]">
{{ selectedOperator ? selectedOperator.label : t('moldOperate.placeholderOperator') }}
</text>
<uni-icons type="bottom" size="14" color="#999" class="dropdown-arrow"></uni-icons>
</view>
<!-- 下拉列表在输入框下方展开 -->
<view v-if="showOperatorDropdown" class="dropdown-panel">
<scroll-view scroll-y class="dropdown-scroll">
<view
v-for="(item, idx) in operatorOptions"
:key="item.value"
class="dropdown-item"
:class="{ active: selectedOperator?.value === item.value }"
@click.stop="handleSelectOperator(item, idx)"
>
<text class="dropdown-item-text">{{ item.label }}</text>
<uni-icons
v-if="selectedOperator?.value === item.value"
type="checkmarkempty"
size="16"
color="#1f7cff"
></uni-icons>
</view>
<view v-if="!operatorOptions.length" class="dropdown-empty"></view>
</scroll-view>
</view>
<view class="dropdown-input readonly-input">
<text class="dropdown-value">{{ currentUserName }}</text>
</view>
</view>
</view>
@ -176,9 +149,15 @@ import { onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import { getDeviceLedgerList, createMoldOperate } from '@/api/mes/moldoperate'
import { getSimpleUserList } from '@/api/system/user'
import { getMoldBrandPage } from '@/api/mes/mold'
import useUserStore from '@/store/modules/user'
const { t } = useI18n()
const userStore = useUserStore()
//
const currentUserName = computed(() => userStore.name || '未知用户')
const currentUserId = computed(() => userStore.userId)
// ---- ----
function textValue(v) {
@ -217,9 +196,7 @@ const selectedDevice = ref({})
const selectedMountMolds = ref([])
const tempSelectedDeviceId = ref(null)
const remarkText = ref('')
const operatorOptions = ref([])
const selectedOperator = ref(null)
const operatorIndex = ref(-1)
// -
const deviceStatusClass = computed(() => {
@ -241,7 +218,7 @@ const deviceStatusLabel = computed(() => {
return map[status] || textValue(selectedDevice.value?.deviceStatus) || '-'
})
const MOLD_STATUS_MAP = { 0: '在机', 1: '待用', 2: '维修', 3: '报废' }
const MOLD_STATUS_MAP = { 0: '在机', 1: '待用', 2: '维修', 3: '报废', 4: '在库' }
function getMoldStatusText(s) { return MOLD_STATUS_MAP[s] || textValue(s) }
function getMoldStatusClass(s) {
if (s === 0) return 'inuse-tag'
@ -250,91 +227,54 @@ function getMoldStatusClass(s) {
return 'standby-tag'
}
// ---- ID----
const MOUNTED_MOLD_KEY = '_mountedMoldInfoMap'
function getMountedMoldMap() {
try {
const data = uni.getStorageSync(MOUNTED_MOLD_KEY) || {}
return data
} catch (e) {
console.warn('[上模] getMountedMoldMap 异常', e)
return {}
// - machineId = ID
const currentMoldList = ref([])
async function fetchCurrentMolds(deviceName) {
if (!deviceName) {
currentMoldList.value = []
return
}
}
function getMountedMoldByDevice(deviceId) {
if (!deviceId) return null
const map = getMountedMoldMap()
const key = String(deviceId)
return map[key] || null
}
function saveMountedMoldInfo(info) {
if (!info || !info.deviceId) return
try {
const map = getMountedMoldMap()
map[String(info.deviceId)] = info
uni.setStorageSync(MOUNTED_MOLD_KEY, map)
console.log('[上模] saveMountedMoldInfo 写入成功, deviceId=', info.deviceId, 'map keys=', Object.keys(map))
//
const params = { deviceName, pageSize: 100 }
console.log('[上模] fetchCurrentMolds 请求参数:', JSON.stringify(params))
const res = await getMoldBrandPage(params)
console.log('[上模] fetchCurrentMolds 原始响应:', JSON.stringify(res))
const root = res && res.data !== undefined ? res.data : res
const pageData = root?.pageResult || root
const list = Array.isArray(pageData) ? pageData : (Array.isArray(pageData?.list) ? pageData.list : [])
console.log('[上模] fetchCurrentMolds 解析后:', list.length, '条数据', list.map(m => ({ id: m.id, name: m.name, currentDevice: m.currentDevice })))
currentMoldList.value = list
} catch (e) {
console.warn('[上模] saveMountedMoldInfo 异常', e)
console.error('fetchCurrentMolds error', e)
currentMoldList.value = []
}
}
function clearMountedMoldInfo(deviceId) {
if (!deviceId) {
try { uni.removeStorageSync(MOUNTED_MOLD_KEY) } catch {}
return
}
try {
const map = getMountedMoldMap()
delete map[String(deviceId)]
uni.setStorageSync(MOUNTED_MOLD_KEY, map)
} catch {}
}
// -
const currentMoldDisplay = computed(() => {
if (!selectedDevice.value?.id) return '-'
const saved = getMountedMoldByDevice(selectedDevice.value.id)
if (saved) {
console.log('[上模] currentMoldDisplay 命中持久化, deviceId=', selectedDevice.value.id, 'mold=', saved.mold?.name || saved.mold?.moldName)
return saved.mold?.name || saved.mold?.moldName || '-'
if (currentMoldList.value.length > 0) {
return currentMoldList.value.map(m => m.name || '').filter(Boolean).join('') || '-'
}
return textValue(selectedDevice.value.currentMold)
return t('moldOperate.noMoldOnDevice')
})
// ---- ----
async function loadOperators() {
try {
const res = await getSimpleUserList()
const data = Array.isArray(res) ? res : (Array.isArray(res?.data) ? res.data : [])
operatorOptions.value = data.map((u) => ({
value: u.id || u.userId,
label: u.nickname || u.userName || u.name || String(u.id || '')
}))
} catch (e) {
console.error('loadOperators error', e)
// ---- ----
function autoSetOperator() {
if (currentUserId.value && currentUserName.value) {
selectedOperator.value = {
value: currentUserId.value,
label: currentUserName.value
}
}
}
const showOperatorDropdown = ref(false)
function toggleOperatorDropdown() {
showOperatorDropdown.value = !showOperatorDropdown.value
}
function closeOperatorDropdown() {
showOperatorDropdown.value = false
}
function handleSelectOperator(item, idx) {
selectedOperator.value = item
operatorIndex.value = idx
closeOperatorDropdown()
}
function selectDevice(device) {
selectedDevice.value = device || {}
tempSelectedDeviceId.value = device ? device.id : null
selectedMountMolds.value = []
if (device?.deviceName) fetchCurrentMolds(device.deviceName)
}
function openDevicePicker() {
@ -394,22 +334,6 @@ async function handleConfirmMount() {
console.log('=== 上模返回 ===', JSON.stringify(res))
uni.showToast({ title: t('functionCommon.createSuccess'), icon: 'success' })
// /
if (selectedMountMolds.value.length > 0) {
const info = {
deviceId: selectedDevice.value.id,
deviceCode: selectedDevice.value.deviceCode,
deviceName: selectedDevice.value.deviceName,
mold: selectedMountMolds.value[0],
mountTime: new Date().toLocaleString()
}
saveMountedMoldInfo(info)
// globalData
getApp().globalData._mountedMoldInfo = info
getApp().globalData._mountedMoldInfoMap = getMountedMoldMap()
console.log('=== 已保存在机模具信息 ===', JSON.stringify(info))
}
selectedDevice.value = {}
selectedMountMolds.value = []
} catch (e) {
@ -449,8 +373,6 @@ function handleCancel() {
selectedDevice.value = {}
selectedMountMolds.value = []
remarkText.value = ''
selectedOperator.value = null
operatorIndex.value = -1
//
uni.navigateBack({
fail: () => uni.switchTab({ url: '/pages/work' })
@ -462,7 +384,8 @@ function goToHistory() {
}
onShow(async () => {
await Promise.allSettled([loadDevices(), loadOperators()])
autoSetOperator()
await Promise.allSettled([loadDevices()])
// globalData
const device = getApp().globalData._deviceSelectResult
if (device) {
@ -706,6 +629,11 @@ onShow(async () => {
font-size: 27rpx;
color: #333;
background: #f9fafb;
&.readonly-input {
background: #f8fafc;
border-color: #f0f0f0;
}
}
.dropdown-value {

@ -77,7 +77,7 @@ function textValue(v) {
return s || '-'
}
const STATUS_MAP = { 0: '在机', 1: '待用', 2: '维修', 3: '报废' }
const STATUS_MAP = { 0: '在机', 1: '待用', 2: '维修', 3: '报废', 4: '在库' }
function getStatusText(s) { return STATUS_MAP[s] || textValue(s) }
function getStatusClass(s) {
if (s === 0) return 'in-use-tag'
@ -87,9 +87,11 @@ function getStatusClass(s) {
}
const filteredList = computed(() => {
// status=0
const available = moldList.value.filter(m => Number(m.status) !== 0)
const keyword = searchText.value.trim().toLowerCase()
if (!keyword) return moldList.value
return moldList.value.filter((m) => {
if (!keyword) return available
return available.filter((m) => {
return (m.name || '').toLowerCase().includes(keyword) ||
(m.code || '').toLowerCase().includes(keyword) ||
(m.productName || '').toLowerCase().includes(keyword)

@ -312,10 +312,12 @@ export function resolveMenuUrl(menu) {
return directRoute
}
const keys = [menu?.component, menu?.path, menu?.enName, menu?.name]
// 优先用 menu.name中文最不容易冲突再用 component/path
const keys = [menu?.name, menu?.enName, menu?.component, menu?.path]
for (const key of keys) {
const normalizedKey = normalizeMenuKey(key)
if (normalizedKey && MENU_ROUTE_MAP[normalizedKey]) {
console.log('[resolveMenuUrl] menu.name="', menu?.name, '" matched key="', normalizedKey, '" → route="', MENU_ROUTE_MAP[normalizedKey], '"')
return MENU_ROUTE_MAP[normalizedKey]
}
}

Loading…
Cancel
Save