collectionPayment.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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="{ y: 300 }"
  37. :loading="loading"
  38. :locale="{emptyText: '请先选择单据'}"
  39. :pagination="false"
  40. bordered>
  41. <!-- 序号 -->
  42. <template slot="no" slot-scope="text, record, index">
  43. {{ index+1 }}
  44. </template>
  45. <!-- 本次结算金额 -->
  46. <template slot="settleAmount" slot-scope="text, record">
  47. <a-input-number
  48. id="collectionPayment-settleAmount"
  49. v-model="record.settleAmount"
  50. :precision="2"
  51. :min="record.unsettleAmount<0 ? record.unsettleAmount : 0.01"
  52. :max="record.unsettleAmount<0 ? -0.01 : record.unsettleAmount"
  53. size="small"
  54. placeholder="请输入"
  55. style="width: 100%;" />
  56. </template>
  57. <!-- 操作 -->
  58. <template slot="action" slot-scope="text, record">
  59. <a-button size="small" type="primary" class="button-error" @click="handleDel(record)" id="collectionPayment-del-btn">移除</a-button>
  60. </template>
  61. </a-table>
  62. </a-collapse-panel>
  63. </a-collapse>
  64. </a-card>
  65. <a-card size="small" :bordered="false" class="collectionPayment-cont">
  66. <a-collapse :activeKey="['1']">
  67. <a-collapse-panel key="1" header="收付款信息">
  68. <a-form-model
  69. id="collectionPayment-form"
  70. ref="ruleForm"
  71. :model="form"
  72. :rules="rules"
  73. :label-col="formItemLayout.labelCol"
  74. :wrapper-col="formItemLayout.wrapperCol">
  75. <a-row :gutter="20">
  76. <a-col span="12">
  77. <a-form-model-item prop="amountSettled">
  78. <template slot="label">
  79. 应结算金额(<span :class="isPositive ? 'green':'red'">{{ isPositive ? '收款' : '付款' }}</span>)
  80. </template>
  81. <a-input-number
  82. id="collectionPayment-amountSettled"
  83. v-model="amountSettled"
  84. disabled
  85. :precision="2"
  86. placeholder=""
  87. style="width: 100%;" />
  88. </a-form-model-item>
  89. </a-col>
  90. <a-col span="12">
  91. <a-form-model-item label="折让金额" prop="discountAmount">
  92. <a-input-number
  93. id="collectionPayment-discountAmount"
  94. v-model="form.discountAmount"
  95. :precision="2"
  96. :min="0"
  97. :max="amountSettled"
  98. placeholder="请输入"
  99. style="width: 100%;"
  100. allowClear />
  101. </a-form-model-item>
  102. </a-col>
  103. <a-col span="12">
  104. <a-form-model-item prop="actualSettlementAmount">
  105. <template slot="label">
  106. 实结算金额(<span :class="isPositive ? 'green':'red'">{{ isPositive ? '收款' : '付款' }}</span>)
  107. </template>
  108. <a-input-number
  109. id="collectionPayment-actualSettlementAmount"
  110. v-model="actualSettlementAmount"
  111. disabled
  112. :precision="2"
  113. placeholder=""
  114. style="width: 100%;" />
  115. </a-form-model-item>
  116. </a-col>
  117. <a-col span="12">
  118. <a-form-model-item label="结算方式" prop="settleStyleSn">
  119. <a-select id="collectionPayment-settleStyleSn" v-model="form.settleStyleSn" placeholder="请选择结算方式" allowClear>
  120. <a-select-option v-for="item in settleStyleList" :value="item.settleStyleSn" :key="item.settleStyleSn">{{ item.name }}</a-select-option>
  121. </a-select>
  122. </a-form-model-item>
  123. </a-col>
  124. <a-col span="24">
  125. <a-form-model-item label="备注" prop="remark" :label-col="{ span: 3 }" :wrapper-col="{ span: 20 }">
  126. <a-textarea id="collectionPayment-remark" :maxLength="100" v-model="form.remark" placeholder="请输入备注(最多100个字符)" allowClear />
  127. </a-form-model-item>
  128. </a-col>
  129. </a-row>
  130. </a-form-model>
  131. </a-collapse-panel>
  132. </a-collapse>
  133. </a-card>
  134. </a-spin>
  135. <div class="affix-cont">
  136. <a-button
  137. type="primary"
  138. id="collectionPayment-submit"
  139. size="large"
  140. :disabled="spinning"
  141. class="button-primary"
  142. @click="handleSubmit"
  143. style="padding: 0 60px;">提交</a-button>
  144. </div>
  145. <choose-bill-modal :openModal="openModal" :nowChoose="chooseLoadData" :settleClientSn="$route.params.sn" @ok="handleOk" @close="handleClose" />
  146. </div>
  147. </template>
  148. <script>
  149. import { STable, VSelect } from '@/components'
  150. import chooseBillModal from './chooseBillModal.vue'
  151. import { settleStyleQueryAll } from '@/api/settleStyle'
  152. import { settleUnitSave } from '@/api/settle'
  153. export default {
  154. components: { STable, VSelect, chooseBillModal },
  155. data () {
  156. return {
  157. spinning: false,
  158. loading: false, // 表格加载中
  159. chooseQueryParam: {
  160. productCode: '',
  161. productName: ''
  162. },
  163. // 表头
  164. chooseColumns: [
  165. { title: '序号', scopedSlots: { customRender: 'no' }, width: '5%', align: 'center' },
  166. { title: '单据号', dataIndex: 'bizNo', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  167. { title: '单据类型', dataIndex: 'bizTypeDictValue', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  168. { title: '审核时间', dataIndex: 'auditTime', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  169. { title: '金额', dataIndex: 'totalAmount', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  170. { title: '余额', dataIndex: 'unsettleAmount', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  171. { title: '本次结算金额', scopedSlots: { customRender: 'settleAmount' }, width: '15%', align: 'center' },
  172. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  173. ],
  174. chooseLoadData: [],
  175. settleStyleList: [], // 结算方式
  176. formItemLayout: {
  177. labelCol: { span: 6 },
  178. wrapperCol: { span: 16 }
  179. },
  180. form: {
  181. discountAmount: 0, // 折让金额
  182. settleStyleSn: undefined,
  183. remark: ''
  184. },
  185. rules: {
  186. discountAmount: [{ required: true, message: '请输入折让金额', trigger: 'blur' }],
  187. settleStyleSn: [{ required: true, message: '请选择结算方式', trigger: 'change' }]
  188. },
  189. openModal: false, // 弹框
  190. isPositive: true // 是否是正值
  191. }
  192. },
  193. computed: {
  194. // 本次结算金额合计
  195. currentTotalBalance () {
  196. let val = 0
  197. this.chooseLoadData.map(item => {
  198. val += (Number(item.settleAmount) * 1000)
  199. })
  200. return val / 1000
  201. },
  202. // 金额合计
  203. totalAmount () {
  204. let val = 0
  205. this.chooseLoadData.map(item => {
  206. val += (Number(item.totalAmount) * 1000)
  207. })
  208. return val / 1000
  209. },
  210. // 余额合计
  211. totalBalance () {
  212. let val = 0
  213. this.chooseLoadData.map(item => {
  214. val += (Number(item.unsettleAmount) * 1000)
  215. })
  216. return val / 1000
  217. },
  218. // 应结算金额
  219. amountSettled () {
  220. let val = 0
  221. this.chooseLoadData.map(item => {
  222. val += (Number(item.settleAmount) * 1000)
  223. })
  224. val = val / 1000
  225. if (val < 0) {
  226. this.isPositive = false
  227. } else {
  228. this.isPositive = true
  229. }
  230. return Math.abs(val)
  231. },
  232. // 实结算金额
  233. actualSettlementAmount () {
  234. const val = (this.amountSettled * 1000 - this.form.discountAmount * 1000) / 1000
  235. return val
  236. }
  237. },
  238. methods: {
  239. // 选择单据
  240. handleChoose () {
  241. this.openModal = true
  242. },
  243. // 移除
  244. handleDel (record) {
  245. const ind = this.chooseLoadData.findIndex(item => item.id == record.id)
  246. this.chooseLoadData.splice(ind, 1)
  247. },
  248. // 提交
  249. handleSubmit () {
  250. const _this = this
  251. if (_this.chooseLoadData.length == 0) {
  252. _this.$message.warning('请选择单据后再提交信息')
  253. return
  254. }
  255. this.$refs.ruleForm.validate(valid => {
  256. if (valid) {
  257. const form = _this.form
  258. form.settleClientSn = _this.$route.params.sn || undefined
  259. form.settleClientType = _this.chooseLoadData[0].settleClientType
  260. form.settleType = _this.isPositive ? 'R' : 'P'
  261. form.settleAmount = _this.amountSettled
  262. form.realSettleAmount = _this.actualSettlementAmount
  263. form.detailList = []
  264. _this.chooseLoadData.map(item => {
  265. form.detailList.push({
  266. bizSn: item.bizSn,
  267. settleAmount: item.settleAmount,
  268. prFlag: item.prFlag
  269. })
  270. })
  271. _this.spinning = true
  272. settleUnitSave(form).then(res => {
  273. if (res.status == 200) {
  274. _this.$message.success(res.message)
  275. _this.handleBack()
  276. _this.spinning = false
  277. } else {
  278. _this.spinning = false
  279. }
  280. })
  281. } else {
  282. console.log('error submit!!')
  283. return false
  284. }
  285. })
  286. },
  287. handleOk (selectedRows) {
  288. this.chooseLoadData = selectedRows
  289. },
  290. // 结算方式
  291. getSettleStyle () {
  292. settleStyleQueryAll({}).then(res => {
  293. if (res.status == 200) {
  294. this.settleStyleList = res.data
  295. } else {
  296. this.settleStyleList = []
  297. }
  298. })
  299. },
  300. // 返回列表
  301. handleBack () {
  302. this.$router.push({ path: `/financialManagement/companyReceivablePayable/list` })
  303. },
  304. // 关闭
  305. handleClose () {
  306. this.openModal = false
  307. }
  308. },
  309. mounted () {
  310. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  311. this.getSettleStyle()
  312. this.chooseLoadData = []
  313. }
  314. },
  315. activated () {
  316. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  317. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  318. this.getSettleStyle()
  319. this.chooseLoadData = []
  320. }
  321. },
  322. beforeRouteEnter (to, from, next) {
  323. next(vm => {})
  324. }
  325. }
  326. </script>
  327. <style lang="less">
  328. .collectionPayment-wrap{
  329. position: relative;
  330. height: 100%;
  331. padding-bottom: 51px;
  332. box-sizing: border-box;
  333. margin-bottom: 10px;
  334. >.ant-spin-nested-loading{
  335. overflow-y: scroll;
  336. height: 100%;
  337. }
  338. .collectionPayment-cont{
  339. margin-top: 10px;
  340. .green{
  341. color: #19be6b;
  342. }
  343. .red{
  344. color: #ed1c24;
  345. }
  346. }
  347. }
  348. </style>