| | |
| | | import { Input, InputNumber, Select } from 'ant-design-vue'; |
| | | |
| | | import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { getProductSimpleList } from '#/api/erp/product/product'; |
| | | import { getWarehouseStockCount } from '#/api/erp/stock/stock'; |
| | | import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse'; |
| | | |
| | |
| | | ]); |
| | | |
| | | const tableData = ref<ErpPurchaseReturnApi.PurchaseReturnItem[]>([]); // 表格数据 |
| | | const productOptions = ref<any[]>([]); // 产品下拉选项 |
| | | const warehouseOptions = ref<any[]>([]); // 仓库下拉选项 |
| | | |
| | | /** 获取表格合计数据 */ |
| | |
| | | /** 处理行数据变更 */ |
| | | function handleRowChange(row: any) { |
| | | // TODO 芋艿 |
| | | recalcRow(row); |
| | | const index = tableData.value.findIndex((item) => item.seq === row.seq); |
| | | if (index === -1) { |
| | | tableData.value.push(row); |
| | |
| | | emit('update:items', [...tableData.value]); |
| | | } |
| | | |
| | | /** 初始化行数据 */ |
| | | function initRow(row: ErpPurchaseReturnApi.PurchaseReturnItem) { |
| | | /** |
| | | * 重算行金额(单价为**含税**单价) |
| | | * 含税金额 = 含税单价 × 数量;税额 = 含税金额 × 税率;不含税金额 = 含税金额 - 税额 |
| | | */ |
| | | function recalcRow(row: ErpPurchaseReturnApi.PurchaseReturnItem) { |
| | | if (row.productPrice && row.count) { |
| | | row.totalProductPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0; |
| | | const taxInclusivePrice = erpPriceMultiply(row.productPrice, row.count) ?? 0; |
| | | row.taxPrice = |
| | | erpPriceMultiply(row.totalProductPrice, (row.taxPercent || 0) / 100) ?? 0; |
| | | row.totalPrice = row.totalProductPrice + row.taxPrice; |
| | | erpPriceMultiply(taxInclusivePrice, (row.taxPercent || 0) / 100) ?? 0; |
| | | row.totalProductPrice = taxInclusivePrice - row.taxPrice; |
| | | row.totalPrice = taxInclusivePrice; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 初始化行数据 |
| | | * 已有单据的明细行(带 id)沿用后端返回的金额,避免历史单据被新口径覆盖; |
| | | * 只有未保存的新增行才按新口径重算。 |
| | | */ |
| | | function initRow(row: ErpPurchaseReturnApi.PurchaseReturnItem) { |
| | | if (!row.id) { |
| | | recalcRow(row); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | /** 初始化 */ |
| | | onMounted(async () => { |
| | | productOptions.value = await getProductSimpleList(); |
| | | warehouseOptions.value = await getWarehouseSimpleList(); |
| | | }); |
| | | </script> |
| | |
| | | /> |
| | | </template> |
| | | <template #productId="{ row }"> |
| | | <Select |
| | | disabled |
| | | v-model:value="row.productId" |
| | | :options="productOptions" |
| | | :field-names="{ label: 'name', value: 'id' }" |
| | | class="w-full" |
| | | placeholder="请选择产品" |
| | | show-search |
| | | /> |
| | | <span>{{ row.productName || '-' }}</span> |
| | | </template> |
| | | <template #count="{ row }"> |
| | | <InputNumber |
| | |
| | | <div class="flex space-x-4"> |
| | | <span>数量:{{ erpCountInputFormatter(summaries.count) }}</span> |
| | | <span> |
| | | 金额:{{ erpPriceInputFormatter(summaries.totalProductPrice) }} |
| | | 不含税金额:{{ erpPriceInputFormatter(summaries.totalProductPrice) }} |
| | | </span> |
| | | <span>税额:{{ erpPriceInputFormatter(summaries.taxPrice) }}</span> |
| | | <span> |
| | | 税额合计:{{ erpPriceInputFormatter(summaries.totalPrice) }} |
| | | 含税合计:{{ erpPriceInputFormatter(summaries.totalPrice) }} |
| | | </span> |
| | | </div> |
| | | </div> |