index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <ContentWrap>
  3. <!-- 搜索工作栏 -->
  4. <!-- TODO @wanwan:筛选条件,按照 docs 的再改下 -->
  5. <el-form
  6. class="-mb-15px"
  7. :model="queryParams"
  8. ref="queryFormRef"
  9. :inline="true"
  10. label-width="68px"
  11. >
  12. <el-form-item label="客户名称" prop="name">
  13. <el-input
  14. v-model="queryParams.name"
  15. placeholder="请输入客户名称"
  16. clearable
  17. @keyup.enter="handleQuery"
  18. class="!w-240px"
  19. />
  20. </el-form-item>
  21. <el-form-item label="手机" prop="mobile">
  22. <el-input
  23. v-model="queryParams.mobile"
  24. placeholder="请输入手机"
  25. clearable
  26. @keyup.enter="handleQuery"
  27. class="!w-240px"
  28. />
  29. </el-form-item>
  30. <el-form-item>
  31. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  32. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  33. <el-button type="primary" @click="openForm('create')" v-hasPermi="['crm:customer:create']">
  34. <Icon icon="ep:plus" class="mr-5px" /> 新增
  35. </el-button>
  36. <el-button
  37. type="success"
  38. plain
  39. @click="handleExport"
  40. :loading="exportLoading"
  41. v-hasPermi="['crm:customer:export']"
  42. >
  43. <Icon icon="ep:download" class="mr-5px" /> 导出
  44. </el-button>
  45. </el-form-item>
  46. </el-form>
  47. </ContentWrap>
  48. <!-- 列表 -->
  49. <!-- TODO @wanwan:列表,按照 docs 的再改下 -->
  50. <ContentWrap>
  51. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  52. <el-table-column label="编号" align="center" prop="id" />
  53. <el-table-column label="客户名称" align="center" prop="name" width="160" />
  54. <el-table-column label="所属行业" align="center" prop="industryId" width="120">
  55. <template #default="scope">
  56. <dict-tag :type="DICT_TYPE.CRM_CUSTOMER_INDUSTRY" :value="scope.row.industryId" />
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="客户来源" align="center" prop="source" width="100">
  60. <template #default="scope">
  61. <dict-tag :type="DICT_TYPE.CRM_CUSTOMER_SOURCE" :value="scope.row.source" />
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="客户等级" align="center" prop="level" width="120">
  65. <template #default="scope">
  66. <dict-tag :type="DICT_TYPE.CRM_CUSTOMER_LEVEL" :value="scope.row.level" />
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="手机" align="center" prop="mobile" width="120" />
  70. <el-table-column label="详细地址" align="center" prop="detailAddress" width="200" />
  71. <!-- TODO @Wanwan 负责人回显,所属部门,创建人 -->
  72. <el-table-column label="负责人" align="center" prop="ownerUserId" />
  73. <el-table-column
  74. label="创建时间"
  75. align="center"
  76. prop="createTime"
  77. :formatter="dateFormatter"
  78. width="180px"
  79. />
  80. <el-table-column label="成交状态" align="center" prop="dealStatus">
  81. <template #default="scope">
  82. <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.dealStatus" />
  83. </template>
  84. </el-table-column>
  85. <el-table-column
  86. label="下次联系时间"
  87. align="center"
  88. prop="contactNextTime"
  89. :formatter="dateFormatter"
  90. width="180px"
  91. />
  92. <el-table-column
  93. label="最后跟进时间"
  94. align="center"
  95. prop="contactLastTime"
  96. :formatter="dateFormatter"
  97. width="180px"
  98. />
  99. <el-table-column label="锁定状态" align="center" prop="lockStatus">
  100. <template #default="scope">
  101. <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.lockStatus" />
  102. </template>
  103. </el-table-column>
  104. <!-- TODO @Wanwan 距进入公海天数 -->
  105. <el-table-column label="操作" align="center" width="160">
  106. <template #default="scope">
  107. <el-button
  108. link
  109. type="primary"
  110. @click="openForm('update', scope.row.id)"
  111. v-hasPermi="['crm:customer:update']"
  112. >
  113. 编辑
  114. </el-button>
  115. <el-button
  116. link
  117. type="danger"
  118. @click="handleDelete(scope.row.id)"
  119. v-hasPermi="['crm:customer:delete']"
  120. >
  121. 删除
  122. </el-button>
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. <!-- 分页 -->
  127. <Pagination
  128. :total="total"
  129. v-model:page="queryParams.pageNo"
  130. v-model:limit="queryParams.pageSize"
  131. @pagination="getList"
  132. />
  133. </ContentWrap>
  134. <!-- 表单弹窗:添加/修改 -->
  135. <CustomerForm ref="formRef" @success="getList" />
  136. </template>
  137. <script setup lang="ts">
  138. import { DICT_TYPE, getBoolDictOptions } from '@/utils/dict'
  139. import { dateFormatter } from '@/utils/formatTime'
  140. import download from '@/utils/download'
  141. import * as CustomerApi from '@/api/crm/customer'
  142. import CustomerForm from './CustomerForm.vue'
  143. defineOptions({ name: 'CrmCustomer' })
  144. const message = useMessage() // 消息弹窗
  145. const { t } = useI18n() // 国际化
  146. const loading = ref(true) // 列表的加载中
  147. const total = ref(0) // 列表的总页数
  148. const list = ref([]) // 列表的数据
  149. const queryParams = reactive({
  150. pageNo: 1,
  151. pageSize: 10,
  152. name: null,
  153. mobile: null
  154. })
  155. const queryFormRef = ref() // 搜索的表单
  156. const exportLoading = ref(false) // 导出的加载中
  157. /** 查询列表 */
  158. const getList = async () => {
  159. loading.value = true
  160. try {
  161. const data = await CustomerApi.getCustomerPage(queryParams)
  162. list.value = data.list
  163. total.value = data.total
  164. } finally {
  165. loading.value = false
  166. }
  167. }
  168. /** 搜索按钮操作 */
  169. const handleQuery = () => {
  170. queryParams.pageNo = 1
  171. getList()
  172. }
  173. /** 重置按钮操作 */
  174. const resetQuery = () => {
  175. queryFormRef.value.resetFields()
  176. handleQuery()
  177. }
  178. /** 添加/修改操作 */
  179. const formRef = ref()
  180. const openForm = (type: string, id?: number) => {
  181. formRef.value.open(type, id)
  182. }
  183. /** 删除按钮操作 */
  184. const handleDelete = async (id: number) => {
  185. try {
  186. // 删除的二次确认
  187. await message.delConfirm()
  188. // 发起删除
  189. await CustomerApi.deleteCustomer(id)
  190. message.success(t('common.delSuccess'))
  191. // 刷新列表
  192. await getList()
  193. } catch {}
  194. }
  195. /** 导出按钮操作 */
  196. const handleExport = async () => {
  197. try {
  198. // 导出的二次确认
  199. await message.exportConfirm()
  200. // 发起导出
  201. exportLoading.value = true
  202. const data = await CustomerApi.exportCustomer(queryParams)
  203. download.excel(data, '客户.xls')
  204. } catch {
  205. } finally {
  206. exportLoading.value = false
  207. }
  208. }
  209. /** 初始化 **/
  210. onMounted(() => {
  211. getList()
  212. })
  213. </script>