3
This commit is contained in:
@@ -9,18 +9,17 @@
|
||||
<view class="row"><text class="label">名称</text><text class="value">{{ detail.name || '-' }}</text></view>
|
||||
<view class="row"><text class="label">品牌</text><text class="value">{{ detail.brand || '-' }}</text></view>
|
||||
<view class="row"><text class="label">规格</text><text class="value">{{ detail.spec || '-' }}</text></view>
|
||||
<view class="row"><text class="label">产地</text><text class="value">{{ detail.origin || '-' }}</text></view>
|
||||
<view class="row"><text class="label">条码</text><text class="value">{{ detail.barcode || '-' }}</text></view>
|
||||
<view class="row"><text class="label">单位</text><text class="value">{{ unitName }}</text></view>
|
||||
<view class="row"><text class="label">类别</text><text class="value">{{ categoryName }}</text></view>
|
||||
<view class="row"><text class="label">安全库存</text><text class="value">{{ stockRange }}</text></view>
|
||||
<view class="row"><text class="label">模板</text><text class="value">{{ templateName }}</text></view>
|
||||
<!-- 隐藏产地/单位/安全库存显示 -->
|
||||
</view>
|
||||
|
||||
<view class="section">
|
||||
<view class="block-title">参数</view>
|
||||
<view v-if="parameterPairs.length" class="params">
|
||||
<view class="param" v-for="item in parameterPairs" :key="item.key">
|
||||
<text class="param-key">{{ item.key }}</text>
|
||||
<view v-if="labeledPairs.length" class="params">
|
||||
<view class="param" v-for="item in labeledPairs" :key="item.key">
|
||||
<text class="param-key">{{ item.label }}</text>
|
||||
<text class="param-val">{{ item.value }}</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -63,7 +62,8 @@ export default {
|
||||
id: '',
|
||||
detail: null,
|
||||
unitName: '-',
|
||||
categoryName: '-'
|
||||
categoryName: '-',
|
||||
templateName: '-'
|
||||
}
|
||||
},
|
||||
async onLoad(query) {
|
||||
@@ -79,8 +79,9 @@ export default {
|
||||
try {
|
||||
const data = await get(`/api/products/submissions/${this.id}`)
|
||||
this.detail = data
|
||||
this.unitName = this.unitLookup(data.unitId)
|
||||
// 单位已移除
|
||||
this.categoryName = this.categoryLookup(data.categoryId)
|
||||
this.templateName = this.templateLookup(data.templateId)
|
||||
} catch (e) {
|
||||
const msg = e?.message || '加载失败'
|
||||
uni.showToast({ title: msg, icon: 'none' })
|
||||
@@ -96,11 +97,7 @@ export default {
|
||||
if (s === 'rejected') return 'rejected'
|
||||
return 'pending'
|
||||
},
|
||||
parameterPairs() {
|
||||
const params = this.detail?.parameters
|
||||
if (!params || typeof params !== 'object') return []
|
||||
return Object.keys(params).map(k => ({ key: k, value: params[k] }))
|
||||
},
|
||||
|
||||
preview(idx) {
|
||||
if (!this.detail?.images || !this.detail.images.length) return
|
||||
uni.previewImage({ urls: this.detail.images, current: idx })
|
||||
@@ -120,7 +117,7 @@ export default {
|
||||
},
|
||||
unitLookup(id) {
|
||||
try {
|
||||
const list = uni.getStorageSync('CACHE_UNITS') || []
|
||||
const list = []
|
||||
const found = list.find(x => String(x.id) === String(id))
|
||||
return found ? found.name : '-'
|
||||
} catch (_) { return '-' }
|
||||
@@ -132,6 +129,13 @@ export default {
|
||||
return found ? found.name : '-'
|
||||
} catch (_) { return '-' }
|
||||
},
|
||||
templateLookup(id) {
|
||||
try {
|
||||
const list = uni.getStorageSync('CACHE_TEMPLATES') || []
|
||||
const found = list.find(x => String(x.id) === String(id))
|
||||
return found ? found.name : '-'
|
||||
} catch (_) { return '-' }
|
||||
},
|
||||
back() {
|
||||
uni.navigateBack({ delta: 1 })
|
||||
},
|
||||
@@ -160,6 +164,20 @@ export default {
|
||||
if (min != null && max != null) return `${min} ~ ${max}`
|
||||
if (min != null) return `≥ ${min}`
|
||||
return `≤ ${max}`
|
||||
},
|
||||
labeledPairs() {
|
||||
const params = this.detail?.parameters
|
||||
if (!params || typeof params !== 'object') return []
|
||||
// 从缓存模板中读取 label
|
||||
let labelMap = {}
|
||||
try {
|
||||
const templates = uni.getStorageSync('CACHE_TEMPLATES') || []
|
||||
const tpl = templates.find(t => String(t.id) === String(this.detail?.templateId))
|
||||
if (tpl && Array.isArray(tpl.params)) {
|
||||
for (const p of tpl.params) labelMap[p.fieldKey] = p.fieldLabel
|
||||
}
|
||||
} catch (_) {}
|
||||
return Object.keys(params).map(k => ({ key: k, label: labelMap[k] || k, value: params[k] }))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user