Skip to content

Commit 8a70b3f

Browse files
committed
✨ ERP:付款单 60%(接入)【可付款的采购入库单列表】
1 parent d7427bf commit 8a70b3f

File tree

5 files changed

+248
-25
lines changed

5 files changed

+248
-25
lines changed

src/utils/constants.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,14 @@ export const TradeOrderStatusEnum = {
418418
name: '已取消'
419419
}
420420
}
421+
422+
// ========== ERP - 企业资源计划 ==========
423+
424+
export const ErpBizType = {
425+
PURCHASE_ORDER: 10,
426+
PURCHASE_IN: 11,
427+
PURCHASE_RETURN: 12,
428+
SALE_ORDER: 20,
429+
SALE_OUT: 21,
430+
SALE_RETURN: 22
431+
}

src/views/erp/finance/payment/FinancePaymentForm.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
<el-tab-pane label="采购入库、退货单" name="item">
8484
<FinancePaymentItemForm
8585
ref="itemFormRef"
86+
:supplier-id="formData.supplierId"
8687
:items="formData.items"
8788
:disabled="disabled"
8889
/>
@@ -196,11 +197,9 @@ watch(
196197
if (!val) {
197198
return
198199
}
199-
const totalPrice = val.items.reduce((prev, curr) => prev + curr.totalPrice, 0)
200-
const discountPrice =
201-
val.discountPercent != null ? erpPriceMultiply(totalPrice, val.discountPercent / 100.0) : 0
202-
formData.value.discountPrice = discountPrice
203-
formData.value.totalPrice = totalPrice - discountPrice
200+
const totalPrice = val.items.reduce((prev, curr) => prev + curr.paymentPrice, 0)
201+
formData.value.totalPrice = totalPrice
202+
formData.value.paymentPrice = totalPrice - val.discountPrice
204203
},
205204
{ deep: true }
206205
)

src/views/erp/finance/payment/components/FinancePaymentItemForm.vue

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,29 @@
5959
</el-table>
6060
</el-form>
6161
<el-row justify="center" class="mt-3" v-if="!disabled">
62-
<el-button @click="handleAdd" round>+ 添加采购入库单</el-button>
62+
<el-button @click="handleOpenPurchaseIn" round>+ 添加采购入库单</el-button>
6363
<el-button @click="handleAdd" round>+ 添加采购退货单</el-button>
6464
</el-row>
65+
66+
<PurchaseInPaymentEnableList
67+
ref="purchaseInPaymentEnableListRef"
68+
@success="handleAddPurchaseIn"
69+
/>
6570
</template>
6671
<script setup lang="ts">
67-
import { ProductApi, ProductVO } from '@/api/erp/product/product'
68-
import { StockApi } from '@/api/erp/stock/stock'
69-
import {
70-
erpCountInputFormatter,
71-
erpPriceInputFormatter,
72-
erpPriceMultiply,
73-
getSumValue
74-
} from '@/utils'
72+
import { ProductVO } from '@/api/erp/product/product'
73+
import { erpPriceInputFormatter, getSumValue } from '@/utils'
74+
import PurchaseInPaymentEnableList from '@/views/erp/purchase/in/components/PurchaseInPaymentEnableList.vue'
75+
import { PurchaseInVO } from '@/api/erp/purchase/in'
76+
import { ErpBizType } from '@/utils/constants'
7577
7678
const props = defineProps<{
7779
items: undefined
80+
supplierId: undefined
7881
disabled: false
7982
}>()
83+
const message = useMessage()
84+
8085
const formLoading = ref(false) // 表单的加载中
8186
const formData = ref([])
8287
const formRules = reactive({
@@ -114,17 +119,26 @@ const getSummaries = (param: SummaryMethodProps) => {
114119
return sums
115120
}
116121
117-
/** 新增按钮操作 */
118-
const handleAdd = () => {
119-
const row = {
120-
id: undefined,
121-
totalPrice: undefined,
122-
paidPrice: undefined,
123-
paymentPrice: undefined,
124-
totalPrice: undefined,
125-
remark: undefined
122+
/** 新增【采购入库】按钮操作 */
123+
const purchaseInPaymentEnableListRef = ref()
124+
const handleOpenPurchaseIn = () => {
125+
if (!props.supplierId) {
126+
message.error('请选择供应商')
127+
return
126128
}
127-
formData.value.push(row)
129+
purchaseInPaymentEnableListRef.value.open(props.supplierId)
130+
}
131+
const handleAddPurchaseIn = (rows: PurchaseInVO[]) => {
132+
rows.forEach((row) => {
133+
formData.value.push({
134+
bizId: row.id,
135+
bizType: ErpBizType.PURCHASE_IN,
136+
bizNo: row.no,
137+
totalPrice: row.totalPrice,
138+
paidPrice: row.paymentPrice,
139+
paymentPrice: row.totalPrice - row.paymentPrice
140+
})
141+
})
128142
}
129143
130144
/** 删除按钮操作 */
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
<!-- 可付款的采购入库单列表 -->
2+
<template>
3+
<Dialog
4+
title="选择采购入库(仅展示可付款)"
5+
v-model="dialogVisible"
6+
:appendToBody="true"
7+
:scroll="true"
8+
width="1080"
9+
>
10+
<ContentWrap>
11+
<!-- 搜索工作栏 -->
12+
<el-form
13+
class="-mb-15px"
14+
:model="queryParams"
15+
ref="queryFormRef"
16+
:inline="true"
17+
label-width="68px"
18+
>
19+
<el-form-item label="入库单号" prop="no">
20+
<el-input
21+
v-model="queryParams.no"
22+
placeholder="请输入入库单号"
23+
clearable
24+
@keyup.enter="handleQuery"
25+
class="!w-160px"
26+
/>
27+
</el-form-item>
28+
<el-form-item label="产品" prop="productId">
29+
<el-select
30+
v-model="queryParams.productId"
31+
clearable
32+
filterable
33+
placeholder="请选择产品"
34+
class="!w-160px"
35+
>
36+
<el-option
37+
v-for="item in productList"
38+
:key="item.id"
39+
:label="item.name"
40+
:value="item.id"
41+
/>
42+
</el-select>
43+
</el-form-item>
44+
<el-form-item label="入库时间" prop="orderTime">
45+
<el-date-picker
46+
v-model="queryParams.inTime"
47+
value-format="YYYY-MM-DD HH:mm:ss"
48+
type="daterange"
49+
start-placeholder="开始日期"
50+
end-placeholder="结束日期"
51+
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
52+
class="!w-160px"
53+
/>
54+
</el-form-item>
55+
<el-form-item>
56+
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
57+
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
58+
</el-form-item>
59+
</el-form>
60+
</ContentWrap>
61+
62+
<ContentWrap>
63+
<el-table
64+
v-loading="loading"
65+
:data="list"
66+
:show-overflow-tooltip="true"
67+
:stripe="true"
68+
@selection-change="handleSelectionChange"
69+
>
70+
<el-table-column width="30" label="选择" type="selection" />
71+
<el-table-column min-width="180" label="入库单号" align="center" prop="no" />
72+
<el-table-column label="供应商" align="center" prop="supplierName" />
73+
<el-table-column label="产品信息" align="center" prop="productNames" min-width="200" />
74+
<el-table-column
75+
label="入库时间"
76+
align="center"
77+
prop="inTime"
78+
:formatter="dateFormatter2"
79+
width="120px"
80+
/>
81+
<el-table-column label="创建人" align="center" prop="creatorName" />
82+
<el-table-column
83+
label="应付金额"
84+
align="center"
85+
prop="totalPrice"
86+
:formatter="erpPriceTableColumnFormatter"
87+
/>
88+
<el-table-column
89+
label="已付金额"
90+
align="center"
91+
prop="paymentPrice"
92+
:formatter="erpPriceTableColumnFormatter"
93+
/>
94+
<el-table-column label="未付金额" align="center">
95+
<template #default="scope">
96+
<span v-if="scope.row.paymentPrice === scope.row.totalPrice">0</span>
97+
<el-tag type="danger" v-else>
98+
{{ erpPriceInputFormatter(scope.row.totalPrice - scope.row.paymentPrice) }}
99+
</el-tag>
100+
</template>
101+
</el-table-column>
102+
</el-table>
103+
<!-- 分页 -->
104+
<Pagination
105+
v-model:limit="queryParams.pageSize"
106+
v-model:page="queryParams.pageNo"
107+
:total="total"
108+
@pagination="getList"
109+
/>
110+
</ContentWrap>
111+
<template #footer>
112+
<el-button :disabled="!selectionList.length" type="primary" @click="submitForm">
113+
确 定
114+
</el-button>
115+
<el-button @click="dialogVisible = false">取 消</el-button>
116+
</template>
117+
</Dialog>
118+
</template>
119+
<script lang="ts" setup>
120+
import { ElTable } from 'element-plus'
121+
import { dateFormatter2 } from '@/utils/formatTime'
122+
import { erpPriceInputFormatter, erpPriceTableColumnFormatter } from '@/utils'
123+
import { ProductApi, ProductVO } from '@/api/erp/product/product'
124+
import { PurchaseInApi, PurchaseInVO } from '@/api/erp/purchase/in'
125+
126+
defineOptions({ name: 'PurchaseInPaymentEnableList' })
127+
128+
const list = ref<PurchaseInVO[]>([]) // 列表的数据
129+
const total = ref(0) // 列表的总页数
130+
const loading = ref(false) // 列表的加载中
131+
const dialogVisible = ref(false) // 弹窗的是否展示
132+
const queryParams = reactive({
133+
pageNo: 1,
134+
pageSize: 10,
135+
no: undefined,
136+
productId: undefined,
137+
inTime: [],
138+
paymentEnable: true,
139+
supplierId: undefined
140+
})
141+
const queryFormRef = ref() // 搜索的表单
142+
const productList = ref<ProductVO[]>([]) // 产品列表
143+
144+
/** 选中操作 */
145+
const selectionList = ref<PurchaseInVO[]>([])
146+
const handleSelectionChange = (rows: PurchaseInVO[]) => {
147+
selectionList.value = rows
148+
}
149+
150+
/** 打开弹窗 */
151+
const open = async (supplierId: number) => {
152+
dialogVisible.value = true
153+
await nextTick() // 等待,避免 queryFormRef 为空
154+
// 加载可入库的订单列表
155+
queryParams.supplierId = supplierId
156+
await resetQuery()
157+
// 加载产品列表
158+
productList.value = await ProductApi.getProductSimpleList()
159+
}
160+
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
161+
162+
/** 提交选择 */
163+
const emits = defineEmits<{
164+
(e: 'success', value: PurchaseInVO[]): void
165+
}>()
166+
const submitForm = () => {
167+
try {
168+
emits('success', selectionList.value)
169+
} finally {
170+
// 关闭弹窗
171+
dialogVisible.value = false
172+
}
173+
}
174+
175+
/** 加载列表 */
176+
const getList = async () => {
177+
loading.value = true
178+
try {
179+
const data = await PurchaseInApi.getPurchaseInPage(queryParams)
180+
list.value = data.list
181+
total.value = data.total
182+
} finally {
183+
loading.value = false
184+
}
185+
}
186+
187+
/** 重置按钮操作 */
188+
const resetQuery = () => {
189+
queryFormRef.value.resetFields()
190+
handleQuery()
191+
}
192+
193+
/** 搜索按钮操作 */
194+
const handleQuery = () => {
195+
queryParams.pageNo = 1
196+
selectionList.value = []
197+
getList()
198+
}
199+
</script>

src/views/erp/purchase/order/components/PurchaseOrderInEnableList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
</template>
7474
</el-table-column>
7575
<el-table-column min-width="180" label="订单单号" align="center" prop="no" />
76-
<el-table-column label="客户" align="center" prop="supplierName" />
76+
<el-table-column label="供应商" align="center" prop="supplierName" />
7777
<el-table-column label="产品信息" align="center" prop="productNames" min-width="200" />
7878
<el-table-column
7979
label="订单时间"

0 commit comments

Comments
 (0)