index.vue 7.3 KB

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