feat(wms):增加 warehouse 功能
parent
9d8d0647be
commit
c3737d3b7a
|
|
@ -0,0 +1,45 @@
|
|||
import request from '@/config/axios'
|
||||
|
||||
// WMS 库区 VO
|
||||
export interface WarehouseAreaVO {
|
||||
id?: number
|
||||
code?: string
|
||||
name?: string
|
||||
warehouseId?: number
|
||||
warehouseName?: string
|
||||
remark?: string
|
||||
createTime?: Date
|
||||
}
|
||||
|
||||
// WMS 库区 API
|
||||
export const WarehouseAreaApi = {
|
||||
// 查询库区分页
|
||||
getWarehouseAreaPage: async (params: any) => {
|
||||
return await request.get({ url: '/wms/warehouse-area/page', params })
|
||||
},
|
||||
|
||||
// 查询库区精简列表
|
||||
getWarehouseAreaSimpleList: async (warehouseId?: number) => {
|
||||
return await request.get({ url: '/wms/warehouse-area/simple-list', params: { warehouseId } })
|
||||
},
|
||||
|
||||
// 查询库区详情
|
||||
getWarehouseArea: async (id: number) => {
|
||||
return await request.get({ url: '/wms/warehouse-area/get?id=' + id })
|
||||
},
|
||||
|
||||
// 新增库区
|
||||
createWarehouseArea: async (data: WarehouseAreaVO) => {
|
||||
return await request.post({ url: '/wms/warehouse-area/create', data })
|
||||
},
|
||||
|
||||
// 修改库区
|
||||
updateWarehouseArea: async (data: WarehouseAreaVO) => {
|
||||
return await request.put({ url: '/wms/warehouse-area/update', data })
|
||||
},
|
||||
|
||||
// 删除库区
|
||||
deleteWarehouseArea: async (id: number) => {
|
||||
return await request.delete({ url: '/wms/warehouse-area/delete?id=' + id })
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
import request from '@/config/axios'
|
||||
|
||||
// WMS 仓库 VO
|
||||
export interface WarehouseVO {
|
||||
id?: number
|
||||
code?: string
|
||||
name?: string
|
||||
remark?: string
|
||||
sort?: number
|
||||
createTime?: Date
|
||||
}
|
||||
|
||||
// WMS 仓库 API
|
||||
export const WarehouseApi = {
|
||||
// 查询仓库分页
|
||||
getWarehousePage: async (params: any) => {
|
||||
return await request.get({ url: '/wms/warehouse/page', params })
|
||||
},
|
||||
|
||||
// 查询仓库精简列表
|
||||
getWarehouseSimpleList: async () => {
|
||||
return await request.get({ url: '/wms/warehouse/simple-list' })
|
||||
},
|
||||
|
||||
// 查询仓库详情
|
||||
getWarehouse: async (id: number) => {
|
||||
return await request.get({ url: '/wms/warehouse/get?id=' + id })
|
||||
},
|
||||
|
||||
// 新增仓库
|
||||
createWarehouse: async (data: WarehouseVO) => {
|
||||
return await request.post({ url: '/wms/warehouse/create', data })
|
||||
},
|
||||
|
||||
// 修改仓库
|
||||
updateWarehouse: async (data: WarehouseVO) => {
|
||||
return await request.put({ url: '/wms/warehouse/update', data })
|
||||
},
|
||||
|
||||
// 删除仓库
|
||||
deleteWarehouse: async (id: number) => {
|
||||
return await request.delete({ url: '/wms/warehouse/delete?id=' + id })
|
||||
}
|
||||
}
|
||||
|
|
@ -127,6 +127,29 @@ const remainingRouter: AppRouteRecordRaw[] = [
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/wms',
|
||||
component: Layout,
|
||||
name: 'Wms',
|
||||
meta: {
|
||||
hidden: true
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'warehouse/area/:warehouseId',
|
||||
component: () => import('@/views/wms/warehouse/area/index.vue'),
|
||||
name: 'WmsWarehouseArea',
|
||||
meta: {
|
||||
title: '库区管理',
|
||||
noCache: true,
|
||||
hidden: true,
|
||||
canTo: true,
|
||||
icon: '',
|
||||
activeMenu: '/wms/basic/warehouse'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/codegen',
|
||||
component: Layout,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* WMS 前端运行参数
|
||||
*
|
||||
* 标注「后端镜像」的常量与 yudao.wms.* 配置默认值一致;调整后端配置时需同步修改这里
|
||||
*/
|
||||
|
||||
// ==================== 后端镜像(与 WmsProperties 默认值对齐) ====================
|
||||
|
||||
/** 是否启用库区模式(对齐 yudao.wms.area-enable) */
|
||||
export const AREA_ENABLE = true
|
||||
|
||||
/**
|
||||
* 是否启用批次/效期/库存明细模式(对齐 yudao.wms.batch-enable)
|
||||
*
|
||||
* 依赖 AREA_ENABLE = true
|
||||
*/
|
||||
export const BATCH_ENABLE = true
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
<!-- WMS 仓库表单 -->
|
||||
<template>
|
||||
<Dialog v-model="dialogVisible" :title="dialogTitle">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
v-loading="formLoading"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-form-item label="仓库名称" prop="name">
|
||||
<el-input v-model="formData.name" maxlength="50" placeholder="请输入仓库名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="仓库编号" prop="code">
|
||||
<el-input v-model="formData.code" maxlength="20" placeholder="请输入仓库编号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input-number v-model="formData.sort" :min="0" class="!w-1/1" controls-position="right" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input
|
||||
v-model="formData.remark"
|
||||
maxlength="255"
|
||||
placeholder="请输入备注"
|
||||
type="textarea"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { WarehouseApi, WarehouseVO } from '@/api/wms/warehouse'
|
||||
|
||||
/** WMS 仓库表单 */
|
||||
defineOptions({ name: 'WmsWarehouseForm' })
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const formData = ref<WarehouseVO>({
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
sort: 0,
|
||||
remark: undefined
|
||||
})
|
||||
const formRules = reactive({
|
||||
code: [{ required: true, message: '仓库编号不能为空', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '仓库名称不能为空', trigger: 'blur' }],
|
||||
sort: [{ required: true, message: '排序不能为空', trigger: 'blur' }]
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await WarehouseApi.getWarehouse(id)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as WarehouseVO
|
||||
if (formType.value === 'create') {
|
||||
await WarehouseApi.createWarehouse(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await WarehouseApi.updateWarehouse(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
sort: 0,
|
||||
remark: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
<!-- WMS 库区表单 -->
|
||||
<template>
|
||||
<Dialog v-model="dialogVisible" :title="dialogTitle">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
v-loading="formLoading"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-form-item label="所属仓库" prop="warehouseId">
|
||||
<el-select v-model="formData.warehouseId" class="!w-1/1" placeholder="请选择所属仓库">
|
||||
<el-option
|
||||
v-for="warehouse in selectableWarehouseList"
|
||||
:key="warehouse.id"
|
||||
:label="warehouse.name"
|
||||
:value="warehouse.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="库区名称" prop="name">
|
||||
<el-input v-model="formData.name" maxlength="60" placeholder="请输入库区名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="库区编号" prop="code">
|
||||
<el-input v-model="formData.code" maxlength="20" placeholder="请输入库区编号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input
|
||||
v-model="formData.remark"
|
||||
maxlength="255"
|
||||
placeholder="请输入备注"
|
||||
type="textarea"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { WarehouseApi, WarehouseVO } from '@/api/wms/warehouse'
|
||||
import { WarehouseAreaApi, WarehouseAreaVO } from '@/api/wms/warehouse/area'
|
||||
|
||||
/** WMS 库区表单 */
|
||||
defineOptions({ name: 'WmsWarehouseAreaForm' })
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const warehouseList = ref<WarehouseVO[]>([]) // 仓库精简列表
|
||||
const selectableWarehouseList = computed(() =>
|
||||
warehouseList.value.filter((warehouse): warehouse is WarehouseVO & { id: number } => !!warehouse.id)
|
||||
)
|
||||
const formData = ref<WarehouseAreaVO>({
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
warehouseId: undefined,
|
||||
remark: undefined
|
||||
})
|
||||
const formRules = reactive({
|
||||
warehouseId: [{ required: true, message: '所属仓库不能为空', trigger: 'change' }],
|
||||
code: [{ required: true, message: '库区编号不能为空', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '库区名称不能为空', trigger: 'blur' }]
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number, warehouseId?: number) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
await getWarehouseList()
|
||||
if (warehouseId) {
|
||||
formData.value.warehouseId = warehouseId
|
||||
}
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await WarehouseAreaApi.getWarehouseArea(id)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 查询仓库精简列表 */
|
||||
const getWarehouseList = async () => {
|
||||
warehouseList.value = await WarehouseApi.getWarehouseSimpleList()
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as WarehouseAreaVO
|
||||
if (formType.value === 'create') {
|
||||
await WarehouseAreaApi.createWarehouseArea(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await WarehouseAreaApi.updateWarehouseArea(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
warehouseId: undefined,
|
||||
remark: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
||||
|
|
@ -0,0 +1,211 @@
|
|||
<!-- WMS 库区管理 -->
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
:model="queryParams"
|
||||
class="-mb-15px"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="所属仓库" prop="warehouseId">
|
||||
<el-select
|
||||
v-model="queryParams.warehouseId"
|
||||
class="!w-240px"
|
||||
placeholder="请选择所属仓库"
|
||||
@change="warehouseChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="warehouse in selectableWarehouseList"
|
||||
:key="warehouse.id"
|
||||
:label="warehouse.name"
|
||||
:value="warehouse.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="库区名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
class="!w-240px"
|
||||
clearable
|
||||
placeholder="请输入库区名称"
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="库区编号" prop="code">
|
||||
<el-input
|
||||
v-model="queryParams.code"
|
||||
class="!w-240px"
|
||||
clearable
|
||||
placeholder="请输入库区编号"
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery">
|
||||
<Icon class="mr-5px" icon="ep:search" />
|
||||
搜索
|
||||
</el-button>
|
||||
<el-button @click="resetQuery">
|
||||
<Icon class="mr-5px" icon="ep:refresh" />
|
||||
重置
|
||||
</el-button>
|
||||
<el-button
|
||||
v-hasPermi="['wms:warehouse-area:create']"
|
||||
plain
|
||||
type="primary"
|
||||
@click="openForm('create')"
|
||||
>
|
||||
<Icon class="mr-5px" icon="ep:plus" />
|
||||
新增
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
|
||||
<el-table-column align="center" label="库区名称" prop="name" />
|
||||
<el-table-column align="center" label="库区编号" prop="code" />
|
||||
<el-table-column align="center" label="所属仓库" prop="warehouseName">
|
||||
<template #default="scope">
|
||||
{{ scope.row.warehouseName || getWarehouseName(scope.row.warehouseId) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="备注" prop="remark" />
|
||||
<el-table-column
|
||||
:formatter="dateFormatter"
|
||||
align="center"
|
||||
label="创建时间"
|
||||
prop="createTime"
|
||||
width="180"
|
||||
/>
|
||||
<el-table-column align="center" label="操作" width="150">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
v-hasPermi="['wms:warehouse-area:update']"
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
>
|
||||
修改
|
||||
</el-button>
|
||||
<el-button
|
||||
v-hasPermi="['wms:warehouse-area:delete']"
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
v-model:limit="queryParams.pageSize"
|
||||
v-model:page="queryParams.pageNo"
|
||||
:total="total"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<WarehouseAreaForm ref="formRef" @success="getList" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import { WarehouseApi, WarehouseVO } from '@/api/wms/warehouse'
|
||||
import { WarehouseAreaApi, WarehouseAreaVO } from '@/api/wms/warehouse/area'
|
||||
import WarehouseAreaForm from './WarehouseAreaForm.vue'
|
||||
|
||||
/** WMS 库区管理 */
|
||||
defineOptions({ name: 'WmsWarehouseArea' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
const route = useRoute() // 路由
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<WarehouseAreaVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
warehouseId: Number(route.params.warehouseId) || undefined,
|
||||
code: undefined,
|
||||
name: undefined
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const warehouseList = ref<WarehouseVO[]>([]) // 仓库精简列表
|
||||
const selectableWarehouseList = computed(() =>
|
||||
warehouseList.value.filter((warehouse): warehouse is WarehouseVO & { id: number } => !!warehouse.id)
|
||||
)
|
||||
|
||||
/** 查询库区列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await WarehouseAreaApi.getWarehouseAreaPage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询仓库精简列表 */
|
||||
const getWarehouseList = async () => {
|
||||
warehouseList.value = await WarehouseApi.getWarehouseSimpleList()
|
||||
}
|
||||
|
||||
/** 获得仓库名称 */
|
||||
const getWarehouseName = (warehouseId?: number) => {
|
||||
return warehouseList.value.find((warehouse) => warehouse.id === warehouseId)?.name
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 所属仓库更改同时更新列表数据 */
|
||||
const warehouseChange = () => {
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id, queryParams.warehouseId)
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
// 删除的二次确认
|
||||
await message.delConfirm()
|
||||
// 发起删除
|
||||
await WarehouseAreaApi.deleteWarehouseArea(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
await getWarehouseList()
|
||||
await getList()
|
||||
})
|
||||
</script>
|
||||
|
|
@ -0,0 +1,181 @@
|
|||
<!-- WMS 仓库管理 -->
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
:model="queryParams"
|
||||
class="-mb-15px"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="仓库名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
class="!w-240px"
|
||||
clearable
|
||||
placeholder="请输入仓库名称"
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="仓库编号" prop="code">
|
||||
<el-input
|
||||
v-model="queryParams.code"
|
||||
class="!w-240px"
|
||||
clearable
|
||||
placeholder="请输入仓库编号"
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery">
|
||||
<Icon class="mr-5px" icon="ep:search" />
|
||||
搜索
|
||||
</el-button>
|
||||
<el-button @click="resetQuery">
|
||||
<Icon class="mr-5px" icon="ep:refresh" />
|
||||
重置
|
||||
</el-button>
|
||||
<el-button
|
||||
v-hasPermi="['wms:warehouse:create']"
|
||||
plain
|
||||
type="primary"
|
||||
@click="openWarehouseForm('create')"
|
||||
>
|
||||
<Icon class="mr-5px" icon="ep:plus" />
|
||||
新增
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 仓库列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
|
||||
<el-table-column align="center" label="仓库名称" prop="name" />
|
||||
<el-table-column align="center" label="仓库编号" prop="code" />
|
||||
<el-table-column align="center" label="备注" prop="remark" />
|
||||
<el-table-column align="center" label="排序" prop="sort" width="100" />
|
||||
<el-table-column
|
||||
:formatter="dateFormatter"
|
||||
align="center"
|
||||
label="创建时间"
|
||||
prop="createTime"
|
||||
width="180"
|
||||
/>
|
||||
<el-table-column align="center" label="操作" width="210">
|
||||
<template #default="scope">
|
||||
<router-link
|
||||
v-if="AREA_ENABLE"
|
||||
:to="{ name: 'WmsWarehouseArea', params: { warehouseId: scope.row.id } }"
|
||||
>
|
||||
<el-button v-hasPermi="['wms:warehouse-area:query']" link type="primary">库区</el-button>
|
||||
</router-link>
|
||||
<el-button
|
||||
v-hasPermi="['wms:warehouse:update']"
|
||||
link
|
||||
type="primary"
|
||||
@click="openWarehouseForm('update', scope.row.id)"
|
||||
>
|
||||
修改
|
||||
</el-button>
|
||||
<el-button
|
||||
v-hasPermi="['wms:warehouse:delete']"
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
v-model:limit="queryParams.pageSize"
|
||||
v-model:page="queryParams.pageNo"
|
||||
:total="total"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<WarehouseForm ref="formRef" @success="handleWarehouseSuccess" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import { WarehouseApi, WarehouseVO } from '@/api/wms/warehouse'
|
||||
import { AREA_ENABLE } from '@/views/wms/utils/config'
|
||||
import WarehouseForm from './WarehouseForm.vue'
|
||||
|
||||
/** WMS 仓库管理 */
|
||||
defineOptions({ name: 'WmsWarehouse' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<WarehouseVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
code: undefined,
|
||||
name: undefined
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
|
||||
/** 查询仓库列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await WarehouseApi.getWarehousePage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const openWarehouseForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id)
|
||||
}
|
||||
|
||||
/** 仓库保存成功 */
|
||||
const handleWarehouseSuccess = async () => {
|
||||
await getList()
|
||||
}
|
||||
|
||||
/** 删除仓库 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
// 删除的二次确认
|
||||
await message.delConfirm()
|
||||
// 发起删除
|
||||
await WarehouseApi.deleteWarehouse(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await handleWarehouseSuccess()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
Loading…
Reference in New Issue