index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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>
  21. <el-button @click="handleQuery">
  22. <Icon class="mr-5px" icon="ep:search" />
  23. 搜索
  24. </el-button>
  25. <el-button @click="resetQuery">
  26. <Icon class="mr-5px" icon="ep:refresh" />
  27. 重置
  28. </el-button>
  29. <el-button v-hasPermi="['crm:business:create']" type="primary" @click="openForm('create')">
  30. <Icon class="mr-5px" icon="ep:plus" />
  31. 新增
  32. </el-button>
  33. <el-button
  34. v-hasPermi="['crm:business:export']"
  35. :loading="exportLoading"
  36. plain
  37. type="success"
  38. @click="handleExport"
  39. >
  40. <Icon class="mr-5px" icon="ep:download" />
  41. 导出
  42. </el-button>
  43. </el-form-item>
  44. </el-form>
  45. </ContentWrap>
  46. <!-- 列表 -->
  47. <ContentWrap>
  48. <el-tabs v-model="activeName" @tab-click="handleTabClick">
  49. <el-tab-pane label="我负责的" name="1" />
  50. <el-tab-pane label="我参与的" name="2" />
  51. <el-tab-pane label="下属负责的" name="3" />
  52. </el-tabs>
  53. <el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
  54. <el-table-column align="center" fixed="left" label="商机名称" prop="name" width="160">
  55. <template #default="scope">
  56. <el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
  57. {{ scope.row.name }}
  58. </el-link>
  59. </template>
  60. </el-table-column>
  61. <el-table-column align="center" fixed="left" label="客户名称" prop="customerName" width="120">
  62. <template #default="scope">
  63. <el-link
  64. :underline="false"
  65. type="primary"
  66. @click="openCustomerDetail(scope.row.customerId)"
  67. >
  68. {{ scope.row.customerName }}
  69. </el-link>
  70. </template>
  71. </el-table-column>
  72. <el-table-column
  73. :formatter="erpPriceTableColumnFormatter"
  74. align="center"
  75. label="商机金额(元)"
  76. prop="totalPrice"
  77. width="140"
  78. />
  79. <el-table-column
  80. :formatter="dateFormatter"
  81. align="center"
  82. label="预计成交日期"
  83. prop="dealTime"
  84. width="180px"
  85. />
  86. <el-table-column align="center" label="备注" prop="remark" width="200" />
  87. <el-table-column
  88. :formatter="dateFormatter"
  89. align="center"
  90. label="下次联系时间"
  91. prop="contactNextTime"
  92. width="180px"
  93. />
  94. <el-table-column align="center" label="负责人" prop="ownerUserName" width="100px" />
  95. <el-table-column align="center" label="所属部门" prop="ownerUserDeptName" width="100px" />
  96. <el-table-column
  97. :formatter="dateFormatter"
  98. align="center"
  99. label="最后跟进时间"
  100. prop="contactLastTime"
  101. width="180px"
  102. />
  103. <el-table-column
  104. :formatter="dateFormatter"
  105. align="center"
  106. label="更新时间"
  107. prop="updateTime"
  108. width="180px"
  109. />
  110. <el-table-column
  111. :formatter="dateFormatter"
  112. align="center"
  113. label="创建时间"
  114. prop="createTime"
  115. width="180px"
  116. />
  117. <el-table-column align="center" label="创建人" prop="creatorName" width="100px" />
  118. <el-table-column
  119. align="center"
  120. fixed="right"
  121. label="商机状态组"
  122. prop="statusTypeName"
  123. width="140"
  124. />
  125. <el-table-column
  126. align="center"
  127. fixed="right"
  128. label="商机阶段"
  129. prop="statusName"
  130. width="120"
  131. />
  132. <el-table-column align="center" fixed="right" label="操作" width="130px">
  133. <template #default="scope">
  134. <el-button
  135. v-hasPermi="['crm:business:update']"
  136. link
  137. type="primary"
  138. @click="openForm('update', scope.row.id)"
  139. >
  140. 编辑
  141. </el-button>
  142. <el-button
  143. v-hasPermi="['crm:business:delete']"
  144. link
  145. type="danger"
  146. @click="handleDelete(scope.row.id)"
  147. >
  148. 删除
  149. </el-button>
  150. </template>
  151. </el-table-column>
  152. </el-table>
  153. <!-- 分页 -->
  154. <Pagination
  155. v-model:limit="queryParams.pageSize"
  156. v-model:page="queryParams.pageNo"
  157. :total="total"
  158. @pagination="getList"
  159. />
  160. </ContentWrap>
  161. <!-- 表单弹窗:添加/修改 -->
  162. <BusinessForm ref="formRef" @success="getList" />
  163. </template>
  164. <script lang="ts" setup>
  165. import { dateFormatter } from '@/utils/formatTime'
  166. import download from '@/utils/download'
  167. import * as BusinessApi from '@/api/crm/business'
  168. import BusinessForm from './BusinessForm.vue'
  169. import { erpPriceTableColumnFormatter } from '@/utils'
  170. import { TabsPaneContext } from 'element-plus'
  171. defineOptions({ name: 'CrmBusiness' })
  172. const message = useMessage() // 消息弹窗
  173. const { t } = useI18n() // 国际化
  174. const loading = ref(true) // 列表的加载中
  175. const total = ref(0) // 列表的总页数
  176. const list = ref([]) // 列表的数据
  177. const queryParams = reactive({
  178. pageNo: 1,
  179. pageSize: 10,
  180. sceneType: '1', // 默认和 activeName 相等
  181. name: null
  182. })
  183. const queryFormRef = ref() // 搜索的表单
  184. const exportLoading = ref(false) // 导出的加载中
  185. const activeName = ref('1') // 列表 tab
  186. /** 查询列表 */
  187. const getList = async () => {
  188. loading.value = true
  189. try {
  190. const data = await BusinessApi.getBusinessPage(queryParams)
  191. list.value = data.list
  192. total.value = data.total
  193. } finally {
  194. loading.value = false
  195. }
  196. }
  197. /** 搜索按钮操作 */
  198. const handleQuery = () => {
  199. queryParams.pageNo = 1
  200. getList()
  201. }
  202. /** 重置按钮操作 */
  203. const resetQuery = () => {
  204. queryFormRef.value.resetFields()
  205. handleQuery()
  206. }
  207. /** tab 切换 */
  208. const handleTabClick = (tab: TabsPaneContext) => {
  209. queryParams.sceneType = tab.paneName
  210. handleQuery()
  211. }
  212. /** 打开客户详情 */
  213. const { push } = useRouter()
  214. const openDetail = (id: number) => {
  215. push({ name: 'CrmBusinessDetail', params: { id } })
  216. }
  217. /** 打开客户详情 */
  218. const openCustomerDetail = (id: number) => {
  219. push({ name: 'CrmCustomerDetail', params: { id } })
  220. }
  221. /** 添加/修改操作 */
  222. const formRef = ref()
  223. const openForm = (type: string, id?: number) => {
  224. formRef.value.open(type, id)
  225. }
  226. /** 删除按钮操作 */
  227. const handleDelete = async (id: number) => {
  228. try {
  229. // 删除的二次确认
  230. await message.delConfirm()
  231. // 发起删除
  232. await BusinessApi.deleteBusiness(id)
  233. message.success(t('common.delSuccess'))
  234. // 刷新列表
  235. await getList()
  236. } catch {}
  237. }
  238. /** 导出按钮操作 */
  239. const handleExport = async () => {
  240. try {
  241. // 导出的二次确认
  242. await message.exportConfirm()
  243. // 发起导出
  244. exportLoading.value = true
  245. const data = await BusinessApi.exportBusiness(queryParams)
  246. download.excel(data, '商机.xls')
  247. } catch {
  248. } finally {
  249. exportLoading.value = false
  250. }
  251. }
  252. /** 初始化 **/
  253. onMounted(() => {
  254. getList()
  255. })
  256. </script>