index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <ContentWrap>
  3. <!-- 搜索工作栏 -->
  4. <el-form
  5. ref="queryFormRef"
  6. :inline="true"
  7. :model="queryParams"
  8. class="-mb-15px"
  9. label-width="68px"
  10. >
  11. <el-form-item label="客户名称" prop="name">
  12. <el-input
  13. v-model="queryParams.name"
  14. class="!w-240px"
  15. clearable
  16. placeholder="请输入客户名称"
  17. @keyup.enter="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="手机" prop="mobile">
  21. <el-input
  22. v-model="queryParams.mobile"
  23. class="!w-240px"
  24. clearable
  25. placeholder="请输入手机"
  26. @keyup.enter="handleQuery"
  27. />
  28. </el-form-item>
  29. <el-form-item label="所属行业" prop="industryId">
  30. <el-select
  31. v-model="queryParams.industryId"
  32. class="!w-240px"
  33. clearable
  34. placeholder="请选择所属行业"
  35. >
  36. <el-option
  37. v-for="dict in getIntDictOptions(DICT_TYPE.CRM_CUSTOMER_INDUSTRY)"
  38. :key="dict.value"
  39. :label="dict.label"
  40. :value="dict.value"
  41. />
  42. </el-select>
  43. </el-form-item>
  44. <el-form-item label="客户级别" prop="level">
  45. <el-select
  46. v-model="queryParams.level"
  47. class="!w-240px"
  48. clearable
  49. placeholder="请选择客户级别"
  50. >
  51. <el-option
  52. v-for="dict in getIntDictOptions(DICT_TYPE.CRM_CUSTOMER_LEVEL)"
  53. :key="dict.value"
  54. :label="dict.label"
  55. :value="dict.value"
  56. />
  57. </el-select>
  58. </el-form-item>
  59. <el-form-item label="客户来源" prop="source">
  60. <el-select
  61. v-model="queryParams.source"
  62. class="!w-240px"
  63. clearable
  64. placeholder="请选择客户来源"
  65. >
  66. <el-option
  67. v-for="dict in getIntDictOptions(DICT_TYPE.CRM_CUSTOMER_SOURCE)"
  68. :key="dict.value"
  69. :label="dict.label"
  70. :value="dict.value"
  71. />
  72. </el-select>
  73. </el-form-item>
  74. <el-form-item>
  75. <el-button @click="handleQuery">
  76. <Icon class="mr-5px" icon="ep:search" />
  77. 搜索
  78. </el-button>
  79. <el-button @click="resetQuery(undefined)">
  80. <Icon class="mr-5px" icon="ep:refresh" />
  81. 重置
  82. </el-button>
  83. <el-button
  84. v-hasPermi="['crm:customer:export']"
  85. :loading="exportLoading"
  86. plain
  87. type="success"
  88. @click="handleExport"
  89. >
  90. <Icon class="mr-5px" icon="ep:download" />
  91. 导出
  92. </el-button>
  93. </el-form-item>
  94. </el-form>
  95. </ContentWrap>
  96. <!-- 列表 -->
  97. <ContentWrap>
  98. <el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
  99. <el-table-column align="center" label="客户名称" fixed="left" prop="name" width="160">
  100. <template #default="scope">
  101. <el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
  102. {{ scope.row.name }}
  103. </el-link>
  104. </template>
  105. </el-table-column>
  106. <el-table-column align="center" label="客户来源" prop="source" width="100">
  107. <template #default="scope">
  108. <dict-tag :type="DICT_TYPE.CRM_CUSTOMER_SOURCE" :value="scope.row.source" />
  109. </template>
  110. </el-table-column>
  111. <el-table-column label="手机" align="center" prop="mobile" width="120" />
  112. <el-table-column label="电话" align="center" prop="telephone" width="130" />
  113. <el-table-column label="邮箱" align="center" prop="email" width="180" />
  114. <el-table-column align="center" label="客户级别" prop="level" width="135">
  115. <template #default="scope">
  116. <dict-tag :type="DICT_TYPE.CRM_CUSTOMER_LEVEL" :value="scope.row.level" />
  117. </template>
  118. </el-table-column>
  119. <el-table-column align="center" label="客户行业" prop="industryId" width="100">
  120. <template #default="scope">
  121. <dict-tag :type="DICT_TYPE.CRM_CUSTOMER_INDUSTRY" :value="scope.row.industryId" />
  122. </template>
  123. </el-table-column>
  124. <el-table-column
  125. :formatter="dateFormatter"
  126. align="center"
  127. label="下次联系时间"
  128. prop="contactNextTime"
  129. width="180px"
  130. />
  131. <el-table-column align="center" label="备注" prop="remark" width="200" />
  132. <el-table-column align="center" label="成交状态" prop="dealStatus">
  133. <template #default="scope">
  134. <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.dealStatus" />
  135. </template>
  136. </el-table-column>
  137. <el-table-column
  138. :formatter="dateFormatter"
  139. align="center"
  140. label="最后跟进时间"
  141. prop="contactLastTime"
  142. width="180px"
  143. />
  144. <el-table-column align="center" label="最后跟进记录" prop="contactLastContent" width="200" />
  145. <el-table-column
  146. :formatter="dateFormatter"
  147. align="center"
  148. label="更新时间"
  149. prop="updateTime"
  150. width="180px"
  151. />
  152. <el-table-column
  153. :formatter="dateFormatter"
  154. align="center"
  155. label="创建时间"
  156. prop="createTime"
  157. width="180px"
  158. />
  159. <el-table-column align="center" label="创建人" prop="creatorName" width="100px" />
  160. </el-table>
  161. <!-- 分页 -->
  162. <Pagination
  163. v-model:limit="queryParams.pageSize"
  164. v-model:page="queryParams.pageNo"
  165. :total="total"
  166. @pagination="getList"
  167. />
  168. </ContentWrap>
  169. </template>
  170. <script lang="ts" setup>
  171. import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
  172. import { dateFormatter } from '@/utils/formatTime'
  173. import download from '@/utils/download'
  174. import * as CustomerApi from '@/api/crm/customer'
  175. defineOptions({ name: 'CrmCustomerPool' })
  176. const message = useMessage() // 消息弹窗
  177. const loading = ref(true) // 列表的加载中
  178. const total = ref(0) // 列表的总页数
  179. const list = ref([]) // 列表的数据
  180. const queryParams = ref({
  181. pageNo: 1,
  182. pageSize: 10,
  183. name: '',
  184. mobile: '',
  185. industryId: undefined,
  186. level: undefined,
  187. source: undefined,
  188. sceneType: undefined,
  189. pool: true
  190. })
  191. const queryFormRef = ref() // 搜索的表单
  192. const exportLoading = ref(false) // 导出的加载中
  193. /** 查询列表 */
  194. const getList = async () => {
  195. loading.value = true
  196. try {
  197. const data = await CustomerApi.getCustomerPage(queryParams.value)
  198. list.value = data.list
  199. total.value = data.total
  200. } finally {
  201. loading.value = false
  202. }
  203. }
  204. /** 搜索按钮操作 */
  205. const handleQuery = () => {
  206. queryParams.value.pageNo = 1
  207. getList()
  208. }
  209. /** 重置按钮操作 */
  210. const resetQuery = () => {
  211. queryFormRef.value.resetFields()
  212. queryParams.value = {
  213. pageNo: 1,
  214. pageSize: 10,
  215. name: '',
  216. mobile: '',
  217. industryId: undefined,
  218. level: undefined,
  219. source: undefined,
  220. sceneType: undefined,
  221. pool: true
  222. }
  223. handleQuery()
  224. }
  225. /** 打开客户详情 */
  226. const { currentRoute, push } = useRouter()
  227. const openDetail = (id: number) => {
  228. push({ name: 'CrmCustomerDetail', params: { id } })
  229. }
  230. /** 导出按钮操作 */
  231. const handleExport = async () => {
  232. try {
  233. // 导出的二次确认
  234. await message.exportConfirm()
  235. // 发起导出
  236. exportLoading.value = true
  237. const data = await CustomerApi.exportCustomer(queryParams.value)
  238. download.excel(data, '客户公海.xls')
  239. } catch {
  240. } finally {
  241. exportLoading.value = false
  242. }
  243. }
  244. /** 监听路由变化更新列表 */
  245. watch(
  246. () => currentRoute.value,
  247. () => {
  248. getList()
  249. }
  250. )
  251. /** 初始化 **/
  252. onMounted(() => {
  253. getList()
  254. })
  255. </script>