CustomerLimitConfDetails.vue 4.0 KB

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