index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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="no">
  12. <el-input
  13. v-model="queryParams.no"
  14. class="!w-240px"
  15. clearable
  16. placeholder="请输入合同编号"
  17. @keyup.enter="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="合同名称" prop="name">
  21. <el-input
  22. v-model="queryParams.name"
  23. class="!w-240px"
  24. clearable
  25. placeholder="请输入合同名称"
  26. @keyup.enter="handleQuery"
  27. />
  28. <el-form-item label="客户" prop="customerId">
  29. <el-select
  30. v-model="queryParams.customerId"
  31. class="!w-240px"
  32. clearable
  33. lable-key="name"
  34. placeholder="请选择客户"
  35. value-key="id"
  36. @keyup.enter="handleQuery"
  37. >
  38. <el-option
  39. v-for="item in customerList"
  40. :key="item.id"
  41. :label="item.name"
  42. :value="item.id!"
  43. />
  44. </el-select>
  45. </el-form-item>
  46. </el-form-item>
  47. <el-form-item>
  48. <el-button @click="handleQuery">
  49. <Icon class="mr-5px" icon="ep:search" />
  50. 搜索
  51. </el-button>
  52. <el-button @click="resetQuery">
  53. <Icon class="mr-5px" icon="ep:refresh" />
  54. 重置
  55. </el-button>
  56. <el-button v-hasPermi="['crm:contract:create']" type="primary" @click="openForm('create')">
  57. <Icon class="mr-5px" icon="ep:plus" />
  58. 新增
  59. </el-button>
  60. <el-button
  61. v-hasPermi="['crm:contract:export']"
  62. :loading="exportLoading"
  63. plain
  64. type="success"
  65. @click="handleExport"
  66. >
  67. <Icon class="mr-5px" icon="ep:download" />
  68. 导出
  69. </el-button>
  70. </el-form-item>
  71. </el-form>
  72. </ContentWrap>
  73. <!-- 列表 -->
  74. <ContentWrap>
  75. <el-tabs v-model="activeName" @tab-click="handleTabClick">
  76. <el-tab-pane label="我负责的" name="1" />
  77. <el-tab-pane label="我参与的" name="2" />
  78. <el-tab-pane label="下属负责的" name="3" />
  79. </el-tabs>
  80. <el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
  81. <el-table-column align="center" fixed="left" label="合同编号" prop="no" width="130" />
  82. <el-table-column align="center" fixed="left" label="合同名称" prop="name" width="160">
  83. <template #default="scope">
  84. <el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
  85. {{ scope.row.name }}
  86. </el-link>
  87. </template>
  88. </el-table-column>
  89. <el-table-column align="center" label="客户名称" prop="customerName" width="120">
  90. <template #default="scope">
  91. <el-link
  92. :underline="false"
  93. type="primary"
  94. @click="openCustomerDetail(scope.row.customerId)"
  95. >
  96. {{ scope.row.customerName }}
  97. </el-link>
  98. </template>
  99. </el-table-column>
  100. <el-table-column align="center" label="商机名称" prop="businessName" width="130">
  101. <template #default="scope">
  102. <el-link
  103. :underline="false"
  104. type="primary"
  105. @click="openBusinessDetail(scope.row.businessId)"
  106. >
  107. {{ scope.row.businessName }}
  108. </el-link>
  109. </template>
  110. </el-table-column>
  111. <el-table-column
  112. align="center"
  113. label="合同金额(元)"
  114. prop="totalPrice"
  115. width="140"
  116. :formatter="erpPriceTableColumnFormatter"
  117. />
  118. <el-table-column
  119. align="center"
  120. label="下单时间"
  121. prop="orderDate"
  122. width="120"
  123. :formatter="dateFormatter2"
  124. />
  125. <el-table-column
  126. align="center"
  127. label="合同开始时间"
  128. prop="startTime"
  129. width="120"
  130. :formatter="dateFormatter2"
  131. />
  132. <el-table-column
  133. align="center"
  134. label="合同结束时间"
  135. prop="endTime"
  136. width="120"
  137. :formatter="dateFormatter2"
  138. />
  139. <el-table-column align="center" label="客户签约人" prop="contactName" width="130">
  140. <template #default="scope">
  141. <el-link
  142. :underline="false"
  143. type="primary"
  144. @click="openContactDetail(scope.row.signContactId)"
  145. >
  146. {{ scope.row.signContactName }}
  147. </el-link>
  148. </template>
  149. </el-table-column>
  150. <el-table-column align="center" label="公司签约人" prop="signUserName" width="130" />
  151. <el-table-column align="center" label="备注" prop="remark" width="200" />
  152. <!-- TODO @puhui999:后续可加 【已收款金额】、【未收款金额】 -->
  153. <el-table-column
  154. :formatter="dateFormatter"
  155. align="center"
  156. label="最后跟进时间"
  157. prop="contactLastTime"
  158. width="180px"
  159. />
  160. <el-table-column align="center" label="负责人" prop="ownerUserName" width="120" />
  161. <el-table-column align="center" label="所属部门" prop="ownerUserDeptName" width="100px" />
  162. <el-table-column
  163. :formatter="dateFormatter"
  164. align="center"
  165. label="更新时间"
  166. prop="updateTime"
  167. width="180px"
  168. />
  169. <el-table-column
  170. :formatter="dateFormatter"
  171. align="center"
  172. label="创建时间"
  173. prop="createTime"
  174. width="180px"
  175. />
  176. <el-table-column align="center" label="创建人" prop="creatorName" width="120" />
  177. <el-table-column align="center" fixed="right" label="合同状态" prop="auditStatus" width="120">
  178. <template #default="scope">
  179. <dict-tag :type="DICT_TYPE.CRM_AUDIT_STATUS" :value="scope.row.auditStatus" />
  180. </template>
  181. </el-table-column>
  182. <el-table-column fixed="right" label="操作" width="250">
  183. <template #default="scope">
  184. <el-button
  185. v-hasPermi="['crm:contract:update']"
  186. link
  187. type="primary"
  188. @click="openForm('update', scope.row.id)"
  189. >
  190. 编辑
  191. </el-button>
  192. <!-- TODO @puhui999:可以加下判断,什么情况下,可以审批;然后加个【查看审批】按钮 -->
  193. <el-button
  194. v-hasPermi="['crm:contract:update']"
  195. link
  196. type="primary"
  197. @click="handleSubmit(scope.row)"
  198. >
  199. 提交审核
  200. </el-button>
  201. <el-button
  202. v-hasPermi="['crm:contract:query']"
  203. link
  204. type="primary"
  205. @click="openDetail(scope.row.id)"
  206. >
  207. 详情
  208. </el-button>
  209. <el-button
  210. v-hasPermi="['crm:contract:delete']"
  211. link
  212. type="danger"
  213. @click="handleDelete(scope.row.id)"
  214. >
  215. 删除
  216. </el-button>
  217. </template>
  218. </el-table-column>
  219. </el-table>
  220. <!-- 分页 -->
  221. <Pagination
  222. v-model:limit="queryParams.pageSize"
  223. v-model:page="queryParams.pageNo"
  224. :total="total"
  225. @pagination="getList"
  226. />
  227. </ContentWrap>
  228. <!-- 表单弹窗:添加/修改 -->
  229. <ContractForm ref="formRef" @success="getList" />
  230. </template>
  231. <script lang="ts" setup>
  232. import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
  233. import download from '@/utils/download'
  234. import * as ContractApi from '@/api/crm/contract'
  235. import ContractForm from './ContractForm.vue'
  236. import { fenToYuanFormat } from '@/utils/formatter'
  237. import { DICT_TYPE } from '@/utils/dict'
  238. import { erpPriceTableColumnFormatter } from '@/utils'
  239. import * as CustomerApi from '@/api/crm/customer'
  240. defineOptions({ name: 'CrmContract' })
  241. const message = useMessage() // 消息弹窗
  242. const { t } = useI18n() // 国际化
  243. const loading = ref(true) // 列表的加载中
  244. const total = ref(0) // 列表的总页数
  245. const list = ref([]) // 列表的数据
  246. const queryParams = reactive({
  247. pageNo: 1,
  248. pageSize: 10,
  249. sceneType: '1', // 默认和 activeName 相等
  250. name: null,
  251. customerId: null,
  252. orderDate: [],
  253. no: null
  254. })
  255. const queryFormRef = ref() // 搜索的表单
  256. const exportLoading = ref(false) // 导出的加载中
  257. const activeName = ref('1') // 列表 tab
  258. const customerList = ref<CustomerApi.CustomerVO[]>([]) // 客户列表
  259. /** 查询列表 */
  260. const getList = async () => {
  261. loading.value = true
  262. try {
  263. const data = await ContractApi.getContractPage(queryParams)
  264. list.value = data.list
  265. total.value = data.total
  266. } finally {
  267. loading.value = false
  268. }
  269. }
  270. /** 搜索按钮操作 */
  271. const handleQuery = () => {
  272. queryParams.pageNo = 1
  273. getList()
  274. }
  275. /** 重置按钮操作 */
  276. const resetQuery = () => {
  277. queryFormRef.value.resetFields()
  278. handleQuery()
  279. }
  280. /** 添加/修改操作 */
  281. const formRef = ref()
  282. const openForm = (type: string, id?: number) => {
  283. formRef.value.open(type, id)
  284. }
  285. /** 删除按钮操作 */
  286. const handleDelete = async (id: number) => {
  287. try {
  288. // 删除的二次确认
  289. await message.delConfirm()
  290. // 发起删除
  291. await ContractApi.deleteContract(id)
  292. message.success(t('common.delSuccess'))
  293. // 刷新列表
  294. await getList()
  295. } catch {}
  296. }
  297. /** 导出按钮操作 */
  298. const handleExport = async () => {
  299. try {
  300. // 导出的二次确认
  301. await message.exportConfirm()
  302. // 发起导出
  303. exportLoading.value = true
  304. const data = await ContractApi.exportContract(queryParams)
  305. download.excel(data, '合同.xls')
  306. } catch {
  307. } finally {
  308. exportLoading.value = false
  309. }
  310. }
  311. /** 提交审核 **/
  312. const handleSubmit = async (row: ContractApi.ContractVO) => {
  313. await message.confirm(`您确定提交【${row.name}】审核吗?`)
  314. await ContractApi.submitContract(row.id)
  315. message.success('提交审核成功!')
  316. await getList()
  317. }
  318. /** 打开合同详情 */
  319. const { push } = useRouter()
  320. const openDetail = (id: number) => {
  321. push({ name: 'CrmContractDetail', params: { id } })
  322. }
  323. /** 打开客户详情 */
  324. const openCustomerDetail = (id: number) => {
  325. push({ name: 'CrmCustomerDetail', params: { id } })
  326. }
  327. /** 打开联系人详情 */
  328. const openContactDetail = (id: number) => {
  329. push({ name: 'CrmContactDetail', params: { id } })
  330. }
  331. /** 打开商机详情 */
  332. const openBusinessDetail = (id: number) => {
  333. push({ name: 'CrmBusinessDetail', params: { id } })
  334. }
  335. /** 初始化 **/
  336. onMounted(async () => {
  337. await getList()
  338. customerList.value = await CustomerApi.getCustomerSimpleList()
  339. })
  340. </script>