| | |
| | | import type { CrmCustomerApi } from '#/api/crm/customer'; |
| | | |
| | | import { computed, ref, useAttrs, watch } from 'vue'; |
| | | import { useRoute } from 'vue-router'; |
| | | |
| | | import { IconifyIcon } from '@vben/icons'; |
| | | |
| | | import { Input, Tooltip } from 'ant-design-vue'; |
| | | |
| | | import { getCustomer } from '#/api/crm/customer'; |
| | | import { getBusinessCustomer, getCustomer } from '#/api/crm/customer'; |
| | | |
| | | import CrmCustomerSelectDialog from './crm-customer-select-dialog.vue'; |
| | | |
| | |
| | | const props = withDefaults( |
| | | defineProps<{ |
| | | allowClear?: boolean; |
| | | allCustomers?: boolean; |
| | | disabled?: boolean; |
| | | modelValue?: number; |
| | | placeholder?: string; |
| | |
| | | modelValue: undefined, |
| | | placeholder: '请选择客户', |
| | | }, |
| | | ); |
| | | const route = useRoute(); |
| | | const useAllCustomers = computed( |
| | | () => props.allCustomers ?? !String(route.path).startsWith('/crm/'), |
| | | ); |
| | | const emit = defineEmits<{ |
| | | change: [item: CrmCustomerApi.Customer | undefined]; |
| | |
| | | if (selectedItem.value?.id === id) { |
| | | return; |
| | | } |
| | | selectedItem.value = await getCustomer(id); |
| | | selectedItem.value = useAllCustomers.value |
| | | ? await getBusinessCustomer(id) |
| | | : await getCustomer(id); |
| | | } |
| | | |
| | | watch( |
| | |
| | | </Input> |
| | | </Tooltip> |
| | | </div> |
| | | <CrmCustomerSelectDialog ref="dialogRef" @selected="handleSelected" /> |
| | | <CrmCustomerSelectDialog |
| | | ref="dialogRef" |
| | | :all-customers="useAllCustomers" |
| | | @selected="handleSelected" |
| | | /> |
| | | </template> |