collectionPayment.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <div class="collectionPayment-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="collectionPayment-back" >
  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" style="margin-bottom:10px">
  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-spin>
  133. <div class="affix-cont">
  134. <a-button
  135. type="primary"
  136. id="collectionPayment-submit"
  137. size="large"
  138. :disabled="spinning"
  139. class="button-primary"
  140. @click="handleSubmit"
  141. style="padding: 0 60px;">提交</a-button>
  142. </div>
  143. <choose-bill-modal :openModal="openModal" :nowChoose="chooseLoadData" :settleClientSn="$route.params.sn" @ok="handleOk" @close="handleClose" />
  144. </div>
  145. </template>
  146. <script>
  147. import { STable, VSelect } from '@/components'
  148. import chooseBillModal from './chooseBillModal.vue'
  149. import { settleStyleQueryAll } from '@/api/settleStyle'
  150. import { settleUnitSave } from '@/api/settle'
  151. export default {
  152. components: { STable, VSelect, chooseBillModal },
  153. data () {
  154. return {
  155. spinning: false,
  156. loading: false, // 表格加载中
  157. chooseQueryParam: {
  158. productCode: '',
  159. productName: ''
  160. },
  161. // 表头
  162. chooseColumns: [
  163. { title: '序号', scopedSlots: { customRender: 'no' }, width: 80, align: 'center' },
  164. { title: '单据号', dataIndex: 'bizNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  165. { title: '单据类型', dataIndex: 'bizTypeDictValue', align: 'center', customRender: function (text) { return text || '--' } },
  166. { title: '审核时间', dataIndex: 'auditTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  167. { title: '金额', dataIndex: 'totalAmount', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  168. { title: '余额', dataIndex: 'unsettleAmount', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  169. { title: '本次结算金额', scopedSlots: { customRender: 'settleAmount' }, width: 140, align: 'center' },
  170. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  171. ],
  172. chooseLoadData: [],
  173. settleStyleList: [], // 结算方式
  174. formItemLayout: {
  175. labelCol: { span: 6 },
  176. wrapperCol: { span: 16 }
  177. },
  178. form: {
  179. discountAmount: 0, // 折让金额
  180. settleStyleSn: undefined,
  181. remark: ''
  182. },
  183. rules: {
  184. discountAmount: [{ required: true, message: '请输入折让金额', trigger: 'blur' }],
  185. settleStyleSn: [{ required: true, message: '请选择结算方式', trigger: 'change' }]
  186. },
  187. openModal: false, // 弹框
  188. isPositive: true // 是否是正值
  189. }
  190. },
  191. computed: {
  192. // 本次结算金额合计
  193. currentTotalBalance () {
  194. let val = 0
  195. this.chooseLoadData.map(item => {
  196. val += (Number(item.settleAmount) * 1000)
  197. })
  198. return val / 1000
  199. },
  200. // 金额合计
  201. totalAmount () {
  202. let val = 0
  203. this.chooseLoadData.map(item => {
  204. val += (Number(item.totalAmount) * 1000)
  205. })
  206. return val / 1000
  207. },
  208. // 余额合计
  209. totalBalance () {
  210. let val = 0
  211. this.chooseLoadData.map(item => {
  212. val += (Number(item.unsettleAmount) * 1000)
  213. })
  214. return val / 1000
  215. },
  216. // 应结算金额
  217. amountSettled () {
  218. let val = 0
  219. this.chooseLoadData.map(item => {
  220. val += (Number(item.settleAmount) * 1000)
  221. })
  222. val = val / 1000
  223. if (val < 0) {
  224. this.isPositive = false
  225. } else {
  226. this.isPositive = true
  227. }
  228. return Math.abs(val)
  229. },
  230. // 实结算金额
  231. actualSettlementAmount () {
  232. const val = (this.amountSettled * 1000 - this.form.discountAmount * 1000) / 1000
  233. return val
  234. }
  235. },
  236. methods: {
  237. // 选择单据
  238. handleChoose () {
  239. this.openModal = true
  240. },
  241. // 移除
  242. handleDel (record) {
  243. const ind = this.chooseLoadData.findIndex(item => item.id == record.id)
  244. this.chooseLoadData.splice(ind, 1)
  245. },
  246. // 提交
  247. handleSubmit () {
  248. const _this = this
  249. if (_this.chooseLoadData.length == 0) {
  250. _this.$message.warning('请选择单据后再提交信息')
  251. return
  252. }
  253. this.$refs.ruleForm.validate(valid => {
  254. if (valid) {
  255. const form = _this.form
  256. form.settleClientSn = _this.$route.params.sn || undefined
  257. form.settleClientType = _this.chooseLoadData[0].settleClientType
  258. form.settleType = _this.isPositive ? 'R' : 'P'
  259. form.settleAmount = _this.amountSettled
  260. form.realSettleAmount = _this.actualSettlementAmount
  261. form.detailList = []
  262. _this.chooseLoadData.map(item => {
  263. form.detailList.push({
  264. bizSn: item.bizSn,
  265. settleAmount: item.settleAmount,
  266. prFlag: item.prFlag
  267. })
  268. })
  269. _this.spinning = true
  270. settleUnitSave(form).then(res => {
  271. if (res.status == 200) {
  272. _this.$message.success(res.message)
  273. _this.handleBack()
  274. _this.spinning = false
  275. } else {
  276. _this.spinning = false
  277. }
  278. })
  279. } else {
  280. console.log('error submit!!')
  281. return false
  282. }
  283. })
  284. },
  285. handleOk (selectedRows) {
  286. this.chooseLoadData = selectedRows
  287. },
  288. // 结算方式
  289. getSettleStyle () {
  290. settleStyleQueryAll({}).then(res => {
  291. if (res.status == 200) {
  292. this.settleStyleList = res.data
  293. } else {
  294. this.settleStyleList = []
  295. }
  296. })
  297. },
  298. // 返回列表
  299. handleBack () {
  300. this.$router.push({ path: `/financialManagement/companyReceivablePayable/list`, query: { closeLastOldTab: true } })
  301. },
  302. // 关闭
  303. handleClose () {
  304. this.openModal = false
  305. }
  306. },
  307. beforeRouteEnter (to, from, next) {
  308. next(vm => {
  309. vm.getSettleStyle()
  310. })
  311. }
  312. }
  313. </script>
  314. <style lang="less">
  315. .collectionPayment-wrap{
  316. position: relative;
  317. height: 100%;
  318. padding-bottom: 51px;
  319. box-sizing: border-box;
  320. margin-bottom: 10px;
  321. >.ant-spin-nested-loading{
  322. overflow-y: scroll;
  323. height: 100%;
  324. }
  325. .collectionPayment-cont{
  326. margin-top: 10px;
  327. .green{
  328. color: #19be6b;
  329. }
  330. .red{
  331. color: #ed1c24;
  332. }
  333. }
  334. }
  335. </style>