10
10
>
11
11
<el-table :data =" formData" show-summary :summary-method =" getSummaries" class =" -mt-10px" >
12
12
<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 >
36
13
<el-table-column label =" 产品名称" min-width =" 180" >
37
14
<template #default =" { row , $index } " >
38
15
<el-form-item :prop =" `${$index}.productId`" :rules =" formRules.productId" class =" mb-0px!" >
88
65
</el-table-column >
89
66
<el-table-column label =" 产品单价" fixed =" right" min-width =" 120" >
90
67
<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!" >
96
69
<el-input-number
97
70
v-model =" row.productPrice"
98
71
controls-position =" right"
103
76
</el-form-item >
104
77
</template >
105
78
</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" >
107
104
<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!" >
113
121
<el-input disabled v-model =" row.totalPrice" :formatter =" erpPriceInputFormatter" />
114
122
</el-form-item >
115
123
</template >
116
124
</el-table-column >
117
125
<el-table-column label =" 备注" min-width =" 150" >
118
126
<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!" >
120
128
<el-input v-model =" row.remark" placeholder =" 请输入备注" />
121
129
</el-form-item >
122
130
</template >
134
142
</template >
135
143
<script setup lang="ts">
136
144
import { ProductApi , ProductVO } from ' @/api/erp/product/product'
137
- import { WarehouseApi , WarehouseVO } from ' @/api/erp/stock/warehouse'
138
145
import { StockApi } from ' @/api/erp/stock/stock'
139
146
import {
140
147
erpCountInputFormatter ,
@@ -153,13 +160,10 @@ const formRules = reactive({
153
160
inId: [{ required: true , message: ' 出库编号不能为空' , trigger: ' blur' }],
154
161
warehouseId: [{ required: true , message: ' 仓库不能为空' , trigger: ' blur' }],
155
162
productId: [{ required: true , message: ' 产品不能为空' , trigger: ' blur' }],
156
- productId: [{ required: true , message: ' 产品不能为空' , trigger: ' blur' }],
157
163
count: [{ required: true , message: ' 产品数量不能为空' , trigger: ' blur' }]
158
164
})
159
165
const formRef = ref ([]) // 表单 Ref
160
166
const productList = ref <ProductVO []>([]) // 产品列表
161
- const warehouseList = ref <WarehouseVO []>([]) // 仓库列表
162
- const defaultWarehouse = ref <WarehouseVO >(undefined ) // 默认仓库
163
167
164
168
/** 初始化设置出库项 */
165
169
watch (
@@ -179,7 +183,13 @@ watch(
179
183
}
180
184
// 循环处理
181
185
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
+ }
183
193
})
184
194
},
185
195
{ deep: true }
@@ -189,12 +199,12 @@ watch(
189
199
const getSummaries = (param : SummaryMethodProps ) => {
190
200
const { columns, data } = param
191
201
const sums: string [] = []
192
- columns .forEach ((column , index ) => {
202
+ columns .forEach ((column , index : number ) => {
193
203
if (index === 0 ) {
194
204
sums [index ] = ' 合计'
195
205
return
196
206
}
197
- if ([' count' , ' totalPrice' ].includes (column .property )) {
207
+ if ([' count' , ' totalProductPrice ' , ' taxPrice ' , ' totalPrice' ].includes (column .property )) {
198
208
const sum = getSumValue (data .map ((item ) => Number (item [column .property ])))
199
209
sums [index ] =
200
210
column .property === ' count' ? erpCountInputFormatter (sum ) : erpPriceInputFormatter (sum )
@@ -210,30 +220,26 @@ const getSummaries = (param: SummaryMethodProps) => {
210
220
const handleAdd = () => {
211
221
const row = {
212
222
id: undefined ,
213
- warehouseId: defaultWarehouse .value ?.id ,
214
223
productId: undefined ,
215
224
productUnitName: undefined , // 产品单位
216
225
productBarCode: undefined , // 产品条码
217
226
productPrice: undefined ,
218
227
stockCount: undefined ,
219
228
count: 1 ,
229
+ totalProductPrice: undefined ,
230
+ taxPercent: undefined ,
231
+ taxPrice: undefined ,
220
232
totalPrice: undefined ,
221
233
remark: undefined
222
234
}
223
235
formData .value .push (row )
224
236
}
225
237
226
238
/** 删除按钮操作 */
227
- const handleDelete = (index ) => {
239
+ const handleDelete = (index : number ) => {
228
240
formData .value .splice (index , 1 )
229
241
}
230
242
231
- /** 处理仓库变更 */
232
- const onChangeWarehouse = (warehouseId , row ) => {
233
- // 加载库存
234
- setStockCount (row )
235
- }
236
-
237
243
/** 处理产品变更 */
238
244
const onChangeProduct = (productId , row ) => {
239
245
const product = productList .value .find ((item ) => item .id === productId )
@@ -247,12 +253,12 @@ const onChangeProduct = (productId, row) => {
247
253
}
248
254
249
255
/** 加载库存 */
250
- const setStockCount = async (row ) => {
251
- if (! row .productId || ! row . warehouseId ) {
256
+ const setStockCount = async (row : any ) => {
257
+ if (! row .productId ) {
252
258
return
253
259
}
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
256
262
}
257
263
258
264
/** 表单校验 */
@@ -264,8 +270,6 @@ defineExpose({ validate })
264
270
/** 初始化 */
265
271
onMounted (async () => {
266
272
productList .value = await ProductApi .getProductSimpleList ()
267
- warehouseList .value = await WarehouseApi .getWarehouseSimpleList ()
268
- defaultWarehouse .value = warehouseList .value .find ((item ) => item .defaultStatus )
269
273
// 默认添加一个
270
274
if (formData .value .length === 0 ) {
271
275
handleAdd ()
0 commit comments