CustomerLimitConfigList.vue 4.0 KB

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