index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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="180" />
  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 { DICT_TYPE } from '@/utils/dict'
  247. import { erpPriceTableColumnFormatter } from '@/utils'
  248. import * as CustomerApi from '@/api/crm/customer'
  249. defineOptions({ name: 'CrmContract' })
  250. const message = useMessage() // 消息弹窗
  251. const { t } = useI18n() // 国际化
  252. const loading = ref(true) // 列表的加载中
  253. const total = ref(0) // 列表的总页数
  254. const list = ref([]) // 列表的数据
  255. const queryParams = reactive({
  256. pageNo: 1,
  257. pageSize: 10,
  258. sceneType: '1', // 默认和 activeName 相等
  259. name: null,
  260. customerId: null,
  261. orderDate: [],
  262. no: null
  263. })
  264. const queryFormRef = ref() // 搜索的表单
  265. const exportLoading = ref(false) // 导出的加载中
  266. const activeName = ref('1') // 列表 tab
  267. const customerList = ref<CustomerApi.CustomerVO[]>([]) // 客户列表
  268. /** 查询列表 */
  269. const getList = async () => {
  270. loading.value = true
  271. try {
  272. const data = await ContractApi.getContractPage(queryParams)
  273. list.value = data.list
  274. total.value = data.total
  275. } finally {
  276. loading.value = false
  277. }
  278. }
  279. /** 搜索按钮操作 */
  280. const handleQuery = () => {
  281. queryParams.pageNo = 1
  282. getList()
  283. }
  284. /** 重置按钮操作 */
  285. const resetQuery = () => {
  286. queryFormRef.value.resetFields()
  287. handleQuery()
  288. }
  289. /** 添加/修改操作 */
  290. const formRef = ref()
  291. const openForm = (type: string, id?: number) => {
  292. formRef.value.open(type, id)
  293. }
  294. /** 删除按钮操作 */
  295. const handleDelete = async (id: number) => {
  296. try {
  297. // 删除的二次确认
  298. await message.delConfirm()
  299. // 发起删除
  300. await ContractApi.deleteContract(id)
  301. message.success(t('common.delSuccess'))
  302. // 刷新列表
  303. await getList()
  304. } catch {}
  305. }
  306. /** 导出按钮操作 */
  307. const handleExport = async () => {
  308. try {
  309. // 导出的二次确认
  310. await message.exportConfirm()
  311. // 发起导出
  312. exportLoading.value = true
  313. const data = await ContractApi.exportContract(queryParams)
  314. download.excel(data, '合同.xls')
  315. } catch {
  316. } finally {
  317. exportLoading.value = false
  318. }
  319. }
  320. /** 提交审核 **/
  321. const handleSubmit = async (row: ContractApi.ContractVO) => {
  322. await message.confirm(`您确定提交【${row.name}】审核吗?`)
  323. await ContractApi.submitContract(row.id)
  324. message.success('提交审核成功!')
  325. await getList()
  326. }
  327. /** 查看审批 */
  328. const handleProcessDetail = (row: ContractApi.ContractVO) => {
  329. push({ name: 'BpmProcessInstanceDetail', query: { id: row.processInstanceId } })
  330. }
  331. /** 打开合同详情 */
  332. const { push } = useRouter()
  333. const openDetail = (id: number) => {
  334. push({ name: 'CrmContractDetail', params: { id } })
  335. }
  336. /** 打开客户详情 */
  337. const openCustomerDetail = (id: number) => {
  338. push({ name: 'CrmCustomerDetail', params: { id } })
  339. }
  340. /** 打开联系人详情 */
  341. const openContactDetail = (id: number) => {
  342. push({ name: 'CrmContactDetail', params: { id } })
  343. }
  344. /** 打开商机详情 */
  345. const openBusinessDetail = (id: number) => {
  346. push({ name: 'CrmBusinessDetail', params: { id } })
  347. }
  348. /** 初始化 **/
  349. onMounted(async () => {
  350. await getList()
  351. customerList.value = await CustomerApi.getCustomerSimpleList()
  352. })
  353. </script>