flowDetail.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <script setup lang="ts">
  2. import FileUpload from '@/components/FlieUpload/index.vue'
  3. import DeptTreeSelect from '@/views/components/DeptTreeSelect/index.vue'
  4. import AForm from '@/components/AForm/index.vue'
  5. import { StrAnyObj } from '@/typings'
  6. import { FormConfigType } from '@/components/AForm/type'
  7. import { getPageApi as getCorporationPageApi } from '@/api/business/corporation/corporation'
  8. import { getPageApi as getCapitalAccountPageApi } from '@/api/business/capital/account'
  9. import { ColumnConfigType } from '@/components/ATable/type'
  10. import { getDetailApi } from '@/api/business/payment/requests'
  11. const props = withDefaults(
  12. defineProps<{
  13. businessId: string
  14. disabled?: boolean
  15. }>(),
  16. {
  17. disabled: true
  18. }
  19. )
  20. watch(
  21. () => props.businessId,
  22. () => {
  23. nextTick(() => deptIdRef.value?.load())
  24. getDetailApi({ id: props.businessId }).then((resp: StrAnyObj) => {
  25. formData.value = resp
  26. updateAmount()
  27. updateDetailRemark()
  28. })
  29. },
  30. { immediate: true }
  31. )
  32. const formData = ref<StrAnyObj>({ paymentRequestsDetailList: [{}] })
  33. const deptIdRef = ref<InstanceType<typeof DeptTreeSelect>>()
  34. const formConfig: 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. placeholder: props.disabled ? '' : undefined,
  46. rule: [{ required: true, message: '归属公司id不能为空', trigger: 'blur' }]
  47. },
  48. {
  49. type: 'slot',
  50. prop: 'deptId',
  51. label: '归属部门',
  52. placeholder: props.disabled ? '' : undefined,
  53. rule: [{ required: true, message: '部门id不能为空', trigger: 'blur' }]
  54. },
  55. {
  56. type: 'select',
  57. prop: 'type',
  58. label: '请款类型',
  59. dict: 'payment_requests_type',
  60. placeholder: props.disabled ? '' : undefined,
  61. rule: [{ required: true, message: '请款类型不能为空', trigger: 'blur' }]
  62. },
  63. {
  64. type: 'datePicker',
  65. prop: 'useTime',
  66. label: '用款时间',
  67. datePickerType: 'datetime',
  68. format: 'YYYY-MM-DD 00:00:00',
  69. valueFormat: 'YYYY-MM-DD 00:00:00',
  70. placeholder: props.disabled ? '' : undefined
  71. },
  72. {
  73. type: 'input',
  74. itemType: 'textarea',
  75. prop: 'useRemark',
  76. label: '用款说明',
  77. rows: 3,
  78. span: 24,
  79. placeholder: '自动拼接请款明细中的款项说明',
  80. disabled: true
  81. },
  82. {
  83. type: 'slot',
  84. prop: 'atts',
  85. label: '上传附件',
  86. span: 24,
  87. placeholder: props.disabled ? '' : undefined
  88. },
  89. {
  90. type: 'slot',
  91. prop: 'detailTable',
  92. label: '请款明细',
  93. span: 24,
  94. placeholder: props.disabled ? '' : undefined
  95. },
  96. {
  97. type: 'input',
  98. prop: 'totalAmount',
  99. label: '付款总金额',
  100. disabled: true,
  101. placeholder: '自动统计请款明细中的请款金额'
  102. },
  103. {
  104. type: 'inputNumber',
  105. prop: 'documentQuantity',
  106. label: '单据数量',
  107. min: 0,
  108. precision: 0,
  109. placeholder: props.disabled ? '' : undefined,
  110. rule: [{ required: true, message: '单据数量不能为空', trigger: 'blur' }]
  111. },
  112. {
  113. type: 'select',
  114. prop: 'payType',
  115. label: '付款方式',
  116. dict: 'pay_type',
  117. placeholder: props.disabled ? '' : undefined,
  118. rule: [{ required: true, message: '付款方式不能为空', trigger: 'blur' }]
  119. },
  120. {
  121. type: 'select',
  122. prop: 'capitalAccountId',
  123. label: '付款账户',
  124. keyName: 'id',
  125. labelName: 'accountAlias',
  126. async option() {
  127. const data = await getCapitalAccountPageApi({ searchAll: true })
  128. return data.records
  129. },
  130. placeholder: props.disabled ? '' : undefined
  131. },
  132. {
  133. type: 'input',
  134. prop: 'accountName',
  135. label: '户名',
  136. placeholder: props.disabled ? '' : undefined
  137. },
  138. {
  139. type: 'input',
  140. prop: 'account',
  141. label: '银行账号',
  142. placeholder: props.disabled ? '' : undefined
  143. },
  144. {
  145. type: 'input',
  146. prop: 'depositBank',
  147. label: '开户银行',
  148. placeholder: props.disabled ? '' : undefined
  149. },
  150. {
  151. type: 'input',
  152. prop: 'correspondentNumber',
  153. label: '联行号/SWIFT Code',
  154. placeholder: props.disabled ? '' : undefined
  155. }
  156. ]
  157. const detailTableColumnConfig: ColumnConfigType[] = [
  158. {
  159. slot: 'expenseType',
  160. label: '费用类型',
  161. width: 250
  162. },
  163. {
  164. slot: 'remark',
  165. label: '款项说明'
  166. },
  167. {
  168. slot: 'amount',
  169. label: '请款金额',
  170. width: 180
  171. },
  172. {
  173. width: 100,
  174. if: () => !props.disabled,
  175. handleConfig: [
  176. {
  177. common: 'delete',
  178. click(row, index) {
  179. formData.value.paymentRequestsDetailList.splice(index, 1)
  180. updateDetailRemark()
  181. updateAmount()
  182. }
  183. }
  184. ]
  185. }
  186. ]
  187. function addPaymentRequestsDetailList() {
  188. formData.value.paymentRequestsDetailList.push({})
  189. }
  190. function updateDetailRemark() {
  191. formData.value.useRemark = formData.value.paymentRequestsDetailList
  192. .map((item) => item.remark)
  193. .filter((item) => item !== '' && item !== null && item !== undefined)
  194. .join(' - \n')
  195. }
  196. function updateAmount() {
  197. formData.value.totalAmount = formData.value.paymentRequestsDetailList
  198. .map((item) => item.amount)
  199. .filter((item) => item !== '' && item !== null && item !== undefined)
  200. .reduce((pre, next) => pre + next, 0)
  201. }
  202. </script>
  203. <template>
  204. <a-form ref="formRef" v-model="formData" :config="formConfig" :span="12" :disabled="disabled">
  205. <template #deptId>
  206. <dept-tree-select ref="deptIdRef" v-model="formData.deptId" :disabled="disabled" />
  207. </template>
  208. <template #atts>
  209. <file-upload v-model="formData.atts" :disabled="disabled" />
  210. </template>
  211. <template #detailTable>
  212. <a-table
  213. :data="formData.paymentRequestsDetailList"
  214. :columnConfig="detailTableColumnConfig"
  215. style="width: 100%"
  216. :card="false"
  217. >
  218. <template #expenseType="scope">
  219. <a-select v-model="scope.row.expenseType" dict="expense_type" :disabled="disabled" />
  220. </template>
  221. <template #remark="scope">
  222. <a-input
  223. v-model="scope.row.remark"
  224. type="textarea"
  225. :rows="2"
  226. :disabled="disabled"
  227. @change="updateDetailRemark"
  228. />
  229. </template>
  230. <template #amount="scope">
  231. <a-inputNumber
  232. v-model="scope.row.amount"
  233. :min="0.01"
  234. :precision="2"
  235. :disabled="disabled"
  236. @change="updateAmount"
  237. />
  238. </template>
  239. </a-table>
  240. <el-button
  241. v-if="!disabled"
  242. style="width: 100%; margin-bottom: 20px"
  243. type="primary"
  244. @click="addPaymentRequestsDetailList"
  245. >
  246. 添加行
  247. </el-button>
  248. </template>
  249. </a-form>
  250. </template>
  251. <style scoped lang="scss"></style>