liufumingren 517bd83c76 1
2026-06-10 09:01:41 +08:00

969 lines
30 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="warehouse-settings-page app-container">
<el-card shadow="never" class="settings-card" v-loading="pageLoading">
<template #header>
<div class="card-header">
<div class="header-text">
<span class="title">仓库设置</span>
<span v-if="warehouseId != null" class="sub">当前仓库 ID:{{ warehouseId }}</span>
</div>
<div class="header-actions">
<el-button :loading="pageLoading" @click="loadAll">刷新</el-button>
<el-button type="primary" :loading="saving" @click="handleSave">保存</el-button>
</div>
</div>
</template>
<el-alert
v-if="loadError"
type="error"
:closable="false"
show-icon
class="mb-16"
:title="loadError"
/>
<el-tabs v-model="activeTab" class="settings-tabs">
<el-tab-pane label="配置表单" name="form">
<!-- <p v-if="useMetaForm && normalizedFields.length" class="hint">
以下字段来自接口 <code>setting.warehouse.getFieldMeta</code>,修改后点击右上角保存,将调用
<code>setting.warehouse.saveSettings</code>。
</p>
<p v-else-if="!useMetaForm" class="hint">
未获取到字段元信息,已使用常用 <code>subject_config</code> 项作为表单;保存仍写入完整配置对象。
</p> -->
<el-form label-width="200px" label-position="right" class="settings-form">
<template v-if="displayFields.length">
<el-form-item
v-for="field in displayFields"
:key="field.key"
:required="field.required"
>
<template #label>
<span :title="field.description">{{ field.label }}</span>
</template>
<div class="field-block">
<el-switch
v-if="field.type === 'boolean'"
v-model="subjectConfig[field.key]"
:active-value="true"
:inactive-value="false"
/>
<div v-else-if="field.type === 'array'" class="array-editor">
<div v-if="field.itemFields && field.itemFields.length" class="array-table">
<div class="array-table__head">
<div v-for="itemField in field.itemFields" :key="`${field.key}-${itemField.key}-head`" class="array-table__cell">
{{ itemField.label }}
</div>
<div class="array-table__op">操作</div>
</div>
<div
v-for="(item, idx) in getArrayFieldItems(field.key)"
:key="`${field.key}-${idx}`"
class="array-table__row"
>
<div v-for="itemField in field.itemFields" :key="`${field.key}-${idx}-${itemField.key}`" class="array-table__cell">
<el-switch
v-if="itemField.type === 'boolean'"
:model-value="getArrayObjectFieldValue(item, itemField.key) as boolean"
:active-value="true"
:inactive-value="false"
@update:model-value="onArrayObjectItemInput(field, idx, itemField.key, $event)"
/>
<el-select
v-else-if="itemField.type === 'select'"
:model-value="getArrayObjectFieldValue(item, itemField.key)"
clearable
filterable
placeholder="请选择"
@update:model-value="onArrayObjectItemInput(field, idx, itemField.key, $event)"
>
<el-option
v-for="opt in itemField.options || []"
:key="`${field.key}-${idx}-${itemField.key}-${String(opt.value)}`"
:label="opt.label"
:value="opt.value"
/>
</el-select>
<el-color-picker
v-else-if="itemField.type === 'color'"
:model-value="String(getArrayObjectFieldValue(item, itemField.key) ?? '')"
show-alpha
:predefine="PREDEFINED_COLORS"
@update:model-value="onArrayObjectItemInput(field, idx, itemField.key, $event)"
/>
<el-input-number
v-else-if="itemField.type === 'number'"
:model-value="getArrayObjectFieldValue(item, itemField.key) as number | undefined"
:min="itemField.min"
:max="itemField.max"
:step="itemField.step ?? 1"
:precision="itemField.precision"
controls-position="right"
placeholder="留空"
@update:model-value="onArrayObjectItemInput(field, idx, itemField.key, $event)"
/>
<el-input
v-else
:model-value="String(getArrayObjectFieldValue(item, itemField.key) ?? '')"
clearable
placeholder="请输入"
:maxlength="itemField.maxLength"
:show-word-limit="Boolean(itemField.maxLength)"
@update:model-value="onArrayObjectItemInput(field, idx, itemField.key, $event)"
/>
</div>
<div class="array-table__op">
<el-button type="danger" plain @click="removeArrayFieldItem(field.key, idx)">删除</el-button>
</div>
</div>
</div>
<div v-else>
<div
v-for="(item, idx) in getArrayFieldItems(field.key)"
:key="`${field.key}-${idx}`"
class="array-editor__row"
>
<el-input
:model-value="formatArrayItemText(item)"
type="textarea"
:rows="2"
class="field-control"
placeholder="可输入文本,或输入 JSON(对象/数组)"
@update:model-value="onArrayItemInput(field.key, idx, $event)"
/>
<el-button type="danger" plain @click="removeArrayFieldItem(field.key, idx)">删除</el-button>
</div>
</div>
<el-button type="primary" plain @click="addArrayFieldItem(field)">新增一项</el-button>
</div>
<el-select
v-else-if="field.type === 'select'"
v-model="subjectConfig[field.key]"
clearable
filterable
class="field-control"
placeholder="请选择"
>
<el-option
v-for="opt in field.options || []"
:key="String(opt.value)"
:label="opt.label"
:value="opt.value"
/>
</el-select>
<el-color-picker
v-else-if="field.type === 'color'"
v-model="subjectConfig[field.key] as string"
class="field-color-control"
show-alpha
:predefine="PREDEFINED_COLORS"
/>
<el-input-number
v-else-if="field.type === 'number'"
v-model="subjectConfig[field.key] as number | undefined"
class="field-control"
:min="field.min"
:max="field.max"
:step="field.step ?? 1"
:precision="field.precision"
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"
class="field-control"
clearable
placeholder="请输入"
:maxlength="field.maxLength"
:show-word-limit="Boolean(field.maxLength)"
/>
<div v-if="field.description" class="field-desc">{{ field.description }}</div>
</div>
</el-form-item>
</template>
<el-empty v-else description="暂无可编辑字段,请尝试 JSON 页签或检查接口返回" />
</el-form>
</el-tab-pane>
<!-- <el-tab-pane label="JSON 编辑" name="json">
<p class="hint">
直接编辑 <code>subject_config</code> 完整 JSON。保存前会校验格式;与表单页签共用同一份数据。
</p>
<el-input
v-model="jsonText"
type="textarea"
:rows="18"
class="json-editor"
placeholder='例如:{ "max_wave_quantity": 500 }'
spellcheck="false"
/>
<div class="json-actions">
<el-button @click="syncJsonFromModel">从当前表单同步到 JSON</el-button>
<el-button type="primary" plain @click="applyJsonToModel">应用 JSON 到表单</el-button>
</div>
</el-tab-pane>
<el-tab-pane label="保存选项" name="cache">
<el-form label-width="220px" class="settings-form">
<el-form-item label="清理缓存的仓库 ID">
<el-input-number
v-model="cacheWarehouseId"
:min="1"
:precision="0"
controls-position="right"
placeholder="可选,默认当前仓库"
class="field-control-narrow"
/>
<div class="field-desc">
对应参数 <code>cache_warehouse_id</code> / <code>cacheWarehouseId</code>;与接口说明一致,用于保存后清理指定仓库缓存。
</div>
</el-form-item>
</el-form>
</el-tab-pane> -->
</el-tabs>
</el-card>
</div>
</template>
<script setup lang="ts">
import { computed, reactive, ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import {
settingWarehouseGetSettings,
settingWarehouseGetFieldMeta,
settingWarehouseSaveSettings,
unwrapSettingWarehousePayload,
type SettingWarehouseSaveSettingsParams,
type SettingWarehouseSaveSettingsPayload,
type SettingWarehouseSettingsPayload
} from '@/api/setting.warehouse/settingwarehouse'
const okCode = (code: unknown) => code === 1 || code === 200 || code === 0
const PREDEFINED_COLORS = ['#ff4d4f', '#ff7a45', '#faad14', '#fadb14', '#95de64', '#52c41a']
type NormalizedField = {
key: string
label: string
type: 'number' | 'string' | 'boolean' | 'select' | 'array' | 'color' | 'object'
description?: string
required?: boolean
min?: number
max?: number
step?: number
precision?: number
maxLength?: number
defaultValue?: unknown
itemFields?: NormalizedField[]
options?: { label: string; value: string | number | boolean }[]
}
const FALLBACK_FIELDS: NormalizedField[] = [
{
key: 'max_wave_quantity',
label: '波次最大订单数',
type: 'number',
min: 1,
precision: 0,
description: '自动加团等场景会跳过订单数已达该上限的波次(与波次模块逻辑一致)。'
},
{
key: 'min_group_order_fetch_quantity',
label: '团购判定最小同组订单数',
type: 'number',
min: 1,
precision: 0,
description: '抓取团购/散单分组阈值,未配置时后端常用默认值 13。'
},
{
key: 'max_notice_webhook_count',
label: 'Webhook 通知上限',
type: 'number',
min: 0,
precision: 0
},
{ key: 'default_express_code', label: '默认快递编码', type: 'string' },
{ key: 'default_platform_code', label: '默认平台编码', type: 'string' },
{ key: 'group_wave_prefix', label: '团购波次号前缀', type: 'string' },
{
key: 'enable_external_express_code',
label: '启用外部快递编码',
type: 'boolean',
description:
'开启后允许按外部系统传入的快递编码进行处理(如无匹配仍以业务校验为准);默认关闭。'
}
]
function pickStr(obj: Record<string, unknown>, keys: string[]): string | undefined {
for (const k of keys) {
const v = obj[k]
if (v !== undefined && v !== null && String(v).trim() !== '') return String(v)
}
return undefined
}
function parseOptions(raw: unknown): { label: string; value: string | number | boolean }[] {
if (!Array.isArray(raw)) return []
return raw.map((item) => {
if (item !== null && typeof item === 'object') {
const o = item as Record<string, unknown>
const value = o.value ?? o.key ?? o.id
const label = String(o.label ?? o.text ?? o.name ?? value ?? '')
return { label, value: value as string | number | boolean }
}
return { label: String(item), value: item as string | number | boolean }
})
}
function normalizeFieldMetaItem(raw: Record<string, unknown>): NormalizedField | null {
const key = pickStr(raw, ['key', 'field', 'name', 'prop', 'id'])
if (!key) return null
const label = pickStr(raw, ['label', 'name', 'title', 'displayName']) || key
const description = pickStr(raw, ['description', 'desc', 'help', 'remark'])
const required = Boolean(raw.required ?? raw.is_required)
const rawType = String(
pickStr(raw, ['type', 'valueType', 'component', 'inputType']) || 'string'
).toLowerCase()
const options = parseOptions(raw.options ?? raw.enum)
let type: NormalizedField['type'] = 'string'
if (
rawType.includes('int') ||
rawType.includes('number') ||
rawType === 'float' ||
rawType === 'decimal'
) {
type = 'number'
} else if (rawType.includes('bool') || rawType === 'switch' || rawType === 'flag') {
type = 'boolean'
} else if (rawType.includes('color')) {
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'
}
const toNumber = (v: unknown) => {
const n = typeof v === 'number' ? v : Number(v)
return Number.isFinite(n) ? n : undefined
}
const min = toNumber(raw.min)
const max = toNumber(raw.max)
const step = toNumber(raw.step)
const precision = toNumber(raw.precision)
const maxLength = toNumber(raw.maxLength ?? raw.max_length)
const defaultValue = raw.default
const itemFields = (type === 'array' || type === 'object') ? normalizeArrayItemFields(raw.item_keys ?? raw.item_key) : undefined
return {
key,
label,
type,
description,
required,
min,
max,
step,
precision,
maxLength,
defaultValue,
itemFields,
options: options.length ? options : undefined
}
}
function normalizeArrayItemFields(raw: unknown): NormalizedField[] {
if (!raw || typeof raw !== 'object') return []
if (Array.isArray(raw)) {
return raw
.map((item) => (item && typeof item === 'object' ? normalizeFieldMetaItem(item as Record<string, unknown>) : null))
.filter((x): x is NormalizedField => !!x)
.filter((x) => x.type !== 'array')
}
const obj = raw as Record<string, unknown>
const out: NormalizedField[] = []
for (const [k, v] of Object.entries(obj)) {
if (!v || typeof v !== 'object' || Array.isArray(v)) continue
const candidate = { key: k, ...(v as Record<string, unknown>) }
const normalized = normalizeFieldMetaItem(candidate)
if (normalized && normalized.type !== 'array') out.push(normalized)
}
return out
}
function normalizeFieldMetaList(list: unknown): NormalizedField[] {
if (!Array.isArray(list)) return []
const out: NormalizedField[] = []
for (const item of list) {
if (item && typeof item === 'object') {
const n = normalizeFieldMetaItem(item as Record<string, unknown>)
if (n) out.push(n)
}
}
return out
}
function cloneSubjectConfig(src: unknown): Record<string, unknown> {
if (src && typeof src === 'object' && !Array.isArray(src)) {
return JSON.parse(JSON.stringify(src))
}
return {}
}
function cloneValue<T>(value: T): T {
if (value === null || value === undefined) return value
if (typeof value === 'object') {
try {
return JSON.parse(JSON.stringify(value)) as T
} catch {
return value
}
}
return value
}
function ensureFieldDefaults(target: Record<string, unknown>, fields: NormalizedField[]) {
for (const f of fields) {
if (!(f.key in target)) {
if (f.defaultValue !== undefined) {
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') {
/* 不默认选中,避免误保存 */
} else target[f.key] = ''
}
}
}
function getArrayFieldItems(key: string): unknown[] {
const current = subjectConfig[key]
if (Array.isArray(current)) return current
if (current === undefined || current === null || current === '') {
subjectConfig[key] = []
return subjectConfig[key] as unknown[]
}
subjectConfig[key] = [current]
return subjectConfig[key] as unknown[]
}
function parseArrayItemText(text: string): unknown {
const trimmed = text.trim()
if (!trimmed) return ''
try {
return JSON.parse(trimmed)
} catch {
return text
}
}
function formatArrayItemText(value: unknown): string {
if (value === null || value === undefined) return ''
if (typeof value === 'string') return value
try {
return JSON.stringify(value)
} catch {
return String(value)
}
}
function updateArrayFieldItem(key: string, index: number, text: string) {
const list = [...getArrayFieldItems(key)]
list[index] = parseArrayItemText(text)
subjectConfig[key] = list
}
function onArrayItemInput(key: string, index: number, val: string | number) {
updateArrayFieldItem(key, index, String(val ?? ''))
}
function addArrayFieldItem(field: NormalizedField) {
const list = [...getArrayFieldItems(field.key)]
let next: unknown = ''
if (field.itemFields && field.itemFields.length) {
next = buildArrayObjectDefault(field.itemFields)
} else if (Array.isArray(field.defaultValue) && field.defaultValue.length > 0) {
next = cloneValue(field.defaultValue[0])
}
list.push(next)
subjectConfig[field.key] = list
}
function removeArrayFieldItem(key: string, index: number) {
const list = [...getArrayFieldItems(key)]
list.splice(index, 1)
subjectConfig[key] = list
}
function buildArrayObjectDefault(itemFields: NormalizedField[]): Record<string, unknown> {
const out: Record<string, unknown> = {}
for (const f of itemFields) {
if (f.defaultValue !== undefined) {
out[f.key] = cloneValue(f.defaultValue)
} else if (f.type === 'boolean') {
out[f.key] = false
} else if (f.type === 'number') {
out[f.key] = undefined
} else {
out[f.key] = ''
}
}
return out
}
function getArrayObjectFieldValue(item: unknown, childKey: string): unknown {
if (!item || typeof item !== 'object' || Array.isArray(item)) return undefined
return (item as Record<string, unknown>)[childKey]
}
function onArrayObjectItemInput(
field: NormalizedField,
index: number,
childKey: string,
value: string | number | boolean | null | undefined
) {
const list = [...getArrayFieldItems(field.key)]
const current = list[index]
const row: Record<string, unknown> =
current && typeof current === 'object' && !Array.isArray(current) ? { ...(current as Record<string, unknown>) } : {}
row[childKey] = value
list[index] = row
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
if (!Number.isFinite(warehouseId.value as number)) warehouseId.value = null
const cfg = cloneSubjectConfig(settingsRes.subject_config)
Object.keys(subjectConfig).forEach((k) => delete subjectConfig[k])
Object.assign(subjectConfig, cfg)
ensureFieldDefaults(subjectConfig, displayFields.value)
jsonText.value = JSON.stringify(subjectConfig, null, 2)
if (warehouseId.value != null) {
cacheWarehouseId.value = warehouseId.value
}
}
const pageLoading = ref(false)
const saving = ref(false)
const loadError = ref('')
const warehouseId = ref<number | null>(null)
const subjectConfig = reactive<Record<string, unknown>>({})
const normalizedFields = ref<NormalizedField[]>([])
const useMetaForm = ref(true)
const activeTab = ref('form')
const cacheWarehouseId = ref<number | undefined>(undefined)
const jsonText = ref('{}')
const displayFields = computed(() =>
useMetaForm.value && normalizedFields.value.length ? normalizedFields.value : FALLBACK_FIELDS
)
watch(activeTab, (tab) => {
if (tab === 'json') {
try {
jsonText.value = JSON.stringify(subjectConfig, null, 2)
} catch {
jsonText.value = '{}'
}
}
})
async function loadAll() {
loadError.value = ''
pageLoading.value = true
try {
const [settingsRes, metaRes] = await Promise.all([
settingWarehouseGetSettings(),
settingWarehouseGetFieldMeta()
])
if (!settingsRes || !okCode(settingsRes.code)) {
throw new Error(settingsRes?.message || '获取仓库设置失败(getSettings)')
}
const settingsPayload = unwrapSettingWarehousePayload(
settingsRes as Record<string, unknown>
) as SettingWarehouseSettingsPayload
applySettingsPayload(settingsPayload)
const metaPayload = unwrapSettingWarehousePayload(metaRes as Record<string, unknown>)
const metaList = metaRes && okCode(metaRes.code) ? metaPayload.list : null
const parsed = normalizeFieldMetaList(metaList)
normalizedFields.value = parsed
useMetaForm.value = parsed.length > 0
ensureFieldDefaults(subjectConfig, displayFields.value)
if (metaRes && !okCode(metaRes.code)) {
ElMessage.warning(metaRes.message || '字段元信息获取失败,已使用默认表单字段')
}
} catch (e: unknown) {
const msg = e instanceof Error ? e.message : '加载失败'
loadError.value = msg
ElMessage.error(msg)
} finally {
pageLoading.value = false
}
}
function syncJsonFromModel() {
jsonText.value = JSON.stringify(subjectConfig, null, 2)
ElMessage.success('已同步')
}
function applyJsonToModel() {
try {
const parsed = JSON.parse(jsonText.value || '{}')
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
ElMessage.error('subject_config 必须是 JSON 对象')
return
}
Object.keys(subjectConfig).forEach((k) => delete subjectConfig[k])
Object.assign(subjectConfig, parsed as Record<string, unknown>)
ensureFieldDefaults(subjectConfig, displayFields.value)
ElMessage.success('已应用')
} catch {
ElMessage.error('JSON 格式不正确')
}
}
async function handleSave() {
let payloadConfig: Record<string, unknown>
if (activeTab.value === 'json') {
try {
payloadConfig = JSON.parse(jsonText.value || '{}')
if (payloadConfig === null || typeof payloadConfig !== 'object' || Array.isArray(payloadConfig)) {
ElMessage.error('subject_config 必须是 JSON 对象')
return
}
} catch {
ElMessage.error('JSON 格式不正确,无法保存')
return
}
} else {
payloadConfig = { ...subjectConfig }
}
saving.value = true
try {
const body: SettingWarehouseSaveSettingsParams = {
subject_config: payloadConfig
}
if (cacheWarehouseId.value != null && Number.isFinite(cacheWarehouseId.value)) {
body.cache_warehouse_id = cacheWarehouseId.value
}
const res = await settingWarehouseSaveSettings(body)
if (!res || !okCode(res.code)) {
throw new Error(res?.message || '保存失败')
}
ElMessage.success(res.message || '保存成功')
const savePayload = unwrapSettingWarehousePayload(
res as Record<string, unknown>
) as SettingWarehouseSaveSettingsPayload
applySettingsPayload(savePayload)
const cleared = savePayload.cache_cleared_warehouse_id
if (cleared != null) {
ElMessage.info(`已清理仓库缓存:${cleared}`)
}
} catch (e: unknown) {
ElMessage.error(e instanceof Error ? e.message : '保存失败')
} finally {
saving.value = false
}
}
loadAll()
</script>
<style scoped lang="scss">
.warehouse-settings-page {
padding: 12px;
height: 100%;
box-sizing: border-box;
}
.settings-card {
border-radius: 8px;
height: calc(100vh - 108px);
:deep(.el-card__body) {
height: calc(100% - 57px);
overflow: hidden;
display: flex;
flex-direction: column;
}
}
.card-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
flex-wrap: wrap;
}
.header-text {
display: flex;
flex-direction: column;
gap: 4px;
}
.title {
font-size: 16px;
font-weight: 600;
color: #303133;
}
.sub {
font-size: 13px;
color: #909399;
}
.header-actions {
display: flex;
gap: 8px;
}
.mb-16 {
margin-bottom: 16px;
}
.hint {
font-size: 13px;
color: #606266;
margin: 0 0 16px;
line-height: 1.5;
code {
font-size: 12px;
padding: 1px 6px;
background: #f4f4f5;
border-radius: 4px;
}
}
.settings-tabs {
margin-top: 4px;
flex: 1;
min-height: 0;
:deep(.el-tabs__content) {
height: calc(100% - 55px);
overflow: auto;
padding-right: 4px;
box-sizing: border-box;
}
:deep(.el-tab-pane) {
min-height: 100%;
}
}
.settings-form {
max-width: 720px;
}
.field-block {
width: 100%;
}
.array-editor {
width: 100%;
display: flex;
flex-direction: column;
gap: 8px;
max-width: 560px;
.array-table {
border: 1px solid #ebeef5;
border-radius: 4px;
overflow-x: auto;
overflow-y: hidden;
&__head,
&__row {
display: flex;
flex-wrap: nowrap;
border-bottom: 1px solid #ebeef5;
min-width: max-content;
}
&__head {
background: #f8fafc;
font-size: 12px;
color: #606266;
font-weight: 600;
}
&__row:last-child {
border-bottom: none;
}
&__cell,
&__op {
padding: 8px;
border-right: 1px solid #ebeef5;
box-sizing: border-box;
}
&__cell {
flex: 0 0 140px;
min-width: 140px;
}
&__cell:last-child,
&__op:last-child {
border-right: none;
}
&__op {
flex: 0 0 72px;
min-width: 72px;
display: flex;
align-items: center;
justify-content: center;
}
:deep(.el-input),
:deep(.el-select),
:deep(.el-input-number),
:deep(.el-color-picker) {
width: 100%;
}
}
&__row {
display: flex;
gap: 8px;
align-items: flex-start;
.el-button {
flex-shrink: 0;
margin-top: 2px;
}
}
}
.field-control {
width: 100%;
max-width: 420px;
}
.field-color-control {
max-width: 420px;
}
.field-control-narrow {
width: 220px;
}
.field-desc {
margin-top: 6px;
font-size: 12px;
color: #909399;
line-height: 1.45;
max-width: 520px;
code {
font-size: 11px;
padding: 0 4px;
background: #f4f4f5;
border-radius: 3px;
}
}
.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;
font-size: 13px;
}
.json-actions {
margin-top: 12px;
display: flex;
gap: 8px;
}
</style>