index.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <ProductDetailsHeader :product="product" :loading="loading" @refresh="getProductData(id)"/>
  3. <el-col>
  4. <el-tabs>
  5. <el-tab-pane label="详细资料">
  6. <ProductDetailsInfo :product="product"/>
  7. </el-tab-pane>
  8. <el-tab-pane label="操作日志">
  9. <OperateLogV2 :log-list="logList"/>
  10. </el-tab-pane>
  11. </el-tabs>
  12. </el-col>
  13. </template>
  14. <script setup lang="ts">
  15. import {useTagsViewStore} from '@/store/modules/tagsView'
  16. import {OperateLogV2VO} from '@/api/system/operatelog'
  17. import * as ProductApi from '@/api/crm/product'
  18. import ProductDetailsHeader from '@/views/crm/product/detail/ProductDetailsHeader.vue'
  19. import ProductDetailsInfo from '@/views/crm/product/detail/ProductDetailsInfo.vue'
  20. defineOptions({name: 'CrmProductDetail'})
  21. const route = useRoute()
  22. const id = Number(route.params.id) // 编号
  23. const loading = ref(true) // 加载中
  24. const product = ref<ProductApi.ProductVO>({} as ProductApi.ProductVO) // 详情
  25. /** 获取详情 */
  26. const getProductData = async (id: number) => {
  27. loading.value = true
  28. try {
  29. product.value = await ProductApi.getProduct(id)
  30. await getOperateLog(id)
  31. } finally {
  32. loading.value = false
  33. }
  34. }
  35. /**
  36. * 获取操作日志
  37. */
  38. const logList = ref<OperateLogV2VO[]>([]) // 操作日志列表
  39. const getOperateLog = async (productId: number) => {
  40. if (!productId) {
  41. return
  42. }
  43. const data = await ProductApi.getOperateLogPage({
  44. bizId: productId
  45. })
  46. logList.value = data.list
  47. }
  48. /** 初始化 */
  49. const {delView} = useTagsViewStore() // 视图操作
  50. const {currentRoute} = useRouter() // 路由
  51. onMounted(async () => {
  52. if (!id) {
  53. ElMessage.warning('参数错误,产品不能为空!')
  54. delView(unref(currentRoute))
  55. return
  56. }
  57. await getProductData(id)
  58. })
  59. </script>