Compare commits
2 Commits
2d955cf961
...
692e5cd4a4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
692e5cd4a4 | ||
|
|
21b0249097 |
@ -6,14 +6,10 @@ const v = '1.0'
|
||||
// 站内信模块 API
|
||||
// ============================================================
|
||||
|
||||
/** 站内信列表查询参数 */
|
||||
/** 站内信列表查询参数(对齐 order.pendingOrder.list 格式) */
|
||||
export interface InboxListParams {
|
||||
direction?: string // 消息方向筛选:inbound(收件)/ outbound(回信)
|
||||
pushStatus?: number // 推送状态筛选:0=待推送 1=推送中 2=已送达 3=失败
|
||||
targetChannel?: string // 目标渠道筛选:wecom / dingtalk / feishu / warehouse_api / webhook
|
||||
keyword?: string // 关键词搜索,模糊匹配 ext_id 和 ref_code
|
||||
page?: number // 页码,默认 1
|
||||
pageSize?: number // 每页数量,默认 20,最大 200
|
||||
pagination?: { page?: number; pageSize?: number }
|
||||
where?: Record<string, { operator: string; value: any }>
|
||||
}
|
||||
|
||||
/** 站内信消息列表(inbox.message.list) */
|
||||
|
||||
@ -42,6 +42,21 @@ export function loadWarehouses(data?: Record<string, unknown>) {
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 当前仓库下的快递接口下拉列表,可传入 systemExpressCode 过滤 */
|
||||
export function loadExpressInterfaces(data?: { systemExpressCode?: string }) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'index.loadExpressInterfaces',
|
||||
v: '1.0',
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: data ?? {},
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
export function getCOSUploadConfig(data:any){
|
||||
return request({
|
||||
url: '/system',
|
||||
|
||||
@ -4,6 +4,14 @@ import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/o
|
||||
// 站内信群组 - ScanBox 筛选字段
|
||||
// ============================================================
|
||||
export const groupAvailableFields = [
|
||||
{
|
||||
value: 'store_id',
|
||||
label: '货主',
|
||||
type: 'select',
|
||||
multiple: true,
|
||||
placeholder: '请选择货主',
|
||||
options: [] as { label: string; value: unknown }[],
|
||||
},
|
||||
{
|
||||
value: 'groupType',
|
||||
label: '群类型',
|
||||
@ -25,20 +33,32 @@ export const groupAvailableFields = [
|
||||
operators: ['contains'],
|
||||
defaultOperator: 'contains',
|
||||
},
|
||||
{
|
||||
value: 'is_blocked',
|
||||
label: '是否禁用',
|
||||
type: 'select',
|
||||
placeholder: '请选择状态',
|
||||
operators: ['eq'],
|
||||
defaultOperator: 'eq',
|
||||
options: [
|
||||
{ label: '启用', value: 0 },
|
||||
{ label: '禁用', value: 1 },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
// ============================================================
|
||||
// 站内信群组 - UpperTable 列配置
|
||||
// ============================================================
|
||||
export const groupColumns = [
|
||||
{ prop: 'id', label: 'ID', width: '70' },
|
||||
{ prop: 'group_name', label: '群名称', minWidth: '160', showOverflowTooltip: true },
|
||||
{ prop: 'group_id', label: '群ID', minWidth: '160', showOverflowTooltip: true },
|
||||
{ prop: 'group_type', label: '群类型', width: '100' },
|
||||
{ prop: 'sub_type', label: '子类型', width: '100' },
|
||||
{ prop: 'store_id', label: '货主ID', width: '90' },
|
||||
{ prop: 'express_interfaces', label: '快递接口', minWidth: '140', showOverflowTooltip: true },
|
||||
{ prop: 'system_express_code', label: '系统快递编码', minWidth: '140', showOverflowTooltip: true },
|
||||
{ prop: 'store_name', label: '货主', minWidth: '120', showOverflowTooltip: true },
|
||||
{ prop: 'express_interfaces', label: '快递接口', minWidth: '160', showOverflowTooltip: true },
|
||||
{ prop: 'system_express_name', label: '系统快递', width: '110', showOverflowTooltip: true },
|
||||
{ prop: 'ai_enabled', label: 'AI回复', width: '90' },
|
||||
{ prop: 'is_blocked', label: '状态', width: '80' },
|
||||
{ prop: 'created_at', label: '创建时间', width: '170' },
|
||||
{ prop: 'actions', label: '操作', width: '220', fixed: 'right' },
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
:tree-props="{ children: 'children', label: 'label' }"
|
||||
:auto-submit="false"
|
||||
:available-fields="availableFields"
|
||||
:initial-conditions="initialConditions"
|
||||
@condition-change="handleConditionChange"
|
||||
@reset="handleConditionReset"
|
||||
@condition-clear="handleConditionClear"
|
||||
@ -52,7 +53,7 @@
|
||||
<template #column-express_interfaces="{ row }">
|
||||
<template v-if="row.express_interfaces && row.express_interfaces.length">
|
||||
<el-tag v-for="(iface, idx) in row.express_interfaces" :key="idx" size="small" style="margin: 1px 2px">
|
||||
{{ iface }}
|
||||
{{ iface.name || iface }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<span v-else>-</span>
|
||||
@ -64,6 +65,12 @@
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<template #column-ai_enabled="{ row }">
|
||||
<el-tag size="small" :type="row.ai_enabled ? 'success' : 'info'">
|
||||
{{ row.ai_enabled ? '开' : '关' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<template #column-actions="{ row }">
|
||||
<el-button size="small" type="primary" link @click.stop="handleEdit(row)">编辑</el-button>
|
||||
<el-button size="small" :type="row.is_blocked ? 'success' : 'danger'" link @click.stop="handleToggleDisable(row)">
|
||||
@ -87,7 +94,7 @@
|
||||
<el-form ref="bindFormRef" :model="bindForm" :rules="bindRules" label-width="100px" size="small">
|
||||
<el-form-item label="选择货主" prop="storeId">
|
||||
<el-select v-model="bindForm.storeId" placeholder="请选择货主" filterable style="width: 100%" :loading="storeLoading">
|
||||
<el-option v-for="store in storeList" :key="store.id" :label="store.name" :value="store.id" />
|
||||
<el-option v-for="store in storeList" :key="store.value" :label="store.label" :value="store.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="子类型">
|
||||
@ -139,7 +146,12 @@
|
||||
</el-form-item>
|
||||
<el-form-item v-if="editForm.groupType === 'store'" label="关联货主" prop="storeId">
|
||||
<el-select v-model="editForm.storeId" placeholder="请选择货主" filterable clearable style="width: 100%" :loading="storeLoading">
|
||||
<el-option v-for="store in storeList" :key="store.id" :label="store.counterparty_name" :value="store.id" />
|
||||
<el-option v-for="store in storeList" :key="store.value" :label="store.label" :value="store.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="editForm.groupType === 'express'" label="系统快递编码" prop="systemExpressCode">
|
||||
<el-select v-model="editForm.systemExpressCode" placeholder="请选择系统快递编码" filterable clearable style="width: 100%" :loading="expressLoading" @change="onSystemExpressCodeChange">
|
||||
<el-option v-for="item in expressCodeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="editForm.groupType === 'express'" label="快递接口" prop="expressInterfaces">
|
||||
@ -147,11 +159,6 @@
|
||||
<el-option v-for="item in expressInterfaceOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="editForm.groupType === 'express'" label="系统快递编码" prop="systemExpressCode">
|
||||
<el-select v-model="editForm.systemExpressCode" placeholder="请选择系统快递编码" filterable clearable style="width: 100%" :loading="expressLoading">
|
||||
<el-option v-for="item in expressCodeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="AI 自动回复">
|
||||
<el-switch v-model="editForm.aiEnabled" :active-value="1" :inactive-value="0" active-text="开" inactive-text="关" />
|
||||
</el-form-item>
|
||||
@ -212,8 +219,8 @@ import {
|
||||
inboxGroupMessages,
|
||||
inboxBindCode,
|
||||
} from '@/api/inbox/inbox'
|
||||
import { storeList as fetchStoreList } from '@/api/storewarehouse.store/storeWarehouse'
|
||||
import { expressInterfaceList } from '@/api/setting.expressinterface/expressInterface'
|
||||
import { loadStores, loadExpressInterfaces } from '@/api/index/index'
|
||||
import { extractStoreListFromResponse, fillStoreScanFieldOptions, mapStoreListToSelectOptions } from '@/views/order/orderManagement/config/order-common-config'
|
||||
import { expressIndexGetExpressList } from '@/api/setting.express/express'
|
||||
import { groupAvailableFields, groupColumns } from './group-config'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
@ -255,8 +262,16 @@ function handleConditionChange(conditions: Record<string, any>) {
|
||||
upperPagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
function handleConditionReset() { currentConditions.value = {}; pagination.currentPage = 1; upperPagination.currentPage = 1; fetchData() }
|
||||
function handleConditionClear() { currentConditions.value = {}; pagination.currentPage = 1; upperPagination.currentPage = 1; fetchData() }
|
||||
function handleConditionReset() {
|
||||
currentConditions.value = { is_blocked: { value: 0, operator: 'eq', type: 'select' } }
|
||||
pagination.currentPage = 1; upperPagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
function handleConditionClear() {
|
||||
currentConditions.value = {}
|
||||
pagination.currentPage = 1; upperPagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
function handleRowClick(row: any) { selectedRow.value = row }
|
||||
|
||||
// ==================== 数据查询 ====================
|
||||
@ -265,8 +280,15 @@ function buildWhereFromConditions(conditions: Record<string, any>) {
|
||||
const where: Record<string, any> = {}
|
||||
for (const [key, cond] of Object.entries(conditions)) {
|
||||
if (cond === undefined || cond === null || cond === '') continue
|
||||
if (typeof cond === 'object' && cond.value !== undefined) where[key] = cond.value
|
||||
else where[key] = cond
|
||||
if (typeof cond === 'object' && cond.value !== undefined) {
|
||||
const val = cond.value
|
||||
const op = cond.operator || 'eq'
|
||||
// 空值跳过
|
||||
if (val === undefined || val === null || val === '' || (Array.isArray(val) && val.length === 0)) continue
|
||||
where[key] = { operator: op, value: val }
|
||||
} else {
|
||||
where[key] = { operator: 'eq', value: cond }
|
||||
}
|
||||
}
|
||||
return where
|
||||
}
|
||||
@ -275,7 +297,10 @@ async function fetchData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const where = buildWhereFromConditions(currentConditions.value)
|
||||
const params: any = { page: pagination.currentPage, pageSize: pagination.pageSize, ...where }
|
||||
const params: any = {
|
||||
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
|
||||
where,
|
||||
}
|
||||
const res: any = await inboxGroupList(params)
|
||||
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||||
const data = res.data ?? res
|
||||
@ -314,9 +339,15 @@ function resetBindForm() { bindFormRef.value?.resetFields() }
|
||||
async function loadStoreList() {
|
||||
storeLoading.value = true
|
||||
try {
|
||||
const res: any = await fetchStoreList({})
|
||||
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) storeList.value = res.data?.list ?? res.data ?? []
|
||||
} catch { /* ignore */ } finally { storeLoading.value = false }
|
||||
const storesRes: any = await loadStores()
|
||||
const rawStores = extractStoreListFromResponse(storesRes)
|
||||
storeList.value = mapStoreListToSelectOptions(rawStores)
|
||||
// 同时注入 ScanBox 货主筛选选项
|
||||
fillStoreScanFieldOptions(availableFields, rawStores)
|
||||
} catch {
|
||||
storeList.value = []
|
||||
fillStoreScanFieldOptions(availableFields, [])
|
||||
} finally { storeLoading.value = false }
|
||||
}
|
||||
|
||||
async function handleGenerateCode() {
|
||||
@ -356,42 +387,52 @@ function handleEdit(row: any) {
|
||||
editForm.groupId = row.group_id ?? ''; editForm.groupName = row.group_name ?? ''
|
||||
editForm.groupType = row.group_type ?? ''; editForm.subType = row.sub_type ?? ''
|
||||
editForm.storeId = row.store_id ?? null
|
||||
editForm.expressInterfaces = Array.isArray(row.express_interfaces) ? [...row.express_interfaces] : []
|
||||
editForm.expressInterfaces = Array.isArray(row.express_interfaces)
|
||||
? row.express_interfaces.map((item: any) => (typeof item === 'object' ? item.id : item))
|
||||
: []
|
||||
editForm.systemExpressCode = row.system_express_code ?? ''
|
||||
editForm.aiEnabled = row.ai_enabled ?? 1
|
||||
editDialogVisible.value = true; loadStoreList()
|
||||
if (editForm.groupType === 'express') { loadExpressCodes(); loadExpressInterfacesByCode() }
|
||||
}
|
||||
function resetEditForm() { editFormRef.value?.resetFields(); editingRow.value = null }
|
||||
|
||||
async function loadExpressOptions() {
|
||||
expressLoading.value = true
|
||||
async function loadExpressCodes() {
|
||||
try {
|
||||
const [ifaceRes, expressRes]: any[] = await Promise.all([
|
||||
expressInterfaceList({ pagination: { page: 1, pageSize: 200 } }),
|
||||
expressIndexGetExpressList({ systemOnly: true }),
|
||||
])
|
||||
const ifaceList = ifaceRes?.data?.list || ifaceRes?.data || []
|
||||
expressInterfaceOptions.value = ifaceList.map((item: any) => ({
|
||||
label: `${item.name || item.express_code || ''}(${item.id})`,
|
||||
value: item.id,
|
||||
}))
|
||||
const expressRes: any = await expressIndexGetExpressList({ systemOnly: true })
|
||||
const expressList = expressRes?.data?.list || expressRes?.data || []
|
||||
expressCodeOptions.value = expressList.map((item: any) => ({
|
||||
label: `${item.code || ''} - ${item.name || ''}`,
|
||||
value: item.code || '',
|
||||
}))
|
||||
} catch {
|
||||
expressInterfaceOptions.value = []
|
||||
expressCodeOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
async function loadExpressInterfacesByCode() {
|
||||
expressLoading.value = true
|
||||
try {
|
||||
const ifaceRes: any = await loadExpressInterfaces(
|
||||
editForm.systemExpressCode ? { systemExpressCode: editForm.systemExpressCode } : undefined
|
||||
)
|
||||
expressInterfaceOptions.value = ifaceRes?.expressInterfaces || []
|
||||
} catch {
|
||||
expressInterfaceOptions.value = []
|
||||
} finally {
|
||||
expressLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onSystemExpressCodeChange() {
|
||||
editForm.expressInterfaces = []
|
||||
loadExpressInterfacesByCode()
|
||||
}
|
||||
|
||||
function onEditGroupTypeChange() {
|
||||
if (editForm.groupType !== 'express') { editForm.expressInterfaces = []; editForm.systemExpressCode = '' }
|
||||
if (editForm.groupType !== 'store') editForm.storeId = null
|
||||
if (editForm.groupType === 'express') loadExpressOptions()
|
||||
if (editForm.groupType === 'express') { loadExpressCodes(); loadExpressInterfacesByCode() }
|
||||
}
|
||||
|
||||
async function handleSubmitEdit() {
|
||||
@ -459,7 +500,12 @@ async function fetchGroupMessages() {
|
||||
function onMsgPageChange(page: number) { msgPagination.currentPage = page; fetchGroupMessages() }
|
||||
function onMsgPageSizeChange(size: number) { msgPagination.pageSize = size; msgPagination.currentPage = 1; fetchGroupMessages() }
|
||||
|
||||
onMounted(() => { fetchData() })
|
||||
// ==================== 默认筛选:仅显示启用群组 ====================
|
||||
const initialConditions = {
|
||||
is_blocked: { value: 0, operator: 'eq', type: 'select' },
|
||||
}
|
||||
|
||||
onMounted(() => { loadStoreList(); fetchData() })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
@ -57,19 +57,6 @@
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<template #column-target_type="{ row }">
|
||||
<el-tag size="small" :type="row.target_type === 'api' ? '' : 'info'">
|
||||
{{ row.target_type ?? '-' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<template #column-target_channel="{ row }">
|
||||
<el-tag v-if="row.target_channel" size="small" :type="channelTagType(row.target_channel)">
|
||||
{{ channelLabel(row.target_channel) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
|
||||
<template #column-push_status="{ row }">
|
||||
<template v-if="row.direction === 'outbound'">
|
||||
<el-tag size="small" :type="pushStatusTagType(row.push_status)">
|
||||
@ -237,6 +224,8 @@ import {
|
||||
inboxRetry,
|
||||
inboxStats,
|
||||
} from '@/api/inbox/inbox'
|
||||
import { loadStores } from '@/api/index/index'
|
||||
import { extractStoreListFromResponse, fillStoreScanFieldOptions } from '@/views/order/orderManagement/config/order-common-config'
|
||||
import { messageAvailableFields, messageColumns } from './message-config'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
@ -321,9 +310,24 @@ function buildWhereFromConditions(conditions: Record<string, any>) {
|
||||
for (const [key, cond] of Object.entries(conditions)) {
|
||||
if (cond === undefined || cond === null || cond === '') continue
|
||||
if (typeof cond === 'object' && cond.value !== undefined) {
|
||||
where[key] = cond.value
|
||||
const val = cond.value
|
||||
const op = cond.operator || 'eq'
|
||||
|
||||
// 空值跳过
|
||||
if (val === undefined || val === null || val === '' || (Array.isArray(val) && val.length === 0)) continue
|
||||
|
||||
// 日期范围:拆分为 begin/end
|
||||
if (Array.isArray(val) && val.length === 2 && (cond.type === 'daterange' || cond.type === 'datetimerange')) {
|
||||
where[key] = {
|
||||
operator: op,
|
||||
value: [val[0] + ' 00:00:00', val[1] + ' 23:59:59'],
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
where[key] = { operator: op, value: val }
|
||||
} else {
|
||||
where[key] = cond
|
||||
where[key] = { operator: 'eq', value: cond }
|
||||
}
|
||||
}
|
||||
return where
|
||||
@ -335,9 +339,8 @@ async function fetchData() {
|
||||
try {
|
||||
const where = buildWhereFromConditions(currentConditions.value)
|
||||
const params: any = {
|
||||
page: pagination.currentPage,
|
||||
pageSize: pagination.pageSize,
|
||||
...where,
|
||||
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
|
||||
where,
|
||||
}
|
||||
const res: any = await inboxList(params)
|
||||
if (res && (res.code === 1 || res.code === 200 || res.code === 20000)) {
|
||||
@ -506,7 +509,25 @@ async function handleViewThread(row: any) {
|
||||
finally { threadLoading.value = false }
|
||||
}
|
||||
|
||||
// ==================== 货主列表加载 ====================
|
||||
|
||||
async function loadStoreOptions() {
|
||||
try {
|
||||
const storesRes: any = await loadStores()
|
||||
fillStoreScanFieldOptions(availableFields, extractStoreListFromResponse(storesRes))
|
||||
} catch {
|
||||
fillStoreScanFieldOptions(availableFields, [])
|
||||
} finally {
|
||||
// 硬编码:无货主消息选项
|
||||
const storeField = availableFields.find((f: any) => f.value === 'store_id')
|
||||
if (storeField?.options) {
|
||||
(storeField.options as any[]).unshift({ label: '无货主消息', value: 0 })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadStoreOptions()
|
||||
fetchData()
|
||||
fetchStats()
|
||||
})
|
||||
|
||||
@ -4,6 +4,22 @@ import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/o
|
||||
// 站内信消息列表 - ScanBox 筛选字段(对齐 inbox.list 实际字段)
|
||||
// ============================================================
|
||||
export const messageAvailableFields = [
|
||||
{
|
||||
value: 'store_id',
|
||||
label: '货主',
|
||||
type: 'select',
|
||||
multiple: true,
|
||||
placeholder: '请选择货主',
|
||||
options: [] as { label: string; value: unknown }[],
|
||||
},
|
||||
{
|
||||
value: 'keyword',
|
||||
label: '关键词',
|
||||
type: 'text',
|
||||
placeholder: '搜索群名称、内容、用户名称,多个用逗号分隔',
|
||||
operators: ['contains'],
|
||||
defaultOperator: 'contains',
|
||||
},
|
||||
{
|
||||
value: 'direction',
|
||||
label: '消息方向',
|
||||
@ -58,12 +74,10 @@ export const messageAvailableFields = [
|
||||
],
|
||||
},
|
||||
{
|
||||
value: 'keyword',
|
||||
label: '关键词',
|
||||
type: 'text',
|
||||
placeholder: '搜索 ext_id / content / group_name',
|
||||
operators: ['contains'],
|
||||
defaultOperator: 'contains',
|
||||
value: 'created_at',
|
||||
label: '创建时间',
|
||||
type: 'daterange',
|
||||
placeholder: '请选择时间范围',
|
||||
},
|
||||
]
|
||||
|
||||
@ -71,18 +85,14 @@ export const messageAvailableFields = [
|
||||
// 站内信消息列表 - UpperTable 列配置(对齐 inbox.list 实际响应字段)
|
||||
// ============================================================
|
||||
export const messageColumns = [
|
||||
{ prop: 'id', label: 'ID', width: '70' },
|
||||
{ prop: 'ext_id', label: '外部ID', minWidth: '160', showOverflowTooltip: true },
|
||||
{ prop: 'content', label: '正文', minWidth: '220', showOverflowTooltip: true },
|
||||
{ prop: 'direction', label: '方向', width: '70' },
|
||||
{ prop: 'source_type', label: '来源', width: '80' },
|
||||
{ prop: 'target_type', label: '目标类型', width: '90' },
|
||||
{ prop: 'target_channel', label: '渠道', width: '100' },
|
||||
{ prop: 'group_name', label: '群名称', minWidth: '140', showOverflowTooltip: true },
|
||||
{ prop: 'user_name', label: '发送人', minWidth: '120', showOverflowTooltip: true },
|
||||
{ prop: 'store_name', label: '货主', minWidth: '140', showOverflowTooltip: true },
|
||||
{ prop: 'push_status', label: '推送状态', width: '90' },
|
||||
{ prop: 'retry_count', label: '重试', width: '60' },
|
||||
{ prop: 'parent_id', label: '父消息ID', width: '90' },
|
||||
{ prop: 'created_at', label: '创建时间', width: '170' },
|
||||
{ prop: 'actions', label: '操作', width: '240', fixed: 'right' },
|
||||
]
|
||||
|
||||
@ -65,6 +65,18 @@
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<template #column-actions="{ row }">
|
||||
<el-button
|
||||
v-if="row.order_status === 'CREATED' || row.order_status === 'PENDING'"
|
||||
type="primary"
|
||||
size="small"
|
||||
:loading="row._stockoutLoading"
|
||||
@click.stop="handleSingleRowStockout(row)"
|
||||
>
|
||||
一键出库
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<template #empty>
|
||||
<div class="empty-tip">暂无出库单</div>
|
||||
</template>
|
||||
@ -240,8 +252,7 @@ const toolbarActionMap: Record<string, () => void> = {
|
||||
toggleDetailVisible: () => toggleDetailVisible(),
|
||||
handleCreateStockout: () => handleCreateStockout(),
|
||||
handleImport: () => handleImport(),
|
||||
confirmBatchCancel: () => { void confirmBatchCancel() },
|
||||
confirmStockout: () => { void confirmStockout() }
|
||||
confirmBatchCancel: () => { void confirmBatchCancel() }
|
||||
}
|
||||
|
||||
function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
||||
@ -477,6 +488,41 @@ function handleCreateStockout() {
|
||||
ElMessage.info('新建出库单功能')
|
||||
}
|
||||
|
||||
/** 单行一键出库 */
|
||||
async function handleSingleRowStockout(row: any) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定要一键出库出库单「${row.stockout_order_code || row.id}」吗?确认后状态将变更为"已完成"。请确保已填写运单号。`,
|
||||
'一键出库',
|
||||
{ type: 'warning', confirmButtonText: '确认', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
row._stockoutLoading = true
|
||||
try {
|
||||
const res: any = await stockoutApi.stockoutConfirm({ id: row.id })
|
||||
if (res && (res.code === 1 || res.code === 200 || res.code === 20000 || res.flag === 'success')) {
|
||||
const data = res?.data || res
|
||||
if (data?.expressCode) {
|
||||
row.express_code = data.expressCode
|
||||
}
|
||||
if (data?.expressCodes) {
|
||||
row.express_codes = data.expressCodes
|
||||
}
|
||||
ElMessage.success('出库成功')
|
||||
loadData()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '出库失败')
|
||||
}
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '出库失败')
|
||||
} finally {
|
||||
row._stockoutLoading = false
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmBatchCancel() {
|
||||
if (!selectionRows.value.length) {
|
||||
ElMessage.warning('请先选择要作废的出库单')
|
||||
@ -490,60 +536,6 @@ async function confirmBatchCancel() {
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
async function confirmStockout() {
|
||||
const rows = selectionRows.value
|
||||
if (!rows.length) {
|
||||
ElMessage.warning('请先选择要确认出库的出库单')
|
||||
return
|
||||
}
|
||||
|
||||
// 仅允许 CREATED / PENDING 状态进行确认
|
||||
const confirmable = rows.filter(
|
||||
(r: any) => r.order_status === 'CREATED' || r.order_status === 'PENDING'
|
||||
)
|
||||
if (!confirmable.length) {
|
||||
ElMessage.warning('所选出库单状态不支持确认操作,仅"已创建"或"待出库"状态可确认')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定要直出确认以下 ${confirmable.length} 个出库单吗?确认后状态将变更为"已完成"。请确保已在详情面板填写运单号。`,
|
||||
'确认出库',
|
||||
{ type: 'warning', confirmButtonText: '确认', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
let successCount = 0
|
||||
let failCount = 0
|
||||
for (const row of confirmable) {
|
||||
try {
|
||||
const res: any = await stockoutApi.stockoutConfirm({ id: row.id })
|
||||
// 更新列表中对应行的运单信息
|
||||
const data = res?.data || res
|
||||
if (data?.expressCode) {
|
||||
row.express_code = data.expressCode
|
||||
}
|
||||
if (data?.expressCodes) {
|
||||
row.express_codes = data.expressCodes
|
||||
}
|
||||
successCount++
|
||||
} catch (e: any) {
|
||||
failCount++
|
||||
console.error(`确认出库单 ${row.stockout_order_code || row.id} 失败`, e)
|
||||
}
|
||||
}
|
||||
|
||||
if (failCount === 0) {
|
||||
ElMessage.success(`成功确认 ${successCount} 个出库单`)
|
||||
} else {
|
||||
ElMessage.warning(`确认完成:成功 ${successCount} 个,失败 ${failCount} 个`)
|
||||
}
|
||||
loadData()
|
||||
}
|
||||
|
||||
async function handleExport(mode: 'waybill' | 'item' = 'waybill') {
|
||||
const sourceRows = selectionRows.value.length ? selectionRows.value : list.value
|
||||
if (!sourceRows.length) {
|
||||
|
||||
@ -42,14 +42,6 @@ export const stockoutToolbarButtons: ToolbarButtonConfig[] = [
|
||||
size: 'small',
|
||||
action: 'handleImport'
|
||||
},
|
||||
{
|
||||
key: 'confirmStockout',
|
||||
label: '确认出库',
|
||||
category: 'action',
|
||||
size: 'small',
|
||||
disabledKey: 'hasNoSelection',
|
||||
action: 'confirmStockout'
|
||||
},
|
||||
{
|
||||
key: 'batchCancel',
|
||||
label: '批量作废',
|
||||
@ -159,7 +151,8 @@ export const entryColums = [
|
||||
{ prop: 'remark', label: '备注', minWidth: '150' },
|
||||
{ prop: 'order_create_time', label: '下单时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.order_create_time) },
|
||||
{ prop: 'created_at', label: '创建时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.created_at) },
|
||||
{ prop: 'updated_at', label: '更新时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.updated_at) }
|
||||
{ prop: 'updated_at', label: '更新时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.updated_at) },
|
||||
{ prop: 'actions', label: '操作', width: '120', fixed: 'right' }
|
||||
]
|
||||
|
||||
export const availableFields: StockoutScanFieldConfig[] = [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user