index.vue 8.6 KB

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