review(mes):wm-warehouse 的初步实现 50%

pull/871/MERGE
YunaiV 2026-02-17 22:52:45 +08:00
parent 57894e7ab5
commit 9546589ccc
7 changed files with 324 additions and 95 deletions

View File

@ -127,6 +127,42 @@ const remainingRouter: AppRouteRecordRaw[] = [
}
]
},
{
path: '/mes',
component: Layout,
name: 'MesWmRouter',
meta: {
hidden: true
},
children: [
{
path: 'wm/warehouse/location',
component: () => import('@/views/mes/wm/warehouse/location/index.vue'),
name: 'MesWmLocationRouter',
meta: {
noCache: true,
hidden: true,
canTo: true,
icon: '',
title: '库区设置',
activeMenu: '/mes/wm/warehouse'
}
},
{
path: 'wm/warehouse/area',
component: () => import('@/views/mes/wm/warehouse/area/index.vue'),
name: 'MesWmAreaRouter',
meta: {
noCache: true,
hidden: true,
canTo: true,
icon: '',
title: '库位设置',
activeMenu: '/mes/wm/warehouse'
}
}
]
},
{
path: '/codegen',

View File

@ -9,6 +9,7 @@
>
<el-row>
<el-col :span="8">
<!-- TODO @AI生成参考别的界面 -->
<el-form-item label="仓库编码" prop="code">
<el-input v-model="formData.code" placeholder="请输入仓库编码" />
</el-form-item>
@ -26,7 +27,12 @@
clearable
class="!w-1/1"
>
<el-option v-for="user in userList" :key="user.id" :label="user.nickname" :value="user.id" />
<el-option
v-for="user in userList"
:key="user.id"
:label="user.nickname"
:value="user.id"
/>
</el-select>
</el-form-item>
</el-col>
@ -38,7 +44,7 @@
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="面积" prop="area">
<el-form-item label="面积(㎡)" prop="area">
<el-input-number
v-model="formData.area"
:precision="2"
@ -48,6 +54,7 @@
/>
</el-form-item>
</el-col>
<!-- TODO @AI前后端这个字段都删除包括数据库的 -->
<el-col :span="8">
<el-form-item label="状态" prop="status">
<el-radio-group v-model="formData.status">
@ -78,6 +85,7 @@
</el-row>
</el-form>
<template #footer>
<!-- TODO @AIbarcodeimg -->
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
@ -90,6 +98,8 @@ import { CommonStatusEnum } from '@/utils/constants'
import { WmWarehouseApi, WmWarehouseVO } from '@/api/mes/wm/warehouse'
import * as UserApi from '@/api/system/user'
// TODO @AI仿
defineOptions({ name: 'WarehouseForm' })
const { t } = useI18n()
@ -121,6 +131,7 @@ const formRef = ref()
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
// TODO @AI form
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
@ -140,6 +151,7 @@ defineExpose({ open })
/** 提交表单 */
const emit = defineEmits(['success'])
const submitForm = async () => {
// TODO @AI form
await formRef.value.validate()
formLoading.value = true
try {

View File

@ -43,6 +43,7 @@
</el-form-item>
</el-col>
<el-col :span="8">
<!-- TODO @AI生成参考别的界面 -->
<el-form-item label="库位编码" prop="code">
<el-input v-model="formData.code" placeholder="请输入库位编码" />
</el-form-item>
@ -55,7 +56,7 @@
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="面积" prop="area">
<el-form-item label="面积(㎡)" prop="area">
<el-input-number
v-model="formData.area"
:precision="2"
@ -80,17 +81,32 @@
<el-row>
<el-col :span="8">
<el-form-item label="坐标 X" prop="positionX">
<el-input-number v-model="formData.positionX" :min="0" controls-position="right" class="!w-1/1" />
<el-input-number
v-model="formData.positionX"
:min="0"
controls-position="right"
class="!w-1/1"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="坐标 Y" prop="positionY">
<el-input-number v-model="formData.positionY" :min="0" controls-position="right" class="!w-1/1" />
<el-input-number
v-model="formData.positionY"
:min="0"
controls-position="right"
class="!w-1/1"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="坐标 Z" prop="positionZ">
<el-input-number v-model="formData.positionZ" :min="0" controls-position="right" class="!w-1/1" />
<el-input-number
v-model="formData.positionZ"
:min="0"
controls-position="right"
class="!w-1/1"
/>
</el-form-item>
</el-col>
</el-row>
@ -121,6 +137,7 @@
</el-row>
<el-row>
<el-col :span="8">
<!-- TODO @AI允许产品混放 -->
<el-form-item label="允许物料混放" prop="allowItemMixing">
<el-switch v-model="formData.allowItemMixing" />
</el-form-item>
@ -140,6 +157,7 @@
</el-row>
</el-form>
<template #footer>
<!-- TODO @AIbarcodeimg -->
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
@ -155,9 +173,11 @@ import { WmWarehouseAreaApi, WmWarehouseAreaVO } from '@/api/mes/wm/warehouse/ar
defineOptions({ name: 'AreaForm' })
// TODO @AI仿
const { t } = useI18n()
const message = useMessage()
// TODO @AI仿
const dialogVisible = ref(false)
const dialogTitle = ref('')
const formLoading = ref(false)
@ -194,6 +214,7 @@ const formRules = reactive({
})
const formRef = ref()
/** 加载库区列表 */
const loadLocationList = async (warehouseId?: number) => {
if (!warehouseId) {
locationList.value = []
@ -202,13 +223,20 @@ const loadLocationList = async (warehouseId?: number) => {
locationList.value = await WmWarehouseLocationApi.getWarehouseLocationSimpleList(warehouseId)
}
/** 仓库改变时,重置库区 */
const handleWarehouseChange = async (warehouseId?: number) => {
formData.value.locationId = undefined
await loadLocationList(warehouseId)
}
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
const open = async (
type: string,
id?: number,
defaultLocationId?: number,
defaultWarehouseId?: number
) => {
// TODO @AI form
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
@ -240,6 +268,20 @@ const open = async (type: string, id?: number) => {
} finally {
formLoading.value = false
}
return
}
if (defaultWarehouseId) {
selectedWarehouseId.value = defaultWarehouseId
await loadLocationList(defaultWarehouseId)
}
if (defaultLocationId) {
if (!selectedWarehouseId.value) {
const location = await WmWarehouseLocationApi.getWarehouseLocation(defaultLocationId)
selectedWarehouseId.value = location.warehouseId
await loadLocationList(selectedWarehouseId.value)
}
// TODO @linter
formData.value.locationId = defaultLocationId
}
}
defineExpose({ open })

View File

@ -1,32 +1,21 @@
<template>
<ContentWrap>
<el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px">
<el-form-item label="所属仓库">
<el-select
v-model="queryWarehouseId"
placeholder="请选择仓库"
clearable
class="!w-240px"
@change="handleWarehouseChange"
>
<el-option
v-for="warehouse in warehouseList"
:key="warehouse.id"
:label="warehouse.name"
:value="warehouse.id"
/>
</el-select>
</el-form-item>
<el-form-item label="所属库区" prop="locationId">
<el-select v-model="queryParams.locationId" placeholder="请选择库区" clearable class="!w-240px" :disabled="!queryWarehouseId">
<el-option
v-for="location in locationList"
:key="location.id"
:label="location.name"
:value="location.id"
/>
</el-select>
</el-form-item>
<el-alert
v-if="currentLocationId"
:title="`当前仓库/库区:${currentWarehouseName || `#${currentWarehouseId || '-'}`} / ${currentLocationName || `#${currentLocationId}`}`"
type="info"
show-icon
:closable="false"
class="!mb-12px"
/>
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<!-- TODO @AI只保留库位编码名称其它状态冻结都删除 -->
<el-form-item label="库位编码" prop="code">
<el-input
v-model="queryParams.code"
@ -61,10 +50,19 @@
<el-option :value="false" label="否" />
</el-select>
</el-form-item>
<!-- TODO @AI额外增加库位位置 X库位位置 Y库位位置 Z -->
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button type="primary" plain @click="openForm('create')" v-hasPermi="['mes:wm-warehouse-area:create']">
<el-button @click="goBackToLocation"
><Icon icon="ep:back" class="mr-5px" /> 返回库区</el-button
>
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['mes:wm-warehouse:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
@ -72,7 +70,7 @@
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['mes:wm-warehouse-area:export']"
v-hasPermi="['mes:wm-warehouse:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
@ -82,17 +80,20 @@
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="所属仓库" align="center" prop="warehouseName" min-width="130" />
<el-table-column label="所属库区" align="center" prop="locationName" min-width="130" />
<el-table-column label="库位编码" align="center" prop="code" min-width="120" />
<el-table-column label="库位名称" align="center" prop="name" min-width="140" />
<el-table-column label="面积" align="center" prop="area" min-width="90" />
<el-table-column label="面积(㎡)" align="center" prop="area" min-width="90" />
<el-table-column label="最大载重" align="center" prop="maxLoad" min-width="100" />
<!-- TODO @AI库位位置 XYZ -->
<!-- TODO @AI使用字典渲染 -->
<el-table-column label="启用" align="center" prop="enabled" min-width="70">
<template #default="scope">
<el-tag :type="scope.row.enabled ? 'success' : 'info'">{{ scope.row.enabled ? '是' : '否' }}</el-tag>
<el-tag :type="scope.row.enabled ? 'success' : 'info'">{{
scope.row.enabled ? '是' : '否'
}}</el-tag>
</template>
</el-table-column>
<!-- TODO @AI删除状态字段前端+后端数据库 -->
<el-table-column label="状态" align="center" prop="status" min-width="90">
<template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
@ -100,9 +101,12 @@
</el-table-column>
<el-table-column label="冻结" align="center" prop="frozen" min-width="80">
<template #default="scope">
<el-tag :type="scope.row.frozen ? 'danger' : 'success'">{{ scope.row.frozen ? '是' : '否' }}</el-tag>
<el-tag :type="scope.row.frozen ? 'danger' : 'success'">{{
scope.row.frozen ? '是' : '否'
}}</el-tag>
</template>
</el-table-column>
<!-- TODO @AI增加备注 -->
<el-table-column
label="创建时间"
align="center"
@ -116,7 +120,7 @@
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['mes:wm-warehouse-area:update']"
v-hasPermi="['mes:wm-warehouse:update']"
>
编辑
</el-button>
@ -124,7 +128,7 @@
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['mes:wm-warehouse-area:delete']"
v-hasPermi="['mes:wm-warehouse:delete']"
>
删除
</el-button>
@ -146,8 +150,7 @@
import { dateFormatter } from '@/utils/formatTime'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import download from '@/utils/download'
import { WmWarehouseApi, WmWarehouseVO } from '@/api/mes/wm/warehouse'
import { WmWarehouseLocationApi, WmWarehouseLocationVO } from '@/api/mes/wm/warehouse/location'
import { WmWarehouseLocationApi } from '@/api/mes/wm/warehouse/location'
import { WmWarehouseAreaApi, WmWarehouseAreaVO } from '@/api/mes/wm/warehouse/area'
import AreaForm from './AreaForm.vue'
@ -155,13 +158,16 @@ defineOptions({ name: 'MesWmArea' })
const message = useMessage()
const { t } = useI18n()
const router = useRouter()
const route = useRoute()
const loading = ref(true)
const list = ref<WmWarehouseAreaVO[]>([])
const total = ref(0)
const warehouseList = ref<WmWarehouseVO[]>([])
const locationList = ref<WmWarehouseLocationVO[]>([])
const queryWarehouseId = ref<number | undefined>(undefined)
const currentWarehouseId = ref<number | undefined>(undefined)
const currentWarehouseName = ref('')
const currentLocationId = ref<number | undefined>(undefined)
const currentLocationName = ref('')
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
@ -174,17 +180,30 @@ const queryParams = reactive({
const queryFormRef = ref()
const exportLoading = ref(false)
const loadLocationList = async (warehouseId?: number) => {
if (!warehouseId) {
locationList.value = []
return
const parseQueryId = (queryValue: string | string[] | null | undefined): number | undefined => {
const value = Array.isArray(queryValue) ? queryValue[0] : queryValue
if (!value) {
return undefined
}
locationList.value = await WmWarehouseLocationApi.getWarehouseLocationSimpleList(warehouseId)
const id = Number(value)
return Number.isInteger(id) && id > 0 ? id : undefined
}
const handleWarehouseChange = async (warehouseId?: number) => {
queryParams.locationId = undefined
await loadLocationList(warehouseId)
const loadLocationContext = async () => {
const locationId = parseQueryId(route.query.locationId as string | string[] | undefined)
if (!locationId) {
return
}
currentLocationId.value = locationId
queryParams.locationId = locationId
try {
const location = await WmWarehouseLocationApi.getWarehouseLocation(locationId)
currentLocationName.value = location.name
currentWarehouseId.value = location.warehouseId
currentWarehouseName.value = location.warehouseName
} catch {
//
}
}
/** 查询列表 */
@ -207,16 +226,27 @@ const handleQuery = () => {
/** 重置按钮操作 */
const resetQuery = () => {
queryWarehouseId.value = undefined
locationList.value = []
queryFormRef.value.resetFields()
queryParams.locationId = currentLocationId.value
handleQuery()
}
/** 返回库区页面 */
const goBackToLocation = () => {
if (currentWarehouseId.value) {
router.push({
path: '/mes/wm/warehouse/location',
query: { warehouseId: String(currentWarehouseId.value) }
})
return
}
router.push('/mes/wm/warehouse/location')
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
formRef.value.open(type, id, currentLocationId.value, currentWarehouseId.value)
}
/** 删除按钮操作 */
@ -243,7 +273,7 @@ const handleExport = async () => {
}
onMounted(async () => {
await loadLocationContext()
await getList()
warehouseList.value = await WmWarehouseApi.getWarehouseSimpleList()
})
</script>

View File

@ -1,6 +1,12 @@
<template>
<ContentWrap>
<el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px">
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="仓库编码" prop="code">
<el-input
v-model="queryParams.code"
@ -19,6 +25,7 @@
class="!w-240px"
/>
</el-form-item>
<!-- TODO @AI可以起到这个筛选前端 + 后端 -->
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable class="!w-240px">
<el-option
@ -29,6 +36,7 @@
/>
</el-select>
</el-form-item>
<!-- TODO @AI可以起到这个筛选前端 + 后端 -->
<el-form-item label="是否冻结" prop="frozen">
<el-select v-model="queryParams.frozen" placeholder="请选择" clearable class="!w-240px">
<el-option :value="true" label="是" />
@ -38,7 +46,12 @@
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button type="primary" plain @click="openForm('create')" v-hasPermi="['mes:wm-warehouse:create']">
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['mes:wm-warehouse:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
@ -59,17 +72,17 @@
<el-table-column label="仓库编码" align="center" prop="code" min-width="120" />
<el-table-column label="仓库名称" align="center" prop="name" min-width="140" />
<el-table-column label="仓库地址" align="center" prop="address" min-width="150" />
<el-table-column label="面积" align="center" prop="area" min-width="100" />
<el-table-column label="状态" align="center" prop="status" min-width="90">
<template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="面积(㎡)" align="center" prop="area" min-width="100" />
<!-- TODO @AI负责人 -->
<!-- TODO @AI可以使用字典翻译是否 -->
<el-table-column label="冻结" align="center" prop="frozen" min-width="80">
<template #default="scope">
<el-tag :type="scope.row.frozen ? 'danger' : 'success'">{{ scope.row.frozen ? '是' : '否' }}</el-tag>
<el-tag :type="scope.row.frozen ? 'danger' : 'success'">{{
scope.row.frozen ? '是' : '否'
}}</el-tag>
</template>
</el-table-column>
<!-- TODO @AI备注的展示 -->
<el-table-column
label="创建时间"
align="center"
@ -77,8 +90,17 @@
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="操作" align="center" width="150">
<el-table-column label="操作" align="center" width="220">
<template #default="scope">
<el-button
link
type="primary"
@click="openLocation(scope.row.id)"
v-hasPermi="['mes:wm-warehouse:query']"
>
库区
</el-button>
<!-- TODO @芋艿标签打印 -->
<el-button
link
type="primary"
@ -120,6 +142,7 @@ defineOptions({ name: 'MesWmWarehouse' })
const message = useMessage()
const { t } = useI18n()
const router = useRouter()
const loading = ref(true)
const list = ref<WmWarehouseVO[]>([])
@ -165,6 +188,14 @@ const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 打开库区页面 */
const openLocation = (warehouseId: number) => {
router.push({
path: '/mes/wm/warehouse/location',
query: { warehouseId: String(warehouseId) }
})
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {

View File

@ -9,6 +9,7 @@
>
<el-row>
<el-col :span="8">
<!-- TODO @AI生成参考别的界面 -->
<el-form-item label="库区编码" prop="code">
<el-input v-model="formData.code" placeholder="请输入库区编码" />
</el-form-item>
@ -78,6 +79,7 @@
</el-row>
</el-form>
<template #footer>
<!-- TODO @AIbarcodeimg -->
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
@ -92,6 +94,7 @@ import { WmWarehouseLocationApi, WmWarehouseLocationVO } from '@/api/mes/wm/ware
defineOptions({ name: 'LocationForm' })
// TODO @AI仿
const { t } = useI18n()
const message = useMessage()
@ -122,7 +125,8 @@ const formRules = reactive({
const formRef = ref()
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
const open = async (type: string, id?: number, defaultWarehouseId?: number) => {
// TODO @AI form
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
@ -135,6 +139,11 @@ const open = async (type: string, id?: number) => {
} finally {
formLoading.value = false
}
return
}
// TODO @linter
if (defaultWarehouseId) {
formData.value.warehouseId = defaultWarehouseId
}
}
defineExpose({ open })
@ -142,6 +151,7 @@ defineExpose({ open })
/** 提交表单 */
const emit = defineEmits(['success'])
const submitForm = async () => {
// TODO @AI form
await formRef.value.validate()
formLoading.value = true
try {

View File

@ -1,6 +1,21 @@
<template>
<ContentWrap>
<el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px">
<el-alert
v-if="currentWarehouseId"
:title="`当前仓库:${currentWarehouseName || `#${currentWarehouseId}`}`"
type="info"
show-icon
:closable="false"
class="!mb-12px"
/>
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<!-- TODO @AI只保留区域编码名称其它状态冻结都删除 -->
<el-form-item label="库区编码" prop="code">
<el-input
v-model="queryParams.code"
@ -19,16 +34,6 @@
class="!w-240px"
/>
</el-form-item>
<el-form-item label="所属仓库" prop="warehouseId">
<el-select v-model="queryParams.warehouseId" placeholder="请选择仓库" clearable class="!w-240px">
<el-option
v-for="warehouse in warehouseList"
:key="warehouse.id"
:label="warehouse.name"
:value="warehouse.id"
/>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable class="!w-240px">
<el-option
@ -48,11 +53,14 @@
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button @click="goBackToWarehouse"
><Icon icon="ep:back" class="mr-5px" /> 返回仓库</el-button
>
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['mes:wm-warehouse-location:create']"
v-hasPermi="['mes:wm-warehouse:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
@ -61,7 +69,7 @@
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['mes:wm-warehouse-location:export']"
v-hasPermi="['mes:wm-warehouse:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
@ -71,25 +79,32 @@
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="所属仓库" align="center" prop="warehouseName" min-width="130" />
<el-table-column label="库区编码" align="center" prop="code" min-width="120" />
<el-table-column label="库区名称" align="center" prop="name" min-width="140" />
<el-table-column label="面积" align="center" prop="area" min-width="100" />
<el-table-column label="面积(㎡)" align="center" prop="area" min-width="100" />
<!-- TODO @AI去掉库位管理状态字段 -->
<el-table-column label="库位管理" align="center" prop="areaEnabled" min-width="90">
<template #default="scope">
<el-tag :type="scope.row.areaEnabled ? 'success' : 'info'">{{ scope.row.areaEnabled ? '启用' : '关闭' }}</el-tag>
<el-tag :type="scope.row.areaEnabled ? 'success' : 'info'">{{
scope.row.areaEnabled ? '启用' : '关闭'
}}</el-tag>
</template>
</el-table-column>
<!-- TODO @AI删除状态字段前端+后端数据库 -->
<el-table-column label="状态" align="center" prop="status" min-width="90">
<template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
</template>
</el-table-column>
<!-- TODO @AI使用字典渲染 -->
<el-table-column label="冻结" align="center" prop="frozen" min-width="80">
<template #default="scope">
<el-tag :type="scope.row.frozen ? 'danger' : 'success'">{{ scope.row.frozen ? '是' : '否' }}</el-tag>
<el-tag :type="scope.row.frozen ? 'danger' : 'success'">{{
scope.row.frozen ? '是' : '否'
}}</el-tag>
</template>
</el-table-column>
<!-- TODO @AI增加备注 -->
<el-table-column
label="创建时间"
align="center"
@ -97,13 +112,22 @@
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="操作" align="center" width="150">
<el-table-column label="操作" align="center" width="220">
<template #default="scope">
<el-button
link
type="primary"
@click="openArea(scope.row.id)"
v-hasPermi="['mes:wm-warehouse:query']"
>
库位
</el-button>
<!-- TODO @芋艿标签打印 -->
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['mes:wm-warehouse-location:update']"
v-hasPermi="['mes:wm-warehouse:update']"
>
编辑
</el-button>
@ -111,7 +135,7 @@
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['mes:wm-warehouse-location:delete']"
v-hasPermi="['mes:wm-warehouse:delete']"
>
删除
</el-button>
@ -133,7 +157,7 @@
import { dateFormatter } from '@/utils/formatTime'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import download from '@/utils/download'
import { WmWarehouseApi, WmWarehouseVO } from '@/api/mes/wm/warehouse'
import { WmWarehouseApi } from '@/api/mes/wm/warehouse'
import { WmWarehouseLocationApi, WmWarehouseLocationVO } from '@/api/mes/wm/warehouse/location'
import LocationForm from './LocationForm.vue'
@ -141,11 +165,15 @@ defineOptions({ name: 'MesWmLocation' })
const message = useMessage()
const { t } = useI18n()
const router = useRouter()
const route = useRoute()
const loading = ref(true)
const list = ref<WmWarehouseLocationVO[]>([])
const total = ref(0)
const warehouseList = ref<WmWarehouseVO[]>([])
const currentWarehouseId = ref<number | undefined>(undefined)
// TODO @AI currentWarehouse
const currentWarehouseName = ref('')
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
@ -158,6 +186,32 @@ const queryParams = reactive({
const queryFormRef = ref()
const exportLoading = ref(false)
// TODO @AI number
const parseQueryId = (queryValue: string | string[] | null | undefined): number | undefined => {
const value = Array.isArray(queryValue) ? queryValue[0] : queryValue
if (!value) {
return undefined
}
const id = Number(value)
return Number.isInteger(id) && id > 0 ? id : undefined
}
// TODO @AI
const loadWarehouseContext = async () => {
const warehouseId = parseQueryId(route.query.warehouseId as string | string[] | undefined)
if (!warehouseId) {
return
}
currentWarehouseId.value = warehouseId
queryParams.warehouseId = warehouseId
try {
const warehouse = await WmWarehouseApi.getWarehouse(warehouseId)
currentWarehouseName.value = warehouse.name
} catch {
//
}
}
/** 查询列表 */
const getList = async () => {
loading.value = true
@ -179,13 +233,27 @@ const handleQuery = () => {
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
queryParams.warehouseId = currentWarehouseId.value
handleQuery()
}
/** 返回仓库页面 */
const goBackToWarehouse = () => {
router.push('/mes/wm/warehouse')
}
/** 打开库位页面 */
const openArea = (locationId: number) => {
router.push({
path: '/mes/wm/warehouse/area',
query: { locationId: String(locationId) }
})
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
formRef.value.open(type, id, currentWarehouseId.value)
}
/** 删除按钮操作 */
@ -212,7 +280,7 @@ const handleExport = async () => {
}
onMounted(async () => {
await loadWarehouseContext()
await getList()
warehouseList.value = await WmWarehouseApi.getWarehouseSimpleList()
})
</script>