This commit is contained in:
yin 2026-08-12 18:10:00 +08:00
parent aef02273ad
commit b3be2e11e6
12 changed files with 247 additions and 130 deletions

View File

@ -483,12 +483,45 @@ export function confirmIntercept(data: ConfirmRecheckParams): Promise<any> {
} as any) } as any)
} }
/** order.recheckOrder.interceptScan 请求参数 */
export type InterceptScanParams = {
waybill_code: string
}
/** order.recheckOrder.interceptScan 响应 data */
export type InterceptScanResponse = {
waybill_code: string
is_back: string
after_sale?: Record<string, unknown> | null
order?: {
order_id?: number
order_no?: string
intercept_status?: string
} | null
}
/** order.recheckOrder.interceptScan:拦截扫描,通过运单号标记退回并处理关联售后工单 */
export function interceptScan(data: InterceptScanParams): Promise<any> {
return request({
url: '/system',
method: 'post',
params: {
method: 'order.recheckOrder.interceptScan',
v,
timestamp: Date.now()
},
data,
isSystemApi: true
} as any)
}
export const orderRecheckOrder = { export const orderRecheckOrder = {
scanOrder, scanOrder,
batchQuickRecheck, batchQuickRecheck,
batchQuickRecheckByWave, batchQuickRecheckByWave,
confirmRecheck, confirmRecheck,
confirmIntercept, confirmIntercept,
interceptScan,
queryRecheckOrderSingleList queryRecheckOrderSingleList
} }

View File

@ -100,6 +100,17 @@ export type PickCartCodeDuplicateCheckResponse = {
status?: number | null status?: number | null
} }
export type PickCartBatchDeleteParams = {
ids: number[]
}
export type PickCartBatchDeleteResponse = {
deleted_ids: number[]
skipped_ids: number[]
deleted_count: number
skipped_count: number
}
/** pickCart.scan:按拣货车条码/编码查询拣货车信息 */ /** pickCart.scan:按拣货车条码/编码查询拣货车信息 */
export function pickCartScan( export function pickCartScan(
data: PickCartScanParams data: PickCartScanParams
@ -185,6 +196,23 @@ export function pickCartDelete(
} as any) } as any)
} }
/** pickCart.batchDelete:批量删除拣货车 */
export function pickCartBatchDelete(
data: PickCartBatchDeleteParams
): Promise<PickCartBatchDeleteResponse & { code?: number; message?: string; data?: Partial<PickCartBatchDeleteResponse> }> {
return request({
url: '/system',
method: 'post',
params: {
method: 'pickCart.batchDelete',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
/** pickCart.detail:查询拣货车详情 */ /** pickCart.detail:查询拣货车详情 */
export function pickCartDetail( export function pickCartDetail(
data: PickCartDetailParams data: PickCartDetailParams
@ -242,6 +270,7 @@ export const pickCart = {
create: pickCartCreate, create: pickCartCreate,
update: pickCartUpdate, update: pickCartUpdate,
delete: pickCartDelete, delete: pickCartDelete,
batchDelete: pickCartBatchDelete,
detail: pickCartDetail, detail: pickCartDetail,
list: pickCartList, list: pickCartList,
codeDuplicateCheck: pickCartCodeDuplicateCheck codeDuplicateCheck: pickCartCodeDuplicateCheck

View File

@ -78,9 +78,9 @@
</template> </template>
</el-dropdown> </el-dropdown>
<div class="view-btn"> <div class="view-btn">
<div class="view-change" @click="toggleLayout"> <!-- <div class="view-change" @click="toggleLayout">
<svg-icon :icon-class="layoutMode === 'sidebar' ? 'tree' : 'table'" style="font-size: 20px; color: white;" /> <svg-icon :icon-class="layoutMode === 'sidebar' ? 'tree' : 'table'" style="font-size: 20px; color: white;" />
</div> </div> -->
<div class="ai-btn" @click="toggleAi"> <div class="ai-btn" @click="toggleAi">
<img class="ai-img" /> <img class="ai-img" />
</div> </div>

View File

@ -192,6 +192,14 @@ export function getAfterSaleAvailableFields(typeFilter?: string): typeof afterSa
// -------------------- ScanBox 筛选字段 -------------------- // -------------------- ScanBox 筛选字段 --------------------
export const afterSaleAvailableFields = [ export const afterSaleAvailableFields = [
{
value: 'store_id',
label: '货主',
type: 'select',
multiple: true,
placeholder: '请选择货主',
options: [] as { label: string; value: unknown }[],
},
{ {
value: 'after_sale_no', value: 'after_sale_no',
label: '售后单号', label: '售后单号',

View File

@ -236,6 +236,7 @@ import {
} from '@/api/afterSale/index' } from '@/api/afterSale/index'
import { import {
getAfterSaleAvailableFields, getAfterSaleAvailableFields,
afterSaleAvailableFields,
afterSaleColumns, afterSaleColumns,
afterSaleToolbarButtons, afterSaleToolbarButtons,
AFTER_SALE_TYPE_MAP, AFTER_SALE_TYPE_MAP,
@ -248,6 +249,8 @@ import {
CLAIM_STATUS_MAP, CLAIM_STATUS_MAP,
CLAIM_STATUS_TAG_MAP, CLAIM_STATUS_TAG_MAP,
} from './afterSale-config' } from './afterSale-config'
import { loadStores } from '@/api/index/index'
import { extractStoreListFromResponse, fillStoreScanFieldOptions } from '@/views/order/orderManagement/config/order-common-config'
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 OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue' import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
@ -777,7 +780,19 @@ function handleViewDetail(row: any) {
// ==================== 生命周期 ==================== // ==================== 生命周期 ====================
// ==================== 货主列表加载 ====================
async function loadStoreOptions() {
try {
const storesRes: any = await loadStores()
fillStoreScanFieldOptions(afterSaleAvailableFields, extractStoreListFromResponse(storesRes))
} catch {
fillStoreScanFieldOptions(afterSaleAvailableFields, [])
}
}
onMounted(() => { onMounted(() => {
loadStoreOptions()
fetchData() fetchData()
}) })

View File

@ -56,11 +56,14 @@ export const groupColumns = [
{ prop: 'group_type', label: '群类型', width: '100' }, { prop: 'group_type', label: '群类型', width: '100' },
{ prop: 'sub_type', label: '子类型', width: '100' }, { prop: 'sub_type', label: '子类型', width: '100' },
{ prop: 'store_name', label: '货主', minWidth: '120', showOverflowTooltip: true }, { prop: 'store_name', label: '货主', minWidth: '120', showOverflowTooltip: true },
{ prop: 'source_type', label: '来源', width: '90' },
{ prop: 'source_extra', label: '来源标识', minWidth: '140', showOverflowTooltip: true },
{ prop: 'express_interfaces', label: '快递接口', minWidth: '160', showOverflowTooltip: true }, { prop: 'express_interfaces', label: '快递接口', minWidth: '160', showOverflowTooltip: true },
{ prop: 'system_express_name', label: '系统快递', width: '110', showOverflowTooltip: true }, { prop: 'system_express_name', label: '系统快递', width: '110', showOverflowTooltip: true },
{ prop: 'ai_enabled', label: 'AI回复', width: '90' }, { prop: 'ai_enabled', label: 'AI回复', width: '90' },
{ prop: 'is_blocked', label: '状态', width: '80' }, { prop: 'is_blocked', label: '状态', width: '80' },
{ prop: 'created_at', label: '创建时间', width: '170' }, { prop: 'created_at', label: '创建时间', width: '170' },
{ prop: 'updated_at', label: '更新时间', width: '170' },
{ prop: 'actions', label: '操作', width: '220', fixed: 'right' }, { prop: 'actions', label: '操作', width: '220', fixed: 'right' },
] ]

View File

@ -59,6 +59,12 @@
{{ subTypeLabel(row.sub_type) }} {{ subTypeLabel(row.sub_type) }}
</template> </template>
<template #column-source_type="{ row }">
<el-tag size="small" :type="row.source_type === 'api' ? 'success' : 'info'">
{{ row.source_type === 'api' ? 'API' : row.source_type || '-' }}
</el-tag>
</template>
<template #column-express_interfaces="{ row }"> <template #column-express_interfaces="{ row }">
<template v-if="row.express_interfaces && row.express_interfaces.length"> <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"> <el-tag v-for="(iface, idx) in row.express_interfaces" :key="idx" size="small" style="margin: 1px 2px">

View File

@ -203,6 +203,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'
import { afterSaleWorkList, afterSaleBatchSetPendingFeedback, afterSaleBatchClose, type AfterSaleListParams } from '@/api/afterSale/index' import { afterSaleWorkList, afterSaleBatchSetPendingFeedback, afterSaleBatchClose, type AfterSaleListParams } from '@/api/afterSale/index'
import { import {
getAfterSaleAvailableFields, getAfterSaleAvailableFields,
afterSaleAvailableFields,
afterSaleColumns, afterSaleColumns,
AFTER_SALE_TYPE_MAP, AFTER_SALE_TYPE_MAP,
AFTER_SALE_TYPE_TAG_MAP, AFTER_SALE_TYPE_TAG_MAP,
@ -214,6 +215,8 @@ import {
CLAIM_STATUS_MAP, CLAIM_STATUS_MAP,
CLAIM_STATUS_TAG_MAP, CLAIM_STATUS_TAG_MAP,
} from '@/views/afterSale/list/afterSale-config' } from '@/views/afterSale/list/afterSale-config'
import { loadStores } from '@/api/index/index'
import { extractStoreListFromResponse, fillStoreScanFieldOptions } from '@/views/order/orderManagement/config/order-common-config'
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config' import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
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'
@ -273,12 +276,13 @@ const availableFields = computed(() => {
const columns = afterSaleColumns const columns = afterSaleColumns
const tableSize = 'small' const tableSize = 'small'
/** 工单工具栏按钮(排序与样式对齐 storage/receiving):
* 刷新 → 基础功能(白底黑字) → 页面功能(蓝底/白底蓝字) → 取消类(红字)
*/
const toolbarButtons: ToolbarButtonConfig[] = [ const toolbarButtons: ToolbarButtonConfig[] = [
// 刷新
{ key: 'refresh', label: '刷新', category: 'refresh', size: 'small', loadingKey: 'loading', action: 'refresh' }, { key: 'refresh', label: '刷新', category: 'refresh', size: 'small', loadingKey: 'loading', action: 'refresh' },
{ key: 'create', label: '发起售后单', category: 'action', size: 'small', type: 'primary', action: 'showCreateDialog' }, // 基础功能(白底黑字)
{ key: 'batchPendingFeedback', label: '设为待反馈', category: 'action', size: 'small', type: 'warning', loadingKey: 'batchPendingFeedbackLoading', disabledKey: 'batchPendingFeedbackDisabled', action: 'batchSetPendingFeedback' },
{ key: 'batchComplete', label: '批量完成', category: 'action', size: 'small', type: 'success', loadingKey: 'batchCompleteLoading', disabledKey: 'batchPendingFeedbackDisabled', action: 'batchComplete' },
{ key: 'batchClose', label: '批量关闭', category: 'action', size: 'small', type: 'info', loadingKey: 'batchCloseLoading', disabledKey: 'batchPendingFeedbackDisabled', action: 'batchClose' },
{ key: 'columnConfig', label: '字段设置', category: 'setting', size: 'small', action: 'openColumnConfigPanel' }, { key: 'columnConfig', label: '字段设置', category: 'setting', size: 'small', action: 'openColumnConfigPanel' },
{ {
key: 'toggleDetail', key: 'toggleDetail',
@ -288,6 +292,13 @@ const toolbarButtons: ToolbarButtonConfig[] = [
size: 'small', size: 'small',
action: 'toggleDetailVisible' action: 'toggleDetailVisible'
}, },
// 页面功能:可直接点击=白底蓝字(对齐 storage/receiving "添加收货单")
{ key: 'create', label: '发起售后单', category: 'action', size: 'small', action: 'showCreateDialog' },
// 页面功能:需勾选=白底蓝字
{ key: 'batchPendingFeedback', label: '设为待反馈', category: 'action', size: 'small', loadingKey: 'batchPendingFeedbackLoading', disabledKey: 'batchPendingFeedbackDisabled', action: 'batchSetPendingFeedback' },
{ key: 'batchComplete', label: '批量完成', category: 'action', size: 'small', loadingKey: 'batchCompleteLoading', disabledKey: 'batchPendingFeedbackDisabled', action: 'batchComplete' },
// 取消类(红字)
{ key: 'batchClose', label: '批量关闭', category: 'cancel', size: 'small', loadingKey: 'batchCloseLoading', disabledKey: 'batchPendingFeedbackDisabled', action: 'batchClose' },
] ]
// ==================== 按钮状态 ==================== // ==================== 按钮状态 ====================
@ -562,7 +573,19 @@ function handleViewDetail(row: any) {
detailDialogVisible.value = true detailDialogVisible.value = true
} }
// ==================== 货主列表加载 ====================
async function loadStoreOptions() {
try {
const storesRes: any = await loadStores()
fillStoreScanFieldOptions(afterSaleAvailableFields, extractStoreListFromResponse(storesRes))
} catch {
fillStoreScanFieldOptions(afterSaleAvailableFields, [])
}
}
onMounted(() => { onMounted(() => {
loadStoreOptions()
fetchData() fetchData()
}) })
</script> </script>

View File

@ -31,10 +31,11 @@
{{ row.package_material_name_snapshot || row.package_material_code || '—' }} {{ row.package_material_name_snapshot || row.package_material_code || '—' }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" width="220" align="center" fixed="right"> <el-table-column label="操作" width="320" align="center" fixed="right">
<template #default="{ row }"> <template #default="{ row }">
<el-button link type="primary" size="small" @click="openWeighingDialog(row)">称重</el-button> <el-button link type="primary" size="small" @click="openWeighingDialog(row)">称重</el-button>
<el-button link type="success" size="small" @click="openBindDialog(row)">绑定包材</el-button> <el-button link type="success" size="small" @click="openBindDialog(row)">绑定包材</el-button>
<el-button link type="danger" size="small" @click="handleInterceptScan(row)">库内拦截确认</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -73,8 +74,9 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, reactive, ref, watch } from 'vue' import { computed, reactive, ref, watch } from 'vue'
import { ElMessage } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import { orderDetail, orderUpdateExpressWeighingWeight } from '@/api/order.index/orderindex' import { orderDetail, orderUpdateExpressWeighingWeight } from '@/api/order.index/orderindex'
import { interceptScan } from '@/api/order.recheckorder/recheckOrder'
import { isOrderIndexApiSuccess, parseOrderDetailPayload, normalizeOrderExpressList } from '../utils/order-index-helpers' import { isOrderIndexApiSuccess, parseOrderDetailPayload, normalizeOrderExpressList } from '../utils/order-index-helpers'
import BindPackageMaterialByWaybillDialog from './BindPackageMaterialByWaybillDialog.vue' import BindPackageMaterialByWaybillDialog from './BindPackageMaterialByWaybillDialog.vue'
@ -166,6 +168,35 @@ function resetWeighingForm() {
weighingForm.weighing_weight = undefined weighingForm.weighing_weight = undefined
} }
async function handleInterceptScan(row: any) {
const waybillCode = row?.waybill_code
if (!waybillCode) {
ElMessage.warning('该运单无运单号,无法执行拦截')
return
}
try {
await ElMessageBox.confirm(
`确认对运单「${waybillCode}」执行库内拦截吗?该操作将标记运单退回并处理关联售后工单。`,
'库内拦截确认',
{ type: 'warning', confirmButtonText: '确认拦截', cancelButtonText: '取消' }
)
} catch {
return
}
try {
const res: any = await interceptScan({ waybill_code: waybillCode })
const data = res?.data ?? res
if (res?.code === 1 || res?.code === 200 || data?.is_back === 'Y') {
ElMessage.success(`运单「${waybillCode}」拦截成功,已标记退回`)
await loadDetail()
} else {
ElMessage.error(res?.message || '拦截操作失败')
}
} catch (error: any) {
ElMessage.error(error?.message || '拦截操作失败')
}
}
async function submitWeighing() { async function submitWeighing() {
if (!orderId.value || weighingSaving.value) return if (!orderId.value || weighingSaving.value) return
if (!weighingForm.weighing_weight || weighingForm.weighing_weight <= 0) { if (!weighingForm.weighing_weight || weighingForm.weighing_weight <= 0) {

View File

@ -138,10 +138,9 @@ function emitAction(action: ToolbarButtonConfig['action']) {
emit('action', action) emit('action', action)
} }
/** 按钮 key → 强制样式覆盖(绕过模块缓存) */ /** 按钮 key → 强制样式覆盖,仅用于跨视图统一特定按钮样式 */
const BUTTON_STYLE_OVERRIDE: Record<string, { type: string; plain: boolean }> = { const BUTTON_STYLE_OVERRIDE: Record<string, { type: string; plain: boolean }> = {
batchComplete: { type: 'warning', plain: false }, // 各视图通过 category + type 自行控制样式
batchClose: { type: 'danger', plain: false },
} }
/** 根据 category 或 type/plain 解析按钮样式 */ /** 根据 category 或 type/plain 解析按钮样式 */
@ -156,7 +155,7 @@ function resolveButtonStyle(button: ToolbarButtonConfig): { type: string; plain:
case 'action': case 'action':
if (button.type) return { type: button.type, plain: false } if (button.type) return { type: button.type, plain: false }
return { type: 'primary', plain: true } return { type: 'primary', plain: true }
case 'cancel': return { type: 'danger', plain: false } case 'cancel': return { type: 'danger', plain: true }
default: return { type: button.type || 'default', plain: !!button.plain } default: return { type: button.type || 'default', plain: !!button.plain }
} }
} }

View File

@ -39,11 +39,13 @@
:pagination="pagination" :pagination="pagination"
:show-index="true" :show-index="true"
:show-actions="true" :show-actions="true"
:show-selection="showSelection"
:loading="loading" :loading="loading"
:query-time="queryTime" :query-time="queryTime"
row-key="cart_id" row-key="cart_id"
@current-change="handleRowClick" @current-change="handleRowClick"
@row-click="handleRowClick" @row-click="handleRowClick"
@selection-change="handleSelectionChange"
@page-change="handlePageChange" @page-change="handlePageChange"
@page-size-change="handlePageSizeChange" @page-size-change="handlePageSizeChange"
@refresh="loadList" @refresh="loadList"
@ -216,39 +218,15 @@
<el-divider /> <el-divider />
<div class="batch-section-title">拣货车名称</div> <div class="batch-section-title">拣货车名称</div>
<el-form-item label="名称前缀" prop="name.prefix"> <el-form-item label="名称前缀">
<el-input v-model="batchForm.name.prefix" placeholder="留空则不生成名称" maxlength="64" show-word-limit /> <el-input v-model="batchForm.namePrefix" placeholder="留空则不生成名称,序号与编码共用" maxlength="64" show-word-limit />
</el-form-item>
<el-form-item v-if="batchForm.namePrefix.trim()" label="位置">
<el-radio-group v-model="batchForm.namePosition">
<el-radio value="prefix">前缀(如:拣货车01)</el-radio>
<el-radio value="suffix">后缀(如:01拣货车)</el-radio>
</el-radio-group>
</el-form-item> </el-form-item>
<template v-if="batchForm.name.prefix.trim()">
<el-form-item label="数字范围" required>
<div class="batch-range-row">
<el-form-item prop="name.start_num" class="batch-range-item">
<el-input-number v-model="batchForm.name.start_num" :min="0" :max="999999" controls-position="right" />
</el-form-item>
<span class="batch-range-sep">至</span>
<el-form-item prop="name.end_num" class="batch-range-item">
<el-input-number v-model="batchForm.name.end_num" :min="0" :max="999999" controls-position="right" />
</el-form-item>
</div>
</el-form-item>
<el-form-item label="数字补零">
<el-switch v-model="batchForm.name.pad_zero" />
<el-input-number
v-if="batchForm.name.pad_zero"
v-model="batchForm.name.pad_width"
:min="1"
:max="8"
controls-position="right"
class="batch-pad-width"
/>
<el-text v-if="batchForm.name.pad_zero" type="info" size="small" class="batch-pad-hint">
位数 {{ batchForm.name.pad_width }},不足时左侧补 0
</el-text>
</el-form-item>
<el-form-item v-if="batchNameRangeMismatch">
<el-text type="danger" size="small">名称数量需与编码数量一致(当前编码 {{ codeBatchCount }} 条,名称 {{ nameBatchCount }} 条)</el-text>
</el-form-item>
</template>
<el-divider /> <el-divider />
@ -324,6 +302,7 @@ import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/o
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane' import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
import InfoPanel from './components/InfoPanel.vue' import InfoPanel from './components/InfoPanel.vue'
import { import {
pickCartBatchDelete,
pickCartBindTaskCart, pickCartBindTaskCart,
pickCartCodeDuplicateCheck, pickCartCodeDuplicateCheck,
pickCartCreate, pickCartCreate,
@ -347,6 +326,7 @@ import {
pickCartScanFields, pickCartScanFields,
type PickCartRecord type PickCartRecord
} from './pickcart-config' } from './pickcart-config'
import type { PickCartBatchDeleteParams } from '@/api/pickcart/pickcart'
const settingsStore = useSettingsStore() const settingsStore = useSettingsStore()
const scanBox = ref<any>(null) const scanBox = ref<any>(null)
@ -387,10 +367,12 @@ const toolbarButtons: ToolbarButtonConfig[] = [
{ key: 'toggleDetail', label: '显示详情', dynamicLabelKey: 'detailToggleLabel', category: 'setting', size: 'small', action: 'toggleDetail' }, { key: 'toggleDetail', label: '显示详情', dynamicLabelKey: 'detailToggleLabel', category: 'setting', size: 'small', action: 'toggleDetail' },
{ key: 'scanQuery', label: '扫码查询', category: 'setting', size: 'small', action: 'openScanDialog' }, { key: 'scanQuery', label: '扫码查询', category: 'setting', size: 'small', action: 'openScanDialog' },
{ key: 'create', label: '新增拣货车', category: 'action', size: 'small', action: 'openCreate' }, { key: 'create', label: '新增拣货车', category: 'action', size: 'small', action: 'openCreate' },
{ key: 'batchCreate', label: '批量新增', category: 'action', size: 'small', action: 'openBatchCreate' } { key: 'batchCreate', label: '批量新增', category: 'action', size: 'small', action: 'openBatchCreate' },
{ key: 'batchDelete', label: '批量删除', category: 'action', size: 'small', action: 'handleBatchDelete' }
] ]
function resolveButtonDisabled(_key?: string): boolean { function resolveButtonDisabled(key?: string): boolean {
if (key === 'batchDelete') return selectedRows.value.length === 0
return false return false
} }
@ -408,7 +390,8 @@ const toolbarActionMap: Record<string, () => void> = {
toggleDetail, toggleDetail,
openScanDialog, openScanDialog,
openCreate, openCreate,
openBatchCreate openBatchCreate,
handleBatchDelete
} }
function handleToolbarButtonClick(action: string) { function handleToolbarButtonClick(action: string) {
@ -466,38 +449,39 @@ const bindRules: FormRules = {
task_id: [{ required: true, message: '请输入任务ID', trigger: 'blur' }] task_id: [{ required: true, message: '请输入任务ID', trigger: 'blur' }]
} }
// ---- 批量选择(用于批量删除)----
const showSelection = ref(true)
const selectedRows = ref<PickCartRecord[]>([])
function handleSelectionChange(rows: PickCartRecord[]) {
selectedRows.value = rows
}
const batchDialogVisible = ref(false) const batchDialogVisible = ref(false)
const batchSaving = ref(false) const batchSaving = ref(false)
const batchFormRef = ref<FormInstance>() const batchFormRef = ref<FormInstance>()
function createDefaultBatchNumberRule(start = 1, end = 10) {
return {
prefix: '',
start_num: start,
end_num: end,
pad_zero: true,
pad_width: getDefaultPickCartBatchPadWidth(start, end)
}
}
const batchForm = reactive({ const batchForm = reactive({
code: createDefaultBatchNumberRule(), code: {
name: { prefix: '',
...createDefaultBatchNumberRule(), start_num: 1,
prefix: '拣货车' end_num: 10,
pad_zero: true,
pad_width: 2
}, },
namePrefix: '',
namePosition: 'prefix' as 'prefix' | 'suffix',
status: 1 status: 1
}) })
function createBatchRangeValidator(section: 'code' | 'name') { function createBatchRangeValidator() {
return (_rule: unknown, _value: unknown, callback: (error?: Error) => void) => { return (_rule: unknown, _value: unknown, callback: (error?: Error) => void) => {
const rule = batchForm[section] const count = getPickCartBatchRangeCount(batchForm.code.start_num, batchForm.code.end_num)
const count = getPickCartBatchRangeCount(rule.start_num, rule.end_num)
if (count <= 0) { if (count <= 0) {
callback(new Error('请输入有效的数字范围')) callback(new Error('请输入有效的数字范围'))
return return
} }
if (section === 'code' && count > PICK_CART_BATCH_CREATE_MAX) { if (count > PICK_CART_BATCH_CREATE_MAX) {
callback(new Error(`单次最多新增 ${PICK_CART_BATCH_CREATE_MAX} 条`)) callback(new Error(`单次最多新增 ${PICK_CART_BATCH_CREATE_MAX} 条`))
return return
} }
@ -505,29 +489,10 @@ function createBatchRangeValidator(section: 'code' | 'name') {
} }
} }
const validateBatchNameRange = (_rule: unknown, _value: unknown, callback: (error?: Error) => void) => {
if (!batchForm.name.prefix.trim()) {
callback()
return
}
const nameCount = getPickCartBatchRangeCount(batchForm.name.start_num, batchForm.name.end_num)
if (nameCount <= 0) {
callback(new Error('请输入有效的名称数字范围'))
return
}
if (nameCount !== codeBatchCount.value) {
callback(new Error('名称数量需与编码数量一致'))
return
}
callback()
}
const batchRules: FormRules = { const batchRules: FormRules = {
'code.prefix': [{ required: true, message: '请输入编码前缀', trigger: 'blur' }], 'code.prefix': [{ required: true, message: '请输入编码前缀', trigger: 'blur' }],
'code.start_num': [{ validator: createBatchRangeValidator('code'), trigger: 'change' }], 'code.start_num': [{ validator: createBatchRangeValidator(), trigger: 'change' }],
'code.end_num': [{ validator: createBatchRangeValidator('code'), trigger: 'change' }], 'code.end_num': [{ validator: createBatchRangeValidator(), trigger: 'change' }],
'name.start_num': [{ validator: validateBatchNameRange, trigger: 'change' }],
'name.end_num': [{ validator: validateBatchNameRange, trigger: 'change' }],
status: [{ required: true, message: '请选择状态', trigger: 'change' }] status: [{ required: true, message: '请选择状态', trigger: 'change' }]
} }
@ -535,22 +500,10 @@ const codeBatchCount = computed(() =>
getPickCartBatchRangeCount(batchForm.code.start_num, batchForm.code.end_num) getPickCartBatchRangeCount(batchForm.code.start_num, batchForm.code.end_num)
) )
const nameBatchCount = computed(() =>
batchForm.name.prefix.trim()
? getPickCartBatchRangeCount(batchForm.name.start_num, batchForm.name.end_num)
: 0
)
const batchNameRangeMismatch = computed(() => {
if (!batchForm.name.prefix.trim()) return false
return nameBatchCount.value > 0 && nameBatchCount.value !== codeBatchCount.value
})
const batchPreviewItems = computed(() => { const batchPreviewItems = computed(() => {
try { try {
if (!batchForm.code.prefix.trim() || codeBatchCount.value <= 0) return [] if (!batchForm.code.prefix.trim() || codeBatchCount.value <= 0) return []
if (codeBatchCount.value > PICK_CART_BATCH_CREATE_MAX) return [] if (codeBatchCount.value > PICK_CART_BATCH_CREATE_MAX) return []
if (batchNameRangeMismatch.value) return []
return buildPickCartBatchItems(batchForm) return buildPickCartBatchItems(batchForm)
} catch { } catch {
return [] return []
@ -578,17 +531,6 @@ watch(
} }
) )
watch(
() => [batchForm.name.start_num, batchForm.name.end_num, batchForm.name.pad_zero] as const,
() => {
if (!batchForm.name.pad_zero) return
batchForm.name.pad_width = getDefaultPickCartBatchPadWidth(
batchForm.name.start_num,
batchForm.name.end_num
)
}
)
const isSuccess = (res: any) => res && [0, 1, 200].includes(res.code) const isSuccess = (res: any) => res && [0, 1, 200].includes(res.code)
async function loadList() { async function loadList() {
@ -685,13 +627,8 @@ function resetBatchForm() {
pad_zero: true, pad_zero: true,
pad_width: 2 pad_width: 2
} }
batchForm.name = { batchForm.namePrefix = ''
prefix: '拣货车', batchForm.namePosition = 'prefix'
start_num: 1,
end_num: 10,
pad_zero: false,
pad_width: 1
}
batchForm.status = 1 batchForm.status = 1
batchFormRef.value?.clearValidate() batchFormRef.value?.clearValidate()
} }
@ -868,6 +805,40 @@ function handleDelete(row: PickCartRecord) {
.catch(() => undefined) .catch(() => undefined)
} }
function handleBatchDelete() {
const rows = selectedRows.value
if (!rows.length) {
ElMessage.warning('请先选择要删除的拣货车')
return
}
const ids = rows.map((r) => r.cart_id).filter((id): id is number => typeof id === 'number')
if (!ids.length) return
ElMessageBox.confirm(
`确认批量删除 ${ids.length} 辆拣货车吗?已绑定任务的拣货车将被跳过。`,
'批量删除确认',
{ type: 'warning' }
)
.then(async () => {
const res: any = await pickCartBatchDelete({ ids } as PickCartBatchDeleteParams)
if (!isSuccess(res)) {
ElMessage.error(res?.message || '批量删除失败')
return
}
const data = res?.data || {}
const deleted = data.deleted_count ?? 0
const skipped = data.skipped_count ?? 0
if (skipped > 0) {
ElMessage.warning(`批量删除完成:成功 ${deleted} 条,跳过 ${skipped} 条(已绑定任务)`)
} else {
ElMessage.success(`批量删除成功,共 ${deleted} 条`)
}
selectedRows.value = []
loadList()
})
.catch(() => undefined)
}
function toggleDetail() { function toggleDetail() {
detailVisible.value = !detailVisible.value detailVisible.value = !detailVisible.value
} }

View File

@ -134,7 +134,8 @@ export type PickCartBatchNumberRule = {
export type PickCartBatchCreateForm = { export type PickCartBatchCreateForm = {
code: PickCartBatchNumberRule code: PickCartBatchNumberRule
name: PickCartBatchNumberRule namePrefix: string
namePosition: 'prefix' | 'suffix'
status: number status: number
} }
@ -184,32 +185,30 @@ export function getPickCartBatchRangeCount(start: number, end: number) {
return safeEnd - safeStart + 1 return safeEnd - safeStart + 1
} }
/** 编码与名称分别按各自前缀、范围和补零规则生成,再按序号一一对应 */ /** 按编码前缀、范围和补零规则生成批量拣货车条目;名称前缀共用编码数字范围 */
export function buildPickCartBatchItems(form: PickCartBatchCreateForm): PickCartBatchCreateItem[] { export function buildPickCartBatchItems(form: PickCartBatchCreateForm): PickCartBatchCreateItem[] {
const codeStart = Math.floor(Number(form.code.start_num)) const codeStart = Math.floor(Number(form.code.start_num))
const codeEnd = Math.floor(Number(form.code.end_num)) const codeEnd = Math.floor(Number(form.code.end_num))
const codePrefix = String(form.code.prefix ?? '').trim() const codePrefix = String(form.code.prefix ?? '').trim()
const namePrefix = String(form.name.prefix ?? '').trim() const namePrefix = String(form.namePrefix ?? '').trim()
const codeCount = getPickCartBatchRangeCount(codeStart, codeEnd) const codeCount = getPickCartBatchRangeCount(codeStart, codeEnd)
if (!codePrefix || codeCount <= 0) return [] if (!codePrefix || codeCount <= 0) return []
const nameCount = namePrefix
? getPickCartBatchRangeCount(form.name.start_num, form.name.end_num)
: 0
if (namePrefix && nameCount !== codeCount) return []
const items: PickCartBatchCreateItem[] = [] const items: PickCartBatchCreateItem[] = []
for (let i = 0; i < codeCount; i += 1) { for (let i = 0; i < codeCount; i += 1) {
const cart_code = buildPickCartBatchValue(form.code, codeStart + i) const num = codeStart + i
const cart_code = buildPickCartBatchValue(form.code, num)
const item: PickCartBatchCreateItem = { cart_code } const item: PickCartBatchCreateItem = { cart_code }
if (namePrefix) { if (namePrefix) {
const nameStart = Math.floor(Number(form.name.start_num)) const paddedNum = formatPickCartBatchNumber(num, {
item.cart_name = buildPickCartBatchValue(form.name, nameStart + i) pad_zero: form.code.pad_zero,
pad_width: resolvePickCartBatchPadWidth(form.code)
})
item.cart_name = form.namePosition === 'suffix'
? `${paddedNum}${namePrefix}`
: `${namePrefix}${paddedNum}`
} }
items.push(item) items.push(item)
} }
return items return items