collectionPayment.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <div class="collectionPayment-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="collectionPayment-cont" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="collectionPayment-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <p style=" display: inline-block;margin: 0 0 0 60px;color: #000;font-size: 16px;font-weight: 600;">客户:{{ $route.params.name || '--' }}</p>
  9. </template>
  10. </a-page-header>
  11. <!-- 已选单据 -->
  12. <a-card size="small" :bordered="false" class="collectionPayment-cont">
  13. <a-collapse :activeKey="['1']">
  14. <a-collapse-panel key="1">
  15. <template slot="header">
  16. 已选单据
  17. <a-button type="primary" size="small" class="button-error" id="collectionPayment-circle-btn" @click.stop="handleChoose">选择单据</a-button>
  18. </template>
  19. <!-- 总计 -->
  20. <a-alert type="info" showIcon style="margin-bottom:15px">
  21. <div slot="message">
  22. 共 <strong>{{ chooseLoadData.length }}</strong>条明细 ,
  23. 金额合计¥<strong>{{ totalAmount }}</strong> ,
  24. 余额合计¥<strong>{{ totalBalance }}</strong> ,
  25. 本次结算金额合计¥<strong>{{ currentTotalBalance }}</strong>
  26. </div>
  27. </a-alert>
  28. <!-- 列表 -->
  29. <a-table
  30. class="sTable"
  31. ref="chooseTable"
  32. size="small"
  33. :rowKey="(record) => record.id"
  34. :columns="chooseColumns"
  35. :dataSource="chooseLoadData"
  36. :scroll="{ x: 1040, y: 300 }"
  37. :loading="loading"
  38. :pagination="false"
  39. bordered>
  40. <!-- 序号 -->
  41. <template slot="no" slot-scope="text, record, index">
  42. {{ index+1 }}
  43. </template>
  44. <!-- 本次结算金额 -->
  45. <template slot="settleAmount" slot-scope="text, record">
  46. <a-input-number
  47. id="collectionPayment-settleAmount"
  48. v-model="record.settleAmount"
  49. :precision="2"
  50. :min="record.unsettleAmount<0 ? record.unsettleAmount : 0.01"
  51. :max="record.unsettleAmount<0 ? -0.01 : record.unsettleAmount"
  52. placeholder="请输入"
  53. style="width: 100%;" />
  54. </template>
  55. <!-- 操作 -->
  56. <template slot="action" slot-scope="text, record">
  57. <a-button size="small" type="primary" class="button-error" @click="handleDel(record)" id="collectionPayment-del-btn">移除</a-button>
  58. </template>
  59. </a-table>
  60. </a-collapse-panel>
  61. </a-collapse>
  62. </a-card>
  63. <a-card size="small" :bordered="false" class="collectionPayment-cont">
  64. <a-collapse :activeKey="['1']">
  65. <a-collapse-panel key="1" header="收付款信息">
  66. <a-form-model
  67. id="collectionPayment-form"
  68. ref="ruleForm"
  69. :model="form"
  70. :rules="rules"
  71. :label-col="formItemLayout.labelCol"
  72. :wrapper-col="formItemLayout.wrapperCol">
  73. <a-row :gutter="20">
  74. <a-col span="12">
  75. <a-form-model-item prop="amountSettled">
  76. <template slot="label">
  77. 应结算金额(<span :class="isPositive ? 'green':'red'">{{ isPositive ? '收款' : '付款' }}</span>)
  78. </template>
  79. <a-input-number
  80. id="collectionPayment-amountSettled"
  81. v-model="amountSettled"
  82. disabled
  83. :precision="2"
  84. placeholder=""
  85. style="width: 100%;" />
  86. </a-form-model-item>
  87. </a-col>
  88. <a-col span="12">
  89. <a-form-model-item label="折让金额" prop="discountAmount">
  90. <a-input-number
  91. id="collectionPayment-discountAmount"
  92. v-model="form.discountAmount"
  93. :precision="2"
  94. :min="0"
  95. :max="amountSettled"
  96. placeholder="请输入"
  97. style="width: 100%;"
  98. allowClear />
  99. </a-form-model-item>
  100. </a-col>
  101. <a-col span="12">
  102. <a-form-model-item prop="actualSettlementAmount">
  103. <template slot="label">
  104. 实结算金额(<span :class="isPositive ? 'green':'red'">{{ isPositive ? '收款' : '付款' }}</span>)
  105. </template>
  106. <a-input-number
  107. id="collectionPayment-actualSettlementAmount"
  108. v-model="actualSettlementAmount"
  109. disabled
  110. :precision="2"
  111. placeholder=""
  112. style="width: 100%;" />
  113. </a-form-model-item>
  114. </a-col>
  115. <a-col span="12">
  116. <a-form-model-item label="结算方式" prop="settleStyleSn">
  117. <a-select id="collectionPayment-settleStyleSn" v-model="form.settleStyleSn" placeholder="请选择结算方式" allowClear>
  118. <a-select-option v-for="item in settleStyleList" :value="item.settleStyleSn" :key="item.settleStyleSn">{{ item.name }}</a-select-option>
  119. </a-select>
  120. </a-form-model-item>
  121. </a-col>
  122. <a-col span="24">
  123. <a-form-model-item label="备注" prop="remark" :label-col="{ span: 3 }" :wrapper-col="{ span: 20 }">
  124. <a-textarea id="collectionPayment-remark" :maxLength="100" v-model="form.remark" placeholder="请输入备注(最多100个字符)" allowClear />
  125. </a-form-model-item>
  126. </a-col>
  127. </a-row>
  128. </a-form-model>
  129. </a-collapse-panel>
  130. </a-collapse>
  131. </a-card>
  132. <a-affix :offset-bottom="0">
  133. <div style="text-align: center;width: 100%;background-color: #fff;padding: 12px 0;box-shadow: 0 0 20px #dcdee2;">
  134. <a-button
  135. type="primary"
  136. id="collectionPayment-submit"
  137. size="large"
  138. class="button-primary"
  139. @click="handleSubmit"
  140. style="padding: 0 60px;">提交</a-button>
  141. </div>
  142. </a-affix>
  143. </a-spin>
  144. <choose-bill-modal :openModal="openModal" :nowChoose="chooseLoadData" :settleClientSn="$route.params.sn" @ok="handleOk" @close="handleClose" />
  145. </div>
  146. </template>
  147. <script>
  148. import { STable, VSelect } from '@/components'
  149. import chooseBillModal from './chooseBillModal.vue'
  150. import { settleStyleQueryAll } from '@/api/settleStyle'
  151. import { settleUnitSave } from '@/api/settle'
  152. export default {
  153. components: { STable, VSelect, chooseBillModal },
  154. data () {
  155. return {
  156. spinning: false,
  157. loading: false, // 表格加载中
  158. chooseQueryParam: {
  159. productCode: '',
  160. productName: ''
  161. },
  162. // 表头
  163. chooseColumns: [
  164. { title: '序号', scopedSlots: { customRender: 'no' }, width: 80, align: 'center' },
  165. { title: '单据号', dataIndex: 'bizNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  166. { title: '单据类型', dataIndex: 'bizTypeDictValue', align: 'center', customRender: function (text) { return text || '--' } },
  167. { title: '审核时间', dataIndex: 'auditTime', align: 'center', customRender: function (text) { return text || '--' } },
  168. { title: '金额', dataIndex: 'totalAmount', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  169. { title: '余额', dataIndex: 'unsettleAmount', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  170. { title: '本次结算金额', scopedSlots: { customRender: 'settleAmount' }, width: 140, align: 'center' },
  171. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  172. ],
  173. chooseLoadData: [],
  174. choosePageNo: 1, // 分页页码
  175. choosePageSize: 10, // 分页 每页多少条
  176. settleStyleList: [], // 结算方式
  177. formItemLayout: {
  178. labelCol: { span: 6 },
  179. wrapperCol: { span: 16 }
  180. },
  181. form: {
  182. discountAmount: 0, // 折让金额
  183. settleStyleSn: undefined,
  184. remark: ''
  185. },
  186. rules: {
  187. discountAmount: [{ required: true, message: '请输入折让金额', trigger: 'blur' }],
  188. settleStyleSn: [{ required: true, message: '请选择结算方式', trigger: 'change' }]
  189. },
  190. openModal: false, // 弹框
  191. isPositive: true // 是否是正值
  192. }
  193. },
  194. computed: {
  195. // 本次结算金额合计
  196. currentTotalBalance () {
  197. let val = 0
  198. this.chooseLoadData.map(item => {
  199. val += (Number(item.settleAmount) * 1000)
  200. })
  201. return val / 1000
  202. },
  203. // 金额合计
  204. totalAmount () {
  205. let val = 0
  206. this.chooseLoadData.map(item => {
  207. val += (Number(item.totalAmount) * 1000)
  208. })
  209. return val / 1000
  210. },
  211. // 余额合计
  212. totalBalance () {
  213. let val = 0
  214. this.chooseLoadData.map(item => {
  215. val += (Number(item.unsettleAmount) * 1000)
  216. })
  217. return val / 1000
  218. },
  219. // 应结算金额
  220. amountSettled () {
  221. let val = 0
  222. this.chooseLoadData.map(item => {
  223. val += (Number(item.settleAmount) * 1000)
  224. })
  225. val = val / 1000
  226. if (val < 0) {
  227. this.isPositive = false
  228. } else {
  229. this.isPositive = true
  230. }
  231. return Math.abs(val)
  232. },
  233. // 实结算金额
  234. actualSettlementAmount () {
  235. const val = (this.amountSettled * 1000 - this.form.discountAmount * 1000) / 1000
  236. return val
  237. }
  238. },
  239. methods: {
  240. // 选择单据
  241. handleChoose () {
  242. this.openModal = true
  243. },
  244. // 移除
  245. handleDel (record) {
  246. const ind = this.chooseLoadData.findIndex(item => item.id == record.id)
  247. this.chooseLoadData.splice(ind, 1)
  248. },
  249. // 提交
  250. handleSubmit () {
  251. const _this = this
  252. if (_this.chooseLoadData.length == 0) {
  253. _this.$message.warning('请选择单据后再提交信息')
  254. return
  255. }
  256. this.$refs.ruleForm.validate(valid => {
  257. if (valid) {
  258. const form = _this.form
  259. form.settleClientSn = _this.$route.params.sn || undefined
  260. form.settleClientType = _this.chooseLoadData[0].settleClientType
  261. form.settleType = _this.isPositive ? 'R' : 'P'
  262. form.settleAmount = _this.amountSettled
  263. form.realSettleAmount = _this.actualSettlementAmount
  264. form.detailList = []
  265. _this.chooseLoadData.map(item => {
  266. form.detailList.push({
  267. bizSn: item.bizSn,
  268. settleAmount: item.settleAmount,
  269. prFlag: item.prFlag
  270. })
  271. })
  272. _this.spinning = true
  273. settleUnitSave(form).then(res => {
  274. if (res.status == 200) {
  275. _this.$message.success(res.message)
  276. _this.handleBack()
  277. _this.spinning = false
  278. } else {
  279. _this.spinning = false
  280. }
  281. })
  282. } else {
  283. console.log('error submit!!')
  284. return false
  285. }
  286. })
  287. },
  288. handleOk (selectedRows) {
  289. this.chooseLoadData = selectedRows
  290. },
  291. // 结算方式
  292. getSettleStyle () {
  293. settleStyleQueryAll({}).then(res => {
  294. if (res.status == 200) {
  295. this.settleStyleList = res.data
  296. } else {
  297. this.settleStyleList = []
  298. }
  299. })
  300. },
  301. // 返回列表
  302. handleBack () {
  303. this.$router.push({ path: `/financialManagement/companyReceivablePayable/list` })
  304. },
  305. // 关闭
  306. handleClose () {
  307. this.openModal = false
  308. }
  309. },
  310. beforeRouteEnter (to, from, next) {
  311. next(vm => {
  312. vm.getSettleStyle()
  313. })
  314. }
  315. }
  316. </script>
  317. <style lang="less">
  318. .collectionPayment-cont{
  319. margin-bottom: 15px;
  320. .green{
  321. color: #19be6b;
  322. }
  323. .red{
  324. color: #ed1c24;
  325. }
  326. }
  327. </style>