ContractList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <!-- 操作栏 -->
  3. <el-row justify="end">
  4. <el-button @click="openForm">
  5. <Icon class="mr-5px" icon="clarity:contract-line" />
  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="no" />
  20. <el-table-column label="客户名称" align="center" prop="customerName" />
  21. <el-table-column
  22. label="合同金额(元)"
  23. align="center"
  24. prop="price"
  25. :formatter="fenToYuanFormat"
  26. />
  27. <el-table-column
  28. label="开始时间"
  29. align="center"
  30. prop="startTime"
  31. :formatter="dateFormatter"
  32. width="180px"
  33. />
  34. <el-table-column
  35. label="结束时间"
  36. align="center"
  37. prop="endTime"
  38. :formatter="dateFormatter"
  39. width="180px"
  40. />
  41. <el-table-column align="center" label="状态" prop="auditStatus">
  42. <template #default="scope">
  43. <dict-tag :type="DICT_TYPE.CRM_AUDIT_STATUS" :value="scope.row.auditStatus" />
  44. </template>
  45. </el-table-column>
  46. </el-table>
  47. <!-- 分页 -->
  48. <Pagination
  49. :total="total"
  50. v-model:page="queryParams.pageNo"
  51. v-model:limit="queryParams.pageSize"
  52. @pagination="getList"
  53. />
  54. </ContentWrap>
  55. <!-- 表单弹窗:添加 -->
  56. <ContractForm ref="formRef" @success="getList" />
  57. </template>
  58. <script setup lang="ts">
  59. import * as ContractApi from '@/api/crm/contract'
  60. import ContractForm from './../ContractForm.vue'
  61. import { BizTypeEnum } from '@/api/crm/permission'
  62. import { fenToYuanFormat } from '@/utils/formatter'
  63. import { dateFormatter } from '@/utils/formatTime'
  64. import { DICT_TYPE } from '@/utils/dict'
  65. defineOptions({ name: 'CrmContractList' })
  66. const props = defineProps<{
  67. bizType: number // 业务类型
  68. bizId: number // 业务编号
  69. }>()
  70. const loading = ref(true) // 列表的加载中
  71. const total = ref(0) // 列表的总页数
  72. const list = ref([]) // 列表的数据
  73. const queryParams = reactive({
  74. pageNo: 1,
  75. pageSize: 10,
  76. customerId: undefined as unknown // 允许 undefined + number
  77. })
  78. /** 查询列表 */
  79. const getList = async () => {
  80. loading.value = true
  81. try {
  82. // 置空参数
  83. queryParams.customerId = undefined
  84. // 执行查询
  85. let data = { list: [], total: 0 }
  86. switch (props.bizType) {
  87. case BizTypeEnum.CRM_CUSTOMER:
  88. queryParams.customerId = props.bizId
  89. data = await ContractApi.getContractPageByCustomer(queryParams)
  90. break
  91. default:
  92. return
  93. }
  94. list.value = data.list
  95. total.value = data.total
  96. } finally {
  97. loading.value = false
  98. }
  99. }
  100. /** 搜索按钮操作 */
  101. const handleQuery = () => {
  102. queryParams.pageNo = 1
  103. getList()
  104. }
  105. /** 添加 */
  106. const formRef = ref()
  107. const openForm = () => {
  108. formRef.value.open('create')
  109. }
  110. /** 打开合同详情 */
  111. const { push } = useRouter()
  112. const openDetail = (id: number) => {
  113. push({ name: 'CrmContractDetail', params: { id } })
  114. }
  115. /** 监听打开的 bizId + bizType,从而加载最新的列表 */
  116. watch(
  117. () => [props.bizId, props.bizType],
  118. () => {
  119. handleQuery()
  120. },
  121. { immediate: true, deep: true }
  122. )
  123. </script>