| | |
| | | erpPriceMultiply, |
| | | } from '@vben/utils'; |
| | | |
| | | import { Input, InputNumber, Select, Switch } from 'ant-design-vue'; |
| | | import { Input, InputNumber, Switch } from 'ant-design-vue'; |
| | | |
| | | import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { getItemPage } from '#/api/mdm/item'; |
| | | import { MdmItemSelect } from '#/views/basicData/mdm/components'; |
| | | |
| | | import { useFormItemColumns } from '../data'; |
| | | |
| | |
| | | ]); |
| | | |
| | | const tableData = ref<ErpPurchaseOrderApi.PurchaseOrderItem[]>([]); // 表格数据 |
| | | const productOptions = ref<MdmItemApi.Item[]>([]); // 产品下拉选项 |
| | | |
| | | /** 获取表格合计数据 */ |
| | | const summaries = computed(() => { |
| | |
| | | } |
| | | |
| | | /** 处理产品变更 */ |
| | | async function handleProductChange(productId: any, row: any) { |
| | | const product = productOptions.value.find((p) => p.id === productId); |
| | | if (!product) { |
| | | function handleProductChange(item: MdmItemApi.Item | undefined, row: any) { |
| | | if (!item?.id) { |
| | | return; |
| | | } |
| | | row.productId = productId; |
| | | row.productUnitId = product.unitMeasureId; |
| | | row.productUnitName = product.unitMeasureName; |
| | | row.productName = product.name; |
| | | row.productPrice = product.purchasePrice || 0; |
| | | row.productId = item.id; |
| | | row.productUnitId = item.unitMeasureId; |
| | | row.productUnitName = item.unitMeasureName; |
| | | row.productName = item.name; |
| | | row.productPrice = item.purchasePrice || 0; |
| | | row.count = row.count || 1; |
| | | handleRowChange(row); |
| | | } |
| | |
| | | }); |
| | | |
| | | /** 初始化 */ |
| | | onMounted(async () => { |
| | | const res = await getItemPage({ pageNo: 1, pageSize: 100, status: 0 }); |
| | | productOptions.value = res.list || []; |
| | | onMounted(() => { |
| | | // 目的:新增时,默认添加一行 |
| | | if (tableData.value.length === 0) { |
| | | handleAdd(); |
| | |
| | | <template> |
| | | <Grid class="w-full"> |
| | | <template #productId="{ row }"> |
| | | <Select |
| | | <MdmItemSelect |
| | | v-if="!disabled" |
| | | v-model:value="row.productId" |
| | | :options="productOptions" |
| | | :field-names="{ label: 'name', value: 'id' }" |
| | | class="w-full" |
| | | v-model:model-value="row.productId" |
| | | :label="row.productName" |
| | | placeholder="请选择产品" |
| | | show-search |
| | | @change="handleProductChange($event, row)" |
| | | @change="(item) => handleProductChange(item, row)" |
| | | /> |
| | | <span v-else>{{ row.productName || '-' }}</span> |
| | | </template> |