index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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. <el-table-column
  153. align="center"
  154. label="已回款金额(元)"
  155. prop="totalReceivablePrice"
  156. width="140"
  157. :formatter="erpPriceTableColumnFormatter"
  158. />
  159. <el-table-column
  160. align="center"
  161. label="未回款金额(元)"
  162. prop="totalReceivablePrice"
  163. width="140"
  164. :formatter="erpPriceTableColumnFormatter"
  165. >
  166. <template #default="scope">
  167. {{ erpPriceInputFormatter(scope.row.totalPrice - scope.row.totalReceivablePrice) }}
  168. </template>
  169. </el-table-column>
  170. <el-table-column
  171. :formatter="dateFormatter"
  172. align="center"
  173. label="最后跟进时间"
  174. prop="contactLastTime"
  175. width="180px"
  176. />
  177. <el-table-column align="center" label="负责人" prop="ownerUserName" width="120" />
  178. <el-table-column align="center" label="所属部门" prop="ownerUserDeptName" width="100px" />
  179. <el-table-column
  180. :formatter="dateFormatter"
  181. align="center"
  182. label="更新时间"
  183. prop="updateTime"
  184. width="180px"
  185. />
  186. <el-table-column
  187. :formatter="dateFormatter"
  188. align="center"
  189. label="创建时间"
  190. prop="createTime"
  191. width="180px"
  192. />
  193. <el-table-column align="center" label="创建人" prop="creatorName" width="120" />
  194. <el-table-column align="center" fixed="right" label="合同状态" prop="auditStatus" width="120">
  195. <template #default="scope">
  196. <dict-tag :type="DICT_TYPE.CRM_AUDIT_STATUS" :value="scope.row.auditStatus" />
  197. </template>
  198. </el-table-column>
  199. <el-table-column fixed="right" label="操作" width="250">
  200. <template #default="scope">
  201. <el-button
  202. v-if="scope.row.auditStatus === 0"
  203. v-hasPermi="['crm:contract:update']"
  204. link
  205. type="primary"
  206. @click="openForm('update', scope.row.id)"
  207. >
  208. 编辑
  209. </el-button>
  210. <el-button
  211. v-if="scope.row.auditStatus === 0"
  212. v-hasPermi="['crm:contract:update']"
  213. link
  214. type="primary"
  215. @click="handleSubmit(scope.row)"
  216. >
  217. 提交审核
  218. </el-button>
  219. <el-button
  220. v-else
  221. link
  222. v-hasPermi="['crm:contract:update']"
  223. type="primary"
  224. @click="handleProcessDetail(scope.row)"
  225. >
  226. 查看审批
  227. </el-button>
  228. <el-button
  229. v-hasPermi="['crm:contract:query']"
  230. link
  231. type="primary"
  232. @click="openDetail(scope.row.id)"
  233. >
  234. 详情
  235. </el-button>
  236. <el-button
  237. v-hasPermi="['crm:contract:delete']"
  238. link
  239. type="danger"
  240. @click="handleDelete(scope.row.id)"
  241. >
  242. 删除
  243. </el-button>
  244. </template>
  245. </el-table-column>
  246. </el-table>
  247. <!-- 分页 -->
  248. <Pagination
  249. v-model:limit="queryParams.pageSize"
  250. v-model:page="queryParams.pageNo"
  251. :total="total"
  252. @pagination="getList"
  253. />
  254. </ContentWrap>
  255. <!-- 表单弹窗:添加/修改 -->
  256. <ContractForm ref="formRef" @success="getList" />
  257. </template>
  258. <script lang="ts" setup>
  259. import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
  260. import download from '@/utils/download'
  261. import * as ContractApi from '@/api/crm/contract'
  262. import ContractForm from './ContractForm.vue'
  263. import { DICT_TYPE } from '@/utils/dict'
  264. import { erpPriceInputFormatter, erpPriceTableColumnFormatter } from '@/utils'
  265. import * as CustomerApi from '@/api/crm/customer'
  266. import { TabsPaneContext } from 'element-plus'
  267. defineOptions({ name: 'CrmContract' })
  268. const message = useMessage() // 消息弹窗
  269. const { t } = useI18n() // 国际化
  270. const loading = ref(true) // 列表的加载中
  271. const total = ref(0) // 列表的总页数
  272. const list = ref([]) // 列表的数据
  273. const queryParams = reactive({
  274. pageNo: 1,
  275. pageSize: 10,
  276. sceneType: '1', // 默认和 activeName 相等
  277. name: null,
  278. customerId: null,
  279. orderDate: [],
  280. no: null
  281. })
  282. const queryFormRef = ref() // 搜索的表单
  283. const exportLoading = ref(false) // 导出的加载中
  284. const activeName = ref('1') // 列表 tab
  285. const customerList = ref<CustomerApi.CustomerVO[]>([]) // 客户列表
  286. /** tab 切换 */
  287. const handleTabClick = (tab: TabsPaneContext) => {
  288. queryParams.sceneType = tab.paneName
  289. handleQuery()
  290. }
  291. /** 查询列表 */
  292. const getList = async () => {
  293. loading.value = true
  294. try {
  295. const data = await ContractApi.getContractPage(queryParams)
  296. list.value = data.list
  297. total.value = data.total
  298. } finally {
  299. loading.value = false
  300. }
  301. }
  302. /** 搜索按钮操作 */
  303. const handleQuery = () => {
  304. queryParams.pageNo = 1
  305. getList()
  306. }
  307. /** 重置按钮操作 */
  308. const resetQuery = () => {
  309. queryFormRef.value.resetFields()
  310. handleQuery()
  311. }
  312. /** 添加/修改操作 */
  313. const formRef = ref()
  314. const openForm = (type: string, id?: number) => {
  315. formRef.value.open(type, id)
  316. }
  317. /** 删除按钮操作 */
  318. const handleDelete = async (id: number) => {
  319. try {
  320. // 删除的二次确认
  321. await message.delConfirm()
  322. // 发起删除
  323. await ContractApi.deleteContract(id)
  324. message.success(t('common.delSuccess'))
  325. // 刷新列表
  326. await getList()
  327. } catch {}
  328. }
  329. /** 导出按钮操作 */
  330. const handleExport = async () => {
  331. try {
  332. // 导出的二次确认
  333. await message.exportConfirm()
  334. // 发起导出
  335. exportLoading.value = true
  336. const data = await ContractApi.exportContract(queryParams)
  337. download.excel(data, '合同.xls')
  338. } catch {
  339. } finally {
  340. exportLoading.value = false
  341. }
  342. }
  343. /** 提交审核 **/
  344. const handleSubmit = async (row: ContractApi.ContractVO) => {
  345. await message.confirm(`您确定提交【${row.name}】审核吗?`)
  346. await ContractApi.submitContract(row.id)
  347. message.success('提交审核成功!')
  348. await getList()
  349. }
  350. /** 查看审批 */
  351. const handleProcessDetail = (row: ContractApi.ContractVO) => {
  352. push({ name: 'BpmProcessInstanceDetail', query: { id: row.processInstanceId } })
  353. }
  354. /** 打开合同详情 */
  355. const { push } = useRouter()
  356. const openDetail = (id: number) => {
  357. push({ name: 'CrmContractDetail', params: { id } })
  358. }
  359. /** 打开客户详情 */
  360. const openCustomerDetail = (id: number) => {
  361. push({ name: 'CrmCustomerDetail', params: { id } })
  362. }
  363. /** 打开联系人详情 */
  364. const openContactDetail = (id: number) => {
  365. push({ name: 'CrmContactDetail', params: { id } })
  366. }
  367. /** 打开商机详情 */
  368. const openBusinessDetail = (id: number) => {
  369. push({ name: 'CrmBusinessDetail', params: { id } })
  370. }
  371. /** 初始化 **/
  372. onMounted(async () => {
  373. await getList()
  374. customerList.value = await CustomerApi.getCustomerSimpleList()
  375. })
  376. </script>