Skip to content

Commit 2634363

Browse files
committed
✨ ERP:完成 stock 产品库存、库存明细的实现
1 parent 6d9ca29 commit 2634363

File tree

11 files changed

+486
-8
lines changed

11 files changed

+486
-8
lines changed

src/api/erp/product/index.ts renamed to src/api/erp/product/product/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ export const ProductApi = {
2424
return await request.get({ url: `/erp/product/page`, params })
2525
},
2626

27+
// 查询产品精简列表
28+
getProductSimpleList: async (params: any) => {
29+
return await request.get({ url: `/erp/product/simple-list`, params })
30+
},
31+
2732
// 查询产品详情
2833
getProduct: async (id: number) => {
2934
return await request.get({ url: `/erp/product/get?id=` + id })

src/api/erp/stock/stock/index.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import request from '@/config/axios'
2+
3+
// ERP 产品库存 VO
4+
export interface StockVO {
5+
// 编号
6+
id: number
7+
// 产品编号
8+
productId: number
9+
// 仓库编号
10+
warehouseId: number
11+
// 库存数量
12+
count: number
13+
}
14+
15+
// ERP 产品库存 API
16+
export const StockApi = {
17+
// 查询产品库存分页
18+
getStockPage: async (params: any) => {
19+
return await request.get({ url: `/erp/stock/page`, params })
20+
},
21+
22+
// 查询产品库存详情
23+
getStock: async (id: number) => {
24+
return await request.get({ url: `/erp/stock/get?id=` + id })
25+
},
26+
27+
// 导出产品库存 Excel
28+
exportStock: async (params) => {
29+
return await request.download({ url: `/erp/stock/export-excel`, params })
30+
}
31+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import request from '@/config/axios'
2+
3+
// ERP 产品库存明细 VO
4+
export interface StockRecordVO {
5+
id: number // 编号
6+
productId: number // 产品编号
7+
warehouseId: number // 仓库编号
8+
count: number // 出入库数量
9+
totalCount: number // 总库存量
10+
bizType: number // 业务类型
11+
bizId: number // 业务编号
12+
bizItemId: number // 业务项编号
13+
bizNo: string // 业务单号
14+
}
15+
16+
// ERP 产品库存明细 API
17+
export const StockRecordApi = {
18+
// 查询产品库存明细分页
19+
getStockRecordPage: async (params: any) => {
20+
return await request.get({ url: `/erp/stock-record/page`, params })
21+
},
22+
23+
// 查询产品库存明细详情
24+
getStockRecord: async (id: number) => {
25+
return await request.get({ url: `/erp/stock-record/get?id=` + id })
26+
},
27+
28+
// 导出产品库存明细 Excel
29+
exportStockRecord: async (params) => {
30+
return await request.download({ url: `/erp/stock-record/export-excel`, params })
31+
}
32+
}

src/api/erp/stock/warehouse/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ export const WarehouseApi = {
2121
return await request.get({ url: `/erp/warehouse/page`, params })
2222
},
2323

24+
// 查询仓库精简列表
25+
getWarehouseSimpleList: async (params: any) => {
26+
return await request.get({ url: `/erp/warehouse/simple-list`, params })
27+
},
28+
2429
// 查询仓库详情
2530
getWarehouse: async (id: number) => {
2631
return await request.get({ url: `/erp/warehouse/get?id=` + id })

src/utils/dict.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,6 @@ export enum DICT_TYPE {
205205
CRM_PRODUCT_UNIT = 'crm_product_unit', // 产品单位
206206
CRM_FOLLOW_UP_TYPE = 'crm_follow_up_type', // 跟进方式
207207

208-
// ========== BI - 商业智能模块 ==========
209-
BI_ANALYZE_TYPE = 'bi_analyze_type' // 分析类型
208+
// ========== ERP - 企业资源计划模块 ==========
209+
ERP_STOCK_RECORD_BIZ_TYPE = 'erp_stock_record_biz_type' // 库存明细的业务类型
210210
}

src/views/erp/product/ProductForm.vue renamed to src/views/erp/product/product/ProductForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
</Dialog>
131131
</template>
132132
<script setup lang="ts">
133-
import { ProductApi, ProductVO } from '@/api/erp/product'
133+
import { ProductApi, ProductVO } from '@/api/erp/product/product'
134134
import { ProductCategoryApi, ProductCategoryVO } from '@/api/erp/product/category'
135135
import { ProductUnitApi, ProductUnitVO } from '@/api/erp/product/unit'
136136
import { CommonStatusEnum } from '@/utils/constants'

src/views/erp/product/index.vue renamed to src/views/erp/product/product/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
<script setup lang="ts">
114114
import { dateFormatter } from '@/utils/formatTime'
115115
import download from '@/utils/download'
116-
import { ProductApi, ProductVO } from '@/api/erp/product'
116+
import { ProductApi, ProductVO } from '@/api/erp/product/product'
117117
import { ProductCategoryApi, ProductCategoryVO } from '@/api/erp/product/category'
118118
import ProductForm from './ProductForm.vue'
119119
import { DICT_TYPE } from '@/utils/dict'

src/views/erp/product/unit/index.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ const { t } = useI18n() // 国际化
121121
122122
const loading = ref(true) // 列表的加载中
123123
const list = ref<ProductUnitVO[]>([]) // 列表的数据
124-
// 列表的总页数
125-
const total = ref(0)
124+
const total = ref(0) // 列表的总页数
126125
const queryParams = reactive({
127126
pageNo: 1,
128127
pageSize: 10,

src/views/erp/stock/stock/index.vue

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
<!-- ERP 产品库存列表 -->
2+
<template>
3+
<ContentWrap>
4+
<!-- 搜索工作栏 -->
5+
<el-form
6+
class="-mb-15px"
7+
:model="queryParams"
8+
ref="queryFormRef"
9+
:inline="true"
10+
label-width="68px"
11+
>
12+
<el-form-item label="产品" prop="productId">
13+
<el-select
14+
v-model="queryParams.productId"
15+
filterable
16+
placeholder="请选择产品"
17+
class="!w-240px"
18+
>
19+
<el-option
20+
v-for="item in productList"
21+
:key="item.id"
22+
:label="item.name"
23+
:value="item.id"
24+
/>
25+
</el-select>
26+
</el-form-item>
27+
<el-form-item label="仓库" prop="warehouseId">
28+
<el-select
29+
v-model="queryParams.warehouseId"
30+
filterable
31+
placeholder="请选择仓库"
32+
class="!w-240px"
33+
>
34+
<el-option
35+
v-for="item in warehouseList"
36+
:key="item.id"
37+
:label="item.name"
38+
:value="item.id"
39+
/>
40+
</el-select>
41+
</el-form-item>
42+
<el-form-item>
43+
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
44+
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
45+
<el-button
46+
type="primary"
47+
plain
48+
@click="openForm('create')"
49+
v-hasPermi="['erp:stock:create']"
50+
>
51+
<Icon icon="ep:plus" class="mr-5px" /> 新增
52+
</el-button>
53+
<el-button
54+
type="success"
55+
plain
56+
@click="handleExport"
57+
:loading="exportLoading"
58+
v-hasPermi="['erp:stock:export']"
59+
>
60+
<Icon icon="ep:download" class="mr-5px" /> 导出
61+
</el-button>
62+
</el-form-item>
63+
</el-form>
64+
</ContentWrap>
65+
66+
<!-- 列表 -->
67+
<ContentWrap>
68+
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
69+
<el-table-column label="产品名称" align="center" prop="productName" />
70+
<el-table-column label="产品单位" align="center" prop="unitName" />
71+
<el-table-column label="产品分类" align="center" prop="categoryName" />
72+
<el-table-column label="库存量" align="center" prop="count" />
73+
<el-table-column label="仓库" align="center" prop="warehouseName" />
74+
</el-table>
75+
<!-- 分页 -->
76+
<Pagination
77+
:total="total"
78+
v-model:page="queryParams.pageNo"
79+
v-model:limit="queryParams.pageSize"
80+
@pagination="getList"
81+
/>
82+
</ContentWrap>
83+
</template>
84+
85+
<script setup lang="ts">
86+
import download from '@/utils/download'
87+
import { StockApi, StockVO } from '@/api/erp/stock/stock'
88+
import { ProductApi, ProductVO } from '@/api/erp/product/product'
89+
import { WarehouseApi, WarehouseVO } from '@/api/erp/stock/warehouse'
90+
91+
/** ERP 产品库存列表 */
92+
defineOptions({ name: 'ErpStock' })
93+
94+
const message = useMessage() // 消息弹窗
95+
const { t } = useI18n() // 国际化
96+
97+
const loading = ref(true) // 列表的加载中
98+
const list = ref<StockVO[]>([]) // 列表的数据
99+
const total = ref(0) // 列表的总页数
100+
const queryParams = reactive({
101+
pageNo: 1,
102+
pageSize: 10,
103+
productId: undefined,
104+
warehouseId: undefined
105+
})
106+
const queryFormRef = ref() // 搜索的表单
107+
const exportLoading = ref(false) // 导出的加载中
108+
const productList = ref<ProductVO[]>([]) // 产品列表
109+
const warehouseList = ref<WarehouseVO[]>([]) // 仓库列表
110+
111+
/** 查询列表 */
112+
const getList = async () => {
113+
loading.value = true
114+
try {
115+
const data = await StockApi.getStockPage(queryParams)
116+
list.value = data.list
117+
total.value = data.total
118+
} finally {
119+
loading.value = false
120+
}
121+
}
122+
123+
/** 搜索按钮操作 */
124+
const handleQuery = () => {
125+
queryParams.pageNo = 1
126+
getList()
127+
}
128+
129+
/** 重置按钮操作 */
130+
const resetQuery = () => {
131+
queryFormRef.value.resetFields()
132+
handleQuery()
133+
}
134+
135+
/** 添加/修改操作 */
136+
const formRef = ref()
137+
const openForm = (type: string, id?: number) => {
138+
formRef.value.open(type, id)
139+
}
140+
141+
/** 删除按钮操作 */
142+
const handleDelete = async (id: number) => {
143+
try {
144+
// 删除的二次确认
145+
await message.delConfirm()
146+
// 发起删除
147+
await StockApi.deleteStock(id)
148+
message.success(t('common.delSuccess'))
149+
// 刷新列表
150+
await getList()
151+
} catch {}
152+
}
153+
154+
/** 导出按钮操作 */
155+
const handleExport = async () => {
156+
try {
157+
// 导出的二次确认
158+
await message.exportConfirm()
159+
// 发起导出
160+
exportLoading.value = true
161+
const data = await StockApi.exportStock(queryParams)
162+
download.excel(data, '产品库存.xls')
163+
} catch {
164+
} finally {
165+
exportLoading.value = false
166+
}
167+
}
168+
169+
/** 初始化 **/
170+
onMounted(async () => {
171+
await getList()
172+
// 加载产品、仓库列表
173+
productList.value = await ProductApi.getProductSimpleList()
174+
warehouseList.value = await WarehouseApi.getWarehouseSimpleList()
175+
})
176+
</script>

0 commit comments

Comments
 (0)