SupplierDetails.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <div inert="true">
  3. <a-range-picker v-model:value="date" />
  4. <div v-if="supplier">
  5. <h1>{{ supplier.name }}</h1> <!-- 添加企业名称 -->
  6. <p>地址: {{ supplier.address }}</p> <!-- 添加企业地址 -->
  7. <p>联系方式: {{ supplier.contact }}</p> <!-- 添加联系方式 -->
  8. </div>
  9. </div>
  10. </template>
  11. <script lang="ts" setup>
  12. import { ref, watch } from 'vue';
  13. import { getCompanyInfo } from '../customsData.api'; // Adjust the import based on your API structure
  14. import type { Dayjs } from 'dayjs';
  15. type RangeValue = [Dayjs, Dayjs];
  16. const date = ref<RangeValue>();
  17. const props = defineProps({
  18. supplierId: {
  19. type: String,
  20. required: true,
  21. },
  22. });
  23. const supplier = ref<{ name: string; address: string; contact: string } | null>(null);
  24. const loading = ref(true);
  25. const fetchSupplierDetails = async () => {
  26. loading.value = true;
  27. const params = {
  28. source_type: 1,
  29. data_source: ['IMP_AMERICA_BL_SEA'],
  30. date: [20230101, 20230630],
  31. com_id:props.supplierId,
  32. com_role: 2,
  33. }
  34. const response = await getCompanyInfo(params);
  35. supplier.value = response.result.data.result; // Adjust based on your API response structure
  36. loading.value = false;
  37. };
  38. // Watch for changes in supplierId prop
  39. watch(() => props.supplierId, (newId) => {
  40. if (newId) {
  41. fetchSupplierDetails();
  42. }
  43. });
  44. </script>
  45. <style scoped lang="less">
  46. .supplier-details {
  47. padding: 20px;
  48. }
  49. </style>