| | |
| | | import type { MdmItemApi } from '#/api/mdm/item'; |
| | | import type { CrmSaleQuotationApi } from '#/api/crm/saleQuotation'; |
| | | |
| | | import { computed, onMounted, ref } from 'vue'; |
| | | import { computed, ref } from 'vue'; |
| | | |
| | | import { erpPriceMultiply } from '#/packages/utils/src'; |
| | | |
| | | import { InputNumber, Select } from 'ant-design-vue'; |
| | | import { InputNumber } from 'ant-design-vue'; |
| | | |
| | | import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { getItemPage } from '#/api/mdm/item'; |
| | | import MdmItemSelect from '#/views/basicData/mdm/components/select.vue'; |
| | | |
| | | import { useItemColumns } from '../data'; |
| | | |
| | |
| | | const emit = defineEmits(['change']); |
| | | |
| | | const tableData = ref<CrmSaleQuotationApi.SaleQuotationItem[]>([]); |
| | | const itemOptions = ref<MdmItemApi.Item[]>([]); |
| | | const selectedItem = ref<MdmItemApi.Item>(); |
| | | |
| | | /** 获取表格合计数据 */ |
| | | const summaries = computed(() => { |
| | |
| | | } |
| | | } |
| | | |
| | | /** 处理物料变更 */ |
| | | function handleItemChange(itemId: number, row: any) { |
| | | const item = itemOptions.value.find((p) => p.id === itemId); |
| | | /** 处理产品变更 */ |
| | | function handleItemChange(item: MdmItemApi.Item | undefined, row: any) { |
| | | if (!item) { |
| | | row.itemId = undefined; |
| | | row.itemName = undefined; |
| | | row.itemCode = undefined; |
| | | row.itemBarCode = undefined; |
| | | row.itemSpecification = undefined; |
| | | row.itemUnitName = undefined; |
| | | row.itemUnitName2 = undefined; |
| | | row.itemUnitName3 = undefined; |
| | | row.itemPrice = undefined; |
| | | row.quotationPrice = undefined; |
| | | row.totalPrice = 0; |
| | | return; |
| | | } |
| | | row.itemId = itemId; |
| | | row.itemId = item.id; |
| | | row.itemName = item.name; |
| | | row.itemCode = item.code; |
| | | row.itemBarCode = item.barCode; |
| | |
| | | const item = tableData.value[i]; |
| | | if (item) { |
| | | if (!item.itemId) { |
| | | throw new Error(`第 ${i + 1} 行:物料不能为空`); |
| | | throw new Error(`第 ${i + 1} 行:产品不能为空`); |
| | | } |
| | | if (!item.count || item.count <= 0) { |
| | | throw new Error(`第 ${i + 1} 行:数量不能为空`); |
| | |
| | | getData, |
| | | resetData, |
| | | }); |
| | | |
| | | /** 初始化 */ |
| | | onMounted(async () => { |
| | | const res = await getItemPage({ pageNo: 1, pageSize: 100, status: 0 }); |
| | | itemOptions.value = res.list || []; |
| | | }); |
| | | </script> |
| | | |
| | | <template> |
| | | <Grid class="w-full"> |
| | | <template #itemId="{ row }"> |
| | | <Select |
| | | <MdmItemSelect |
| | | v-if="!disabled" |
| | | v-model:value="row.itemId" |
| | | :options="itemOptions" |
| | | :field-names="{ label: 'name', value: 'id' }" |
| | | class="w-full" |
| | | placeholder="请选择物料" |
| | | @change="(val) => handleItemChange(val, row)" |
| | | v-model:model-value="row.itemId" |
| | | :label="row.itemName" |
| | | placeholder="请选择产品" |
| | | @change="(item) => handleItemChange(item, row)" |
| | | /> |
| | | <span v-else>{{ row.itemName || '-' }}</span> |
| | | </template> |
| | |
| | | type: 'link', |
| | | danger: true, |
| | | popConfirm: { |
| | | title: '确认删除该物料吗?', |
| | | title: '确认删除该产品吗?', |
| | | confirm: handleDelete.bind(null, row), |
| | | }, |
| | | }, |
| | |
| | | class="mt-2 flex justify-center" |
| | | :actions="[ |
| | | { |
| | | label: '添加物料', |
| | | label: '添加产品', |
| | | type: 'default', |
| | | onClick: handleAdd, |
| | | }, |