index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <!-- TODO 芋艿:要不要把 3 到 62 合并成一个组件 -->
  3. <div v-loading="loading">
  4. <div class="flex items-start justify-between">
  5. <div>
  6. <!-- 左上:客户基本信息 -->
  7. <ContactBasicInfo :contact="contact" />
  8. </div>
  9. <div>
  10. <!-- 右上:按钮 -->
  11. <el-button @click="openForm('update', contact.id)" v-hasPermi="['crm:contact:update']">
  12. 编辑
  13. </el-button>
  14. </div>
  15. </div>
  16. <el-row class="mt-10px">
  17. <el-button>
  18. <Icon icon="ph:calendar-fill" class="mr-5px" />
  19. 创建任务
  20. </el-button>
  21. <el-button>
  22. <Icon icon="carbon:email" class="mr-5px" />
  23. 发送邮件
  24. </el-button>
  25. <el-button>
  26. <Icon icon="system-uicons:contacts" class="mr-5px" />
  27. 创建联系人
  28. </el-button>
  29. <el-button>
  30. <Icon icon="ep:opportunity" class="mr-5px" />
  31. 创建商机
  32. </el-button>
  33. <el-button>
  34. <Icon icon="clarity:contract-line" class="mr-5px" />
  35. 创建合同
  36. </el-button>
  37. <el-button>
  38. <Icon icon="icon-park:income-one" class="mr-5px" />
  39. 创建回款
  40. </el-button>
  41. <el-button>
  42. <Icon icon="fluent:people-team-add-20-filled" class="mr-5px" />
  43. 添加团队成员
  44. </el-button>
  45. </el-row>
  46. </div>
  47. <ContentWrap class="mt-10px">
  48. <el-descriptions :column="5" direction="vertical">
  49. <el-descriptions-item label="客户名称">
  50. {{ contact.customerName }}
  51. </el-descriptions-item>
  52. <el-descriptions-item label="职务">
  53. {{ contact.post }}
  54. </el-descriptions-item>
  55. <el-descriptions-item label="手机">
  56. {{ contact.mobile }}
  57. </el-descriptions-item>
  58. <el-descriptions-item label="创建时间">
  59. {{ contact.createTime ? formatDate(contact.createTime) : '空' }}
  60. </el-descriptions-item>
  61. </el-descriptions>
  62. </ContentWrap>
  63. <!-- TODO wanwan:这个 tab 拉满哈,可以更好看; -->
  64. <el-col :span="18">
  65. <el-tabs>
  66. <el-tab-pane label="基本信息">
  67. <!-- TODO wanwan:这个 ml-2 是不是可以优化下,不要整个左移,而是里面的内容有个几 px 的偏移,不顶在框里 -->
  68. <ContactDetails class="ml-2" :contact="contact" />
  69. </el-tab-pane>
  70. <el-tab-pane label="跟进记录" lazy> 跟进记录</el-tab-pane>
  71. <el-tab-pane label="商机" lazy> 商机</el-tab-pane>
  72. <el-tab-pane label="附件" lazy> 附件</el-tab-pane>
  73. <!-- TODO wanwan 以下标签上的数量需要接口统计返回 -->
  74. <el-tab-pane label="操作记录" lazy>
  75. <template #label> 操作记录<el-badge :value="12" class="item" type="primary" /> </template>
  76. 操作记录
  77. </el-tab-pane>
  78. </el-tabs>
  79. </el-col>
  80. <!-- 表单弹窗:添加/修改 -->
  81. <ContactForm ref="formRef" @success="getContactData(id)" />
  82. </template>
  83. <script setup lang="ts">
  84. import { ElMessage } from 'element-plus'
  85. import { useTagsViewStore } from '@/store/modules/tagsView'
  86. import * as ContactApi from '@/api/crm/contact'
  87. import ContactBasicInfo from '@/views/crm/contact/detail/ContactBasicInfo.vue'
  88. import ContactDetails from '@/views/crm/contact/detail/ContactDetails.vue'
  89. import ContactForm from '@/views/crm/contact/ContactForm.vue'
  90. import { formatDate } from '@/utils/formatTime'
  91. import * as CustomerApi from '@/api/crm/customer'
  92. // TODO 芋艿:后面在 review 么?
  93. defineOptions({ name: 'ContactDetail' })
  94. const { delView } = useTagsViewStore() // 视图操作
  95. const route = useRoute()
  96. const { currentRoute } = useRouter() // 路由
  97. const id = Number(route.params.id)
  98. const loading = ref(true) // 加载中
  99. // 联系人详情
  100. const contact = ref<ContactApi.ContactVO>({} as ContactApi.ContactVO)
  101. /**
  102. * 获取详情
  103. *
  104. * @param id
  105. */
  106. const getContactData = async (id: number) => {
  107. loading.value = true
  108. try {
  109. contact.value = await ContactApi.getContact(id)
  110. } finally {
  111. loading.value = false
  112. }
  113. }
  114. const formRef = ref()
  115. const openForm = (type: string, id?: number) => {
  116. formRef.value.open(type, id)
  117. }
  118. /**
  119. * 初始化
  120. */
  121. onMounted(async () => {
  122. if (!id) {
  123. ElMessage.warning('参数错误,联系人不能为空!')
  124. delView(unref(currentRoute))
  125. return
  126. }
  127. await getContactData(id)
  128. })
  129. </script>