index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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 { useHandleData } from '@/utils/useHandleData'
  8. import {
  9. getPageApi,
  10. getDetailApi,
  11. addApi,
  12. editApi,
  13. deleteApi,
  14. confirmArrivalAccountApi
  15. } from '@/api/business/contract/fundReceived'
  16. import { getPageApi as getCapitalAccountPageApi } from '@/api/business/capital/account'
  17. import Detail from '@/views/business/contract/info/detail.vue'
  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 formData = ref<StrAnyObj>({})
  26. const dialogTitle = ref<string>('')
  27. const dialogVisible = ref<boolean>(false)
  28. const detailDialog = ref<boolean>(false)
  29. const queryConfig: FormConfigType[] = [
  30. {
  31. type: 'input',
  32. prop: 'contractNo',
  33. label: '合同'
  34. },
  35. {
  36. type: 'select',
  37. prop: 'hasReceived',
  38. label: '是否到账',
  39. dict: 'yes_no'
  40. }
  41. ]
  42. const toolbarConfig: ToolbarConfigType[] = [
  43. {
  44. common: 'search',
  45. click() {
  46. queryData.value.pageNum = 1
  47. getPage()
  48. }
  49. },
  50. {
  51. common: 'reset',
  52. click() {
  53. queryRef.value?.resetFields()
  54. getPage()
  55. }
  56. }
  57. ]
  58. const columnConfig: ColumnConfigType[] = [
  59. {
  60. slot: 'contractNo',
  61. label: '合同'
  62. },
  63. {
  64. prop: 'receivedAmount',
  65. label: '到账金额'
  66. },
  67. {
  68. prop: 'hasReceived',
  69. label: '是否到账',
  70. dict: 'yes_no'
  71. },
  72. {
  73. prop: 'accountAlias',
  74. label: '资金账号'
  75. },
  76. {
  77. prop: 'receivedTime',
  78. label: '到账时间'
  79. },
  80. {
  81. prop: 'remark',
  82. label: '备注'
  83. },
  84. {
  85. width: 180,
  86. handleConfig: [
  87. {
  88. if: (row) => {
  89. return row.hasReceived == 0
  90. },
  91. text: '确认到账',
  92. click(row) {
  93. dialogVisible.value = true
  94. dialogTitle.value = '确认到账'
  95. getDetailApi({ id: row.id }).then((resp: StrAnyObj) => {
  96. formData.value = resp
  97. })
  98. }
  99. }
  100. ]
  101. }
  102. ]
  103. const formConfig: FormConfigType[] = [
  104. {
  105. type: 'input',
  106. prop: 'contractNo',
  107. label: '合同',
  108. disabled: true
  109. },
  110. {
  111. type: 'input',
  112. prop: 'receivedAmount',
  113. label: '到账金额',
  114. disabled: true
  115. },
  116. {
  117. type: 'select',
  118. prop: 'capitalAccountId',
  119. label: '资金账号',
  120. keyName: 'id',
  121. labelName: 'accountAlias',
  122. async option() {
  123. const data = await getCapitalAccountPageApi({ searchAll: true })
  124. return data.records
  125. },
  126. rule: [{ required: true, message: '资金账号不能为空', trigger: 'blur' }]
  127. },
  128. {
  129. type: 'datePicker',
  130. prop: 'receivedTime',
  131. label: '到账时间',
  132. datePickerType: 'datetime',
  133. format: 'YYYY-MM-DD hh:mm:ss',
  134. valueFormat: 'YYYY-MM-DD hh:mm:ss',
  135. rule: [{ required: true, message: '到账时间不能为空', trigger: 'blur' }]
  136. },
  137. {
  138. type: 'input',
  139. itemType: 'textarea',
  140. prop: 'remark',
  141. label: '备注',
  142. rows: 3,
  143. span: 24
  144. }
  145. ]
  146. onMounted(() => {
  147. getPage()
  148. })
  149. function getPage() {
  150. getPageApi(queryData.value).then((resp) => {
  151. tableData.value = resp.records
  152. pageTotal.value = resp.total
  153. })
  154. }
  155. function tableSelectionChange(item: StrAnyObjArr) {
  156. selectKeys.value = item.map((item) => item.id)
  157. }
  158. function formSubmit() {
  159. formRef.value?.validate(() => {
  160. confirmArrivalAccountApi(formData.value).then(() => {
  161. dialogVisible.value = false
  162. ElMessage.success('确认成功')
  163. getPage()
  164. })
  165. })
  166. }
  167. function formClosed() {
  168. formRef.value?.resetFields()
  169. }
  170. function clickContract(item: StrAnyObjArr) {
  171. formData.value = {
  172. id: item.contractId
  173. }
  174. detailDialog.value = true
  175. dialogTitle.value = '详情'
  176. }
  177. </script>
  178. <template>
  179. <div>
  180. <el-card v-if="showQuery">
  181. <a-form ref="queryRef" v-model="queryData" :config="queryConfig" :span="6"> </a-form>
  182. </el-card>
  183. <a-table
  184. :data="tableData"
  185. :page-total="pageTotal"
  186. :toolbar-config="toolbarConfig"
  187. :column-config="columnConfig"
  188. v-model:showQuery="showQuery"
  189. v-model:page-num="queryData.pageNum"
  190. v-model:page-size="queryData.pageSize"
  191. @page-num-change="getPage"
  192. @page-size-change="getPage"
  193. @selection-change="tableSelectionChange"
  194. >
  195. <template #contractNo="{ row }">
  196. <div>
  197. <a
  198. style="color: #409eff; cursor: pointer; word-break: break-all"
  199. @click="clickContract(row)"
  200. >{{ row.contractNo }}</a
  201. >
  202. </div>
  203. </template>
  204. </a-table>
  205. <a-dialog
  206. v-model="dialogVisible"
  207. :title="dialogTitle"
  208. @submit="formSubmit"
  209. @closed="formClosed"
  210. >
  211. <a-form ref="formRef" v-model="formData" :config="formConfig" :span="24"> </a-form>
  212. </a-dialog>
  213. <a-dialog
  214. v-if="detailDialog"
  215. v-model="detailDialog"
  216. :title="detailTitle"
  217. @closed="formClosed"
  218. style="width: 900px"
  219. :footer="false"
  220. >
  221. <Detail :rowData="formData"></Detail>
  222. </a-dialog>
  223. </div>
  224. </template>