index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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">
  80. <Icon class="mr-5px" icon="ep:refresh" />
  81. 重置
  82. </el-button>
  83. <el-button v-hasPermi="['crm:customer:create']" type="primary" @click="openForm('create')">
  84. <Icon class="mr-5px" icon="ep:plus" />
  85. 新增
  86. </el-button>
  87. <el-button v-hasPermi="['crm:customer:import']" plain type="warning" @click="handleImport">
  88. <Icon icon="ep:upload" />
  89. 导入
  90. </el-button>
  91. <el-button
  92. v-hasPermi="['crm:customer:export']"
  93. :loading="exportLoading"
  94. plain
  95. type="success"
  96. @click="handleExport"
  97. >
  98. <Icon class="mr-5px" icon="ep:download" />
  99. 导出
  100. </el-button>
  101. </el-form-item>
  102. </el-form>
  103. </ContentWrap>
  104. <!-- 列表 -->
  105. <ContentWrap>
  106. <el-tabs v-model="activeName" @tab-click="handleTabClick">
  107. <el-tab-pane label="我负责的" name="1" />
  108. <el-tab-pane label="我参与的" name="2" />
  109. <el-tab-pane label="下属负责的" name="3" />
  110. </el-tabs>
  111. <el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
  112. <el-table-column align="center" fixed="left" label="客户名称" prop="name" width="160">
  113. <template #default="scope">
  114. <el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
  115. {{ scope.row.name }}
  116. </el-link>
  117. </template>
  118. </el-table-column>
  119. <el-table-column align="center" label="客户来源" prop="source" width="100">
  120. <template #default="scope">
  121. <dict-tag :type="DICT_TYPE.CRM_CUSTOMER_SOURCE" :value="scope.row.source" />
  122. </template>
  123. </el-table-column>
  124. <el-table-column align="center" label="手机" prop="mobile" width="120" />
  125. <el-table-column align="center" label="电话" prop="telephone" width="130" />
  126. <el-table-column align="center" label="邮箱" prop="email" width="180" />
  127. <el-table-column align="center" label="客户级别" prop="level" width="135">
  128. <template #default="scope">
  129. <dict-tag :type="DICT_TYPE.CRM_CUSTOMER_LEVEL" :value="scope.row.level" />
  130. </template>
  131. </el-table-column>
  132. <el-table-column align="center" label="客户行业" prop="industryId" width="100">
  133. <template #default="scope">
  134. <dict-tag :type="DICT_TYPE.CRM_CUSTOMER_INDUSTRY" :value="scope.row.industryId" />
  135. </template>
  136. </el-table-column>
  137. <el-table-column
  138. :formatter="dateFormatter"
  139. align="center"
  140. label="下次联系时间"
  141. prop="contactNextTime"
  142. width="180px"
  143. />
  144. <el-table-column align="center" label="备注" prop="remark" width="200" />
  145. <el-table-column align="center" label="锁定状态" prop="lockStatus">
  146. <template #default="scope">
  147. <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.lockStatus" />
  148. </template>
  149. </el-table-column>
  150. <el-table-column align="center" label="成交状态" prop="dealStatus">
  151. <template #default="scope">
  152. <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.dealStatus" />
  153. </template>
  154. </el-table-column>
  155. <el-table-column
  156. :formatter="dateFormatter"
  157. align="center"
  158. label="最后跟进时间"
  159. prop="contactLastTime"
  160. width="180px"
  161. />
  162. <el-table-column align="center" label="最后跟进记录" prop="contactLastContent" width="200" />
  163. <el-table-column align="center" label="地址" prop="detailAddress" width="180" />
  164. <el-table-column align="center" label="距离进入公海天数" prop="poolDay" width="140">
  165. <template #default="scope"> {{ scope.row.poolDay }} 天</template>
  166. </el-table-column>
  167. <el-table-column align="center" label="负责人" prop="ownerUserName" width="100px" />
  168. <el-table-column align="center" label="所属部门" prop="ownerUserDeptName" width="100px" />
  169. <el-table-column
  170. :formatter="dateFormatter"
  171. align="center"
  172. label="更新时间"
  173. prop="updateTime"
  174. width="180px"
  175. />
  176. <el-table-column
  177. :formatter="dateFormatter"
  178. align="center"
  179. label="创建时间"
  180. prop="createTime"
  181. width="180px"
  182. />
  183. <el-table-column align="center" label="创建人" prop="creatorName" width="100px" />
  184. <el-table-column align="center" fixed="right" label="操作" min-width="150">
  185. <template #default="scope">
  186. <el-button
  187. v-hasPermi="['crm:customer:update']"
  188. link
  189. type="primary"
  190. @click="openForm('update', scope.row.id)"
  191. >
  192. 编辑
  193. </el-button>
  194. <el-button
  195. v-hasPermi="['crm:customer:delete']"
  196. link
  197. type="danger"
  198. @click="handleDelete(scope.row.id)"
  199. >
  200. 删除
  201. </el-button>
  202. </template>
  203. </el-table-column>
  204. </el-table>
  205. <!-- 分页 -->
  206. <Pagination
  207. v-model:limit="queryParams.pageSize"
  208. v-model:page="queryParams.pageNo"
  209. :total="total"
  210. @pagination="getList"
  211. />
  212. </ContentWrap>
  213. <!-- 表单弹窗:添加/修改 -->
  214. <CustomerForm ref="formRef" @success="getList" />
  215. <CustomerImportForm ref="importFormRef" @success="getList" />
  216. </template>
  217. <script lang="ts" setup>
  218. import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
  219. import { dateFormatter } from '@/utils/formatTime'
  220. import download from '@/utils/download'
  221. import * as CustomerApi from '@/api/crm/customer'
  222. import CustomerForm from './CustomerForm.vue'
  223. import CustomerImportForm from './CustomerImportForm.vue'
  224. import { TabsPaneContext } from 'element-plus'
  225. defineOptions({ name: 'CrmCustomer' })
  226. const message = useMessage() // 消息弹窗
  227. const { t } = useI18n() // 国际化
  228. const loading = ref(true) // 列表的加载中
  229. const total = ref(0) // 列表的总页数
  230. const list = ref([]) // 列表的数据
  231. const queryParams = reactive({
  232. pageNo: 1,
  233. pageSize: 10,
  234. sceneType: '1', // 默认和 activeName 相等
  235. name: '',
  236. mobile: '',
  237. industryId: undefined,
  238. level: undefined,
  239. source: undefined,
  240. pool: undefined
  241. })
  242. const queryFormRef = ref() // 搜索的表单
  243. const exportLoading = ref(false) // 导出的加载中
  244. const activeName = ref('1') // 列表 tab
  245. /** tab 切换 */
  246. const handleTabClick = (tab: TabsPaneContext) => {
  247. queryParams.sceneType = tab.paneName as string
  248. handleQuery()
  249. }
  250. /** 查询列表 */
  251. const getList = async () => {
  252. loading.value = true
  253. try {
  254. const data = await CustomerApi.getCustomerPage(queryParams)
  255. list.value = data.list
  256. total.value = data.total
  257. } finally {
  258. loading.value = false
  259. }
  260. }
  261. /** 搜索按钮操作 */
  262. const handleQuery = () => {
  263. queryParams.pageNo = 1
  264. getList()
  265. }
  266. /** 重置按钮操作 */
  267. const resetQuery = () => {
  268. queryFormRef.value.resetFields()
  269. handleQuery()
  270. }
  271. /** 打开客户详情 */
  272. const { currentRoute, push } = useRouter()
  273. const openDetail = (id: number) => {
  274. push({ name: 'CrmCustomerDetail', params: { id } })
  275. }
  276. /** 添加/修改操作 */
  277. const formRef = ref()
  278. const openForm = (type: string, id?: number) => {
  279. formRef.value.open(type, id)
  280. }
  281. /** 删除按钮操作 */
  282. const handleDelete = async (id: number) => {
  283. try {
  284. // 删除的二次确认
  285. await message.delConfirm()
  286. // 发起删除
  287. await CustomerApi.deleteCustomer(id)
  288. message.success(t('common.delSuccess'))
  289. // 刷新列表
  290. await getList()
  291. } catch {}
  292. }
  293. /** 导入按钮操作 */
  294. const importFormRef = ref<InstanceType<typeof CustomerImportForm>>()
  295. const handleImport = () => {
  296. importFormRef.value?.open()
  297. }
  298. /** 导出按钮操作 */
  299. const handleExport = async () => {
  300. try {
  301. // 导出的二次确认
  302. await message.exportConfirm()
  303. // 发起导出
  304. exportLoading.value = true
  305. const data = await CustomerApi.exportCustomer(queryParams)
  306. download.excel(data, '客户.xls')
  307. } catch {
  308. } finally {
  309. exportLoading.value = false
  310. }
  311. }
  312. /** 监听路由变化更新列表 */
  313. watch(
  314. () => currentRoute.value,
  315. () => {
  316. getList()
  317. }
  318. )
  319. /** 初始化 **/
  320. onMounted(() => {
  321. getList()
  322. })
  323. </script>