Skip to content

Commit ab63660

Browse files
committed
✨ ERP:增加 ERP 销售订单的实现 50%(详情)
新年快乐~
1 parent 2615054 commit ab63660

File tree

10 files changed

+94
-119
lines changed

10 files changed

+94
-119
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface ProductVO {
77
barCode: string // 产品条码
88
categoryId: number // 产品类型编号
99
unitId: number // 单位编号
10+
unitName?: string // 单位名字
1011
status: number // 产品状态
1112
standard: string // 产品规格
1213
remark: string // 产品备注
@@ -25,8 +26,8 @@ export const ProductApi = {
2526
},
2627

2728
// 查询产品精简列表
28-
getProductSimpleList: async (params: any) => {
29-
return await request.get({ url: `/erp/product/simple-list`, params })
29+
getProductSimpleList: async () => {
30+
return await request.get({ url: `/erp/product/simple-list` })
3031
},
3132

3233
// 查询产品详情

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ export const StockApi = {
2929
return await request.get({ url: `/erp/stock/get`, params: { productId, warehouseId } })
3030
},
3131

32+
// 获得产品库存数量
33+
getStockCount: async (productId: number) => {
34+
return await request.get({ url: `/erp/stock/get-count`, params: { productId } })
35+
},
36+
3237
// 导出产品库存 Excel
3338
exportStock: async (params) => {
3439
return await request.download({ url: `/erp/stock/export-excel`, params })

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export const WarehouseApi = {
2222
},
2323

2424
// 查询仓库精简列表
25-
getWarehouseSimpleList: async (params: any) => {
26-
return await request.get({ url: `/erp/warehouse/simple-list`, params })
25+
getWarehouseSimpleList: async () => {
26+
return await request.get({ url: `/erp/warehouse/simple-list` })
2727
},
2828

2929
// 查询仓库详情

src/views/erp/sale/order/SaleOrderForm.vue

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
>
1111
<el-row :gutter="20">
1212
<el-col :span="8">
13-
<el-form-item label="出库单号" prop="no">
13+
<el-form-item label="订单单号" prop="no">
1414
<el-input disabled v-model="formData.no" placeholder="保存时自动生成" />
1515
</el-form-item>
1616
</el-col>
1717
<el-col :span="8">
18-
<el-form-item label="出库时间" prop="outTime">
18+
<el-form-item label="订单时间" prop="outTime">
1919
<el-date-picker
20-
v-model="formData.outTime"
20+
v-model="formData.orderTime"
2121
type="date"
2222
value-format="x"
23-
placeholder="选择出库时间"
23+
placeholder="选择订单时间"
2424
class="!w-1/1"
2525
/>
2626
</el-form-item>
@@ -62,7 +62,7 @@
6262
<!-- 子表的表单 -->
6363
<ContentWrap>
6464
<el-tabs v-model="subTabsName" class="-mt-15px -mb-10px">
65-
<el-tab-pane label="出库产品清单" name="item">
65+
<el-tab-pane label="订单产品清单" name="item">
6666
<SaleOrderItemForm ref="itemFormRef" :items="formData.items" :disabled="disabled" />
6767
</el-tab-pane>
6868
</el-tabs>
@@ -80,7 +80,7 @@ import { SaleOrderApi, SaleOrderVO } from '@/api/erp/sale/order'
8080
import SaleOrderItemForm from './components/SaleOrderItemForm.vue'
8181
import { CustomerApi, CustomerVO } from '@/api/erp/sale/customer'
8282
83-
/** ERP 其它出库单表单 */
83+
/** ERP 销售订单表单 */
8484
defineOptions({ name: 'SaleOrderForm' })
8585
8686
const { t } = useI18n() // 国际化
@@ -96,10 +96,11 @@ const formData = ref({
9696
orderTime: undefined,
9797
remark: undefined,
9898
fileUrl: '',
99-
items: []
99+
items: [],
100+
no: undefined // 订单单号,后端返回
100101
})
101102
const formRules = reactive({
102-
orderTime: [{ required: true, message: '出库时间不能为空', trigger: 'blur' }]
103+
orderTime: [{ required: true, message: '订单时间不能为空', trigger: 'blur' }]
103104
})
104105
const disabled = computed(() => formType.value === 'detail')
105106
const formRef = ref() // 表单 Ref

src/views/erp/sale/order/components/SaleOrderItemForm.vue

Lines changed: 60 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,6 @@
1010
>
1111
<el-table :data="formData" show-summary :summary-method="getSummaries" class="-mt-10px">
1212
<el-table-column label="序号" type="index" align="center" width="60" />
13-
<el-table-column label="仓库名称" min-width="125">
14-
<template #default="{ row, $index }">
15-
<el-form-item
16-
:prop="`${$index}.warehouseId`"
17-
:rules="formRules.warehouseId"
18-
class="mb-0px!"
19-
>
20-
<el-select
21-
v-model="row.warehouseId"
22-
filterable
23-
placeholder="请选择仓库"
24-
@change="onChangeWarehouse($event, row)"
25-
>
26-
<el-option
27-
v-for="item in warehouseList"
28-
:key="item.id"
29-
:label="item.name"
30-
:value="item.id"
31-
/>
32-
</el-select>
33-
</el-form-item>
34-
</template>
35-
</el-table-column>
3613
<el-table-column label="产品名称" min-width="180">
3714
<template #default="{ row, $index }">
3815
<el-form-item :prop="`${$index}.productId`" :rules="formRules.productId" class="mb-0px!">
@@ -88,11 +65,7 @@
8865
</el-table-column>
8966
<el-table-column label="产品单价" fixed="right" min-width="120">
9067
<template #default="{ row, $index }">
91-
<el-form-item
92-
:prop="`${$index}.productPrice`"
93-
:rules="formRules.productPrice"
94-
class="mb-0px!"
95-
>
68+
<el-form-item :prop="`${$index}.productPrice`" class="mb-0px!">
9669
<el-input-number
9770
v-model="row.productPrice"
9871
controls-position="right"
@@ -103,20 +76,55 @@
10376
</el-form-item>
10477
</template>
10578
</el-table-column>
106-
<el-table-column label="合计金额" prop="totalPrice" fixed="right" min-width="100">
79+
<el-table-column label="金额" prop="totalProductPrice" fixed="right" min-width="100">
80+
<template #default="{ row, $index }">
81+
<el-form-item :prop="`${$index}.totalProductPrice`" class="mb-0px!">
82+
<el-input
83+
disabled
84+
v-model="row.totalProductPrice"
85+
:formatter="erpPriceInputFormatter"
86+
/>
87+
</el-form-item>
88+
</template>
89+
</el-table-column>
90+
<el-table-column label="税率(%)" fixed="right" min-width="115">
91+
<template #default="{ row, $index }">
92+
<el-form-item :prop="`${$index}.taxPercent`" class="mb-0px!">
93+
<el-input-number
94+
v-model="row.taxPercent"
95+
controls-position="right"
96+
:min="0.01"
97+
:precision="2"
98+
class="!w-100%"
99+
/>
100+
</el-form-item>
101+
</template>
102+
</el-table-column>
103+
<el-table-column label="税额" prop="taxPrice" fixed="right" min-width="120">
107104
<template #default="{ row, $index }">
108-
<el-form-item
109-
:prop="`${$index}.totalPrice`"
110-
:rules="formRules.totalPrice"
111-
class="mb-0px!"
112-
>
105+
<el-form-item :prop="`${$index}.taxPrice`" class="mb-0px!">
106+
<el-form-item :prop="`${$index}.taxPrice`" class="mb-0px!">
107+
<el-input-number
108+
v-model="row.taxPrice"
109+
controls-position="right"
110+
:min="0.01"
111+
:precision="2"
112+
class="!w-100%"
113+
/>
114+
</el-form-item>
115+
</el-form-item>
116+
</template>
117+
</el-table-column>
118+
<el-table-column label="税额合计" prop="totalPrice" fixed="right" min-width="100">
119+
<template #default="{ row, $index }">
120+
<el-form-item :prop="`${$index}.totalPrice`" class="mb-0px!">
113121
<el-input disabled v-model="row.totalPrice" :formatter="erpPriceInputFormatter" />
114122
</el-form-item>
115123
</template>
116124
</el-table-column>
117125
<el-table-column label="备注" min-width="150">
118126
<template #default="{ row, $index }">
119-
<el-form-item :prop="`${$index}.remark`" :rules="formRules.remark" class="mb-0px!">
127+
<el-form-item :prop="`${$index}.remark`" class="mb-0px!">
120128
<el-input v-model="row.remark" placeholder="请输入备注" />
121129
</el-form-item>
122130
</template>
@@ -134,7 +142,6 @@
134142
</template>
135143
<script setup lang="ts">
136144
import { ProductApi, ProductVO } from '@/api/erp/product/product'
137-
import { WarehouseApi, WarehouseVO } from '@/api/erp/stock/warehouse'
138145
import { StockApi } from '@/api/erp/stock/stock'
139146
import {
140147
erpCountInputFormatter,
@@ -153,13 +160,10 @@ const formRules = reactive({
153160
inId: [{ required: true, message: '出库编号不能为空', trigger: 'blur' }],
154161
warehouseId: [{ required: true, message: '仓库不能为空', trigger: 'blur' }],
155162
productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }],
156-
productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }],
157163
count: [{ required: true, message: '产品数量不能为空', trigger: 'blur' }]
158164
})
159165
const formRef = ref([]) // 表单 Ref
160166
const productList = ref<ProductVO[]>([]) // 产品列表
161-
const warehouseList = ref<WarehouseVO[]>([]) // 仓库列表
162-
const defaultWarehouse = ref<WarehouseVO>(undefined) // 默认仓库
163167
164168
/** 初始化设置出库项 */
165169
watch(
@@ -179,7 +183,13 @@ watch(
179183
}
180184
// 循环处理
181185
val.forEach((item) => {
182-
item.totalPrice = erpPriceMultiply(item.productPrice, item.count)
186+
item.totalProductPrice = erpPriceMultiply(item.productPrice, item.count)
187+
item.taxPrice = erpPriceMultiply(item.totalProductPrice, item.taxPercent / 100.0)
188+
if (item.totalProductPrice != null) {
189+
item.totalPrice = item.totalProductPrice + (item.taxPrice || 0)
190+
} else {
191+
item.totalPrice = undefined
192+
}
183193
})
184194
},
185195
{ deep: true }
@@ -189,12 +199,12 @@ watch(
189199
const getSummaries = (param: SummaryMethodProps) => {
190200
const { columns, data } = param
191201
const sums: string[] = []
192-
columns.forEach((column, index) => {
202+
columns.forEach((column, index: number) => {
193203
if (index === 0) {
194204
sums[index] = '合计'
195205
return
196206
}
197-
if (['count', 'totalPrice'].includes(column.property)) {
207+
if (['count', 'totalProductPrice', 'taxPrice', 'totalPrice'].includes(column.property)) {
198208
const sum = getSumValue(data.map((item) => Number(item[column.property])))
199209
sums[index] =
200210
column.property === 'count' ? erpCountInputFormatter(sum) : erpPriceInputFormatter(sum)
@@ -210,30 +220,26 @@ const getSummaries = (param: SummaryMethodProps) => {
210220
const handleAdd = () => {
211221
const row = {
212222
id: undefined,
213-
warehouseId: defaultWarehouse.value?.id,
214223
productId: undefined,
215224
productUnitName: undefined, // 产品单位
216225
productBarCode: undefined, // 产品条码
217226
productPrice: undefined,
218227
stockCount: undefined,
219228
count: 1,
229+
totalProductPrice: undefined,
230+
taxPercent: undefined,
231+
taxPrice: undefined,
220232
totalPrice: undefined,
221233
remark: undefined
222234
}
223235
formData.value.push(row)
224236
}
225237
226238
/** 删除按钮操作 */
227-
const handleDelete = (index) => {
239+
const handleDelete = (index: number) => {
228240
formData.value.splice(index, 1)
229241
}
230242
231-
/** 处理仓库变更 */
232-
const onChangeWarehouse = (warehouseId, row) => {
233-
// 加载库存
234-
setStockCount(row)
235-
}
236-
237243
/** 处理产品变更 */
238244
const onChangeProduct = (productId, row) => {
239245
const product = productList.value.find((item) => item.id === productId)
@@ -247,12 +253,12 @@ const onChangeProduct = (productId, row) => {
247253
}
248254
249255
/** 加载库存 */
250-
const setStockCount = async (row) => {
251-
if (!row.productId || !row.warehouseId) {
256+
const setStockCount = async (row: any) => {
257+
if (!row.productId) {
252258
return
253259
}
254-
const stock = await StockApi.getStock2(row.productId, row.warehouseId)
255-
row.stockCount = stock ? stock.count : 0
260+
const count = await StockApi.getStockCount(row.productId)
261+
row.stockCount = count || 0
256262
}
257263
258264
/** 表单校验 */
@@ -264,8 +270,6 @@ defineExpose({ validate })
264270
/** 初始化 */
265271
onMounted(async () => {
266272
productList.value = await ProductApi.getProductSimpleList()
267-
warehouseList.value = await WarehouseApi.getWarehouseSimpleList()
268-
defaultWarehouse.value = warehouseList.value.find((item) => item.defaultStatus)
269273
// 默认添加一个
270274
if (formData.value.length === 0) {
271275
handleAdd()

src/views/erp/sale/order/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ import * as UserApi from '@/api/system/user'
284284
import { erpCountTableColumnFormatter, erpPriceTableColumnFormatter } from '@/utils'
285285
import { CustomerApi, CustomerVO } from '@/api/erp/sale/customer'
286286
287-
/** ERP 其它订单单列表 */
287+
/** ERP 销售订单列表 */
288288
defineOptions({ name: 'ErpSaleOrder' })
289289
290290
const message = useMessage() // 消息弹窗
@@ -359,7 +359,7 @@ const handleDelete = async (ids: number[]) => {
359359
const handleUpdateStatus = async (id: number, status: number) => {
360360
try {
361361
// 审批的二次确认
362-
await message.confirm(`确定${status === 20 ? '审批' : '反审批'}该订单单吗`)
362+
await message.confirm(`确定${status === 20 ? '审批' : '反审批'}该订单吗`)
363363
// 发起审批
364364
await SaleOrderApi.updateSaleOrderStatus(id, status)
365365
message.success(`${status === 20 ? '审批' : '反审批'}成功`)
@@ -376,7 +376,7 @@ const handleExport = async () => {
376376
// 发起导出
377377
exportLoading.value = true
378378
const data = await SaleOrderApi.exportSaleOrder(queryParams)
379-
download.excel(data, '其它订单单.xls')
379+
download.excel(data, '销售订单.xls')
380380
} catch {
381381
} finally {
382382
exportLoading.value = false

src/views/erp/stock/check/components/StockCheckItemForm.vue

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,7 @@
103103
</el-table-column>
104104
<el-table-column label="产品单价" fixed="right" min-width="120">
105105
<template #default="{ row, $index }">
106-
<el-form-item
107-
:prop="`${$index}.productPrice`"
108-
:rules="formRules.productPrice"
109-
class="mb-0px!"
110-
>
106+
<el-form-item :prop="`${$index}.productPrice`" class="mb-0px!">
111107
<el-input-number
112108
v-model="row.productPrice"
113109
controls-position="right"
@@ -120,18 +116,14 @@
120116
</el-table-column>
121117
<el-table-column label="合计金额" prop="totalPrice" fixed="right" min-width="100">
122118
<template #default="{ row, $index }">
123-
<el-form-item
124-
:prop="`${$index}.totalPrice`"
125-
:rules="formRules.totalPrice"
126-
class="mb-0px!"
127-
>
119+
<el-form-item :prop="`${$index}.totalPrice`" class="mb-0px!">
128120
<el-input disabled v-model="row.totalPrice" :formatter="erpPriceInputFormatter" />
129121
</el-form-item>
130122
</template>
131123
</el-table-column>
132124
<el-table-column label="备注" min-width="150">
133125
<template #default="{ row, $index }">
134-
<el-form-item :prop="`${$index}.remark`" :rules="formRules.remark" class="mb-0px!">
126+
<el-form-item :prop="`${$index}.remark`" class="mb-0px!">
135127
<el-input v-model="row.remark" placeholder="请输入备注" />
136128
</el-form-item>
137129
</template>
@@ -168,7 +160,6 @@ const formRules = reactive({
168160
inId: [{ required: true, message: '盘点编号不能为空', trigger: 'blur' }],
169161
warehouseId: [{ required: true, message: '仓库名字不能为空', trigger: 'blur' }],
170162
productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }],
171-
productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }],
172163
count: [{ required: true, message: '产品数量不能为空', trigger: 'blur' }]
173164
})
174165
const formRef = ref([]) // 表单 Ref

0 commit comments

Comments
 (0)