1
This commit is contained in:
parent
b92745c8ec
commit
637a1092cc
@ -37,8 +37,10 @@ export function returnUnpackCreate(data: ReturnUnpackCreateParams): Promise<any>
|
||||
export type ReturnUnpackAddDetailParams = {
|
||||
/** 拆包单ID(returnUnpack.create 返回的依据) */
|
||||
id: number
|
||||
/** 系统商品ID(wms_stock_warehouse.id),为空即无关联货物 */
|
||||
stock_id?: number
|
||||
/** 系统商品ID(wms_stock_warehouse.id),为空即无关联货物(商品名称标注未知商品) */
|
||||
stock_id?: number | null
|
||||
/** 扫描条码(最长100字符,仅作记录,不参与商品匹配) */
|
||||
barcode?: string
|
||||
/** 数量,默认 1(小于 1 按 1 处理) */
|
||||
quantity?: number
|
||||
/** 产品状态:normal 正常(默认)/ damaged 破损 */
|
||||
|
||||
161
src/api/returnwaybill/index.ts
Normal file
161
src/api/returnwaybill/index.ts
Normal file
@ -0,0 +1,161 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
const v = '1.0'
|
||||
|
||||
// ============ returnWaybill.create ============
|
||||
|
||||
/** returnWaybill.create 请求参数 */
|
||||
export type ReturnWaybillCreateParams = {
|
||||
/** 运单号(登记入参,必填,trim 后不能为空) */
|
||||
waybill_code: string
|
||||
/** 货主ID(必填,正整数,需存在 wms_store_warehouse 中 store_id + warehouse_id 合约记录) */
|
||||
store_id: number
|
||||
/** 备注(可选,最长 500 字符,超出截断) */
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** returnWaybill.create:运单退回登记(录入「货主 + 运单号」退回关系) */
|
||||
export function returnWaybillCreate(data: ReturnWaybillCreateParams): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'returnWaybill.create',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
// ============ returnWaybill.update ============
|
||||
|
||||
/** returnWaybill.update 请求参数 */
|
||||
export type ReturnWaybillUpdateParams = {
|
||||
/** 登记记录主键ID(必填,正整数) */
|
||||
id: number
|
||||
/** 运单号(可选,改运单号,trim 后不能为空字符串) */
|
||||
waybill_code?: string
|
||||
/** 货主ID(可选,改货主ID;变更时校验新货主在当前仓库的合约) */
|
||||
store_id?: number
|
||||
/** 备注(可选,最长 500 字符,超出截断) */
|
||||
remark?: string
|
||||
}
|
||||
|
||||
/** returnWaybill.update:修改登记(id 必填,可改 waybill_code/store_id/remark) */
|
||||
export function returnWaybillUpdate(data: ReturnWaybillUpdateParams): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'returnWaybill.update',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
// ============ returnWaybill.list ============
|
||||
|
||||
/** returnWaybill.list 的 where 筛选条件 */
|
||||
export type ReturnWaybillListWhere = {
|
||||
/** 运单号(模糊搜索,传 {operator:'like',value} 或直接值) */
|
||||
waybill_code?: string | { operator: string; value: any }
|
||||
/** 货主ID(等值) */
|
||||
store_id?: number
|
||||
/** 是否已通知(等值):1 已通知 / 0 未通知 */
|
||||
is_notified?: 0 | 1
|
||||
/** 是否退回(等值):1 已退回 / 0 未退回 */
|
||||
is_back?: 0 | 1
|
||||
/** 登记日期范围 { operator:'between'|'gte'|'lte'|'gt'|'lt', value:[start,end] 或单值 } */
|
||||
created_at?: { operator: 'between' | 'gte' | 'lte' | 'gt' | 'lt'; value: [string, string] | string }
|
||||
}
|
||||
|
||||
/** returnWaybill.list 排序参数 */
|
||||
export type ReturnWaybillListSort = {
|
||||
/** 排序字段 */
|
||||
sortField?: 'id' | 'created_at' | 'updated_at' | 'waybill_code'
|
||||
/** 排序方向:asc / desc */
|
||||
sortOrder?: 'asc' | 'desc'
|
||||
}
|
||||
|
||||
/** returnWaybill.list 请求参数 */
|
||||
export type ReturnWaybillListParams = {
|
||||
pagination?: { page?: number; pageSize?: number }
|
||||
where?: ReturnWaybillListWhere
|
||||
sort?: ReturnWaybillListSort
|
||||
}
|
||||
|
||||
/** returnWaybill.list:运单退回登记分页列表(仓库隔离,服务端注入 warehouse_id) */
|
||||
export function returnWaybillList(data: ReturnWaybillListParams = {}): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'returnWaybill.list',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
// ============ returnWaybill.detail ============
|
||||
|
||||
/** returnWaybill.detail 请求参数 */
|
||||
export type ReturnWaybillDetailParams = {
|
||||
/** 登记记录主键ID(必填,正整数) */
|
||||
id: number
|
||||
}
|
||||
|
||||
/** returnWaybill.detail:运单退回登记详情(仓库隔离校验) */
|
||||
export function returnWaybillDetail(data: ReturnWaybillDetailParams): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'returnWaybill.detail',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
// ============ returnWaybill.delete ============
|
||||
|
||||
/** returnWaybill.delete 请求参数 */
|
||||
export type ReturnWaybillDeleteParams = {
|
||||
/** 登记记录主键ID(必填,正整数) */
|
||||
id: number
|
||||
}
|
||||
|
||||
/** returnWaybill.delete:删除运单退回登记(物理删除,表 paranoid:false) */
|
||||
export function returnWaybillDelete(data: ReturnWaybillDeleteParams): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'returnWaybill.delete',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
// ============ 模块导出 ============
|
||||
|
||||
export const returnWaybillModule = {
|
||||
create: returnWaybillCreate,
|
||||
update: returnWaybillUpdate,
|
||||
list: returnWaybillList,
|
||||
detail: returnWaybillDetail,
|
||||
delete: returnWaybillDelete
|
||||
}
|
||||
@ -33,6 +33,7 @@ export type SettingWarehouseSenderConfig = {
|
||||
district_name?: string
|
||||
town_name?: string
|
||||
address?: string
|
||||
receiver_address?: string
|
||||
}
|
||||
|
||||
export const WAREHOUSE_SENDER_FIELD_KEYS = [
|
||||
@ -42,7 +43,8 @@ export const WAREHOUSE_SENDER_FIELD_KEYS = [
|
||||
'city_name',
|
||||
'district_name',
|
||||
'town_name',
|
||||
'address'
|
||||
'address',
|
||||
'receiver_address'
|
||||
] as const
|
||||
|
||||
export const DEFAULT_WAREHOUSE_SENDER_FIELDS: Required<SettingWarehouseSenderConfig> = {
|
||||
@ -52,7 +54,8 @@ export const DEFAULT_WAREHOUSE_SENDER_FIELDS: Required<SettingWarehouseSenderCon
|
||||
city_name: '',
|
||||
district_name: '',
|
||||
town_name: '',
|
||||
address: ''
|
||||
address: '',
|
||||
receiver_address: ''
|
||||
}
|
||||
|
||||
/** 与 module setting.warehouse 文档 subject_config 对齐 */
|
||||
|
||||
@ -79,6 +79,7 @@ export default {
|
||||
'inbox_groups':'groups',
|
||||
'returnReceived':'Return Received',
|
||||
'returnUnpack':'Return Unpack',
|
||||
'returnwaybill':'Return Waybill',
|
||||
},
|
||||
"login": {
|
||||
"title": "Login",
|
||||
|
||||
@ -82,6 +82,7 @@ export default {
|
||||
'inbox_groups':'群组',
|
||||
'returnReceived':'退回收件',
|
||||
'returnUnpack':'退回拆包',
|
||||
'returnwaybill':'退回运单',
|
||||
},
|
||||
"login": {
|
||||
"title": "登录",
|
||||
|
||||
@ -75,4 +75,6 @@ export const componentMap: Record<string, any> = {
|
||||
'inbox/message/index': () => import('@/views/inbox/message/index.vue'),
|
||||
'inbox/group/index': () => import('@/views/inbox/group/index.vue'),
|
||||
'express/returnUnpack/index': () => import('@/views/express/returnUnpack/index.vue'),
|
||||
'express/returnwaybill/index': () => import('@/views/express/returnwaybill/index.vue'),
|
||||
'express/returnUnpackwork/index': () => import('@/views/express/returnUnpackwork/index.vue'),
|
||||
};
|
||||
197
src/views/express/returnUnpack/components/StockPickerDialog.vue
Normal file
197
src/views/express/returnUnpack/components/StockPickerDialog.vue
Normal file
@ -0,0 +1,197 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
title="选择商品"
|
||||
width="760px"
|
||||
align-center
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
@closed="handleClosed"
|
||||
>
|
||||
<div class="picker-toolbar">
|
||||
<el-input
|
||||
v-model="keyword"
|
||||
placeholder="商品编码 / 条码 / 名称"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter="handleSearch"
|
||||
/>
|
||||
<el-button type="primary" size="small" :loading="loading" @click="handleSearch">搜索</el-button>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
ref="tableRef"
|
||||
:data="list"
|
||||
border
|
||||
size="small"
|
||||
max-height="360"
|
||||
v-loading="loading"
|
||||
highlight-current-row
|
||||
empty-text="暂无商品,请输入关键字搜索"
|
||||
@current-change="handleCurrentChange"
|
||||
>
|
||||
<el-table-column prop="item_code" label="商品编码" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="item_name" label="商品名称" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="barcode" label="条码" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="store_id" label="货主ID" width="90" />
|
||||
</el-table>
|
||||
|
||||
<div class="picker-meta">{{ currentRow ? `已选:${formatRowLabel(currentRow)}` : '未选择商品' }}</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" :disabled="!currentRow" @click="handleConfirm">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { warehouseSearch, stockWarehouse } from '@/api/stock/stock'
|
||||
import {
|
||||
isStockApiSuccess,
|
||||
parseStockWarehouseSearch,
|
||||
mapStockPickerItem,
|
||||
} from '@/views/order/orderManagement/utils/stock-picker-helpers'
|
||||
import { parseStockWarehouseListResponse } from '@/views/stock/combo_stock/combo-stock-config'
|
||||
|
||||
export type StockPickerItem = {
|
||||
id: number
|
||||
item_code: string
|
||||
item_name: string
|
||||
barcode: string
|
||||
store_id?: number
|
||||
}
|
||||
|
||||
const PICKER_LIST_PAGE_SIZE = 50
|
||||
|
||||
const visible = defineModel<boolean>({ default: false })
|
||||
|
||||
const props = withDefaults(defineProps<{ storeId?: number; initialKeyword?: string }>(), {
|
||||
storeId: undefined,
|
||||
initialKeyword: '',
|
||||
})
|
||||
|
||||
const emit = defineEmits<{ confirm: [item: StockPickerItem] }>()
|
||||
|
||||
const loading = ref(false)
|
||||
const keyword = ref('')
|
||||
const list = ref<StockPickerItem[]>([])
|
||||
const currentRow = ref<StockPickerItem | null>(null)
|
||||
const tableRef = ref<any>(null)
|
||||
|
||||
watch(visible, (opened) => {
|
||||
if (!opened) return
|
||||
keyword.value = props.initialKeyword || ''
|
||||
currentRow.value = null
|
||||
if (props.initialKeyword) {
|
||||
handleSearch()
|
||||
} else {
|
||||
loadInitialList()
|
||||
}
|
||||
})
|
||||
|
||||
function mapRow(row: any): StockPickerItem | null {
|
||||
const mapped = mapStockPickerItem(row)
|
||||
const id = Number(mapped.item_id)
|
||||
if (!Number.isInteger(id) || id <= 0) return null
|
||||
const storeId = Number(mapped.store_id ?? row?.store_id)
|
||||
return {
|
||||
id,
|
||||
item_code: String(mapped.item_code ?? ''),
|
||||
item_name: String(mapped.item_name ?? ''),
|
||||
barcode: String(mapped.barcode ?? ''),
|
||||
store_id: Number.isFinite(storeId) && storeId > 0 ? storeId : undefined,
|
||||
}
|
||||
}
|
||||
|
||||
function mapRows(rawList: unknown[]): StockPickerItem[] {
|
||||
return rawList.map((row) => mapRow(row)).filter((item): item is StockPickerItem => item != null)
|
||||
}
|
||||
|
||||
function formatRowLabel(item: StockPickerItem): string {
|
||||
const parts = [item.item_code, item.item_name].filter(Boolean)
|
||||
return parts.join(' ') || String(item.id)
|
||||
}
|
||||
|
||||
async function loadInitialList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const where: Record<string, unknown> = {}
|
||||
if (props.storeId) where.store_id = props.storeId
|
||||
const res: any = await stockWarehouse({ page: 1, pageSize: PICKER_LIST_PAGE_SIZE }, where)
|
||||
if (!isStockApiSuccess(res)) {
|
||||
list.value = []
|
||||
return
|
||||
}
|
||||
const { list: rawList } = parseStockWarehouseListResponse(res)
|
||||
list.value = mapRows(rawList)
|
||||
} catch {
|
||||
list.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSearch() {
|
||||
const text = keyword.value.trim()
|
||||
if (!text) {
|
||||
ElMessage.warning('请输入搜索关键字')
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const params: { keyword: string; store_id?: number } = { keyword: text }
|
||||
if (props.storeId) params.store_id = props.storeId
|
||||
const res: any = await warehouseSearch(params)
|
||||
if (!isStockApiSuccess(res)) {
|
||||
list.value = []
|
||||
ElMessage.error(res?.message || '搜索商品失败')
|
||||
return
|
||||
}
|
||||
const { list: rawList } = parseStockWarehouseSearch(res)
|
||||
list.value = mapRows(rawList)
|
||||
} catch {
|
||||
list.value = []
|
||||
ElMessage.error('搜索商品失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleCurrentChange(row: StockPickerItem | null) {
|
||||
currentRow.value = row
|
||||
}
|
||||
|
||||
function handleConfirm() {
|
||||
if (!currentRow.value) return
|
||||
emit('confirm', { ...currentRow.value })
|
||||
visible.value = false
|
||||
}
|
||||
|
||||
function handleClosed() {
|
||||
keyword.value = ''
|
||||
list.value = []
|
||||
currentRow.value = null
|
||||
tableRef.value?.setCurrentRow?.()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.picker-toolbar {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.el-input {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.picker-meta {
|
||||
margin-top: 10px;
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
}
|
||||
</style>
|
||||
@ -24,30 +24,6 @@
|
||||
@action="handleToolbarButtonClick"
|
||||
/>
|
||||
<el-divider direction="vertical" />
|
||||
<div class="scan-create">
|
||||
<el-input
|
||||
v-model="createForm.waybillCode"
|
||||
size="small"
|
||||
class="create-input"
|
||||
placeholder="退回运单号(扫码/输入)"
|
||||
clearable
|
||||
@keyup.enter="handleCreate"
|
||||
/>
|
||||
<el-input
|
||||
v-model="createForm.remark"
|
||||
size="small"
|
||||
class="create-remark"
|
||||
placeholder="备注(可选)"
|
||||
clearable
|
||||
@keyup.enter="handleCreate"
|
||||
/>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
:loading="createLoading"
|
||||
@click="handleCreate"
|
||||
>开拆包单</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -99,21 +75,6 @@
|
||||
<template #column-actions="{ row }">
|
||||
<div class="operation-actions">
|
||||
<el-button size="small" type="primary" link @click.stop="handleViewDetail(row)">详情</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'unpacking'"
|
||||
size="small"
|
||||
type="success"
|
||||
link
|
||||
@click.stop="handleSubmit(row)"
|
||||
>提交</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'unpacking'"
|
||||
size="small"
|
||||
type="warning"
|
||||
link
|
||||
@click.stop="handleCancel(row)"
|
||||
>取消</el-button>
|
||||
<el-button size="small" type="danger" link @click.stop="handleDelete(row)">删除</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -189,12 +150,6 @@
|
||||
<!-- 明细表格 -->
|
||||
<div class="detail-list-header">
|
||||
<span class="detail-list-title">拆包明细({{ detailList.length }})</span>
|
||||
<el-button
|
||||
v-if="detailRecord.status === 'unpacking'"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="openAddDetail"
|
||||
>录明细</el-button>
|
||||
</div>
|
||||
<el-table :data="detailList" size="small" border class="detail-table" empty-text="暂无明细">
|
||||
<el-table-column prop="id" label="明细ID" width="80" />
|
||||
@ -221,76 +176,25 @@
|
||||
</el-table-column>
|
||||
<el-table-column prop="quantity" label="数量" width="80" />
|
||||
<el-table-column prop="remark" label="备注" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column v-if="detailRecord.status === 'unpacking'" label="操作" width="130" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button size="small" type="primary" link @click="openEditDetail(row)">编辑</el-button>
|
||||
<el-button size="small" type="danger" link @click="handleRemoveDetail(row)">移除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<template v-if="detailRecord?.status === 'unpacking'">
|
||||
<el-button type="success" :loading="submitLoading" @click="handleSubmit(detailRecord)">提交确认</el-button>
|
||||
<el-button type="warning" :loading="cancelLoading" @click="handleCancel(detailRecord)">取消拆包</el-button>
|
||||
</template>
|
||||
<el-button type="danger" :loading="deleteLoading" @click="handleDelete(detailRecord)">删除</el-button>
|
||||
<el-button @click="detailVisible = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- ========== 录明细 / 编辑明细弹窗 ========== -->
|
||||
<el-dialog
|
||||
v-model="detailFormVisible"
|
||||
:title="detailForm.isEdit ? '编辑明细' : '录明细'"
|
||||
width="480px"
|
||||
destroy-on-close
|
||||
align-center
|
||||
>
|
||||
<el-form :model="detailForm" label-width="90px" size="small">
|
||||
<el-form-item label="商品ID">
|
||||
<el-input
|
||||
v-model="detailForm.stockId"
|
||||
placeholder="系统商品ID,留空表示无关联货物"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="数量">
|
||||
<el-input-number v-model="detailForm.quantity" :min="1" :max="999999" class="full-width" />
|
||||
</el-form-item>
|
||||
<el-form-item label="产品状态">
|
||||
<el-select v-model="detailForm.productStatus" placeholder="请选择产品状态" class="full-width">
|
||||
<el-option label="正常" value="normal" />
|
||||
<el-option label="破损" value="damaged" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="detailForm.remark" type="textarea" :rows="2" maxlength="500" show-word-limit placeholder="备注(可选)" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="detailFormVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="detailFormLoading" @click="submitDetailForm">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import {
|
||||
returnUnpackList,
|
||||
returnUnpackCreate,
|
||||
returnUnpackDetail,
|
||||
returnUnpackAddDetail,
|
||||
returnUnpackUpdateDetail,
|
||||
returnUnpackRemoveDetail,
|
||||
returnUnpackSubmit,
|
||||
returnUnpackCancel,
|
||||
returnUnpackDelete,
|
||||
returnUnpackDetailList,
|
||||
} from '@/api/returnunpack'
|
||||
import { loadStores } from '@/api/index/index'
|
||||
import { extractStoreListFromResponse, fillStoreScanFieldOptions } from '@/views/order/orderManagement/config/order-common-config'
|
||||
@ -557,46 +461,6 @@ function handleSortChange({ prop, order }: any) {
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// ==================== 开拆包单 ====================
|
||||
|
||||
const createLoading = ref(false)
|
||||
const createForm = reactive({ waybillCode: '', remark: '' })
|
||||
|
||||
async function handleCreate() {
|
||||
const code = createForm.waybillCode.trim()
|
||||
if (!code) {
|
||||
ElMessage.warning('请先扫描或输入退回运单号')
|
||||
return
|
||||
}
|
||||
createLoading.value = true
|
||||
try {
|
||||
const res: any = await returnUnpackCreate({
|
||||
waybill_code: code,
|
||||
remark: createForm.remark ? createForm.remark.trim() : undefined,
|
||||
})
|
||||
if (isOk(res)) {
|
||||
const data = res.data ?? res
|
||||
if (data.is_original_return) {
|
||||
ElMessage.success(`开单成功:命中原单退回,拆包单ID ${data.id}`)
|
||||
} else {
|
||||
ElMessage.success(`开单成功:拆包单ID ${data.id}`)
|
||||
}
|
||||
createForm.waybillCode = ''
|
||||
createForm.remark = ''
|
||||
fetchData()
|
||||
if (data.id) {
|
||||
handleViewDetail({ id: data.id })
|
||||
}
|
||||
} else {
|
||||
ElMessage.error(res?.message || '开单失败')
|
||||
}
|
||||
} catch {
|
||||
// 请求层已提示错误
|
||||
} finally {
|
||||
createLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 详情 ====================
|
||||
|
||||
const detailVisible = ref(false)
|
||||
@ -617,10 +481,10 @@ async function handleViewDetail(row: any) {
|
||||
const data = res.data ?? res
|
||||
detailRecord.value = data.record ?? data
|
||||
detailOrder.value = data.related?.order ?? data.order ?? null
|
||||
detailList.value = detailRecord.value?.details ?? []
|
||||
} else {
|
||||
ElMessage.error(res?.message || '获取详情失败')
|
||||
}
|
||||
await loadDetailList(row.id)
|
||||
} catch {
|
||||
// 请求层已提示错误
|
||||
} finally {
|
||||
@ -628,197 +492,20 @@ async function handleViewDetail(row: any) {
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshDetail() {
|
||||
if (!detailRecord.value?.id) return
|
||||
await handleViewDetail({ id: detailRecord.value.id })
|
||||
}
|
||||
|
||||
// ==================== 明细操作 ====================
|
||||
|
||||
const detailFormVisible = ref(false)
|
||||
const detailFormLoading = ref(false)
|
||||
const detailForm = reactive({
|
||||
isEdit: false,
|
||||
detailId: null as number | null,
|
||||
stockId: '',
|
||||
quantity: 1,
|
||||
productStatus: 'normal' as 'normal' | 'damaged',
|
||||
remark: '',
|
||||
})
|
||||
|
||||
function openAddDetail() {
|
||||
detailForm.isEdit = false
|
||||
detailForm.detailId = null
|
||||
detailForm.stockId = ''
|
||||
detailForm.quantity = 1
|
||||
detailForm.productStatus = 'normal'
|
||||
detailForm.remark = ''
|
||||
detailFormVisible.value = true
|
||||
}
|
||||
|
||||
function openEditDetail(row: any) {
|
||||
detailForm.isEdit = true
|
||||
detailForm.detailId = row.id
|
||||
detailForm.stockId = row.stock_id != null ? String(row.stock_id) : ''
|
||||
detailForm.quantity = row.quantity ?? 1
|
||||
detailForm.productStatus = row.product_status ?? 'normal'
|
||||
detailForm.remark = row.remark ?? ''
|
||||
detailFormVisible.value = true
|
||||
}
|
||||
|
||||
async function submitDetailForm() {
|
||||
if (!detailRecord.value?.id) return
|
||||
const unpackId = detailRecord.value.id
|
||||
const stockIdRaw = String(detailForm.stockId).trim()
|
||||
const stockId = stockIdRaw ? Number(stockIdRaw) : undefined
|
||||
|
||||
detailFormLoading.value = true
|
||||
async function loadDetailList(unpackId: number) {
|
||||
try {
|
||||
let res: any
|
||||
if (detailForm.isEdit) {
|
||||
if (!detailForm.detailId) {
|
||||
ElMessage.warning('缺少明细ID')
|
||||
return
|
||||
}
|
||||
res = await returnUnpackUpdateDetail({
|
||||
id: unpackId,
|
||||
detail_id: detailForm.detailId,
|
||||
quantity: detailForm.quantity,
|
||||
remark: detailForm.remark ? detailForm.remark.trim() : undefined,
|
||||
})
|
||||
} else {
|
||||
res = await returnUnpackAddDetail({
|
||||
id: unpackId,
|
||||
stock_id: stockId,
|
||||
quantity: detailForm.quantity,
|
||||
product_status: detailForm.productStatus,
|
||||
remark: detailForm.remark ? detailForm.remark.trim() : undefined,
|
||||
})
|
||||
}
|
||||
const res: any = await returnUnpackDetailList({
|
||||
pagination: { page: 1, pageSize: 500 },
|
||||
where: { unpack_id: unpackId },
|
||||
})
|
||||
if (isOk(res)) {
|
||||
ElMessage.success(detailForm.isEdit ? '明细更新成功' : '明细录入成功')
|
||||
detailFormVisible.value = false
|
||||
await refreshDetail()
|
||||
fetchData()
|
||||
const data = res.data ?? res
|
||||
detailList.value = data.list ?? []
|
||||
} else {
|
||||
ElMessage.error(res?.message || (detailForm.isEdit ? '明细更新失败' : '明细录入失败'))
|
||||
detailList.value = []
|
||||
}
|
||||
} catch {
|
||||
// 请求层已提示错误
|
||||
} finally {
|
||||
detailFormLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleRemoveDetail(row: any) {
|
||||
if (!detailRecord.value?.id) return
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认移除该明细(明细ID ${row.id})?移除为物理删除,不可恢复。`,
|
||||
'移除明细确认',
|
||||
{ type: 'warning', confirmButtonText: '移除', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const res: any = await returnUnpackRemoveDetail({ id: detailRecord.value.id, detail_id: row.id })
|
||||
if (isOk(res)) {
|
||||
ElMessage.success('明细移除成功')
|
||||
await refreshDetail()
|
||||
fetchData()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '明细移除失败')
|
||||
}
|
||||
} catch {
|
||||
// 请求层已提示错误
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 提交 / 取消 / 删除 ====================
|
||||
|
||||
const submitLoading = ref(false)
|
||||
const cancelLoading = ref(false)
|
||||
const deleteLoading = ref(false)
|
||||
|
||||
async function handleSubmit(row: any) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认提交拆包单「${row.unpack_no ?? row.id}」?提交后转为已完成终态,不可再录/移除明细。`,
|
||||
'提交确认',
|
||||
{ type: 'warning', confirmButtonText: '提交', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
submitLoading.value = true
|
||||
try {
|
||||
const res: any = await returnUnpackSubmit({ id: row.id })
|
||||
if (isOk(res)) {
|
||||
ElMessage.success('提交成功')
|
||||
await refreshDetail()
|
||||
fetchData()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '提交失败')
|
||||
}
|
||||
} catch {
|
||||
// 请求层已提示错误
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleCancel(row: any) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认取消拆包单「${row.unpack_no ?? row.id}」?取消将硬删除该单及全部明细,不可恢复。`,
|
||||
'取消拆包确认',
|
||||
{ type: 'warning', confirmButtonText: '取消拆包', cancelButtonText: '返回' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
cancelLoading.value = true
|
||||
try {
|
||||
const res: any = await returnUnpackCancel({ id: row.id })
|
||||
if (isOk(res)) {
|
||||
ElMessage.success('已取消拆包单')
|
||||
detailVisible.value = false
|
||||
fetchData()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '取消拆包失败')
|
||||
}
|
||||
} catch {
|
||||
// 请求层已提示错误
|
||||
} finally {
|
||||
cancelLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(row: any) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认删除拆包单「${row.unpack_no ?? row.id}」?删除为物理删除(含全部明细),不可恢复。`,
|
||||
'删除确认',
|
||||
{ type: 'warning', confirmButtonText: '删除', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
deleteLoading.value = true
|
||||
try {
|
||||
const res: any = await returnUnpackDelete({ id: row.id })
|
||||
if (isOk(res)) {
|
||||
ElMessage.success('删除成功')
|
||||
detailVisible.value = false
|
||||
fetchData()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '删除失败')
|
||||
}
|
||||
} catch {
|
||||
// 请求层已提示错误
|
||||
} finally {
|
||||
deleteLoading.value = false
|
||||
detailList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
@ -903,6 +590,17 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
.stock-picker-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
|
||||
.el-input {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
230
src/views/express/returnUnpackwork/CameraLivePreview.vue
Normal file
230
src/views/express/returnUnpackwork/CameraLivePreview.vue
Normal file
@ -0,0 +1,230 @@
|
||||
<template>
|
||||
<div class="camera-live">
|
||||
<div v-if="error" class="live-error">
|
||||
<p class="live-error-title">预览不可用</p>
|
||||
<p class="live-error-sub">{{ error }}</p>
|
||||
</div>
|
||||
<img v-else-if="streamReady && streamSrc" :key="streamKey" :src="streamSrc" class="live-img" />
|
||||
<div v-else class="live-loading">
|
||||
<span>{{ loading ? '正在连接录像机…' : '无信号' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { getLiveStreamUrl } from '@/api/camera_server/localServerApi'
|
||||
import { list as serverList, detail as serverDetail } from '@/api/camera_server/camera_server'
|
||||
|
||||
export interface CameraLiveItem {
|
||||
id?: number
|
||||
server_id?: number
|
||||
channel_id?: number
|
||||
channel_name?: string
|
||||
custom_name?: string
|
||||
ip?: string
|
||||
port?: number
|
||||
}
|
||||
|
||||
const props = defineProps<{ camera: CameraLiveItem | null }>()
|
||||
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
const streamReady = ref(false)
|
||||
const streamKey = ref(0)
|
||||
let probeAbort: AbortController | null = null
|
||||
|
||||
const nvrIp = ref('')
|
||||
const nvrPort = ref<number | undefined>(undefined)
|
||||
const nvrUser = ref('')
|
||||
const nvrPass = ref('')
|
||||
const internalIp = ref('')
|
||||
const internalPort = ref<number | undefined>(undefined)
|
||||
const publicIp = ref('')
|
||||
const publicPort = ref<number | undefined>(undefined)
|
||||
|
||||
const streamSrc = computed(() => {
|
||||
const row = props.camera
|
||||
if (!row || !row.channel_id || !nvrIp.value || !nvrUser.value || !nvrPass.value) return null
|
||||
return getLiveStreamUrl({
|
||||
ip: nvrIp.value,
|
||||
user: nvrUser.value,
|
||||
pass: nvrPass.value,
|
||||
channel: row.channel_id,
|
||||
streamType: 0,
|
||||
port: nvrPort.value
|
||||
})
|
||||
})
|
||||
|
||||
const ok = (res: any) => res && [0, 1, 200].includes(res.code)
|
||||
|
||||
async function getServerInfo(id: number) {
|
||||
try {
|
||||
const res: any = await serverList({ pagination: { page: 1, pageSize: 999 } })
|
||||
if (ok(res)) {
|
||||
const found = (res?.list || []).find((item: any) => item.id === id)
|
||||
if (found) return found
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
return null
|
||||
}
|
||||
|
||||
async function init() {
|
||||
const row = props.camera
|
||||
if (!row) {
|
||||
stopStream()
|
||||
error.value = ''
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
streamReady.value = false
|
||||
nvrIp.value = ''
|
||||
nvrPort.value = undefined
|
||||
nvrUser.value = ''
|
||||
nvrPass.value = ''
|
||||
internalIp.value = ''
|
||||
internalPort.value = undefined
|
||||
publicIp.value = ''
|
||||
publicPort.value = undefined
|
||||
|
||||
const sid = row.server_id
|
||||
if (!sid) { error.value = '未关联录像服务器'; loading.value = false; return }
|
||||
|
||||
const srv = await getServerInfo(sid)
|
||||
if (!srv) { error.value = '未找到服务器信息'; loading.value = false; return }
|
||||
|
||||
let pwd = srv.password
|
||||
if (!pwd) {
|
||||
try {
|
||||
const d: any = await serverDetail({ id: sid })
|
||||
if (ok(d) && d?.data?.password) pwd = d.data.password
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
if (!pwd) { error.value = '缺少服务器密码'; loading.value = false; return }
|
||||
|
||||
internalIp.value = (srv.internal_ip || '').trim()
|
||||
internalPort.value = srv.internal_port || srv.port
|
||||
publicIp.value = (srv.public_ip || '').trim()
|
||||
publicPort.value = srv.public_port || srv.port
|
||||
nvrUser.value = srv.username || ''
|
||||
nvrPass.value = pwd
|
||||
|
||||
const ip = internalIp.value || publicIp.value
|
||||
if (!ip) { error.value = '服务器未配置 IP'; loading.value = false; return }
|
||||
|
||||
nvrIp.value = ip
|
||||
nvrPort.value = internalIp.value ? internalPort.value : publicPort.value
|
||||
|
||||
await probeStream()
|
||||
}
|
||||
|
||||
async function probeStream() {
|
||||
if (probeAbort) { probeAbort.abort(); probeAbort = null }
|
||||
const url = streamSrc.value
|
||||
if (!url) { loading.value = false; return }
|
||||
probeAbort = new AbortController()
|
||||
const { signal } = probeAbort
|
||||
const t = setTimeout(() => probeAbort?.abort(), 8000)
|
||||
try {
|
||||
const resp = await fetch(url, { signal })
|
||||
clearTimeout(t)
|
||||
if (!signal.aborted && resp.ok) {
|
||||
streamReady.value = true
|
||||
loading.value = false
|
||||
streamKey.value += 1
|
||||
} else if (!signal.aborted) {
|
||||
await handleProbeFail('nvr')
|
||||
}
|
||||
} catch (e: any) {
|
||||
clearTimeout(t)
|
||||
if (signal.aborted) return
|
||||
await handleProbeFail(e.name === 'TypeError' ? 'proxy' : 'nvr')
|
||||
}
|
||||
}
|
||||
|
||||
async function handleProbeFail(reason: 'proxy' | 'nvr') {
|
||||
stopStream()
|
||||
nvrIp.value = ''
|
||||
nvrPort.value = undefined
|
||||
streamReady.value = false
|
||||
|
||||
if (reason === 'proxy') {
|
||||
error.value = '本地视频服务未启动'
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
|
||||
if (internalIp.value && publicIp.value && publicIp.value !== internalIp.value) {
|
||||
nvrIp.value = publicIp.value
|
||||
nvrPort.value = publicPort.value
|
||||
streamKey.value += 1
|
||||
await probeStream()
|
||||
return
|
||||
}
|
||||
|
||||
const tried = [internalIp.value, publicIp.value].filter(Boolean).join('、')
|
||||
error.value = `无法连接录像机(已尝试:${tried})`
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
function stopStream() {
|
||||
if (probeAbort) { probeAbort.abort(); probeAbort = null }
|
||||
streamReady.value = false
|
||||
}
|
||||
|
||||
function reload() {
|
||||
stopStream()
|
||||
void init()
|
||||
}
|
||||
defineExpose({ reload })
|
||||
|
||||
watch(() => props.camera, () => {
|
||||
void init()
|
||||
}, { immediate: true })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.camera-live {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 160px;
|
||||
background: #000;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.live-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 160px;
|
||||
object-fit: contain;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.live-loading {
|
||||
color: #909399;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.live-error {
|
||||
color: #f56c6c;
|
||||
text-align: center;
|
||||
padding: 16px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.live-error-title {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.live-error-sub {
|
||||
color: #909399;
|
||||
}
|
||||
</style>
|
||||
1327
src/views/express/returnUnpackwork/index.vue
Normal file
1327
src/views/express/returnUnpackwork/index.vue
Normal file
File diff suppressed because it is too large
Load Diff
647
src/views/express/returnwaybill/index.vue
Normal file
647
src/views/express/returnwaybill/index.vue
Normal file
@ -0,0 +1,647 @@
|
||||
<template>
|
||||
<div class="order-sub-container">
|
||||
<scan-box
|
||||
ref="scanBox"
|
||||
cache-key="express:returnwaybill"
|
||||
width="220px"
|
||||
:tree-props="{ children: 'children', label: 'label' }"
|
||||
:auto-submit="false"
|
||||
:available-fields="availableFields"
|
||||
@condition-change="handleConditionChange"
|
||||
@reset="handleConditionReset"
|
||||
@condition-clear="handleConditionClear"
|
||||
/>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="toolbar">
|
||||
<div class="toolbar-left">
|
||||
<order-toolbar-button-group
|
||||
:buttons="toolbarButtons"
|
||||
:resolve-disabled="resolveButtonDisabled"
|
||||
:resolve-loading="resolveButtonLoading"
|
||||
:resolve-label="resolveButtonLabel"
|
||||
:layout-key="toolbarLayoutKey"
|
||||
@action="handleToolbarButtonClick"
|
||||
/>
|
||||
<el-divider direction="vertical" />
|
||||
<div class="scan-register">
|
||||
<el-input
|
||||
v-model="createForm.waybillCode"
|
||||
size="small"
|
||||
class="register-input"
|
||||
placeholder="运单号(扫码/输入)"
|
||||
clearable
|
||||
@keyup.enter="handleCreate"
|
||||
/>
|
||||
<el-select
|
||||
v-model="createForm.storeId"
|
||||
size="small"
|
||||
class="register-store"
|
||||
placeholder="选择货主"
|
||||
filterable
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="item in storeOptions"
|
||||
:key="String(item.value)"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
<el-input
|
||||
v-model="createForm.remark"
|
||||
size="small"
|
||||
class="register-remark"
|
||||
placeholder="备注(可选)"
|
||||
clearable
|
||||
@keyup.enter="handleCreate"
|
||||
/>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
:loading="createLoading"
|
||||
@click="handleCreate"
|
||||
>登记</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="split-stack">
|
||||
<div class="upper-wrapper">
|
||||
<upper-table
|
||||
ref="upperTable"
|
||||
title="运单退回登记列表"
|
||||
default-align="center"
|
||||
table-id="express-returnwaybill-list"
|
||||
:data="tableData"
|
||||
:columns="columns"
|
||||
:table-size="tableSize"
|
||||
:pagination="upperPagination"
|
||||
:show-index="true"
|
||||
:show-actions="true"
|
||||
:enable-column-config="true"
|
||||
:loading="loading"
|
||||
:query-time="queryTime"
|
||||
@current-change="handleRowClick"
|
||||
@page-change="handlePageChange"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
@refresh="handleRefresh"
|
||||
@sort-change="handleSortChange"
|
||||
>
|
||||
<template #column-is_notified="{ row }">
|
||||
<el-tag :type="row.is_notified ? 'success' : 'info'" size="small">
|
||||
{{ row.is_notified ? '已通知' : '未通知' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<template #column-is_back="{ row }">
|
||||
<el-tag :type="row.is_back ? 'warning' : 'info'" size="small">
|
||||
{{ row.is_back ? '已退回' : '未退回' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<template #column-store_id="{ row }">
|
||||
<span v-if="row.store_id != null">{{ row.store_id }}</span>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
|
||||
<template #column-actions="{ row }">
|
||||
<div class="operation-actions">
|
||||
<el-button size="small" type="primary" link @click.stop="handleViewDetail(row)">详情</el-button>
|
||||
<el-button size="small" type="warning" link @click.stop="openEdit(row)">编辑</el-button>
|
||||
<el-button size="small" type="danger" link @click.stop="handleDelete(row)">删除</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #empty>
|
||||
<div class="empty-tip">暂无运单退回登记数据</div>
|
||||
</template>
|
||||
</upper-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ========== 详情弹窗 ========== -->
|
||||
<el-dialog v-model="detailVisible" title="运单退回登记详情" width="720px" destroy-on-close align-center>
|
||||
<div v-loading="detailLoading" class="detail-content">
|
||||
<el-descriptions v-if="detailRecord" title="登记信息" :column="2" border size="small">
|
||||
<el-descriptions-item label="登记ID">{{ detailRecord.id ?? '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="运单号">
|
||||
<span
|
||||
v-if="detailRecord.waybill_code"
|
||||
class="copyable"
|
||||
role="button"
|
||||
title="点击复制"
|
||||
@click="copyText(detailRecord.waybill_code)"
|
||||
>{{ detailRecord.waybill_code }}</span>
|
||||
<span v-else>-</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="货主ID">{{ detailRecord.store_id ?? '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="仓库ID">{{ detailRecord.warehouse_id ?? '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="是否已通知">
|
||||
<el-tag :type="detailRecord.is_notified ? 'success' : 'info'" size="small">
|
||||
{{ detailRecord.is_notified ? '已通知' : '未通知' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="是否退回">
|
||||
<el-tag :type="detailRecord.is_back ? 'warning' : 'info'" size="small">
|
||||
{{ detailRecord.is_back ? '已退回' : '未退回' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="登记时间">{{ formatTime(detailRecord.created_at) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="更新时间">{{ formatTime(detailRecord.updated_at) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="备注" :span="2">{{ detailRecord.remark || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="detailVisible = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- ========== 编辑弹窗 ========== -->
|
||||
<el-dialog v-model="editVisible" title="编辑运单退回登记" width="480px" destroy-on-close align-center>
|
||||
<el-form :model="editForm" label-width="80px" size="small">
|
||||
<el-form-item label="运单号">
|
||||
<el-input v-model="editForm.waybillCode" placeholder="运单号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="货主">
|
||||
<el-select v-model="editForm.storeId" placeholder="请选择货主" filterable clearable class="full-width">
|
||||
<el-option
|
||||
v-for="item in storeOptions"
|
||||
:key="String(item.value)"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="editForm.remark" type="textarea" :rows="2" maxlength="500" show-word-limit placeholder="备注(可选)" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="editVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="editLoading" @click="handleEditSubmit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import {
|
||||
returnWaybillList,
|
||||
returnWaybillCreate,
|
||||
returnWaybillUpdate,
|
||||
returnWaybillDetail,
|
||||
returnWaybillDelete,
|
||||
} from '@/api/returnwaybill'
|
||||
import { loadStores } from '@/api/index/index'
|
||||
import {
|
||||
extractStoreListFromResponse,
|
||||
mapStoreListToSelectOptions,
|
||||
fillStoreScanFieldOptions,
|
||||
} from '@/views/order/orderManagement/config/order-common-config'
|
||||
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
||||
import { returnWaybillAvailableFields, returnWaybillColumns, returnWaybillToolbarButtons } from './returnwaybill-config'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
|
||||
|
||||
// ==================== 常量 / 工具 ====================
|
||||
|
||||
function formatTime(val: any): string {
|
||||
if (val === null || val === undefined || val === '') return '-'
|
||||
const d = new Date(val)
|
||||
if (isNaN(d.getTime())) return String(val)
|
||||
return d.toLocaleString('zh-CN', { hour12: false })
|
||||
}
|
||||
|
||||
function isOk(res: any): boolean {
|
||||
return Boolean(res && (res.code === 1 || res.code === 200 || res.code === 20000))
|
||||
}
|
||||
|
||||
async function copyText(text: string) {
|
||||
if (!text) {
|
||||
ElMessage.warning('无可复制内容')
|
||||
return
|
||||
}
|
||||
try {
|
||||
if (navigator.clipboard?.writeText) {
|
||||
await navigator.clipboard.writeText(text)
|
||||
} else {
|
||||
throw new Error('no clipboard api')
|
||||
}
|
||||
ElMessage.success('已复制到剪贴板')
|
||||
} catch {
|
||||
try {
|
||||
const textarea = document.createElement('textarea')
|
||||
textarea.value = text
|
||||
textarea.setAttribute('readonly', 'readonly')
|
||||
textarea.style.position = 'fixed'
|
||||
textarea.style.left = '-9999px'
|
||||
document.body.appendChild(textarea)
|
||||
textarea.select()
|
||||
document.execCommand('copy')
|
||||
document.body.removeChild(textarea)
|
||||
ElMessage.success('已复制到剪贴板')
|
||||
} catch {
|
||||
ElMessage.error('复制失败,请手动复制')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 配置 ====================
|
||||
|
||||
const availableFields = returnWaybillAvailableFields
|
||||
const columns = returnWaybillColumns
|
||||
const tableSize = 'small'
|
||||
const toolbarButtons: ToolbarButtonConfig[] = returnWaybillToolbarButtons
|
||||
|
||||
const buttonLoadingMap = ref<Record<string, boolean>>({ loading: false })
|
||||
const buttonDisabledMap = ref<Record<string, boolean>>({})
|
||||
const buttonLabelMap = ref<Record<string, string>>({})
|
||||
const toolbarLayoutKey = ref('')
|
||||
|
||||
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) {
|
||||
return dynamicLabelKey ? (buttonLabelMap.value[dynamicLabelKey] || defaultLabel) : defaultLabel
|
||||
}
|
||||
|
||||
const toolbarActionMap: Record<string, () => void> = {
|
||||
loadData: () => { handleRefresh() },
|
||||
openColumnConfigPanel: () => openColumnConfigPanel(),
|
||||
}
|
||||
|
||||
function openColumnConfigPanel() {
|
||||
upperTable.value?.openColumnConfig?.()
|
||||
}
|
||||
|
||||
function handleToolbarButtonClick(action: string) {
|
||||
const handler = toolbarActionMap[action]
|
||||
if (!handler) return
|
||||
handler()
|
||||
}
|
||||
|
||||
// ==================== 数据状态 ====================
|
||||
|
||||
const scanBox = ref<any>(null)
|
||||
const upperTable = ref<any>(null)
|
||||
const loading = ref(false)
|
||||
const queryTime = ref(0)
|
||||
const tableData = ref<any[]>([])
|
||||
const currentConditions = ref<Record<string, any>>({})
|
||||
const currentSort = ref<{ prop: string; order: string }>({ prop: '', order: '' })
|
||||
|
||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
const upperPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
|
||||
// ==================== 货主选项 ====================
|
||||
|
||||
const storeOptions = ref<{ label: string; value: number | string }[]>([])
|
||||
|
||||
async function loadStoreOptions() {
|
||||
try {
|
||||
const storesRes: any = await loadStores()
|
||||
const rawStores = extractStoreListFromResponse(storesRes)
|
||||
storeOptions.value = mapStoreListToSelectOptions(rawStores)
|
||||
fillStoreScanFieldOptions(availableFields, rawStores)
|
||||
} catch {
|
||||
storeOptions.value = []
|
||||
fillStoreScanFieldOptions(availableFields, [])
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== ScanBox 事件 ====================
|
||||
|
||||
function handleConditionChange(conditions: Record<string, any>) {
|
||||
currentConditions.value = conditions ?? {}
|
||||
pagination.currentPage = 1
|
||||
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 handleRowClick() {
|
||||
/* 点击行无默认行为,详情通过操作列触发 */
|
||||
}
|
||||
|
||||
// ==================== 条件转换 ====================
|
||||
|
||||
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
|
||||
const value = cond && typeof cond === 'object' && 'value' in cond ? cond.value : cond
|
||||
if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) continue
|
||||
|
||||
switch (key) {
|
||||
case 'waybill_code':
|
||||
where.waybill_code = { operator: 'like', value: String(value) }
|
||||
break
|
||||
case 'created_at':
|
||||
where.created_at = { operator: 'between', value }
|
||||
break
|
||||
case 'is_notified':
|
||||
case 'is_back':
|
||||
where[key] = Boolean(value) ? 1 : 0
|
||||
break
|
||||
case 'store_id': {
|
||||
const n = Number(value)
|
||||
if (!Number.isNaN(n)) where[key] = n
|
||||
break
|
||||
}
|
||||
default:
|
||||
where[key] = value
|
||||
}
|
||||
}
|
||||
return where
|
||||
}
|
||||
|
||||
// ==================== 数据查询 ====================
|
||||
|
||||
async function fetchData() {
|
||||
loading.value = true
|
||||
const start = Date.now()
|
||||
try {
|
||||
const where = buildWhereFromConditions(currentConditions.value)
|
||||
const params: any = {
|
||||
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
|
||||
where,
|
||||
}
|
||||
if (currentSort.value.prop) {
|
||||
params.sort = {
|
||||
sortField: currentSort.value.prop,
|
||||
sortOrder: currentSort.value.order === 'ascending' ? 'asc' : 'desc',
|
||||
}
|
||||
}
|
||||
const res: any = await returnWaybillList(params)
|
||||
if (isOk(res)) {
|
||||
const data = res.data ?? res
|
||||
tableData.value = data.list ?? data.items ?? []
|
||||
const total = data.pagination?.total ?? data.total ?? 0
|
||||
pagination.total = total
|
||||
upperPagination.total = total
|
||||
} else {
|
||||
tableData.value = []
|
||||
pagination.total = 0
|
||||
upperPagination.total = 0
|
||||
ElMessage.error(res?.message || '获取运单退回登记列表失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取运单退回登记列表失败:', error)
|
||||
tableData.value = []
|
||||
pagination.total = 0
|
||||
upperPagination.total = 0
|
||||
} finally {
|
||||
queryTime.value = Date.now() - start
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleRefresh() {
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handlePageChange(page: number) {
|
||||
pagination.currentPage = page
|
||||
upperPagination.currentPage = page
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handlePageSizeChange(size: number) {
|
||||
pagination.pageSize = size
|
||||
upperPagination.pageSize = size
|
||||
pagination.currentPage = 1
|
||||
upperPagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleSortChange({ prop, order }: any) {
|
||||
currentSort.value = { prop: prop ?? '', order: order ?? '' }
|
||||
pagination.currentPage = 1
|
||||
upperPagination.currentPage = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// ==================== 登记 ====================
|
||||
|
||||
const createLoading = ref(false)
|
||||
const createForm = reactive({
|
||||
waybillCode: '',
|
||||
storeId: null as number | string | null,
|
||||
remark: '',
|
||||
})
|
||||
|
||||
async function handleCreate() {
|
||||
const code = createForm.waybillCode.trim()
|
||||
if (!code) {
|
||||
ElMessage.warning('请先扫描或输入运单号')
|
||||
return
|
||||
}
|
||||
if (createForm.storeId == null || createForm.storeId === '') {
|
||||
ElMessage.warning('请选择货主')
|
||||
return
|
||||
}
|
||||
createLoading.value = true
|
||||
try {
|
||||
const res: any = await returnWaybillCreate({
|
||||
waybill_code: code,
|
||||
store_id: Number(createForm.storeId),
|
||||
remark: createForm.remark ? createForm.remark.trim() : undefined,
|
||||
})
|
||||
if (isOk(res)) {
|
||||
const data = res.data ?? res
|
||||
if (data.duplicated) {
|
||||
ElMessage.warning('该货主+运单号已登记,已返回已有记录')
|
||||
} else {
|
||||
ElMessage.success('登记成功')
|
||||
}
|
||||
createForm.waybillCode = ''
|
||||
createForm.storeId = null
|
||||
createForm.remark = ''
|
||||
fetchData()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '登记失败')
|
||||
}
|
||||
} catch {
|
||||
// 请求层已提示错误
|
||||
} finally {
|
||||
createLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 详情 ====================
|
||||
|
||||
const detailVisible = ref(false)
|
||||
const detailLoading = ref(false)
|
||||
const detailRecord = ref<any>(null)
|
||||
|
||||
async function handleViewDetail(row: any) {
|
||||
detailVisible.value = true
|
||||
detailLoading.value = true
|
||||
detailRecord.value = null
|
||||
try {
|
||||
const res: any = await returnWaybillDetail({ id: row.id })
|
||||
if (isOk(res)) {
|
||||
const data = res.data ?? res
|
||||
detailRecord.value = data.record ?? data
|
||||
} else {
|
||||
ElMessage.error(res?.message || '获取详情失败')
|
||||
}
|
||||
} catch {
|
||||
// 请求层已提示错误
|
||||
} finally {
|
||||
detailLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 编辑 ====================
|
||||
|
||||
const editVisible = ref(false)
|
||||
const editLoading = ref(false)
|
||||
const editForm = reactive({
|
||||
id: null as number | null,
|
||||
waybillCode: '',
|
||||
storeId: null as number | string | null,
|
||||
remark: '',
|
||||
})
|
||||
|
||||
function openEdit(row: any) {
|
||||
editForm.id = row.id
|
||||
editForm.waybillCode = row.waybill_code ?? ''
|
||||
editForm.storeId = row.store_id != null ? row.store_id : null
|
||||
editForm.remark = row.remark ?? ''
|
||||
editVisible.value = true
|
||||
}
|
||||
|
||||
async function handleEditSubmit() {
|
||||
if (!editForm.id) {
|
||||
ElMessage.warning('缺少登记ID')
|
||||
return
|
||||
}
|
||||
const code = editForm.waybillCode.trim()
|
||||
if (!code) {
|
||||
ElMessage.warning('运单号不能为空')
|
||||
return
|
||||
}
|
||||
editLoading.value = true
|
||||
try {
|
||||
const res: any = await returnWaybillUpdate({
|
||||
id: editForm.id,
|
||||
waybill_code: code,
|
||||
store_id: editForm.storeId != null && editForm.storeId !== '' ? Number(editForm.storeId) : undefined,
|
||||
remark: editForm.remark ? editForm.remark.trim() : undefined,
|
||||
})
|
||||
if (isOk(res)) {
|
||||
ElMessage.success('修改成功')
|
||||
editVisible.value = false
|
||||
fetchData()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '修改失败')
|
||||
}
|
||||
} catch {
|
||||
// 请求层已提示错误
|
||||
} finally {
|
||||
editLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 删除 ====================
|
||||
|
||||
async function handleDelete(row: any) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认删除登记记录「${row.waybill_code}」?删除为物理删除,不可恢复。`,
|
||||
'删除确认',
|
||||
{ type: 'warning', confirmButtonText: '删除', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const res: any = await returnWaybillDelete({ id: row.id })
|
||||
if (isOk(res)) {
|
||||
ElMessage.success('删除成功')
|
||||
fetchData()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '删除失败')
|
||||
}
|
||||
} catch {
|
||||
// 请求层已提示错误
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadStoreOptions()
|
||||
fetchData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@use "../../order/orderManagement/styles/order-sub.scss";
|
||||
|
||||
.scan-register {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex: 0 0 auto;
|
||||
|
||||
.register-input {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.register-store {
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
.register-remark {
|
||||
width: 140px;
|
||||
}
|
||||
}
|
||||
|
||||
.operation-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.detail-content {
|
||||
min-height: 120px;
|
||||
|
||||
.copyable {
|
||||
cursor: pointer;
|
||||
color: #409eff;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
64
src/views/express/returnwaybill/returnwaybill-config.ts
Normal file
64
src/views/express/returnwaybill/returnwaybill-config.ts
Normal file
@ -0,0 +1,64 @@
|
||||
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
||||
|
||||
// ============================================================
|
||||
// 运单退回登记(returnWaybill) - ScanBox 筛选字段
|
||||
// 对齐 returnWaybill.list 接口文档 where 参数
|
||||
// ============================================================
|
||||
export const returnWaybillAvailableFields = [
|
||||
{
|
||||
value: 'waybill_code',
|
||||
label: '运单号',
|
||||
type: 'text',
|
||||
placeholder: '运单号模糊搜索',
|
||||
operators: ['like'],
|
||||
defaultOperator: 'like',
|
||||
},
|
||||
{
|
||||
value: 'store_id',
|
||||
label: '货主',
|
||||
type: 'select',
|
||||
placeholder: '请选择货主',
|
||||
options: [] as { label: string; value: unknown }[],
|
||||
},
|
||||
{
|
||||
value: 'is_notified',
|
||||
label: '是否已通知',
|
||||
type: 'boolean',
|
||||
placeholder: '请选择是否已通知',
|
||||
},
|
||||
{
|
||||
value: 'is_back',
|
||||
label: '是否退回',
|
||||
type: 'boolean',
|
||||
placeholder: '请选择是否退回',
|
||||
},
|
||||
{
|
||||
value: 'created_at',
|
||||
label: '登记时间',
|
||||
type: 'datetimerange',
|
||||
},
|
||||
]
|
||||
|
||||
// ============================================================
|
||||
// 运单退回登记(returnWaybill) - UpperTable 列配置
|
||||
// 对齐 returnWaybill.list 实际响应字段
|
||||
// ============================================================
|
||||
export const returnWaybillColumns = [
|
||||
{ prop: 'id', label: 'ID', width: '80', sortable: 'custom' },
|
||||
{ prop: 'waybill_code', label: '运单号', minWidth: '180', showOverflowTooltip: true, copyAction: 'copy' as const },
|
||||
{ prop: 'store_id', label: '货主ID', width: '100' },
|
||||
{ prop: 'is_notified', label: '是否已通知', width: '110' },
|
||||
{ prop: 'is_back', label: '是否退回', width: '100' },
|
||||
{ prop: 'remark', label: '备注', minWidth: '140', showOverflowTooltip: true },
|
||||
{ prop: 'created_at', label: '登记时间', width: '170', sortable: 'custom' },
|
||||
{ prop: 'updated_at', label: '更新时间', width: '170', sortable: 'custom' },
|
||||
{ prop: 'actions', label: '操作', width: '200', fixed: 'right' },
|
||||
]
|
||||
|
||||
// ============================================================
|
||||
// 工具栏按钮
|
||||
// ============================================================
|
||||
export const returnWaybillToolbarButtons: ToolbarButtonConfig[] = [
|
||||
{ key: 'refresh', label: '刷新', category: 'refresh', size: 'small', loadingKey: 'loading', action: 'loadData' },
|
||||
{ key: 'columnConfig', label: '字段设置', category: 'setting', size: 'small', action: 'openColumnConfigPanel' },
|
||||
]
|
||||
@ -356,6 +356,7 @@ const FALLBACK_FIELDS: NormalizedField[] = [
|
||||
{ key: 'district_name', label: '默认发件区/县', type: 'string', maxLength: 50 },
|
||||
{ key: 'town_name', label: '默认发件镇/街道', type: 'string', maxLength: 50 },
|
||||
{ key: 'address', label: '默认发件详细地址', type: 'string', maxLength: 200 },
|
||||
{ key: 'receiver_address', label: '仓库收货地址', type: 'string', maxLength: 500, description: '退货/退件收件地址,一行文本' },
|
||||
{
|
||||
key: 'auto_outbound_rules',
|
||||
label: '自动出库规则',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user