index.vue 6.7 KB

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