| | |
| | | |
| | | const open = ref(false); // 弹窗是否打开 |
| | | const multiple = ref(true); // 是否多选 |
| | | const selectedRows = ref<MesMdItemApi.Item[]>([]); // 已选物料列表 |
| | | const selectedRows = ref<MesMdItemApi.Item[]>([]); // 已选品种列表 |
| | | const selectedItemTypeId = ref<number>(); // 当前筛选分类编号 |
| | | const preSelectedIds = ref<number[]>([]); // 预选物料编号列表 |
| | | const productIds = ref<number[]>([]); // 限定可选的物料编号列表(为空则不限制) |
| | | const typeTreeRef = ref<InstanceType<typeof MdItemTypeTree>>(); // 物料分类树 |
| | | const preSelectedIds = ref<number[]>([]); // 预选品种编号列表 |
| | | const productIds = ref<number[]>([]); // 限定可选的品种编号列表(为空则不限制) |
| | | const typeTreeRef = ref<InstanceType<typeof MdItemTypeTree>>(); // 品种分类树 |
| | | |
| | | /** 获取当前表格数据 */ |
| | | function getTableRows() { |
| | |
| | | handleConfirm(); |
| | | } |
| | | |
| | | /** 按分类筛选物料 */ |
| | | /** 按分类筛选品种 */ |
| | | function handleItemTypeNodeClick(row: MesMdItemTypeApi.ItemType | undefined) { |
| | | selectedItemTypeId.value = row?.id; |
| | | gridApi.query(); |
| | | } |
| | | |
| | | /** 回显预选物料 */ |
| | | /** 回显预选品种 */ |
| | | async function applyPreSelection() { |
| | | if (preSelectedIds.value.length === 0) { |
| | | return; |
| | |
| | | itemTypeId: selectedItemTypeId.value, |
| | | status: CommonStatusEnum.ENABLE, |
| | | }; |
| | | // 限定可选物料范围 |
| | | // 限定可选品种范围 |
| | | if (productIds.value.length > 0) { |
| | | params.pageSize = 1000; |
| | | params.ids = productIds.value.join(','); |
| | |
| | | await gridApi.formApi.resetForm(); |
| | | } |
| | | |
| | | /** 打开物料选择弹窗 */ |
| | | /** 打开品种选择弹窗 */ |
| | | async function openModal( |
| | | selectedIds?: number[], |
| | | options?: { multiple?: boolean; productIds?: number[] } |
| | |
| | | await applyPreSelection(); |
| | | } |
| | | |
| | | /** 关闭物料选择弹窗 */ |
| | | /** 关闭品种选择弹窗 */ |
| | | async function closeModal() { |
| | | open.value = false; |
| | | await resetQueryState(); |
| | | } |
| | | |
| | | /** 确认选择物料 */ |
| | | /** 确认选择品种 */ |
| | | function handleConfirm() { |
| | | const rows = multiple.value ? getMultipleSelectedRows() : selectedRows.value; |
| | | if (rows.length === 0) { |
| | |
| | | |
| | | <template> |
| | | <Modal v-model:open="open" |
| | | title="物料产品选择" |
| | | title="品种产品选择" |
| | | width="80%" |
| | | :destroy-on-close="true" |
| | | @ok="handleConfirm" |
| | |
| | | @node-click="handleItemTypeNodeClick" /> |
| | | </Card> |
| | | <div class="w-4/5"> |
| | | <Grid table-title="物料产品列表" /> |
| | | <Grid table-title="品种产品列表" /> |
| | | </div> |
| | | </div> |
| | | </Modal> |