index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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-tabs v-model="activeName" @tab-click="handleTabClick">
  69. <el-tab-pane label="我负责的" name="1" />
  70. <el-tab-pane label="我参与的" name="2" />
  71. <el-tab-pane label="下属负责的" name="3" />
  72. </el-tabs>
  73. <el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
  74. <el-table-column align="center" fixed="left" label="回款编号" prop="no" width="180" />
  75. <el-table-column align="center" label="客户名称" prop="customerName" width="120">
  76. <template #default="scope">
  77. <el-link
  78. :underline="false"
  79. type="primary"
  80. @click="openCustomerDetail(scope.row.customerId)"
  81. >
  82. {{ scope.row.customerName }}
  83. </el-link>
  84. </template>
  85. </el-table-column>
  86. <el-table-column align="center" label="合同编号" prop="contractNo" width="180">
  87. <template #default="scope">
  88. <el-link
  89. :underline="false"
  90. type="primary"
  91. @click="openContractDetail(scope.row.contractId)"
  92. >
  93. {{ scope.row.contract.no }}
  94. </el-link>
  95. </template>
  96. </el-table-column>
  97. <el-table-column
  98. :formatter="dateFormatter2"
  99. align="center"
  100. label="回款日期"
  101. prop="returnTime"
  102. width="150px"
  103. />
  104. <el-table-column
  105. align="center"
  106. label="回款金额(元)"
  107. prop="price"
  108. width="140"
  109. :formatter="erpPriceTableColumnFormatter"
  110. />
  111. <el-table-column align="center" label="回款方式" prop="returnType" width="130px">
  112. <template #default="scope">
  113. <dict-tag :type="DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE" :value="scope.row.returnType" />
  114. </template>
  115. </el-table-column>
  116. <el-table-column align="center" label="备注" prop="remark" width="200" />
  117. <el-table-column
  118. align="center"
  119. label="合同金额(元)"
  120. prop="contract.totalPrice"
  121. width="140"
  122. :formatter="erpPriceTableColumnFormatter"
  123. />
  124. <el-table-column align="center" label="负责人" prop="ownerUserName" width="120" />
  125. <el-table-column align="center" label="所属部门" prop="ownerUserDeptName" width="100px" />
  126. <el-table-column
  127. :formatter="dateFormatter"
  128. align="center"
  129. label="更新时间"
  130. prop="updateTime"
  131. width="180px"
  132. />
  133. <el-table-column
  134. :formatter="dateFormatter"
  135. align="center"
  136. label="创建时间"
  137. prop="createTime"
  138. width="180px"
  139. />
  140. <el-table-column align="center" label="创建人" prop="creatorName" width="120" />
  141. <el-table-column align="center" fixed="right" label="回款状态" prop="auditStatus" width="120">
  142. <template #default="scope">
  143. <dict-tag :type="DICT_TYPE.CRM_AUDIT_STATUS" :value="scope.row.auditStatus" />
  144. </template>
  145. </el-table-column>
  146. <el-table-column align="center" fixed="right" label="操作" width="180px">
  147. <template #default="scope">
  148. <el-button
  149. v-hasPermi="['crm:receivable:update']"
  150. link
  151. type="primary"
  152. @click="openForm('update', scope.row.id)"
  153. >
  154. 编辑
  155. </el-button>
  156. <el-button
  157. v-if="scope.row.auditStatus === 0"
  158. v-hasPermi="['crm:receivable:update']"
  159. link
  160. type="primary"
  161. @click="handleSubmit(scope.row)"
  162. >
  163. 提交审核
  164. </el-button>
  165. <el-button
  166. v-else
  167. v-hasPermi="['crm:receivable:update']"
  168. link
  169. type="primary"
  170. @click="handleProcessDetail(scope.row)"
  171. >
  172. 查看审批
  173. </el-button>
  174. <el-button
  175. v-hasPermi="['crm:receivable:delete']"
  176. link
  177. type="danger"
  178. @click="handleDelete(scope.row.id)"
  179. >
  180. 删除
  181. </el-button>
  182. </template>
  183. </el-table-column>
  184. </el-table>
  185. <!-- 分页 -->
  186. <Pagination
  187. v-model:limit="queryParams.pageSize"
  188. v-model:page="queryParams.pageNo"
  189. :total="total"
  190. @pagination="getList"
  191. />
  192. </ContentWrap>
  193. <!-- 表单弹窗:添加/修改 -->
  194. <ReceivableForm ref="formRef" @success="getList" />
  195. </template>
  196. <script lang="ts" setup>
  197. import { DICT_TYPE } from '@/utils/dict'
  198. import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
  199. import download from '@/utils/download'
  200. import * as ReceivableApi from '@/api/crm/receivable'
  201. import ReceivableForm from './ReceivableForm.vue'
  202. import * as CustomerApi from '@/api/crm/customer'
  203. import { TabsPaneContext } from 'element-plus'
  204. import { erpPriceTableColumnFormatter } from '@/utils'
  205. defineOptions({ name: 'Receivable' })
  206. const message = useMessage() // 消息弹窗
  207. const { t } = useI18n() // 国际化
  208. const loading = ref(true) // 列表的加载中
  209. const total = ref(0) // 列表的总页数
  210. const list = ref([]) // 列表的数据
  211. const queryParams = reactive({
  212. pageNo: 1,
  213. pageSize: 10,
  214. sceneType: '1', // 默认和 activeName 相等
  215. no: undefined,
  216. customerId: undefined
  217. })
  218. const queryFormRef = ref() // 搜索的表单
  219. const exportLoading = ref(false) // 导出的加载中
  220. const activeName = ref('1') // 列表 tab
  221. const customerList = ref<CustomerApi.CustomerVO[]>([]) // 客户列表
  222. /** tab 切换 */
  223. const handleTabClick = (tab: TabsPaneContext) => {
  224. queryParams.sceneType = tab.paneName
  225. handleQuery()
  226. }
  227. /** 查询列表 */
  228. const getList = async () => {
  229. loading.value = true
  230. try {
  231. const data = await ReceivableApi.getReceivablePage(queryParams)
  232. list.value = data.list
  233. total.value = data.total
  234. } finally {
  235. loading.value = false
  236. }
  237. }
  238. /** 搜索按钮操作 */
  239. const handleQuery = () => {
  240. queryParams.pageNo = 1
  241. getList()
  242. }
  243. /** 重置按钮操作 */
  244. const resetQuery = () => {
  245. queryFormRef.value.resetFields()
  246. handleQuery()
  247. }
  248. /** 添加/修改操作 */
  249. const formRef = ref()
  250. const openForm = (type: string, id?: number) => {
  251. formRef.value.open(type, id)
  252. }
  253. /** 删除按钮操作 */
  254. const handleDelete = async (id: number) => {
  255. try {
  256. // 删除的二次确认
  257. await message.delConfirm()
  258. // 发起删除
  259. await ReceivableApi.deleteReceivable(id)
  260. message.success(t('common.delSuccess'))
  261. // 刷新列表
  262. await getList()
  263. } catch {}
  264. }
  265. /** 提交审核 **/
  266. const handleSubmit = async (row: ReceivableApi.ReceivableVO) => {
  267. await message.confirm(`您确定提交编号为【${row.no}】的回款审核吗?`)
  268. await ReceivableApi.submitReceivable(row.id)
  269. message.success('提交审核成功!')
  270. await getList()
  271. }
  272. /** 打开回款详情 */
  273. const { push } = useRouter()
  274. const openDetail = (id: number) => {
  275. push({ name: 'CrmReceivableDetail', params: { id } })
  276. }
  277. /** 打开客户详情 */
  278. const openCustomerDetail = (id: number) => {
  279. push({ name: 'CrmCustomerDetail', params: { id } })
  280. }
  281. /** 打开合同详情 */
  282. const openContractDetail = (id: number) => {
  283. push({ name: 'CrmContractDetail', params: { id } })
  284. }
  285. /** 查看审批 */
  286. const handleProcessDetail = (row: ReceivableApi.ReceivableVO) => {
  287. push({ name: 'BpmProcessInstanceDetail', query: { id: row.processInstanceId } })
  288. }
  289. // TODO puhui999: 回款流程审批表单详情查看后面完善
  290. /** 导出按钮操作 */
  291. const handleExport = async () => {
  292. try {
  293. // 导出的二次确认
  294. await message.exportConfirm()
  295. // 发起导出
  296. exportLoading.value = true
  297. const data = await ReceivableApi.exportReceivable(queryParams)
  298. download.excel(data, '回款.xls')
  299. } catch {
  300. } finally {
  301. exportLoading.value = false
  302. }
  303. }
  304. /** 初始化 **/
  305. onMounted(async () => {
  306. await getList()
  307. // 获得客户列表
  308. customerList.value = await CustomerApi.getCustomerSimpleList()
  309. })
  310. </script>