index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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="customerId">
  21. <el-select
  22. v-model="queryParams.customerId"
  23. class="!w-240px"
  24. placeholder="请选择客户"
  25. @keyup.enter="handleQuery"
  26. >
  27. <el-option
  28. v-for="item in customerList"
  29. :key="item.id"
  30. :label="item.name"
  31. :value="item.id"
  32. />
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item>
  36. <el-button @click="handleQuery">
  37. <Icon class="mr-5px" icon="ep:search" />
  38. 搜索
  39. </el-button>
  40. <el-button @click="resetQuery">
  41. <Icon class="mr-5px" icon="ep:refresh" />
  42. 重置
  43. </el-button>
  44. <el-button
  45. v-hasPermi="['crm:receivable:create']"
  46. plain
  47. type="primary"
  48. @click="openForm('create')"
  49. >
  50. <Icon class="mr-5px" icon="ep:plus" />
  51. 新增
  52. </el-button>
  53. <el-button
  54. v-hasPermi="['crm:receivable:export']"
  55. :loading="exportLoading"
  56. plain
  57. type="success"
  58. @click="handleExport"
  59. >
  60. <Icon class="mr-5px" icon="ep:download" />
  61. 导出
  62. </el-button>
  63. </el-form-item>
  64. </el-form>
  65. </ContentWrap>
  66. <!-- 列表 -->
  67. <ContentWrap>
  68. <el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
  69. <el-table-column align="center" label="回款编号" prop="no" />
  70. <el-table-column align="center" label="客户" prop="customerName" />
  71. <el-table-column align="center" label="合同" prop="contractName" />
  72. <el-table-column
  73. :formatter="dateFormatter2"
  74. align="center"
  75. label="回款日期"
  76. prop="returnTime"
  77. width="150px"
  78. />
  79. <el-table-column align="center" label="回款方式" prop="returnType" width="130px">
  80. <template #default="scope">
  81. <dict-tag :type="DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE" :value="scope.row.returnType" />
  82. </template>
  83. </el-table-column>
  84. <el-table-column align="center" label="回款金额(元)" prop="price" />
  85. <el-table-column align="center" label="负责人" prop="ownerUserName" />
  86. <el-table-column align="center" label="备注" prop="remark" />
  87. <el-table-column align="center" fixed="right" label="回款状态" prop="auditStatus" width="120">
  88. <template #default="scope">
  89. <dict-tag :type="DICT_TYPE.CRM_AUDIT_STATUS" :value="scope.row.auditStatus" />
  90. </template>
  91. </el-table-column>
  92. <el-table-column align="center" fixed="right" label="操作" width="180px">
  93. <template #default="scope">
  94. <el-button
  95. v-hasPermi="['crm:receivable:update']"
  96. link
  97. type="primary"
  98. @click="openForm('update', scope.row.id)"
  99. >
  100. 编辑
  101. </el-button>
  102. <el-button
  103. v-if="scope.row.auditStatus === 0"
  104. v-hasPermi="['crm:receivable:update']"
  105. link
  106. type="primary"
  107. @click="handleSubmit(scope.row)"
  108. >
  109. 提交审核
  110. </el-button>
  111. <el-button
  112. v-else
  113. v-hasPermi="['crm:receivable:update']"
  114. link
  115. type="primary"
  116. @click="handleProcessDetail(scope.row)"
  117. >
  118. 查看审批
  119. </el-button>
  120. <el-button
  121. v-hasPermi="['crm:receivable:delete']"
  122. link
  123. type="danger"
  124. @click="handleDelete(scope.row.id)"
  125. >
  126. 删除
  127. </el-button>
  128. </template>
  129. </el-table-column>
  130. </el-table>
  131. <!-- 分页 -->
  132. <Pagination
  133. v-model:limit="queryParams.pageSize"
  134. v-model:page="queryParams.pageNo"
  135. :total="total"
  136. @pagination="getList"
  137. />
  138. </ContentWrap>
  139. <!-- 表单弹窗:添加/修改 -->
  140. <ReceivableForm ref="formRef" @success="getList" />
  141. </template>
  142. <script lang="ts" setup>
  143. import { DICT_TYPE } from '@/utils/dict'
  144. import { dateFormatter2 } from '@/utils/formatTime'
  145. import download from '@/utils/download'
  146. import * as ReceivableApi from '@/api/crm/receivable'
  147. import ReceivableForm from './ReceivableForm.vue'
  148. import * as CustomerApi from '@/api/crm/customer'
  149. defineOptions({ name: 'Receivable' })
  150. const message = useMessage() // 消息弹窗
  151. const { t } = useI18n() // 国际化
  152. const { push } = useRouter() // 路由
  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. no: undefined,
  160. customerId: undefined
  161. })
  162. const queryFormRef = ref() // 搜索的表单
  163. const exportLoading = ref(false) // 导出的加载中
  164. /** 查询列表 */
  165. const getList = async () => {
  166. loading.value = true
  167. try {
  168. const data = await ReceivableApi.getReceivablePage(queryParams)
  169. list.value = data.list
  170. total.value = data.total
  171. } finally {
  172. loading.value = false
  173. }
  174. }
  175. /** 搜索按钮操作 */
  176. const handleQuery = () => {
  177. queryParams.pageNo = 1
  178. getList()
  179. }
  180. /** 重置按钮操作 */
  181. const resetQuery = () => {
  182. queryFormRef.value.resetFields()
  183. handleQuery()
  184. }
  185. /** 添加/修改操作 */
  186. const formRef = ref()
  187. const openForm = (type: string, id?: number) => {
  188. formRef.value.open(type, id)
  189. }
  190. /** 删除按钮操作 */
  191. const handleDelete = async (id: number) => {
  192. try {
  193. // 删除的二次确认
  194. await message.delConfirm()
  195. // 发起删除
  196. await ReceivableApi.deleteReceivable(id)
  197. message.success(t('common.delSuccess'))
  198. // 刷新列表
  199. await getList()
  200. } catch {}
  201. }
  202. /** 提交审核 **/
  203. const handleSubmit = async (row: ReceivableApi.ReceivableVO) => {
  204. await message.confirm(`您确定提交编号为【${row.no}】的回款审核吗?`)
  205. await ReceivableApi.submitReceivable(row.id)
  206. message.success('提交审核成功!')
  207. await getList()
  208. }
  209. /** 查看审批 */
  210. const handleProcessDetail = (row: ReceivableApi.ReceivableVO) => {
  211. push({ name: 'BpmProcessInstanceDetail', query: { id: row.processInstanceId } })
  212. }
  213. // TODO puhui999: 回款流程审批表单详情查看后面完善
  214. /** 导出按钮操作 */
  215. const handleExport = async () => {
  216. try {
  217. // 导出的二次确认
  218. await message.exportConfirm()
  219. // 发起导出
  220. exportLoading.value = true
  221. const data = await ReceivableApi.exportReceivable(queryParams)
  222. download.excel(data, '回款.xls')
  223. } catch {
  224. } finally {
  225. exportLoading.value = false
  226. }
  227. }
  228. const customerList = ref<CustomerApi.CustomerVO[]>([]) // 客户列表
  229. /** 初始化 **/
  230. onMounted(async () => {
  231. await getList()
  232. // 获得客户列表
  233. customerList.value = await CustomerApi.getCustomerSimpleList()
  234. })
  235. </script>