1
This commit is contained in:
parent
48718b521e
commit
517bd83c76
@ -168,7 +168,11 @@ export const orderRecheckOrder = {
|
||||
}
|
||||
|
||||
/** order.updateExpressWeighingWeight:更新订单运单称重重量 */
|
||||
export function updateExpressWeighingWeight(data: { order_id: number; weighing_weight: number }) {
|
||||
export function updateExpressWeighingWeight(data: {
|
||||
order_id: number | string
|
||||
waybill_code?: string
|
||||
weighing_weight: number | string
|
||||
}) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
|
||||
@ -26,6 +26,7 @@ export const componentMap: Record<string, any> = {
|
||||
/** 与后端菜单 component 字段兼容 */
|
||||
'order/waveOrder': () => import('@/views/order/waveOrder/index.vue'),
|
||||
'orderreview/index': () => import('@/views/order/orderreview/index.vue'),
|
||||
'order/weighing': () => import('@/views/order/orderWeighing/index.vue'),
|
||||
'role/index': () => import('@/views/system/setting/role/index.vue'),
|
||||
'basicManagement':() => import('@/views/system/setting/basicManagement/index.vue'),
|
||||
'system/setting/role/index': () => import('@/views/system/setting/role/index.vue'),
|
||||
|
||||
@ -7,13 +7,23 @@
|
||||
</div>
|
||||
|
||||
<el-table :data="expressRows" border stripe size="small" empty-text="暂无运单信息">
|
||||
<el-table-column prop="waybill_code" label="运单号" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="waybill_code" label="运单号" min-width="160" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<span>{{ row.waybill_code }}</span>
|
||||
<el-tag v-if="row.is_main" size="small" type="danger" effect="dark" style="margin-left:4px">主</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="logistics_name" label="物流公司" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="称重(kg)" width="110" align="right">
|
||||
<template #default="{ row }">
|
||||
{{ formatWeight(row.weighing_weight) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="分配时间" width="140" align="center">
|
||||
<template #default="{ row }">
|
||||
{{ formatTime(row.created_at) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="包材" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ row.package_material_name_snapshot || row.package_material_code || '—' }}
|
||||
@ -130,13 +140,24 @@ function formatWeight(value: unknown) {
|
||||
return Number.isFinite(num) ? String(num) : String(value)
|
||||
}
|
||||
|
||||
function formatTime(value: unknown) {
|
||||
if (value === null || value === undefined || value === '') return '—'
|
||||
const ts = typeof value === 'number' ? (value > 1e12 ? value : value * 1000) : new Date(String(value)).getTime()
|
||||
if (!Number.isFinite(ts)) return String(value)
|
||||
const d = new Date(ts)
|
||||
const pad = (n: number) => String(n).padStart(2, '0')
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
|
||||
}
|
||||
|
||||
function normalizeExpressRows(data: Record<string, any>) {
|
||||
const expresses = Array.isArray(data.expresses) ? data.expresses : []
|
||||
if (expresses.length) {
|
||||
return expresses.map((item: any) => ({
|
||||
waybill_code: String(item.waybill_code || item.express_code || item.code || '').trim(),
|
||||
logistics_name: item.logistics_name || item.logisticsName || '',
|
||||
logistics_name: item.logistics_name || item.sys_logistics_name || item.logisticsName || '',
|
||||
weighing_weight: item.weighing_weight,
|
||||
is_main: String(item.business_key) === '1',
|
||||
created_at: item.created_at || item.create_at,
|
||||
package_material_code: item.package_material_code,
|
||||
package_material_name_snapshot: item.package_material_name_snapshot
|
||||
})).filter((item) => item.waybill_code)
|
||||
|
||||
370
src/views/order/orderWeighing/index.vue
Normal file
370
src/views/order/orderWeighing/index.vue
Normal file
@ -0,0 +1,370 @@
|
||||
<template>
|
||||
<div class="weighing-container" :style="{ height: containerHeight }">
|
||||
<div class="weighing-panel">
|
||||
<div class="panel-settings">
|
||||
<span class="setting-label">单位</span>
|
||||
<el-select v-model="weighingUnit" size="small" style="width:65px">
|
||||
<el-option label="kg" value="kg" />
|
||||
<el-option label="g" value="g" />
|
||||
</el-select>
|
||||
<span class="setting-label">分隔符</span>
|
||||
<el-input v-model="weighingDelimiter" size="small" style="width:60px" maxlength="3" />
|
||||
</div>
|
||||
<div class="panel-input">
|
||||
<el-input
|
||||
ref="searchInput"
|
||||
v-model="searchKeyword"
|
||||
:placeholder="`运单号${weighingDelimiter}重量,回车保存`"
|
||||
clearable
|
||||
size="small"
|
||||
:loading="quickSaving"
|
||||
@keyup.enter="handleQuickSave"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="panel-result" v-if="lastResult">
|
||||
<div class="result-title">{{ lastResult.wave_no || lastResult.waybill || '称重结果' }}</div>
|
||||
<div class="result-weights">
|
||||
<div class="weight-row">
|
||||
<el-tag size="default" :type="weightWarnType" class="weight-tag">{{ lastResult.weighing_weight }} kg</el-tag>
|
||||
<span class="weight-label">称重</span>
|
||||
</div>
|
||||
<div class="weight-row" v-if="lastResult.total_weight != null">
|
||||
<el-tag size="default" type="info" class="weight-tag">{{ lastResult.total_weight }} kg</el-tag>
|
||||
<span class="weight-label">系统</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="result-meta" v-if="lastResult.wave_id">
|
||||
<span>波次 {{ lastResult.wave_no }}</span>
|
||||
<span class="meta-divider">|</span>
|
||||
<span>{{ lastResult.store_name || '' }}</span>
|
||||
<template v-if="lastResult.sys_logistics_name">
|
||||
<span class="meta-divider">|</span>
|
||||
<el-tag size="small" type="warning">{{ lastResult.sys_logistics_name }}</el-tag>
|
||||
</template>
|
||||
</div>
|
||||
<div class="result-meta" v-if="lastResult.split_count > 1">
|
||||
<span>拆单 {{ lastResult.split_count }} 个</span>
|
||||
</div>
|
||||
<div class="result-splits" v-if="lastResult.splits && lastResult.splits.length > 1">
|
||||
<div
|
||||
v-for="s in lastResult.splits"
|
||||
:key="s.business_key"
|
||||
class="split-row"
|
||||
:class="{ 'has-waybill': s.waybill_code }"
|
||||
>
|
||||
<span class="split-key">{{ s.business_key }}</span>
|
||||
<span class="split-weight">{{ s.weighing_weight }} kg</span>
|
||||
<span class="split-waybill" v-if="s.waybill_code">{{ s.waybill_code }}</span>
|
||||
<span class="split-waybill empty" v-else>待分配</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="toolbar">
|
||||
<div class="toolbar-left">
|
||||
<el-button size="small" type="primary" :loading="loading" @click="loadList">刷新</el-button>
|
||||
<el-tag size="small" type="info">共 {{ pagination.total }} 条</el-tag>
|
||||
</div>
|
||||
<el-input
|
||||
v-model="filterWaybill"
|
||||
size="small"
|
||||
style="width:200px"
|
||||
placeholder="筛选运单号"
|
||||
clearable
|
||||
@keyup.enter="loadList"
|
||||
@clear="loadList"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="upper-wrapper">
|
||||
<upper-table
|
||||
ref="upperTable"
|
||||
title="称重记录"
|
||||
table-id="order-weighing-records"
|
||||
:data="tableData"
|
||||
:columns="columns"
|
||||
:table-size="tableSize"
|
||||
:pagination="pagination"
|
||||
:show-index="true"
|
||||
:loading="loading"
|
||||
:query-time="queryTime"
|
||||
row-key="id"
|
||||
@page-change="handlePageChange"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
@refresh="loadList"
|
||||
>
|
||||
<template #column-weighing_weight="{ row }">
|
||||
<span v-if="row.weighing_weight != null">{{ row.weighing_weight }} kg</span>
|
||||
<span v-else style="color:#c0c4cc">未称重</span>
|
||||
</template>
|
||||
|
||||
<template #column-updated_at="{ row }">
|
||||
{{ formatTime(row.updated_at) }}
|
||||
</template>
|
||||
</upper-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref, watch, nextTick } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { updateExpressWeighingWeight } from '@/api/order.recheckorder/recheckOrder'
|
||||
import { orderPendingOrderList } from '@/api/order.pendingorder/orderpendingOrder'
|
||||
|
||||
const settingsStore = useSettingsStore()
|
||||
const upperTable = ref<any>(null)
|
||||
const searchInput = ref<any>(null)
|
||||
|
||||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||||
const containerHeight = computed(() =>
|
||||
shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)'
|
||||
)
|
||||
|
||||
const columns = [
|
||||
{ prop: 'waybill_no', label: '运单号', minWidth: '160', showOverflowTooltip: true },
|
||||
{ prop: 'delivery_order_code', label: '订单号', minWidth: '160', showOverflowTooltip: true },
|
||||
{ prop: 'weighing_weight', label: '重量', width: '120', align: 'center' },
|
||||
{ prop: 'updated_at', label: '称重时间', width: '170', align: 'center' },
|
||||
{ prop: 'id', label: 'ID', width: '80', sortable: true }
|
||||
]
|
||||
|
||||
const tableData = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const queryTime = ref(0)
|
||||
const tableSize = ref<'small' | 'default' | 'large'>('small')
|
||||
const filterWaybill = ref('')
|
||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
|
||||
// 左侧输入
|
||||
const searchKeyword = ref('')
|
||||
const lastResult = ref<any>(null)
|
||||
const quickSaving = ref(false)
|
||||
|
||||
const weightWarnType = computed(() => {
|
||||
const actual = Number(lastResult.value?.weighing_weight)
|
||||
const system = Number(lastResult.value?.total_weight)
|
||||
if (!actual || !system) return 'success'
|
||||
const diff = Math.abs(actual - system)
|
||||
const threshold = system / 3
|
||||
if (diff > threshold) return 'danger'
|
||||
return 'success'
|
||||
})
|
||||
|
||||
// 设置
|
||||
const DELIMITER_KEY = 'order_weighing_delimiter'
|
||||
const UNIT_KEY = 'order_weighing_unit'
|
||||
const weighingDelimiter = ref(loadSetting(DELIMITER_KEY, '|'))
|
||||
const weighingUnit = ref(loadSetting(UNIT_KEY, 'kg'))
|
||||
|
||||
function loadSetting(key: string, fallback: string): string {
|
||||
try { return localStorage.getItem(key) || fallback } catch { return fallback }
|
||||
}
|
||||
function saveSetting(key: string, val: string) {
|
||||
try { localStorage.setItem(key, val) } catch { /* ignore */ }
|
||||
}
|
||||
|
||||
function isSuccess(res: any) {
|
||||
return res && [0, 1, 200].includes(res.code)
|
||||
}
|
||||
|
||||
function formatTime(v: string) {
|
||||
if (!v) return '—'
|
||||
try {
|
||||
const d = new Date(v)
|
||||
if (isNaN(d.getTime())) return v
|
||||
const pad = (n: number) => String(n).padStart(2, '0')
|
||||
return `${d.getFullYear()}-${pad(d.getMonth()+1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
|
||||
} catch { return v }
|
||||
}
|
||||
|
||||
async function loadList() {
|
||||
if (loading.value) return
|
||||
loading.value = true
|
||||
const start = Date.now()
|
||||
try {
|
||||
const where: Record<string, unknown> = {}
|
||||
const fw = filterWaybill.value.trim()
|
||||
if (fw) where.waybill_no = { operator: 'contains', value: fw, type: 'text' }
|
||||
const res: any = await orderPendingOrderList({
|
||||
page: pagination.currentPage,
|
||||
pageSize: pagination.pageSize,
|
||||
where
|
||||
})
|
||||
if (!isSuccess(res)) {
|
||||
ElMessage.error(res?.message || '获取列表失败')
|
||||
tableData.value = []
|
||||
pagination.total = 0
|
||||
return
|
||||
}
|
||||
const data = res?.data || {}
|
||||
tableData.value = data.list || []
|
||||
pagination.total = Number(data.pagination?.total ?? data.total ?? 0)
|
||||
} catch {
|
||||
tableData.value = []
|
||||
pagination.total = 0
|
||||
ElMessage.error('获取列表失败')
|
||||
} finally {
|
||||
queryTime.value = Date.now() - start
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleQuickSave() {
|
||||
const text = searchKeyword.value.trim()
|
||||
if (!text || quickSaving.value) return
|
||||
const delimiter = weighingDelimiter.value || '|'
|
||||
const parts = text.split(delimiter)
|
||||
if (parts.length < 2) {
|
||||
ElMessage.warning(`格式: 运单号${delimiter}重量`)
|
||||
return
|
||||
}
|
||||
const waybill = parts[0].trim()
|
||||
const weight = parseFloat(parts[1].trim())
|
||||
if (!waybill) { ElMessage.warning('运单号为空'); return }
|
||||
if (isNaN(weight) || weight <= 0) { ElMessage.warning('重量无效'); return }
|
||||
const finalWeight = weighingUnit.value === 'g' ? weight / 1000 : weight
|
||||
|
||||
quickSaving.value = true
|
||||
try {
|
||||
// order_id=0 + waybill_code 直接称重,无需先查订单
|
||||
const res: any = await updateExpressWeighingWeight({
|
||||
order_id: 0,
|
||||
waybill_code: waybill,
|
||||
weighing_weight: Number(finalWeight.toFixed(3))
|
||||
})
|
||||
if (isSuccess(res)) {
|
||||
ElMessage.success(`运单 ${waybill} 称重 ${finalWeight}kg 保存成功`)
|
||||
const detail = res?.data || {}
|
||||
lastResult.value = {
|
||||
waybill,
|
||||
weighing_weight: finalWeight,
|
||||
wave_id: detail.wave_id,
|
||||
wave_no: detail.wave_no,
|
||||
total_weight: detail.total_weight ?? detail.totalWeight,
|
||||
split_count: detail.split_count ?? 0,
|
||||
splits: detail.splits || [],
|
||||
store_name: detail.store_name || '',
|
||||
sys_logistics_name: detail.sys_logistics_name || ''
|
||||
}
|
||||
searchKeyword.value = ''
|
||||
void nextTick(() => searchInput.value?.focus?.())
|
||||
loadList()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '保存失败')
|
||||
}
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '保存失败')
|
||||
} finally {
|
||||
quickSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handlePageChange(page: number) { pagination.currentPage = page; loadList() }
|
||||
function handlePageSizeChange(size: number) { pagination.pageSize = size; pagination.currentPage = 1; loadList() }
|
||||
|
||||
watch(weighingDelimiter, (v) => saveSetting(DELIMITER_KEY, v))
|
||||
watch(weighingUnit, (v) => saveSetting(UNIT_KEY, v))
|
||||
|
||||
onMounted(() => { loadList(); void nextTick(() => searchInput.value?.focus?.()) })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.weighing-container {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
background-color: #f0f2f5;
|
||||
|
||||
.weighing-panel {
|
||||
flex: 0 0 280px;
|
||||
width: 280px;
|
||||
background: #fff;
|
||||
border-right: 1px solid #e4e7ed;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px;
|
||||
gap: 10px;
|
||||
|
||||
.panel-settings {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
.setting-label { font-size: 12px; color: #909399; white-space: nowrap; }
|
||||
}
|
||||
|
||||
.panel-current {
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 4px;
|
||||
padding: 8px;
|
||||
.current-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
|
||||
.current-item { display: flex; gap: 8px; font-size: 12px; margin-bottom: 4px;
|
||||
.current-label { color: #909399; min-width: 50px; }
|
||||
code { font-size: 12px; }
|
||||
strong { font-size: 13px; color: #67c23a; }
|
||||
}
|
||||
}
|
||||
|
||||
.panel-result {
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 4px;
|
||||
padding: 8px;
|
||||
.result-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
|
||||
.result-weights {
|
||||
margin-bottom: 4px;
|
||||
.weight-row { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
|
||||
.weight-tag { font-size: 15px; font-weight: 700; }
|
||||
.weight-label { font-size: 12px; color: #909399; }
|
||||
}
|
||||
.result-meta {
|
||||
font-size: 12px; color: #909399; margin-bottom: 2px;
|
||||
.meta-divider { margin: 0 6px; color: #dcdfe6; }
|
||||
strong { color: #e6a23c; }
|
||||
}
|
||||
.result-splits {
|
||||
margin-top: 6px;
|
||||
.split-row {
|
||||
display: flex; align-items: center; gap: 8px;
|
||||
font-size: 12px; padding: 3px 6px; border-radius: 3px;
|
||||
&.has-waybill { background: #f0f9eb; }
|
||||
.split-key { font-weight: 600; min-width: 24px; color: #409eff; }
|
||||
.split-weight { color: #e6a23c; min-width: 60px; }
|
||||
.split-waybill { color: #67c23a; font-family: monospace; }
|
||||
.split-waybill.empty { color: #c0c4cc; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.main-content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px;
|
||||
overflow: hidden;
|
||||
min-width: 0;
|
||||
|
||||
.toolbar {
|
||||
padding: 5px 8px;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background-color: #fff;
|
||||
flex-shrink: 0;
|
||||
.toolbar-left { display: flex; align-items: center; gap: 8px; }
|
||||
}
|
||||
|
||||
.upper-wrapper {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -414,16 +414,18 @@ defineExpose({
|
||||
}
|
||||
|
||||
.panel-list-item.is-reviewed {
|
||||
background-color: #f5f5f5;
|
||||
color: #999;
|
||||
background-color: #fafafa;
|
||||
color: #c0c4cc;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.panel-list-item.is-reviewed:hover {
|
||||
background-color: #eee;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.panel-list-item.is-reviewed.is-active {
|
||||
background-color: #e6f0fa;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.panel-list-item.is-intercepted {
|
||||
|
||||
@ -174,6 +174,30 @@
|
||||
controls-position="right"
|
||||
placeholder="未设置则留空"
|
||||
/>
|
||||
<div v-else-if="field.type === 'object' && field.itemFields && field.itemFields.length" class="object-editor">
|
||||
<div
|
||||
v-for="itemKey in field.itemFields"
|
||||
:key="`${field.key}-${itemKey.key}`"
|
||||
class="object-editor__row"
|
||||
>
|
||||
<span class="object-editor__label">{{ itemKey.label }}</span>
|
||||
<el-switch
|
||||
v-if="itemKey.type === 'boolean'"
|
||||
:model-value="getObjectFieldValue(field.key, itemKey.key) as boolean"
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
@update:model-value="onObjectFieldChange(field.key, itemKey.key, $event)"
|
||||
/>
|
||||
<el-input
|
||||
v-else
|
||||
:model-value="String(getObjectFieldValue(field.key, itemKey.key) ?? '')"
|
||||
size="small"
|
||||
style="width:200px"
|
||||
@update:model-value="onObjectFieldChange(field.key, itemKey.key, $event)"
|
||||
/>
|
||||
<span v-if="itemKey.description" class="object-editor__desc">{{ itemKey.description }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<el-input
|
||||
v-else
|
||||
v-model="subjectConfig[field.key] as string"
|
||||
@ -250,7 +274,7 @@ const PREDEFINED_COLORS = ['#ff4d4f', '#ff7a45', '#faad14', '#fadb14', '#95de64'
|
||||
type NormalizedField = {
|
||||
key: string
|
||||
label: string
|
||||
type: 'number' | 'string' | 'boolean' | 'select' | 'array' | 'color'
|
||||
type: 'number' | 'string' | 'boolean' | 'select' | 'array' | 'color' | 'object'
|
||||
description?: string
|
||||
required?: boolean
|
||||
min?: number
|
||||
@ -346,6 +370,8 @@ function normalizeFieldMetaItem(raw: Record<string, unknown>): NormalizedField |
|
||||
type = 'color'
|
||||
} else if (rawType.includes('array')) {
|
||||
type = 'array'
|
||||
} else if (rawType.includes('object')) {
|
||||
type = 'object'
|
||||
} else if (rawType === 'select' || rawType === 'enum' || options.length > 0) {
|
||||
type = 'select'
|
||||
}
|
||||
@ -360,7 +386,7 @@ function normalizeFieldMetaItem(raw: Record<string, unknown>): NormalizedField |
|
||||
const precision = toNumber(raw.precision)
|
||||
const maxLength = toNumber(raw.maxLength ?? raw.max_length)
|
||||
const defaultValue = raw.default
|
||||
const itemFields = type === 'array' ? normalizeArrayItemFields(raw.item_keys ?? raw.item_key) : undefined
|
||||
const itemFields = (type === 'array' || type === 'object') ? normalizeArrayItemFields(raw.item_keys ?? raw.item_key) : undefined
|
||||
|
||||
return {
|
||||
key,
|
||||
@ -438,6 +464,7 @@ function ensureFieldDefaults(target: Record<string, unknown>, fields: Normalized
|
||||
target[f.key] = cloneValue(f.defaultValue)
|
||||
} else if (f.type === 'boolean') target[f.key] = false
|
||||
else if (f.type === 'array') target[f.key] = []
|
||||
else if (f.type === 'object') target[f.key] = f.defaultValue !== undefined ? cloneValue(f.defaultValue) : {}
|
||||
else if (f.type === 'number') {
|
||||
/* 不写入 key,便于 el-input-number 展示为空 */
|
||||
} else if (f.type === 'select') {
|
||||
@ -542,6 +569,20 @@ function onArrayObjectItemInput(
|
||||
subjectConfig[field.key] = list
|
||||
}
|
||||
|
||||
function getObjectFieldValue(fieldKey: string, subKey: string): unknown {
|
||||
const obj = subjectConfig[fieldKey]
|
||||
if (!obj || typeof obj !== 'object' || Array.isArray(obj)) return undefined
|
||||
return (obj as Record<string, unknown>)[subKey]
|
||||
}
|
||||
|
||||
function onObjectFieldChange(fieldKey: string, subKey: string, value: unknown) {
|
||||
const current = subjectConfig[fieldKey]
|
||||
const obj: Record<string, unknown> =
|
||||
current && typeof current === 'object' && !Array.isArray(current) ? { ...(current as Record<string, unknown>) } : {}
|
||||
obj[subKey] = value
|
||||
subjectConfig[fieldKey] = obj
|
||||
}
|
||||
|
||||
function applySettingsPayload(settingsRes: SettingWarehouseSettingsPayload | Record<string, any>) {
|
||||
const wid = settingsRes.warehouse_id
|
||||
warehouseId.value = typeof wid === 'number' ? wid : wid != null ? Number(wid) : null
|
||||
@ -893,6 +934,26 @@ loadAll()
|
||||
}
|
||||
}
|
||||
|
||||
.object-editor {
|
||||
&__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
&__label {
|
||||
font-size: 13px;
|
||||
min-width: 80px;
|
||||
}
|
||||
|
||||
&__desc {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
line-height: 1.45;
|
||||
}
|
||||
}
|
||||
|
||||
.json-editor {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
|
||||
monospace;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user