index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. <!-- TODO 芋艿:各种字段要调整 -->
  57. <ContentWrap>
  58. <el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
  59. <el-table-column align="center" label="合同编号" prop="no" width="130" />
  60. <el-table-column align="center" label="合同名称" prop="name" width="130" />
  61. <el-table-column align="center" label="合同状态" prop="auditStatus" width="130" />
  62. <el-table-column align="center" label="客户名称" prop="customerName" width="130" />
  63. <el-table-column align="center" label="商机名称" prop="businessName" width="130" />
  64. <el-table-column align="center" label="合同金额(元)" prop="price" width="130" />
  65. <el-table-column
  66. :formatter="dateFormatter"
  67. align="center"
  68. label="下单时间"
  69. prop="orderDate"
  70. width="180"
  71. />
  72. <el-table-column
  73. :formatter="dateFormatter"
  74. align="center"
  75. label="开始时间"
  76. prop="startTime"
  77. width="180"
  78. />
  79. <el-table-column
  80. :formatter="dateFormatter"
  81. align="center"
  82. label="结束时间"
  83. prop="endTime"
  84. width="180"
  85. />
  86. <el-table-column align="center" label="客户签约人" prop="contactName" width="130" />
  87. <el-table-column align="center" label="公司签约人" prop="signUserName" width="130" />
  88. <el-table-column align="center" label="备注" prop="remark" width="130" />
  89. <el-table-column align="center" label="审核状态" prop="auditStatus" width="130" />
  90. <el-table-column
  91. :formatter="dateFormatter"
  92. align="center"
  93. label="最后跟进时间"
  94. prop="contactLastTime"
  95. width="180"
  96. />
  97. <el-table-column fixed="right" label="操作" width="250">
  98. <template #default="scope">
  99. <el-button
  100. v-hasPermi="['crm:contract:update']"
  101. link
  102. type="primary"
  103. @click="openForm('update', scope.row.id)"
  104. >
  105. 编辑
  106. </el-button>
  107. <el-button
  108. v-hasPermi="['crm:contract:update']"
  109. link
  110. type="primary"
  111. @click="handleApprove(scope.row)"
  112. >
  113. 提交审核
  114. </el-button>
  115. <el-button
  116. v-hasPermi="['crm:contract:query']"
  117. link
  118. type="primary"
  119. @click="openDetail(scope.row.id)"
  120. >
  121. 详情
  122. </el-button>
  123. <el-button
  124. v-hasPermi="['crm:contract:delete']"
  125. link
  126. type="danger"
  127. @click="handleDelete(scope.row.id)"
  128. >
  129. 删除
  130. </el-button>
  131. </template>
  132. </el-table-column>
  133. </el-table>
  134. <!-- 分页 -->
  135. <Pagination
  136. v-model:limit="queryParams.pageSize"
  137. v-model:page="queryParams.pageNo"
  138. :total="total"
  139. @pagination="getList"
  140. />
  141. </ContentWrap>
  142. <!-- 表单弹窗:添加/修改 -->
  143. <ContractForm ref="formRef" @success="getList" />
  144. </template>
  145. <script lang="ts" setup>
  146. import { dateFormatter } from '@/utils/formatTime'
  147. import download from '@/utils/download'
  148. import * as ContractApi from '@/api/crm/contract'
  149. import ContractForm from './ContractForm.vue'
  150. defineOptions({ name: 'CrmContract' })
  151. const message = useMessage() // 消息弹窗
  152. const { t } = useI18n() // 国际化
  153. const loading = ref(true) // 列表的加载中
  154. const total = ref(0) // 列表的总页数
  155. const list = ref([]) // 列表的数据
  156. const queryParams = reactive({
  157. pageNo: 1,
  158. pageSize: 10,
  159. name: null,
  160. customerId: null,
  161. businessId: null,
  162. orderDate: [],
  163. no: null,
  164. discountPercent: null,
  165. productPrice: null
  166. })
  167. const queryFormRef = ref() // 搜索的表单
  168. const exportLoading = ref(false) // 导出的加载中
  169. /** 查询列表 */
  170. const getList = async () => {
  171. loading.value = true
  172. try {
  173. const data = await ContractApi.getContractPage(queryParams)
  174. list.value = data.list
  175. total.value = data.total
  176. } finally {
  177. loading.value = false
  178. }
  179. }
  180. /** 搜索按钮操作 */
  181. const handleQuery = () => {
  182. queryParams.pageNo = 1
  183. getList()
  184. }
  185. /** 重置按钮操作 */
  186. const resetQuery = () => {
  187. queryFormRef.value.resetFields()
  188. handleQuery()
  189. }
  190. /** 添加/修改操作 */
  191. const formRef = ref()
  192. const openForm = (type: string, id?: number) => {
  193. formRef.value.open(type, id)
  194. }
  195. /** 删除按钮操作 */
  196. const handleDelete = async (id: number) => {
  197. try {
  198. // 删除的二次确认
  199. await message.delConfirm()
  200. // 发起删除
  201. await ContractApi.deleteContract(id)
  202. message.success(t('common.delSuccess'))
  203. // 刷新列表
  204. await getList()
  205. } catch {}
  206. }
  207. /** 导出按钮操作 */
  208. const handleExport = async () => {
  209. try {
  210. // 导出的二次确认
  211. await message.exportConfirm()
  212. // 发起导出
  213. exportLoading.value = true
  214. const data = await ContractApi.exportContract(queryParams)
  215. download.excel(data, '合同.xls')
  216. } catch {
  217. } finally {
  218. exportLoading.value = false
  219. }
  220. }
  221. /** 提交审核 **/
  222. const handleApprove = async (row: ContractApi.ContractVO) => {
  223. await message.confirm(`您确定提交【${row.name}】审核吗?`)
  224. await ContractApi.handleApprove(row.id)
  225. message.success('提交审核成功!')
  226. await getList()
  227. }
  228. const { push } = useRouter()
  229. const openDetail = (id: number) => {
  230. push({ name: 'CrmContractDetail', params: { id } })
  231. }
  232. /** 初始化 **/
  233. onMounted(() => {
  234. getList()
  235. })
  236. </script>