edit.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <div class="p-4">
  3. <!-- 页面标题和按钮 -->
  4. <div class="flex justify-between items-center mb-4">
  5. <div class="flex items-center gap-2">
  6. <el-button icon="ArrowLeft" @click="router.back()">返回</el-button>
  7. <span class="text-lg font-medium">客户详情</span>
  8. </div>
  9. </div>
  10. <!-- 菜单导航 -->
  11. <el-card shadow="never" class="mb-4">
  12. <el-menu :default-active="activeMenu" class="el-menu-demo" mode="horizontal" @select="handleSelect" :ellipsis="false">
  13. <el-menu-item index="baseInfo">基本信息</el-menu-item>
  14. <el-menu-item index="orgStructure">组织结构</el-menu-item>
  15. <el-menu-item index="contactInfo">联系人</el-menu-item>
  16. <el-menu-item index="shippingAddress">收货地址</el-menu-item>
  17. <el-menu-item index="contractManagement">合同管理</el-menu-item>
  18. <el-menu-item index="erpSaleInfo">ERP销售信息</el-menu-item>
  19. <!-- <el-menu-item index="procurementProfile">采购画像</el-menu-item>
  20. <el-menu-item index="operationLog">日志管理</el-menu-item> -->
  21. </el-menu>
  22. <!-- 动态组件显示区域 -->
  23. <component
  24. :is="currentComponent"
  25. :customer-id="customerId"
  26. :customer-no="customerNo"
  27. :customer-name="customerName"
  28. :is-view-mode="isViewMode"
  29. />
  30. </el-card>
  31. </div>
  32. </template>
  33. <script setup lang="ts" name="CustomerInfoEdit">
  34. const route = useRoute();
  35. const router = useRouter();
  36. const activeMenu = ref('baseInfo');
  37. const customerId = ref<string>('');
  38. const customerNo = ref<string>('');
  39. const customerName = ref<string>('');
  40. const isViewMode = ref(false); // 查看模式标志
  41. // 异步加载子组件
  42. const BaseInfo = defineAsyncComponent(() => import('@/views/customer/customerFile/customerInfo/overview/baseInfo.vue'));
  43. const OrgStructure = defineAsyncComponent(() => import('@/views/customer/customerFile/customerInfo/overview/orgStructure.vue'));
  44. const ContactInfo = defineAsyncComponent(() => import('@/views/customer/customerFile/customerInfo/overview/contactInfo.vue'));
  45. const ShippingAddress = defineAsyncComponent(() => import('@/views/customer/customerFile/customerInfo/overview/shippingAddress.vue'));
  46. const ContractManagement = defineAsyncComponent(() => import('@/views/customer/customerFile/customerInfo/overview/contractManagement.vue'));
  47. const ErpSaleInfo = defineAsyncComponent(() => import('@/views/customer/customerFile/customerInfo/overview/erpSaleInfo.vue'));
  48. // const ProcurementProfile = defineAsyncComponent(() => import('@/views/customer/customerFile/customerInfo/overview/procurementProfile.vue'));
  49. // const OperationLog = defineAsyncComponent(() => import('@/views/customer/customerFile/customerInfo/overview/operationLog.vue'));
  50. // 组件映射
  51. const componentMap: Record<string, any> = {
  52. baseInfo: BaseInfo,
  53. orgStructure: OrgStructure,
  54. contactInfo: ContactInfo,
  55. shippingAddress: ShippingAddress,
  56. contractManagement: ContractManagement,
  57. erpSaleInfo: ErpSaleInfo
  58. // procurementProfile: ProcurementProfile,
  59. // operationLog: OperationLog
  60. };
  61. const currentComponent = ref(componentMap['baseInfo']); // 默认显示基本信息
  62. // 菜单选择处理
  63. const handleSelect = (key: string) => {
  64. activeMenu.value = key;
  65. currentComponent.value = componentMap[key] || componentMap['baseInfo'];
  66. };
  67. // 初始化
  68. onMounted(async () => {
  69. const id = route.query.id;
  70. if (id) {
  71. customerId.value = id as string;
  72. // 加载客户基本信息获取客户编号
  73. await loadCustomerNo(id as string);
  74. }
  75. // 如果URL中有tab参数,则显示对应的tab
  76. const tab = route.query.tab;
  77. if (tab && componentMap[tab as string]) {
  78. activeMenu.value = tab as string;
  79. currentComponent.value = componentMap[tab as string];
  80. }
  81. // 判断是否为查看模式
  82. const status = route.query.status;
  83. if (status === 'view') {
  84. isViewMode.value = true;
  85. }
  86. });
  87. // 加载客户编号
  88. const loadCustomerNo = async (id: string) => {
  89. try {
  90. const { getCustomerInfo } = await import('@/api/customer/customerFile/customerInfo');
  91. const res = await getCustomerInfo(id);
  92. customerNo.value = res.data.customerNo || '';
  93. customerName.value = res.data.customerName || '';
  94. } catch (error) {
  95. console.error('加载客户编号失败:', error);
  96. }
  97. };
  98. </script>
  99. <style scoped>
  100. .el-menu-demo {
  101. border-bottom: none;
  102. }
  103. </style>