ERP:完成 product 信息、分类、单位的实现

This commit is contained in:
YunaiV 2024-02-05 00:15:40 +08:00
parent ce9317e3d0
commit 36a0330277
8 changed files with 212 additions and 115 deletions

View File

@ -18,32 +18,37 @@ export interface ProductCategoryVO {
// ERP 商品分类 API // ERP 商品分类 API
export const ProductCategoryApi = { export const ProductCategoryApi = {
// 查询ERP 商品分类列表 // 查询商品分类列表
getProductCategoryList: async (params) => { getProductCategoryList: async (params) => {
return await request.get({ url: `/erp/product-category/list`, params }) return await request.get({ url: `/erp/product-category/list`, params })
}, },
// 查询ERP 商品分类详情 // 查询商品分类精简列表
getProductCategorySimpleList: async () => {
return await request.get({ url: `/erp/product-category/simple-list` })
},
// 查询商品分类详情
getProductCategory: async (id: number) => { getProductCategory: async (id: number) => {
return await request.get({ url: `/erp/product-category/get?id=` + id }) return await request.get({ url: `/erp/product-category/get?id=` + id })
}, },
// 新增ERP 商品分类 // 新增商品分类
createProductCategory: async (data: ProductCategoryVO) => { createProductCategory: async (data: ProductCategoryVO) => {
return await request.post({ url: `/erp/product-category/create`, data }) return await request.post({ url: `/erp/product-category/create`, data })
}, },
// 修改ERP 商品分类 // 修改商品分类
updateProductCategory: async (data: ProductCategoryVO) => { updateProductCategory: async (data: ProductCategoryVO) => {
return await request.put({ url: `/erp/product-category/update`, data }) return await request.put({ url: `/erp/product-category/update`, data })
}, },
// 删除ERP 商品分类 // 删除商品分类
deleteProductCategory: async (id: number) => { deleteProductCategory: async (id: number) => {
return await request.delete({ url: `/erp/product-category/delete?id=` + id }) return await request.delete({ url: `/erp/product-category/delete?id=` + id })
}, },
// 导出ERP 商品分类 Excel // 导出商品分类 Excel
exportProductCategory: async (params) => { exportProductCategory: async (params) => {
return await request.download({ url: `/erp/product-category/export-excel`, params }) return await request.download({ url: `/erp/product-category/export-excel`, params })
} }

View File

@ -32,32 +32,32 @@ export interface ProductVO {
// ERP 产品 API // ERP 产品 API
export const ProductApi = { export const ProductApi = {
// 查询ERP 产品分页 // 查询产品分页
getProductPage: async (params: any) => { getProductPage: async (params: any) => {
return await request.get({ url: `/erp/product/page`, params }) return await request.get({ url: `/erp/product/page`, params })
}, },
// 查询ERP 产品详情 // 查询产品详情
getProduct: async (id: number) => { getProduct: async (id: number) => {
return await request.get({ url: `/erp/product/get?id=` + id }) return await request.get({ url: `/erp/product/get?id=` + id })
}, },
// 新增ERP 产品 // 新增产品
createProduct: async (data: ProductVO) => { createProduct: async (data: ProductVO) => {
return await request.post({ url: `/erp/product/create`, data }) return await request.post({ url: `/erp/product/create`, data })
}, },
// 修改ERP 产品 // 修改产品
updateProduct: async (data: ProductVO) => { updateProduct: async (data: ProductVO) => {
return await request.put({ url: `/erp/product/update`, data }) return await request.put({ url: `/erp/product/update`, data })
}, },
// 删除ERP 产品 // 删除产品
deleteProduct: async (id: number) => { deleteProduct: async (id: number) => {
return await request.delete({ url: `/erp/product/delete?id=` + id }) return await request.delete({ url: `/erp/product/delete?id=` + id })
}, },
// 导出ERP 产品 Excel // 导出产品 Excel
exportProduct: async (params) => { exportProduct: async (params) => {
return await request.download({ url: `/erp/product/export-excel`, params }) return await request.download({ url: `/erp/product/export-excel`, params })
} }

View File

@ -12,32 +12,37 @@ export interface ProductUnitVO {
// ERP 产品单位 API // ERP 产品单位 API
export const ProductUnitApi = { export const ProductUnitApi = {
// 查询ERP 产品单位分页 // 查询产品单位分页
getProductUnitPage: async (params: any) => { getProductUnitPage: async (params: any) => {
return await request.get({ url: `/erp/product-unit/page`, params }) return await request.get({ url: `/erp/product-unit/page`, params })
}, },
// 查询ERP 产品单位详情 // 查询商品单位精简列表
getProductUnitSimpleList: async () => {
return await request.get({ url: `/erp/product-unit/simple-list` })
},
// 查询产品单位详情
getProductUnit: async (id: number) => { getProductUnit: async (id: number) => {
return await request.get({ url: `/erp/product-unit/get?id=` + id }) return await request.get({ url: `/erp/product-unit/get?id=` + id })
}, },
// 新增ERP 产品单位 // 新增产品单位
createProductUnit: async (data: ProductUnitVO) => { createProductUnit: async (data: ProductUnitVO) => {
return await request.post({ url: `/erp/product-unit/create`, data }) return await request.post({ url: `/erp/product-unit/create`, data })
}, },
// 修改ERP 产品单位 // 修改产品单位
updateProductUnit: async (data: ProductUnitVO) => { updateProductUnit: async (data: ProductUnitVO) => {
return await request.put({ url: `/erp/product-unit/update`, data }) return await request.put({ url: `/erp/product-unit/update`, data })
}, },
// 删除ERP 产品单位 // 删除产品单位
deleteProductUnit: async (id: number) => { deleteProductUnit: async (id: number) => {
return await request.delete({ url: `/erp/product-unit/delete?id=` + id }) return await request.delete({ url: `/erp/product-unit/delete?id=` + id })
}, },
// 导出ERP 产品单位 Excel // 导出产品单位 Excel
exportProductUnit: async (params) => { exportProductUnit: async (params) => {
return await request.download({ url: `/erp/product-unit/export-excel`, params }) return await request.download({ url: `/erp/product-unit/export-excel`, params })
} }

View File

@ -8,44 +8,120 @@
label-width="100px" label-width="100px"
v-loading="formLoading" v-loading="formLoading"
> >
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="名称" prop="name"> <el-form-item label="名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入名称" /> <el-input v-model="formData.name" placeholder="请输入名称" />
</el-form-item> </el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="条码" prop="barCode"> <el-form-item label="条码" prop="barCode">
<el-input v-model="formData.barCode" placeholder="请输入条码" /> <el-input v-model="formData.barCode" placeholder="请输入条码" />
</el-form-item> </el-form-item>
<el-form-item label="分类编号" prop="categoryId"> </el-col>
<el-input v-model="formData.categoryId" placeholder="请输入分类编号" /> <el-col :span="12">
<el-form-item label="分类" prop="categoryId">
<el-tree-select
v-model="formData.categoryId"
:data="categoryList"
:props="defaultProps"
check-strictly
default-expand-all
placeholder="请选择分类"
class="w-1/1"
/>
</el-form-item> </el-form-item>
<el-form-item label="单位编号" prop="unitId"> </el-col>
<el-input v-model="formData.unitId" placeholder="请输入单位编号" /> <el-col :span="12">
<el-form-item label="单位" prop="unitId">
<el-select v-model="formData.unitId" clearable placeholder="请选择单位" class="w-1/1">
<el-option
v-for="unit in unitList"
:key="unit.id"
:label="unit.name"
:value="unit.id"
/>
</el-select>
</el-form-item> </el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-radio-group v-model="formData.status"> <el-radio-group v-model="formData.status">
<el-radio label="1">请选择字典生成</el-radio> <el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="规格" prop="standard"> <el-form-item label="规格" prop="standard">
<el-input v-model="formData.standard" placeholder="请输入规格" /> <el-input v-model="formData.standard" placeholder="请输入规格" />
</el-form-item> </el-form-item>
<el-form-item label="备注" prop="remark"> </el-col>
<el-input v-model="formData.remark" placeholder="请输入备注" /> <el-col :span="12">
</el-form-item>
<el-form-item label="保质期天数" prop="expiryDay"> <el-form-item label="保质期天数" prop="expiryDay">
<el-input v-model="formData.expiryDay" placeholder="请输入保质期天数" /> <el-input-number
v-model="formData.expiryDay"
placeholder="请输入保质期天数"
:min="0"
:precision="0"
class="!w-1/1"
/>
</el-form-item> </el-form-item>
<el-form-item label="基础重量kg" prop="weight"> </el-col>
<el-input v-model="formData.weight" placeholder="请输入基础重量kg" /> <el-col :span="12">
<el-form-item label="重量kg" prop="weight">
<el-input-number
v-model="formData.weight"
placeholder="请输入重量kg"
:min="0"
class="!w-1/1"
/>
</el-form-item> </el-form-item>
<el-form-item label="采购价格,单位:元" prop="purchasePrice"> </el-col>
<el-input v-model="formData.purchasePrice" placeholder="请输入采购价格,单位:元" /> <el-col :span="12">
<el-form-item label="采购价格" prop="purchasePrice">
<el-input-number
v-model="formData.purchasePrice"
placeholder="请输入采购价格,单位:元"
:min="0"
:precision="2"
class="!w-1/1"
/>
</el-form-item> </el-form-item>
<el-form-item label="销售价格,单位:元" prop="salePrice"> </el-col>
<el-input v-model="formData.salePrice" placeholder="请输入销售价格,单位:元" /> <el-col :span="12">
<el-form-item label="销售价格" prop="salePrice">
<el-input-number
v-model="formData.salePrice"
placeholder="请输入销售价格,单位:元"
:min="0"
:precision="2"
class="!w-1/1"
/>
</el-form-item> </el-form-item>
<el-form-item label="最低价格,单位:元" prop="minPrice"> </el-col>
<el-input v-model="formData.minPrice" placeholder="请输入最低价格,单位:元" /> <el-col :span="12">
<el-form-item label="最低价格" prop="minPrice">
<el-input-number
v-model="formData.minPrice"
placeholder="请输入最低价格,单位:元"
:min="0"
:precision="2"
class="!w-1/1"
/>
</el-form-item> </el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input type="textarea" v-model="formData.remark" placeholder="请输入备注" />
</el-form-item>
</el-col>
</el-row>
</el-form> </el-form>
<template #footer> <template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button> <el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
@ -54,7 +130,12 @@
</Dialog> </Dialog>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ProductApi } from '@/api/erp/product' import { ProductApi, ProductVO } from '@/api/erp/product'
import { ProductCategoryApi, ProductCategoryVO } from '@/api/erp/product/category'
import { ProductUnitApi, ProductUnitVO } from '@/api/erp/product/unit'
import { CommonStatusEnum } from '@/utils/constants'
import { defaultProps, handleTree } from '@/utils/tree'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
/** ERP 产品 表单 */ /** ERP 产品 表单 */
defineOptions({ name: 'ProductForm' }) defineOptions({ name: 'ProductForm' })
@ -89,6 +170,8 @@ const formRules = reactive({
status: [{ required: true, message: '产品状态不能为空', trigger: 'blur' }] status: [{ required: true, message: '产品状态不能为空', trigger: 'blur' }]
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
const categoryList = ref<ProductCategoryVO[]>([]) //
const unitList = ref<ProductUnitVO[]>([]) //
/** 打开弹窗 */ /** 打开弹窗 */
const open = async (type: string, id?: number) => { const open = async (type: string, id?: number) => {
@ -105,6 +188,11 @@ const open = async (type: string, id?: number) => {
formLoading.value = false formLoading.value = false
} }
} }
//
const categoryData = await ProductCategoryApi.getProductCategorySimpleList()
categoryList.value = handleTree(categoryData, 'id', 'parentId')
//
unitList.value = await ProductUnitApi.getProductUnitSimpleList()
} }
defineExpose({ open }) // open defineExpose({ open }) // open
@ -116,7 +204,7 @@ const submitForm = async () => {
// //
formLoading.value = true formLoading.value = true
try { try {
const data = formData.value as unknown as ProductApi.ProductVO const data = formData.value as unknown as ProductVO
if (formType.value === 'create') { if (formType.value === 'create') {
await ProductApi.createProduct(data) await ProductApi.createProduct(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
@ -140,7 +228,7 @@ const resetForm = () => {
barCode: undefined, barCode: undefined,
categoryId: undefined, categoryId: undefined,
unitId: undefined, unitId: undefined,
status: undefined, status: CommonStatusEnum.ENABLE,
standard: undefined, standard: undefined,
remark: undefined, remark: undefined,
expiryDay: undefined, expiryDay: undefined,

View File

@ -136,12 +136,8 @@ const { t } = useI18n() // 国际化
const loading = ref(true) // const loading = ref(true) //
const list = ref<ProductCategoryVO[]>([]) // const list = ref<ProductCategoryVO[]>([]) //
const queryParams = reactive({ const queryParams = reactive({
parentId: undefined,
name: undefined, name: undefined,
code: undefined, status: undefined
sort: undefined,
status: undefined,
createTime: []
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
const exportLoading = ref(false) // const exportLoading = ref(false) //

View File

@ -9,32 +9,23 @@
:inline="true" :inline="true"
label-width="68px" label-width="68px"
> >
<el-form-item label="产品名称" prop="name"> <el-form-item label="名称" prop="name">
<el-input <el-input
v-model="queryParams.name" v-model="queryParams.name"
placeholder="请输入产品名称" placeholder="请输入名称"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
class="!w-240px" class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item label="产品分类" prop="categoryId"> <el-form-item label="分类" prop="categoryId">
<el-input <el-tree-select
v-model="queryParams.categoryId" v-model="queryParams.categoryId"
placeholder="请输入产品分类" :data="categoryList"
clearable :props="defaultProps"
@keyup.enter="handleQuery" check-strictly
class="!w-240px" default-expand-all
/> placeholder="请输入分类"
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="queryParams.createTime"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px" class="!w-240px"
/> />
</el-form-item> </el-form-item>
@ -68,15 +59,16 @@
<el-table-column label="条码" align="center" prop="barCode" /> <el-table-column label="条码" align="center" prop="barCode" />
<el-table-column label="名称" align="center" prop="name" /> <el-table-column label="名称" align="center" prop="name" />
<el-table-column label="规格" align="center" prop="standard" /> <el-table-column label="规格" align="center" prop="standard" />
<!-- TODO 芋艿待实现 --> <el-table-column label="分类" align="center" prop="categoryName" />
<el-table-column label="分类" align="center" prop="categoryId" /> <el-table-column label="单位" align="center" prop="unitName" />
<!-- TODO 芋艿待实现 -->
<el-table-column label="单位" align="center" prop="unitId" />
<el-table-column label="采购价格" align="center" prop="purchasePrice" /> <el-table-column label="采购价格" align="center" prop="purchasePrice" />
<el-table-column label="销售价格" align="center" prop="salePrice" /> <el-table-column label="销售价格" align="center" prop="salePrice" />
<el-table-column label="最低价格" align="center" prop="minPrice" /> <el-table-column label="最低价格" align="center" prop="minPrice" />
<!-- TODO 芋艿待实现 --> <el-table-column label="状态" align="center" prop="status">
<el-table-column label="产品状态" align="center" prop="status" /> <template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column <el-table-column
label="创建时间" label="创建时间"
align="center" align="center"
@ -122,7 +114,10 @@
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download' import download from '@/utils/download'
import { ProductApi, ProductVO } from '@/api/erp/product' import { ProductApi, ProductVO } from '@/api/erp/product'
import { ProductCategoryApi, ProductCategoryVO } from '@/api/erp/product/category'
import ProductForm from './ProductForm.vue' import ProductForm from './ProductForm.vue'
import { DICT_TYPE } from '@/utils/dict'
import { defaultProps, handleTree } from '@/utils/tree'
/** ERP 产品列表 */ /** ERP 产品列表 */
defineOptions({ name: 'ErpProduct' }) defineOptions({ name: 'ErpProduct' })
@ -137,11 +132,11 @@ const queryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
name: undefined, name: undefined,
categoryId: undefined, categoryId: undefined
createTime: []
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
const exportLoading = ref(false) // const exportLoading = ref(false) //
const categoryList = ref<ProductCategoryVO[]>([]) //
/** 查询列表 */ /** 查询列表 */
const getList = async () => { const getList = async () => {
@ -202,7 +197,10 @@ const handleExport = async () => {
} }
/** 初始化 **/ /** 初始化 **/
onMounted(() => { onMounted(async () => {
getList() await getList()
//
const categoryData = await ProductCategoryApi.getProductCategorySimpleList()
categoryList.value = handleTree(categoryData, 'id', 'parentId')
}) })
</script> </script>

View File

@ -12,7 +12,13 @@
</el-form-item> </el-form-item>
<el-form-item label="单位状态" prop="status"> <el-form-item label="单位状态" prop="status">
<el-radio-group v-model="formData.status"> <el-radio-group v-model="formData.status">
<el-radio label="1">请选择字典生成</el-radio> <el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -24,6 +30,8 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ProductUnitApi } from '@/api/erp/product/unit' import { ProductUnitApi } from '@/api/erp/product/unit'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { CommonStatusEnum } from '@/utils/constants'
/** ERP 产品单位表单 */ /** ERP 产品单位表单 */
defineOptions({ name: 'ProductUnitForm' }) defineOptions({ name: 'ProductUnitForm' })
@ -93,7 +101,7 @@ const resetForm = () => {
formData.value = { formData.value = {
id: undefined, id: undefined,
name: undefined, name: undefined,
status: undefined status: CommonStatusEnum.ENABLE
} }
formRef.value?.resetFields() formRef.value?.resetFields()
} }

View File

@ -24,19 +24,13 @@
clearable clearable
class="!w-240px" class="!w-240px"
> >
<el-option label="请选择字典生成" value="" /> <el-option
</el-select> v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
</el-form-item> :key="dict.value"
<el-form-item label="创建时间" prop="createTime"> :label="dict.label"
<el-date-picker :value="dict.value"
v-model="queryParams.createTime"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px"
/> />
</el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
@ -65,9 +59,12 @@
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="单位编号" align="center" prop="id" /> <el-table-column label="名字" align="center" prop="name" />
<el-table-column label="单位名字" align="center" prop="name" /> <el-table-column label="状态" align="center" prop="status">
<el-table-column label="单位状态" align="center" prop="status" /> <template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column <el-table-column
label="创建时间" label="创建时间"
align="center" align="center"
@ -114,6 +111,7 @@ import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download' import download from '@/utils/download'
import { ProductUnitApi, ProductUnitVO } from '@/api/erp/product/unit' import { ProductUnitApi, ProductUnitVO } from '@/api/erp/product/unit'
import ProductUnitForm from './ProductUnitForm.vue' import ProductUnitForm from './ProductUnitForm.vue'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
/** ERP 产品单位列表 */ /** ERP 产品单位列表 */
defineOptions({ name: 'ErpProductUnit' }) defineOptions({ name: 'ErpProductUnit' })
@ -129,8 +127,7 @@ const queryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
name: undefined, name: undefined,
status: undefined, status: undefined
createTime: []
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
const exportLoading = ref(false) // const exportLoading = ref(false) //
@ -186,7 +183,7 @@ const handleExport = async () => {
// //
exportLoading.value = true exportLoading.value = true
const data = await ProductUnitApi.exportProductUnit(queryParams) const data = await ProductUnitApi.exportProductUnit(queryParams)
download.excel(data, 'ERP 产品单位.xls') download.excel(data, '产品单位.xls')
} catch { } catch {
} finally { } finally {
exportLoading.value = false exportLoading.value = false