| | |
| | | <script lang="ts" setup> |
| | | import type { ErpProductApi } from '#/api/erp/product/product'; |
| | | import type { MdmItemApi } from '#/api/mdm/item'; |
| | | import type { ErpPurchaseOrderApi } from '#/api/erp/purchase/order'; |
| | | |
| | | import { computed, nextTick, onMounted, ref, watch } from 'vue'; |
| | |
| | | erpCountInputFormatter, |
| | | erpPriceInputFormatter, |
| | | erpPriceMultiply, |
| | | } from '..\..\..\..\..\packages\utils\src'; |
| | | } from '@vben/utils'; |
| | | |
| | | import { Input, InputNumber, Select } from 'ant-design-vue'; |
| | | import { Input, InputNumber, Select, Switch } from 'ant-design-vue'; |
| | | |
| | | import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { getProductSimpleList } from '#/api/erp/product/product'; |
| | | import { getStockCount } from '#/api/erp/stock/stock'; |
| | | import { getItemPage } from '#/api/mdm/item'; |
| | | |
| | | import { useFormItemColumns } from '../data'; |
| | | |
| | |
| | | ]); |
| | | |
| | | const tableData = ref<ErpPurchaseOrderApi.PurchaseOrderItem[]>([]); // 表格数据 |
| | | const productOptions = ref<ErpProductApi.Product[]>([]); // 产品下拉选项 |
| | | const productOptions = ref<MdmItemApi.Item[]>([]); // 产品下拉选项 |
| | | |
| | | /** 获取表格合计数据 */ |
| | | const summaries = computed(() => { |
| | |
| | | const newRow = { |
| | | id: undefined, |
| | | productId: undefined, |
| | | productUnitName: undefined, // 产品单位 |
| | | productBarCode: undefined, // 产品条码 |
| | | productUnitName: undefined, |
| | | productPrice: undefined, |
| | | stockCount: undefined, |
| | | count: 1, |
| | | totalProductPrice: undefined, |
| | | taxPercent: 0, |
| | | taxPrice: undefined, |
| | | totalPrice: undefined, |
| | | remark: undefined, |
| | | qcCheckFlag: false, |
| | | }; |
| | | tableData.value.push(newRow); |
| | | // 通知父组件更新 |
| | |
| | | return; |
| | | } |
| | | row.productId = productId; |
| | | row.productUnitId = product.unitId; |
| | | row.productBarCode = product.barCode; |
| | | row.productUnitName = product.unitName; |
| | | row.productUnitId = product.unitMeasureId; |
| | | row.productUnitName = product.unitMeasureName; |
| | | row.productName = product.name; |
| | | row.stockCount = (await getStockCount(productId)) || 0; |
| | | row.productPrice = product.purchasePrice || 0; |
| | | row.count = row.count || 1; |
| | | handleRowChange(row); |
| | |
| | | |
| | | /** 初始化 */ |
| | | onMounted(async () => { |
| | | productOptions.value = await getProductSimpleList(); |
| | | const res = await getItemPage({ pageNo: 1, pageSize: 100, status: 0 }); |
| | | productOptions.value = res.list || []; |
| | | // 目的:新增时,默认添加一行 |
| | | if (tableData.value.length === 0) { |
| | | handleAdd(); |
| | |
| | | <Grid class="w-full"> |
| | | <template #productId="{ row }"> |
| | | <Select |
| | | v-if="!disabled" |
| | | v-model:value="row.productId" |
| | | :options="productOptions" |
| | | :field-names="{ label: 'name', value: 'id' }" |
| | |
| | | show-search |
| | | @change="handleProductChange($event, row)" |
| | | /> |
| | | <span v-else>{{ row.productName || '-' }}</span> |
| | | </template> |
| | | <template #count="{ row }"> |
| | | <InputNumber |
| | |
| | | <Input v-if="!disabled" v-model:value="row.remark" class="w-full" /> |
| | | <span v-else>{{ row.remark || '-' }}</span> |
| | | </template> |
| | | <template #qcCheckFlag="{ row }"> |
| | | <Switch |
| | | v-if="!disabled" |
| | | v-model:checked="row.qcCheckFlag" |
| | | checked-children="是" |
| | | un-checked-children="否" |
| | | @change="handleRowChange(row)" |
| | | /> |
| | | <span v-else>{{ row.qcCheckFlag ? '是' : '否' }}</span> |
| | | </template> |
| | | <template #taxPercent="{ row }"> |
| | | <InputNumber |
| | | v-if="!disabled" |