index.vue 7.6 KB

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