index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <ContentWrap>
  3. <!-- 搜索工作栏 -->
  4. <!-- TODO zyna:筛选项,按照需求简化下 -->
  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="customerId">
  13. <el-input
  14. v-model="queryParams.customerId"
  15. placeholder="请输入客户编号"
  16. clearable
  17. @keyup.enter="handleQuery"
  18. class="!w-240px"
  19. />
  20. </el-form-item>
  21. <el-form-item label="姓名" prop="name">
  22. <el-input
  23. v-model="queryParams.name"
  24. placeholder="请输入姓名"
  25. clearable
  26. @keyup.enter="handleQuery"
  27. class="!w-240px"
  28. />
  29. </el-form-item>
  30. <el-form-item label="手机号" prop="mobile">
  31. <el-input
  32. v-model="queryParams.mobile"
  33. placeholder="请输入手机号"
  34. clearable
  35. @keyup.enter="handleQuery"
  36. class="!w-240px"
  37. />
  38. </el-form-item>
  39. <el-form-item label="座机" prop="telephone">
  40. <el-input
  41. v-model="queryParams.telephone"
  42. placeholder="请输入电话"
  43. clearable
  44. @keyup.enter="handleQuery"
  45. class="!w-240px"
  46. />
  47. </el-form-item>
  48. <el-form-item label="QQ" prop="qq">
  49. <el-input
  50. v-model="queryParams.qq"
  51. placeholder="请输入QQ"
  52. clearable
  53. @keyup.enter="handleQuery"
  54. class="!w-240px"
  55. />
  56. </el-form-item>
  57. <el-form-item label="微信" prop="wechat">
  58. <el-input
  59. v-model="queryParams.wechat"
  60. placeholder="请输入微信"
  61. clearable
  62. @keyup.enter="handleQuery"
  63. class="!w-240px"
  64. />
  65. </el-form-item>
  66. <el-form-item label="电子邮箱" prop="email">
  67. <el-input
  68. v-model="queryParams.email"
  69. placeholder="请输入电子邮箱"
  70. clearable
  71. @keyup.enter="handleQuery"
  72. class="!w-240px"
  73. />
  74. </el-form-item>
  75. <el-form-item>
  76. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  77. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  78. <el-button type="primary" @click="openForm('create')" v-hasPermi="['crm:contact:create']">
  79. <Icon icon="ep:plus" class="mr-5px" /> 新增
  80. </el-button>
  81. <el-button
  82. type="success"
  83. plain
  84. @click="handleExport"
  85. :loading="exportLoading"
  86. v-hasPermi="['crm:contact:export']"
  87. >
  88. <Icon icon="ep:download" class="mr-5px" /> 导出
  89. </el-button>
  90. </el-form-item>
  91. </el-form>
  92. </ContentWrap>
  93. <!-- 列表 -->
  94. <ContentWrap>
  95. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  96. <el-table-column label="姓名" fixed="left" align="center" prop="name">
  97. <template #default="scope">
  98. <el-link type="primary" :underline="false" @click="openDetail(scope.row.id)">{{
  99. scope.row.name
  100. }}</el-link>
  101. </template>
  102. </el-table-column>
  103. <el-table-column label="客户名称" fixed="left" align="center" prop="customerName" />
  104. <el-table-column label="性别" align="center" prop="sex">
  105. <template #default="scope">
  106. <dict-tag :type="DICT_TYPE.SYSTEM_USER_SEX" :value="scope.row.sex" />
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="职位" align="center" prop="post" />
  110. <el-table-column label="是否关键决策人" align="center" prop="master">
  111. <template #default="scope">
  112. <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.master" />
  113. </template>
  114. </el-table-column>
  115. <el-table-column label="直属上级" align="center" prop="parentName"/>
  116. <el-table-column label="手机号" align="center" prop="mobile" />
  117. <el-table-column label="座机" align="center" prop="telephone" />
  118. <el-table-column label="QQ" align="center" prop="qq" />
  119. <el-table-column label="微信" align="center" prop="wechat" />
  120. <el-table-column label="邮箱" align="center" prop="email" />
  121. <el-table-column label="地址" align="center" prop="address" />
  122. <el-table-column
  123. label="下次联系时间"
  124. align="center"
  125. prop="nextTime"
  126. width="180px"
  127. :formatter="dateFormatter"
  128. />
  129. <el-table-column label="备注" align="center" prop="remark" />
  130. <el-table-column
  131. label="最后跟进时间"
  132. align="center"
  133. prop="lastTime"
  134. :formatter="dateFormatter"
  135. width="180px"
  136. />
  137. <el-table-column label="负责人" align="center" prop="ownerUserId">
  138. <template #default="scope">
  139. {{ scope.row.ownerUserName}}
  140. </template>
  141. </el-table-column>
  142. <!-- <el-table-column label="所属部门" align="center" prop="ownerUserId" /> -->
  143. <el-table-column
  144. label="更新时间"
  145. align="center"
  146. prop="updateTime"
  147. :formatter="dateFormatter"
  148. width="180px"
  149. />
  150. <el-table-column
  151. label="创建时间"
  152. align="center"
  153. prop="createTime"
  154. :formatter="dateFormatter"
  155. width="180px"
  156. />
  157. <!-- <el-table-column
  158. label="创建人"
  159. align="center"
  160. prop="creator"
  161. :formatter="dateFormatter"
  162. width="180px"
  163. >
  164. <template #default="scope">
  165. {{ userList.find((user) => user.id === scope.row.creator)?.nickname }}
  166. </template>
  167. </el-table-column> -->
  168. <el-table-column label="操作" align="center" fixed="right" width="200">
  169. <template #default="scope">
  170. <el-button
  171. plain
  172. type="primary"
  173. @click="openForm('update', scope.row.id)"
  174. v-hasPermi="['crm:contact:update']"
  175. >
  176. 编辑
  177. </el-button>
  178. <el-button
  179. plain
  180. type="danger"
  181. @click="handleDelete(scope.row.id)"
  182. v-hasPermi="['crm:contact:delete']"
  183. >
  184. 删除
  185. </el-button>
  186. </template>
  187. </el-table-column>
  188. </el-table>
  189. <!-- 分页 -->
  190. <Pagination
  191. :total="total"
  192. v-model:page="queryParams.pageNo"
  193. v-model:limit="queryParams.pageSize"
  194. @pagination="getList"
  195. />
  196. </ContentWrap>
  197. <!-- 表单弹窗:添加/修改 -->
  198. <ContactForm ref="formRef" @success="getList" />
  199. </template>
  200. <script setup lang="ts">
  201. import { dateFormatter } from '@/utils/formatTime'
  202. import download from '@/utils/download'
  203. import * as ContactApi from '@/api/crm/contact'
  204. import ContactForm from './ContactForm.vue'
  205. import { DICT_TYPE } from '@/utils/dict'
  206. import * as UserApi from '@/api/system/user'
  207. import * as CustomerApi from '@/api/crm/customer'
  208. defineOptions({ name: 'CrmContact' })
  209. const message = useMessage() // 消息弹窗
  210. const { t } = useI18n() // 国际化
  211. const loading = ref(true) // 列表的加载中
  212. const total = ref(0) // 列表的总页数
  213. const list = ref([]) // 列表的数据
  214. const queryParams = reactive({
  215. pageNo: 1,
  216. pageSize: 10,
  217. nextTime: [],
  218. mobile: null,
  219. telephone: null,
  220. email: null,
  221. customerId: null,
  222. address: null,
  223. remark: null,
  224. ownerUserId: null,
  225. createTime: [],
  226. lastTime: [],
  227. parentId: null,
  228. name: null,
  229. post: null,
  230. qq: null,
  231. wechat: null,
  232. sex: null,
  233. policyMakers: null
  234. })
  235. const queryFormRef = ref() // 搜索的表单
  236. const exportLoading = ref(false) // 导出的加载中
  237. /** 查询列表 */
  238. const getList = async () => {
  239. loading.value = true
  240. try {
  241. const data = await ContactApi.getContactPage(queryParams)
  242. list.value = data.list
  243. total.value = data.total
  244. } finally {
  245. loading.value = false
  246. }
  247. }
  248. /** 搜索按钮操作 */
  249. const handleQuery = () => {
  250. queryParams.pageNo = 1
  251. getList()
  252. }
  253. /** 重置按钮操作 */
  254. const resetQuery = () => {
  255. queryFormRef.value.resetFields()
  256. handleQuery()
  257. }
  258. /** 添加/修改操作 */
  259. const formRef = ref()
  260. const openForm = (type: string, id?: number) => {
  261. formRef.value.open(type, id)
  262. }
  263. /** 删除按钮操作 */
  264. const handleDelete = async (id: number) => {
  265. try {
  266. // 删除的二次确认
  267. await message.delConfirm()
  268. // 发起删除
  269. await ContactApi.deleteContact(id)
  270. message.success(t('common.delSuccess'))
  271. // 刷新列表
  272. await getList()
  273. } catch {}
  274. }
  275. /** 导出按钮操作 */
  276. const handleExport = async () => {
  277. try {
  278. // 导出的二次确认
  279. await message.exportConfirm()
  280. // 发起导出
  281. exportLoading.value = true
  282. const data = await ContactApi.exportContact(queryParams)
  283. download.excel(data, '联系人.xls')
  284. } catch {
  285. } finally {
  286. exportLoading.value = false
  287. }
  288. }
  289. /** 打开客户详情 */
  290. const { push } = useRouter()
  291. const openDetail = (id: number) => {
  292. push({ name: 'CrmContactDetail', params: { id } })
  293. }
  294. /** 初始化 **/
  295. onMounted(async () => {
  296. await getList()
  297. })
  298. </script>