index.vue 9.7 KB

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