fcDetailModal.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <a-modal
  3. v-model="opened"
  4. :title="title"
  5. centered
  6. :maskClosable="false"
  7. width="60%"
  8. :footer="null"
  9. @cancel="cancel"
  10. >
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-form-model
  13. ref="ruleForm"
  14. :model="form"
  15. :rules="rules"
  16. :label-col="formItemLayout.labelCol"
  17. :wrapper-col="formItemLayout.wrapperCol">
  18. <a-row>
  19. <a-col :span="12">
  20. <a-form-model-item style="margin-bottom:5px;" label="收款日期" prop="receiptDate">
  21. <a-date-picker inputReadOnly style="width:100%" format="YYYY-MM-DD" v-model="form.receiptDate" placeholder="请选择收款日期" />
  22. </a-form-model-item>
  23. </a-col>
  24. <a-col :span="12">
  25. <a-form-model-item style="margin-bottom:5px;" label="客户名称" prop="dealerSn">
  26. <dealerSubareaScopeList ref="settleClientName" @change="custChange" />
  27. </a-form-model-item>
  28. </a-col>
  29. </a-row>
  30. <a-row>
  31. <a-col :span="12">
  32. <a-form-model-item style="margin-bottom:5px;" label="财务编码">
  33. {{ form.dealerCode||'--' }}
  34. <!-- <a-input :maxLength="100" placeholder="请输入财务编码" v-model="form.dealerCode"></a-input> -->
  35. </a-form-model-item>
  36. </a-col>
  37. <a-col :span="12">
  38. <a-form-model-item style="margin-bottom:5px;" label="营业执照名称">
  39. {{ form.licenseName||'--' }}
  40. <!-- <a-input :maxLength="100" placeholder="请输入营业执照名称" v-model="form.licenseName"></a-input> -->
  41. </a-form-model-item>
  42. </a-col>
  43. <a-col :span="12">
  44. <a-form-model-item style="margin-bottom:5px;" label="订单金额">
  45. <a-input-number
  46. style="width:100%"
  47. :min="0"
  48. :max="999999"
  49. :precision="2"
  50. placeholder="请输入订单金额"
  51. v-model="form.orderAmount"></a-input-number>
  52. </a-form-model-item>
  53. </a-col>
  54. <a-col :span="12">
  55. <a-form-model-item style="margin-bottom:5px;" label="收款金额">
  56. <a-input-number
  57. style="width:100%"
  58. :min="0"
  59. :max="999999"
  60. :precision="2"
  61. placeholder="请输入收款金额"
  62. v-model="form.receiptAmount"></a-input-number>
  63. </a-form-model-item>
  64. </a-col>
  65. <a-col :span="12">
  66. <a-form-model-item style="margin-bottom:5px;" label="使用授信">
  67. <a-checkbox v-model="form.useCreditFlag" @change="form.detailItemUseList=[]">是</a-checkbox>
  68. <span v-if="form.useCreditFlag">合计: {{ useTotalAmount||'--' }}</span>
  69. </a-form-model-item>
  70. </a-col>
  71. <a-col :span="12">
  72. <a-form-model-item style="margin-bottom:5px;" label="授信还款">
  73. <a-checkbox v-model="form.payCreditFlag" @change="form.detailItemPayList=[]">是</a-checkbox>
  74. <span v-if="form.payCreditFlag">合计: {{ payTotalAmount||'--' }}</span>
  75. </a-form-model-item>
  76. </a-col>
  77. <a-col :span="12">
  78. <a-form-model-item style="margin-bottom:5px;" label="余款抵扣">
  79. <a-input-number
  80. style="width:100%"
  81. :min="0"
  82. :max="999999"
  83. :precision="2"
  84. placeholder="请输入余款抵扣"
  85. v-model="form.balanceAmount"></a-input-number>
  86. </a-form-model-item>
  87. </a-col>
  88. <a-col :span="12">
  89. <a-form-model-item style="margin-bottom:5px;" label="跨月打款">
  90. <a-input-number
  91. style="width:100%"
  92. :min="0"
  93. :max="999999"
  94. :precision="2"
  95. placeholder="请输入跨月打款金额"
  96. v-model="form.nextMonthAmount"></a-input-number>
  97. </a-form-model-item>
  98. </a-col>
  99. <a-col :span="12">
  100. <a-form-model-item style="margin-bottom:5px;" label="户名">
  101. <a-select placeholder="请选择户名" v-model="form.bankAccount" style="width: 100%" @change="handleChange">
  102. <a-select-option v-for="item in bankList" :value="item.bankAccount">
  103. {{ item.bankAccount }}
  104. </a-select-option>
  105. </a-select>
  106. </a-form-model-item>
  107. </a-col>
  108. <a-col :span="12">
  109. <a-form-model-item style="margin-bottom:5px;" label="汇入银行">
  110. <a-select placeholder="请选择汇入银行" v-model="form.bankName" style="width: 100%">
  111. <a-select-option v-for="item in bankNameList" :value="item">
  112. {{ item }}
  113. </a-select-option>
  114. </a-select>
  115. </a-form-model-item>
  116. </a-col>
  117. <a-col :span="12">
  118. <a-form-model-item style="margin-bottom:5px;" label="足额打款">
  119. <v-select
  120. v-model="form.fullPaymentFlag"
  121. code="FLAG"
  122. placeholder="请选择是否足额打款"
  123. allowClear></v-select>
  124. </a-form-model-item>
  125. </a-col>
  126. <a-col :span="24">
  127. <a-form-model-item style="margin-bottom:5px;" label="备注" :labelCol="{span:3}" :wrapper-col="{ span: 20 }">
  128. <a-textarea :rows="2" :maxLength="500" placeholder="请输入备注(最多500个字符)" v-model="form.remarks"></a-textarea>
  129. </a-form-model-item>
  130. </a-col>
  131. <!-- 使用授信列表 -->
  132. <a-col :span="22" :offset="1" v-if="form.useCreditFlag">
  133. <div style="padding:10px 0">使用授信项目:</div>
  134. <fcDetailSxItem title="使用授信" @updateItemAmount="updateUseAmount" :list="form.detailItemUseList" ref="useCreditItem"></fcDetailSxItem>
  135. </a-col>
  136. <!-- 授信还款列表 -->
  137. <a-col :span="22" :offset="1" v-if="form.payCreditFlag">
  138. <div style="padding:10px 0">授信还款项目:</div>
  139. <fcDetailSxItem title="授信还款" @updateItemAmount="updatePayAmount" :list="form.detailItemPayList" ref="payCreditItem"></fcDetailSxItem>
  140. </a-col>
  141. <a-col :span="24">
  142. <a-form-model-item :wrapper-col="{ span: 12, offset: 6 }" style="text-align: center;margin-top: 50px;">
  143. <a-button type="primary" :loading="confirmLoading" @click="handleSubmit" id="chooseCustom-btn-submit">保存</a-button>
  144. <a-button @click="cancel" style="margin-left: 15px" id="chooseCustom-btn-back">取消</a-button>
  145. </a-form-model-item>
  146. </a-col>
  147. </a-row>
  148. </a-form-model>
  149. </a-spin>
  150. </a-modal>
  151. </template>
  152. <script>
  153. import moment from 'moment'
  154. import { commonMixin } from '@/utils/mixin'
  155. import { VSelect, Upload } from '@/components'
  156. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  157. import fcDetailSxItem from './fcDetailSxItem.vue'
  158. import { financeBookDetailSave, financeBookDetailQueryBySn } from '@/api/financeBook.js'
  159. export default {
  160. name: 'FcDetailModal',
  161. mixins: [commonMixin],
  162. components: { VSelect, Upload, dealerSubareaScopeList, fcDetailSxItem },
  163. props: {
  164. show: {
  165. type: [Boolean],
  166. default: false
  167. },
  168. bookSn: {
  169. type: String,
  170. default: ''
  171. },
  172. bookNo: {
  173. type: String,
  174. default: ''
  175. }
  176. },
  177. data () {
  178. return {
  179. opened: this.show,
  180. spinning: false,
  181. disabled: false,
  182. title: '新增收款明细',
  183. confirmLoading: false,
  184. bookDetailSn: '',
  185. formItemLayout: {
  186. labelCol: { span: 6 },
  187. wrapperCol: { span: 16 }
  188. },
  189. form: {
  190. dealerSn: undefined,
  191. dealerName: '',
  192. receiptDate: moment(),
  193. dealerCode: '',
  194. licenseName: '',
  195. orderAmount: '',
  196. receiptAmount: '',
  197. useCreditFlag: false,
  198. detailItemUseList: [],
  199. payCreditFlag: false,
  200. detailItemPayList: [],
  201. balanceAmount: '',
  202. nextMonthAmount: '',
  203. bankAccount: undefined,
  204. bankName: undefined,
  205. fullPaymentFlag: undefined,
  206. remarks: ''
  207. },
  208. rules: {
  209. receiptDate: [ { required: true, message: '请选择收款日期', trigger: ['change', 'blur'] } ],
  210. dealerSn: [ { required: true, message: '请选择客户', trigger: ['change', 'blur'] } ]
  211. },
  212. useTotalAmount: '',
  213. payTotalAmount: '',
  214. bankList: [
  215. {
  216. bankAccount: '张丽友',
  217. bankName: ['建设银行', '微信收款']
  218. },
  219. {
  220. bankAccount: '张丽添',
  221. bankName: ['农业银行']
  222. },
  223. {
  224. bankAccount: '东莞箭冠',
  225. bankName: ['东莞银行']
  226. },
  227. {
  228. bankAccount: '江西箭冠',
  229. bankName: ['九江银行']
  230. }
  231. ],
  232. bankNameList: []
  233. }
  234. },
  235. methods: {
  236. handleChange (v) {
  237. console.log(v)
  238. const row = this.bankList.find(item => item.bankAccount == v)
  239. this.bankNameList = row.bankName
  240. this.form.bankName = undefined
  241. },
  242. // 客户
  243. custChange (v) {
  244. this.form.dealerSn = v.key
  245. this.form.dealerName = v.name
  246. this.form.licenseName = v.row ? v.row.licenseName : ''
  247. this.form.dealerCode = v.row ? v.row.kdMidCustomerFnumber : ''
  248. },
  249. updateUseAmount (v) {
  250. this.useTotalAmount = v
  251. },
  252. updatePayAmount (v) {
  253. this.payTotalAmount = v
  254. },
  255. // 保存
  256. handleSubmit (e) {
  257. e.preventDefault()
  258. const _this = this
  259. this.$refs.ruleForm.validate(valid => {
  260. if (valid) {
  261. _this.salesSaveFun()
  262. } else {
  263. return false
  264. }
  265. })
  266. },
  267. validItem (data) {
  268. return data.find(item => !item.itemName || !item.itemAmount)
  269. },
  270. // 新建或编辑销售单
  271. salesSaveFun () {
  272. const _this = this
  273. const form = JSON.parse(JSON.stringify(_this.form))
  274. form.receiptDate = moment(form.receiptDate).format('YYYY-MM-DD')
  275. form.payCreditFlag = form.payCreditFlag ? 1 : 0
  276. form.useCreditFlag = form.useCreditFlag ? 1 : 0
  277. form.bookSn = this.bookSn
  278. form.bookNo = this.bookNo
  279. delete form.dealerName
  280. delete form.licenseName
  281. delete form.dealerCode
  282. console.log(form)
  283. if ((form.useCreditFlag && form.detailItemUseList.length == 0) || this.validItem(form.detailItemUseList)) {
  284. this.$message.info('使用授信项目不能为空')
  285. return
  286. }
  287. if ((form.payCreditFlag && form.detailItemPayList.length == 0) || this.validItem(form.detailItemPayList)) {
  288. this.$message.info('授信还款项目不能为空')
  289. return
  290. }
  291. _this.spinning = true
  292. financeBookDetailSave(form).then(res => {
  293. if (res.status == 200) {
  294. _this.$message.success(res.message)
  295. _this.$emit('refashData')
  296. _this.cancel()
  297. _this.spinning = false
  298. } else {
  299. _this.spinning = false
  300. }
  301. })
  302. },
  303. // 详情
  304. getDetail (bookDetailSn) {
  305. this.spinning = true
  306. this.confirmLoading = true
  307. this.title = '编辑收款明细'
  308. this.bookDetailSn = bookDetailSn
  309. financeBookDetailQueryBySn({ bookDetailSn: this.bookDetailSn }).then(res => {
  310. if (res.status == 200) {
  311. const data = res.data
  312. this.form = Object.assign(this.form, data)
  313. this.form.receiptDate = moment(this.form.receiptDate).format('YYYY-MM-DD')
  314. this.form.payCreditFlag = this.form.payCreditFlag == 1
  315. this.form.useCreditFlag = this.form.useCreditFlag == 1
  316. // 回显客户
  317. if (this.form.dealerSn) {
  318. this.$refs.settleClientName.getDetail(this.form.dealerSn)
  319. }
  320. }
  321. this.spinning = false
  322. this.confirmLoading = false
  323. })
  324. },
  325. cancel () {
  326. this.opened = false
  327. this.$emit('cancel')
  328. this.pageInit()
  329. },
  330. pageInit () {
  331. this.$nextTick(() => {
  332. this.title = '新增收款明细'
  333. this.$refs.ruleForm.resetFields()
  334. this.$refs.settleClientName.resetForm()
  335. this.bankNameList = []
  336. this.form = {
  337. dealerSn: undefined,
  338. dealerName: '',
  339. receiptDate: moment(),
  340. dealerCode: '',
  341. licenseName: '',
  342. orderAmount: '',
  343. receiptAmount: '',
  344. useCreditFlag: false,
  345. detailItemUseList: [],
  346. payCreditFlag: false,
  347. detailItemPayList: [],
  348. balanceAmount: '',
  349. nextMonthAmount: '',
  350. bankAccount: undefined,
  351. bankName: undefined,
  352. fullPaymentFlag: undefined,
  353. remarks: ''
  354. }
  355. })
  356. }
  357. },
  358. watch: {
  359. show (newValue, oldValue) {
  360. this.opened = newValue
  361. if (!newValue) {
  362. this.pageInit()
  363. }
  364. }
  365. }
  366. }
  367. </script>