4月6日
This commit is contained in:
parent
29a3f7701c
commit
df0b693592
BIN
dist.tar.gz
BIN
dist.tar.gz
Binary file not shown.
@ -230,7 +230,7 @@ export function completeReceiving(data: any): Promise<any> {
|
||||
})
|
||||
}
|
||||
|
||||
// 绑定货主到收货单(入参示例: { receiving_id, store_id })
|
||||
// 绑定货主到收货单
|
||||
export function bindReceivingStore(data: any): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
@ -242,4 +242,17 @@ export function bindReceivingStore(data: any): Promise<any> {
|
||||
},
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function bindDetailProduct(data: any): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.receiving.bindDetailProduct',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
@ -213,3 +213,87 @@ export function updateSpaceInfo(data:any){
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
export function createRack(data: any) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'warehouse.createRack',
|
||||
v: '1.0',
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
export function getPickPath(data: any) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'warehouse.getPickPath',
|
||||
v: '1.0',
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
export function updateRackPosition(data: any) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'warehouse.updateRackPosition',
|
||||
v: '1.0',
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
export function recalculatePickPath(warehouse_id: any) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'warehouse.recalculatePickPath',
|
||||
v: '1.0',
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: { warehouse_id },
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
export function updateNeighbors(warehouse_id: any) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'warehouse.updateNeighbors',
|
||||
v: '1.0',
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: { warehouse_id },
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
export function getAreaRacks(area_id: any) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'warehouse.getAreaRacks',
|
||||
v: '1.0',
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: { area_id },
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@
|
||||
<el-dropdown-item
|
||||
v-for="role in user.employees"
|
||||
:key="role.id"
|
||||
:class="role.is_primary == 1 ? 'on' : ''"
|
||||
:class="role.is_primary == 1 ? 'on current-role' : 'other-role'"
|
||||
@click="changeRole(role.id)"
|
||||
>
|
||||
{{ role.store_name }} | {{ role.real_name }}
|
||||
@ -343,10 +343,18 @@ onMounted(() => {
|
||||
.text-warning { color: #e6a23c; }
|
||||
.text-success { color: #67c23a; }
|
||||
.user-dropdown {
|
||||
.on {
|
||||
background-color: #ecf5ff;
|
||||
color: #409EFF;
|
||||
:deep(.current-role) {
|
||||
background-color: rgba(0, 0, 0, .025) !important;
|
||||
color: #409EFF !important;
|
||||
font-weight: bold;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
:deep(.other-role) {
|
||||
&:hover {
|
||||
background-color: transparent !important;
|
||||
color: inherit !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -29,5 +29,5 @@ export default {
|
||||
* @type {boolean} true | false
|
||||
* @description Whether expand the shortcut key area
|
||||
*/
|
||||
shortcutExpanded: true
|
||||
shortcutExpanded: false
|
||||
}
|
||||
|
||||
@ -343,7 +343,19 @@ watch(() => props.initialStore, (val) => {
|
||||
}
|
||||
}, { immediate: true })
|
||||
|
||||
defineExpose({ formData })
|
||||
// Reset non-form fields if any or complex reset logic
|
||||
const resetForm = () => {
|
||||
lastItemCode.value = ''
|
||||
if (formRef.value) {
|
||||
formRef.value.resetFields()
|
||||
}
|
||||
formData.managementFlags = []
|
||||
formData.enable_box_spec = false
|
||||
handleBoxSpecToggle(false)
|
||||
ElMessage.info('表单已重置')
|
||||
}
|
||||
|
||||
defineExpose({ formData, resetForm })
|
||||
|
||||
const originalData = reactive({})
|
||||
|
||||
@ -518,21 +530,6 @@ const handleSave = async () => {
|
||||
})
|
||||
}
|
||||
|
||||
const resetForm = () => {
|
||||
lastItemCode.value = ''
|
||||
if (formRef.value) {
|
||||
formRef.value.resetFields()
|
||||
}
|
||||
// Reset non-form fields if any or complex reset logic
|
||||
formData.managementFlags = []
|
||||
formData.enable_box_spec = false
|
||||
handleBoxSpecToggle(false)
|
||||
|
||||
// Restore original data if needed (Vue 2 logic had originalData)
|
||||
// Object.assign(formData, originalData)
|
||||
ElMessage.info('表单已重置')
|
||||
}
|
||||
|
||||
const handleCustomChange = (value: any) => {
|
||||
console.log('违禁品类型变更:', value)
|
||||
}
|
||||
|
||||
@ -10,24 +10,41 @@
|
||||
:label="field.label"
|
||||
:prop="field.prop"
|
||||
>
|
||||
<!-- 特殊处理:货主行,显示下拉并在右侧增加绑定按钮 -->
|
||||
<!-- 特殊处理:货主行,根据绑定状态显示不同内容 -->
|
||||
<template v-if="field.prop === 'store_name'">
|
||||
<div style="display:flex; gap:8px; align-items:center;">
|
||||
<el-select
|
||||
v-model="form.store_id"
|
||||
:placeholder="'请选择' + field.label"
|
||||
style="flex:1"
|
||||
:disabled="field.disabled || storeBound"
|
||||
filterable
|
||||
<div style="display:flex; gap:8px; align-items:center; width: 100%;">
|
||||
<!-- 已绑定货主:显示文本,禁用按钮 -->
|
||||
<template v-if="storeBound">
|
||||
<div style="flex: 1; padding: 0px 12px; background-color: #f5f7fa; border-radius: 4px; color: #606266; border: 1px solid #dcdfe6; height: 32px; line-height: 32px;">
|
||||
{{ form.store_name || '未设置' }}
|
||||
</div>
|
||||
</template>
|
||||
<!-- 未绑定货主:显示下拉选择,按钮可用 -->
|
||||
<template v-else>
|
||||
<el-select
|
||||
v-model="form.store_id"
|
||||
:placeholder="'请选择' + field.label"
|
||||
style="flex: 1;"
|
||||
filterable
|
||||
:loading="storeListLoading"
|
||||
@focus="loadStoreList"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in (localAvailableFields.find((f: { value: string }) => f.value === 'store_id')?.options || [])"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
@click="handleBindStore"
|
||||
:disabled="storeBound"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in (availableFields.find(f => f.value === 'store_id')?.options || [])"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
<el-button size="small" type="primary" @click="handleBindStore">货主绑定</el-button>
|
||||
货主绑定
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="field.type === 'select'">
|
||||
@ -37,7 +54,7 @@
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in availableFields.find(f => f.value === field.prop)?.options || []"
|
||||
v-for="item in localAvailableFields.find((f: { value: string }) => f.value === field.prop)?.options || []"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
@ -85,17 +102,18 @@
|
||||
</el-button-group>
|
||||
</div>
|
||||
<!-- 图片预览对话框 -->
|
||||
<el-dialog v-model="previewVisible" title="图片预览" width="60%" append-to-body>
|
||||
<el-dialog v-model="previewVisible" title="图片预览" width="60%" align-center append-to-body>
|
||||
<img :src="dialogImageUrl" alt="预览" style="width: 100%; max-height: 70vh; object-fit: contain;" />
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch, computed } from 'vue'
|
||||
import { ref, onMounted, watch, computed, reactive } from 'vue'
|
||||
import { availableFields, detailpanel } from '../receiving-config'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import * as receivingApi from '@/api/storage/receiving'
|
||||
import * as indexApi from '@/api/index'
|
||||
import { Picture, Check, Refresh } from '@element-plus/icons-vue'
|
||||
|
||||
const props = defineProps<{
|
||||
@ -158,69 +176,123 @@ const imagesArr = computed(() => {
|
||||
}).filter((s: string) => !!s)
|
||||
})
|
||||
|
||||
// 绑定状态:绑定后不可更改
|
||||
// 创建availableFields的本地响应式副本
|
||||
const localAvailableFields = reactive(JSON.parse(JSON.stringify(availableFields)))
|
||||
|
||||
// 货主列表加载状态
|
||||
const storeListLoading = ref(false)
|
||||
const storeListLoaded = ref(false)
|
||||
|
||||
// 加载货主列表
|
||||
const loadStoreList = async () => {
|
||||
// 如果已加载过,直接返回
|
||||
if (storeListLoaded.value) return
|
||||
|
||||
storeListLoading.value = true
|
||||
try {
|
||||
const res: any = await indexApi.loadStores({ type: 'receiving' })
|
||||
if (res && res.code === 200 && res.stores) {
|
||||
// 更新本地availableFields中store_id的options
|
||||
const storeIdField = localAvailableFields.find((f: any) => f.value === 'store_id')
|
||||
if (storeIdField) {
|
||||
storeIdField.options = res.stores.map((store: any) => ({
|
||||
value: store.value,
|
||||
label: store.label
|
||||
}))
|
||||
}
|
||||
storeListLoaded.value = true
|
||||
} else {
|
||||
ElMessage.warning('加载货主列表失败')
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('加载货主列表出错:', e)
|
||||
ElMessage.error('加载货主列表失败')
|
||||
} finally {
|
||||
storeListLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 绑定状态:绑定后不可更改(根据是否已有货主决定)
|
||||
const storeBound = ref(false)
|
||||
|
||||
// 触发绑定流程
|
||||
const handleBindStore = async () => {
|
||||
const storeId = form.value.store_id
|
||||
const receivingId = props.id || props.row?.id
|
||||
const receivingNumber = form.value.receiving_number
|
||||
const receivingId = props.row?.id
|
||||
|
||||
if (!storeId) {
|
||||
ElMessage.warning('请先选择货主')
|
||||
ElMessage.warning('请先在下拉框中选择货主')
|
||||
return
|
||||
}
|
||||
if (!receivingId) {
|
||||
ElMessage.warning('缺少收货单ID,无法绑定')
|
||||
|
||||
if (!receivingId || !receivingNumber) {
|
||||
ElMessage.warning('缺少收货单必要信息,无法绑定')
|
||||
return
|
||||
}
|
||||
|
||||
const status = props.row?.status
|
||||
const hasStore = !!(props.row && (props.row.store || props.row.store_id))
|
||||
// 拒绝条件:取消状态始终拒绝;收货中/已完成且已有货主也拒绝
|
||||
|
||||
// 拒绝条件1:取消状态始终拒绝
|
||||
if (status === 'cancelled') {
|
||||
ElMessage.error('取消状态的收货单无法绑定货主')
|
||||
return
|
||||
}
|
||||
|
||||
// 拒绝条件2:收货中/已完成状态且已有货主则拒绝
|
||||
if ((status === 'receiving' || status === 'completed') && hasStore) {
|
||||
ElMessage.error('当前状态下已有货主,无法绑定')
|
||||
ElMessage.error('当前状态下已有货主,无法重新绑定')
|
||||
return
|
||||
}
|
||||
|
||||
// 询问确认
|
||||
// 获取货主名称用于确认信息
|
||||
const storeLabel = getStoreLabel(storeId)
|
||||
|
||||
// 显示确认对话框,提示绑定后不可更改
|
||||
try {
|
||||
await ElMessageBox.confirm(`将货主绑定为:${getStoreLabel(storeId)}?绑定后不可更改。是否继续?`, '确认绑定', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
await ElMessageBox.confirm(
|
||||
`将货主绑定为:<strong>${storeLabel}</strong>?\n\n<span style="color:#f56c6c;">绑定后不可更改,请确认无误。</span>`,
|
||||
'确认绑定货主',
|
||||
{
|
||||
confirmButtonText: '确定绑定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
dangerouslyUseHTMLString: true
|
||||
}
|
||||
)
|
||||
|
||||
// 调用后端接口
|
||||
const payload = { receiving_id: receivingId, store_id: storeId }
|
||||
// 调用后端接口进行绑定
|
||||
const payload = { id: receivingId, receiving_number: receivingNumber, store_id: storeId }
|
||||
const res: any = await receivingApi.bindReceivingStore(payload)
|
||||
|
||||
if (res && (res.code === 200 || res.flag === 'success')) {
|
||||
ElMessage.success(res.message || '绑定成功')
|
||||
ElMessage.success(res.message || '货主绑定成功')
|
||||
storeBound.value = true
|
||||
// update local form and optionally props.row
|
||||
form.value.store_name = getStoreLabel(storeId)
|
||||
|
||||
// 更新本地表单数据
|
||||
form.value.store_name = storeLabel
|
||||
|
||||
// 更新props.row以保持数据同步
|
||||
if (props.row) {
|
||||
props.row.store = props.row.store || {}
|
||||
props.row.store.id = storeId
|
||||
props.row.store.store_remask = form.value.store_name
|
||||
props.row.store.store_remask = storeLabel
|
||||
props.row.store_id = storeId
|
||||
}
|
||||
} else {
|
||||
ElMessage.error((res && res.message) || '绑定失败')
|
||||
ElMessage.error((res && res.message) || '货主绑定失败,请稍后重试')
|
||||
}
|
||||
} catch (e: any) {
|
||||
// 取消或错误
|
||||
// 用户取消或其他错误
|
||||
if (e === 'cancel') return
|
||||
console.error('bind store error', e)
|
||||
ElMessage.error('绑定过程中出错')
|
||||
ElMessage.error('绑定过程中出错,请稍后重试')
|
||||
}
|
||||
}
|
||||
|
||||
const getStoreLabel = (id: any) => {
|
||||
const opts = (availableFields.find(f => f.value === 'store_id') || {}).options || []
|
||||
const opts = (localAvailableFields.find((f: { value: string }) => f.value === 'store_id') || {}).options || []
|
||||
const found = opts.find((o: any) => o.value === id)
|
||||
return found ? found.label : String(id)
|
||||
}
|
||||
@ -230,14 +302,17 @@ const handlePreview = (src: string) => {
|
||||
previewVisible.value = true
|
||||
}
|
||||
|
||||
// 监听 row 变化,更新表单数据
|
||||
// 监听 row 变化,更新表单数据和绑定状态
|
||||
watch(() => props.row, (newRow) => {
|
||||
if (newRow) {
|
||||
form.value = { ...newRow }
|
||||
form.value.store_id = newRow.store?.id || newRow.store_id || ''
|
||||
form.value.store_name = newRow.store?.store_remask || newRow.store_name || form.value.store_name
|
||||
// 如果后端或数据表明已经绑定,设置 storeBound(保守:如果 row.bound === true)
|
||||
storeBound.value = !!(newRow.bound === true)
|
||||
|
||||
// 根据是否已有货主来设置 storeBound 状态
|
||||
// 如果 row 中 store 或 store_id 存在,则说明已绑定货主,不可更改
|
||||
const hasStore = !!(newRow.store || newRow.store_id)
|
||||
storeBound.value = hasStore
|
||||
}
|
||||
}, { immediate: true })
|
||||
|
||||
|
||||
@ -8,6 +8,13 @@
|
||||
<el-radio-button label="matched">已匹配</el-radio-button>
|
||||
<el-radio-button label="unmatched">未匹配</el-radio-button>
|
||||
</el-radio-group>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
size="small"
|
||||
:disabled="multipleSelection.length > 1"
|
||||
@click="openAddDrawer"
|
||||
>添加商品</el-button>
|
||||
<el-button size="small" type="primary" disabled>批量操作</el-button>
|
||||
<!-- <el-button size="small" disabled>导出</el-button> -->
|
||||
</div>
|
||||
@ -84,13 +91,13 @@
|
||||
>
|
||||
快速关联
|
||||
</el-button>
|
||||
<el-button
|
||||
<!-- <el-button
|
||||
type="primary"
|
||||
plain
|
||||
size="small"
|
||||
style="margin-left:8px"
|
||||
@click.stop="openAddDrawer(row)"
|
||||
>添加商品</el-button>
|
||||
@click="openAddDrawer"
|
||||
>添加商品</el-button> -->
|
||||
</template>
|
||||
</UpperTable>
|
||||
</div>
|
||||
@ -106,64 +113,52 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="window-body">
|
||||
<div class="quick-link-content">
|
||||
<el-alert title="请选择需要关联的系统商品" type="info" :closable="false" show-icon style="margin-bottom: 15px;" />
|
||||
<!-- 这里可以放置商品搜索和选择列表 -->
|
||||
<div class="search-section">
|
||||
<el-form label-position="left" label-width="60px" class="search-form">
|
||||
<el-form-item label="货主">
|
||||
<el-input :value="quickLinkStore?.name || quickLinkStore?.store_remask || quickLinkStore?.store_name" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-input v-model="quickSearchQuery" placeholder="输入商品名称或条码搜索" class="search-input">
|
||||
<template #append>
|
||||
<el-button :icon="Search" @click="() => performQuickSearch(1)">搜索</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<div class="system-product-list" style="display:flex; flex-direction:column;">
|
||||
<el-table
|
||||
:data="quickSearchResults"
|
||||
v-loading="quickSearchLoading"
|
||||
highlight-current-row
|
||||
stripe
|
||||
size="small"
|
||||
:row-key="(row: { id: any }) => row.id"
|
||||
@current-change="onSystemProductChange"
|
||||
@row-click="onSystemProductChange"
|
||||
:height="360"
|
||||
style="width:100%"
|
||||
:row-class-name="tableRowClassName"
|
||||
>
|
||||
<el-table-column prop="id" label="ID" width="80" />
|
||||
<el-table-column prop="item_name" label="名称" show-overflow-tooltip />
|
||||
<el-table-column prop="barcodes" label="条码" width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="store_name" label="货主" width="150" show-overflow-tooltip />
|
||||
<template #empty>
|
||||
<div style="padding:24px; text-align:center; color:#909399;">暂无系统商品数据,请搜索或关联</div>
|
||||
</template>
|
||||
</el-table>
|
||||
|
||||
<div class="pagination-container" style="padding:8px; text-align:right;">
|
||||
<el-pagination
|
||||
background
|
||||
small
|
||||
:current-page="quickResultPagination.page"
|
||||
:page-size="quickResultPagination.pageSize"
|
||||
:total="quickResultPagination.total"
|
||||
@current-change="performQuickSearch"
|
||||
@size-change="onQuickPageSizeChange"
|
||||
layout="prev, pager, next, sizes, total"
|
||||
:page-sizes="[10,20,50,100]"
|
||||
<div class="window-content">
|
||||
<div class="quick-link-content">
|
||||
<!-- 这里可以放置商品搜索和选择列表 -->
|
||||
<div class="search-section">
|
||||
<el-form label-position="left" :inline="true" class="search-form">
|
||||
<el-form-item label="货主">
|
||||
<el-input :value="quickLinkStore?.name || quickLinkStore?.store_remask || quickLinkStore?.store_name" disabled style="width: 200px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="快速搜索">
|
||||
<el-input v-model="quickSearchQuery" placeholder="输入商品名称或条码搜索" class="search-input" style="width: 300px">
|
||||
<template #append>
|
||||
<el-button :icon="Search" @click="() => performQuickSearch(1)">搜索</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<div class="system-product-list" style="display:flex; flex-direction:column; flex: 1; min-height: 0;">
|
||||
<UpperTable
|
||||
:data="quickSearchResults"
|
||||
v-loading="quickSearchLoading"
|
||||
:columns="[
|
||||
{ prop: 'id', label: 'ID', width: 80 },
|
||||
{ prop: 'item_name', label: '名称' },
|
||||
{ prop: 'barcodes', label: '条码', width: 160 },
|
||||
{ prop: 'store_name', label: '货主', width: 150 }
|
||||
]"
|
||||
:pagination="{
|
||||
currentPage: quickResultPagination.page,
|
||||
pageSize: quickResultPagination.pageSize,
|
||||
total: quickResultPagination.total
|
||||
}"
|
||||
:show-selection="true"
|
||||
:multiple-selection="multipleQuickSelection"
|
||||
@selection-change="handleQuickSelectionChange"
|
||||
@row-click="handleQuickRowClick"
|
||||
@page-change="performQuickSearch"
|
||||
@page-size-change="onQuickPageSizeChange"
|
||||
style="height: 100%;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="window-body-bottom">
|
||||
<div class="window-footer">
|
||||
<el-button size="small" @click="quickLinkVisible = false">取消</el-button>
|
||||
<el-button size="small" type="primary" @click="confirmQuickLink" :disabled="!selectedSystemProduct">完成关联</el-button>
|
||||
<el-button size="small" type="primary" @click="confirmQuickLink" :disabled="multipleQuickSelection.length !== 1">完成关联</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -179,7 +174,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 货品详情弹窗 -->
|
||||
<div v-if="windowVisible" class="product-window" :class="{ 'is-fullscreen': isFullscreen }" :style="windowStyle">
|
||||
<div v-if="windowVisible" class="product-window detail-window" :class="{ 'is-fullscreen': isFullscreen }" :style="windowStyle">
|
||||
<div class="window-header" @mousedown="startDrag">
|
||||
<span class="window-title">货品详情 - {{ currentRow?.item_name }}</span>
|
||||
<div class="window-actions">
|
||||
@ -188,18 +183,18 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="window-body">
|
||||
<div class="window-body-top">
|
||||
<div class="window-tabs">
|
||||
<div
|
||||
v-for="tab in windowtopbar"
|
||||
:key="tab.key"
|
||||
class="window-tab-item"
|
||||
class="tab-item"
|
||||
:class="{ active: activeWindowTab === tab.key }"
|
||||
@click="activeWindowTab = tab.key"
|
||||
>
|
||||
{{ tab.label }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="window-body-middle">
|
||||
<div class="window-content">
|
||||
<KeepAlive>
|
||||
<component
|
||||
:is="currentWindowComponent"
|
||||
@ -208,7 +203,7 @@
|
||||
/>
|
||||
</KeepAlive>
|
||||
</div>
|
||||
<div class="window-body-bottom">
|
||||
<div class="window-footer">
|
||||
<el-button size="small" @click="resetForm" disabled>重置</el-button>
|
||||
<el-button size="small" type="primary" @click="saveProductDetail" disabled>保存</el-button>
|
||||
</div>
|
||||
@ -507,6 +502,7 @@ const quickSearchResults = ref<any[]>([])
|
||||
const quickSearchLoading = ref(false)
|
||||
const quickResultPagination = reactive({ page: 1, pageSize: 10, total: 0 })
|
||||
const selectedSystemProduct = ref<any>(null)
|
||||
const multipleQuickSelection = ref<any[]>([])
|
||||
|
||||
// 添加商品抽屉
|
||||
const addDrawerVisible = ref(false)
|
||||
@ -517,7 +513,7 @@ const windowStyle = computed(() => {
|
||||
if (isFullscreen.value) return {}
|
||||
return {
|
||||
top: `${position.value.y}px`,
|
||||
left: `${position.value.x}px`
|
||||
left: `${position.value.x}px`,
|
||||
}
|
||||
})
|
||||
|
||||
@ -529,18 +525,48 @@ const quickLinkStyle = computed(() => {
|
||||
}
|
||||
})
|
||||
|
||||
const openAddDrawer = (row: any) => {
|
||||
const openAddDrawer = () => {
|
||||
// row here is product row, but store info comes from parent receiving row (props.row)
|
||||
addDrawerStore.value = props.row?.store || { id: props.row?.store_id, name: props.row?.store_name }
|
||||
addDrawerVisible.value = true
|
||||
// allow child to initialize with store after mount
|
||||
nextTick(() => {
|
||||
if (addCompRef.value && addDrawerStore.value) {
|
||||
try {
|
||||
addCompRef.value.formData && (addCompRef.value.formData.store_id = addDrawerStore.value.id || addDrawerStore.value.store_id || addDrawerStore.value.storeId)
|
||||
} catch (e) {}
|
||||
setTimeout(() => {
|
||||
if (addCompRef.value) {
|
||||
if (typeof addCompRef.value.resetForm === 'function') {
|
||||
addCompRef.value.resetForm()
|
||||
}
|
||||
const formData = addCompRef.value.formData
|
||||
if (!formData) return
|
||||
|
||||
if (addDrawerStore.value) {
|
||||
formData.store_id = addDrawerStore.value.id || addDrawerStore.value.store_id || addDrawerStore.value.storeId
|
||||
}
|
||||
|
||||
// 如果勾选了一个商品,自动填充相关字段
|
||||
if (multipleSelection.value.length === 1) {
|
||||
const item = multipleSelection.value[0]
|
||||
formData.item_name = item.item_name || item.product_name || ''
|
||||
const barcode = item.barcodes || item.barcode || ''
|
||||
formData.barcode = barcode
|
||||
formData.item_code = barcode || item.item_code || ''
|
||||
|
||||
// 解析可能存在的规格/属性 snapshot
|
||||
if (item.product_snapshot) {
|
||||
try {
|
||||
const snap = typeof item.product_snapshot === 'string' ? JSON.parse(item.product_snapshot) : item.product_snapshot
|
||||
if (snap.spec) formData.sku_property = snap.spec
|
||||
if (snap.brand) formData.brand_name = snap.brand
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// 尝试填充箱规或体积(如果明细存在)
|
||||
if (item.box_length) formData.length = item.box_length
|
||||
if (item.box_width) formData.width = item.box_width
|
||||
if (item.box_height) formData.height = item.box_height
|
||||
if (item.weight) formData.gross_weight = item.weight
|
||||
}
|
||||
}
|
||||
})
|
||||
}, 100)
|
||||
}
|
||||
|
||||
const handleSelectionChange = (val: any[]) => {
|
||||
@ -562,9 +588,14 @@ const closeMenu = () => {
|
||||
const handleProductDetail = () => {
|
||||
if (currentRow.value) {
|
||||
windowVisible.value = true
|
||||
// 重置位置或保持原位
|
||||
position.value = { x: 350, y: 250 }
|
||||
// 重置为居中位置
|
||||
isFullscreen.value = false
|
||||
// 以样式中定义的默认窗口大小居中(width:1250, height:700)
|
||||
const winW = 1250
|
||||
const winH = 700
|
||||
const x = Math.max(0, Math.floor((window.innerWidth - winW) / 2))
|
||||
const y = Math.max(0, Math.floor((window.innerHeight - winH) / 2))
|
||||
position.value = { x, y }
|
||||
}
|
||||
closeMenu()
|
||||
}
|
||||
@ -573,9 +604,16 @@ const handleProductDetail = () => {
|
||||
const handleQuickLink = (row: any) => {
|
||||
currentRow.value = row
|
||||
quickLinkVisible.value = true
|
||||
quickPosition.value = { x: 300, y: 150 }
|
||||
// 将快速关联窗口居中显示
|
||||
isQuickFullscreen.value = false
|
||||
const winW = 1250
|
||||
const winH = 700
|
||||
const qx = Math.max(0, Math.floor((window.innerWidth - winW) / 2))
|
||||
const qy = Math.max(0, Math.floor((window.innerHeight - winH) / 2))
|
||||
quickPosition.value = { x: qx, y: qy }
|
||||
quickSearchQuery.value = row.product_name || row.item_name || ''
|
||||
multipleQuickSelection.value = []
|
||||
selectedSystemProduct.value = null
|
||||
// 优先使用商品行中可能包含的收货单货主(例如 row.receiving.store),
|
||||
// 否则使用父组件传入的收货单(props.row)信息作为回退
|
||||
const storeFromDetail = row?.receiving?.store || row?.store || (row && (row.store_id || row.store_name) ? { id: row.store_id, name: row.store_name } : null)
|
||||
@ -585,6 +623,22 @@ const handleQuickLink = (row: any) => {
|
||||
performQuickSearch(1)
|
||||
}
|
||||
|
||||
const handleQuickSelectionChange = (val: any[]) => {
|
||||
multipleQuickSelection.value = val
|
||||
if (val.length === 1) {
|
||||
selectedSystemProduct.value = val[0]
|
||||
} else {
|
||||
selectedSystemProduct.value = null
|
||||
}
|
||||
}
|
||||
|
||||
const handleQuickRowClick = (row: any) => {
|
||||
// 点击行时切换选中状态,这里如果是单选逻辑,可以清空其他再选中当前
|
||||
// 或者直接赋值给 multipleQuickSelection 模拟单选
|
||||
multipleQuickSelection.value = [row]
|
||||
selectedSystemProduct.value = row
|
||||
}
|
||||
|
||||
const onSystemProductChange = (row: any) => {
|
||||
selectedSystemProduct.value = row
|
||||
}
|
||||
@ -636,20 +690,40 @@ const performQuickSearch = async (page = 1) => {
|
||||
}
|
||||
}
|
||||
|
||||
const confirmQuickLink = () => {
|
||||
const confirmQuickLink = async () => {
|
||||
if (!selectedSystemProduct.value) {
|
||||
ElMessage.warning('请先选择一个系统商品')
|
||||
return
|
||||
}
|
||||
|
||||
const detailId = currentRow.value?.id
|
||||
const systemProductId = selectedSystemProduct.value?.id
|
||||
|
||||
if (!detailId || !systemProductId) {
|
||||
ElMessage.warning('缺少关联必要信息')
|
||||
return
|
||||
}
|
||||
|
||||
saveLoading.value = true
|
||||
try {
|
||||
// 将选择的系统商品信息写回当前行(仅本地映射,真实业务可能需要调用接口)
|
||||
currentRow.value.system_product_id = selectedSystemProduct.value.id
|
||||
currentRow.value.system_product = selectedSystemProduct.value
|
||||
ElMessage.success('关联成功')
|
||||
quickLinkVisible.value = false
|
||||
const res: any = await receivingApi.bindDetailProduct({
|
||||
detail_id: detailId,
|
||||
system_product_id: systemProductId
|
||||
})
|
||||
|
||||
if (res && (res.code === 200 || res.flag === 'success')) {
|
||||
ElMessage.success(res.message || '关联成功')
|
||||
quickLinkVisible.value = false
|
||||
// 触发刷新列表
|
||||
loadProductData()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '关联失败')
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
ElMessage.error('关联失败')
|
||||
console.error('confirmQuickLink error:', e)
|
||||
ElMessage.error('关联过程中出错')
|
||||
} finally {
|
||||
saveLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@ -776,7 +850,7 @@ onUnmounted(() => {
|
||||
position: fixed;
|
||||
z-index: 2000;
|
||||
width: 1250px;
|
||||
height: 650px;
|
||||
height: 700px;
|
||||
background: #fff;
|
||||
border: 1px solid #ebeef5;
|
||||
box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.1);
|
||||
@ -834,21 +908,20 @@ onUnmounted(() => {
|
||||
|
||||
.window-body {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.window-body-top {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
background-color: #f5f7fa;
|
||||
width: 100%;
|
||||
height: 35px;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.window-tab-item {
|
||||
.window-tabs {
|
||||
display: flex;
|
||||
height: 40px;
|
||||
background: #f5f7fa;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.window-tabs .tab-item {
|
||||
padding: 0 20px;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
@ -857,42 +930,44 @@ onUnmounted(() => {
|
||||
color: #606266;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
border-right: 1px solid transparent;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.window-tab-item:hover {
|
||||
.window-tabs .tab-item:hover {
|
||||
color: #409eff;
|
||||
background-color: #ecf5ff;
|
||||
}
|
||||
|
||||
.window-tab-item.active {
|
||||
.window-tabs .tab-item.active {
|
||||
color: #409eff;
|
||||
background-color: #fff;
|
||||
font-weight: bold;
|
||||
border-right: 1px solid #ebeef5;
|
||||
border-left: 1px solid #ebeef5;
|
||||
}
|
||||
|
||||
.window-tab-item.active:first-child {
|
||||
border-left: none;
|
||||
.window-tabs .tab-item.active::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 2px;
|
||||
background: #409eff;
|
||||
}
|
||||
|
||||
.window-body-middle {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
padding: 15px;
|
||||
/* background-color: yellow; */
|
||||
.window-content {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
padding: 20px;
|
||||
}
|
||||
.window-body-bottom {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
background-color: rgb(235, 235, 235);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.window-footer {
|
||||
height: 52px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
padding: 0 20px;
|
||||
background: #fff;
|
||||
border-top: 1px solid #ebeef5;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.quick-link-content {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="storage-receiving-container">
|
||||
<div class="storage-receiving-container" :style="{ height: containerHeight }">
|
||||
<scan-box ref="scanBox" width="320px" :tree-props="{ children: 'children', label: 'label' }" :auto-submit="false"
|
||||
:initial-conditions="initialConditions" :preset-tree="presetTree" :available-fields="availableFieldsRef"
|
||||
@condition-change="handleConditionChange" @reset="handleConditionReset" @condition-clear="handleConditionClear"
|
||||
@ -246,6 +246,7 @@ import Logs from './component/Logs.vue'
|
||||
import Product from './component/Product.vue'
|
||||
import * as indexApi from '@/api/index'
|
||||
import * as receivingApi from '@/api/storage/receiving'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import {
|
||||
receivingColumns,
|
||||
availableFields,
|
||||
@ -275,6 +276,10 @@ const presetTree = ref<any[]>([])
|
||||
const availableFieldsRef = reactive(JSON.parse(JSON.stringify(availableFields)))
|
||||
const addReceivingFieldsRef = reactive(JSON.parse(JSON.stringify(addReceivingFields)))
|
||||
|
||||
const settingsStore = useSettingsStore()
|
||||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||||
const containerHeight = computed(() => shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)')
|
||||
|
||||
const activeTab = ref('details')
|
||||
|
||||
const list = ref<any[]>([])
|
||||
@ -1129,7 +1134,7 @@ async function handleExport() {
|
||||
<style scoped lang="scss">
|
||||
.storage-receiving-container {
|
||||
display: flex;
|
||||
height: calc(100vh - 100px);
|
||||
// height: calc(100vh - 100px); // 移除固定高度,由模板中的 :style 控制
|
||||
width: 100%;
|
||||
background-color: #f0f2f5;
|
||||
|
||||
|
||||
@ -278,7 +278,7 @@ export const productdetail = [
|
||||
]
|
||||
|
||||
export const productquick = [
|
||||
{ prop: 'images', label: '图片', width: '80', align: 'center', fixed: 'left' },
|
||||
{ prop: 'images', label: '图片', width: '120', align: 'center', fixed: 'left' },
|
||||
{ prop: 'product_name', label: '商品名称', width: '200', fixed: 'left' },
|
||||
{ prop: 'barcode', label: '条码', width: '150' },
|
||||
{ prop: 'match_status', label: '匹配状态', width: '100', align: 'center' },
|
||||
@ -291,7 +291,7 @@ export const productquick = [
|
||||
{ prop: 'storage_status', label: '入库', width: '80', align: 'center' },
|
||||
{ prop: 'space_id', label: '库位', width: '120' },
|
||||
{ prop: 'remark', label: '备注', minWidth: '150' },
|
||||
{ prop: 'actions', label: '操作', width: '120', align: 'center', fixed: 'right' },
|
||||
{ prop: 'actions', label: '操作', width: '100', align: 'center', fixed: 'right' },
|
||||
]
|
||||
|
||||
|
||||
|
||||
@ -90,6 +90,11 @@ defineExpose({
|
||||
|
||||
<style lang="css" scoped>
|
||||
.basic-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
/* 在弹窗的弹性布局中占满剩余高度 */
|
||||
flex: 1 1 auto;
|
||||
min-height: 0; /* 允许子元素溢出裁剪,支持滚动容器 */
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
@ -97,6 +102,9 @@ defineExpose({
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 0 20px;
|
||||
/* 使表单网格在垂直方向也能伸展并在需要时滚动 */
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.image-upload-wrapper {
|
||||
@ -115,4 +123,11 @@ defineExpose({
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
/* 让内部 el-form 也能充满高度,从而使 basic-info 真正占满父容器 */
|
||||
:deep(.basic-info) :deep(.el-form) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -391,25 +391,6 @@
|
||||
<el-input v-model="qimenForm.api_version" placeholder="默认1.0" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="签名方式">
|
||||
<el-select v-model="qimenForm.sign_method" style="width:100%">
|
||||
<el-option label="md5" value="md5" />
|
||||
<el-option label="hmac" value="hmac" />
|
||||
<el-option label="sha256" value="sha256" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="限流(次/分)">
|
||||
<el-input-number v-model="qimenForm.rate_limit" :min="1" style="width:100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="超时(秒)">
|
||||
<el-input-number v-model="qimenForm.timeout_seconds" :min="1" style="width:100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="联系人">
|
||||
<el-input v-model="qimenForm.contact_person" />
|
||||
@ -775,9 +756,7 @@ function openQimenForm(config: any) {
|
||||
qimenDialog.editingConfig = config
|
||||
if (config) {
|
||||
Object.assign(qimenForm, qimenFormDefault, config)
|
||||
// 兼容rate_limit/timeout_seconds/is_enabled为0的情况
|
||||
if (config.rate_limit !== undefined) qimenForm.rate_limit = config.rate_limit
|
||||
if (config.timeout_seconds !== undefined) qimenForm.timeout_seconds = config.timeout_seconds
|
||||
// 兼容is_enabled为0的情况
|
||||
if (config.is_enabled !== undefined) qimenForm.is_enabled = config.is_enabled
|
||||
} else {
|
||||
Object.assign(qimenForm, qimenFormDefault)
|
||||
|
||||
@ -22,9 +22,6 @@ export const qimenFormDefault = {
|
||||
qimen_customer_id: '',
|
||||
qimen_warehouse_code: '',
|
||||
api_version: '1.0',
|
||||
sign_method: 'md5',
|
||||
rate_limit: 1000,
|
||||
timeout_seconds: 30,
|
||||
contact_person: '',
|
||||
contact_phone: '',
|
||||
email: '',
|
||||
|
||||
793
src/views/warehouse/AreaRacksList.vue
Normal file
793
src/views/warehouse/AreaRacksList.vue
Normal file
@ -0,0 +1,793 @@
|
||||
<template>
|
||||
<div class="area-racks-list">
|
||||
<el-card class="box-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>区域货架管理</span>
|
||||
<div class="header-buttons">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="refreshRackList"
|
||||
:loading="loading"
|
||||
>
|
||||
刷新
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
size="small"
|
||||
@click="showRackStats"
|
||||
:disabled="!areaRacks.length"
|
||||
>
|
||||
统计信息
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="racks-content">
|
||||
<!-- 区域信息 -->
|
||||
<div v-if="selectedArea" class="area-info">
|
||||
<el-descriptions
|
||||
title="区域信息"
|
||||
:column="3"
|
||||
size="small"
|
||||
border
|
||||
>
|
||||
<el-descriptions-item label="区域编码">
|
||||
{{ selectedArea.code }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="区域名称">
|
||||
{{ selectedArea.name }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="货架数量">
|
||||
{{ areaRacks.length }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="区域尺寸">
|
||||
{{ selectedArea.length }}×{{ selectedArea.width }}×{{ selectedArea.height }}mm
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="货架行数">
|
||||
{{ selectedArea.rackRows || 0 }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="货架列数">
|
||||
{{ selectedArea.rackColumns || 0 }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
|
||||
<!-- 搜索和筛选 -->
|
||||
<div class="search-filters">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="8">
|
||||
<el-input
|
||||
v-model="searchText"
|
||||
placeholder="搜索货架编码或名称"
|
||||
clearable
|
||||
@input="handleSearch"
|
||||
>
|
||||
<template #prefix>
|
||||
<el-icon><Search /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-select
|
||||
v-model="statusFilter"
|
||||
placeholder="状态筛选"
|
||||
clearable
|
||||
@change="handleFilter"
|
||||
>
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="正常" value="normal" />
|
||||
<el-option label="维护中" value="maintenance" />
|
||||
<el-option label="禁用" value="disabled" />
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-select
|
||||
v-model="typeFilter"
|
||||
placeholder="类型筛选"
|
||||
clearable
|
||||
@change="handleFilter"
|
||||
>
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="标准货架" value="standard" />
|
||||
<el-option label="高位货架" value="high" />
|
||||
<el-option label="特殊货架" value="special" />
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="resetFilters"
|
||||
>
|
||||
重置筛选
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
<!-- 货架列表 -->
|
||||
<div class="racks-table">
|
||||
<el-table
|
||||
:data="filteredRacks"
|
||||
@row-click="handleRackClick"
|
||||
@selection-change="handleSelectionChange"
|
||||
highlight-current-row
|
||||
size="small"
|
||||
v-loading="loading"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="code" label="货架编码" width="120" sortable />
|
||||
<el-table-column prop="name" label="货架名称" width="150" />
|
||||
<el-table-column label="位置信息" width="150">
|
||||
<template #default="{ row }">
|
||||
<div class="position-info">
|
||||
<div>X: {{ row.x || 0 }}</div>
|
||||
<div>Y: {{ row.y || 0 }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="货架规格" width="120">
|
||||
<template #default="{ row }">
|
||||
{{ row.rackLevels || 0 }}层 × {{ row.rackRows || 0 }}排 × {{ row.rackColumns || 0 }}列
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="空间数量" width="100">
|
||||
<template #default="{ row }">
|
||||
{{ calculateSpaceCount(row) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getStatusColor(row.status)">
|
||||
{{ getStatusName(row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="利用率" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-progress
|
||||
:percentage="row.utilizationRate || 0"
|
||||
:color="getUtilizationColor(row.utilizationRate)"
|
||||
:stroke-width="6"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="200" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
size="small"
|
||||
@click.stop="selectRack(row)"
|
||||
>
|
||||
选择
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
link
|
||||
size="small"
|
||||
@click.stop="editPosition(row)"
|
||||
>
|
||||
编辑位置
|
||||
</el-button>
|
||||
<el-button
|
||||
type="info"
|
||||
link
|
||||
size="small"
|
||||
@click.stop="viewSpaces(row)"
|
||||
>
|
||||
查看空间
|
||||
</el-button>
|
||||
<el-dropdown @command="(command: string) => handleDropdownCommand(command, row)">
|
||||
<el-button type="info" link size="small">
|
||||
更多<el-icon class="el-icon--right"><ArrowDown /></el-icon>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="optimize">优化排序</el-dropdown-item>
|
||||
<el-dropdown-item command="maintenance">设为维护</el-dropdown-item>
|
||||
<el-dropdown-item command="disable" divided>禁用货架</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<el-pagination
|
||||
v-if="filteredRacks.length > pageSize"
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:total="filteredRacks.length"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
class="pagination"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 批量操作工具栏 -->
|
||||
<div v-if="selectedRacks.length" class="batch-toolbar">
|
||||
<el-alert
|
||||
:title="`已选择 ${selectedRacks.length} 个货架`"
|
||||
type="info"
|
||||
:closable="false"
|
||||
class="selection-alert"
|
||||
/>
|
||||
<div class="batch-actions">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="batchOptimize"
|
||||
>
|
||||
批量优化
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
size="small"
|
||||
@click="batchSetStatus('normal')"
|
||||
>
|
||||
设为正常
|
||||
</el-button>
|
||||
<el-button
|
||||
type="warning"
|
||||
size="small"
|
||||
@click="batchSetStatus('maintenance')"
|
||||
>
|
||||
批量维护
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
size="small"
|
||||
@click="batchSetStatus('disabled')"
|
||||
>
|
||||
批量禁用
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 统计信息抽屉 -->
|
||||
<el-drawer
|
||||
v-model="statsDrawerVisible"
|
||||
title="区域货架统计"
|
||||
direction="rtl"
|
||||
size="400px"
|
||||
>
|
||||
<div class="stats-content">
|
||||
<el-row :gutter="16" class="stats-cards">
|
||||
<el-col :span="12">
|
||||
<el-card class="stat-card">
|
||||
<el-statistic
|
||||
title="总货架数"
|
||||
:value="rackStats.totalCount"
|
||||
/>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-card class="stat-card">
|
||||
<el-statistic
|
||||
title="正常货架"
|
||||
:value="rackStats.normalCount"
|
||||
/>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="16" class="stats-cards">
|
||||
<el-col :span="12">
|
||||
<el-card class="stat-card">
|
||||
<el-statistic
|
||||
title="总空间数"
|
||||
:value="rackStats.totalSpaces"
|
||||
/>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-card class="stat-card">
|
||||
<el-statistic
|
||||
title="平均利用率"
|
||||
:value="rackStats.avgUtilization"
|
||||
suffix="%"
|
||||
/>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 利用率分布图表 -->
|
||||
<div class="stats-chart">
|
||||
<h4>利用率分布</h4>
|
||||
<div class="utilization-bars">
|
||||
<div
|
||||
v-for="range in utilizationRanges"
|
||||
:key="range.label"
|
||||
class="util-bar"
|
||||
>
|
||||
<div class="bar-label">{{ range.label }}</div>
|
||||
<div class="bar-container">
|
||||
<div
|
||||
class="bar-fill"
|
||||
:style="{ width: (range.count / rackStats.totalCount * 100) + '%' }"
|
||||
></div>
|
||||
<span class="bar-count">{{ range.count }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 状态分布 -->
|
||||
<div class="status-distribution">
|
||||
<h4>状态分布</h4>
|
||||
<el-row :gutter="8">
|
||||
<el-col :span="8" v-for="status in statusDistribution" :key="status.name">
|
||||
<div class="status-item">
|
||||
<el-tag :type="status.color">{{ status.name }}</el-tag>
|
||||
<div class="status-count">{{ status.count }}</div>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</div>
|
||||
</el-drawer>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<div v-if="!areaRacks.length && !loading" class="empty-state">
|
||||
<el-empty
|
||||
description="该区域暂无货架"
|
||||
:image-size="100"
|
||||
>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="refreshRackList"
|
||||
>
|
||||
刷新数据
|
||||
</el-button>
|
||||
</el-empty>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Search, ArrowDown } from '@element-plus/icons-vue'
|
||||
import * as warehouseApi from '@/api/warehouse'
|
||||
|
||||
interface Rack {
|
||||
id: number
|
||||
code: string
|
||||
name: string
|
||||
x?: number
|
||||
y?: number
|
||||
z?: number
|
||||
status: string
|
||||
rackLevels?: number
|
||||
rackRows?: number
|
||||
rackColumns?: number
|
||||
utilizationRate?: number
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
selectedArea?: any
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
rackSelect: [rack: any]
|
||||
rackEdit: [rack: any]
|
||||
rackBatchUpdate: [racks: any[]]
|
||||
}>()
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false)
|
||||
const areaRacks = ref<Rack[]>([])
|
||||
const selectedRacks = ref<Rack[]>([])
|
||||
const statsDrawerVisible = ref(false)
|
||||
|
||||
// 搜索和筛选
|
||||
const searchText = ref('')
|
||||
const statusFilter = ref('')
|
||||
const typeFilter = ref('')
|
||||
|
||||
// 分页
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(20)
|
||||
|
||||
// 筛选后的货架列表
|
||||
const filteredRacks = computed(() => {
|
||||
let result = [...areaRacks.value]
|
||||
|
||||
// 文本搜索
|
||||
if (searchText.value) {
|
||||
const keyword = searchText.value.toLowerCase()
|
||||
result = result.filter(rack =>
|
||||
rack.code.toLowerCase().includes(keyword) ||
|
||||
rack.name.toLowerCase().includes(keyword)
|
||||
)
|
||||
}
|
||||
|
||||
// 状态筛选
|
||||
if (statusFilter.value) {
|
||||
result = result.filter(rack => rack.status === statusFilter.value)
|
||||
}
|
||||
|
||||
// 类型筛选(这里简化处理)
|
||||
if (typeFilter.value) {
|
||||
// 根据实际业务逻辑筛选类型
|
||||
}
|
||||
|
||||
return result
|
||||
})
|
||||
|
||||
// 货架统计信息
|
||||
const rackStats = computed(() => {
|
||||
const total = areaRacks.value.length
|
||||
const normal = areaRacks.value.filter(r => r.status === 'normal').length
|
||||
const totalSpaces = areaRacks.value.reduce((sum, rack) => sum + calculateSpaceCount(rack), 0)
|
||||
const avgUtil = total > 0 ?
|
||||
Math.round(areaRacks.value.reduce((sum, rack) => sum + (rack.utilizationRate || 0), 0) / total) : 0
|
||||
|
||||
return {
|
||||
totalCount: total,
|
||||
normalCount: normal,
|
||||
totalSpaces,
|
||||
avgUtilization: avgUtil
|
||||
}
|
||||
})
|
||||
|
||||
// 利用率分布
|
||||
const utilizationRanges = computed(() => {
|
||||
const ranges = [
|
||||
{ label: '0-20%', min: 0, max: 20, count: 0 },
|
||||
{ label: '21-40%', min: 21, max: 40, count: 0 },
|
||||
{ label: '41-60%', min: 41, max: 60, count: 0 },
|
||||
{ label: '61-80%', min: 61, max: 80, count: 0 },
|
||||
{ label: '81-100%', min: 81, max: 100, count: 0 }
|
||||
]
|
||||
|
||||
areaRacks.value.forEach(rack => {
|
||||
const util = rack.utilizationRate || 0
|
||||
ranges.forEach(range => {
|
||||
if (util >= range.min && util <= range.max) {
|
||||
range.count++
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
return ranges
|
||||
})
|
||||
|
||||
// 状态分布
|
||||
const statusDistribution = computed(() => {
|
||||
const distribution = [
|
||||
{ name: '正常', value: 'normal', color: 'success', count: 0 },
|
||||
{ name: '维护', value: 'maintenance', color: 'warning', count: 0 },
|
||||
{ name: '禁用', value: 'disabled', color: 'danger', count: 0 }
|
||||
]
|
||||
|
||||
areaRacks.value.forEach(rack => {
|
||||
const item = distribution.find(d => d.value === rack.status)
|
||||
if (item) item.count++
|
||||
})
|
||||
|
||||
return distribution
|
||||
})
|
||||
|
||||
// 加载区域货架列表
|
||||
const loadAreaRacks = async (areaId: number) => {
|
||||
loading.value = true
|
||||
try {
|
||||
const response: any = await warehouseApi.getAreaRacks(areaId)
|
||||
|
||||
if (response.code === 200) {
|
||||
areaRacks.value = response.racks || []
|
||||
} else {
|
||||
ElMessage.error(response.message || '获取货架列表失败')
|
||||
}
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error.message || '获取货架列表失败')
|
||||
console.error(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新货架列表
|
||||
const refreshRackList = () => {
|
||||
if (props.selectedArea?.id) {
|
||||
loadAreaRacks(props.selectedArea.id)
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索处理
|
||||
const handleSearch = () => {
|
||||
currentPage.value = 1
|
||||
}
|
||||
|
||||
// 筛选处理
|
||||
const handleFilter = () => {
|
||||
currentPage.value = 1
|
||||
}
|
||||
|
||||
// 重置筛选
|
||||
const resetFilters = () => {
|
||||
searchText.value = ''
|
||||
statusFilter.value = ''
|
||||
typeFilter.value = ''
|
||||
currentPage.value = 1
|
||||
}
|
||||
|
||||
// 货架行点击
|
||||
const handleRackClick = (rack: Rack) => {
|
||||
selectRack(rack)
|
||||
}
|
||||
|
||||
// 选择变化处理
|
||||
const handleSelectionChange = (selection: Rack[]) => {
|
||||
selectedRacks.value = selection
|
||||
}
|
||||
|
||||
// 选择货架
|
||||
const selectRack = (rack: Rack) => {
|
||||
emit('rackSelect', rack)
|
||||
ElMessage.success(`已选择货架: ${rack.code}`)
|
||||
}
|
||||
|
||||
// 编辑位置
|
||||
const editPosition = (rack: Rack) => {
|
||||
emit('rackEdit', rack)
|
||||
ElMessage.info(`编辑货架 ${rack.code} 的位置`)
|
||||
}
|
||||
|
||||
// 查看空间
|
||||
const viewSpaces = (rack: Rack) => {
|
||||
ElMessage.info(`查看货架 ${rack.code} 的空间信息`)
|
||||
}
|
||||
|
||||
// 下拉操作处理
|
||||
const handleDropdownCommand = (command: string, rack: Rack) => {
|
||||
switch (command) {
|
||||
case 'optimize':
|
||||
ElMessage.info(`优化货架 ${rack.code} 的排序`)
|
||||
break
|
||||
case 'maintenance':
|
||||
setRackStatus(rack, 'maintenance')
|
||||
break
|
||||
case 'disable':
|
||||
setRackStatus(rack, 'disabled')
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 设置货架状态
|
||||
const setRackStatus = (rack: Rack, status: string) => {
|
||||
ElMessageBox.confirm(`确定将货架 ${rack.code} 设为${getStatusName(status)}状态吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
// 这里应该调用API更新状态
|
||||
rack.status = status
|
||||
ElMessage.success('状态更新成功')
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
// 批量优化
|
||||
const batchOptimize = () => {
|
||||
ElMessage.info('批量优化功能开发中...')
|
||||
}
|
||||
|
||||
// 批量设置状态
|
||||
const batchSetStatus = (status: string) => {
|
||||
ElMessageBox.confirm(`确定将选中的 ${selectedRacks.value.length} 个货架设为${getStatusName(status)}状态吗?`, '批量操作', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
selectedRacks.value.forEach(rack => {
|
||||
rack.status = status
|
||||
})
|
||||
ElMessage.success('批量状态更新成功')
|
||||
emit('rackBatchUpdate', selectedRacks.value)
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
// 显示统计信息
|
||||
const showRackStats = () => {
|
||||
statsDrawerVisible.value = true
|
||||
}
|
||||
|
||||
// 计算空间数量
|
||||
const calculateSpaceCount = (rack: Rack): number => {
|
||||
return (rack.rackLevels || 0) * (rack.rackRows || 0) * (rack.rackColumns || 0)
|
||||
}
|
||||
|
||||
// 获取状态颜色
|
||||
const getStatusColor = (status: string): string => {
|
||||
const colors: Record<string, string> = {
|
||||
'normal': 'success',
|
||||
'maintenance': 'warning',
|
||||
'disabled': 'danger'
|
||||
}
|
||||
return colors[status] || ''
|
||||
}
|
||||
|
||||
// 获取状态名称
|
||||
const getStatusName = (status: string): string => {
|
||||
const names: Record<string, string> = {
|
||||
'normal': '正常',
|
||||
'maintenance': '维护中',
|
||||
'disabled': '已禁用'
|
||||
}
|
||||
return names[status] || status
|
||||
}
|
||||
|
||||
// 获取利用率颜色
|
||||
const getUtilizationColor = (rate?: number): string => {
|
||||
if (!rate) return '#e6e6e6'
|
||||
if (rate < 30) return '#f56c6c'
|
||||
if (rate < 60) return '#e6a23c'
|
||||
if (rate < 80) return '#409eff'
|
||||
return '#67c23a'
|
||||
}
|
||||
|
||||
// 监听区域变化
|
||||
watch(() => props.selectedArea?.id, (newAreaId) => {
|
||||
if (newAreaId) {
|
||||
loadAreaRacks(newAreaId)
|
||||
} else {
|
||||
areaRacks.value = []
|
||||
}
|
||||
}, { immediate: true })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.area-racks-list {
|
||||
.box-card {
|
||||
height: 100%;
|
||||
|
||||
:deep(.el-card__body) {
|
||||
padding: 16px;
|
||||
height: calc(100% - 60px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.header-buttons {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.racks-content {
|
||||
.area-info {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.search-filters {
|
||||
margin: 16px 0;
|
||||
}
|
||||
|
||||
.racks-table {
|
||||
.position-info {
|
||||
font-size: 12px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
margin-top: 16px;
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
|
||||
.batch-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 16px;
|
||||
padding: 12px;
|
||||
background: #f0f9ff;
|
||||
border: 1px solid #bfdbfe;
|
||||
border-radius: 4px;
|
||||
|
||||
.selection-alert {
|
||||
flex: 1;
|
||||
margin-right: 16px;
|
||||
}
|
||||
|
||||
.batch-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding: 40px 0;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
// 统计抽屉样式
|
||||
.stats-content {
|
||||
.stats-cards {
|
||||
margin-bottom: 16px;
|
||||
|
||||
.stat-card {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.stats-chart {
|
||||
margin: 24px 0;
|
||||
|
||||
h4 {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.utilization-bars {
|
||||
.util-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
|
||||
.bar-label {
|
||||
width: 80px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.bar-container {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
height: 20px;
|
||||
background: #f5f5f5;
|
||||
border-radius: 10px;
|
||||
margin: 0 8px;
|
||||
|
||||
.bar-fill {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #409eff, #67c23a);
|
||||
border-radius: 10px;
|
||||
transition: width 0.3s;
|
||||
}
|
||||
|
||||
.bar-count {
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.status-distribution {
|
||||
h4 {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.status-item {
|
||||
text-align: center;
|
||||
padding: 8px;
|
||||
border: 1px solid #e4e4e4;
|
||||
border-radius: 4px;
|
||||
|
||||
.status-count {
|
||||
margin-top: 8px;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
448
src/views/warehouse/PathManagement.vue
Normal file
448
src/views/warehouse/PathManagement.vue
Normal file
@ -0,0 +1,448 @@
|
||||
<template>
|
||||
<div class="path-management">
|
||||
<el-card class="box-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>路径管理</span>
|
||||
<div class="header-buttons">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="recalculatePath"
|
||||
:loading="recalculatingPath"
|
||||
:disabled="!selectedWarehouse?.id"
|
||||
>
|
||||
重新计算路径
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
size="small"
|
||||
@click="updateNeighbors"
|
||||
:loading="updatingNeighbors"
|
||||
:disabled="!selectedWarehouse?.id"
|
||||
>
|
||||
更新邻居关系
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="path-content">
|
||||
<!-- 路径参数设置 -->
|
||||
<el-form
|
||||
:model="pathParams"
|
||||
label-width="120px"
|
||||
size="small"
|
||||
@submit.prevent
|
||||
>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="包含空间信息">
|
||||
<el-switch v-model="pathParams.includeSpaces" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="结果限制">
|
||||
<el-input-number
|
||||
v-model="pathParams.limit"
|
||||
:min="1"
|
||||
:max="1000"
|
||||
controls-position="right"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="排序方式">
|
||||
<el-select v-model="pathParams.sortBy" placeholder="请选择排序方式">
|
||||
<el-option label="距离优先" value="distance" />
|
||||
<el-option label="序号优先" value="sequence" />
|
||||
<el-option label="效率优先" value="efficiency" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="getPickPath"
|
||||
:loading="loadingPath"
|
||||
:disabled="!selectedWarehouse?.id"
|
||||
>
|
||||
获取拣货路径
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
|
||||
<!-- 路径信息展示 -->
|
||||
<div class="path-info" v-if="pickPath">
|
||||
<el-divider content-position="left">拣货路径信息</el-divider>
|
||||
|
||||
<div class="path-stats">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="6">
|
||||
<el-statistic title="总路径长度" :value="pathStats.totalDistance" suffix="米" />
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-statistic title="路径节点数" :value="pathStats.nodeCount" suffix="个" />
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-statistic title="预计用时" :value="pathStats.estimatedTime" suffix="分钟" />
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-statistic title="效率评分" :value="pathStats.efficiencyScore" suffix="分" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
<!-- 路径详细信息 -->
|
||||
<el-table
|
||||
:data="pickPath"
|
||||
style="margin-top: 16px"
|
||||
size="small"
|
||||
max-height="300"
|
||||
>
|
||||
<el-table-column prop="sequence" label="序号" width="60" />
|
||||
<el-table-column prop="nodeType" label="节点类型" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="getNodeTypeColor(row.nodeType)">
|
||||
{{ getNodeTypeName(row.nodeType) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="nodeName" label="节点名称" />
|
||||
<el-table-column prop="distance" label="距离(米)" width="80" />
|
||||
<el-table-column prop="estimatedTime" label="用时(秒)" width="80" />
|
||||
<el-table-column label="操作" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
size="small"
|
||||
@click="highlightNode(row)"
|
||||
>
|
||||
定位
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<!-- 路径可视化选项 -->
|
||||
<div class="path-visualization" v-if="pickPath">
|
||||
<el-divider content-position="left">路径可视化</el-divider>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-button
|
||||
type="success"
|
||||
@click="showPathOnMap"
|
||||
:disabled="!pickPath"
|
||||
>
|
||||
在地图上显示路径
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-button
|
||||
type="info"
|
||||
@click="exportPath"
|
||||
:disabled="!pickPath"
|
||||
>
|
||||
导出路径数据
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<div v-if="!pickPath && !loadingPath" class="empty-state">
|
||||
<el-empty
|
||||
description="暂无路径数据"
|
||||
:image-size="100"
|
||||
>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="getPickPath"
|
||||
:disabled="!selectedWarehouse?.id"
|
||||
>
|
||||
获取拣货路径
|
||||
</el-button>
|
||||
</el-empty>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import * as warehouseApi from '@/api/warehouse'
|
||||
|
||||
interface PathNode {
|
||||
sequence: number
|
||||
nodeType: string
|
||||
nodeName: string
|
||||
distance: number
|
||||
estimatedTime: number
|
||||
location?: {
|
||||
x: number
|
||||
y: number
|
||||
z?: number
|
||||
}
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
selectedWarehouse?: any
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
pathHighlight: [nodeData: any]
|
||||
pathShow: [pathData: any[]]
|
||||
}>()
|
||||
|
||||
// 响应式数据
|
||||
const pickPath = ref<PathNode[]>([])
|
||||
const loadingPath = ref(false)
|
||||
const recalculatingPath = ref(false)
|
||||
const updatingNeighbors = ref(false)
|
||||
|
||||
// 路径参数
|
||||
const pathParams = reactive({
|
||||
includeSpaces: true,
|
||||
limit: 100,
|
||||
sortBy: 'efficiency'
|
||||
})
|
||||
|
||||
// 路径统计信息
|
||||
const pathStats = computed(() => {
|
||||
if (!pickPath.value?.length) {
|
||||
return {
|
||||
totalDistance: 0,
|
||||
nodeCount: 0,
|
||||
estimatedTime: 0,
|
||||
efficiencyScore: 0
|
||||
}
|
||||
}
|
||||
|
||||
const totalDistance = pickPath.value.reduce((sum, node) => sum + (node.distance || 0), 0)
|
||||
const totalTime = pickPath.value.reduce((sum, node) => sum + (node.estimatedTime || 0), 0)
|
||||
const nodeCount = pickPath.value.length
|
||||
const efficiencyScore = nodeCount > 0 ? Math.round((totalDistance / nodeCount) * 10) / 10 : 0
|
||||
|
||||
return {
|
||||
totalDistance: Math.round(totalDistance * 100) / 100,
|
||||
nodeCount,
|
||||
estimatedTime: Math.round(totalTime / 60 * 100) / 100,
|
||||
efficiencyScore
|
||||
}
|
||||
})
|
||||
|
||||
// 获取拣货路径
|
||||
const getPickPath = async () => {
|
||||
if (!props.selectedWarehouse?.id) {
|
||||
ElMessage.warning('请先选择一个仓库')
|
||||
return
|
||||
}
|
||||
|
||||
loadingPath.value = true
|
||||
try {
|
||||
const params = {
|
||||
warehouse_id: props.selectedWarehouse.id,
|
||||
include_spaces: pathParams.includeSpaces ? 'true' : 'false',
|
||||
limit: pathParams.limit,
|
||||
sort_by: pathParams.sortBy
|
||||
}
|
||||
|
||||
const response: any = await warehouseApi.getPickPath(params)
|
||||
|
||||
if (response.code === 200) {
|
||||
// 模拟路径数据结构(根据实际返回调整)
|
||||
pickPath.value = response.path || generateMockPath()
|
||||
ElMessage.success('路径获取成功')
|
||||
} else {
|
||||
ElMessage.error(response.message || '获取路径失败')
|
||||
}
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error.message || '获取路径失败')
|
||||
console.error(error)
|
||||
} finally {
|
||||
loadingPath.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 重新计算拣货路径
|
||||
const recalculatePath = async () => {
|
||||
if (!props.selectedWarehouse?.id) {
|
||||
ElMessage.warning('请先选择一个仓库')
|
||||
return
|
||||
}
|
||||
|
||||
ElMessageBox.confirm('重新计算路径将花费一些时间,是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
recalculatingPath.value = true
|
||||
try {
|
||||
const response: any = await warehouseApi.recalculatePickPath(props.selectedWarehouse.id)
|
||||
|
||||
if (response.code === 200) {
|
||||
ElMessage.success('路径重新计算成功')
|
||||
// 重新获取路径数据
|
||||
await getPickPath()
|
||||
} else {
|
||||
ElMessage.error(response.message || '重新计算失败')
|
||||
}
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error.message || '重新计算失败')
|
||||
console.error(error)
|
||||
} finally {
|
||||
recalculatingPath.value = false
|
||||
}
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
// 更新邻居关系
|
||||
const updateNeighbors = async () => {
|
||||
if (!props.selectedWarehouse?.id) {
|
||||
ElMessage.warning('请先选择一个仓库')
|
||||
return
|
||||
}
|
||||
|
||||
updatingNeighbors.value = true
|
||||
try {
|
||||
const response: any = await warehouseApi.updateNeighbors(props.selectedWarehouse.id)
|
||||
|
||||
if (response.code === 200) {
|
||||
ElMessage.success('邻居关系更新成功')
|
||||
} else {
|
||||
ElMessage.error(response.message || '更新邻居关系失败')
|
||||
}
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error.message || '更新邻居关系失败')
|
||||
console.error(error)
|
||||
} finally {
|
||||
updatingNeighbors.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 节点类型颜色
|
||||
const getNodeTypeColor = (type: string) => {
|
||||
const colors: Record<string, string> = {
|
||||
'start': 'success',
|
||||
'rack': 'primary',
|
||||
'junction': 'info',
|
||||
'end': 'danger'
|
||||
}
|
||||
return colors[type] || ''
|
||||
}
|
||||
|
||||
// 节点类型名称
|
||||
const getNodeTypeName = (type: string) => {
|
||||
const names: Record<string, string> = {
|
||||
'start': '起点',
|
||||
'rack': '货架',
|
||||
'junction': '路口',
|
||||
'end': '终点'
|
||||
}
|
||||
return names[type] || type
|
||||
}
|
||||
|
||||
// 高亮节点
|
||||
const highlightNode = (node: PathNode) => {
|
||||
emit('pathHighlight', node)
|
||||
ElMessage.info(`已定位到: ${node.nodeName}`)
|
||||
}
|
||||
|
||||
// 在地图上显示路径
|
||||
const showPathOnMap = () => {
|
||||
emit('pathShow', pickPath.value)
|
||||
ElMessage.success('路径已在地图上显示')
|
||||
}
|
||||
|
||||
// 导出路径数据
|
||||
const exportPath = () => {
|
||||
if (!pickPath.value?.length) return
|
||||
|
||||
const data = {
|
||||
warehouse_id: props.selectedWarehouse?.id,
|
||||
path_params: pathParams,
|
||||
path_stats: pathStats.value,
|
||||
path_nodes: pickPath.value,
|
||||
export_time: new Date().toLocaleString()
|
||||
}
|
||||
|
||||
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = `pick_path_${props.selectedWarehouse?.code || 'warehouse'}_${Date.now()}.json`
|
||||
link.click()
|
||||
URL.revokeObjectURL(url)
|
||||
|
||||
ElMessage.success('路径数据已导出')
|
||||
}
|
||||
|
||||
// 生成模拟路径数据(用于测试)
|
||||
const generateMockPath = (): PathNode[] => {
|
||||
return [
|
||||
{ sequence: 1, nodeType: 'start', nodeName: '拣货起点', distance: 0, estimatedTime: 0 },
|
||||
{ sequence: 2, nodeType: 'rack', nodeName: 'A区-货架01', distance: 15.5, estimatedTime: 30 },
|
||||
{ sequence: 3, nodeType: 'rack', nodeName: 'A区-货架03', distance: 8.2, estimatedTime: 45 },
|
||||
{ sequence: 4, nodeType: 'junction', nodeName: '路口J01', distance: 12.0, estimatedTime: 20 },
|
||||
{ sequence: 5, nodeType: 'rack', nodeName: 'B区-货架05', distance: 22.3, estimatedTime: 60 },
|
||||
{ sequence: 6, nodeType: 'end', nodeName: '拣货终点', distance: 18.7, estimatedTime: 25 }
|
||||
]
|
||||
}
|
||||
|
||||
// 监听仓库变化
|
||||
watch(() => props.selectedWarehouse?.id, () => {
|
||||
pickPath.value = []
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.path-management {
|
||||
.box-card {
|
||||
height: 100%;
|
||||
|
||||
:deep(.el-card__body) {
|
||||
padding: 16px;
|
||||
height: calc(100% - 60px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.header-buttons {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.path-content {
|
||||
.path-stats {
|
||||
margin: 16px 0;
|
||||
padding: 16px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.path-visualization {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding: 40px 0;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
653
src/views/warehouse/RackPositionEditor.vue
Normal file
653
src/views/warehouse/RackPositionEditor.vue
Normal file
@ -0,0 +1,653 @@
|
||||
<template>
|
||||
<div class="rack-position-editor">
|
||||
<el-card class="box-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>货架位置管理</span>
|
||||
<div class="header-buttons">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="toggleEditMode"
|
||||
:disabled="!selectedRack"
|
||||
>
|
||||
{{ editMode ? '退出编辑' : '编辑位置' }}
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
size="small"
|
||||
@click="batchEditMode = !batchEditMode"
|
||||
:disabled="!(rackList && rackList.length)"
|
||||
>
|
||||
{{ batchEditMode ? '退出批量' : '批量编辑' }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="position-content">
|
||||
<!-- 单个货架位置编辑 -->
|
||||
<div v-if="!batchEditMode && selectedRack" class="single-edit">
|
||||
<el-descriptions
|
||||
title="货架信息"
|
||||
:column="2"
|
||||
size="small"
|
||||
border
|
||||
>
|
||||
<el-descriptions-item label="货架编码">
|
||||
{{ selectedRack.code }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="货架名称">
|
||||
{{ selectedRack.name }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="所属区域">
|
||||
{{ selectedRack.parentName || '未指定' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="货架类型">
|
||||
{{ selectedRack.type || '标准货架' }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<el-divider content-position="left">位置坐标</el-divider>
|
||||
|
||||
<el-form
|
||||
:model="positionForm"
|
||||
label-width="80px"
|
||||
size="small"
|
||||
:disabled="!editMode"
|
||||
>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="X 坐标">
|
||||
<el-input-number
|
||||
v-model="positionForm.x"
|
||||
:min="0"
|
||||
:max="999999"
|
||||
:precision="2"
|
||||
:step="10"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
@change="onPositionChange"
|
||||
/>
|
||||
<div class="unit-hint">单位: 毫米</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="Y 坐标">
|
||||
<el-input-number
|
||||
v-model="positionForm.y"
|
||||
:min="0"
|
||||
:max="999999"
|
||||
:precision="2"
|
||||
:step="10"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
@change="onPositionChange"
|
||||
/>
|
||||
<div class="unit-hint">单位: 毫米</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="Z 坐标">
|
||||
<el-input-number
|
||||
v-model="positionForm.z"
|
||||
:min="0"
|
||||
:max="999999"
|
||||
:precision="2"
|
||||
:step="5"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
@change="onPositionChange"
|
||||
/>
|
||||
<div class="unit-hint">单位: 毫米 (可选)</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row v-if="editMode">
|
||||
<el-col :span="24">
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="savePosition"
|
||||
:loading="saving"
|
||||
>
|
||||
保存位置
|
||||
</el-button>
|
||||
<el-button @click="resetPosition">
|
||||
重置
|
||||
</el-button>
|
||||
<el-button
|
||||
type="info"
|
||||
@click="previewPosition"
|
||||
:disabled="!hasPositionChanged"
|
||||
>
|
||||
预览位置
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
|
||||
<!-- 位置历史记录 -->
|
||||
<div v-if="positionHistory.length" class="position-history">
|
||||
<el-divider content-position="left">位置历史</el-divider>
|
||||
<el-table
|
||||
:data="positionHistory"
|
||||
size="small"
|
||||
max-height="200"
|
||||
>
|
||||
<el-table-column prop="timestamp" label="时间" width="160">
|
||||
<template #default="{ row }">
|
||||
{{ formatTime(row.timestamp) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="坐标">
|
||||
<template #default="{ row }">
|
||||
X:{{ row.x }}, Y:{{ row.y }}{{ row.z ? `, Z:${row.z}` : '' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="operator" label="操作人" width="100" />
|
||||
<el-table-column label="操作" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
size="small"
|
||||
@click="restorePosition(row)"
|
||||
>
|
||||
恢复
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 批量编辑模式 -->
|
||||
<div v-if="batchEditMode" class="batch-edit">
|
||||
<div class="batch-header">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="selectAllRacks"
|
||||
>
|
||||
全选
|
||||
</el-button>
|
||||
<el-button
|
||||
type="info"
|
||||
size="small"
|
||||
@click="clearSelection"
|
||||
>
|
||||
清空选择
|
||||
</el-button>
|
||||
<span class="selection-count">
|
||||
已选择 {{ selectedRacks.length }} 个货架
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
:data="rackList"
|
||||
@selection-change="handleSelectionChange"
|
||||
style="margin-top: 16px"
|
||||
size="small"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="code" label="货架编码" />
|
||||
<el-table-column prop="name" label="货架名称" />
|
||||
<el-table-column label="当前位置">
|
||||
<template #default="{ row }">
|
||||
X:{{ row.x || 0 }}, Y:{{ row.y || 0 }}{{ row.z ? `, Z:${row.z}` : '' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
size="small"
|
||||
@click="editSingleRack(row)"
|
||||
>
|
||||
单独编辑
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 批量操作工具 -->
|
||||
<div v-if="selectedRacks.length" class="batch-tools">
|
||||
<el-divider content-position="left">批量操作</el-divider>
|
||||
|
||||
<el-form :model="batchForm" label-width="120px" size="small">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="X 轴偏移">
|
||||
<el-input-number
|
||||
v-model="batchForm.offsetX"
|
||||
:step="10"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="Y 轴偏移">
|
||||
<el-input-number
|
||||
v-model="batchForm.offsetY"
|
||||
:step="10"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="Z 轴偏移">
|
||||
<el-input-number
|
||||
v-model="batchForm.offsetZ"
|
||||
:step="5"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="applyBatchOffset"
|
||||
:loading="batchSaving"
|
||||
>
|
||||
应用偏移
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
@click="alignRacks"
|
||||
>
|
||||
对齐排列
|
||||
</el-button>
|
||||
<el-button
|
||||
type="warning"
|
||||
@click="distributeEvenly"
|
||||
>
|
||||
均匀分布
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<div v-if="!selectedRack && !batchEditMode" class="empty-state">
|
||||
<el-empty
|
||||
description="请选择一个货架进行位置编辑"
|
||||
:image-size="100"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import * as warehouseApi from '@/api/warehouse'
|
||||
|
||||
interface RackPosition {
|
||||
x: number
|
||||
y: number
|
||||
z?: number
|
||||
}
|
||||
|
||||
interface PositionHistory {
|
||||
timestamp: number
|
||||
x: number
|
||||
y: number
|
||||
z?: number
|
||||
operator: string
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
selectedRack?: any
|
||||
rackList?: any[]
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
positionUpdate: [rackId: number, position: RackPosition]
|
||||
positionPreview: [rackId: number, position: RackPosition]
|
||||
}>()
|
||||
|
||||
// 响应式数据
|
||||
const editMode = ref(false)
|
||||
const batchEditMode = ref(false)
|
||||
const saving = ref(false)
|
||||
const batchSaving = ref(false)
|
||||
|
||||
// 位置表单
|
||||
const positionForm = reactive<RackPosition>({
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
})
|
||||
|
||||
// 原始位置备份
|
||||
const originalPosition = reactive<RackPosition>({
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
})
|
||||
|
||||
// 批量编辑表单
|
||||
const batchForm = reactive({
|
||||
offsetX: 0,
|
||||
offsetY: 0,
|
||||
offsetZ: 0
|
||||
})
|
||||
|
||||
// 选中的货架列表
|
||||
const selectedRacks = ref<any[]>([])
|
||||
|
||||
// 位置历史记录
|
||||
const positionHistory = ref<PositionHistory[]>([])
|
||||
|
||||
// 计算属性
|
||||
const hasPositionChanged = computed(() => {
|
||||
return positionForm.x !== originalPosition.x ||
|
||||
positionForm.y !== originalPosition.y ||
|
||||
positionForm.z !== originalPosition.z
|
||||
})
|
||||
|
||||
// 切换编辑模式
|
||||
const toggleEditMode = () => {
|
||||
if (editMode.value) {
|
||||
// 退出编辑模式,检查是否有未保存的更改
|
||||
if (hasPositionChanged.value) {
|
||||
ElMessageBox.confirm('有未保存的更改,确定退出编辑模式吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
editMode.value = false
|
||||
resetPosition()
|
||||
}).catch(() => {})
|
||||
} else {
|
||||
editMode.value = false
|
||||
}
|
||||
} else {
|
||||
editMode.value = true
|
||||
}
|
||||
}
|
||||
|
||||
// 位置变化处理
|
||||
const onPositionChange = () => {
|
||||
// 可以添加实时预览逻辑
|
||||
}
|
||||
|
||||
// 保存位置
|
||||
const savePosition = async () => {
|
||||
if (!props.selectedRack?.id) return
|
||||
|
||||
saving.value = true
|
||||
try {
|
||||
const params = {
|
||||
rack_id: props.selectedRack.id,
|
||||
x: positionForm.x,
|
||||
y: positionForm.y,
|
||||
z: positionForm.z
|
||||
}
|
||||
|
||||
const response: any = await warehouseApi.updateRackPosition(params)
|
||||
|
||||
if (response.code === 200) {
|
||||
ElMessage.success('货架位置更新成功')
|
||||
|
||||
// 更新原始位置
|
||||
Object.assign(originalPosition, positionForm)
|
||||
|
||||
// 添加历史记录
|
||||
positionHistory.value.unshift({
|
||||
timestamp: Date.now(),
|
||||
x: positionForm.x,
|
||||
y: positionForm.y,
|
||||
z: positionForm.z,
|
||||
operator: '当前用户' // 实际应用中从用户信息获取
|
||||
})
|
||||
|
||||
// 发送位置更新事件
|
||||
emit('positionUpdate', props.selectedRack.id, { ...positionForm })
|
||||
|
||||
editMode.value = false
|
||||
} else {
|
||||
ElMessage.error(response.message || '更新位置失败')
|
||||
}
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error.message || '更新位置失败')
|
||||
console.error(error)
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 重置位置
|
||||
const resetPosition = () => {
|
||||
Object.assign(positionForm, originalPosition)
|
||||
}
|
||||
|
||||
// 预览位置
|
||||
const previewPosition = () => {
|
||||
if (!props.selectedRack?.id) return
|
||||
emit('positionPreview', props.selectedRack.id, { ...positionForm })
|
||||
ElMessage.info('位置预览已更新')
|
||||
}
|
||||
|
||||
// 恢复历史位置
|
||||
const restorePosition = (historyItem: PositionHistory) => {
|
||||
ElMessageBox.confirm('确定恢复到此位置吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
positionForm.x = historyItem.x
|
||||
positionForm.y = historyItem.y
|
||||
positionForm.z = historyItem.z || 0
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
// 批量选择处理
|
||||
const handleSelectionChange = (selection: any[]) => {
|
||||
selectedRacks.value = selection
|
||||
}
|
||||
|
||||
// 全选货架
|
||||
const selectAllRacks = () => {
|
||||
// 这里需要通过ref获取表格组件并调用toggleAllSelection方法
|
||||
// 简化处理:直接设置选中状态
|
||||
selectedRacks.value = [...(props.rackList || [])]
|
||||
}
|
||||
|
||||
// 清空选择
|
||||
const clearSelection = () => {
|
||||
selectedRacks.value = []
|
||||
}
|
||||
|
||||
// 编辑单个货架
|
||||
const editSingleRack = (rack: any) => {
|
||||
batchEditMode.value = false
|
||||
// 这里应该触发parent组件选择该货架
|
||||
ElMessage.info(`切换到货架 ${rack.code} 的编辑模式`)
|
||||
}
|
||||
|
||||
// 应用批量偏移
|
||||
const applyBatchOffset = async () => {
|
||||
if (!selectedRacks.value.length) {
|
||||
ElMessage.warning('请先选择要移动的货架')
|
||||
return
|
||||
}
|
||||
|
||||
ElMessageBox.confirm(`确定对 ${selectedRacks.value.length} 个货架应用偏移吗?`, '批量操作', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
batchSaving.value = true
|
||||
|
||||
try {
|
||||
const promises = selectedRacks.value.map(rack => {
|
||||
const params = {
|
||||
rack_id: rack.id,
|
||||
x: (rack.x || 0) + batchForm.offsetX,
|
||||
y: (rack.y || 0) + batchForm.offsetY,
|
||||
z: (rack.z || 0) + batchForm.offsetZ
|
||||
}
|
||||
return warehouseApi.updateRackPosition(params)
|
||||
})
|
||||
|
||||
await Promise.all(promises)
|
||||
|
||||
ElMessage.success('批量位置更新成功')
|
||||
|
||||
// 重置偏移值
|
||||
batchForm.offsetX = 0
|
||||
batchForm.offsetY = 0
|
||||
batchForm.offsetZ = 0
|
||||
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error.message || '批量更新失败')
|
||||
} finally {
|
||||
batchSaving.value = false
|
||||
}
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
// 对齐排列
|
||||
const alignRacks = () => {
|
||||
if (selectedRacks.value.length < 2) {
|
||||
ElMessage.warning('至少选择2个货架才能进行对齐')
|
||||
return
|
||||
}
|
||||
|
||||
ElMessage.info('对齐功能开发中...')
|
||||
}
|
||||
|
||||
// 均匀分布
|
||||
const distributeEvenly = () => {
|
||||
if (selectedRacks.value.length < 3) {
|
||||
ElMessage.warning('至少选择3个货架才能进行均匀分布')
|
||||
return
|
||||
}
|
||||
|
||||
ElMessage.info('均匀分布功能开发中...')
|
||||
}
|
||||
|
||||
// 格式化时间
|
||||
const formatTime = (timestamp: number) => {
|
||||
return new Date(timestamp).toLocaleString()
|
||||
}
|
||||
|
||||
// 监听选中货架变化
|
||||
watch(() => props.selectedRack, (newRack) => {
|
||||
if (newRack) {
|
||||
positionForm.x = newRack.x || 0
|
||||
positionForm.y = newRack.y || 0
|
||||
positionForm.z = newRack.z || 0
|
||||
|
||||
Object.assign(originalPosition, {
|
||||
x: newRack.x || 0,
|
||||
y: newRack.y || 0,
|
||||
z: newRack.z || 0
|
||||
})
|
||||
|
||||
// 模拟加载历史记录
|
||||
loadPositionHistory(newRack.id)
|
||||
}
|
||||
|
||||
editMode.value = false
|
||||
}, { immediate: true })
|
||||
|
||||
// 加载位置历史记录
|
||||
const loadPositionHistory = (rackId: number) => {
|
||||
// 这里应该调用API获取历史记录
|
||||
// 暂时使用模拟数据
|
||||
positionHistory.value = [
|
||||
{
|
||||
timestamp: Date.now() - 3600000,
|
||||
x: positionForm.x - 10,
|
||||
y: positionForm.y - 5,
|
||||
z: positionForm.z,
|
||||
operator: '用户A'
|
||||
},
|
||||
{
|
||||
timestamp: Date.now() - 7200000,
|
||||
x: positionForm.x - 20,
|
||||
y: positionForm.y - 10,
|
||||
operator: '用户B'
|
||||
}
|
||||
]
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.rack-position-editor {
|
||||
.box-card {
|
||||
height: 100%;
|
||||
|
||||
:deep(.el-card__body) {
|
||||
padding: 16px;
|
||||
height: calc(100% - 60px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.header-buttons {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.position-content {
|
||||
.unit-hint {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.position-history {
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.batch-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 8px 0;
|
||||
|
||||
.selection-count {
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.batch-tools {
|
||||
margin-top: 16px;
|
||||
padding: 16px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding: 40px 0;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -3,6 +3,7 @@
|
||||
title="添加仓库"
|
||||
v-model="internalVisible"
|
||||
width="600px"
|
||||
align-center
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-dialog :title="dialogTitle" v-model="props.visible" width="900px" :before-close="handleClose" :close-on-click-modal="false">
|
||||
<el-dialog :title="dialogTitle" v-model="props.visible" width="900px" align-center :before-close="handleClose" :close-on-click-modal="false">
|
||||
<el-form ref="zoneFormRef" :model="formData" :rules="formRules" label-width="100px" label-position="left">
|
||||
<!-- 分区类型改为下拉选择 -->
|
||||
<el-form-item label="分区类型" prop="zone_type">
|
||||
|
||||
@ -27,18 +27,52 @@
|
||||
|
||||
<!-- 右侧边栏 -->
|
||||
<div class="sidebar right-sidebar">
|
||||
<!-- 修改这里,传入更多信息 -->
|
||||
<rack-space-management
|
||||
:rack="selectedRack"
|
||||
ref="rackSpaceManagement"
|
||||
@refresh="refreshRackSpaces"
|
||||
@space-click="spaceClick"
|
||||
/>
|
||||
<space-card
|
||||
v-if="selectedRack"
|
||||
:spaceId="currentSpaceId"
|
||||
@spaceSave="handleSpaceSave"
|
||||
/>
|
||||
<!-- 标签页切换 -->
|
||||
<el-tabs v-model="activeRightTab" class="right-tabs">
|
||||
<!-- 空间管理 -->
|
||||
<el-tab-pane label="空间管理" name="spaces">
|
||||
<rack-space-management
|
||||
:rack="selectedRack"
|
||||
ref="rackSpaceManagement"
|
||||
@refresh="refreshRackSpaces"
|
||||
@space-click="spaceClick"
|
||||
/>
|
||||
<space-card
|
||||
v-if="selectedRack"
|
||||
:spaceId="currentSpaceId"
|
||||
@spaceSave="handleSpaceSave"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
|
||||
<!-- 路径管理 -->
|
||||
<el-tab-pane label="路径规划" name="path">
|
||||
<path-management
|
||||
:selected-warehouse="selectedWarehouse"
|
||||
@path-highlight="handlePathHighlight"
|
||||
@path-show="handlePathShow"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
|
||||
<!-- 位置编辑 -->
|
||||
<el-tab-pane label="位置管理" name="position">
|
||||
<rack-position-editor
|
||||
:selected-rack="selectedRack"
|
||||
:rack-list="areaRackList"
|
||||
@position-update="handlePositionUpdate"
|
||||
@position-preview="handlePositionPreview"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
|
||||
<!-- 区域货架 -->
|
||||
<el-tab-pane label="区域货架" name="areaRacks">
|
||||
<area-racks-list
|
||||
:selected-area="selectedArea"
|
||||
@rack-select="handleAreaRackSelect"
|
||||
@rack-edit="handleAreaRackEdit"
|
||||
@rack-batch-update="handleAreaRackBatchUpdate"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
|
||||
<!-- 中间主内容区 -->
|
||||
@ -91,6 +125,9 @@ import ZoneDialog from './ZoneDialog.vue'
|
||||
import WarehouseDialog from './WarehouseDialog.vue'
|
||||
import zoneInfo from './zoneInfo.vue'
|
||||
import spaceCard from './spaceCard.vue'
|
||||
import PathManagement from './PathManagement.vue'
|
||||
import RackPositionEditor from './RackPositionEditor.vue'
|
||||
import AreaRacksList from './AreaRacksList.vue'
|
||||
import * as warehouseApi from '@/api/warehouse'
|
||||
|
||||
// 仓库数据
|
||||
@ -102,6 +139,11 @@ const zoneData = ref<any>(null)
|
||||
|
||||
// 货架数据
|
||||
const selectedRack = ref<any>(null)
|
||||
const selectedArea = ref<any>(null)
|
||||
const areaRackList = ref<any[]>([])
|
||||
|
||||
// 右侧标签页状态
|
||||
const activeRightTab = ref('spaces')
|
||||
|
||||
// 缩放控制
|
||||
const scale = ref(1)
|
||||
@ -163,11 +205,23 @@ const handleWarehouseSelect = async (warehouse: any) => {
|
||||
}
|
||||
|
||||
// 选择仓库元素
|
||||
const handleZoneSelect = (zone: any) => {
|
||||
const handleZoneSelect = async (zone: any) => {
|
||||
if (zone.type === 'rack') {
|
||||
selectedRack.value = zone
|
||||
selectedArea.value = null
|
||||
} else if (zone.type === 'area') {
|
||||
selectedArea.value = zone
|
||||
selectedRack.value = null
|
||||
// 加载区域货架列表
|
||||
await loadAreaRacks(zone.id)
|
||||
// 更新平面图显示
|
||||
if (zone.type !== 'pick_start') {
|
||||
zoneData.value = zone
|
||||
}
|
||||
} else {
|
||||
selectedRack.value = null // 更新平面图显示
|
||||
selectedRack.value = null
|
||||
selectedArea.value = null
|
||||
// 更新平面图显示
|
||||
if (zone.type !== 'pick_start') {
|
||||
zoneData.value = zone
|
||||
}
|
||||
@ -276,6 +330,88 @@ const handleWarehouseDialogSuccess = async () => {
|
||||
await loadWarehouseList()
|
||||
}
|
||||
|
||||
// 加载区域货架列表
|
||||
const loadAreaRacks = async (areaId: number) => {
|
||||
try {
|
||||
const response: any = await warehouseApi.getAreaRacks(areaId)
|
||||
if (response.code === 200) {
|
||||
areaRackList.value = response.racks || []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载区域货架列表失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 路径高亮处理
|
||||
const handlePathHighlight = (nodeData: any) => {
|
||||
if (warehouseViewer.value) {
|
||||
// 在平面图中高亮节点
|
||||
warehouseViewer.value.highlightNode?.(nodeData)
|
||||
}
|
||||
}
|
||||
|
||||
// 路径显示处理
|
||||
const handlePathShow = (pathData: any[]) => {
|
||||
if (warehouseViewer.value) {
|
||||
// 在平面图中显示路径
|
||||
warehouseViewer.value.showPath?.(pathData)
|
||||
}
|
||||
}
|
||||
|
||||
// 货架位置更新处理
|
||||
const handlePositionUpdate = async (rackId: number, position: any) => {
|
||||
// 更新本地数据
|
||||
if (selectedRack.value?.id === rackId) {
|
||||
Object.assign(selectedRack.value, position)
|
||||
}
|
||||
|
||||
// 刷新仓库数据
|
||||
await refreshCurrentWarehouse()
|
||||
|
||||
// 刷新区域货架列表
|
||||
if (selectedArea.value?.id) {
|
||||
await loadAreaRacks(selectedArea.value.id)
|
||||
}
|
||||
}
|
||||
|
||||
// 货架位置预览处理
|
||||
const handlePositionPreview = (rackId: number, position: any) => {
|
||||
if (warehouseViewer.value) {
|
||||
// 在平面图中预览位置
|
||||
warehouseViewer.value.previewRackPosition?.(rackId, position)
|
||||
}
|
||||
}
|
||||
|
||||
// 区域货架选择处理
|
||||
const handleAreaRackSelect = (rack: any) => {
|
||||
selectedRack.value = rack
|
||||
activeRightTab.value = 'spaces' // 切换到空间管理标签页
|
||||
|
||||
nextTick(() => {
|
||||
if (warehouseViewer.value) {
|
||||
// 在平面图中高亮货架
|
||||
warehouseViewer.value.highlightRack?.(rack)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 区域货架编辑处理
|
||||
const handleAreaRackEdit = (rack: any) => {
|
||||
selectedRack.value = rack
|
||||
activeRightTab.value = 'position' // 切换到位置管理标签页
|
||||
}
|
||||
|
||||
// 区域货架批量更新处理
|
||||
const handleAreaRackBatchUpdate = async (racks: any[]) => {
|
||||
// 刷新仓库数据
|
||||
await refreshCurrentWarehouse()
|
||||
|
||||
// 刷新区域货架列表
|
||||
if (selectedArea.value?.id) {
|
||||
await loadAreaRacks(selectedArea.value.id)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadWarehouseList()
|
||||
})
|
||||
@ -306,6 +442,23 @@ onMounted(() => {
|
||||
&.right-sidebar {
|
||||
flex-shrink: 0;
|
||||
width: 600px;
|
||||
|
||||
.right-tabs {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
:deep(.el-tabs__content) {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
|
||||
.el-tab-pane {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1255
src/需求文档.txt
1255
src/需求文档.txt
File diff suppressed because it is too large
Load Diff
35
日志.md
35
日志.md
@ -206,3 +206,38 @@ stock获取回收站商品接口复用了商品信息接口stock.warehouse.list
|
||||
完善接口、功能设计,排除故障接口,测试接口功能。
|
||||
完善收货单、货主功能。
|
||||
熟悉开源远程电脑项目billd-desk,准备学习开发相关功能应用。
|
||||
|
||||
-----
|
||||
2026.4.4
|
||||
一、今日完成
|
||||
-修复权限管理PDA页面无法添加图标问题。
|
||||
-添加店铺仓库 API 功能和详情组件。
|
||||
-实现了用于管理店铺仓库操作的 API 功能,包括列表、签收、解绑、重命名以及配置奇门。
|
||||
-添加优化“货主”页面及其相关功能。
|
||||
-修复收货单图片不显示问题。
|
||||
-
|
||||
|
||||
二、问题记录
|
||||
无
|
||||
|
||||
三、后续计划
|
||||
完善接口、功能设计,排除故障接口,测试接口功能。
|
||||
完善收货单、货主功能。
|
||||
熟悉开源远程电脑项目billd-desk,准备学习开发相关功能应用。
|
||||
|
||||
-----
|
||||
2026.4.6
|
||||
一、今日完成
|
||||
-优化收货单页面及相关接口功能。
|
||||
-库位管理新增warehouse.getPickPath等接口和功能,优化页面相关框架。
|
||||
- 优化layout页面相关组件样式、功能使用逻辑。
|
||||
- 收货单新增货主绑定、商品关联功能。
|
||||
-优化收货单及其组件页面样式。
|
||||
|
||||
二、问题记录
|
||||
warehouse.update接口is_active未更新。
|
||||
|
||||
三、后续计划
|
||||
完善接口、功能设计,排除故障接口,测试接口功能。
|
||||
完善库位管理以及其他功能。
|
||||
熟悉开源远程电脑项目billd-desk,准备学习开发相关功能应用。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user