index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <doc-alert title="【商机】商机管理、商机状态" url="https://doc.iocoder.cn/crm/business/" />
  3. <doc-alert title="【通用】数据权限" url="https://doc.iocoder.cn/crm/permission/" />
  4. <ContentWrap>
  5. <!-- 搜索工作栏 -->
  6. <el-form
  7. class="-mb-15px"
  8. :model="queryParams"
  9. ref="queryFormRef"
  10. :inline="true"
  11. label-width="68px"
  12. >
  13. <el-form-item>
  14. <el-button
  15. type="primary"
  16. plain
  17. @click="openForm('create')"
  18. v-hasPermi="['crm:business-status:create']"
  19. >
  20. <Icon icon="ep:plus" class="mr-5px" /> 新增
  21. </el-button>
  22. </el-form-item>
  23. </el-form>
  24. </ContentWrap>
  25. <!-- 列表 -->
  26. <ContentWrap>
  27. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  28. <el-table-column label="状态组名" align="center" prop="name" />
  29. <el-table-column label="应用部门" align="center" prop="deptNames">
  30. <template #default="scope">
  31. <span v-if="scope.row?.deptNames?.length > 0">
  32. {{ scope.row.deptNames.join(' ') }}
  33. </span>
  34. <span v-else>全公司</span>
  35. </template>
  36. </el-table-column>
  37. <el-table-column label="创建人" align="center" prop="creator" />
  38. <el-table-column
  39. label="创建时间"
  40. align="center"
  41. prop="createTime"
  42. :formatter="dateFormatter"
  43. width="180px"
  44. />
  45. <el-table-column label="操作" align="center">
  46. <template #default="scope">
  47. <el-button
  48. link
  49. type="primary"
  50. @click="openForm('update', scope.row.id)"
  51. v-hasPermi="['crm:business-status:update']"
  52. >
  53. 编辑
  54. </el-button>
  55. <el-button
  56. link
  57. type="danger"
  58. @click="handleDelete(scope.row.id)"
  59. v-hasPermi="['crm:business-status:delete']"
  60. >
  61. 删除
  62. </el-button>
  63. </template>
  64. </el-table-column>
  65. </el-table>
  66. <!-- 分页 -->
  67. <Pagination
  68. :total="total"
  69. v-model:page="queryParams.pageNo"
  70. v-model:limit="queryParams.pageSize"
  71. @pagination="getList"
  72. />
  73. </ContentWrap>
  74. <!-- 表单弹窗:添加/修改 -->
  75. <BusinessStatusForm ref="formRef" @success="getList" />
  76. </template>
  77. <script setup lang="ts">
  78. import { dateFormatter } from '@/utils/formatTime'
  79. import download from '@/utils/download'
  80. import * as BusinessStatusApi from '@/api/crm/business/status'
  81. import BusinessStatusForm from './BusinessStatusForm.vue'
  82. import { deleteBusinessStatus } from '@/api/crm/business/status'
  83. defineOptions({ name: 'CrmBusinessStatus' })
  84. const message = useMessage() // 消息弹窗
  85. const { t } = useI18n() // 国际化
  86. const loading = ref(true) // 列表的加载中
  87. const list = ref([]) // 列表的数据
  88. const total = ref(0) // 列表的总页数
  89. const queryParams = reactive({
  90. pageNo: 1,
  91. pageSize: 10
  92. })
  93. const queryFormRef = ref() // 搜索的表单
  94. const exportLoading = ref(false) // 导出的加载中
  95. /** 查询列表 */
  96. const getList = async () => {
  97. loading.value = true
  98. try {
  99. const data = await BusinessStatusApi.getBusinessStatusPage(queryParams)
  100. list.value = data.list
  101. total.value = data.total
  102. } finally {
  103. loading.value = false
  104. }
  105. }
  106. /** 搜索按钮操作 */
  107. const handleQuery = () => {
  108. queryParams.pageNo = 1
  109. getList()
  110. }
  111. /** 重置按钮操作 */
  112. const resetQuery = () => {
  113. queryFormRef.value.resetFields()
  114. handleQuery()
  115. }
  116. /** 添加/修改操作 */
  117. const formRef = ref()
  118. const openForm = (type: string, id?: number) => {
  119. formRef.value.open(type, id)
  120. }
  121. /** 删除按钮操作 */
  122. const handleDelete = async (id: number) => {
  123. try {
  124. // 删除的二次确认
  125. await message.delConfirm()
  126. // 发起删除
  127. await BusinessStatusApi.deleteBusinessStatus(id)
  128. message.success(t('common.delSuccess'))
  129. // 刷新列表
  130. await getList()
  131. } catch {}
  132. }
  133. /** 初始化 **/
  134. onMounted(() => {
  135. getList()
  136. })
  137. </script>