CustomerLimitConfigList.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <el-button type="primary" plain @click="handleQuery">
  3. <Icon icon="ep:refresh" class="mr-5px" /> 刷新
  4. </el-button>
  5. <el-button
  6. type="primary"
  7. plain
  8. @click="openForm('create')"
  9. v-hasPermi="['crm:customer-limit-config:create']"
  10. >
  11. <Icon icon="ep:plus" class="mr-5px" /> 新增
  12. </el-button>
  13. <el-table
  14. v-loading="loading"
  15. :data="list"
  16. :stripe="true"
  17. :show-overflow-tooltip="true"
  18. class="mt-4"
  19. >
  20. <el-table-column label="编号" align="center" prop="id" />
  21. <el-table-column label="规则类型" align="center" prop="type" />
  22. <el-table-column
  23. label="规则适用人群"
  24. align="center"
  25. :formatter="(row) => row.users?.map((user: any) => user.nickname).join(',')"
  26. />
  27. <el-table-column
  28. label="规则适用部门"
  29. align="center"
  30. :formatter="(row) => row.depts?.map((dept: any) => dept.name).join(',')"
  31. />
  32. <el-table-column
  33. :label="
  34. confType === LimitConfType.CUSTOMER_QUANTITY_LIMIT ? '拥有客户数上限' : '锁定客户数上限'
  35. "
  36. align="center"
  37. prop="maxCount"
  38. />
  39. <el-table-column
  40. v-if="confType === LimitConfType.CUSTOMER_QUANTITY_LIMIT"
  41. label="成交客户是否占用拥有客户数"
  42. align="center"
  43. prop="dealCountEnabled"
  44. >
  45. <template #default="scope">
  46. <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.dealCountEnabled" />
  47. </template>
  48. </el-table-column>
  49. <el-table-column
  50. label="创建时间"
  51. align="center"
  52. prop="createTime"
  53. :formatter="dateFormatter"
  54. width="180px"
  55. />
  56. <el-table-column label="操作" align="center" min-width="110" fixed="right">
  57. <template #default="scope">
  58. <el-button
  59. link
  60. type="primary"
  61. @click="openForm('update', scope.row.id)"
  62. v-hasPermi="['crm:customer-limit-config:update']"
  63. >
  64. 编辑
  65. </el-button>
  66. <el-button
  67. link
  68. type="danger"
  69. @click="handleDelete(scope.row.id)"
  70. v-hasPermi="['crm:customer-limit-config:delete']"
  71. >
  72. 删除
  73. </el-button>
  74. </template>
  75. </el-table-column>
  76. </el-table>
  77. <!-- 分页 -->
  78. <Pagination
  79. :total="total"
  80. v-model:page="queryParams.pageNo"
  81. v-model:limit="queryParams.pageSize"
  82. @pagination="getList"
  83. />
  84. <!-- 表单弹窗:添加/修改 -->
  85. <CustomerLimitConfigForm ref="formRef" @success="getList" />
  86. </template>
  87. <script setup lang="ts">
  88. import { dateFormatter } from '@/utils/formatTime'
  89. import * as CustomerLimitConfigApi from '@/api/crm/customerLimitConfig'
  90. import CustomerLimitConfigForm from '@/views/crm/config/customerLimitConfig/CustomerLimitConfigForm.vue'
  91. import { DICT_TYPE } from '@/utils/dict'
  92. import { LimitConfType } from '@/api/crm/customerLimitConfig'
  93. defineOptions({ name: 'CustomerLimitConfigList' })
  94. const message = useMessage() // 消息弹窗
  95. const { t } = useI18n() // 国际化
  96. const { confType } = defineProps<{ confType: LimitConfType }>()
  97. const loading = ref(true) // 列表的加载中
  98. const total = ref(0) // 列表的总页数
  99. const list = ref([]) // 列表的数据
  100. const queryParams = reactive({
  101. pageNo: 1,
  102. pageSize: 10,
  103. type: confType
  104. })
  105. const queryFormRef = ref() // 搜索的表单
  106. const exportLoading = ref(false) // 导出的加载中
  107. /** 查询列表 */
  108. const getList = async () => {
  109. loading.value = true
  110. try {
  111. const data = await CustomerLimitConfigApi.getCustomerLimitConfigPage(queryParams)
  112. list.value = data.list
  113. total.value = data.total
  114. } finally {
  115. loading.value = false
  116. }
  117. }
  118. /** 添加/修改操作 */
  119. const formRef = ref()
  120. const openForm = (type: string, id?: number) => {
  121. formRef.value.open(type, id, confType)
  122. }
  123. /** 删除按钮操作 */
  124. const handleDelete = async (id: number) => {
  125. try {
  126. // 删除的二次确认
  127. await message.delConfirm()
  128. // 发起删除
  129. await CustomerLimitConfigApi.deleteCustomerLimitConfig(id)
  130. message.success(t('common.delSuccess'))
  131. // 刷新列表
  132. await getList()
  133. } catch {}
  134. }
  135. /** 搜索按钮操作 */
  136. const handleQuery = () => {
  137. queryParams.pageNo = 1
  138. getList()
  139. }
  140. /** 初始化 **/
  141. onMounted(() => {
  142. getList()
  143. })
  144. </script>