index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. <script setup lang="ts">
  2. import AForm from '@/components/AForm/index.vue'
  3. import { FormConfigType } from '@/components/AForm/type'
  4. import { ToolbarConfigType } from '@/components/AToolbar/type'
  5. import { ColumnConfigType } from '@/components/ATable/type'
  6. import { StrAnyObj, StrAnyObjArr } from '@/typings'
  7. import {
  8. getDetailApi,
  9. getRemitPageApi,
  10. remitApi,
  11. remitExcelExportApi
  12. } from '@/api/business/payment/requests'
  13. import { getPageApi as getCorporationPageApi } from '@/api/business/corporation/corporation'
  14. import DeptTreeSelect from '@/views/components/DeptTreeSelect/index.vue'
  15. import { getPageApi as getCapitalAccountPageApi } from '@/api/business/capital/account'
  16. import MoneyPDF from '@/components/PDF/moneyPDF.vue'
  17. import { getPdf } from '@/utils/getPdf.js'
  18. const queryRef = ref<InstanceType<typeof AForm>>()
  19. const formRef = ref<InstanceType<typeof AForm>>()
  20. const showQuery = ref<boolean>(true)
  21. const selectKeys = ref<string[]>([])
  22. const pageTotal = ref<number>(0)
  23. const queryData = ref<StrAnyObj>({ pageNum: 1, pageSize: 10 })
  24. const tableData = ref<StrAnyObjArr>([])
  25. const detailData = ref<StrAnyObj>({ paymentRequestsDetailList: [{}] })
  26. const formData = ref<StrAnyObj>({})
  27. const dialogTitle = ref<string>('')
  28. const dialogVisible = ref<boolean>(false)
  29. const selectDeptIdRef = ref<InstanceType<typeof DeptTreeSelect>>()
  30. const disabled = ref(false)
  31. const dialogPrint = ref<boolean>(false)
  32. const rowData = ref<StrAnyObj>({})
  33. const queryConfig: FormConfigType[] = [
  34. {
  35. type: 'select',
  36. prop: 'corporationId',
  37. label: '归属公司',
  38. keyName: 'id',
  39. labelName: 'name',
  40. async option() {
  41. const data = await getCorporationPageApi({ searchAll: true })
  42. return data.records
  43. }
  44. },
  45. {
  46. type: 'slot',
  47. prop: 'deptId',
  48. label: '归属部门'
  49. },
  50. {
  51. type: 'select',
  52. prop: 'type',
  53. label: '请款类型',
  54. dict: 'payment_requests_type'
  55. },
  56. {
  57. type: 'select',
  58. prop: 'payType',
  59. label: '付款方式',
  60. dict: 'pay_type'
  61. },
  62. {
  63. type: 'select',
  64. prop: 'paymentStatus',
  65. label: '放款状态',
  66. option: [
  67. {
  68. key: 0,
  69. label: '未打款'
  70. },
  71. {
  72. key: 1,
  73. label: '部分打款'
  74. },
  75. {
  76. key: 2,
  77. label: '已打款'
  78. }
  79. ]
  80. }
  81. ]
  82. const toolbarConfig: ToolbarConfigType[] = [
  83. {
  84. common: 'search',
  85. click() {
  86. queryData.value.pageNum = 1
  87. getPage()
  88. }
  89. },
  90. {
  91. common: 'reset',
  92. click() {
  93. queryRef.value?.resetFields()
  94. getPage()
  95. }
  96. // },
  97. // {
  98. // common: 'add',
  99. // click() {
  100. // dialogVisible.value = true
  101. // dialogTitle.value = '新增'
  102. // }
  103. },
  104. {
  105. text: '导出',
  106. icon: 'Download',
  107. type: 'primary',
  108. click() {
  109. remitExcelExportApi(queryData.value).then(() => {
  110. ElMessage.success('导出成功')
  111. })
  112. }
  113. }
  114. ]
  115. const columnConfig: ColumnConfigType[] = [
  116. {
  117. prop: 'corporationName',
  118. label: '归属公司'
  119. },
  120. {
  121. prop: 'deptName',
  122. label: '归属部门'
  123. },
  124. {
  125. prop: 'type',
  126. label: '请款类型',
  127. dict: 'payment_requests_type'
  128. },
  129. {
  130. prop: 'userName',
  131. label: '请款人'
  132. },
  133. {
  134. prop: 'createTime',
  135. label: '请款时间'
  136. },
  137. {
  138. prop: 'useTime',
  139. label: '用款时间'
  140. },
  141. {
  142. prop: 'useRemark',
  143. label: '用款说明',
  144. showOverflowTooltip: true
  145. },
  146. {
  147. prop: 'totalAmount',
  148. label: '请款金额'
  149. },
  150. {
  151. prop: 'paymentStatus',
  152. label: '放款状态',
  153. formatter(row) {
  154. switch (row.paymentStatus) {
  155. case 0:
  156. return '未打款'
  157. case 1:
  158. return '部分打款'
  159. case 2:
  160. return '已打款'
  161. }
  162. }
  163. },
  164. {
  165. width: 250,
  166. handleConfig: [
  167. {
  168. text: '打款',
  169. if: (row) => row.paymentStatus != 2,
  170. click(row) {
  171. dialogVisible.value = true
  172. dialogTitle.value = '打款'
  173. disabled.value = false
  174. getDetailApi({ id: row.id }).then((resp: StrAnyObj) => {
  175. detailData.value = resp
  176. formData.value.capitalAccountId = resp.capitalAccountId
  177. formData.value.amount = resp.totalAmount - resp.remitAmount
  178. formData.value.remark = resp.useRemark
  179. formData.value.paymentRequestsId = resp.id
  180. })
  181. }
  182. },
  183. {
  184. common: 'detail',
  185. click(row) {
  186. dialogVisible.value = true
  187. dialogTitle.value = '详情'
  188. disabled.value = true
  189. getDetailApi({ id: row.id }).then((resp: StrAnyObj) => {
  190. detailData.value = resp
  191. })
  192. }
  193. },
  194. {
  195. text: '打印',
  196. click(row) {
  197. rowData.value = row
  198. dialogPrint.value = true
  199. }
  200. }
  201. ]
  202. }
  203. ]
  204. const detailConfig: FormConfigType[] = [
  205. {
  206. type: 'input',
  207. prop: 'totalAmount',
  208. label: '请款金额',
  209. placeholder: '',
  210. disabled: true
  211. },
  212. {
  213. type: 'input',
  214. prop: 'remitAmount',
  215. label: '已打款金额',
  216. placeholder: '',
  217. disabled: true
  218. },
  219. {
  220. type: 'select',
  221. prop: 'payType',
  222. label: '付款方式',
  223. dict: 'pay_type',
  224. placeholder: '',
  225. disabled: true
  226. },
  227. {
  228. type: 'select',
  229. prop: 'capitalAccountId',
  230. label: '付款账户',
  231. keyName: 'id',
  232. labelName: 'accountAlias',
  233. placeholder: '',
  234. async option() {
  235. const data = await getCapitalAccountPageApi({ searchAll: true })
  236. return data.records
  237. },
  238. disabled: true
  239. },
  240. {
  241. type: 'input',
  242. prop: 'accountName',
  243. label: '户名',
  244. placeholder: '',
  245. disabled: true
  246. },
  247. {
  248. type: 'input',
  249. prop: 'account',
  250. label: '银行账号',
  251. placeholder: '',
  252. disabled: true
  253. },
  254. {
  255. type: 'input',
  256. prop: 'depositBank',
  257. label: '开户银行',
  258. placeholder: '',
  259. disabled: true
  260. },
  261. {
  262. type: 'input',
  263. prop: 'correspondentNumber',
  264. label: '联行号/SWIFT Code',
  265. placeholder: '',
  266. disabled: true
  267. },
  268. {
  269. type: 'input',
  270. itemType: 'textarea',
  271. prop: 'useRemark',
  272. label: '用款说明',
  273. rows: 3,
  274. span: 24,
  275. placeholder: '',
  276. disabled: true
  277. },
  278. {
  279. type: 'upload',
  280. prop: 'atts',
  281. label: '附件',
  282. span: 24
  283. }
  284. ]
  285. const formConfig: FormConfigType[] = [
  286. {
  287. type: 'select',
  288. prop: 'capitalAccountId',
  289. label: '付款账户',
  290. keyName: 'id',
  291. labelName: 'accountAlias',
  292. async option() {
  293. const data = await getCapitalAccountPageApi({ searchAll: true })
  294. return data.records
  295. },
  296. rule: [{ required: true, message: '付款账户不能为空', trigger: 'blur' }]
  297. },
  298. {
  299. type: 'inputNumber',
  300. prop: 'amount',
  301. label: '打款金额',
  302. min: 0.01,
  303. precision: 2,
  304. rule: [{ required: true, message: '打款金额不能为空', trigger: 'blur' }]
  305. },
  306. {
  307. type: 'datePicker',
  308. prop: 'remitTime',
  309. label: '打款时间',
  310. datePickerType: 'datetime',
  311. format: 'YYYY-MM-DD 00:00:00',
  312. valueFormat: 'YYYY-MM-DD 00:00:00',
  313. rule: [{ required: true, message: '打款时间不能为空', trigger: ['blur', 'change'] }]
  314. },
  315. {
  316. type: 'input',
  317. itemType: 'textarea',
  318. prop: 'remark',
  319. label: '摘要',
  320. rows: 5,
  321. span: 24
  322. },
  323. {
  324. type: 'upload',
  325. prop: 'atts',
  326. label: '附件',
  327. span: 24
  328. }
  329. ]
  330. onMounted(() => {
  331. getPage()
  332. selectDeptIdRef.value?.load()
  333. })
  334. function getPage() {
  335. getRemitPageApi(queryData.value).then((resp) => {
  336. tableData.value = resp.records
  337. pageTotal.value = resp.total
  338. })
  339. }
  340. function tableSelectionChange(item: StrAnyObjArr) {
  341. selectKeys.value = item.map((item) => item.id)
  342. }
  343. function formSubmit() {
  344. formRef.value?.validate(() => {
  345. remitApi(formData.value).then(() => {
  346. dialogVisible.value = false
  347. ElMessage.success('打款成功')
  348. getPage()
  349. })
  350. })
  351. }
  352. function formClosed() {
  353. formRef.value?.resetFields()
  354. }
  355. const printObj = ref({
  356. id: 'pdfDom',
  357. popTitle: '',
  358. extraCss:
  359. 'https://cdn.bootcdn.net/ajax/libs/animate.css/4.1.1/animate.compat.css, https://cdn.bootcdn.net/ajax/libs/hover.css/2.3.1/css/hover-min.css',
  360. extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>'
  361. })
  362. const clickDownload = () => {
  363. getPdf('请款PDF文件')
  364. }
  365. </script>
  366. <template>
  367. <div>
  368. <el-card v-if="showQuery">
  369. <a-form ref="queryRef" v-model="queryData" :config="queryConfig" :span="6">
  370. <template #deptId>
  371. <dept-tree-select ref="selectDeptIdRef" v-model="queryData.deptId" />
  372. </template>
  373. </a-form>
  374. </el-card>
  375. <a-table
  376. :data="tableData"
  377. :page-total="pageTotal"
  378. :toolbar-config="toolbarConfig"
  379. :column-config="columnConfig"
  380. v-model:showQuery="showQuery"
  381. v-model:page-num="queryData.pageNum"
  382. v-model:page-size="queryData.pageSize"
  383. @page-num-change="getPage"
  384. @page-size-change="getPage"
  385. @selection-change="tableSelectionChange"
  386. >
  387. </a-table>
  388. <a-dialog
  389. v-if="dialogVisible"
  390. v-model="dialogVisible"
  391. :title="dialogTitle"
  392. :footer="!disabled"
  393. @submit="formSubmit"
  394. @closed="formClosed"
  395. width="1400px"
  396. >
  397. <div v-if="disabled">
  398. <a-form v-model="detailData" :config="detailConfig" :span="12" disabled> </a-form>
  399. </div>
  400. <el-card v-if="!disabled" header="请款信息">
  401. <a-form v-model="detailData" :config="detailConfig" :span="12" disabled></a-form>
  402. </el-card>
  403. <el-card v-if="!disabled" header="打款信息" style="margin-top: 10px">
  404. <a-form ref="formRef" v-model="formData" :config="formConfig" :span="12"> </a-form>
  405. </el-card>
  406. </a-dialog>
  407. <a-dialog
  408. :footer="false"
  409. v-if="dialogPrint"
  410. v-model="dialogPrint"
  411. title="打印"
  412. width="840px"
  413. height="200px"
  414. >
  415. <MoneyPDF :rowData="rowData"></MoneyPDF>
  416. <template #footer>
  417. <div>
  418. <el-button @click="dialogPrint = false" size="large">取消</el-button>
  419. <el-button type="primary" v-print="printObj" size="large">打印</el-button>
  420. <el-button type="primary" @click="clickDownload()" size="large">下载PDF</el-button>
  421. </div>
  422. </template>
  423. </a-dialog>
  424. </div>
  425. </template>