index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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-if="scope.row.auditStatus === 0"
  186. v-hasPermi="['crm:contract:update']"
  187. link
  188. type="primary"
  189. @click="openForm('update', scope.row.id)"
  190. >
  191. 编辑
  192. </el-button>
  193. <el-button
  194. v-if="scope.row.auditStatus === 0"
  195. v-hasPermi="['crm:contract:update']"
  196. link
  197. type="primary"
  198. @click="handleSubmit(scope.row)"
  199. >
  200. 提交审核
  201. </el-button>
  202. <el-button
  203. v-else
  204. link
  205. v-hasPermi="['crm:contract:update']"
  206. type="primary"
  207. @click="handleProcessDetail(scope.row)"
  208. >
  209. 查看审批
  210. </el-button>
  211. <el-button
  212. v-hasPermi="['crm:contract:query']"
  213. link
  214. type="primary"
  215. @click="openDetail(scope.row.id)"
  216. >
  217. 详情
  218. </el-button>
  219. <el-button
  220. v-hasPermi="['crm:contract:delete']"
  221. link
  222. type="danger"
  223. @click="handleDelete(scope.row.id)"
  224. >
  225. 删除
  226. </el-button>
  227. </template>
  228. </el-table-column>
  229. </el-table>
  230. <!-- 分页 -->
  231. <Pagination
  232. v-model:limit="queryParams.pageSize"
  233. v-model:page="queryParams.pageNo"
  234. :total="total"
  235. @pagination="getList"
  236. />
  237. </ContentWrap>
  238. <!-- 表单弹窗:添加/修改 -->
  239. <ContractForm ref="formRef" @success="getList" />
  240. </template>
  241. <script lang="ts" setup>
  242. import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
  243. import download from '@/utils/download'
  244. import * as ContractApi from '@/api/crm/contract'
  245. import ContractForm from './ContractForm.vue'
  246. import { fenToYuanFormat } from '@/utils/formatter'
  247. import { DICT_TYPE } from '@/utils/dict'
  248. import { erpPriceTableColumnFormatter } from '@/utils'
  249. import * as CustomerApi from '@/api/crm/customer'
  250. defineOptions({ name: 'CrmContract' })
  251. const message = useMessage() // 消息弹窗
  252. const { t } = useI18n() // 国际化
  253. const loading = ref(true) // 列表的加载中
  254. const total = ref(0) // 列表的总页数
  255. const list = ref([]) // 列表的数据
  256. const queryParams = reactive({
  257. pageNo: 1,
  258. pageSize: 10,
  259. sceneType: '1', // 默认和 activeName 相等
  260. name: null,
  261. customerId: null,
  262. orderDate: [],
  263. no: null
  264. })
  265. const queryFormRef = ref() // 搜索的表单
  266. const exportLoading = ref(false) // 导出的加载中
  267. const activeName = ref('1') // 列表 tab
  268. const customerList = ref<CustomerApi.CustomerVO[]>([]) // 客户列表
  269. /** 查询列表 */
  270. const getList = async () => {
  271. loading.value = true
  272. try {
  273. const data = await ContractApi.getContractPage(queryParams)
  274. list.value = data.list
  275. total.value = data.total
  276. } finally {
  277. loading.value = false
  278. }
  279. }
  280. /** 搜索按钮操作 */
  281. const handleQuery = () => {
  282. queryParams.pageNo = 1
  283. getList()
  284. }
  285. /** 重置按钮操作 */
  286. const resetQuery = () => {
  287. queryFormRef.value.resetFields()
  288. handleQuery()
  289. }
  290. /** 添加/修改操作 */
  291. const formRef = ref()
  292. const openForm = (type: string, id?: number) => {
  293. formRef.value.open(type, id)
  294. }
  295. /** 删除按钮操作 */
  296. const handleDelete = async (id: number) => {
  297. try {
  298. // 删除的二次确认
  299. await message.delConfirm()
  300. // 发起删除
  301. await ContractApi.deleteContract(id)
  302. message.success(t('common.delSuccess'))
  303. // 刷新列表
  304. await getList()
  305. } catch {}
  306. }
  307. /** 导出按钮操作 */
  308. const handleExport = async () => {
  309. try {
  310. // 导出的二次确认
  311. await message.exportConfirm()
  312. // 发起导出
  313. exportLoading.value = true
  314. const data = await ContractApi.exportContract(queryParams)
  315. download.excel(data, '合同.xls')
  316. } catch {
  317. } finally {
  318. exportLoading.value = false
  319. }
  320. }
  321. /** 提交审核 **/
  322. const handleSubmit = async (row: ContractApi.ContractVO) => {
  323. await message.confirm(`您确定提交【${row.name}】审核吗?`)
  324. await ContractApi.submitContract(row.id)
  325. message.success('提交审核成功!')
  326. await getList()
  327. }
  328. /** 查看审批 */
  329. const handleProcessDetail = (row: ContractApi.ContractVO) => {
  330. push({ name: 'BpmProcessInstanceDetail', query: { id: row.processInstanceId } })
  331. }
  332. /** 打开合同详情 */
  333. const { push } = useRouter()
  334. const openDetail = (id: number) => {
  335. push({ name: 'CrmContractDetail', params: { id } })
  336. }
  337. /** 打开客户详情 */
  338. const openCustomerDetail = (id: number) => {
  339. push({ name: 'CrmCustomerDetail', params: { id } })
  340. }
  341. /** 打开联系人详情 */
  342. const openContactDetail = (id: number) => {
  343. push({ name: 'CrmContactDetail', params: { id } })
  344. }
  345. /** 打开商机详情 */
  346. const openBusinessDetail = (id: number) => {
  347. push({ name: 'CrmBusinessDetail', params: { id } })
  348. }
  349. /** 初始化 **/
  350. onMounted(async () => {
  351. await getList()
  352. customerList.value = await CustomerApi.getCustomerSimpleList()
  353. })
  354. </script>