| | |
| | | |
| | | import { computed, ref, useAttrs, watch, watchEffect } from 'vue'; |
| | | |
| | | import { Select, SelectOption, Tag, Tooltip } from 'ant-design-vue'; |
| | | import { Select, SelectOption, Tooltip } from 'ant-design-vue'; |
| | | |
| | | import { getWarehouseLocationSimpleList } from '#/api/mes/wm/warehouse/location'; |
| | | |
| | |
| | | }, |
| | | ); |
| | | |
| | | /** 仓库变更或初始化时重新加载库区列表 */ |
| | | /** 仓库变更时清空已选库区并重新加载列表 */ |
| | | watchEffect(async () => { |
| | | if (!props.warehouseId) { |
| | | allList.value = []; |
| | | return; |
| | | } |
| | | allList.value = await getWarehouseLocationSimpleList(props.warehouseId); |
| | | if (props.modelValue !== null) { |
| | | selectedItem.value = allList.value.find((o) => o.id === props.modelValue); |
| | | // 仓库变更时清空已选的库区 |
| | | if (props.modelValue !== null && props.modelValue !== undefined) { |
| | | const stillExists = allList.value.find((o) => o.id === props.modelValue); |
| | | if (!stillExists) { |
| | | selectedItem.value = undefined; |
| | | emit('update:modelValue', undefined); |
| | | emit('change', undefined); |
| | | } |
| | | } |
| | | }); |
| | | </script> |
| | |
| | | :disabled="disabled" |
| | | :filter-option="filterOption" |
| | | :placeholder="placeholder" |
| | | :popup-match-select-width="false" |
| | | show-search |
| | | @change="handleChange" |
| | | > |
| | | <SelectOption v-for="item in allList" :key="item.id" :value="item.id"> |
| | | <div class="flex items-center gap-2"> |
| | | <span>{{ item.name }}</span> |
| | | <Tag v-if="item.code" color="blue">编号: {{ item.code }}</Tag> |
| | | </div> |
| | | {{ item.name }} |
| | | </SelectOption> |
| | | </Select> |
| | | </Tooltip> |