BusinessList.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <!-- 操作栏 -->
  3. <el-row justify="end">
  4. <el-button @click="openForm">
  5. <Icon class="mr-5px" icon="ep:opportunity" />
  6. 创建商机
  7. </el-button>
  8. </el-row>
  9. <!-- 列表 -->
  10. <ContentWrap class="mt-10px">
  11. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  12. <el-table-column label="商机名称" fixed="left" align="center" prop="name">
  13. <template #default="scope">
  14. <el-link type="primary" :underline="false" @click="openDetail(scope.row.id)">
  15. {{ scope.row.name }}
  16. </el-link>
  17. </template>
  18. </el-table-column>
  19. <el-table-column label="商机金额" align="center" prop="price" :formatter="fenToYuanFormat" />
  20. <el-table-column label="客户名称" align="center" prop="customerName" />
  21. <el-table-column label="商机组" align="center" prop="statusTypeName" />
  22. <el-table-column label="商机阶段" align="center" prop="statusName" />
  23. </el-table>
  24. <!-- 分页 -->
  25. <Pagination
  26. :total="total"
  27. v-model:page="queryParams.pageNo"
  28. v-model:limit="queryParams.pageSize"
  29. @pagination="getList"
  30. />
  31. </ContentWrap>
  32. <!-- 表单弹窗:添加 -->
  33. <BusinessForm ref="formRef" @success="getList" />
  34. </template>
  35. <script setup lang="ts">
  36. import * as BusinessApi from '@/api/crm/business'
  37. import BusinessForm from './../BusinessForm.vue'
  38. import { BizTypeEnum } from '@/api/crm/permission'
  39. import { fenToYuanFormat } from '@/utils/formatter'
  40. defineOptions({ name: 'CrmBusinessList' })
  41. const props = defineProps<{
  42. bizType: number // 业务类型
  43. bizId: number // 业务编号
  44. }>()
  45. const loading = ref(true) // 列表的加载中
  46. const total = ref(0) // 列表的总页数
  47. const list = ref([]) // 列表的数据
  48. const queryParams = reactive({
  49. pageNo: 1,
  50. pageSize: 10,
  51. customerId: undefined as unknown // 允许 undefined + number
  52. })
  53. /** 查询列表 */
  54. const getList = async () => {
  55. loading.value = true
  56. try {
  57. // 置空参数
  58. queryParams.customerId = undefined
  59. // 执行查询
  60. let data = { list: [], total: 0 }
  61. switch (props.bizType) {
  62. case BizTypeEnum.CRM_CUSTOMER:
  63. queryParams.customerId = props.bizId
  64. data = await BusinessApi.getBusinessPageByCustomer(queryParams)
  65. break
  66. default:
  67. return
  68. }
  69. list.value = data.list
  70. total.value = data.total
  71. } finally {
  72. loading.value = false
  73. }
  74. }
  75. /** 搜索按钮操作 */
  76. const handleQuery = () => {
  77. queryParams.pageNo = 1
  78. getList()
  79. }
  80. /** 添加操作 */
  81. const formRef = ref()
  82. const openForm = () => {
  83. formRef.value.open('create')
  84. }
  85. /** 打开联系人详情 */
  86. const { push } = useRouter()
  87. const openDetail = (id: number) => {
  88. push({ name: 'CrmBusinessDetail', params: { id } })
  89. }
  90. /** 监听打开的 bizId + bizType,从而加载最新的列表 */
  91. watch(
  92. () => [props.bizId, props.bizType],
  93. () => {
  94. handleQuery()
  95. },
  96. { immediate: true, deep: true }
  97. )
  98. </script>