1
This commit is contained in:
parent
11fe10829e
commit
4ebef7adc1
BIN
dist.tar.gz
BIN
dist.tar.gz
Binary file not shown.
@ -2,8 +2,7 @@ import request from '@/utils/request'
|
|||||||
|
|
||||||
const v = '1.0'
|
const v = '1.0'
|
||||||
|
|
||||||
/** 与 apidata/data.json 中 list 单项字段一致 */
|
export type StockReportListItem = {
|
||||||
export interface StorageReportListItem {
|
|
||||||
start_time?: string | null
|
start_time?: string | null
|
||||||
end_time?: string | null
|
end_time?: string | null
|
||||||
stock_id: number
|
stock_id: number
|
||||||
@ -21,7 +20,7 @@ export interface StorageReportListItem {
|
|||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StorageReportSearchBody {
|
export interface StockReportSearchBody {
|
||||||
where?: {
|
where?: {
|
||||||
start_time?: string | Date
|
start_time?: string | Date
|
||||||
end_time?: string | Date
|
end_time?: string | Date
|
||||||
@ -38,12 +37,12 @@ export interface StorageReportSearchBody {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StorageReportExportBody extends StorageReportSearchBody {
|
export interface StockReportExportBody extends StockReportSearchBody {
|
||||||
export_mode?: 'waybill' | 'item'
|
export_mode?: 'waybill' | 'item'
|
||||||
exportMode?: 'waybill' | 'item'
|
exportMode?: 'waybill' | 'item'
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StorageReportExportTaskResponse {
|
export interface StockReportExportTaskResponse {
|
||||||
task_id: string
|
task_id: string
|
||||||
status: 'submitted' | 'running' | 'success' | 'failed'
|
status: 'submitted' | 'running' | 'success' | 'failed'
|
||||||
progress: number
|
progress: number
|
||||||
@ -54,12 +53,12 @@ export interface StorageReportExportTaskResponse {
|
|||||||
code?: number
|
code?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StorageReportExportTaskProgressParams {
|
export interface StockReportExportTaskProgressParams {
|
||||||
task_id?: string
|
task_id?: string
|
||||||
taskId?: string
|
taskId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StorageReportExportTaskProgressResponse {
|
export interface StockReportExportTaskProgressResponse {
|
||||||
task_id: string
|
task_id: string
|
||||||
status: 'submitted' | 'running' | 'success' | 'failed' | 'not_found'
|
status: 'submitted' | 'running' | 'success' | 'failed' | 'not_found'
|
||||||
progress: number
|
progress: number
|
||||||
@ -71,21 +70,20 @@ export interface StorageReportExportTaskProgressResponse {
|
|||||||
code?: number
|
code?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 与网关返回一致:成功时 data 内含 list */
|
export interface StockReportSearchResult {
|
||||||
export interface StorageReportSearchResult {
|
|
||||||
flag?: string
|
flag?: string
|
||||||
code?: number
|
code?: number
|
||||||
message?: string
|
message?: string
|
||||||
data?: {
|
data?: {
|
||||||
list?: StorageReportListItem[]
|
list?: StockReportListItem[]
|
||||||
}
|
}
|
||||||
list?: StorageReportListItem[]
|
list?: StockReportListItem[]
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 不传或传 `{}` 表示无业务参数(与页面首次打开一致) */
|
/** 不传或传 `{}` 表示无业务参数(与页面首次打开一致) */
|
||||||
export function searchInventoryReport(
|
export function searchInventoryReport(
|
||||||
data?: StorageReportSearchBody
|
data?: StockReportSearchBody
|
||||||
): Promise<StorageReportSearchResult> {
|
): Promise<StockReportSearchResult> {
|
||||||
return request({
|
return request({
|
||||||
url: '/system',
|
url: '/system',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@ -101,8 +99,8 @@ export function searchInventoryReport(
|
|||||||
|
|
||||||
/** 货主侧库存报表查询 */
|
/** 货主侧库存报表查询 */
|
||||||
export function searchStoreReport(
|
export function searchStoreReport(
|
||||||
data?: StorageReportSearchBody
|
data?: StockReportSearchBody
|
||||||
): Promise<StorageReportSearchResult> {
|
): Promise<StockReportSearchResult> {
|
||||||
return request({
|
return request({
|
||||||
url: '/system',
|
url: '/system',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@ -117,8 +115,8 @@ export function searchStoreReport(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function exportInventoryReport(
|
export function exportInventoryReport(
|
||||||
data?: StorageReportExportBody
|
data?: StockReportExportBody
|
||||||
): Promise<StorageReportExportTaskResponse> {
|
): Promise<StockReportExportTaskResponse> {
|
||||||
return request({
|
return request({
|
||||||
url: '/system',
|
url: '/system',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@ -134,8 +132,8 @@ export function exportInventoryReport(
|
|||||||
|
|
||||||
/** 货主侧库存报表导出 */
|
/** 货主侧库存报表导出 */
|
||||||
export function exportStoreReport(
|
export function exportStoreReport(
|
||||||
data?: StorageReportExportBody
|
data?: StockReportExportBody
|
||||||
): Promise<StorageReportExportTaskResponse> {
|
): Promise<StockReportExportTaskResponse> {
|
||||||
return request({
|
return request({
|
||||||
url: '/system',
|
url: '/system',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@ -150,8 +148,8 @@ export function exportStoreReport(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getExportTaskProgress(
|
export function getExportTaskProgress(
|
||||||
data: StorageReportExportTaskProgressParams
|
data: StockReportExportTaskProgressParams
|
||||||
): Promise<StorageReportExportTaskProgressResponse> {
|
): Promise<StockReportExportTaskProgressResponse> {
|
||||||
return request({
|
return request({
|
||||||
url: '/system',
|
url: '/system',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
66
src/api/stock.transaction/stock.transaction.ts
Normal file
66
src/api/stock.transaction/stock.transaction.ts
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
const v = '1.0'
|
||||||
|
|
||||||
|
export type StockTransactionListSort = {
|
||||||
|
sortField?: string
|
||||||
|
sortOrder?: 'asc' | 'desc' | 'ASC' | 'DESC' | string
|
||||||
|
sort_field?: string
|
||||||
|
sort_order?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 仓库侧异步导出商品流水 */
|
||||||
|
export function transactionExport(data?: {
|
||||||
|
where?: Record<string, unknown>
|
||||||
|
sort?: StockTransactionListSort
|
||||||
|
all?: boolean
|
||||||
|
mode?: string
|
||||||
|
}) {
|
||||||
|
return request({
|
||||||
|
url: '/system',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
method: 'stock.transaction.export',
|
||||||
|
v,
|
||||||
|
timestamp: new Date().getTime()
|
||||||
|
},
|
||||||
|
data: data ?? {},
|
||||||
|
isSystemApi: true
|
||||||
|
} as any)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 货主侧异步导出商品流水 */
|
||||||
|
export function transactionExportStore(data?: {
|
||||||
|
store_id: number
|
||||||
|
where?: Record<string, unknown>
|
||||||
|
sort?: StockTransactionListSort
|
||||||
|
all?: boolean
|
||||||
|
mode?: string
|
||||||
|
}) {
|
||||||
|
return request({
|
||||||
|
url: '/system',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
method: 'stock.transaction.exportStore',
|
||||||
|
v,
|
||||||
|
timestamp: new Date().getTime()
|
||||||
|
},
|
||||||
|
data: data ?? {},
|
||||||
|
isSystemApi: true
|
||||||
|
} as any)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询商品流水导出任务进度(仓库/货主共用) */
|
||||||
|
export function transactionExportTaskProgress(data: { task_id: string }) {
|
||||||
|
return request({
|
||||||
|
url: '/system',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
method: 'stock.transaction.exportTaskProgress',
|
||||||
|
v,
|
||||||
|
timestamp: new Date().getTime()
|
||||||
|
},
|
||||||
|
data,
|
||||||
|
isSystemApi: true
|
||||||
|
} as any)
|
||||||
|
}
|
||||||
@ -567,7 +567,7 @@ export function stockTransactionList(data: StockTransactionListParams) {
|
|||||||
|
|
||||||
/** 货主侧商品出入库流水列表查询 */
|
/** 货主侧商品出入库流水列表查询 */
|
||||||
export function stockTransactionStoreList(
|
export function stockTransactionStoreList(
|
||||||
data: StockTransactionListParams & { store_id: number }
|
data: StockTransactionListParams & { store_id?: number }
|
||||||
) {
|
) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system',
|
url: '/system',
|
||||||
@ -582,60 +582,4 @@ export function stockTransactionStoreList(
|
|||||||
} as any)
|
} as any)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── 商品流水导出 ──────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
/** 仓库侧异步导出商品流水 */
|
|
||||||
export function transactionExport(data?: {
|
|
||||||
where?: Record<string, unknown>
|
|
||||||
sort?: StockTransactionListSort
|
|
||||||
all?: boolean
|
|
||||||
mode?: string
|
|
||||||
}) {
|
|
||||||
return request({
|
|
||||||
url: '/system',
|
|
||||||
method: 'post',
|
|
||||||
params: {
|
|
||||||
method: 'stock.transaction.export',
|
|
||||||
v,
|
|
||||||
timestamp: new Date().getTime()
|
|
||||||
},
|
|
||||||
data: data ?? {},
|
|
||||||
isSystemApi: true
|
|
||||||
} as any)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 货主侧异步导出商品流水 */
|
|
||||||
export function transactionExportStore(data?: {
|
|
||||||
store_id: number
|
|
||||||
where?: Record<string, unknown>
|
|
||||||
sort?: StockTransactionListSort
|
|
||||||
all?: boolean
|
|
||||||
mode?: string
|
|
||||||
}) {
|
|
||||||
return request({
|
|
||||||
url: '/system',
|
|
||||||
method: 'post',
|
|
||||||
params: {
|
|
||||||
method: 'stock.transaction.exportStore',
|
|
||||||
v,
|
|
||||||
timestamp: new Date().getTime()
|
|
||||||
},
|
|
||||||
data: data ?? {},
|
|
||||||
isSystemApi: true
|
|
||||||
} as any)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 查询商品流水导出任务进度(仓库/货主共用) */
|
|
||||||
export function transactionExportTaskProgress(data: { task_id: string }) {
|
|
||||||
return request({
|
|
||||||
url: '/system',
|
|
||||||
method: 'post',
|
|
||||||
params: {
|
|
||||||
method: 'stock.transaction.exportTaskProgress',
|
|
||||||
v,
|
|
||||||
timestamp: new Date().getTime()
|
|
||||||
},
|
|
||||||
data,
|
|
||||||
isSystemApi: true
|
|
||||||
} as any)
|
|
||||||
}
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@ export const componentMap: Record<string, any> = {
|
|||||||
'storage/productflow/store': () => import('@/views/storage/productflow/store/index.vue'),
|
'storage/productflow/store': () => import('@/views/storage/productflow/store/index.vue'),
|
||||||
'store/index': () => import('@/views/store/stores/index.vue'),
|
'store/index': () => import('@/views/store/stores/index.vue'),
|
||||||
'Externalwarehouse/shipperSigning/index': () => import('@/views/Externalwarehouse/shipperSigning/index.vue'),
|
'Externalwarehouse/shipperSigning/index': () => import('@/views/Externalwarehouse/shipperSigning/index.vue'),
|
||||||
'wave/index': () => import('@/views/order/waveOrder/index.vue'),
|
'wave/index': () => import('@/views/order/waveOrder2/index.vue'),
|
||||||
/** 与后端菜单 component 字段兼容 */
|
/** 与后端菜单 component 字段兼容 */
|
||||||
'order/waveOrder': () => import('@/views/order/waveOrder/index.vue'),
|
'order/waveOrder': () => import('@/views/order/waveOrder/index.vue'),
|
||||||
'orderreview/index': () => import('@/views/order/orderreview/index.vue'),
|
'orderreview/index': () => import('@/views/order/orderreview/index.vue'),
|
||||||
|
|||||||
@ -2,12 +2,14 @@
|
|||||||
ColumnCellRenderer — 通用表格列渲染器
|
ColumnCellRenderer — 通用表格列渲染器
|
||||||
|
|
||||||
根据传入的 ColumnSlotConfig 决定如何渲染单元格:
|
根据传入的 ColumnSlotConfig 决定如何渲染单元格:
|
||||||
- type='tag' → el-tag(可配置颜色映射)
|
- type='tag' → el-tag(支持 tagResolver / tagType 颜色映射)
|
||||||
- type='text' → 纯文本(支持 datetime 格式化)
|
- type='text' → 纯文本(支持 datetime 格式化)
|
||||||
|
- type='default' → 默认插槽渲染
|
||||||
|
- type='operation' → 操作列(由 OperationCellRenderer 处理)
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<template v-if="!config || config.type === 'text'">
|
<template v-if="!config || config.type === 'default'">
|
||||||
<span>{{ displayValue }}</span>
|
<slot />
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="config.type === 'tag'">
|
<template v-else-if="config.type === 'tag'">
|
||||||
<el-tag size="small" :type="resolvedTagType">
|
<el-tag size="small" :type="resolvedTagType">
|
||||||
@ -15,39 +17,29 @@
|
|||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<slot />
|
<span>{{ displayValue }}</span>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import type { ColumnSlotConfig } from '../config/template-config'
|
import type { ColumnSlotConfig } from '../config/template-config'
|
||||||
|
import { TAG_RESOLVERS, translate, formatTime } from '../config/template-config'
|
||||||
|
|
||||||
defineOptions({ name: 'ColumnCellRenderer' })
|
defineOptions({ name: 'ColumnCellRenderer' })
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
|
/** 列插槽渲染配置 */
|
||||||
config: ColumnSlotConfig | undefined
|
config: ColumnSlotConfig | undefined
|
||||||
|
/** 单元格值 */
|
||||||
value: any
|
value: any
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
/** 时间戳 → YYYY-MM-DD HH:mm:ss */
|
/** 显示文本:translateField 翻译 > format 格式化 > 原始值 */
|
||||||
function formatTime(val: any): string {
|
|
||||||
if (!val) return '—'
|
|
||||||
try {
|
|
||||||
const d = new Date(val)
|
|
||||||
if (isNaN(d.getTime())) return String(val)
|
|
||||||
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 String(val)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 显示文本:翻译映射 → 格式化 → 原始值 */
|
|
||||||
const displayValue = computed(() => {
|
const displayValue = computed(() => {
|
||||||
const v = props.value
|
const v = props.value
|
||||||
if (props.config?.translateMap && v !== undefined && v !== null) {
|
if (props.config?.translateField) {
|
||||||
return props.config.translateMap[String(v)] ?? String(v)
|
return translate(props.config.translateField, v)
|
||||||
}
|
}
|
||||||
if (props.config?.format === 'datetime') {
|
if (props.config?.format === 'datetime') {
|
||||||
return formatTime(v)
|
return formatTime(v)
|
||||||
@ -55,13 +47,19 @@ const displayValue = computed(() => {
|
|||||||
return v ?? '—'
|
return v ?? '—'
|
||||||
})
|
})
|
||||||
|
|
||||||
/** tag 颜色解析 */
|
|
||||||
const resolvedTagType = computed(() => {
|
const resolvedTagType = computed(() => {
|
||||||
if (!props.config || props.config.type !== 'tag') return ''
|
if (!props.config || props.config.type !== 'tag') return ''
|
||||||
const { tagType } = props.config
|
const { tagType, tagResolver } = props.config
|
||||||
|
// 优先使用 tagResolver(函数名映射)
|
||||||
|
if (tagResolver && TAG_RESOLVERS[tagResolver]) {
|
||||||
|
return TAG_RESOLVERS[tagResolver](props.value)
|
||||||
|
}
|
||||||
|
// 其次使用 tagType 映射表(用原始值查找)
|
||||||
if (tagType && typeof tagType === 'object') {
|
if (tagType && typeof tagType === 'object') {
|
||||||
return tagType[String(props.value)] ?? 'info'
|
return tagType[String(props.value)] ?? 'info'
|
||||||
}
|
}
|
||||||
|
// 最后使用固定值
|
||||||
return (typeof tagType === 'string' ? tagType : 'info')
|
return (typeof tagType === 'string' ? tagType : 'info')
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
175
src/views/mode/components/OperationCellRenderer.vue
Normal file
175
src/views/mode/components/OperationCellRenderer.vue
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
<!--
|
||||||
|
OperationCellRenderer — 表格操作列渲染组件
|
||||||
|
|
||||||
|
根据 operationButtons 配置渲染按钮列表。
|
||||||
|
|
||||||
|
支持的行为类型:
|
||||||
|
- actionType='action' → 触发 @operation-action 事件(可选配置 confirmMessage 弹确认框)
|
||||||
|
- actionType='form' → 打开 COMPONENT_REGISTRY 中注册的表单组件
|
||||||
|
|
||||||
|
使用方式:在 index.vue 中通过插槽 column-operation 引入:
|
||||||
|
<OperationCellRenderer
|
||||||
|
:buttons="currentTabConfig?.operationButtons"
|
||||||
|
:row="row"
|
||||||
|
@operation-action="handleOperationAction"
|
||||||
|
/>
|
||||||
|
-->
|
||||||
|
<template>
|
||||||
|
<div class="operation-cell">
|
||||||
|
<template v-for="btn in buttons" :key="btn.key">
|
||||||
|
<!-- action 按钮:支持确认弹窗 -->
|
||||||
|
<el-button
|
||||||
|
v-if="btn.actionType === 'action'"
|
||||||
|
link
|
||||||
|
:type="btn.type || 'primary'"
|
||||||
|
size="small"
|
||||||
|
:loading="actionLoadingMap[btn.key]"
|
||||||
|
:disabled="isDisabled(btn)"
|
||||||
|
@click.stop="handleActionClick(btn)"
|
||||||
|
>
|
||||||
|
{{ btn.label }}
|
||||||
|
</el-button>
|
||||||
|
|
||||||
|
<!-- form 按钮:打开表单弹窗 -->
|
||||||
|
<template v-else-if="btn.actionType === 'form'">
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
:type="btn.type || 'primary'"
|
||||||
|
size="small"
|
||||||
|
:disabled="isDisabled(btn)"
|
||||||
|
@click.stop="openForm(btn)"
|
||||||
|
>
|
||||||
|
{{ btn.label }}
|
||||||
|
</el-button>
|
||||||
|
|
||||||
|
<!-- 表单弹窗 -->
|
||||||
|
<component
|
||||||
|
:is="resolvedFormComponents[btn.key]"
|
||||||
|
v-if="resolvedFormComponents[btn.key] && activeFormKey === btn.key"
|
||||||
|
v-model:visible="formVisibleMap[btn.key]"
|
||||||
|
v-bind="buildFormProps(btn)"
|
||||||
|
@success="handleFormSuccess(btn.key)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, reactive, type Component } from 'vue'
|
||||||
|
import { ElMessageBox } from 'element-plus'
|
||||||
|
import { COMPONENT_REGISTRY } from '../config/template-config'
|
||||||
|
import type { OperationButtonConfig } from '../config/template-config'
|
||||||
|
|
||||||
|
defineOptions({ name: 'OperationCellRenderer' })
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
/** 操作按钮配置列表(来自 TabPageConfig.operationButtons) */
|
||||||
|
buttons?: OperationButtonConfig[]
|
||||||
|
/** 当前行数据 */
|
||||||
|
row: Record<string, any>
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
/** action 按钮点击事件(key: 按钮标识, row: 行数据) */
|
||||||
|
(e: 'operation-action', key: string, row: Record<string, any>): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
// ===== form 弹窗管理 =====
|
||||||
|
const activeFormKey = ref('')
|
||||||
|
const formVisibleMap = reactive<Record<string, boolean>>({})
|
||||||
|
const resolvedFormComponents = ref<Record<string, Component>>({})
|
||||||
|
const actionLoadingMap = reactive<Record<string, boolean>>({})
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// action 按钮:支持确认弹窗
|
||||||
|
// ============================================================
|
||||||
|
|
||||||
|
async function handleActionClick(btn: OperationButtonConfig) {
|
||||||
|
if (btn.confirmMessage) {
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm(
|
||||||
|
btn.confirmMessage,
|
||||||
|
btn.confirmTitle || '确认操作',
|
||||||
|
{
|
||||||
|
confirmButtonText: btn.confirmButtonText || '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: (btn.confirmType || 'warning') as any
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} catch {
|
||||||
|
return // 取消
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
actionLoadingMap[btn.key] = true
|
||||||
|
try {
|
||||||
|
emit('operation-action', btn.key, props.row)
|
||||||
|
} finally {
|
||||||
|
actionLoadingMap[btn.key] = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// form 按钮:打开表单弹窗
|
||||||
|
// ============================================================
|
||||||
|
|
||||||
|
function openForm(btn: OperationButtonConfig) {
|
||||||
|
if (!btn.formKey) return
|
||||||
|
|
||||||
|
const comp = COMPONENT_REGISTRY[btn.formKey]
|
||||||
|
if (!comp) {
|
||||||
|
console.warn(`[OperationCellRenderer] 未注册的表单组件: ${btn.formKey}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
activeFormKey.value = btn.key
|
||||||
|
resolvedFormComponents.value[btn.key] = comp
|
||||||
|
formVisibleMap[btn.key] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildFormProps(btn: OperationButtonConfig): Record<string, any> {
|
||||||
|
const props: Record<string, any> = {}
|
||||||
|
|
||||||
|
// paramMap: { formProp: rowField } → 从行数据取值注入表单
|
||||||
|
if (btn.paramMap) {
|
||||||
|
for (const [formProp, rowField] of Object.entries(btn.paramMap)) {
|
||||||
|
props[formProp] = props.row[rowField]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// extraParams: 固定参数直接注入
|
||||||
|
if (btn.extraParams) {
|
||||||
|
Object.assign(props, btn.extraParams)
|
||||||
|
}
|
||||||
|
|
||||||
|
return props
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleFormSuccess(key: string) {
|
||||||
|
emit('operation-action', key, props.row)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// 按钮禁用判断
|
||||||
|
// ============================================================
|
||||||
|
|
||||||
|
function isDisabled(btn: OperationButtonConfig): boolean {
|
||||||
|
if (btn.disabledOnField) {
|
||||||
|
const val = props.row[btn.disabledOnField]
|
||||||
|
if (val === undefined || val === null || val === '' || val === false) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.operation-cell {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 2px;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -2,7 +2,9 @@
|
|||||||
DetailPanel — 明细面板(通用)
|
DetailPanel — 明细面板(通用)
|
||||||
|
|
||||||
根据 detailConfig 配置的 sections 渲染 el-descriptions 分区。
|
根据 detailConfig 配置的 sections 渲染 el-descriptions 分区。
|
||||||
支持 text 和 tag 两种渲染类型。
|
支持 text、tag、pre 三种渲染类型。
|
||||||
|
支持 translateField + tagResolver 集中式翻译。
|
||||||
|
支持 apiMethod 自动获取详情数据。
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div class="detail-panel">
|
<div class="detail-panel">
|
||||||
@ -17,13 +19,19 @@
|
|||||||
:label="field.label"
|
:label="field.label"
|
||||||
:span="field.span ?? 1"
|
:span="field.span ?? 1"
|
||||||
>
|
>
|
||||||
|
<!-- tag 渲染 -->
|
||||||
<template v-if="field.renderType === 'tag'">
|
<template v-if="field.renderType === 'tag'">
|
||||||
<el-tag size="small" :type="resolveTagType(field, row[field.key])">
|
<el-tag size="small" :type="resolveTagType(field, getRowData()?.[field.key])">
|
||||||
{{ resolveDisplayValue(field, row[field.key]) }}
|
{{ resolveDisplayValue(field, getRowData()?.[field.key]) }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template>
|
||||||
|
<!-- pre 渲染 -->
|
||||||
|
<template v-else-if="field.renderType === 'pre'">
|
||||||
|
<pre class="order-list-pre">{{ getRowData()?.[field.key] ?? '—' }}</pre>
|
||||||
|
</template>
|
||||||
|
<!-- 默认文本渲染 -->
|
||||||
<template v-else>
|
<template v-else>
|
||||||
{{ resolveDisplayValue(field, row[field.key]) }}
|
{{ resolveDisplayValue(field, getRowData()?.[field.key]) }}
|
||||||
</template>
|
</template>
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
@ -33,29 +41,72 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ref, watch } from 'vue'
|
||||||
|
import { TAG_RESOLVERS, translate } from '../template-config'
|
||||||
import type { DetailSectionConfig, DetailFieldConfig } from '../template-config'
|
import type { DetailSectionConfig, DetailFieldConfig } from '../template-config'
|
||||||
|
|
||||||
defineOptions({ name: 'DetailPanel' })
|
defineOptions({ name: 'DetailPanel' })
|
||||||
|
|
||||||
defineProps<{
|
const props = defineProps<{
|
||||||
row: Record<string, any> | null
|
row: Record<string, any> | null
|
||||||
detailConfig: DetailSectionConfig[]
|
detailConfig: DetailSectionConfig[]
|
||||||
|
/** 可选的 detail API 方法,传入后自动调用获取完整明细数据 */
|
||||||
|
apiMethod?: (...args: any[]) => Promise<any>
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
function resolveTagType(field: DetailFieldConfig, val: any): string {
|
/** 通过 API 获取的增强数据(与 row 合并) */
|
||||||
const { tagType } = field
|
const enrichedData = ref<Record<string, any> | null>(null)
|
||||||
if (tagType && typeof tagType === 'object') {
|
|
||||||
return tagType[String(val)] ?? 'info'
|
watch(() => props.row, async (newRow) => {
|
||||||
|
if (newRow && props.apiMethod) {
|
||||||
|
try {
|
||||||
|
const res = await props.apiMethod({
|
||||||
|
id: newRow.id,
|
||||||
|
code: newRow.code
|
||||||
|
})
|
||||||
|
if (res && (res.code === 1 || res.code === 200)) {
|
||||||
|
enrichedData.value = res.data ?? res
|
||||||
|
} else {
|
||||||
|
enrichedData.value = null
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
enrichedData.value = null
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
enrichedData.value = null
|
||||||
}
|
}
|
||||||
return (typeof tagType === 'string' ? tagType : 'info')
|
}, { immediate: true })
|
||||||
|
|
||||||
|
/** 合并 row + API 增强数据 */
|
||||||
|
function getRowData(): Record<string, any> | null {
|
||||||
|
if (!props.row) return null
|
||||||
|
if (enrichedData.value) {
|
||||||
|
return { ...props.row, ...enrichedData.value }
|
||||||
|
}
|
||||||
|
return props.row
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveDisplayValue(field: DetailFieldConfig, val: any): string {
|
/** 解析显示值:优先使用 translateField 翻译,否则显示原始值 */
|
||||||
if (val === undefined || val === null) return '—'
|
function resolveDisplayValue(field: DetailFieldConfig, value: any): string {
|
||||||
if (field.translateMap) {
|
if (field.translateField) {
|
||||||
return field.translateMap[String(val)] ?? String(val)
|
return translate(field.translateField, value)
|
||||||
}
|
}
|
||||||
return String(val)
|
return value ?? '—'
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 解析 tag 颜色 */
|
||||||
|
function resolveTagType(field: DetailFieldConfig, value: any): string {
|
||||||
|
if (field.tagResolver) {
|
||||||
|
const resolver = TAG_RESOLVERS[field.tagResolver]
|
||||||
|
if (resolver) return resolver(value)
|
||||||
|
}
|
||||||
|
if (field.tagType) {
|
||||||
|
if (typeof field.tagType === 'object') {
|
||||||
|
return field.tagType[String(value)] ?? 'info'
|
||||||
|
}
|
||||||
|
return field.tagType
|
||||||
|
}
|
||||||
|
return 'info'
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -77,20 +128,32 @@ function resolveDisplayValue(field: DetailFieldConfig, val: any): string {
|
|||||||
&:last-child {
|
&:last-child {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.section-title {
|
.section-title {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #303133;
|
color: #303133;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 10px;
|
||||||
padding-left: 4px;
|
padding-left: 8px;
|
||||||
border-left: 3px solid #409eff;
|
border-left: 3px solid #409eff;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail-descriptions {
|
.detail-descriptions {
|
||||||
:deep(.el-descriptions__label) {
|
:deep(.el-descriptions__label) {
|
||||||
width: 120px;
|
width: 120px;
|
||||||
|
background: #fafbfc;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.order-list-pre {
|
||||||
|
margin: 0;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.8;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
color: #606266;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -1,13 +1,15 @@
|
|||||||
<!--
|
<!--
|
||||||
LogPanel — 操作日志面板(通用)
|
LogPanel — 操作日志面板(通用)
|
||||||
|
|
||||||
根据选中行数据生成模拟操作日志。
|
支持两种数据来源:
|
||||||
接入真实接口时,替换 generateMockLogs 逻辑。
|
- apiMethod 传入 → 调用真实接口获取日志
|
||||||
|
- 无 apiMethod → 基于 row 生成模拟日志(开发调试用)
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div class="log-panel">
|
<div class="log-panel">
|
||||||
<div class="section-title">操作日志</div>
|
<div class="section-title">操作日志</div>
|
||||||
<div v-if="!logs.length" class="empty-tip">暂无操作日志</div>
|
<div v-if="apiLoading" v-loading="true" class="empty-tip">加载中…</div>
|
||||||
|
<div v-else-if="!logs.length" class="empty-tip">暂无操作日志</div>
|
||||||
<div v-else class="log-timeline">
|
<div v-else class="log-timeline">
|
||||||
<div v-for="(log, i) in logs" :key="i" class="log-item">
|
<div v-for="(log, i) in logs" :key="i" class="log-item">
|
||||||
<div class="log-dot" :class="log.level" />
|
<div class="log-dot" :class="log.level" />
|
||||||
@ -28,7 +30,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
|
|
||||||
defineOptions({ name: 'LogPanel' })
|
defineOptions({ name: 'LogPanel' })
|
||||||
|
|
||||||
@ -38,15 +40,57 @@ interface LogItem {
|
|||||||
result: string
|
result: string
|
||||||
detail?: string
|
detail?: string
|
||||||
time: string
|
time: string
|
||||||
level: 'info' | 'warning' | 'error'
|
level: 'success' | 'info' | 'warning' | 'error'
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
|
/** 当前选中行数据(用于生成关联日志) */
|
||||||
row: Record<string, any> | null
|
row: Record<string, any> | null
|
||||||
|
/** 可选的日志 API 方法,传入后自动调用获取真实日志 */
|
||||||
|
apiMethod?: (...args: any[]) => Promise<any>
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
/** 根据行数据生成模拟日志 */
|
/** 通过 API 获取的真实日志列表 */
|
||||||
const logs = computed<LogItem[]>(() => {
|
const apiLogs = ref<LogItem[] | null>(null)
|
||||||
|
const apiLoading = ref(false)
|
||||||
|
|
||||||
|
watch(() => props.row, async (newRow) => {
|
||||||
|
if (newRow && props.apiMethod) {
|
||||||
|
apiLoading.value = true
|
||||||
|
try {
|
||||||
|
const res = await props.apiMethod({
|
||||||
|
id: newRow.id,
|
||||||
|
code: newRow.code,
|
||||||
|
page: 1,
|
||||||
|
pageSize: 100
|
||||||
|
})
|
||||||
|
if (res && (res.code === 1 || res.code === 200)) {
|
||||||
|
const list = res.data?.list ?? res.data?.logs ?? res.list ?? res.logs ?? []
|
||||||
|
apiLogs.value = Array.isArray(list) ? list.map((item: any) => ({
|
||||||
|
operator: item.operator ?? item.creator ?? '—',
|
||||||
|
action: item.action ?? item.operation ?? '—',
|
||||||
|
result: item.result ?? item.status ?? '—',
|
||||||
|
detail: item.detail ?? item.description ?? '',
|
||||||
|
time: item.time ?? item.create_time ?? '—',
|
||||||
|
level: (item.result === '成功' || item.status === 'success') ? 'success'
|
||||||
|
: (item.result === '失败' || item.status === 'error') ? 'error'
|
||||||
|
: 'info'
|
||||||
|
})) : []
|
||||||
|
} else {
|
||||||
|
apiLogs.value = []
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
apiLogs.value = []
|
||||||
|
} finally {
|
||||||
|
apiLoading.value = false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
apiLogs.value = null
|
||||||
|
}
|
||||||
|
}, { immediate: true })
|
||||||
|
|
||||||
|
/** 基于 row 生成模拟日志(无 apiMethod 时使用) */
|
||||||
|
const mockLogs = computed<LogItem[]>(() => {
|
||||||
if (!props.row) return []
|
if (!props.row) return []
|
||||||
|
|
||||||
const rowName = props.row.name ?? props.row.code ?? '—'
|
const rowName = props.row.name ?? props.row.code ?? '—'
|
||||||
@ -61,7 +105,7 @@ const logs = computed<LogItem[]>(() => {
|
|||||||
action: `创建了「${rowName}」`,
|
action: `创建了「${rowName}」`,
|
||||||
result: '成功',
|
result: '成功',
|
||||||
time: fmt(new Date(now.getTime() - 3600000 * 3)),
|
time: fmt(new Date(now.getTime() - 3600000 * 3)),
|
||||||
level: 'info'
|
level: 'success'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
operator: props.row.creator ?? '管理员',
|
operator: props.row.creator ?? '管理员',
|
||||||
@ -69,10 +113,18 @@ const logs = computed<LogItem[]>(() => {
|
|||||||
result: '成功',
|
result: '成功',
|
||||||
detail: `修改了状态和相关配置`,
|
detail: `修改了状态和相关配置`,
|
||||||
time: fmt(new Date(now.getTime() - 3600000)),
|
time: fmt(new Date(now.getTime() - 3600000)),
|
||||||
level: 'info'
|
level: 'success'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** 最终展示的日志:优先使用 API 日志,否则使用 mock 日志 */
|
||||||
|
const logs = computed<LogItem[]>(() => {
|
||||||
|
if (apiLogs.value !== null) {
|
||||||
|
return apiLogs.value
|
||||||
|
}
|
||||||
|
return mockLogs.value
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@ -98,68 +150,78 @@ const logs = computed<LogItem[]>(() => {
|
|||||||
|
|
||||||
.log-timeline {
|
.log-timeline {
|
||||||
padding-left: 8px;
|
padding-left: 8px;
|
||||||
}
|
|
||||||
|
|
||||||
.log-item {
|
.log-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
padding-bottom: 16px;
|
margin-bottom: 12px;
|
||||||
position: relative;
|
padding-bottom: 8px;
|
||||||
|
border-bottom: 1px dashed #ebeef5;
|
||||||
|
|
||||||
&:not(:last-child)::after {
|
&:last-child {
|
||||||
content: '';
|
border-bottom: none;
|
||||||
position: absolute;
|
margin-bottom: 0;
|
||||||
left: 5px;
|
}
|
||||||
top: 16px;
|
}
|
||||||
bottom: 0;
|
|
||||||
width: 1px;
|
.log-dot {
|
||||||
background: #e4e7ed;
|
flex-shrink: 0;
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
margin-top: 6px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #c0c4cc;
|
||||||
|
|
||||||
|
&.success {
|
||||||
|
background: #67c23a;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.warning {
|
||||||
|
background: #e6a23c;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.error {
|
||||||
|
background: #f56c6c;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.info {
|
||||||
|
background: #409eff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-content {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-operator {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #303133;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-action {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #606266;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-detail {
|
||||||
|
margin-top: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #909399;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-time {
|
||||||
|
margin-top: 2px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #c0c4cc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.log-dot {
|
|
||||||
width: 11px;
|
|
||||||
height: 11px;
|
|
||||||
border-radius: 50%;
|
|
||||||
flex-shrink: 0;
|
|
||||||
margin-top: 4px;
|
|
||||||
background: #909399;
|
|
||||||
|
|
||||||
&.info { background: #409eff; }
|
|
||||||
&.warning { background: #e6a23c; }
|
|
||||||
&.error { background: #f56c6c; }
|
|
||||||
}
|
|
||||||
|
|
||||||
.log-content {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.log-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.log-operator {
|
|
||||||
font-weight: 500;
|
|
||||||
color: #303133;
|
|
||||||
}
|
|
||||||
|
|
||||||
.log-action {
|
|
||||||
color: #606266;
|
|
||||||
}
|
|
||||||
|
|
||||||
.log-detail {
|
|
||||||
margin-top: 4px;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #909399;
|
|
||||||
}
|
|
||||||
|
|
||||||
.log-time {
|
|
||||||
margin-top: 2px;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #c0c4cc;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -1,17 +1,20 @@
|
|||||||
/**
|
/**
|
||||||
* 【页面模板】配置文件
|
* 【页面模板】配置文件 v2 — 基于 waveOrder2 架构设计
|
||||||
|
*
|
||||||
|
* ===== 核心设计 =====
|
||||||
|
*
|
||||||
|
* 1. FIELD_DICT — 全局字段预设表,每个字段拥有唯一翻译(label)和完整元数据
|
||||||
|
* 2. VALUE_MAPS — 值翻译映射表(select options 和 tag 翻译共用)
|
||||||
|
* 3. TAG_RESOLVERS — 标签颜色解析器(集中管理 tag 颜色逻辑)
|
||||||
|
* 4. 各标签页通过 key 引用所需字段(scanBoxFieldKeys / tableColumnKeys)
|
||||||
|
* 5. resolveTabConfig() — 加载时将 key 列表展开为完整配置
|
||||||
*
|
*
|
||||||
* ===== 快速上手 =====
|
* ===== 快速上手 =====
|
||||||
* 1. 复制整个 views/mode/ 文件夹,重命名为你的页面名
|
* 1. 复制整个 views/mode/ 文件夹,重命名为你的页面名
|
||||||
* 2. 修改本文件中的 tabPages 配置(标签页名称、列、筛选字段)
|
* 2. 在 FIELD_DICT 中添加你需要的字段定义
|
||||||
* 3. 替换 index.vue 中的 defineOptions name
|
* 3. 在 tabPages 中配置标签页(引用 FIELD_DICT 的 key)
|
||||||
* 4. 在 index.vue 的 loadData() 中接入真实接口
|
* 4. 在 TabPageApiConfig 中接入真实接口
|
||||||
* 5. 在 router/map.ts 中添加路由
|
* 5. 在 router/map.ts 中添加路由
|
||||||
*
|
|
||||||
* ===== 结构说明 =====
|
|
||||||
* - PAGE_CONFIG → 全局开关(是否显示 TabArea、单页模式等)
|
|
||||||
* - tabPages → 标签页列表,每个标签页独立配置列/筛选/明细
|
|
||||||
* - resolveTabConfig → 将原始配置展开为组件可用的完整配置
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Component } from 'vue'
|
import type { Component } from 'vue'
|
||||||
@ -22,61 +25,269 @@ import LogPanel from './components/LogPanel.vue'
|
|||||||
// 〇、全局页面配置
|
// 〇、全局页面配置
|
||||||
// ============================================================
|
// ============================================================
|
||||||
export const PAGE_CONFIG = {
|
export const PAGE_CONFIG = {
|
||||||
/** 是否显示顶部多标签栏(false 时所有标签页通过右侧按钮切换) */
|
/** 是否显示顶部多标签栏 */
|
||||||
showTabArea: true,
|
showTabArea: true,
|
||||||
/** 单页模式:不显示标签栏,仅一个标签页内容 */
|
/** 单页模式:不显示标签栏,仅一个标签页内容 */
|
||||||
singlePage: false
|
singlePage: false
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// 一、表格列配置
|
// 〇-A、组件注册表 — 所有可复用组件在此注册
|
||||||
// ============================================================
|
// ============================================================
|
||||||
export interface ColumnConfig {
|
export const COMPONENT_REGISTRY: Record<string, Component> = {
|
||||||
prop: string
|
DetailPanel,
|
||||||
label: string
|
LogPanel
|
||||||
minWidth?: number
|
|
||||||
width?: number
|
|
||||||
fixed?: 'left' | 'right' | boolean
|
|
||||||
align?: 'left' | 'center' | 'right'
|
|
||||||
sortable?: boolean
|
|
||||||
showOverflowTooltip?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// 二、列插槽(Slot)配置 —— 自定义单元格渲染
|
// 〇-B、SCANBOX_GROUPS — ScanBox 分组名称
|
||||||
|
// ============================================================
|
||||||
|
export const SCANBOX_GROUPS = {
|
||||||
|
basic: '基础信息',
|
||||||
|
process: '流程状态',
|
||||||
|
time: '时间范围',
|
||||||
|
custom: '自定义字段'
|
||||||
|
} as const
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// 一、FIELD_DICT — 全局字段预设表(唯一真相来源)
|
||||||
|
// ============================================================
|
||||||
|
// 每个字段拥有:
|
||||||
|
// label — 唯一翻译文本
|
||||||
|
// scanBox — ScanBox 渲染配置(type/options/group)
|
||||||
|
// table — 表格列配置(minWidth/fixed/align/sortable)
|
||||||
|
// slot — 单元格渲染配置(tag/tagResolver/translateField)
|
||||||
|
// detailLabel — 明细面板中的标签文本(可选,默认用 label)
|
||||||
|
// filterParamMap — ScanBox 筛选值 → API 传参值映射
|
||||||
|
|
||||||
|
export interface FieldDefinition {
|
||||||
|
key: string
|
||||||
|
label: string
|
||||||
|
scanBox: {
|
||||||
|
type: 'text' | 'select' | 'daterange' | 'number'
|
||||||
|
group?: string
|
||||||
|
options?: { label: string; value: any }[]
|
||||||
|
} | null
|
||||||
|
table: {
|
||||||
|
minWidth?: number
|
||||||
|
width?: number
|
||||||
|
fixed?: 'left' | 'right' | boolean
|
||||||
|
align?: 'left' | 'center' | 'right'
|
||||||
|
sortable?: boolean
|
||||||
|
showOverflowTooltip?: boolean
|
||||||
|
copyAction?: 'copy' | 'copyQr'
|
||||||
|
copyValue?: (row: any) => any
|
||||||
|
} | null
|
||||||
|
slot: {
|
||||||
|
type: 'tag' | 'text' | 'default' | 'operation'
|
||||||
|
tagType?: string | Record<string, string>
|
||||||
|
tagResolver?: string
|
||||||
|
translateField?: string
|
||||||
|
format?: 'datetime'
|
||||||
|
} | null
|
||||||
|
detailLabel?: string
|
||||||
|
filterParamMap?: Record<string, string>
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// VALUE_MAPS — 值翻译映射(select options 和 tag 翻译共用)
|
||||||
|
// ============================================================
|
||||||
|
export const VALUE_MAPS: Record<string, Record<string, string>> = {
|
||||||
|
status: { 'pending': '待处理', 'processing': '处理中', 'done': '已完成', '待处理': '待处理', '处理中': '处理中', '已完成': '已完成' },
|
||||||
|
type: { 'A': '类型A', 'B': '类型B', 'C': '类型C', '类型A': '类型A', '类型B': '类型B', '类型C': '类型C' },
|
||||||
|
bool: { '1': '是', '0': '否', '是': '是', '否': '否' }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 从 VALUE_MAPS 衍生 options(优先取中文值作为 option value) */
|
||||||
|
export function getOptions(field: string): { label: string; value: string }[] {
|
||||||
|
const map = VALUE_MAPS[field]
|
||||||
|
if (!map) return []
|
||||||
|
const seen = new Set<string>()
|
||||||
|
const opts: { label: string; value: string }[] = []
|
||||||
|
const chineseKeys: [string, string][] = []
|
||||||
|
const otherKeys: [string, string][] = []
|
||||||
|
for (const [v, l] of Object.entries(map)) {
|
||||||
|
if (/^[\u4e00-\u9fa5]/.test(v)) {
|
||||||
|
chineseKeys.push([v, l])
|
||||||
|
} else {
|
||||||
|
otherKeys.push([v, l])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const [v, l] of [...chineseKeys, ...otherKeys]) {
|
||||||
|
if (!seen.has(l)) {
|
||||||
|
seen.add(l)
|
||||||
|
opts.push({ label: l, value: v })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return opts
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 翻译 value → label */
|
||||||
|
export function translate(field: string, value: any): string {
|
||||||
|
const map = VALUE_MAPS[field]
|
||||||
|
if (!map) return String(value ?? '—')
|
||||||
|
return map[String(value)] ?? String(value ?? '—')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 格式化时间戳为 YYYY-MM-DD HH:mm:ss */
|
||||||
|
export function formatTime(value: any): string {
|
||||||
|
if (!value) return '—'
|
||||||
|
try {
|
||||||
|
const d = new Date(value)
|
||||||
|
if (isNaN(d.getTime())) return String(value)
|
||||||
|
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 String(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// TAG_RESOLVERS — 标签颜色解析器
|
||||||
|
// ============================================================
|
||||||
|
// 颜色规则:未xx=info(灰) 已xx=success(绿) xx中/部分xx=warning(黄) 错误=danger(红)
|
||||||
|
export const TAG_RESOLVERS: Record<string, (val: any) => string> = {
|
||||||
|
resolveStatusTag(v) {
|
||||||
|
if (!v) return 'info'
|
||||||
|
if (v === '已完成' || v === 'done') return 'success'
|
||||||
|
if (v === '处理中' || v === 'processing') return 'warning'
|
||||||
|
return 'info'
|
||||||
|
},
|
||||||
|
resolveBoolTag(v) {
|
||||||
|
if (v === undefined || v === null) return 'info'
|
||||||
|
if (v === '是' || v === true || v === 1 || v === '1') return 'success'
|
||||||
|
return 'info'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// 二、FIELD_DICT 实例 — 在此定义页面所需的所有字段
|
||||||
|
// ============================================================
|
||||||
|
export const FIELD_DICT: Record<string, FieldDefinition> = {
|
||||||
|
code: {
|
||||||
|
key: 'code',
|
||||||
|
label: '编号',
|
||||||
|
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
|
||||||
|
table: { minWidth: 160, fixed: 'left', copyAction: 'copy', showOverflowTooltip: true },
|
||||||
|
slot: null,
|
||||||
|
detailLabel: '编号'
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
key: 'name',
|
||||||
|
label: '名称',
|
||||||
|
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
|
||||||
|
table: { minWidth: 150, showOverflowTooltip: true },
|
||||||
|
slot: null,
|
||||||
|
detailLabel: '名称'
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
key: 'type',
|
||||||
|
label: '类型',
|
||||||
|
scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: getOptions('type') },
|
||||||
|
table: { minWidth: 100, align: 'center' },
|
||||||
|
slot: { type: 'tag', tagType: 'info', translateField: 'type' },
|
||||||
|
detailLabel: '类型',
|
||||||
|
filterParamMap: { '类型A': 'A', '类型B': 'B', '类型C': 'C' }
|
||||||
|
},
|
||||||
|
status: {
|
||||||
|
key: 'status',
|
||||||
|
label: '状态',
|
||||||
|
scanBox: { type: 'select', group: SCANBOX_GROUPS.process, options: getOptions('status') },
|
||||||
|
table: { minWidth: 100, align: 'center' },
|
||||||
|
slot: { type: 'tag', tagResolver: 'resolveStatusTag', translateField: 'status' },
|
||||||
|
detailLabel: '状态',
|
||||||
|
filterParamMap: { '待处理': 'pending', '处理中': 'processing', '已完成': 'done' }
|
||||||
|
},
|
||||||
|
count: {
|
||||||
|
key: 'count',
|
||||||
|
label: '数量',
|
||||||
|
scanBox: null,
|
||||||
|
table: { minWidth: 80, align: 'center', sortable: true },
|
||||||
|
slot: null
|
||||||
|
},
|
||||||
|
amount: {
|
||||||
|
key: 'amount',
|
||||||
|
label: '金额(元)',
|
||||||
|
scanBox: null,
|
||||||
|
table: { minWidth: 110, align: 'center', sortable: true },
|
||||||
|
slot: null
|
||||||
|
},
|
||||||
|
creator: {
|
||||||
|
key: 'creator',
|
||||||
|
label: '创建人',
|
||||||
|
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
|
||||||
|
table: { minWidth: 100 },
|
||||||
|
slot: null,
|
||||||
|
detailLabel: '创建人'
|
||||||
|
},
|
||||||
|
create_time: {
|
||||||
|
key: 'create_time',
|
||||||
|
label: '创建时间',
|
||||||
|
scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time },
|
||||||
|
table: { minWidth: 170, sortable: true },
|
||||||
|
slot: { type: 'text', format: 'datetime' },
|
||||||
|
detailLabel: '创建时间'
|
||||||
|
},
|
||||||
|
update_time: {
|
||||||
|
key: 'update_time',
|
||||||
|
label: '更新时间',
|
||||||
|
scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time },
|
||||||
|
table: { minWidth: 170, sortable: true },
|
||||||
|
slot: { type: 'text', format: 'datetime' },
|
||||||
|
detailLabel: '更新时间'
|
||||||
|
},
|
||||||
|
/** 操作列(虚拟字段,仅用于表格列渲染) */
|
||||||
|
operation: {
|
||||||
|
key: 'operation',
|
||||||
|
label: '操作',
|
||||||
|
scanBox: null,
|
||||||
|
table: { minWidth: 180, fixed: 'right', align: 'center' },
|
||||||
|
slot: { type: 'operation' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// 三、ColumnSlotConfig — 列单元格渲染配置
|
||||||
// ============================================================
|
// ============================================================
|
||||||
export interface ColumnSlotConfig {
|
export interface ColumnSlotConfig {
|
||||||
/** 渲染类型 */
|
type: 'tag' | 'text' | 'default' | 'operation'
|
||||||
type: 'tag' | 'text'
|
|
||||||
/** tag 颜色:固定值 或 值→颜色映射 */
|
|
||||||
tagType?: string | Record<string, string>
|
tagType?: string | Record<string, string>
|
||||||
/** 翻译映射表(值→显示文本),如 { '1': '启用', '0': '禁用' } */
|
tagResolver?: string
|
||||||
translateMap?: Record<string, string>
|
translateField?: string
|
||||||
/** 格式化类型 */
|
|
||||||
format?: 'datetime'
|
format?: 'datetime'
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// 三、ScanBox 筛选字段配置
|
// 三-A、OperationButtonConfig — 操作列按钮配置
|
||||||
// ============================================================
|
// ============================================================
|
||||||
export interface ScanBoxFieldConfig {
|
export interface OperationButtonConfig {
|
||||||
|
key: string
|
||||||
label: string
|
label: string
|
||||||
value: string
|
type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | ''
|
||||||
type: 'text' | 'select' | 'daterange' | 'number'
|
actionType: 'form' | 'action'
|
||||||
options?: { label: string; value: any }[]
|
formKey?: string
|
||||||
group?: string
|
formTitle?: string
|
||||||
|
formWidth?: string
|
||||||
|
paramMap?: Record<string, string>
|
||||||
|
extraParams?: Record<string, any>
|
||||||
|
disabledOnField?: string
|
||||||
|
confirmMessage?: string
|
||||||
|
confirmTitle?: string
|
||||||
|
confirmType?: 'warning' | 'danger' | 'info'
|
||||||
|
confirmButtonText?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// 四、明细面板配置
|
// 四、DetailFieldConfig / DetailSectionConfig — 明细面板配置
|
||||||
// ============================================================
|
// ============================================================
|
||||||
export interface DetailFieldConfig {
|
export interface DetailFieldConfig {
|
||||||
key: string
|
key: string
|
||||||
label: string
|
label?: string
|
||||||
span?: number
|
span?: number
|
||||||
renderType?: 'text' | 'tag'
|
renderType?: 'text' | 'tag' | 'pre'
|
||||||
tagType?: string | Record<string, string>
|
tagType?: string | Record<string, string>
|
||||||
translateMap?: Record<string, string>
|
tagResolver?: string
|
||||||
|
translateField?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DetailSectionConfig {
|
export interface DetailSectionConfig {
|
||||||
@ -93,176 +304,381 @@ export interface DetailTabConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// 五、标签页原始配置(声明式,resolveTabConfig 展开)
|
// 五、TabPageApiConfig — 标签页接口插槽配置
|
||||||
// ============================================================
|
// ============================================================
|
||||||
export interface TabPageRawConfig {
|
export type ApiMethod = (...args: any[]) => Promise<any>
|
||||||
/** 标签页唯一标识 */
|
export type ApiSource = 'api' | 'list'
|
||||||
name: string
|
export type ComponentApiConfig = { source: 'list' } | ApiMethod
|
||||||
/** 标签页显示名称 */
|
|
||||||
label: string
|
export interface TabPageApiConfig {
|
||||||
/** ScanBox 缓存 key(不同标签页用不同 key 避免串数据) */
|
/** 列表查询接口 */
|
||||||
scanBoxCacheKey: string
|
list: ApiMethod
|
||||||
/** ScanBox 筛选字段 */
|
/** 明细面板接口(可选,不配则用 row 数据) */
|
||||||
scanBoxFields: ScanBoxFieldConfig[]
|
detail?: ComponentApiConfig
|
||||||
/** UpperTable 列配置 */
|
/** 操作日志接口(可选) */
|
||||||
tableColumns: ColumnConfig[]
|
log?: ComponentApiConfig
|
||||||
/** UpperTable 标题 */
|
/** 导出接口(可选) */
|
||||||
tableTitle: string
|
export?: ApiMethod
|
||||||
/** 列插槽配置(key=列prop) */
|
/** 导出进度查询接口(可选) */
|
||||||
columnSlots?: Record<string, ColumnSlotConfig>
|
exportProgress?: ApiMethod
|
||||||
/** 明细面板分组 */
|
/** ScanBox 下拉选项数据源接口(可选) */
|
||||||
detailSections: DetailSectionConfig[]
|
scanBoxOptions?: Record<string, ApiMethod>
|
||||||
/** 明细面板标签页(默认仅"明细") */
|
/** 工具栏按钮 → API 方法映射(可选) */
|
||||||
detailTabs?: { name: string; label: string; componentKey: string }[]
|
toolbar?: Record<string, ApiMethod>
|
||||||
|
/** 列表响应解析器 */
|
||||||
|
parseListResponse?: (res: any) => { list: any[]; total: number }
|
||||||
|
/** 构建列表请求参数 */
|
||||||
|
buildListParams?: (params: {
|
||||||
|
pagination: { page: number; pageSize: number }
|
||||||
|
conditions: Record<string, any>
|
||||||
|
sort?: { prop: string; order: string }
|
||||||
|
}) => Record<string, any>
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// 六、展开后的完整配置(index.vue 直接使用)
|
// 六、TabPageRawConfig — 标签页声明配置(仅用 key 引用)
|
||||||
|
// ============================================================
|
||||||
|
export interface TabPageRawConfig {
|
||||||
|
name: string
|
||||||
|
label: string
|
||||||
|
scanBoxCacheKey: string
|
||||||
|
/** ScanBox 需要的字段 key 列表(从 FIELD_DICT 中查找) */
|
||||||
|
scanBoxFieldKeys: string[]
|
||||||
|
/** 表格需要的列 key 列表(从 FIELD_DICT 中查找) */
|
||||||
|
tableColumnKeys: string[]
|
||||||
|
upperTableDefaults: {
|
||||||
|
title: string
|
||||||
|
enableColumnConfig?: boolean
|
||||||
|
showIndex?: boolean
|
||||||
|
showSelection?: boolean
|
||||||
|
emptyText?: string
|
||||||
|
}
|
||||||
|
/** 明细面板标签页配置 */
|
||||||
|
detailTabs?: { name: string; label: string; componentKey: string }[]
|
||||||
|
/** 明细面板分区配置(字段 key 列表,resolveTabConfig 展开) */
|
||||||
|
detailSections: {
|
||||||
|
title: string
|
||||||
|
columnCount: number
|
||||||
|
fieldKeys: string[]
|
||||||
|
}[]
|
||||||
|
/** 接口配置(有 api 时启用真实接口) */
|
||||||
|
api?: TabPageApiConfig
|
||||||
|
/** 操作列按钮配置(需 tableColumnKeys 包含 'operation') */
|
||||||
|
operationButtons?: OperationButtonConfig[]
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// 七、TabPageConfig — 展开后的完整配置(给 index.vue 使用)
|
||||||
// ============================================================
|
// ============================================================
|
||||||
export interface TabPageConfig {
|
export interface TabPageConfig {
|
||||||
name: string
|
name: string
|
||||||
label: string
|
label: string
|
||||||
scanBoxCacheKey: string
|
scanBoxCacheKey: string
|
||||||
scanBoxFields: ScanBoxFieldConfig[]
|
scanBoxFields: Record<string, any>[]
|
||||||
upperTable: {
|
upperTable: {
|
||||||
title: string
|
title: string
|
||||||
columns: ColumnConfig[]
|
enableColumnConfig: boolean
|
||||||
|
showIndex: boolean
|
||||||
|
showSelection: boolean
|
||||||
|
emptyText: string
|
||||||
|
columns: Record<string, any>[]
|
||||||
}
|
}
|
||||||
columnSlots: Record<string, ColumnSlotConfig>
|
columnSlots: Record<string, ColumnSlotConfig>
|
||||||
detailConfig: DetailSectionConfig[]
|
detailConfig: DetailSectionConfig[]
|
||||||
detailTabs: DetailTabConfig[]
|
detailTabs: DetailTabConfig[]
|
||||||
|
api?: TabPageApiConfig
|
||||||
|
operationButtons?: OperationButtonConfig[]
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// 七、resolveTabConfig —— 展开原始配置
|
// 八、resolveTabConfig — 加载时将 RawConfig 展开为完整配置
|
||||||
// ============================================================
|
// ============================================================
|
||||||
export function resolveTabConfig(raw: TabPageRawConfig): TabPageConfig {
|
export function resolveTabConfig(raw: TabPageRawConfig): TabPageConfig {
|
||||||
const defaultDetailComponent = DetailPanel
|
// 展开 ScanBox 字段
|
||||||
|
const scanBoxFields: Record<string, any>[] = []
|
||||||
|
for (const key of raw.scanBoxFieldKeys) {
|
||||||
|
const def = FIELD_DICT[key]
|
||||||
|
if (!def || !def.scanBox) continue
|
||||||
|
scanBoxFields.push({
|
||||||
|
label: def.label,
|
||||||
|
value: def.key,
|
||||||
|
type: def.scanBox.type,
|
||||||
|
options: def.scanBox.options ? [...def.scanBox.options] : undefined,
|
||||||
|
group: def.scanBox.group,
|
||||||
|
required: (def.scanBox as any).required
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 展开表格列
|
||||||
|
const columns: Record<string, any>[] = []
|
||||||
|
for (const key of raw.tableColumnKeys) {
|
||||||
|
const def = FIELD_DICT[key]
|
||||||
|
if (!def || !def.table) continue
|
||||||
|
columns.push({
|
||||||
|
prop: def.key,
|
||||||
|
label: def.label,
|
||||||
|
...def.table
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 展开列插槽
|
||||||
|
const columnSlots: Record<string, ColumnSlotConfig> = {}
|
||||||
|
for (const key of raw.tableColumnKeys) {
|
||||||
|
const def = FIELD_DICT[key]
|
||||||
|
if (!def || !def.slot) continue
|
||||||
|
columnSlots[def.key] = { ...def.slot }
|
||||||
|
}
|
||||||
|
|
||||||
|
// 展开明细面板配置
|
||||||
|
const detailConfig: DetailSectionConfig[] = raw.detailSections.map((sec) => ({
|
||||||
|
title: sec.title,
|
||||||
|
columnCount: sec.columnCount,
|
||||||
|
fields: sec.fieldKeys
|
||||||
|
.map((key): DetailFieldConfig | null => {
|
||||||
|
const def = FIELD_DICT[key]
|
||||||
|
if (!def) return null
|
||||||
|
return {
|
||||||
|
key: def.key,
|
||||||
|
label: def.detailLabel ?? def.label,
|
||||||
|
translateField: def.slot?.translateField,
|
||||||
|
tagResolver: def.slot?.tagResolver,
|
||||||
|
tagType: def.slot?.tagType,
|
||||||
|
renderType: def.slot?.type === 'tag' ? 'tag' : 'text'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter((f): f is DetailFieldConfig => f !== null)
|
||||||
|
}))
|
||||||
|
|
||||||
|
// 展开明细标签页(解析 componentKey → Component)
|
||||||
const detailTabs: DetailTabConfig[] = raw.detailTabs
|
const detailTabs: DetailTabConfig[] = raw.detailTabs
|
||||||
? raw.detailTabs.map((tab) => ({
|
? raw.detailTabs.map((tab) => ({
|
||||||
name: tab.name,
|
name: tab.name,
|
||||||
label: tab.label,
|
label: tab.label,
|
||||||
componentKey: tab.componentKey,
|
componentKey: tab.componentKey,
|
||||||
component:
|
component: COMPONENT_REGISTRY[tab.componentKey]
|
||||||
tab.componentKey === 'LogPanel' ? LogPanel : defaultDetailComponent
|
|
||||||
}))
|
}))
|
||||||
: [
|
: [{ name: 'detail', label: '明细', componentKey: 'DetailPanel', component: COMPONENT_REGISTRY['DetailPanel'] }]
|
||||||
{
|
|
||||||
name: 'detail',
|
|
||||||
label: '明细',
|
|
||||||
componentKey: 'DetailPanel',
|
|
||||||
component: defaultDetailComponent
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: raw.name,
|
name: raw.name,
|
||||||
label: raw.label,
|
label: raw.label,
|
||||||
scanBoxCacheKey: raw.scanBoxCacheKey,
|
scanBoxCacheKey: raw.scanBoxCacheKey,
|
||||||
scanBoxFields: raw.scanBoxFields,
|
scanBoxFields,
|
||||||
upperTable: {
|
upperTable: {
|
||||||
title: raw.tableTitle,
|
title: raw.upperTableDefaults.title,
|
||||||
columns: raw.tableColumns
|
enableColumnConfig: raw.upperTableDefaults.enableColumnConfig ?? true,
|
||||||
|
showIndex: raw.upperTableDefaults.showIndex ?? true,
|
||||||
|
showSelection: raw.upperTableDefaults.showSelection ?? true,
|
||||||
|
emptyText: raw.upperTableDefaults.emptyText ?? '暂无数据',
|
||||||
|
columns
|
||||||
},
|
},
|
||||||
columnSlots: raw.columnSlots ?? {},
|
columnSlots,
|
||||||
detailConfig: raw.detailSections,
|
detailConfig,
|
||||||
detailTabs
|
detailTabs,
|
||||||
|
api: raw.api,
|
||||||
|
operationButtons: raw.operationButtons
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// 八、标签页注册表 — 在这里定义你的页面标签页
|
// 九、buildWhereConditions — 将 ScanBox 条件转为 API where 参数
|
||||||
// ============================================================
|
// ============================================================
|
||||||
|
export function buildWhereConditions(rawConditions: Record<string, any>): Record<string, any> {
|
||||||
|
const where: Record<string, any> = {}
|
||||||
|
for (const [key, cond] of Object.entries(rawConditions || {})) {
|
||||||
|
let value: any = undefined
|
||||||
|
if (cond && typeof cond === 'object' && 'operator' in cond) {
|
||||||
|
value = (cond as any).value
|
||||||
|
} else if (cond !== undefined && cond !== null && cond !== '') {
|
||||||
|
value = Array.isArray(cond) ? cond[0] ?? '' : cond
|
||||||
|
}
|
||||||
|
if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const def = FIELD_DICT[key]
|
||||||
|
if (def?.filterParamMap) {
|
||||||
|
const mapped = def.filterParamMap[String(value)]
|
||||||
|
if (mapped !== undefined) {
|
||||||
|
where[key] = mapped
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
where[key] = value
|
||||||
|
}
|
||||||
|
return where
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// 十、工具栏按钮系统
|
||||||
|
// ============================================================
|
||||||
|
// 按钮分为三类:
|
||||||
|
// common — 公共按钮(刷新、导出)
|
||||||
|
// function — 功能按钮(打开表单/确认窗口)
|
||||||
|
// basic — 基础操作(字段设置、隐藏详情)
|
||||||
|
|
||||||
|
export interface ToolbarButtonConfig {
|
||||||
|
key: string
|
||||||
|
label: string
|
||||||
|
category: 'common' | 'function' | 'basic'
|
||||||
|
size?: '' | 'default' | 'small' | 'large'
|
||||||
|
type?: '' | 'primary' | 'success' | 'warning' | 'info' | 'danger'
|
||||||
|
plain?: boolean
|
||||||
|
loadingKey?: string
|
||||||
|
disabledKey?: string
|
||||||
|
action: string
|
||||||
|
dynamicLabelKey?: string
|
||||||
|
onlyForTabs?: string[]
|
||||||
|
buttonType?: 'default' | 'dropdown'
|
||||||
|
dropdownOptions?: Array<{ label: string; action: string; divided?: boolean }>
|
||||||
|
formKey?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const TOOLBAR_BUTTONS: Record<string, ToolbarButtonConfig> = {
|
||||||
|
// ===== 公共按钮 =====
|
||||||
|
refresh: {
|
||||||
|
key: 'refresh',
|
||||||
|
label: '刷新',
|
||||||
|
category: 'common',
|
||||||
|
type: 'primary',
|
||||||
|
size: 'small',
|
||||||
|
loadingKey: 'loading',
|
||||||
|
action: 'loadData'
|
||||||
|
},
|
||||||
|
export: {
|
||||||
|
key: 'export',
|
||||||
|
label: '导出',
|
||||||
|
category: 'common',
|
||||||
|
size: 'small',
|
||||||
|
loadingKey: 'exportLoading',
|
||||||
|
action: 'handleExport',
|
||||||
|
buttonType: 'dropdown',
|
||||||
|
dropdownOptions: [
|
||||||
|
{ label: '不含明细', action: 'handleExport' },
|
||||||
|
{ label: '含明细', action: 'handleExportItem', divided: true }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
// ===== 基础操作 =====
|
||||||
|
columnConfig: {
|
||||||
|
key: 'columnConfig',
|
||||||
|
label: '字段设置',
|
||||||
|
category: 'basic',
|
||||||
|
size: 'small',
|
||||||
|
action: 'openColumnConfigPanel'
|
||||||
|
},
|
||||||
|
toggleDetail: {
|
||||||
|
key: 'toggleDetail',
|
||||||
|
label: '显示详情',
|
||||||
|
category: 'basic',
|
||||||
|
dynamicLabelKey: 'detailToggleLabel',
|
||||||
|
size: 'small',
|
||||||
|
action: 'toggleDetailVisible'
|
||||||
|
}
|
||||||
|
// ★ 在此添加功能按钮(如批量操作)★
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 按标签页名称获取工具栏按钮列表 */
|
||||||
|
export function getTabToolbarButtons(tabName: string): ToolbarButtonConfig[] {
|
||||||
|
return Object.values(TOOLBAR_BUTTONS).filter((btn) => {
|
||||||
|
if (btn.onlyForTabs && !btn.onlyForTabs.includes(tabName)) return false
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// 十一、批量操作配置(可选,接入 BatchOperationForm 时使用)
|
||||||
|
// ============================================================
|
||||||
|
export interface BatchOperationConfig {
|
||||||
|
action: string
|
||||||
|
title: string
|
||||||
|
confirmText: string
|
||||||
|
confirmType?: 'warning' | 'error' | 'info' | 'success'
|
||||||
|
confirmButtonText: string
|
||||||
|
successText: string
|
||||||
|
failText: string
|
||||||
|
apiMethod: (...args: any[]) => Promise<any>
|
||||||
|
payloadKey?: string
|
||||||
|
idField?: string | string[]
|
||||||
|
payloadBuilder?: (rows: Record<string, any>[]) => Record<string, any>
|
||||||
|
useProgress?: boolean
|
||||||
|
progressApiMethod?: (...args: any[]) => Promise<any>
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ★ 在此配置批量操作 */
|
||||||
|
export const BATCH_OPERATION_CONFIGS: Record<string, BatchOperationConfig> = {
|
||||||
|
// batchExample: {
|
||||||
|
// action: 'batchExample',
|
||||||
|
// title: '批量操作示例',
|
||||||
|
// confirmText: '确定对选中的 {count} 项执行操作吗?',
|
||||||
|
// confirmType: 'warning',
|
||||||
|
// confirmButtonText: '确认操作',
|
||||||
|
// successText: '批量操作成功',
|
||||||
|
// failText: '批量操作失败',
|
||||||
|
// apiMethod: yourBatchApi,
|
||||||
|
// payloadKey: 'ids',
|
||||||
|
// idField: 'id'
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// 十二、标签页注册表 — 在此定义你的页面标签页
|
||||||
|
// ============================================================
|
||||||
export const tabPages: TabPageRawConfig[] = [
|
export const tabPages: TabPageRawConfig[] = [
|
||||||
// ===== 示例标签页一 =====
|
// ===== 示例标签页一 =====
|
||||||
{
|
{
|
||||||
name: 'tab1',
|
name: 'tab1',
|
||||||
label: '标签页一',
|
label: '标签页一',
|
||||||
scanBoxCacheKey: 'template-tab1',
|
scanBoxCacheKey: 'template-tab1',
|
||||||
scanBoxFields: [
|
scanBoxFieldKeys: ['code', 'type', 'status', 'creator', 'create_time'],
|
||||||
{ label: '编号', value: 'code', type: 'text', group: '基础信息' },
|
tableColumnKeys: ['code', 'name', 'type', 'status', 'count', 'amount', 'creator', 'create_time', 'operation'],
|
||||||
{
|
upperTableDefaults: {
|
||||||
label: '状态',
|
title: '示例列表一',
|
||||||
value: 'status',
|
showSelection: true
|
||||||
type: 'select',
|
|
||||||
group: '基础信息',
|
|
||||||
options: [
|
|
||||||
{ label: '待处理', value: '待处理' },
|
|
||||||
{ label: '处理中', value: '处理中' },
|
|
||||||
{ label: '已完成', value: '已完成' }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '类型',
|
|
||||||
value: 'type',
|
|
||||||
type: 'select',
|
|
||||||
group: '基础信息',
|
|
||||||
options: [
|
|
||||||
{ label: '类型A', value: '类型A' },
|
|
||||||
{ label: '类型B', value: '类型B' },
|
|
||||||
{ label: '类型C', value: '类型C' }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{ label: '创建人', value: 'creator', type: 'text', group: '基础信息' },
|
|
||||||
{
|
|
||||||
label: '创建时间',
|
|
||||||
value: 'create_time',
|
|
||||||
type: 'daterange',
|
|
||||||
group: '时间范围'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
tableColumns: [
|
|
||||||
{ prop: 'code', label: '编号', minWidth: 160, fixed: 'left', showOverflowTooltip: true },
|
|
||||||
{ prop: 'name', label: '名称', minWidth: 150, showOverflowTooltip: true },
|
|
||||||
{ prop: 'type', label: '类型', minWidth: 100, align: 'center' },
|
|
||||||
{
|
|
||||||
prop: 'status',
|
|
||||||
label: '状态',
|
|
||||||
minWidth: 100,
|
|
||||||
align: 'center'
|
|
||||||
},
|
|
||||||
{ prop: 'count', label: '数量', minWidth: 80, align: 'center', sortable: true },
|
|
||||||
{ prop: 'amount', label: '金额(元)', minWidth: 110, align: 'center', sortable: true },
|
|
||||||
{ prop: 'creator', label: '创建人', minWidth: 100 },
|
|
||||||
{ prop: 'create_time', label: '创建时间', minWidth: 170, sortable: true }
|
|
||||||
],
|
|
||||||
tableTitle: '示例列表一',
|
|
||||||
columnSlots: {
|
|
||||||
type: { type: 'tag', tagType: 'info' },
|
|
||||||
status: {
|
|
||||||
type: 'tag',
|
|
||||||
tagType: { '待处理': 'warning', '处理中': '', '已完成': 'success' }
|
|
||||||
},
|
|
||||||
create_time: { type: 'text', format: 'datetime' }
|
|
||||||
},
|
},
|
||||||
|
detailTabs: [
|
||||||
|
{ name: 'detail', label: '明细', componentKey: 'DetailPanel' },
|
||||||
|
{ name: 'log', label: '操作日志', componentKey: 'LogPanel' }
|
||||||
|
],
|
||||||
detailSections: [
|
detailSections: [
|
||||||
{
|
{
|
||||||
title: '基础信息',
|
title: '基础信息',
|
||||||
columnCount: 3,
|
columnCount: 3,
|
||||||
fields: [
|
fieldKeys: ['code', 'name', 'type', 'status', 'count', 'amount', 'creator']
|
||||||
{ key: 'code', label: '编号' },
|
|
||||||
{ key: 'name', label: '名称' },
|
|
||||||
{ key: 'type', label: '类型', renderType: 'tag', tagType: 'info' },
|
|
||||||
{ key: 'status', label: '状态', renderType: 'tag', tagType: { '待处理': 'warning', '处理中': '', '已完成': 'success' } },
|
|
||||||
{ key: 'count', label: '数量' },
|
|
||||||
{ key: 'amount', label: '金额(元)' },
|
|
||||||
{ key: 'creator', label: '创建人' }
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '时间信息',
|
title: '时间信息',
|
||||||
columnCount: 2,
|
columnCount: 2,
|
||||||
fields: [
|
fieldKeys: ['create_time', 'update_time']
|
||||||
{ key: 'create_time', label: '创建时间' },
|
|
||||||
{ key: 'update_time', label: '更新时间' }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
detailTabs: [
|
/** ★ 接入真实接口时取消注释 */
|
||||||
{ name: 'detail', label: '明细', componentKey: 'DetailPanel' },
|
// api: {
|
||||||
{ name: 'log', label: '操作日志', componentKey: 'LogPanel' }
|
// list: yourListApi,
|
||||||
|
// detail: { source: 'list' },
|
||||||
|
// parseListResponse(res) {
|
||||||
|
// return { list: res.data?.list ?? [], total: res.data?.pagination?.total ?? 0 }
|
||||||
|
// },
|
||||||
|
// buildListParams({ pagination, conditions, sort }) {
|
||||||
|
// return {
|
||||||
|
// page: pagination.page,
|
||||||
|
// pageSize: pagination.pageSize,
|
||||||
|
// where: buildWhereConditions(conditions),
|
||||||
|
// ...(sort?.prop ? { sortField: sort.prop, sortOrder: sort.order === 'ascending' ? 'ASC' : 'DESC' } : {})
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
operationButtons: [
|
||||||
|
{
|
||||||
|
key: 'viewDetail',
|
||||||
|
label: '查看详情',
|
||||||
|
actionType: 'action',
|
||||||
|
type: 'primary'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'edit',
|
||||||
|
label: '编辑',
|
||||||
|
actionType: 'action',
|
||||||
|
type: 'warning'
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -271,48 +687,37 @@ export const tabPages: TabPageRawConfig[] = [
|
|||||||
name: 'tab2',
|
name: 'tab2',
|
||||||
label: '标签页二',
|
label: '标签页二',
|
||||||
scanBoxCacheKey: 'template-tab2',
|
scanBoxCacheKey: 'template-tab2',
|
||||||
scanBoxFields: [
|
scanBoxFieldKeys: ['code', 'status', 'create_time'],
|
||||||
{ label: '编号', value: 'code', type: 'text', group: '基础信息' },
|
tableColumnKeys: ['code', 'name', 'status', 'count', 'creator', 'create_time', 'operation'],
|
||||||
{
|
upperTableDefaults: {
|
||||||
label: '状态',
|
title: '示例列表二',
|
||||||
value: 'status',
|
showSelection: true
|
||||||
type: 'select',
|
|
||||||
group: '基础信息',
|
|
||||||
options: [
|
|
||||||
{ label: '待处理', value: '待处理' },
|
|
||||||
{ label: '处理中', value: '处理中' },
|
|
||||||
{ label: '已完成', value: '已完成' }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
tableColumns: [
|
|
||||||
{ prop: 'code', label: '编号', minWidth: 160, fixed: 'left' },
|
|
||||||
{ prop: 'name', label: '名称', minWidth: 150 },
|
|
||||||
{ prop: 'status', label: '状态', minWidth: 100, align: 'center' },
|
|
||||||
{ prop: 'count', label: '数量', minWidth: 80, align: 'center', sortable: true },
|
|
||||||
{ prop: 'creator', label: '创建人', minWidth: 100 },
|
|
||||||
{ prop: 'create_time', label: '创建时间', minWidth: 170, sortable: true }
|
|
||||||
],
|
|
||||||
tableTitle: '示例列表二',
|
|
||||||
columnSlots: {
|
|
||||||
status: {
|
|
||||||
type: 'tag',
|
|
||||||
tagType: { '待处理': 'warning', '处理中': '', '已完成': 'success' }
|
|
||||||
},
|
|
||||||
create_time: { type: 'text', format: 'datetime' }
|
|
||||||
},
|
},
|
||||||
detailSections: [
|
detailSections: [
|
||||||
{
|
{
|
||||||
title: '基础信息',
|
title: '基础信息',
|
||||||
columnCount: 3,
|
columnCount: 3,
|
||||||
fields: [
|
fieldKeys: ['code', 'name', 'status', 'count', 'creator']
|
||||||
{ key: 'code', label: '编号' },
|
},
|
||||||
{ key: 'name', label: '名称' },
|
{
|
||||||
{ key: 'status', label: '状态', renderType: 'tag', tagType: { '待处理': 'warning', '处理中': '', '已完成': 'success' } },
|
title: '时间信息',
|
||||||
{ key: 'count', label: '数量' },
|
columnCount: 2,
|
||||||
{ key: 'creator', label: '创建人' }
|
fieldKeys: ['create_time', 'update_time']
|
||||||
]
|
}
|
||||||
|
],
|
||||||
|
operationButtons: [
|
||||||
|
{
|
||||||
|
key: 'viewDetail',
|
||||||
|
label: '查看详情',
|
||||||
|
actionType: 'action',
|
||||||
|
type: 'primary'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// 十三、向后兼容导出
|
||||||
|
// ============================================================
|
||||||
|
export const templateTabs = tabPages.map((t) => ({ name: t.name, label: t.label, scanBoxCacheKey: t.scanBoxCacheKey }))
|
||||||
|
|
||||||
|
|||||||
@ -1,23 +1,25 @@
|
|||||||
<!--
|
<!--
|
||||||
╔══════════════════════════════════════════════════════════════╗
|
╔══════════════════════════════════════════════════════════════╗
|
||||||
║ 【页面模板】— 开箱即用的管理页面骨架 ║
|
║ 【页面模板 v2】— 基于 waveOrder2 架构设计 ║
|
||||||
╚══════════════════════════════════════════════════════════════╝
|
╚══════════════════════════════════════════════════════════════╝
|
||||||
|
|
||||||
===== 快速复制使用 =====
|
===== 快速复制使用 =====
|
||||||
1. 复制整个 views/mode/ 文件夹 → 重命名为你的页面名(如 views/order/myPage/)
|
1. 复制整个 views/mode/ 文件夹 → 重命名为你的页面名(如 views/order/myPage/)
|
||||||
2. 修改 defineOptions name(如 'MyPage')
|
2. 修改 defineOptions name(如 'MyPage')
|
||||||
3. 编辑 config/template-config.ts 中的 tabPages(列、筛选)
|
3. 编辑 config/template-config.ts:
|
||||||
4. 在 index.vue 的 loadData() 中接入真实接口
|
a. 在 FIELD_DICT 中添加页面字段
|
||||||
5. 在 router/map.ts 中添加路由
|
b. 在 tabPages 中配置标签页(引用 FIELD_DICT 的 key)
|
||||||
|
c. 在 TabPageApiConfig 中接入真实接口
|
||||||
|
4. 在 router/map.ts 中添加路由
|
||||||
|
|
||||||
===== 页面结构 =====
|
===== 页面结构 =====
|
||||||
┌─────────────────────────────────────────────────────────┐
|
┌─────────────────────────────────────────────────────────┐
|
||||||
│ TabArea(多标签页切换,可关闭) │
|
│ TabArea(多标签页切换,可关闭) │
|
||||||
├──────────┬──────────────────────────────────────────────┤
|
├──────────┬──────────────────────────────────────────────┤
|
||||||
│ ScanBox │ Toolbar(按钮组) │
|
│ ScanBox │ OrderToolbarButtonGroup(工具栏按钮组) │
|
||||||
│ 筛选面板 │ ┌──────────────────────────────────────────┐│
|
│ 筛选面板 │ ┌──────────────────────────────────────────┐│
|
||||||
│ │ │ UpperTable(表格) ││
|
│ │ │ UpperTable(表格) ││
|
||||||
│ │ │ ││
|
│ │ │ - OperationCellRenderer(操作列) ││
|
||||||
│ │ ├──────────────────────────────────────────┤│
|
│ │ ├──────────────────────────────────────────┤│
|
||||||
│ │ │ 分隔条(可拖拽) ││
|
│ │ │ 分隔条(可拖拽) ││
|
||||||
│ │ ├──────────────────────────────────────────┤│
|
│ │ ├──────────────────────────────────────────┤│
|
||||||
@ -59,20 +61,17 @@
|
|||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
<transition name="tab-fade" mode="out-in">
|
<transition name="tab-fade" mode="out-in">
|
||||||
<div :key="activeTabName" class="tab-content-inner">
|
<div :key="activeTabName" class="tab-content-inner">
|
||||||
<!-- 工具栏 -->
|
<!-- 工具栏按钮组 -->
|
||||||
<div class="toolbar">
|
<div class="toolbar">
|
||||||
<div class="toolbar-left">
|
<div class="toolbar-left">
|
||||||
<el-button size="small" @click="loadData">
|
<OrderToolbarButtonGroup
|
||||||
<el-icon><Refresh /></el-icon>
|
:buttons="currentToolbarButtons"
|
||||||
刷新
|
:resolve-disabled="resolveButtonDisabled"
|
||||||
</el-button>
|
:resolve-loading="resolveButtonLoading"
|
||||||
<!-- ★ 在这里添加你的工具栏按钮 ★ -->
|
:resolve-label="resolveButtonLabel"
|
||||||
<!-- <el-button size="small" type="primary" @click="handleYourAction">操作按钮</el-button> -->
|
:layout-key="toolbarLayoutKey"
|
||||||
</div>
|
@action="handleToolbarButtonClick"
|
||||||
<div class="toolbar-right">
|
/>
|
||||||
<el-button size="small" @click="detailVisible = !detailVisible">
|
|
||||||
{{ detailVisible ? '隐藏详情' : '显示详情' }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -84,14 +83,16 @@
|
|||||||
ref="upperTableRef"
|
ref="upperTableRef"
|
||||||
:title="currentTabConfig?.upperTable.title ?? '列表'"
|
:title="currentTabConfig?.upperTable.title ?? '列表'"
|
||||||
default-align="center"
|
default-align="center"
|
||||||
|
:enable-column-config="currentTabConfig?.upperTable.enableColumnConfig ?? true"
|
||||||
|
:column-config-schema-version="1"
|
||||||
:table-id="`template-table-${activeTabName}`"
|
:table-id="`template-table-${activeTabName}`"
|
||||||
:data="listData"
|
:data="listData"
|
||||||
row-key="id"
|
:row-key="'id'"
|
||||||
:columns="currentColumns"
|
:columns="currentColumns"
|
||||||
table-size="small"
|
table-size="small"
|
||||||
:pagination="pagination"
|
:pagination="pagination"
|
||||||
:show-index="true"
|
:show-index="currentTabConfig?.upperTable.showIndex ?? true"
|
||||||
:show-selection="true"
|
:show-selection="currentTabConfig?.upperTable.showSelection ?? true"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:query-time="queryTime"
|
:query-time="queryTime"
|
||||||
@current-change="handleRowClick"
|
@current-change="handleRowClick"
|
||||||
@ -102,20 +103,29 @@
|
|||||||
@sort-change="handleSortChange"
|
@sort-change="handleSortChange"
|
||||||
@selection-change="handleSelectionChange"
|
@selection-change="handleSelectionChange"
|
||||||
>
|
>
|
||||||
<!-- 动态列插槽:根据 columnSlots 配置自动渲染 tag/格式化等 -->
|
<!-- 动态列插槽:根据 columnSlots 配置自动渲染 -->
|
||||||
<template
|
<template
|
||||||
v-for="(slotConfig, colProp) in currentColumnSlots"
|
v-for="(slotConfig, colProp) in currentColumnSlots"
|
||||||
:key="colProp"
|
:key="`columnSlots-${colProp}`"
|
||||||
#[`column-${colProp}`]="{ row }"
|
#[`column-${colProp}`]="{ row }"
|
||||||
>
|
>
|
||||||
|
<!-- 操作列:渲染操作按钮 -->
|
||||||
|
<OperationCellRenderer
|
||||||
|
v-if="slotConfig.type === 'operation'"
|
||||||
|
:buttons="currentTabConfig?.operationButtons"
|
||||||
|
:row="row"
|
||||||
|
@operation-action="handleOperationAction"
|
||||||
|
/>
|
||||||
|
<!-- 其他列:标签/文本渲染 -->
|
||||||
<ColumnCellRenderer
|
<ColumnCellRenderer
|
||||||
|
v-else
|
||||||
:config="slotConfig"
|
:config="slotConfig"
|
||||||
:value="row[colProp]"
|
:value="row[colProp]"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #empty>
|
<template #empty>
|
||||||
<div class="empty-tip">暂无数据</div>
|
<div class="empty-tip">{{ currentTabConfig?.upperTable.emptyText ?? '暂无数据' }}</div>
|
||||||
</template>
|
</template>
|
||||||
</UpperTable>
|
</UpperTable>
|
||||||
</div>
|
</div>
|
||||||
@ -145,6 +155,7 @@
|
|||||||
:is="activeDetailTabComponent"
|
:is="activeDetailTabComponent"
|
||||||
:row="selectedDetail"
|
:row="selectedDetail"
|
||||||
:detail-config="currentDetailConfig"
|
:detail-config="currentDetailConfig"
|
||||||
|
:api-method="currentDetailTabApiMethod"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -162,6 +173,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- ===== 功能按钮表单(pages/ 目录下的组件) ===== -->
|
||||||
|
<!-- ★ 在此添加表单弹窗组件,如:
|
||||||
|
<YourFormDialog
|
||||||
|
v-model:visible="yourFormVisible"
|
||||||
|
@success="handleFormSuccess"
|
||||||
|
/>
|
||||||
|
-->
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -172,22 +191,24 @@
|
|||||||
defineOptions({ name: 'PageTemplate' })
|
defineOptions({ name: 'PageTemplate' })
|
||||||
|
|
||||||
import { ref, computed, onMounted, reactive } from 'vue'
|
import { ref, computed, onMounted, reactive } from 'vue'
|
||||||
import { Refresh } from '@element-plus/icons-vue'
|
import { ElMessage } from 'element-plus'
|
||||||
import { useSettingsStore } from '@/stores/modules/settings'
|
import { useSettingsStore } from '@/stores/modules/settings'
|
||||||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||||||
import ScanBox from '@/components/ScanBox/index.vue'
|
import ScanBox from '@/components/ScanBox/index.vue'
|
||||||
import UpperTable from '@/components/UpperTable/index.vue'
|
import UpperTable from '@/components/UpperTable/index.vue'
|
||||||
import TabArea from './components/TabArea.vue'
|
import TabArea from './components/TabArea.vue'
|
||||||
import ColumnCellRenderer from './components/ColumnCellRenderer.vue'
|
import ColumnCellRenderer from './components/ColumnCellRenderer.vue'
|
||||||
|
import OperationCellRenderer from './components/OperationCellRenderer.vue'
|
||||||
|
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
|
||||||
|
import type { ToolbarButtonConfig as OrderToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
||||||
import {
|
import {
|
||||||
PAGE_CONFIG,
|
PAGE_CONFIG,
|
||||||
tabPages,
|
tabPages,
|
||||||
resolveTabConfig,
|
resolveTabConfig,
|
||||||
|
getTabToolbarButtons,
|
||||||
type TabPageConfig,
|
type TabPageConfig,
|
||||||
type ColumnConfig,
|
type DetailTabConfig,
|
||||||
type ColumnSlotConfig,
|
type ToolbarButtonConfig,
|
||||||
type DetailSectionConfig,
|
|
||||||
type DetailTabConfig
|
|
||||||
} from './config/template-config'
|
} from './config/template-config'
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
@ -225,17 +246,17 @@ const currentScanBoxFields = computed(
|
|||||||
)
|
)
|
||||||
|
|
||||||
/** 当前表格列 */
|
/** 当前表格列 */
|
||||||
const currentColumns = computed<ColumnConfig[]>(
|
const currentColumns = computed(
|
||||||
() => currentTabConfig.value?.upperTable.columns ?? []
|
() => currentTabConfig.value?.upperTable.columns ?? []
|
||||||
)
|
)
|
||||||
|
|
||||||
/** 当前列插槽配置 */
|
/** 当前列插槽配置 */
|
||||||
const currentColumnSlots = computed<Record<string, ColumnSlotConfig>>(
|
const currentColumnSlots = computed(
|
||||||
() => currentTabConfig.value?.columnSlots ?? {}
|
() => currentTabConfig.value?.columnSlots ?? {}
|
||||||
)
|
)
|
||||||
|
|
||||||
/** 当前明细面板配置 */
|
/** 当前明细面板配置 */
|
||||||
const currentDetailConfig = computed<DetailSectionConfig[]>(
|
const currentDetailConfig = computed(
|
||||||
() => currentTabConfig.value?.detailConfig ?? []
|
() => currentTabConfig.value?.detailConfig ?? []
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -252,6 +273,128 @@ const activeDetailTabComponent = computed(() => {
|
|||||||
return tab?.component ?? null
|
return tab?.component ?? null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** 当前激活明细标签页对应的 API 方法 */
|
||||||
|
const currentDetailTabApiMethod = computed(() => {
|
||||||
|
const cfg = currentTabConfig.value
|
||||||
|
if (!cfg?.api) return undefined
|
||||||
|
const tab = currentDetailTabs.value.find((t) => t.name === activeDetailTab.value)
|
||||||
|
if (!tab) return undefined
|
||||||
|
|
||||||
|
let componentCfg: unknown
|
||||||
|
switch (tab.componentKey) {
|
||||||
|
case 'DetailPanel':
|
||||||
|
componentCfg = cfg.api.detail
|
||||||
|
break
|
||||||
|
case 'LogPanel':
|
||||||
|
componentCfg = cfg.api.log
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof componentCfg === 'function') {
|
||||||
|
return componentCfg
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
})
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// 工具栏按钮系统
|
||||||
|
// ============================================================
|
||||||
|
|
||||||
|
/** 当前标签页的工具栏按钮列表 */
|
||||||
|
const currentToolbarButtons = computed<OrderToolbarButtonConfig[]>(() => {
|
||||||
|
const btns = getTabToolbarButtons(activeTabName.value)
|
||||||
|
return btns.map((btn: ToolbarButtonConfig) => ({
|
||||||
|
key: btn.key,
|
||||||
|
label: btn.label,
|
||||||
|
size: btn.size,
|
||||||
|
type: btn.type,
|
||||||
|
plain: btn.plain,
|
||||||
|
loadingKey: btn.loadingKey,
|
||||||
|
disabledKey: btn.disabledKey,
|
||||||
|
action: btn.action,
|
||||||
|
dynamicLabelKey: btn.dynamicLabelKey,
|
||||||
|
buttonType: btn.buttonType,
|
||||||
|
dropdownOptions: btn.dropdownOptions
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
|
const buttonDisabledMap = computed<Record<string, boolean>>(() => ({
|
||||||
|
noSelection: selectedRows.value.length === 0
|
||||||
|
}))
|
||||||
|
|
||||||
|
const buttonLoadingMap = computed<Record<string, boolean>>(() => ({
|
||||||
|
loading: loading.value,
|
||||||
|
exportLoading: false
|
||||||
|
}))
|
||||||
|
|
||||||
|
const buttonLabelMap = computed<Record<string, string>>(() => ({
|
||||||
|
detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情'
|
||||||
|
}))
|
||||||
|
|
||||||
|
const toolbarLayoutKey = computed(() =>
|
||||||
|
JSON.stringify({
|
||||||
|
loading: buttonLoadingMap.value,
|
||||||
|
disabled: buttonDisabledMap.value,
|
||||||
|
labels: buttonLabelMap.value
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
function resolveButtonLoading(loadingKey?: string) {
|
||||||
|
if (!loadingKey) return false
|
||||||
|
return Boolean(buttonLoadingMap.value[loadingKey])
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveButtonDisabled(disabledKey?: string) {
|
||||||
|
if (!disabledKey) return false
|
||||||
|
return Boolean(buttonDisabledMap.value[disabledKey])
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveButtonLabel(defaultLabel: string, dynamicLabelKey?: string) {
|
||||||
|
if (!dynamicLabelKey) return defaultLabel
|
||||||
|
return buttonLabelMap.value[dynamicLabelKey] || defaultLabel
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// 工具栏动作分发
|
||||||
|
// ============================================================
|
||||||
|
const toolbarActionMap: Record<string, () => void> = {
|
||||||
|
loadData: () => { void loadData() },
|
||||||
|
openColumnConfigPanel: () => { upperTableRef.value?.openColumnConfig?.() },
|
||||||
|
toggleDetailVisible: () => { detailVisible.value = !detailVisible.value },
|
||||||
|
handleExport: () => { console.log('[PageTemplate] 导出(不含明细)', activeTabName.value) },
|
||||||
|
handleExportItem: () => { console.log('[PageTemplate] 导出(含明细)', activeTabName.value) }
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleToolbarButtonClick(action: string) {
|
||||||
|
const handler = toolbarActionMap[action]
|
||||||
|
if (handler) {
|
||||||
|
handler()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// ★ 在此添加功能按钮分发
|
||||||
|
console.warn('[PageTemplate] 未处理的工具栏动作:', action)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// 操作列按钮事件处理
|
||||||
|
// ============================================================
|
||||||
|
async function handleOperationAction(key: string, row: Record<string, any>) {
|
||||||
|
// ★ 在此添加操作列按钮回调
|
||||||
|
console.log('[PageTemplate] 操作列按钮:', key, row)
|
||||||
|
switch (key) {
|
||||||
|
case 'viewDetail':
|
||||||
|
// 已经通过行点击处理
|
||||||
|
break
|
||||||
|
case 'edit':
|
||||||
|
ElMessage.info(`编辑「${row.name ?? row.code ?? row.id}」`)
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
console.warn('[PageTemplate] 未处理的操作按钮:', key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// ★★★ 第二步:接入真实接口 ★★★
|
// ★★★ 第二步:接入真实接口 ★★★
|
||||||
// ============================================================
|
// ============================================================
|
||||||
@ -267,24 +410,46 @@ const pagination = reactive({
|
|||||||
|
|
||||||
const currentSort = reactive({ prop: '', order: '' })
|
const currentSort = reactive({ prop: '', order: '' })
|
||||||
|
|
||||||
/** 加载列表数据(在此接入真实接口) */
|
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
|
const cfg = currentTabConfig.value
|
||||||
|
if (!cfg) return
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const startTime = performance.now()
|
const startTime = performance.now()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// ★ TODO: 替换为真实接口调用
|
if (cfg.api) {
|
||||||
// const res = await yourApi.list({
|
// 使用真实接口
|
||||||
// page: pagination.currentPage,
|
const conditions = scanBoxRef.value?.getConditions?.() || {}
|
||||||
// pageSize: pagination.pageSize
|
const params = cfg.api.buildListParams
|
||||||
// })
|
? cfg.api.buildListParams({
|
||||||
// listData.value = res.data.list
|
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
|
||||||
// pagination.total = res.data.total
|
conditions,
|
||||||
|
sort: currentSort.prop ? { prop: currentSort.prop, order: currentSort.order } : undefined
|
||||||
|
})
|
||||||
|
: {
|
||||||
|
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
|
||||||
|
where: conditions
|
||||||
|
}
|
||||||
|
|
||||||
listData.value = []
|
const res = await cfg.api.list(params)
|
||||||
pagination.total = 0
|
if (res && (res.code === 1 || res.code === 200)) {
|
||||||
|
const parsed = cfg.api.parseListResponse
|
||||||
|
? cfg.api.parseListResponse(res)
|
||||||
|
: { list: res.data?.list ?? res.list ?? [], total: res.data?.pagination?.total ?? res.total ?? 0 }
|
||||||
|
listData.value = parsed.list
|
||||||
|
pagination.total = parsed.total
|
||||||
|
} else {
|
||||||
|
throw new Error(res?.message || '接口返回异常')
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// ★ 未配置 API 时使用模拟数据(替换为真实接口后删除)
|
||||||
|
console.log('[PageTemplate] 未配置 API,使用空数据。请在 tabPages 中配置 api 字段。')
|
||||||
|
listData.value = []
|
||||||
|
pagination.total = 0
|
||||||
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error('[PageTemplate] 加载列表失败:', e)
|
console.error('[PageTemplate] 加载列表失败:', e)
|
||||||
|
ElMessage.error(e?.message || '获取列表数据失败')
|
||||||
listData.value = []
|
listData.value = []
|
||||||
pagination.total = 0
|
pagination.total = 0
|
||||||
} finally {
|
} finally {
|
||||||
@ -349,13 +514,27 @@ const selectedDetail = ref<Record<string, any> | null>(null)
|
|||||||
const activeDetailTab = ref('detail')
|
const activeDetailTab = ref('detail')
|
||||||
|
|
||||||
const handleRowClick = async (row: Record<string, any>) => {
|
const handleRowClick = async (row: Record<string, any>) => {
|
||||||
|
const cfg = currentTabConfig.value
|
||||||
|
if (!cfg) return
|
||||||
selectedRow.value = row
|
selectedRow.value = row
|
||||||
|
|
||||||
// ★ TODO: 如需调接口获取明细,在这里添加
|
// 根据 DetailPanel 的 api 配置决定数据来源
|
||||||
// const res = await yourApi.detail(row.id)
|
const detailCfg = cfg.api?.detail
|
||||||
// selectedDetail.value = res.data
|
if (typeof detailCfg === 'function') {
|
||||||
|
try {
|
||||||
selectedDetail.value = { ...row }
|
const detailRes = await detailCfg({ id: row.id, code: row.code })
|
||||||
|
if (detailRes && (detailRes.code === 1 || detailRes.code === 200)) {
|
||||||
|
selectedDetail.value = detailRes.data ?? detailRes
|
||||||
|
} else {
|
||||||
|
selectedDetail.value = { ...row }
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
selectedDetail.value = { ...row }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// source='list' 或未配置:直接用行数据
|
||||||
|
selectedDetail.value = { ...row }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
@ -501,209 +680,112 @@ onMounted(() => {
|
|||||||
================================================================ */
|
================================================================ */
|
||||||
.split-stack {
|
.split-stack {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
min-height: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
|
:deep(.el-card__header) {
|
||||||
|
padding: 2px 12px;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.upper-wrapper {
|
.upper-wrapper {
|
||||||
flex: 1;
|
flex: 1 1 62%;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.upper-wrapper :deep(.upper-table-container) {
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upper-wrapper :deep(.table-container) {
|
|
||||||
height: auto !important;
|
|
||||||
flex: 1 1 auto;
|
|
||||||
min-height: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upper-wrapper :deep(.el-table__body-wrapper) {
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pane-resizer {
|
.pane-resizer {
|
||||||
flex: 0 0 6px;
|
|
||||||
min-height: 6px;
|
|
||||||
background: #e4e7ed;
|
|
||||||
cursor: row-resize;
|
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
position: relative;
|
height: 5px;
|
||||||
z-index: 2;
|
cursor: row-resize;
|
||||||
|
background-color: #f0f2f5;
|
||||||
|
border-top: 1px solid #ebeef5;
|
||||||
|
border-bottom: 1px solid #ebeef5;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: #dcdfe6;
|
background-color: #d3d9e3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.lower-level {
|
||||||
|
flex: 1 1 38%;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
:deep(.el-card) {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-selection {
|
||||||
|
flex: 1 1 38%;
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border: 1px solid #ebeef5;
|
||||||
|
border-radius: 4px;
|
||||||
|
|
||||||
|
.empty-tip p {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #909399;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================================
|
/* ================================================================
|
||||||
5. 明细面板
|
5. 明细面板
|
||||||
================================================================ */
|
================================================================ */
|
||||||
.lower-level {
|
.detail-header {
|
||||||
flex: 0 0 38%;
|
flex-shrink: 0;
|
||||||
height: 38%;
|
border-bottom: 1px solid #e8eef7;
|
||||||
display: flex;
|
background: #fff;
|
||||||
flex-direction: column;
|
padding: 0 12px;
|
||||||
border-top: 1px solid #ebeef5;
|
|
||||||
overflow: hidden;
|
|
||||||
background-color: #fff;
|
|
||||||
|
|
||||||
.detail-header {
|
.detail-tab {
|
||||||
background-color: #fafafa;
|
:deep(.el-tabs__header) {
|
||||||
border-bottom: 1px solid #ebeef5;
|
margin-bottom: 0;
|
||||||
padding: 0 12px;
|
}
|
||||||
display: flex;
|
:deep(.el-tabs__nav-wrap::after) {
|
||||||
align-items: center;
|
height: 1px;
|
||||||
justify-content: space-between;
|
|
||||||
gap: 12px;
|
|
||||||
height: 42px;
|
|
||||||
min-height: 42px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
|
|
||||||
.detail-tab {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
margin-bottom: -1px;
|
|
||||||
|
|
||||||
:deep(.el-tabs__header) {
|
|
||||||
margin: 0;
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.el-tabs__nav-wrap::after) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.el-tabs__active-bar) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.el-tabs__item) {
|
|
||||||
height: 40px;
|
|
||||||
line-height: 40px;
|
|
||||||
font-size: 13px;
|
|
||||||
padding: 0 16px;
|
|
||||||
color: #606266;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
border-bottom: none;
|
|
||||||
border-radius: 4px 4px 0 0;
|
|
||||||
transition: color 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.el-tabs__item:hover) {
|
|
||||||
color: var(--el-color-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.el-tabs__item.is-active) {
|
|
||||||
color: var(--el-color-primary);
|
|
||||||
background-color: #fff;
|
|
||||||
border-color: #ebeef5;
|
|
||||||
border-bottom-color: #fff;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail-container {
|
|
||||||
flex: 1;
|
|
||||||
overflow-y: auto;
|
|
||||||
padding: 12px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 未选中行占位 */
|
.detail-container {
|
||||||
.no-selection {
|
flex: 1;
|
||||||
flex: 0 0 38%;
|
overflow: auto;
|
||||||
height: 38%;
|
padding: 12px;
|
||||||
display: flex;
|
background: #fff;
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
border-top: 1px solid #ebeef5;
|
|
||||||
overflow: hidden;
|
|
||||||
background-color: #fff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================================
|
/* ================================================================
|
||||||
6. 通用样式
|
6. 过渡动画
|
||||||
================================================================ */
|
================================================================ */
|
||||||
.empty-tip {
|
|
||||||
text-align: center;
|
|
||||||
font-size: 13px;
|
|
||||||
color: #909399;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 标签页切换过渡 */
|
|
||||||
.tab-fade-enter-active,
|
.tab-fade-enter-active,
|
||||||
.tab-fade-leave-active {
|
.tab-fade-leave-active {
|
||||||
transition: opacity 0.2s ease, transform 0.2s ease;
|
transition: opacity 0.2s ease;
|
||||||
}
|
opacity: 1;
|
||||||
|
|
||||||
.tab-fade-enter-from {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY(8px);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tab-fade-enter-from,
|
||||||
.tab-fade-leave-to {
|
.tab-fade-leave-to {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(-8px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.tab-fade-leave-active {
|
|
||||||
position: absolute;
|
|
||||||
width: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================================
|
/* ================================================================
|
||||||
7. ScanBox 筛选标签样式微调
|
7. 空状态
|
||||||
================================================================ */
|
================================================================ */
|
||||||
.main-container {
|
.empty-tip {
|
||||||
:deep(.scan-box-container .scan-tabs) {
|
font-size: 13px;
|
||||||
flex-shrink: 0;
|
color: #909399;
|
||||||
border-bottom: 1px solid #ebeef5;
|
|
||||||
background: #fafafa;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.scan-box-container .scan-tabs .el-tabs__header) {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.scan-box-container .scan-tabs .el-tabs__nav-wrap::after) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.scan-box-container .scan-tabs .el-tabs__active-bar) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.scan-box-container .scan-tabs .el-tabs__item) {
|
|
||||||
height: 40px;
|
|
||||||
line-height: 40px;
|
|
||||||
font-size: 13px;
|
|
||||||
padding: 0 12px;
|
|
||||||
color: #606266;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
border-bottom: none;
|
|
||||||
border-radius: 4px 4px 0 0;
|
|
||||||
transition: color 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.scan-box-container .scan-tabs .el-tabs__item:hover) {
|
|
||||||
color: var(--el-color-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.scan-box-container .scan-tabs .el-tabs__item.is-active) {
|
|
||||||
color: var(--el-color-primary);
|
|
||||||
background-color: #fff;
|
|
||||||
border-color: #ebeef5;
|
|
||||||
border-bottom-color: #fff;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
107
src/views/mode/pages/ExampleFormDialog.vue
Normal file
107
src/views/mode/pages/ExampleFormDialog.vue
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
<!--
|
||||||
|
ExampleFormDialog — 示例表单弹窗(模板)
|
||||||
|
|
||||||
|
功能按钮对应的表单组件放在 pages/ 目录下。
|
||||||
|
|
||||||
|
使用方式:
|
||||||
|
1. 在 template-config.ts 的 COMPONENT_REGISTRY 中注册
|
||||||
|
2. 在 template-config.ts 的 TOOLBAR_BUTTONS 中添加功能按钮,设置 formKey
|
||||||
|
3. index.vue 中通过工具栏按钮触发打开
|
||||||
|
-->
|
||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
:model-value="visible"
|
||||||
|
title="示例操作"
|
||||||
|
width="500px"
|
||||||
|
align-center
|
||||||
|
destroy-on-close
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
@closed="handleClosed"
|
||||||
|
>
|
||||||
|
<div class="form-body">
|
||||||
|
<el-form ref="formRef" :model="form" label-width="100px" size="small">
|
||||||
|
<el-form-item label="名称" prop="name">
|
||||||
|
<el-input v-model="form.name" placeholder="请输入名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="描述" prop="description">
|
||||||
|
<el-input
|
||||||
|
v-model="form.description"
|
||||||
|
type="textarea"
|
||||||
|
:rows="3"
|
||||||
|
placeholder="请输入描述"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<el-button size="small" @click="handleClosed">取消</el-button>
|
||||||
|
<el-button size="small" type="primary" :loading="submitting" @click="handleSubmit">
|
||||||
|
确认
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { reactive, ref, watch } from 'vue'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
|
||||||
|
defineOptions({ name: 'ExampleFormDialog' })
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
visible: boolean
|
||||||
|
/** 从行数据注入的初始值(由 OperationCellRenderer 的 paramMap 传递) */
|
||||||
|
id?: string | number
|
||||||
|
code?: string
|
||||||
|
name?: string
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'update:visible', v: boolean): void
|
||||||
|
(e: 'success'): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const formRef = ref<any>(null)
|
||||||
|
const submitting = ref(false)
|
||||||
|
|
||||||
|
const form = reactive({
|
||||||
|
name: '',
|
||||||
|
description: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
// 重置表单
|
||||||
|
watch(() => props.visible, (v) => {
|
||||||
|
if (v) {
|
||||||
|
form.name = props.name ?? ''
|
||||||
|
form.description = ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function handleClosed() {
|
||||||
|
emit('update:visible', false)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
submitting.value = true
|
||||||
|
try {
|
||||||
|
// ★ 替换为真实 API 调用
|
||||||
|
// const res = await yourApi.submit({ id: props.id, ...form })
|
||||||
|
await new Promise((r) => setTimeout(r, 500))
|
||||||
|
|
||||||
|
ElMessage.success('操作成功')
|
||||||
|
emit('update:visible', false)
|
||||||
|
emit('success')
|
||||||
|
} catch (e: any) {
|
||||||
|
ElMessage.error(e?.message || '操作失败')
|
||||||
|
} finally {
|
||||||
|
submitting.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.form-body {
|
||||||
|
padding: 12px 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -444,7 +444,8 @@ import type { SelectProductItem } from './SelectProductDialog.vue'
|
|||||||
import * as indexApi from '@/api/index/index'
|
import * as indexApi from '@/api/index/index'
|
||||||
import { settingPlatformList } from '@/api/setting.platform/platform'
|
import { settingPlatformList } from '@/api/setting.platform/platform'
|
||||||
import {
|
import {
|
||||||
lookupProductByKeyword
|
lookupAndExpandProductByKeyword,
|
||||||
|
type OrderSelectedProductItem
|
||||||
} from '../utils/stock-picker-helpers'
|
} from '../utils/stock-picker-helpers'
|
||||||
import { orderList } from '@/api/order.index/orderindex'
|
import { orderList } from '@/api/order.index/orderindex'
|
||||||
import {
|
import {
|
||||||
@ -839,18 +840,8 @@ function collectGroupOrderItems(rows: ImportPreviewRow[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function lookupStockItemByCode(storeId: number, itemCode: string) {
|
async function lookupStockItemByCode(storeId: number, itemCode: string) {
|
||||||
return lookupProductByKeyword(storeId, itemCode)
|
// 使用展开版:组合商品自动展开为子 SKU 列表
|
||||||
}
|
return lookupAndExpandProductByKeyword(storeId, itemCode)
|
||||||
|
|
||||||
function applyMatchedStockToSelectedItem(item: PreviewSelectedItem, matched: PreviewSelectedItem) {
|
|
||||||
const displayCode = String(item.item_code || '').trim()
|
|
||||||
item.item_id = matched.item_id
|
|
||||||
item.item_name = String(item.item_name || '').trim() || matched.item_name
|
|
||||||
item.item_code = displayCode || matched.item_code
|
|
||||||
item.barcode = String(item.barcode || '').trim() || matched.barcode
|
|
||||||
item.store_id = item.store_id || matched.store_id
|
|
||||||
item.is_combo = matched.is_combo
|
|
||||||
item.combo_id = matched.combo_id
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resolveMissingItemIdsForGroup(rows: ImportPreviewRow[]) {
|
async function resolveMissingItemIdsForGroup(rows: ImportPreviewRow[]) {
|
||||||
@ -861,17 +852,39 @@ async function resolveMissingItemIdsForGroup(rows: ImportPreviewRow[]) {
|
|||||||
if (!Number.isFinite(storeId) || storeId <= 0) return false
|
if (!Number.isFinite(storeId) || storeId <= 0) return false
|
||||||
|
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
|
const newItems: PreviewSelectedItem[] = []
|
||||||
for (const item of row.selected_items) {
|
for (const item of row.selected_items) {
|
||||||
if (hasValidSelectedItemId(item)) continue
|
if (hasValidSelectedItemId(item)) {
|
||||||
|
newItems.push(item)
|
||||||
|
continue
|
||||||
|
}
|
||||||
const itemCode = String(item.item_code || '').trim()
|
const itemCode = String(item.item_code || '').trim()
|
||||||
if (!itemCode) continue
|
if (!itemCode) {
|
||||||
const matched = await lookupStockItemByCode(storeId, itemCode)
|
newItems.push(item)
|
||||||
if (!matched?.item_id) {
|
continue
|
||||||
|
}
|
||||||
|
// 使用展开版查询:组合商品返回子 SKU 数组,普通商品返回 [单品]
|
||||||
|
const matchedItems = await lookupStockItemByCode(storeId, itemCode)
|
||||||
|
if (!matchedItems.length) {
|
||||||
ElMessage.warning(`订单「${orderLabel}」:商品「${itemCode}」未匹配到有效商品,请在右侧重新选择`)
|
ElMessage.warning(`订单「${orderLabel}」:商品「${itemCode}」未匹配到有效商品,请在右侧重新选择`)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
applyMatchedStockToSelectedItem(item, matched)
|
// 统一展开:无论普通商品还是组合商品,均使用匹配结果中的编码和名称
|
||||||
|
const planQty = String(item.plan_qty || '1').trim()
|
||||||
|
matchedItems.forEach((subItem) => {
|
||||||
|
newItems.push({
|
||||||
|
item_id: subItem.item_id,
|
||||||
|
item_code: subItem.item_code,
|
||||||
|
item_name: subItem.item_name,
|
||||||
|
barcode: subItem.barcode,
|
||||||
|
plan_qty: planQty,
|
||||||
|
store_id: subItem.store_id,
|
||||||
|
is_combo: false,
|
||||||
|
combo_id: undefined
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
row.selected_items = newItems
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -1650,23 +1663,46 @@ async function parseImportPreviewFromFile(file: File) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自动匹配商品(按 item_code 查询并填充 item_id)
|
// 自动匹配商品(按 item_code 查询并填充 item_id,组合商品自动展开)
|
||||||
for (const row of mergedRows) {
|
for (const row of mergedRows) {
|
||||||
const storeId = Number(row.store_id)
|
const storeId = Number(row.store_id)
|
||||||
if (!Number.isFinite(storeId) || storeId <= 0) continue
|
if (!Number.isFinite(storeId) || storeId <= 0) continue
|
||||||
|
const newItems: PreviewSelectedItem[] = []
|
||||||
for (const item of row.selected_items) {
|
for (const item of row.selected_items) {
|
||||||
if (hasValidSelectedItemId(item)) continue
|
if (hasValidSelectedItemId(item)) {
|
||||||
|
newItems.push(item)
|
||||||
|
continue
|
||||||
|
}
|
||||||
const itemCode = String(item.item_code || '').trim()
|
const itemCode = String(item.item_code || '').trim()
|
||||||
if (!itemCode) continue
|
if (!itemCode) {
|
||||||
|
newItems.push(item)
|
||||||
|
continue
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const matched = await lookupStockItemByCode(storeId, itemCode)
|
const matchedItems = await lookupStockItemByCode(storeId, itemCode)
|
||||||
if (matched?.item_id) {
|
if (!matchedItems.length) {
|
||||||
applyMatchedStockToSelectedItem(item, matched)
|
newItems.push(item)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
// 统一展开:使用匹配结果中的编码和名称
|
||||||
|
const planQty = String(item.plan_qty || '1').trim()
|
||||||
|
matchedItems.forEach((subItem) => {
|
||||||
|
newItems.push({
|
||||||
|
item_id: subItem.item_id,
|
||||||
|
item_code: subItem.item_code,
|
||||||
|
item_name: subItem.item_name,
|
||||||
|
barcode: subItem.barcode,
|
||||||
|
plan_qty: planQty,
|
||||||
|
store_id: subItem.store_id,
|
||||||
|
is_combo: false,
|
||||||
|
combo_id: undefined
|
||||||
|
})
|
||||||
|
})
|
||||||
} catch {
|
} catch {
|
||||||
// 匹配失败不影响导入
|
newItems.push(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
row.selected_items = newItems
|
||||||
}
|
}
|
||||||
|
|
||||||
const firstRow = mergedRows[0]
|
const firstRow = mergedRows[0]
|
||||||
|
|||||||
@ -105,6 +105,7 @@ import {
|
|||||||
findStockRowForSelectedItem,
|
findStockRowForSelectedItem,
|
||||||
getStockItemId,
|
getStockItemId,
|
||||||
indexStockRowsByLookupKeys,
|
indexStockRowsByLookupKeys,
|
||||||
|
isComboStockRow,
|
||||||
isStockApiSuccess,
|
isStockApiSuccess,
|
||||||
mapStockPickerItem,
|
mapStockPickerItem,
|
||||||
queryStockProducts,
|
queryStockProducts,
|
||||||
@ -304,9 +305,25 @@ async function loadList() {
|
|||||||
ElMessage.warning('组合商品未包含有效子商品')
|
ElMessage.warning('组合商品未包含有效子商品')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
allRows.value = rawList
|
// stock 模式也需要展开组合商品为子 SKU
|
||||||
.map((row) => mapStockPickerItem(row))
|
const stockRows: any[] = []
|
||||||
.filter((item) => getPickerRowItemId(item))
|
const comboRows: any[] = []
|
||||||
|
for (const row of rawList) {
|
||||||
|
if (isComboStockRow(row)) {
|
||||||
|
comboRows.push(row)
|
||||||
|
} else {
|
||||||
|
stockRows.push(row)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const expandedCombos = comboRows.length
|
||||||
|
? await expandComboSearchResults(comboRows, { storeId: props.storeId })
|
||||||
|
: []
|
||||||
|
allRows.value = [
|
||||||
|
...stockRows
|
||||||
|
.map((row) => mapStockPickerItem(row))
|
||||||
|
.filter((item) => getPickerRowItemId(item)),
|
||||||
|
...expandedCombos
|
||||||
|
]
|
||||||
}
|
}
|
||||||
pagination.total = allRows.value.length
|
pagination.total = allRows.value.length
|
||||||
const maxPage = Math.max(1, Math.ceil(pagination.total / pagination.pageSize))
|
const maxPage = Math.max(1, Math.ceil(pagination.total / pagination.pageSize))
|
||||||
@ -427,6 +444,23 @@ function handleSearch() {
|
|||||||
pagination.currentPage = 1
|
pagination.currentPage = 1
|
||||||
syncingSelection.value = true
|
syncingSelection.value = true
|
||||||
void loadList()
|
void loadList()
|
||||||
|
.then(() => {
|
||||||
|
// 组合商品展开后自动全选所有子 SKU
|
||||||
|
const expandedComboItems = allRows.value.filter(
|
||||||
|
(row: any) => row.source_combo_code
|
||||||
|
)
|
||||||
|
if (expandedComboItems.length) {
|
||||||
|
const planQty = String(defaultPlanQty.value || '').trim() || '1'
|
||||||
|
expandedComboItems.forEach((row: any) => {
|
||||||
|
const item = buildSelectedItemFromStock(row, planQty)
|
||||||
|
if (item && !localSelectedItems.value.some(
|
||||||
|
(existing) => hasValidItemId(existing) && Number(existing.item_id) === Number(item.item_id)
|
||||||
|
)) {
|
||||||
|
localSelectedItems.value.push(item)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
.then(() => enrichLocalSelectedItems())
|
.then(() => enrichLocalSelectedItems())
|
||||||
.then(() => syncSelectionFromLocal())
|
.then(() => syncSelectionFromLocal())
|
||||||
.finally(async () => {
|
.finally(async () => {
|
||||||
|
|||||||
@ -161,42 +161,67 @@ export function mapWarehousePickerItem(row: any, mode?: WarehouseSearchMode) {
|
|||||||
return mode === 'combo' ? mapComboPickerItem(row) : mapStockPickerItem(row)
|
return mode === 'combo' ? mapComboPickerItem(row) : mapStockPickerItem(row)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 解析 nameNotation:【1】商品A【2】商品B */
|
/** 解析 nameNotation:【1】商品A+【1】商品B → Map<序号, 名称>(按顺序索引,数字为数量非序号) */
|
||||||
export function parseComboNameNotation(notation: string): Map<number, string> {
|
export function parseComboNameNotation(notation: string): Map<number, string> {
|
||||||
const map = new Map<number, string>()
|
const map = new Map<number, string>()
|
||||||
const text = String(notation || '').trim()
|
const text = String(notation || '').trim()
|
||||||
if (!text) return map
|
if (!text) return map
|
||||||
|
// nameNotation 格式:【数量】名称+【数量】名称+...,按顺序依次为第 1、2、3 项
|
||||||
const regex = /【(\d+)】([^【]*)/g
|
const regex = /【(\d+)】([^【]*)/g
|
||||||
|
let idx = 0
|
||||||
let match: RegExpExecArray | null
|
let match: RegExpExecArray | null
|
||||||
while ((match = regex.exec(text)) !== null) {
|
while ((match = regex.exec(text)) !== null) {
|
||||||
const index = Number(match[1])
|
idx++
|
||||||
const name = String(match[2] || '').trim()
|
// 去除末尾可能存在的 + 分隔符
|
||||||
if (Number.isInteger(index) && index > 0 && name) {
|
const name = String(match[2] || '').replace(/\+$/, '').trim()
|
||||||
map.set(index, name)
|
if (name) {
|
||||||
|
map.set(idx, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 将单条组合商品记录展开为子 SKU 草稿行(待库存查询补全编码/条码) */
|
/** 解析 simpleNotation:159060|1,159083|1 → Map<序号, 编码> */
|
||||||
|
export function parseComboSimpleNotation(notation: string): Map<number, string> {
|
||||||
|
const map = new Map<number, string>()
|
||||||
|
const text = String(notation || '').trim()
|
||||||
|
if (!text) return map
|
||||||
|
const pairs = text.split(',')
|
||||||
|
pairs.forEach((pair, idx) => {
|
||||||
|
const [code] = pair.split('|')
|
||||||
|
const trimmed = String(code || '').trim()
|
||||||
|
if (trimmed) {
|
||||||
|
map.set(idx + 1, trimmed)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return map
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 将单条组合商品记录展开为子 SKU 草稿行(使用组合记录内置字段,无需额外 API 查询) */
|
||||||
export function expandComboRecordToDraftRows(combo: any) {
|
export function expandComboRecordToDraftRows(combo: any) {
|
||||||
const comboCode = getComboCode(combo)
|
const comboCode = getComboCode(combo)
|
||||||
const comboName = getComboName(combo)
|
const comboName = getComboName(combo)
|
||||||
const nameByIndex = parseComboNameNotation(combo?.nameNotation)
|
const nameByIndex = parseComboNameNotation(combo?.nameNotation)
|
||||||
|
const simpleByIndex = parseComboSimpleNotation(combo?.simpleNotation)
|
||||||
const items = mapComboGoodsItemsFromRecord(combo?.items)
|
const items = mapComboGoodsItemsFromRecord(combo?.items)
|
||||||
if (!items.length) return []
|
if (!items.length) return []
|
||||||
|
|
||||||
return items.map((item, index) => {
|
return items.map((item, index) => {
|
||||||
const nameIndex = index + 1
|
const nameIndex = index + 1
|
||||||
|
// 优先取 items 中的 item_code/item_name/barcode;其次从 simpleNotation/nameNotation 解析
|
||||||
const itemName = item.item_name
|
const itemName = item.item_name
|
||||||
|| nameByIndex.get(nameIndex)
|
|| nameByIndex.get(nameIndex)
|
||||||
|| nameByIndex.get(Number(item.sort_order))
|
|| nameByIndex.get(Number(item.sort_order))
|
||||||
|| ''
|
|| ''
|
||||||
|
const itemCode = item.item_code
|
||||||
|
|| simpleByIndex.get(nameIndex)
|
||||||
|
|| String(item.item_goods_sku_id)
|
||||||
|
const barcode = item.barcode || itemCode || ''
|
||||||
return {
|
return {
|
||||||
item_id: item.item_goods_sku_id,
|
item_id: item.item_goods_sku_id,
|
||||||
item_code: item.item_code || String(item.item_goods_sku_id),
|
item_code: itemCode,
|
||||||
item_name: itemName,
|
item_name: itemName,
|
||||||
barcode: item.barcode || '',
|
barcode,
|
||||||
source_combo_code: comboCode,
|
source_combo_code: comboCode,
|
||||||
source_combo_name: comboName,
|
source_combo_name: comboName,
|
||||||
combo_item_quantity: item.item_quantity,
|
combo_item_quantity: item.item_quantity,
|
||||||
@ -205,10 +230,10 @@ export function expandComboRecordToDraftRows(combo: any) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 组合商品搜索结果 → 展开并补全为与普通商品一致的可选行 */
|
/** 组合商品搜索结果 → 展开为子商品行(使用组合记录内置字段,无需额外 API 查询) */
|
||||||
export async function expandComboSearchResults(
|
export async function expandComboSearchResults(
|
||||||
comboList: any[],
|
comboList: any[],
|
||||||
options: { storeId?: number } = {}
|
_options: { storeId?: number } = {}
|
||||||
) {
|
) {
|
||||||
const draftRows: any[] = []
|
const draftRows: any[] = []
|
||||||
for (const combo of comboList) {
|
for (const combo of comboList) {
|
||||||
@ -217,35 +242,10 @@ export async function expandComboSearchResults(
|
|||||||
}
|
}
|
||||||
if (!draftRows.length) return []
|
if (!draftRows.length) return []
|
||||||
|
|
||||||
const skuIds = Array.from(new Set(
|
// 使用组合记录的 simpleNotation / nameNotation / items 内置字段,
|
||||||
draftRows.map((row) => Number(row.item_id)).filter((id) => Number.isInteger(id) && id > 0)
|
// 无需额外调用 stock.warehouse.search 查询子 SKU 编码
|
||||||
))
|
|
||||||
const enrichById = new Map<number, ReturnType<typeof mapStockPickerItem>>()
|
|
||||||
if (skuIds.length) {
|
|
||||||
const { res, list } = await queryStockProducts({
|
|
||||||
keyword: skuIds.join(','),
|
|
||||||
storeId: options.storeId
|
|
||||||
})
|
|
||||||
if (isStockApiSuccess(res)) {
|
|
||||||
for (const row of list) {
|
|
||||||
const mapped = mapStockPickerItem(row)
|
|
||||||
if (mapped.item_id) enrichById.set(mapped.item_id, mapped)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return draftRows.map((draft) => {
|
return draftRows.map((draft) => {
|
||||||
const enriched = enrichById.get(Number(draft.item_id))
|
const mapped = mapStockPickerItem(draft)
|
||||||
const merged = enriched
|
|
||||||
? {
|
|
||||||
...enriched,
|
|
||||||
source_combo_code: draft.source_combo_code,
|
|
||||||
source_combo_name: draft.source_combo_name,
|
|
||||||
combo_item_quantity: draft.combo_item_quantity,
|
|
||||||
_from_combo_expanded: true
|
|
||||||
}
|
|
||||||
: draft
|
|
||||||
const mapped = mapStockPickerItem(merged)
|
|
||||||
return mapped.item_id ? mapped : null
|
return mapped.item_id ? mapped : null
|
||||||
}).filter((row): row is ReturnType<typeof mapStockPickerItem> => row != null)
|
}).filter((row): row is ReturnType<typeof mapStockPickerItem> => row != null)
|
||||||
}
|
}
|
||||||
@ -431,12 +431,14 @@ export function applyStockMatchToSelectedItem<T extends OrderSelectedProductItem
|
|||||||
? false
|
? false
|
||||||
: isComboStockRow(stockRow)
|
: isComboStockRow(stockRow)
|
||||||
const mapped = useCombo ? mapComboPickerItem(stockRow) : mapStockPickerItem(stockRow)
|
const mapped = useCombo ? mapComboPickerItem(stockRow) : mapStockPickerItem(stockRow)
|
||||||
const displayCode = String(item.item_code || '').trim()
|
|
||||||
|
// 对于展开的组合商品子项,优先使用匹配结果中的编码和名称
|
||||||
|
const isExpandedCombo = Boolean((item as any)?.source_combo_code || (stockRow as any)?.source_combo_code)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
item_id: mapped.item_id || item.item_id,
|
item_id: mapped.item_id || item.item_id,
|
||||||
item_code: displayCode || mapped.item_code,
|
item_code: isExpandedCombo ? (mapped.item_code || item.item_code) : (String(item.item_code || '').trim() || mapped.item_code),
|
||||||
item_name: String(item.item_name || '').trim() || mapped.item_name,
|
item_name: String(item.item_name || '').trim() || mapped.item_name,
|
||||||
barcode: String(item.barcode || '').trim() || mapped.barcode,
|
barcode: String(item.barcode || '').trim() || mapped.barcode,
|
||||||
store_id: getStockStoreId(stockRow) || item.store_id,
|
store_id: getStockStoreId(stockRow) || item.store_id,
|
||||||
@ -478,11 +480,113 @@ export async function lookupStockProductByKeyword(storeId: number | undefined, k
|
|||||||
return toOrderSelectedProductItem(matched, { displayCode: normalizedKeyword })
|
return toOrderSelectedProductItem(matched, { displayCode: normalizedKeyword })
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 建单商品匹配:先查普通商品,未命中再查组合商品 */
|
/** 判断 API 返回的 row 是否为组合商品(有 combo_code/combo_name 字段) */
|
||||||
|
export function isComboResponseRow(row: any): boolean {
|
||||||
|
return Boolean(String(row?.combo_code ?? '').trim() || String(row?.combo_name ?? '').trim())
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 建单商品匹配:一次查询,根据响应字段自动区分普通/组合商品 */
|
||||||
export async function lookupProductByKeyword(storeId: number | undefined, keyword: string) {
|
export async function lookupProductByKeyword(storeId: number | undefined, keyword: string) {
|
||||||
const stockItem = await lookupStockProductByKeyword(storeId, keyword)
|
const normalizedKeyword = String(keyword || '').trim()
|
||||||
if (stockItem?.item_id) return stockItem
|
if (!normalizedKeyword) return null
|
||||||
return lookupComboProductByKeyword(storeId, keyword)
|
|
||||||
|
// 一次查询:不指定 mode,API 根据 keyword 返回对应类型
|
||||||
|
const { res, list } = await queryStockProducts({
|
||||||
|
keyword: normalizedKeyword,
|
||||||
|
storeId
|
||||||
|
})
|
||||||
|
if (!isStockApiSuccess(res) || !list.length) return null
|
||||||
|
|
||||||
|
// 根据响应字段判断类型:有 combo_code → 组合商品;有 item_code → 普通商品
|
||||||
|
const matched = findStockRowByKeyword(list, normalizedKeyword)
|
||||||
|
if (!matched) {
|
||||||
|
// 当前列表未匹配到,尝试组合商品查找(兼容需要 mode='combo' 的场景)
|
||||||
|
const comboTry = await queryStockProducts({
|
||||||
|
keyword: normalizedKeyword,
|
||||||
|
storeId,
|
||||||
|
mode: 'combo'
|
||||||
|
})
|
||||||
|
if (isStockApiSuccess(comboTry.res) && comboTry.list.length) {
|
||||||
|
const comboMatched = findStockRowByKeyword(comboTry.list, normalizedKeyword, 'combo')
|
||||||
|
if (comboMatched) {
|
||||||
|
return toOrderSelectedProductItem(comboMatched, { displayCode: normalizedKeyword, mode: 'combo' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isComboResponseRow(matched)) {
|
||||||
|
return toOrderSelectedProductItem(matched, { displayCode: normalizedKeyword, mode: 'combo' })
|
||||||
|
}
|
||||||
|
|
||||||
|
return toOrderSelectedProductItem(matched, { displayCode: normalizedKeyword })
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 建单商品匹配(展开版):一次查询,组合商品自动展开为子 SKU 列表。
|
||||||
|
* - 普通商品 → 返回 [单品]
|
||||||
|
* - 组合商品 → 返回展开后的子商品数组(每项已映射为 OrderSelectedProductItem)
|
||||||
|
*/
|
||||||
|
export async function lookupAndExpandProductByKeyword(
|
||||||
|
storeId: number | undefined,
|
||||||
|
keyword: string
|
||||||
|
): Promise<OrderSelectedProductItem[]> {
|
||||||
|
const normalizedKeyword = String(keyword || '').trim()
|
||||||
|
if (!normalizedKeyword) return []
|
||||||
|
|
||||||
|
// 一次查询:不指定 mode
|
||||||
|
const { res, list } = await queryStockProducts({
|
||||||
|
keyword: normalizedKeyword,
|
||||||
|
storeId
|
||||||
|
})
|
||||||
|
|
||||||
|
if (isStockApiSuccess(res) && list.length) {
|
||||||
|
const matched = findStockRowByKeyword(list, normalizedKeyword)
|
||||||
|
if (matched) {
|
||||||
|
// 组合商品:展开为子 SKU 列表
|
||||||
|
if (isComboResponseRow(matched)) {
|
||||||
|
const expanded = expandComboRecordToDraftRows(matched)
|
||||||
|
return expanded
|
||||||
|
.map((draft) => mapStockPickerItem(draft))
|
||||||
|
.filter((item) => item.item_id)
|
||||||
|
.map((item) => ({
|
||||||
|
...item,
|
||||||
|
source_combo_code: matched.combo_code ?? matched.custom_code ?? '',
|
||||||
|
source_combo_name: matched.combo_name ?? '',
|
||||||
|
is_combo: false, // 展开后子商品按普通商品处理
|
||||||
|
combo_id: undefined
|
||||||
|
}) as OrderSelectedProductItem)
|
||||||
|
}
|
||||||
|
// 普通商品:直接返回
|
||||||
|
const stockItem = toOrderSelectedProductItem(matched, { displayCode: normalizedKeyword })
|
||||||
|
return stockItem?.item_id ? [stockItem] : []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 未匹配 → 尝试 mode='combo' 查询
|
||||||
|
const comboTry = await queryStockProducts({
|
||||||
|
keyword: normalizedKeyword,
|
||||||
|
storeId,
|
||||||
|
mode: 'combo'
|
||||||
|
})
|
||||||
|
if (isStockApiSuccess(comboTry.res) && comboTry.list.length) {
|
||||||
|
const comboMatched = findStockRowByKeyword(comboTry.list, normalizedKeyword, 'combo')
|
||||||
|
if (comboMatched) {
|
||||||
|
const expanded = expandComboRecordToDraftRows(comboMatched)
|
||||||
|
return expanded
|
||||||
|
.map((draft) => mapStockPickerItem(draft))
|
||||||
|
.filter((item) => item.item_id)
|
||||||
|
.map((item) => ({
|
||||||
|
...item,
|
||||||
|
source_combo_code: comboMatched.combo_code ?? comboMatched.custom_code ?? '',
|
||||||
|
source_combo_name: comboMatched.combo_name ?? '',
|
||||||
|
is_combo: false,
|
||||||
|
combo_id: undefined
|
||||||
|
}) as OrderSelectedProductItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
export function indexStockRowsByLookupKeys(rows: any[], mode?: WarehouseSearchMode) {
|
export function indexStockRowsByLookupKeys(rows: any[], mode?: WarehouseSearchMode) {
|
||||||
|
|||||||
@ -172,7 +172,8 @@ import ScanBox from '@/components/ScanBox/index.vue'
|
|||||||
import UpperTable from '@/components/UpperTable/index.vue'
|
import UpperTable from '@/components/UpperTable/index.vue'
|
||||||
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
|
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
|
||||||
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
||||||
import { stockTransactionList, transactionExport, transactionExportTaskProgress } from '@/api/stock/stock'
|
import { stockTransactionList } from '@/api/stock/stock'
|
||||||
|
import { transactionExport, transactionExportTaskProgress } from '@/api/stock.transaction/stock.transaction'
|
||||||
import * as indexApi from '@/api/index/index'
|
import * as indexApi from '@/api/index/index'
|
||||||
import { useSettingsStore } from '@/stores/modules/settings'
|
import { useSettingsStore } from '@/stores/modules/settings'
|
||||||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||||||
@ -226,6 +227,7 @@ const {
|
|||||||
exportProgressStatus,
|
exportProgressStatus,
|
||||||
exportStatusLabel,
|
exportStatusLabel,
|
||||||
submitExportTaskWithMode,
|
submitExportTaskWithMode,
|
||||||
|
submitExportTask,
|
||||||
resumeExportTaskFromStorage,
|
resumeExportTaskFromStorage,
|
||||||
hasPendingExportTask
|
hasPendingExportTask
|
||||||
} = useAsyncExportTask({
|
} = useAsyncExportTask({
|
||||||
@ -532,7 +534,7 @@ async function handleExportAction(mode: 'all' | 'selected') {
|
|||||||
resumeExportTaskFromStorage()
|
resumeExportTaskFromStorage()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await submitExportTaskWithMode(buildExportPayload(mode), mode)
|
await submitExportTask(buildExportPayload(mode))
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@ -48,6 +48,7 @@ export const productflowToolbarButtons: ToolbarButtonConfig[] = [
|
|||||||
{
|
{
|
||||||
key: 'export',
|
key: 'export',
|
||||||
label: '导出',
|
label: '导出',
|
||||||
|
action: 'export',
|
||||||
buttonType: 'dropdown',
|
buttonType: 'dropdown',
|
||||||
size: 'small',
|
size: 'small',
|
||||||
dropdownOptions: [
|
dropdownOptions: [
|
||||||
|
|||||||
@ -178,7 +178,8 @@ import UpperTable from '@/components/UpperTable/index.vue'
|
|||||||
import WarehouseSelect from '@/components/WarehouseSelect.vue'
|
import WarehouseSelect from '@/components/WarehouseSelect.vue'
|
||||||
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
|
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
|
||||||
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
||||||
import { stockTransactionStoreList, transactionExportStore, transactionExportTaskProgress } from '@/api/stock/stock'
|
import { stockTransactionStoreList } from '@/api/stock/stock'
|
||||||
|
import { transactionExportStore, transactionExportTaskProgress } from '@/api/stock.transaction/stock.transaction'
|
||||||
import * as indexApi from '@/api/index/index'
|
import * as indexApi from '@/api/index/index'
|
||||||
import { useSettingsStore } from '@/stores/modules/settings'
|
import { useSettingsStore } from '@/stores/modules/settings'
|
||||||
import { useUserStore } from '@/stores/modules/user'
|
import { useUserStore } from '@/stores/modules/user'
|
||||||
@ -236,6 +237,7 @@ const {
|
|||||||
exportProgressStatus,
|
exportProgressStatus,
|
||||||
exportStatusLabel,
|
exportStatusLabel,
|
||||||
submitExportTaskWithMode,
|
submitExportTaskWithMode,
|
||||||
|
submitExportTask,
|
||||||
resumeExportTaskFromStorage,
|
resumeExportTaskFromStorage,
|
||||||
hasPendingExportTask
|
hasPendingExportTask
|
||||||
} = useAsyncExportTask({
|
} = useAsyncExportTask({
|
||||||
@ -426,7 +428,6 @@ async function loadList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const res: any = await stockTransactionStoreList({
|
const res: any = await stockTransactionStoreList({
|
||||||
store_id: Number(storeId),
|
|
||||||
where: Object.keys(where).length > 0 ? where : undefined,
|
where: Object.keys(where).length > 0 ? where : undefined,
|
||||||
pagination: {
|
pagination: {
|
||||||
page: pagination.currentPage,
|
page: pagination.currentPage,
|
||||||
@ -555,7 +556,7 @@ async function handleExportAction(mode: 'all' | 'selected') {
|
|||||||
resumeExportTaskFromStorage()
|
resumeExportTaskFromStorage()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await submitExportTaskWithMode(buildExportPayload(mode), mode)
|
await submitExportTask(buildExportPayload(mode))
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@ -131,9 +131,9 @@ import {
|
|||||||
exportInventoryReport,
|
exportInventoryReport,
|
||||||
getExportTaskProgress,
|
getExportTaskProgress,
|
||||||
searchInventoryReport,
|
searchInventoryReport,
|
||||||
type StorageReportExportBody,
|
type StockReportExportBody,
|
||||||
type StorageReportSearchBody
|
type StockReportSearchBody
|
||||||
} from '@/api/storage.report/report'
|
} from '@/api/stock.report/stock.report'
|
||||||
import * as indexApi from '@/api/index/index'
|
import * as indexApi from '@/api/index/index'
|
||||||
import {
|
import {
|
||||||
buildReportTableColumns,
|
buildReportTableColumns,
|
||||||
@ -200,7 +200,7 @@ const {
|
|||||||
hasPendingExportTask
|
hasPendingExportTask
|
||||||
} = useAsyncExportTask({
|
} = useAsyncExportTask({
|
||||||
storageKey: 'storage.report.export.taskId',
|
storageKey: 'storage.report.export.taskId',
|
||||||
submitExport: (payload) => exportInventoryReport(payload as StorageReportExportBody),
|
submitExport: (payload) => exportInventoryReport(payload as StockReportExportBody),
|
||||||
queryProgress: (params) => getExportTaskProgress(params)
|
queryProgress: (params) => getExportTaskProgress(params)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ function applyClientPage() {
|
|||||||
|
|
||||||
const SORTABLE_FIELDS = new Set(['begin_total', 'inbound_total', 'outbound_total', 'end_total'])
|
const SORTABLE_FIELDS = new Set(['begin_total', 'inbound_total', 'outbound_total', 'end_total'])
|
||||||
|
|
||||||
function buildSortPayload(): StorageReportSearchBody['sort'] | undefined {
|
function buildSortPayload(): StockReportSearchBody['sort'] | undefined {
|
||||||
if (!SORTABLE_FIELDS.has(currentSort.prop)) return undefined
|
if (!SORTABLE_FIELDS.has(currentSort.prop)) return undefined
|
||||||
if (!currentSort.order) return undefined
|
if (!currentSort.order) return undefined
|
||||||
const sortOrder = currentSort.order === 'ascending' ? 'ASC' : 'DESC'
|
const sortOrder = currentSort.order === 'ascending' ? 'ASC' : 'DESC'
|
||||||
@ -302,14 +302,14 @@ function buildSortPayload(): StorageReportSearchBody['sort'] | undefined {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildReportQueryPayload(): StorageReportSearchBody {
|
function buildReportQueryPayload(): StockReportSearchBody {
|
||||||
const where = normalizeScanConditionToReportWhere(currentConditionRaw.value)
|
const where = normalizeScanConditionToReportWhere(currentConditionRaw.value)
|
||||||
// 关键字搜索
|
// 关键字搜索
|
||||||
if (keyword.value.trim()) {
|
if (keyword.value.trim()) {
|
||||||
where.keyword = keyword.value.trim()
|
where.keyword = keyword.value.trim()
|
||||||
}
|
}
|
||||||
const sort = buildSortPayload()
|
const sort = buildSortPayload()
|
||||||
const body: StorageReportSearchBody = {}
|
const body: StockReportSearchBody = {}
|
||||||
if (Object.keys(where).length > 0) {
|
if (Object.keys(where).length > 0) {
|
||||||
body.where = where
|
body.where = where
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import type { StorageReportListItem } from '@/api/storage.report/report'
|
import type { StockReportListItem } from '@/api/stock.report/stock.report'
|
||||||
|
|
||||||
export const reportFieldLabels: Record<string, string> = {
|
export const reportFieldLabels: Record<string, string> = {
|
||||||
store_id: '货主ID',
|
store_id: '货主ID',
|
||||||
@ -70,7 +70,7 @@ export type ReportColumn = {
|
|||||||
align?: 'left' | 'center' | 'right'
|
align?: 'left' | 'center' | 'right'
|
||||||
sortable?: boolean | 'custom'
|
sortable?: boolean | 'custom'
|
||||||
sortOrders?: string[]
|
sortOrders?: string[]
|
||||||
formatter?: (row: StorageReportListItem) => string
|
formatter?: (row: StockReportListItem) => string
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 主表格固定列(与真实接口字段一致);按库位时后端可额外返回 space_*,由 buildReportTableColumns 追加 */
|
/** 主表格固定列(与真实接口字段一致);按库位时后端可额外返回 space_*,由 buildReportTableColumns 追加 */
|
||||||
@ -124,7 +124,7 @@ export const fixedReportColumns: ReportColumn[] = [
|
|||||||
|
|
||||||
const FIXED_PROPS = new Set(fixedReportColumns.map((c) => c.prop))
|
const FIXED_PROPS = new Set(fixedReportColumns.map((c) => c.prop))
|
||||||
|
|
||||||
export function buildReportTableColumns(rows: StorageReportListItem[]) {
|
export function buildReportTableColumns(rows: StockReportListItem[]) {
|
||||||
const cols = fixedReportColumns.map((c) => ({ ...c }))
|
const cols = fixedReportColumns.map((c) => ({ ...c }))
|
||||||
const extra = new Set<string>()
|
const extra = new Set<string>()
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
|
|||||||
@ -136,9 +136,9 @@ import {
|
|||||||
exportStoreReport,
|
exportStoreReport,
|
||||||
getExportTaskProgress,
|
getExportTaskProgress,
|
||||||
searchStoreReport,
|
searchStoreReport,
|
||||||
type StorageReportExportBody,
|
type StockReportExportBody,
|
||||||
type StorageReportSearchBody
|
type StockReportSearchBody
|
||||||
} from '@/api/storage.report/report'
|
} from '@/api/stock.report/stock.report'
|
||||||
import * as indexApi from '@/api/index/index'
|
import * as indexApi from '@/api/index/index'
|
||||||
import {
|
import {
|
||||||
buildReportTableColumns,
|
buildReportTableColumns,
|
||||||
@ -207,7 +207,7 @@ const {
|
|||||||
hasPendingExportTask
|
hasPendingExportTask
|
||||||
} = useAsyncExportTask({
|
} = useAsyncExportTask({
|
||||||
storageKey: 'storage.report.export.taskId',
|
storageKey: 'storage.report.export.taskId',
|
||||||
submitExport: (payload) => exportStoreReport(payload as StorageReportExportBody),
|
submitExport: (payload) => exportStoreReport(payload as StockReportExportBody),
|
||||||
queryProgress: (params) => getExportTaskProgress(params)
|
queryProgress: (params) => getExportTaskProgress(params)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ function applyClientPage() {
|
|||||||
|
|
||||||
const SORTABLE_FIELDS = new Set(['begin_total', 'inbound_total', 'outbound_total', 'end_total'])
|
const SORTABLE_FIELDS = new Set(['begin_total', 'inbound_total', 'outbound_total', 'end_total'])
|
||||||
|
|
||||||
function buildSortPayload(): StorageReportSearchBody['sort'] | undefined {
|
function buildSortPayload(): StockReportSearchBody['sort'] | undefined {
|
||||||
if (!SORTABLE_FIELDS.has(currentSort.prop)) return undefined
|
if (!SORTABLE_FIELDS.has(currentSort.prop)) return undefined
|
||||||
if (!currentSort.order) return undefined
|
if (!currentSort.order) return undefined
|
||||||
const sortOrder = currentSort.order === 'ascending' ? 'ASC' : 'DESC'
|
const sortOrder = currentSort.order === 'ascending' ? 'ASC' : 'DESC'
|
||||||
@ -318,7 +318,7 @@ function buildSortPayload(): StorageReportSearchBody['sort'] | undefined {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildReportQueryPayload(): StorageReportSearchBody {
|
function buildReportQueryPayload(): StockReportSearchBody {
|
||||||
const where = normalizeScanConditionToReportWhere(currentConditionRaw.value)
|
const where = normalizeScanConditionToReportWhere(currentConditionRaw.value)
|
||||||
if (selectedWarehouseId.value) {
|
if (selectedWarehouseId.value) {
|
||||||
where.warehouse_id = selectedWarehouseId.value
|
where.warehouse_id = selectedWarehouseId.value
|
||||||
@ -328,7 +328,7 @@ function buildReportQueryPayload(): StorageReportSearchBody {
|
|||||||
where.keyword = keyword.value.trim()
|
where.keyword = keyword.value.trim()
|
||||||
}
|
}
|
||||||
const sort = buildSortPayload()
|
const sort = buildSortPayload()
|
||||||
const body: StorageReportSearchBody = {}
|
const body: StockReportSearchBody = {}
|
||||||
if (Object.keys(where).length > 0) {
|
if (Object.keys(where).length > 0) {
|
||||||
body.where = where
|
body.where = where
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user