3月27日更新
This commit is contained in:
parent
24e4114c6c
commit
b183c7fcb0
@ -16,12 +16,30 @@ export const getBindInfo = () => {
|
||||
} as any)
|
||||
}
|
||||
|
||||
export interface BindWechatCodeParams {
|
||||
/** 是否强制刷新状态,true 时跳过缓存等待窗口 */
|
||||
forceRefresh?: boolean
|
||||
/** 是否显式开启长轮询等待;true 时进入最长 60 秒等待 */
|
||||
waitForChange?: boolean
|
||||
/** 长轮询开关(兼容字段);true 时进入最长 60 秒等待 */
|
||||
longPoll?: boolean
|
||||
/** 等待超时毫秒数;后端自动封顶 60000 */
|
||||
waitTimeoutMs?: number
|
||||
/** 初始化请求标记;true 时强制立即返回,不进入长等待 */
|
||||
init?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信绑定二维码及轮询状态
|
||||
* 支持轮询,优先命中缓存,不重复查库
|
||||
* 返回: { status: 'waiting'|'scanned'|'bound'|'expired', bindCode, qrUrl, nickname, openid }
|
||||
* 支持长轮询:longPoll/waitForChange=true 时服务端最长等待 60 秒
|
||||
* 初始化调用时传 init:true,服务端立即返回二维码数据
|
||||
* 返回: { status: 'waiting'|'scanned'|'bound'|'expired', code, qrUrl, nickname, openid }
|
||||
*/
|
||||
export const getBindWechatCode = () => {
|
||||
export const getBindWechatCode = (params?: BindWechatCodeParams) => {
|
||||
const isLongPoll = params?.longPoll || params?.waitForChange
|
||||
const waitMs = params?.waitTimeoutMs ?? (isLongPoll ? 60000 : 0)
|
||||
// HTTP 超时需大于后端等待时长
|
||||
const httpTimeout = isLongPoll ? Math.max(waitMs, 60000) + 10000 : 15000
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
@ -30,9 +48,9 @@ export const getBindWechatCode = () => {
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: {},
|
||||
data: params ?? {},
|
||||
isSystemApi: true,
|
||||
timeout: 120000 // 轮询接口,适当延长超时时间
|
||||
timeout: httpTimeout
|
||||
} as any)
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
const v = "1.0"
|
||||
|
||||
export function getEntryList(data:any): Promise<any> {
|
||||
@ -6,7 +7,7 @@ export function getEntryList(data:any): Promise<any> {
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.getEntryList',
|
||||
method: 'storage.entry.list',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
@ -19,7 +20,85 @@ export function getEntryDetail(data:any): Promise<any> {
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.getEntryDetail',
|
||||
method: 'storage.entry.get',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function createEntry(data:any): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.create',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function addDetail(data:any): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.addDetail',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteDetail(data:any): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.deleteDetail',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function detailChange(data:any): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.detailChange',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function cancelEntry(data:any): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.cancel',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function completeEntry(data:any): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.entry.completeEntry',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
|
||||
@ -98,19 +98,19 @@ export function createReceiving(data: any): Promise<any> {
|
||||
})
|
||||
}
|
||||
|
||||
// 不可用
|
||||
export function cancelReceiving(data: any): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.receiving.batchCancelReceiving',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// export function cancelReceiving(data: any): Promise<any> {
|
||||
// return request({
|
||||
// url: '/system',
|
||||
// method: 'post',
|
||||
// params: {
|
||||
// method: 'storage.receiving.batchCancelReceiving',
|
||||
// v,
|
||||
// timestamp: new Date().getTime()
|
||||
// },
|
||||
// data: data
|
||||
// })
|
||||
// }
|
||||
|
||||
|
||||
export function addItem(data: any): Promise<any> {
|
||||
|
||||
15
src/api/storage/stockout.ts
Normal file
15
src/api/storage/stockout.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import request from '@/utils/request'
|
||||
const v = "1.0"
|
||||
|
||||
export const stockoutList = (data: any) => {
|
||||
return request({
|
||||
url: `/system`,
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.stockout.list',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: data
|
||||
})
|
||||
}
|
||||
@ -13,6 +13,7 @@ export const componentMap: Record<string, any> = {
|
||||
'storage/receiving': () => import('@/views/storage/receiving/index.vue'),
|
||||
'storage/entry': () => import('@/views/storage/entry/index.vue'),
|
||||
'storage/inventory': () => import('@/views/storage/inventory/index.vue'),
|
||||
'storage/stockout': () => import('@/views/storage/stockout/index.vue'),
|
||||
'system/setting/printTemplate/index': () => import('@/views/system/setting/printTemplate/index.vue'),
|
||||
// 'system/setting/printStation/index': () => import('@/views/system/setting/printStation/index.vue'),
|
||||
'system/print/station': () => import('@/views/system/setting/printStation/index.vue'),
|
||||
|
||||
@ -99,7 +99,8 @@ service.interceptors.response.use(
|
||||
|
||||
// 检查业务状态码
|
||||
if (!SUCCESS_CODES.includes(res.code)) {
|
||||
const errorMessage = (ERROR_CODE_MAP as Record<number | string, string>)[res.code] || res.message || '请求失败'
|
||||
// 优先使用后端返回的 message,如果没有则从映射表获取,最后使用默认值
|
||||
const errorMessage = res.message || (ERROR_CODE_MAP as Record<number | string, string>)[res.code] || '请求失败'
|
||||
|
||||
// Token 失效处理
|
||||
if ([401, 50008, 50012, 50014].includes(res.code)) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div style="width:100%;padding:10px;height: 100%;">
|
||||
<div style="width:100%;height: 100%;">
|
||||
<!-- 使用 keep-alive 强制保留所有标签 -->
|
||||
<el-tabs
|
||||
v-model="activeTab"
|
||||
|
||||
@ -13,46 +13,42 @@
|
||||
</span>
|
||||
<el-button type="danger" plain size="small" :loading="unbinding" @click="handleUnbind">解绑</el-button>
|
||||
</template>
|
||||
<el-button v-else type="primary" size="small" @click="handleBind">去绑定</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 绑定二维码对话框 -->
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
title="微信扫码绑定"
|
||||
width="350px"
|
||||
append-to-body
|
||||
center
|
||||
@close="handleDialogClose"
|
||||
>
|
||||
<!-- 未绑定时内联显示二维码区域 -->
|
||||
<div v-if="!isBound" class="qrcode-section">
|
||||
<div class="qrcode-wrapper">
|
||||
<!-- 加载中 -->
|
||||
<div v-if="loading" class="loading-overlay">
|
||||
<div v-if="loading" class="status-overlay loading-overlay">
|
||||
<el-icon class="is-loading"><Loading /></el-icon>
|
||||
<span>加载中...</span>
|
||||
</div>
|
||||
<!-- 二维码过期 -->
|
||||
<div v-else-if="qrStatus === 'expired'" class="expired-overlay" @click="refreshQrCode">
|
||||
<div v-else-if="qrStatus === 'expired'" class="status-overlay expired-overlay" @click="refreshQrCode">
|
||||
<el-icon><RefreshRight /></el-icon>
|
||||
<span>二维码已过期,点击刷新</span>
|
||||
</div>
|
||||
<!-- 扫码成功等待确认 -->
|
||||
<div v-else-if="qrStatus === 'scanned'" class="scanned-overlay">
|
||||
<div v-else-if="qrStatus === 'scanned'" class="status-overlay scanned-overlay">
|
||||
<el-icon><CircleCheckFilled /></el-icon>
|
||||
<span>扫码成功,正在确认...</span>
|
||||
</div>
|
||||
<!-- 二维码图片 -->
|
||||
<template v-else>
|
||||
<img :src="qrCodeUrl" alt="微信二维码" class="qrcode-img">
|
||||
</template>
|
||||
<img v-else-if="qrCodeUrl" :src="qrCodeUrl" alt="微信二维码" class="qrcode-img">
|
||||
<!-- 初始占位 -->
|
||||
<div v-else class="status-overlay loading-overlay">
|
||||
<el-icon class="is-loading"><Loading /></el-icon>
|
||||
<span>正在获取二维码...</span>
|
||||
</div>
|
||||
|
||||
<p class="qrcode-tip">
|
||||
<template v-if="qrStatus === 'scanned'">请在微信中确认绑定</template>
|
||||
<template v-else-if="qrStatus === 'expired'">二维码已失效</template>
|
||||
<template v-else-if="qrStatus === 'expired'">二维码已失效,点击上方刷新</template>
|
||||
<template v-else>请使用微信扫码关注公众号完成绑定</template>
|
||||
</p>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -68,16 +64,140 @@ const isBound = ref(false)
|
||||
const unbinding = ref(false)
|
||||
const binderInfo = reactive({ nickname: '', openid: '' })
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const qrCodeUrl = ref("")
|
||||
const qrBaseUrl = "https://ye4s.wms.gztbyc.com/qrcode/build?text="
|
||||
|
||||
const qrCodeUrl = ref('')
|
||||
const qrStatus = ref<QrStatus>('waiting')
|
||||
|
||||
let pollTimer: ReturnType<typeof setInterval> | null = null
|
||||
const POLL_INTERVAL = 120000 // 120 秒轮询一次
|
||||
const qrBaseUrl = 'https://ye4s.wms.gztbyc.com/qrcode/build?text='
|
||||
const bindLinkTemplate = 'https://ye4s.wms.gztbyc.com/mini/?spm=0.3.${code}.1.4'
|
||||
|
||||
/** 初始化:获取当前绑定状态 */
|
||||
/** 是否已获取到首次二维码(决定后续请求是否携带 longPoll) */
|
||||
let hasInitQr = false
|
||||
/** 停止长轮询的标志位 */
|
||||
let stopPollFlag = false
|
||||
/** 轮询版本号,每次停止时递增,用于丢弃过期回调 */
|
||||
let pollVersion = 0
|
||||
|
||||
/** 构造完整二维码 URL */
|
||||
const getFullQrUrl = (code: string) => {
|
||||
const targetUrl = bindLinkTemplate.replace('${code}', code)
|
||||
return qrBaseUrl + encodeURIComponent(targetUrl)
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理后端返回数据,更新组件状态。
|
||||
* @returns true 表示已绑定,轮询应终止
|
||||
*/
|
||||
const processBindData = (data: any, showSuccessMsg = false): boolean => {
|
||||
const boundNow = data.status === 'bound' || data.is_bound === true
|
||||
if (boundNow) {
|
||||
isBound.value = true
|
||||
binderInfo.nickname = data.nickname || ''
|
||||
binderInfo.openid = data.openid || ''
|
||||
if (showSuccessMsg) {
|
||||
ElMessage.success(`微信绑定成功:${data.nickname || '微信用户'}`)
|
||||
}
|
||||
return true
|
||||
}
|
||||
const mapped: QrStatus = data.status === 'pending' ? 'waiting' : (data.status as QrStatus)
|
||||
qrStatus.value = mapped
|
||||
if (data.code) {
|
||||
qrCodeUrl.value = getFullQrUrl(data.code)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动长轮询循环。
|
||||
* 每次请求携带 longPoll + waitForChange,服务端最长等待 60 秒后返回;
|
||||
* 收到响应后立刻发起下一次,直至绑定成功或 stopPollFlag 为 true。
|
||||
*/
|
||||
const startLongPoll = () => {
|
||||
stopPollFlag = false
|
||||
const version = pollVersion
|
||||
const poll = async () => {
|
||||
if (stopPollFlag || pollVersion !== version || isBound.value) return
|
||||
try {
|
||||
const res = await getBindWechatCode({
|
||||
longPoll: true,
|
||||
waitForChange: true,
|
||||
waitTimeoutMs: 60000
|
||||
})
|
||||
if (stopPollFlag || pollVersion !== version || isBound.value) return
|
||||
const data = res?.data
|
||||
if (data) {
|
||||
const bound = processBindData(data, true)
|
||||
if (bound) return // 已绑定,终止轮询
|
||||
}
|
||||
// 继续下一轮(不等待,立即发起)
|
||||
poll()
|
||||
} catch {
|
||||
// 网络异常时静默处理,稍后重试
|
||||
if (!stopPollFlag && pollVersion === version && !isBound.value) {
|
||||
setTimeout(poll, 3000)
|
||||
}
|
||||
}
|
||||
}
|
||||
poll()
|
||||
}
|
||||
|
||||
/** 停止长轮询 */
|
||||
const stopPolling = () => {
|
||||
stopPollFlag = true
|
||||
pollVersion++ // 递增版本号,使所有进行中的回调失效
|
||||
}
|
||||
|
||||
/**
|
||||
* 首次初始化二维码:携带 init:true,服务端立即返回二维码数据,不进入长等待。
|
||||
* 成功拿到数据后启动长轮询。
|
||||
*/
|
||||
const initQrCode = async () => {
|
||||
loading.value = true
|
||||
qrStatus.value = 'waiting'
|
||||
qrCodeUrl.value = ''
|
||||
hasInitQr = false
|
||||
try {
|
||||
const res = await getBindWechatCode({ init: true })
|
||||
const data = res?.data
|
||||
if (!data) throw new Error('无返回数据')
|
||||
const bound = processBindData(data)
|
||||
if (!bound) {
|
||||
hasInitQr = true
|
||||
startLongPoll()
|
||||
}
|
||||
} catch {
|
||||
ElMessage.error('获取二维码失败,请重试')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动刷新二维码(过期后点击触发):
|
||||
* 携带 forceRefresh:true + init:true,强制跳过缓存并立即返回。
|
||||
*/
|
||||
const refreshQrCode = async () => {
|
||||
stopPolling()
|
||||
loading.value = true
|
||||
qrStatus.value = 'waiting'
|
||||
qrCodeUrl.value = ''
|
||||
hasInitQr = false
|
||||
try {
|
||||
const res = await getBindWechatCode({ forceRefresh: true, init: true })
|
||||
const data = res?.data
|
||||
if (!data) throw new Error('无返回数据')
|
||||
const bound = processBindData(data)
|
||||
if (!bound) {
|
||||
hasInitQr = true
|
||||
startLongPoll()
|
||||
}
|
||||
} catch {
|
||||
ElMessage.error('获取二维码失败,请重试')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化:先查询绑定状态,未绑定则自动加载二维码 */
|
||||
const fetchBindInfo = async () => {
|
||||
try {
|
||||
const res = await getBindInfo()
|
||||
@ -88,115 +208,15 @@ const fetchBindInfo = async () => {
|
||||
binderInfo.openid = data.openid || ''
|
||||
} else {
|
||||
isBound.value = false
|
||||
await initQrCode()
|
||||
}
|
||||
} catch {
|
||||
// 获取失败不阻断页面
|
||||
// 查询失败时仍尝试显示二维码
|
||||
isBound.value = false
|
||||
await initQrCode()
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开绑定弹窗,获取二维码 */
|
||||
const handleBind = async () => {
|
||||
dialogVisible.value = true
|
||||
await refreshQrCode()
|
||||
}
|
||||
|
||||
/** 获取/刷新二维码,刷新完成后自动重启轮询 */
|
||||
const refreshQrCode = async () => {
|
||||
stopPolling() // 先停止旧的轮询,避免并发干扰
|
||||
loading.value = true
|
||||
qrStatus.value = 'waiting'
|
||||
qrCodeUrl.value = ''
|
||||
try {
|
||||
const res = await getBindWechatCode()
|
||||
const data = res?.data
|
||||
if (!data) throw new Error('无返回数据')
|
||||
|
||||
const isBoundNow = data.status === 'bound' || data.is_bound === true
|
||||
if (isBoundNow) {
|
||||
// 已绑定,直接刷新状态关闭弹窗
|
||||
isBound.value = true
|
||||
binderInfo.nickname = data.nickname || ''
|
||||
binderInfo.openid = data.openid || ''
|
||||
dialogVisible.value = false
|
||||
ElMessage.success('微信已绑定')
|
||||
return
|
||||
}
|
||||
|
||||
// 将后端 'pending' 归为 'waiting' 处理
|
||||
const mappedStatus = data.status === 'pending' ? 'waiting' : data.status as QrStatus
|
||||
qrStatus.value = mappedStatus
|
||||
// 有新 code 时更新二维码 URL
|
||||
if (data.code) {
|
||||
qrCodeUrl.value = qrBaseUrl + data.code
|
||||
}
|
||||
|
||||
// 刷新成功后重新启动轮询(过期状态不轮询,等待用户手动刷新)
|
||||
if (mappedStatus !== 'expired') {
|
||||
startPolling()
|
||||
}
|
||||
} catch {
|
||||
ElMessage.error('获取二维码失败,请重试')
|
||||
dialogVisible.value = false
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 启动轮询 */
|
||||
const startPolling = () => {
|
||||
stopPolling()
|
||||
pollTimer = setInterval(async () => {
|
||||
try {
|
||||
const res = await getBindWechatCode()
|
||||
const data = res?.data
|
||||
if (!data) return
|
||||
|
||||
// 将后端 'pending' 归为 'waiting' 处理
|
||||
const mappedStatus = data.status === 'pending' ? 'waiting' : data.status as QrStatus
|
||||
qrStatus.value = mappedStatus
|
||||
|
||||
// 更新二维码
|
||||
if (data.code) {
|
||||
qrCodeUrl.value = qrBaseUrl + data.code
|
||||
console.log('二维码已更新')
|
||||
}
|
||||
|
||||
const isBoundNow = data.status === 'bound' || data.is_bound === true
|
||||
if (isBoundNow) {
|
||||
stopPolling()
|
||||
isBound.value = true
|
||||
binderInfo.nickname = data.nickname || ''
|
||||
binderInfo.openid = data.openid || ''
|
||||
dialogVisible.value = false
|
||||
ElMessage.success(`微信绑定成功:${data.nickname || '微信用户'}`)
|
||||
}
|
||||
|
||||
// expired 状态不再停止轮询,等待后端更新 code 或 status
|
||||
if (data.status === 'expired') {
|
||||
// 可选:如果需要清除旧二维码,可以在这里处理
|
||||
// 但为了体验平滑,保持 overlay 覆盖在旧图上即可
|
||||
}
|
||||
} catch {
|
||||
// 轮询失败静默处理,不弹错误
|
||||
}
|
||||
}, POLL_INTERVAL)
|
||||
}
|
||||
|
||||
/** 停止轮询 */
|
||||
const stopPolling = () => {
|
||||
if (pollTimer) {
|
||||
clearInterval(pollTimer)
|
||||
pollTimer = null
|
||||
}
|
||||
}
|
||||
|
||||
/** 关闭弹窗时停止轮询 */
|
||||
const handleDialogClose = () => {
|
||||
stopPolling()
|
||||
qrStatus.value = 'waiting'
|
||||
qrCodeUrl.value = ''
|
||||
}
|
||||
|
||||
/** 解绑微信 */
|
||||
const handleUnbind = () => {
|
||||
ElMessageBox.confirm('确定要解除微信绑定吗?', '提示', {
|
||||
@ -211,6 +231,8 @@ const handleUnbind = () => {
|
||||
binderInfo.nickname = ''
|
||||
binderInfo.openid = ''
|
||||
ElMessage.success('微信绑定已解除')
|
||||
// 解绑后重新加载二维码
|
||||
await initQrCode()
|
||||
} catch {
|
||||
ElMessage.error('解绑失败,请重试')
|
||||
} finally {
|
||||
@ -273,16 +295,26 @@ onUnmounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
.qrcode-section {
|
||||
margin-top: 16px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.qrcode-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
padding: 20px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
background-color: var(--el-fill-color-blank);
|
||||
|
||||
.qrcode-img {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.qrcode-tip {
|
||||
@ -291,10 +323,8 @@ onUnmounted(() => {
|
||||
color: var(--el-text-color-secondary);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.loading-overlay,
|
||||
.expired-overlay,
|
||||
.scanned-overlay {
|
||||
|
||||
.status-overlay {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
display: flex;
|
||||
@ -313,6 +343,7 @@ onUnmounted(() => {
|
||||
|
||||
.loading-overlay {
|
||||
background: var(--el-fill-color-light);
|
||||
color: var(--el-text-color-secondary);
|
||||
.el-icon { color: var(--el-color-primary); }
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
|
||||
<!-- 微信绑定 -->
|
||||
<el-tab-pane label="微信绑定" name="bind">
|
||||
<Bind />
|
||||
<Bind v-if="activeTab === 'bind'" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-card>
|
||||
|
||||
@ -2,11 +2,11 @@
|
||||
<div class="upper-table-container">
|
||||
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="120px" :disabled="loading">
|
||||
<!-- 货主 -->
|
||||
<el-form-item label="货主" prop="store_id" title="商品归属货主">
|
||||
<!-- <el-form-item label="货主" prop="store_id" title="商品归属货主">
|
||||
<el-select v-model="formData.store_id" filterable clearable style="width: 100%;" placeholder="请选择货主">
|
||||
<el-option v-for="option in stores" :key="option.value" :label="option.label" :value="option.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
|
||||
<!-- 商品名称 -->
|
||||
<el-form-item label="商品名称" prop="item_name">
|
||||
@ -35,22 +35,26 @@
|
||||
<!-- 违禁品类型 -->
|
||||
<el-form-item label="违禁品类型" prop="prohibited_id">
|
||||
<div class="select-with-button">
|
||||
<el-select v-model="formData.prohibited_id" filterable clearable style="width: 100%;" placeholder="请选择违禁品类型"
|
||||
<el-select v-model="formData.prohibited_id" filterable clearable placeholder="请选择违禁品类型"
|
||||
@change="handleCustomChange">
|
||||
<el-option v-for="option in prohibitedTypes" :key="option.value" :label="option.label"
|
||||
:value="option.value" />
|
||||
</el-select>
|
||||
<el-button :icon="Plus" circle size="small" @click="openProhibitedDrawer" title="管理违禁品类型" />
|
||||
<el-button circle size="small" @click="openProhibitedDrawer" title="管理违禁品类型">
|
||||
<el-icon><Plus /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 库存单位 -->
|
||||
<el-form-item label="库存单位" prop="stock_unit">
|
||||
<div class="select-with-button">
|
||||
<el-select v-model="formData.stock_unit" filterable clearable style="width: 100%;" placeholder="请选择库存单位">
|
||||
<el-select v-model="formData.stock_unit" filterable clearable placeholder="请选择库存单位">
|
||||
<el-option v-for="unit in stockUnits" :key="unit.value" :label="unit.label" :value="unit.value" />
|
||||
</el-select>
|
||||
<el-button :icon="Plus" circle size="small" @click="openUnitDrawer" title="管理库存单位" />
|
||||
<el-button circle size="small" @click="openUnitDrawer" title="管理库存单位">
|
||||
<el-icon><Plus /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
@ -220,8 +224,14 @@
|
||||
<!-- 底部操作按钮 -->
|
||||
<div class="bottom">
|
||||
<el-button-group class="toolbar-btn-group">
|
||||
<el-button type="primary" size="small" :icon="Check" @click="handleSave" title="保存">保存</el-button>
|
||||
<el-button type="danger" size="small" :icon="Refresh" @click="resetForm" title="重置">重置</el-button>
|
||||
<el-button type="primary" size="small" @click="handleSave" title="保存">
|
||||
<el-icon><Check /></el-icon>
|
||||
保存
|
||||
</el-button>
|
||||
<el-button type="danger" size="small" @click="resetForm" title="重置">
|
||||
<el-icon><Refresh /></el-icon>
|
||||
重置
|
||||
</el-button>
|
||||
</el-button-group>
|
||||
</div>
|
||||
|
||||
@ -759,6 +769,14 @@ onMounted(() => {
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
|
||||
:deep(.el-select) {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
:deep(.el-button) {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.management-flags {
|
||||
|
||||
@ -383,10 +383,24 @@ const confirmBatchDelete = () => {
|
||||
ElMessageBox.confirm('确认删除选中项?', '提示', {
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
// await stockApi.batchDelete(selectionIds.value)
|
||||
ElMessage.success('删除成功')
|
||||
loadData()
|
||||
})
|
||||
try {
|
||||
loading.value = true
|
||||
const res = await stockApi.handleBatchDelete({
|
||||
ids: selectionIds.value.map((item: any) => item.id)
|
||||
})
|
||||
if ((res as any).code === 200) {
|
||||
ElMessage.success((res as any).message || '删除成功')
|
||||
loadData()
|
||||
selectionIds.value = []
|
||||
} else {
|
||||
ElMessage.error((res as any).message || '删除失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
const handleBatchChange = async (command: string) => {
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
<div class="header-actions">
|
||||
<div class="left-actions">
|
||||
<el-button size="small" @click="loadEntryDetail">刷新</el-button>
|
||||
<el-button size="small" disabled>入库</el-button>
|
||||
<el-button size="small" type="primary" disabled>批量入库</el-button>
|
||||
<el-button size="small" @click="handleAddDetail">新增入库</el-button>
|
||||
<!-- <el-button size="small" type="primary" disabled>批量入库</el-button> -->
|
||||
<el-button size="small" disabled>EXCEL导出</el-button>
|
||||
<el-button size="small" disabled>导出</el-button>
|
||||
</div>
|
||||
@ -38,12 +38,33 @@
|
||||
</template>
|
||||
</UpperTable>
|
||||
</div>
|
||||
|
||||
<!-- 新增入库明细对话框 -->
|
||||
<el-dialog
|
||||
v-model="addDialogVisible"
|
||||
title="新增入库明细"
|
||||
width="450px"
|
||||
append-to-body
|
||||
>
|
||||
<el-form :model="addForm" :rules="addRules" ref="addFormRef" label-width="120px" size="small">
|
||||
<el-form-item label="计划入库数量" prop="count">
|
||||
<el-input-number v-model="addForm.count" :min="1" style="width: 100%" placeholder="请输入数量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商品编码" prop="item_code">
|
||||
<el-input v-model="addForm.item_code" placeholder="请输入商品编码" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button size="small" @click="addDialogVisible = false">取消</el-button>
|
||||
<el-button size="small" type="primary" :loading="addLoading" @click="submitAddDetail">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, watch, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import * as entryApi from '@/api/storage/entry'
|
||||
|
||||
@ -70,6 +91,20 @@ const detailColumns = ref(entrydetail)
|
||||
|
||||
const emit = defineEmits(['refresh'])
|
||||
|
||||
// 新增明细相关
|
||||
const addDialogVisible = ref(false)
|
||||
const addLoading = ref(false)
|
||||
const addFormRef = ref<FormInstance>()
|
||||
const addForm = reactive({
|
||||
count: 1,
|
||||
item_code: ''
|
||||
})
|
||||
|
||||
const addRules = reactive<FormRules>({
|
||||
count: [{ required: true, message: '请输入计划入库数量', trigger: 'blur' }],
|
||||
item_code: [{ required: false }]
|
||||
})
|
||||
|
||||
// 监听 ID 变化加载数据
|
||||
watch(() => props.id, (newVal) => {
|
||||
if (newVal) {
|
||||
@ -132,6 +167,48 @@ async function loadEntryDetail() {
|
||||
}
|
||||
}
|
||||
|
||||
function handleAddDetail() {
|
||||
if (!props.id) {
|
||||
ElMessage.warning('请先选择入库单')
|
||||
return
|
||||
}
|
||||
addForm.count = 1
|
||||
addForm.item_code = ''
|
||||
addDialogVisible.value = true
|
||||
}
|
||||
|
||||
async function submitAddDetail() {
|
||||
if (!addFormRef.value) return
|
||||
|
||||
await addFormRef.value.validate(async (valid) => {
|
||||
if (!valid) return
|
||||
|
||||
addLoading.value = true
|
||||
try {
|
||||
const params = {
|
||||
order_id: Number(props.id),
|
||||
count: addForm.count,
|
||||
item_code: addForm.item_code
|
||||
}
|
||||
|
||||
const res = await entryApi.addDetail(params)
|
||||
if (res && res.code === 200) {
|
||||
ElMessage.success('新增明细成功')
|
||||
addDialogVisible.value = false
|
||||
loadEntryDetail()
|
||||
emit('refresh')
|
||||
} else {
|
||||
ElMessage.error(res?.message || '新增失败')
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('新增明细错误:', e)
|
||||
ElMessage.error('操作失败')
|
||||
} finally {
|
||||
addLoading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const handleSelectionChange = (val: any[]) => {
|
||||
multipleSelection.value = val
|
||||
}
|
||||
|
||||
@ -91,4 +91,21 @@ export const detailpanel = [
|
||||
{ label: '运单号', prop: 'express_code' },
|
||||
{ label: '物流公司', prop: 'logistics_name' },
|
||||
{ label: '备注', prop: 'remark' }
|
||||
]
|
||||
|
||||
export const addEntryFields = [
|
||||
{ label: '业务类型', prop: 'order_type', type: 'select', options: [
|
||||
{ label: '生产入库', value: 'SCRK' },
|
||||
{ label: '领用入库', value: 'LYRK' },
|
||||
{ label: '拆解入库', value: 'CCRK' },
|
||||
{ label: '采购入库', value: 'CGRK' },
|
||||
{ label: '调拨入库', value: 'DBRK' },
|
||||
{ label: '其他入库', value: 'QTRK' },
|
||||
{ label: 'B2B入库', value: 'B2BRK' },
|
||||
{ label: '虚拟入库', value: 'XNRK' },
|
||||
]},
|
||||
{ label: '货主', prop: 'store_id', type: 'select', options: [] },
|
||||
{ label: '入库单号', prop: 'entry_order_code' },
|
||||
{ label: '采购单号', prop: 'purchase_order_code' },
|
||||
{ label: '备注', prop: 'remark', type: 'textarea' }
|
||||
]
|
||||
@ -17,6 +17,7 @@
|
||||
<div class="toolbar-left">
|
||||
<el-button size="small" type="primary" @click="loadData">刷新</el-button>
|
||||
<el-button size="small" @click="handleCreateEntry">新建入库单</el-button>
|
||||
<el-button size="small" @click="handleCompleteEntry">完成入库</el-button>
|
||||
<el-button size="small" :disabled="!hasSelection" @click="confirmBatchCancel">批量作废</el-button>
|
||||
<el-button size="small" :loading="exportLoading" @click="handleExport">导出</el-button>
|
||||
<el-button size="small" @click="handleImport">导入</el-button>
|
||||
@ -96,6 +97,32 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 新建入库单对话框 -->
|
||||
<el-dialog
|
||||
v-model="createDialogVisible"
|
||||
title="新建入库单"
|
||||
width="600px"
|
||||
@closed="handleCreateDialogClosed"
|
||||
>
|
||||
<el-form :model="createForm" label-width="100px" size="small">
|
||||
<el-row :gutter="20">
|
||||
<el-col v-for="field in addEntryFieldsRef" :key="field.prop" :span="field.type === 'textarea' ? 24 : 12">
|
||||
<el-form-item :label="field.label">
|
||||
<el-select v-if="field.type === 'select'" v-model="createForm[field.prop]" :placeholder="'请选择' + field.label" style="width: 100%" filterable>
|
||||
<el-option v-for="opt in field.options" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||
</el-select>
|
||||
<el-input v-else-if="field.type === 'textarea'" v-model="createForm[field.prop]" type="textarea" :rows="3" :placeholder="'请输入' + field.label" />
|
||||
<el-input v-else v-model="createForm[field.prop]" :placeholder="'请输入' + field.label" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button size="small" @click="createDialogVisible = false">取消</el-button>
|
||||
<el-button size="small" type="primary" :loading="createLoading" @click="submitCreateEntry">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -110,6 +137,7 @@ import * as entryApi from '@/api/storage/entry'
|
||||
import {
|
||||
availableFields,
|
||||
entryColums,
|
||||
addEntryFields
|
||||
} from './entry-config'
|
||||
|
||||
import entrydetail from './component/entrydetail.vue'
|
||||
@ -121,6 +149,7 @@ const upperTable = ref<any>(null)
|
||||
|
||||
const presetTree = ref<any[]>([])
|
||||
const availableFieldsRef = reactive(JSON.parse(JSON.stringify(availableFields)))
|
||||
const addEntryFieldsRef = reactive(JSON.parse(JSON.stringify(addEntryFields)))
|
||||
|
||||
const activeTab = ref('details')
|
||||
|
||||
@ -331,8 +360,12 @@ async function loadFilterData() {
|
||||
indexApi.fastWhereTree('entry')
|
||||
])
|
||||
if (storesRes && storesRes.code === 200) {
|
||||
const stores = storesRes.stores || []
|
||||
const f = availableFieldsRef.find((i: any) => i.value === 'store_id')
|
||||
if (f) f.options = storesRes.stores || []
|
||||
if (f) f.options = stores
|
||||
|
||||
const af = addEntryFieldsRef.find((i: any) => i.prop === 'store_id')
|
||||
if (af) af.options = stores
|
||||
}
|
||||
if (presetRes && presetRes.code === 200) {
|
||||
presetTree.value = presetRes.presetTree || []
|
||||
@ -392,10 +425,79 @@ function onQuickSearch() {
|
||||
loadData()
|
||||
}
|
||||
|
||||
// 新建入库单相关
|
||||
const createDialogVisible = ref(false)
|
||||
const createLoading = ref(false)
|
||||
const createForm = reactive<any>({
|
||||
order_type: '',
|
||||
store_id: '',
|
||||
entry_order_code: '',
|
||||
purchase_order_code: '',
|
||||
remark: ''
|
||||
})
|
||||
|
||||
function handleCreateEntry() {
|
||||
ElMessage.info('新建入库单')
|
||||
Object.keys(createForm).forEach(key => createForm[key] = '')
|
||||
createDialogVisible.value = true
|
||||
}
|
||||
|
||||
async function handleCompleteEntry() {
|
||||
if (!selectedEntryId.value) {
|
||||
ElMessage.warning('请先选择一个入库单')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(`确定要完成入库单 ${selectedEntryId.value} 吗?`, '确认', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'success'
|
||||
})
|
||||
|
||||
loading.value = true
|
||||
const res = await entryApi.completeEntry({ id: selectedEntryId.value })
|
||||
if (res && res.code === 200) {
|
||||
ElMessage.success('入库单操作完成')
|
||||
loadData()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '操作失败')
|
||||
}
|
||||
} catch (e) {
|
||||
if (e !== 'cancel') {
|
||||
console.error('完成入库单出错:', e)
|
||||
ElMessage.error('操作异常')
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleCreateDialogClosed() {
|
||||
Object.keys(createForm).forEach(key => createForm[key] = '')
|
||||
}
|
||||
|
||||
async function submitCreateEntry() {
|
||||
if (!createForm.order_type) {
|
||||
ElMessage.warning('请选择业务类型')
|
||||
return
|
||||
}
|
||||
|
||||
createLoading.value = true
|
||||
try {
|
||||
const res = await entryApi.createEntry(createForm)
|
||||
if (res && res.code === 200) {
|
||||
ElMessage.success('新建入库单成功')
|
||||
createDialogVisible.value = false
|
||||
loadData()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '新建失败')
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('新建入库单出错:', e)
|
||||
ElMessage.error('新建入库单失败')
|
||||
} finally {
|
||||
createLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmBatchCancel() {
|
||||
if (!selectionRows.value.length) {
|
||||
@ -404,10 +506,28 @@ async function confirmBatchCancel() {
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(`确定要批量作废 ${selectionRows.value.length} 个入库单吗?`, '确认', { type: 'warning' })
|
||||
// 调用作废 API
|
||||
ElMessage.success('操作成功')
|
||||
loadData()
|
||||
} catch (e) {}
|
||||
|
||||
loading.value = true
|
||||
// 提取所有选中的入库单 ID
|
||||
const ids = selectionRows.value.map(row => row.id)
|
||||
|
||||
// 调用 cancelEntry 接口,传入 ID 数组
|
||||
const res = await entryApi.cancelEntry({ ids })
|
||||
|
||||
if (res && res.code === 200) {
|
||||
ElMessage.success('批量作废成功')
|
||||
loadData() // 刷新列表
|
||||
} else {
|
||||
ElMessage.error(res?.message || '作废失败')
|
||||
}
|
||||
} catch (e) {
|
||||
if (e !== 'cancel') {
|
||||
console.error('批量作废出错:', e)
|
||||
ElMessage.error('操作失败')
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleExport() {
|
||||
|
||||
@ -18,11 +18,11 @@
|
||||
<div class="toolbar-left">
|
||||
<el-button size="small" type="primary" @click="loadData">刷新</el-button>
|
||||
<el-button size="small" @click="handleCreateReceiving">新建收货单</el-button>
|
||||
<el-button type="success" size="small" icon="el-icon-delete" @click="confirmBatchCancel" title="批量作废"
|
||||
<el-button type="success" size="small" icon="el-icon-delete" @click="confirmcomplete" title="入库单入库"
|
||||
:disabled="!hasSelection" class="toolbar-btn">
|
||||
入库单入库
|
||||
</el-button>
|
||||
<el-button type="primary" size="small" icon="el-icon-delete" @click="confirmBatchCancel" title="批量作废"
|
||||
<el-button type="primary" size="small" icon="el-icon-delete" @click="confirmcomplete" title="一键入库"
|
||||
:disabled="!hasSelection" class="toolbar-btn">
|
||||
一键入库
|
||||
</el-button>
|
||||
@ -905,7 +905,7 @@ async function doPrint() {
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmBatchCancel() {
|
||||
async function confirmcomplete() {
|
||||
if (!selectionRows.value.length) {
|
||||
ElMessage.warning('请先选择要操作的收货单')
|
||||
return
|
||||
@ -914,9 +914,6 @@ async function confirmBatchCancel() {
|
||||
try {
|
||||
await ElMessageBox.confirm(`确定要批量完成 ${selectionRows.value.length} 个收货单的收货吗?`, '确认完成', { type: 'success' })
|
||||
|
||||
// 根据后端报错推断:WHERE parameter "id" has invalid "undefined" value
|
||||
// 后端执行 SQL 语句时缺少 id 参数。
|
||||
// 这里采用遍历方式对选中的每一行调用 completeReceiving,并传入 id 字段
|
||||
for (const row of selectionRows.value) {
|
||||
console.log('正在执行完成收货,请求数据:', { id: row.id, type: 'complete' })
|
||||
// 传递 id 标识单号,以及 type: 'complete' 来表示完成收货操作(补全请求数据)
|
||||
@ -935,7 +932,35 @@ async function confirmBatchCancel() {
|
||||
} catch (e) {
|
||||
if (e !== 'cancel') {
|
||||
console.error('完成收货操作出错:', e)
|
||||
ElMessage.error('操作执行失败')
|
||||
// ElMessage.error('操作执行失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmBatchCancel() {
|
||||
if (!selectionRows.value.length) {
|
||||
ElMessage.warning('请先选择要操作的收货单')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(`确定要批量作废 ${selectionRows.value.length} 个收货单吗?`, '确认作废', { type: 'warning' })
|
||||
|
||||
const ids = selectionRows.value.map(row => row.id)
|
||||
const res: any = await receivingApi.batchCancelReceiving({ ids })
|
||||
|
||||
if (res && res.code === 200) {
|
||||
ElMessage.success('批量作废成功')
|
||||
} else {
|
||||
ElMessage.error(res.message || '批量作废失败')
|
||||
}
|
||||
|
||||
selectionRows.value = []
|
||||
loadData()
|
||||
} catch (e) {
|
||||
if (e !== 'cancel') {
|
||||
console.error('批量作废操作出错:', e)
|
||||
// ElMessage.error('操作执行失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,7 +218,7 @@ export const detailpanel = [
|
||||
{ prop: 'receiving_number', label: '收货单号', type: 'input', disabled: true },
|
||||
{ prop: 'store_name', label: '货主', type: 'input', disabled: true },
|
||||
{ prop: 'creator_name', label: '创建人', type: 'input', disabled: true },
|
||||
{ prop: 'status', label: '收货状态', type: 'select' },
|
||||
{ prop: 'status', label: '收货状态', type: 'select', disabled: true},
|
||||
{ prop: 'detail_status', label: '匹配状态', type: 'select' },
|
||||
{ prop: 'storage_status', label: '入库状态', type: 'select' },
|
||||
{ prop: 'delivery_method', label: '来货方式', type: 'select' },
|
||||
|
||||
79
src/views/storage/stockout/component/log.vue
Normal file
79
src/views/storage/stockout/component/log.vue
Normal file
@ -0,0 +1,79 @@
|
||||
<template>
|
||||
<div class="stockout-log-container">
|
||||
<el-timeline v-if="logs.length">
|
||||
<el-timeline-item
|
||||
v-for="(log, index) in logs"
|
||||
:key="index"
|
||||
:timestamp="log.created_at"
|
||||
:type="log.type"
|
||||
:color="log.color"
|
||||
size="large"
|
||||
>
|
||||
<div class="log-content">
|
||||
<span class="operator">{{ log.operator_name }}</span>
|
||||
<span class="action">{{ log.action }}</span>
|
||||
<p v-if="log.remark" class="remark">{{ log.remark }}</p>
|
||||
</div>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
<el-empty v-else description="暂无操作日志" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
id: string | number
|
||||
}>()
|
||||
|
||||
const logs = ref<any[]>([])
|
||||
|
||||
const loadLogs = async () => {
|
||||
if (!props.id) return
|
||||
// 模拟日志数据
|
||||
logs.value = [
|
||||
{
|
||||
created_at: '2026-03-27 10:00:00',
|
||||
operator_name: '管理员',
|
||||
action: '创建出库单',
|
||||
type: 'primary',
|
||||
remark: '系统自动创建'
|
||||
},
|
||||
{
|
||||
created_at: '2026-03-27 10:05:00',
|
||||
operator_name: '仓库员',
|
||||
action: '确认出库',
|
||||
type: 'success',
|
||||
remark: '已拣货并打包'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
watch(() => props.id, loadLogs, { immediate: true })
|
||||
|
||||
onMounted(loadLogs)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.stockout-log-container {
|
||||
padding: 20px;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
|
||||
.log-content {
|
||||
.operator {
|
||||
font-weight: bold;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.action {
|
||||
color: #409eff;
|
||||
}
|
||||
.remark {
|
||||
margin-top: 5px;
|
||||
color: #909399;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
64
src/views/storage/stockout/component/product.vue
Normal file
64
src/views/storage/stockout/component/product.vue
Normal file
@ -0,0 +1,64 @@
|
||||
<template>
|
||||
<div class="stockout-product-container">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="data"
|
||||
border
|
||||
size="small"
|
||||
height="100%"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column
|
||||
v-for="col in productColumns"
|
||||
:key="col.prop"
|
||||
:prop="col.prop"
|
||||
:label="col.label"
|
||||
:width="col.width"
|
||||
:min-width="col.minWidth"
|
||||
:fixed="col.fixed"
|
||||
:align="col.align"
|
||||
/>
|
||||
</el-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch } from 'vue'
|
||||
import { productColumns } from '../stockout-config'
|
||||
import * as entryApi from '@/api/storage/entry'
|
||||
|
||||
const props = defineProps<{
|
||||
id: string | number
|
||||
}>()
|
||||
|
||||
const data = ref([])
|
||||
const loading = ref(false)
|
||||
|
||||
const loadData = async () => {
|
||||
if (!props.id) return
|
||||
loading.value = true
|
||||
try {
|
||||
const res: any = await entryApi.getEntryDetail({ id: props.id })
|
||||
if (res && res.code === 200) {
|
||||
// 假设详情中有 details 数组
|
||||
data.value = res.data.details || []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载商品明细失败', error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => props.id, loadData, { immediate: true })
|
||||
|
||||
onMounted(loadData)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.stockout-product-container {
|
||||
height: 100%;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
169
src/views/storage/stockout/component/stockoutdetail.vue
Normal file
169
src/views/storage/stockout/component/stockoutdetail.vue
Normal file
@ -0,0 +1,169 @@
|
||||
<template>
|
||||
<div class="stockout-details-container">
|
||||
<el-form :model="form" label-width="120px" class="details-form">
|
||||
<el-row :gutter="30">
|
||||
<el-col :span="12">
|
||||
<el-form-item
|
||||
v-for="field in detailpanel"
|
||||
:key="field.prop"
|
||||
:label="field.label"
|
||||
:prop="field.prop"
|
||||
>
|
||||
<template v-if="field.type === 'select'">
|
||||
<el-select
|
||||
v-model="(form as any)[field.prop]"
|
||||
:placeholder="'请选择' + field.label"
|
||||
style="width: 100%"
|
||||
:disabled="field.disabled"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in availableFields.find(f => f.value === field.prop)?.options || []"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
<template v-else-if="field.type === 'textarea'">
|
||||
<el-input
|
||||
v-model="(form as any)[field.prop]"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
:disabled="field.disabled"
|
||||
:placeholder="'请输入' + field.label"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-input
|
||||
v-model="(form as any)[field.prop]"
|
||||
:disabled="field.disabled"
|
||||
:placeholder="'请输入' + field.label"
|
||||
/>
|
||||
</template>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12">
|
||||
<div class="image-placeholder">
|
||||
<div class="placeholder-content">
|
||||
<el-icon :size="48" color="#909399"><Picture /></el-icon>
|
||||
<p>出库单图片/附件区</p>
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
|
||||
<div class="bottom">
|
||||
<el-button-group class="toolbar-btn-group">
|
||||
<el-button type="primary" icon="Check" @click="handleSave" :loading="saveLoading">
|
||||
保存
|
||||
</el-button>
|
||||
<el-button type="danger" icon="Refresh" @click="handleReset">
|
||||
重置
|
||||
</el-button>
|
||||
</el-button-group>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, onMounted } from 'vue'
|
||||
import { availableFields, detailpanel } from '../stockout-config'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Picture, Check, Refresh } from '@element-plus/icons-vue'
|
||||
|
||||
const props = defineProps<{
|
||||
id: string | number,
|
||||
row?: any
|
||||
}>()
|
||||
|
||||
const form = ref<any>({})
|
||||
|
||||
const saveLoading = ref(false)
|
||||
|
||||
const handleSave = async () => {
|
||||
try {
|
||||
saveLoading.value = true
|
||||
// 这里调用 API 保存
|
||||
ElMessage.success('保存成功')
|
||||
} catch (error) {
|
||||
ElMessage.error('保存失败')
|
||||
} finally {
|
||||
saveLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleReset = () => {
|
||||
if (props.row) {
|
||||
form.value = { ...props.row }
|
||||
}
|
||||
ElMessage.info('表单已重置')
|
||||
}
|
||||
|
||||
watch(() => props.row, (newRow) => {
|
||||
if (newRow) {
|
||||
form.value = { ...newRow }
|
||||
}
|
||||
}, { immediate: true })
|
||||
|
||||
onMounted(() => {
|
||||
if (props.row) {
|
||||
form.value = { ...props.row }
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.stockout-details-container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.details-form {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 20px;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
-ms-overflow-style: none;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.image-placeholder {
|
||||
width: 100%;
|
||||
height: 400px;
|
||||
background-color: #f5f7fa;
|
||||
border: 1px dashed #dcdfe6;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.placeholder-content {
|
||||
text-align: center;
|
||||
color: #909399;
|
||||
|
||||
p {
|
||||
margin-top: 10px;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.bottom {
|
||||
flex-shrink: 0;
|
||||
text-align: right;
|
||||
padding: 10px 20px;
|
||||
border-top: 1px solid #ebeef5;
|
||||
background-color: #fff;
|
||||
z-index: 10;
|
||||
}
|
||||
</style>
|
||||
392
src/views/storage/stockout/index.vue
Normal file
392
src/views/storage/stockout/index.vue
Normal file
@ -0,0 +1,392 @@
|
||||
<template>
|
||||
<div class="storage-stockout-container">
|
||||
<scan-box
|
||||
ref="scanBox"
|
||||
width="320px"
|
||||
:tree-props="{ children: 'children', label: 'label' }"
|
||||
:auto-submit="false"
|
||||
:preset-tree="presetTree"
|
||||
:available-fields="availableFieldsRef"
|
||||
@condition-change="handleConditionChange"
|
||||
@reset="handleConditionReset"
|
||||
@condition-clear="handleConditionClear"
|
||||
@submit="handleSubmit"
|
||||
/>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="toolbar">
|
||||
<div class="toolbar-left">
|
||||
<el-button size="small" type="primary" @click="loadData">刷新</el-button>
|
||||
<el-button size="small" @click="handleCreateStockout">新建出库单</el-button>
|
||||
<el-button size="small" :disabled="!hasSelection" @click="confirmBatchCancel">批量作废</el-button>
|
||||
<el-button size="small" :loading="exportLoading" @click="handleExport">导出</el-button>
|
||||
<el-button size="small" @click="handleImport">导入</el-button>
|
||||
</div>
|
||||
|
||||
<div class="toolbar-right">
|
||||
<el-input size="small" placeholder="搜索出库单号" v-model="quickSearch" style="width:220px" @keyup.enter.native="onQuickSearch" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="upper-wrapper">
|
||||
<upper-table
|
||||
ref="upperTable"
|
||||
title="出库单列表"
|
||||
:data="list"
|
||||
:columns="columns"
|
||||
:table-size="tableSize"
|
||||
:pagination="pagination"
|
||||
:show-index="true"
|
||||
:show-actions="true"
|
||||
:show-selection="true"
|
||||
:loading="loading"
|
||||
:queryTime="queryTime"
|
||||
@current-change="handleRowClick"
|
||||
@page-change="handlePageChange"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
@sort-change="handleSortChange"
|
||||
@refresh="loadData"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<template #column-status="{ row }">
|
||||
<el-tag v-if="row.status" :type="statusConfig[row.status as keyof typeof statusConfig]?.tagType || 'info'" size="small">
|
||||
{{ statusConfig[row.status as keyof typeof statusConfig]?.text || row.status }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<template #column-sync_status="{ row }">
|
||||
<el-tag v-if="row.sync_status" :type="syncStatusConfig[row.sync_status as keyof typeof syncStatusConfig]?.tagType || 'info'" size="small">
|
||||
{{ syncStatusConfig[row.sync_status as keyof typeof syncStatusConfig]?.text || row.sync_status }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<template #empty>
|
||||
<div class="empty-tip">暂无出库单</div>
|
||||
</template>
|
||||
</upper-table>
|
||||
</div>
|
||||
|
||||
<div class="lower-level" v-if="selectedStockoutId" :class="tableSize">
|
||||
<div class="detail-header">
|
||||
<el-tabs v-model="activeTab" class="detail-tab">
|
||||
<el-tab-pane label="出库详情" name="details" />
|
||||
<el-tab-pane label="商品明细" name="product" />
|
||||
<el-tab-pane label="操作日志" name="logs" />
|
||||
</el-tabs>
|
||||
</div>
|
||||
|
||||
<div class="detail-container">
|
||||
<KeepAlive>
|
||||
<component
|
||||
:is="activeComponent"
|
||||
:id="selectedStockoutId"
|
||||
:row="selectedRow"
|
||||
@refresh="loadData"
|
||||
/>
|
||||
</KeepAlive>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="no-selection" v-else>
|
||||
<div class="empty-tip">
|
||||
<p>请从上方列表中选择一项查看详情</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import * as indexApi from '@/api/index'
|
||||
import * as stockoutApi from '@/api/storage/stockout' //现有的对应 API
|
||||
|
||||
import {
|
||||
availableFields,
|
||||
entryColums,
|
||||
statusConfig,
|
||||
syncStatusConfig,
|
||||
formatStockoutData
|
||||
} from './stockout-config'
|
||||
|
||||
import stockoutdetail from './component/stockoutdetail.vue'
|
||||
import product from './component/product.vue'
|
||||
import log from './component/log.vue'
|
||||
|
||||
const scanBox = ref<any>(null)
|
||||
const upperTable = ref<any>(null)
|
||||
|
||||
const presetTree = ref<any[]>([])
|
||||
const availableFieldsRef = reactive(JSON.parse(JSON.stringify(availableFields)))
|
||||
|
||||
const activeTab = ref('details')
|
||||
|
||||
const list = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const exportLoading = ref(false)
|
||||
const queryTime = ref(0)
|
||||
|
||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
const tableSize = ref('small')
|
||||
const columns = ref(entryColums)
|
||||
|
||||
const selectionRows = ref<any[]>([])
|
||||
const hasSelection = ref(false)
|
||||
const selectedStockoutId = ref<number | string | null>(null)
|
||||
|
||||
const quickSearch = ref('')
|
||||
const currentSort = reactive({ prop: '', order: '' })
|
||||
const currentCondition = ref<any>(null)
|
||||
|
||||
const componentMap: Record<string, any> = {
|
||||
details: stockoutdetail,
|
||||
product: product,
|
||||
logs: log
|
||||
}
|
||||
|
||||
const activeComponent = computed(() => componentMap[activeTab.value] || componentMap.details)
|
||||
|
||||
const selectedRow = computed(() => {
|
||||
return list.value.find((i: any) => i.id === selectedStockoutId.value) || null
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
loadFilterData()
|
||||
})
|
||||
|
||||
async function loadData() {
|
||||
if (loading.value) return
|
||||
loading.value = true
|
||||
const start = Date.now()
|
||||
try {
|
||||
const where = currentCondition.value || {}
|
||||
const params: any = {
|
||||
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
|
||||
where,
|
||||
order: currentSort.prop ? { [currentSort.prop]: currentSort.order === 'ascending' ? 'ASC' : 'DESC' } : undefined
|
||||
}
|
||||
|
||||
if (quickSearch.value) {
|
||||
params.where = { ...(params.where || {}), entry_order_code: quickSearch.value }
|
||||
}
|
||||
|
||||
const res: any = await stockoutApi.stockoutList(params)
|
||||
if (res && res.code === 200) {
|
||||
list.value = formatStockoutData(res.data.list || [])
|
||||
pagination.currentPage = res.data.pagination?.currentPage || pagination.currentPage
|
||||
pagination.pageSize = res.data.pagination?.pageSize || pagination.pageSize
|
||||
pagination.total = res.data.pagination?.total || 0
|
||||
} else {
|
||||
ElMessage.error(res?.message || '加载失败')
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
ElMessage.error('加载出库单失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
queryTime.value = Date.now() - start
|
||||
}
|
||||
}
|
||||
|
||||
async function loadFilterData() {
|
||||
try {
|
||||
const [storesRes, presetRes]: any = await Promise.all([
|
||||
indexApi.loadStores({ type: 'entry' }),
|
||||
indexApi.fastWhereTree('entry')
|
||||
])
|
||||
if (storesRes && storesRes.code === 200) {
|
||||
const f = availableFieldsRef.find((i: any) => i.value === 'store_id')
|
||||
if (f) f.options = storesRes.stores || []
|
||||
}
|
||||
if (presetRes && presetRes.code === 200) {
|
||||
presetTree.value = presetRes.presetTree || []
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('加载筛选配置失败', e)
|
||||
}
|
||||
}
|
||||
|
||||
function handleConditionChange(condition: any) {
|
||||
currentCondition.value = condition
|
||||
pagination.currentPage = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function handleSortChange({ prop, order }: any) {
|
||||
currentSort.prop = prop
|
||||
currentSort.order = order
|
||||
pagination.currentPage = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function handleSubmit() {
|
||||
pagination.currentPage = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
const handleConditionClear = () => {
|
||||
currentCondition.value = null
|
||||
pagination.currentPage = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function handleConditionReset() {
|
||||
currentCondition.value = null
|
||||
pagination.currentPage = 1
|
||||
if (scanBox.value?.reset) {
|
||||
scanBox.value.reset()
|
||||
}
|
||||
loadData()
|
||||
}
|
||||
|
||||
function onSelectionChange(rows: any[]) {
|
||||
selectionRows.value = rows || []
|
||||
hasSelection.value = selectionRows.value.length > 0
|
||||
}
|
||||
|
||||
async function handleRowClick(row: any) {
|
||||
selectedStockoutId.value = row?.id || null
|
||||
}
|
||||
|
||||
function handlePageChange(page: number) {
|
||||
pagination.currentPage = page
|
||||
loadData()
|
||||
}
|
||||
|
||||
function handlePageSizeChange(size: number) {
|
||||
pagination.pageSize = size
|
||||
pagination.currentPage = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function onQuickSearch() {
|
||||
pagination.currentPage = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function handleCreateStockout() {
|
||||
ElMessage.info('新建出库单功能')
|
||||
}
|
||||
|
||||
async function confirmBatchCancel() {
|
||||
if (!selectionRows.value.length) {
|
||||
ElMessage.warning('请先选择要作废的出库单')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(`确定要批量作废 ${selectionRows.value.length} 个出库单吗?`, '确认', { type: 'warning' })
|
||||
// 调用 API
|
||||
ElMessage.success('批量作废成功')
|
||||
loadData()
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
async function handleExport() {
|
||||
exportLoading.value = true
|
||||
setTimeout(() => {
|
||||
exportLoading.value = false
|
||||
ElMessage.success('导出成功')
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
function handleImport() {
|
||||
ElMessage.info('导入功能')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.storage-stockout-container {
|
||||
display: flex;
|
||||
height: calc(100vh - 130px);
|
||||
width: 100%;
|
||||
background-color: #f0f2f5;
|
||||
|
||||
.main-content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px;
|
||||
overflow: hidden;
|
||||
|
||||
.toolbar {
|
||||
padding: 5px;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background-color: #fff;
|
||||
}
|
||||
.toolbar-right {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap:15px;
|
||||
height: 30px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.upper-wrapper {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.upper-wrapper :deep(.upper-table-container) {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.lower-level {
|
||||
flex: 0 0 40%;
|
||||
height: 40%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-top: 1px solid #ebeef5;
|
||||
overflow: hidden;
|
||||
background-color: #fff;
|
||||
|
||||
.detail-header {
|
||||
padding: 0 10px;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
background-color: #fafafa;
|
||||
|
||||
.detail-tab {
|
||||
margin-bottom: -1px;
|
||||
|
||||
:deep(.el-tabs__header) {
|
||||
margin: 0;
|
||||
}
|
||||
:deep(.el-tabs__item) {
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
font-size: 13px;
|
||||
}
|
||||
:deep(.el-tabs__nav-wrap::after) {
|
||||
height: 1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.detail-container {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.no-selection {
|
||||
flex: 0 0 40%;
|
||||
height: 40%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #909399;
|
||||
background-color: #fff;
|
||||
|
||||
.empty-tip { text-align: center; font-size: 14px; }
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
96
src/views/storage/stockout/stockout-config.ts
Normal file
96
src/views/storage/stockout/stockout-config.ts
Normal file
@ -0,0 +1,96 @@
|
||||
export const statusConfig = {
|
||||
pending: { text: '待出库', tagType: 'warning' },
|
||||
processing: { text: '出库中', tagType: 'primary' },
|
||||
completed: { text: '已完成', tagType: 'success' },
|
||||
cancelled: { text: '已作废', tagType: 'danger' }
|
||||
}
|
||||
|
||||
export const syncStatusConfig = {
|
||||
pending: { text: '待同步', tagType: 'info' },
|
||||
success: { text: '同步成功', tagType: 'success' },
|
||||
failed: { text: '同步失败', tagType: 'danger' }
|
||||
}
|
||||
|
||||
// 时间格式化函数
|
||||
export function formatDateTime(dateStr: string): string {
|
||||
if (!dateStr) return '--'
|
||||
try {
|
||||
const date = new Date(dateStr)
|
||||
if (isNaN(date.getTime())) return '--'
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
const hours = String(date.getHours()).padStart(2, '0')
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0')
|
||||
const seconds = String(date.getSeconds()).padStart(2, '0')
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
||||
} catch (e) {
|
||||
return '--'
|
||||
}
|
||||
}
|
||||
|
||||
export const entryColums = [
|
||||
{ prop: 'entry_order_code', label: '出库单号', width: '180', fixed: 'left' },
|
||||
{ prop: 'status', label: '出库状态', width: '100', align: 'center' },
|
||||
{ prop: 'order_type', label: '单据类型', width: '120' },
|
||||
{ prop: 'store_name', label: '货主', width: '120' },
|
||||
{ prop: 'total_order_lines', label: '商品种类', width: '100', align: 'right' },
|
||||
{ prop: 'supplier_name', label: '收货方', width: '150' },
|
||||
{ prop: 'logistics_name', label: '物流公司', width: '120' },
|
||||
{ prop: 'express_code', label: '运单号', width: '150' },
|
||||
{ prop: 'sync_status', label: '同步状态', width: '100', align: 'center' },
|
||||
{ prop: 'order_create_time', label: '下单时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.order_create_time) },
|
||||
{ prop: 'expect_start_time', label: '预计开始', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.expect_start_time) },
|
||||
{ prop: 'expect_end_time', label: '预计结束', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.expect_end_time) },
|
||||
{ prop: 'source_type', label: '来源', width: '100' },
|
||||
{ prop: 'remark', label: '备注', minWidth: '150' }
|
||||
]
|
||||
|
||||
export const availableFields = [
|
||||
{ value: 'entry_order_code', label: '出库单号', type: 'text' },
|
||||
{ value: 'status', label: '出库状态', type: 'select', options: Object.entries(statusConfig).map(([v, c]) => ({ value: v, label: c.text })) },
|
||||
{ value: 'store_id', label: '货主', type: 'select', filterable: true, options: [] },
|
||||
{ value: 'order_type', label: '单据类型', type: 'select', options: [
|
||||
{ label: '销售出库', value: 'SALE' },
|
||||
{ label: '调拨出库', value: 'TRANSFER' },
|
||||
{ label: '退货出库', value: 'RETURN' },
|
||||
{ label: '其他出库', value: 'OTHER' }
|
||||
]},
|
||||
{ value: 'sync_status', label: '同步状态', type: 'select', options: Object.entries(syncStatusConfig).map(([v, c]) => ({ value: v, label: c.text })) },
|
||||
{ value: 'logistics_name', label: '物流公司', type: 'text' },
|
||||
{ value: 'express_code', label: '运单号', type: 'text' },
|
||||
{ value: 'order_create_time', label: '下单时间', type: 'daterange', startPlaceholder: '开始时间', endPlaceholder: '结束时间' },
|
||||
{ value: 'remark', label: '备注', type: 'text' }
|
||||
]
|
||||
|
||||
// 详情面板表单配置
|
||||
export const detailpanel = [
|
||||
{ prop: 'entry_order_code', label: '出库单号', type: 'input', disabled: true },
|
||||
{ prop: 'store_name', label: '货主', type: 'input', disabled: true },
|
||||
{ prop: 'status', label: '出库状态', type: 'select', disabled: true },
|
||||
{ prop: 'order_type', label: '单据类型', type: 'input', disabled: true },
|
||||
{ prop: 'supplier_name', label: '收货方', type: 'input' },
|
||||
{ prop: 'logistics_name', label: '物流公司', type: 'input' },
|
||||
{ prop: 'express_code', label: '运单号', type: 'input' },
|
||||
{ prop: 'total_order_lines', label: '商品种类', type: 'number', disabled: true },
|
||||
{ prop: 'remark', label: '备注', type: 'textarea' }
|
||||
]
|
||||
|
||||
export const productColumns = [
|
||||
{ prop: 'product_name', label: '商品名称', width: '180', fixed: 'left' },
|
||||
{ prop: 'barcode', label: '条码', width: '150' },
|
||||
{ prop: 'spec', label: '规格', width: '120' },
|
||||
{ prop: 'plan_quantity', label: '计划数量', width: '100', align: 'right' },
|
||||
{ prop: 'actual_quantity', label: '实际出库', width: '100', align: 'right' },
|
||||
{ prop: 'batch_number', label: '批次', width: '120' },
|
||||
{ prop: 'remark', label: '备注', minWidth: '150' }
|
||||
]
|
||||
|
||||
export function formatStockoutData(list: any[] = []) {
|
||||
return (list || []).map(item => ({
|
||||
...item,
|
||||
// 可以在这里做一些数据映射或格式化
|
||||
status: item.status || item.order_status || 'pending',
|
||||
sync_status: item.sync_status || 'pending'
|
||||
}))
|
||||
}
|
||||
31
日志.md
31
日志.md
@ -62,7 +62,6 @@
|
||||
-修复receiving页面时间格式显示异常问题。
|
||||
-优化stock接口,排除删除废弃或无用接口。
|
||||
-更新stock-config.ts配置文件,提升stock页面维护性;更新表格状态字段数据。
|
||||
-
|
||||
|
||||
二、问题记录
|
||||
-stock回收站,后端 stock.warehouse.list 接口(对应的数据库表)中不存在 is_deleted 字段,或者该接口不支持通过 is_deleted 参数进行过滤。
|
||||
@ -74,4 +73,32 @@
|
||||
完善各页面config.ts配置设计,优化功能结构。
|
||||
完善各页面布局设计,统一样式和风格,降低维护成本。
|
||||
解决跨域问题。
|
||||
解决路由相关的一些潜在小问题。
|
||||
解决路由相关的一些潜在小问题。
|
||||
|
||||
|
||||
2026.3.27
|
||||
一、今日完成
|
||||
-修复stock无法删除/批量删除商品问题。
|
||||
-修复receiving无法作废收货单的问题。
|
||||
-更新“绑定微信”二维码生成逻辑,修复轮询、绑定状态异常问题,优化二维码使用逻辑,修复轮询关闭异常的问题。
|
||||
-修复入库单页面入库列表、入库单详情接口无法获取数据问题。
|
||||
- 在 entry-config.ts 中实现了用于缺货创建的新录入字段。
|
||||
- 在 index.vue 中添加了用于创建缺货记录的对话框。
|
||||
- 增强了收货功能,增加了批量取消和完成选项。
|
||||
- 更新了 receiving-config.ts,以禁用状态选择。
|
||||
- 创建了用于列出缺货记录的缺货 API。
|
||||
- 开发了用于显示缺货日志和产品详情的组件。
|
||||
- 引入了缺货详情视图,支持表单处理及保存/重置功能。
|
||||
- 在 stockout-config.ts 中配置了缺货特定设置,包括状态和同步状态配置。
|
||||
- 通过新的 index.vue 布局改善了缺货管理的 UI。
|
||||
|
||||
二、问题记录
|
||||
order.reviewOrder.getreviewOrderlist接口没有返回数据。
|
||||
storage.receiving.completeReceiving收货单入库报错:有3个商品缺少必要信息。
|
||||
stock.warehouse.bindItem商品明细外部商品绑定报错:stock.warehouse.bindItem。
|
||||
stock获取回收站商品接口复用了商品信息接口stock.warehouse.list,导致冲突。
|
||||
|
||||
|
||||
三、后续计划
|
||||
完善接口设计,排除故障接口,测试接口功能。
|
||||
实现将项目打包并上传到服务器实现静态资源托管。
|
||||
Loading…
x
Reference in New Issue
Block a user