index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <ContentWrap>
  3. <!-- 搜索工作栏 -->
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="68px"
  10. >
  11. <el-form-item label="商机名称" prop="name">
  12. <el-input
  13. v-model="queryParams.name"
  14. placeholder="请输入商机名称"
  15. clearable
  16. @keyup.enter="handleQuery"
  17. class="!w-240px"
  18. />
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  22. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  23. <el-button type="primary" @click="openForm('create')" v-hasPermi="['crm:business:create']">
  24. <Icon icon="ep:plus" class="mr-5px" /> 新增
  25. </el-button>
  26. <el-button
  27. type="success"
  28. plain
  29. @click="handleExport"
  30. :loading="exportLoading"
  31. v-hasPermi="['crm:business:export']"
  32. >
  33. <Icon icon="ep:download" class="mr-5px" /> 导出
  34. </el-button>
  35. </el-form-item>
  36. </el-form>
  37. </ContentWrap>
  38. <!-- 列表 -->
  39. <ContentWrap>
  40. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  41. <el-table-column label="商机名称" align="center" prop="name" />
  42. <el-table-column label="客户名称" align="center" prop="customerName" />
  43. <el-table-column label="商机金额" align="center" prop="price" />
  44. <el-table-column
  45. label="预计成交日期"
  46. align="center"
  47. prop="dealTime"
  48. :formatter="dateFormatter"
  49. width="180px"
  50. />
  51. <el-table-column label="备注" align="center" prop="remark" />
  52. <el-table-column label="商机状态类型" align="center" prop="statusTypeName" />
  53. <el-table-column label="商机状态" align="center" prop="statusName" />
  54. <el-table-column
  55. label="更新时间"
  56. align="center"
  57. prop="updateTime"
  58. :formatter="dateFormatter"
  59. width="180px"
  60. />
  61. <el-table-column
  62. label="创建时间"
  63. align="center"
  64. prop="createTime"
  65. :formatter="dateFormatter"
  66. width="180px"
  67. />
  68. <el-table-column label="负责人" align="center" prop="ownerUserId" />
  69. <el-table-column label="创建人" align="center" prop="creator" />
  70. <el-table-column label="跟进状态" align="center" prop="followUpStatus" />
  71. <el-table-column label="操作" align="center" fixed="right" width="130px">
  72. <template #default="scope">
  73. <el-button
  74. link
  75. type="primary"
  76. @click="openForm('update', scope.row.id)"
  77. v-hasPermi="['crm:business:update']"
  78. >
  79. 编辑
  80. </el-button>
  81. <el-button
  82. link
  83. type="danger"
  84. @click="handleDelete(scope.row.id)"
  85. v-hasPermi="['crm:business:delete']"
  86. >
  87. 删除
  88. </el-button>
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <!-- 分页 -->
  93. <Pagination
  94. :total="total"
  95. v-model:page="queryParams.pageNo"
  96. v-model:limit="queryParams.pageSize"
  97. @pagination="getList"
  98. />
  99. </ContentWrap>
  100. <!-- 表单弹窗:添加/修改 -->
  101. <BusinessForm ref="formRef" @success="getList" />
  102. </template>
  103. <script setup lang="ts">
  104. import { dateFormatter } from '@/utils/formatTime'
  105. import download from '@/utils/download'
  106. import * as BusinessApi from '@/api/crm/business'
  107. import BusinessForm from './BusinessForm.vue'
  108. defineOptions({ name: 'CrmBusiness' })
  109. const message = useMessage() // 消息弹窗
  110. const { t } = useI18n() // 国际化
  111. const loading = ref(true) // 列表的加载中
  112. const total = ref(0) // 列表的总页数
  113. const list = ref([]) // 列表的数据
  114. const queryParams = reactive({
  115. pageNo: 1,
  116. pageSize: 10,
  117. name: null,
  118. statusTypeId: null,
  119. statusId: null,
  120. contactNextTime: [],
  121. customerId: null,
  122. dealTime: [],
  123. price: null,
  124. discountPercent: null,
  125. productPrice: null,
  126. remark: null,
  127. ownerUserId: null,
  128. createTime: [],
  129. roUserIds: null,
  130. rwUserIds: null,
  131. endStatus: null,
  132. endRemark: null,
  133. contactLastTime: [],
  134. followUpStatus: null
  135. })
  136. const queryFormRef = ref() // 搜索的表单
  137. const exportLoading = ref(false) // 导出的加载中
  138. /** 查询列表 */
  139. const getList = async () => {
  140. loading.value = true
  141. try {
  142. const data = await BusinessApi.getBusinessPage(queryParams)
  143. list.value = data.list
  144. total.value = data.total
  145. } finally {
  146. loading.value = false
  147. }
  148. }
  149. /** 搜索按钮操作 */
  150. const handleQuery = () => {
  151. queryParams.pageNo = 1
  152. getList()
  153. }
  154. /** 重置按钮操作 */
  155. const resetQuery = () => {
  156. queryFormRef.value.resetFields()
  157. handleQuery()
  158. }
  159. /** 添加/修改操作 */
  160. const formRef = ref()
  161. const openForm = (type: string, id?: number) => {
  162. formRef.value.open(type, id)
  163. }
  164. /** 删除按钮操作 */
  165. const handleDelete = async (id: number) => {
  166. try {
  167. // 删除的二次确认
  168. await message.delConfirm()
  169. // 发起删除
  170. await BusinessApi.deleteBusiness(id)
  171. message.success(t('common.delSuccess'))
  172. // 刷新列表
  173. await getList()
  174. } catch {}
  175. }
  176. /** 导出按钮操作 */
  177. const handleExport = async () => {
  178. try {
  179. // 导出的二次确认
  180. await message.exportConfirm()
  181. // 发起导出
  182. exportLoading.value = true
  183. const data = await BusinessApi.exportBusiness(queryParams)
  184. download.excel(data, '商机.xls')
  185. } catch {
  186. } finally {
  187. exportLoading.value = false
  188. }
  189. }
  190. /** 初始化 **/
  191. onMounted(() => {
  192. getList()
  193. })
  194. </script>