index.vue 9.7 KB

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