fcDetailModal.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  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
  22. id="fcDetailModal-receiptDate"
  23. inputReadOnly
  24. style="width:100%"
  25. format="YYYY-MM-DD"
  26. v-model="form.receiptDate"
  27. placeholder="请选择收款日期" />
  28. </a-form-model-item>
  29. </a-col>
  30. <a-col :span="12">
  31. <a-form-model-item style="margin-bottom:5px;" label="付款方类型" prop="payerType">
  32. <!-- <v-select
  33. v-model="form.payerType"
  34. showType="radio"
  35. code="PAYER_TYPE"
  36. placeholder="请选择付款方类型"
  37. @change="payerTypeChange"
  38. ></v-select> -->
  39. {{ form.payerTypeDictValue }}
  40. </a-form-model-item>
  41. </a-col>
  42. </a-row>
  43. <!-- 经销售 -->
  44. <a-row v-if="form.payerType=='DEALER'" >
  45. <a-col :span="12">
  46. <a-form-model-item style="margin-bottom:5px;" label="付款方" prop="dealerSn">
  47. <!-- <dealerSubareaScopeList ref="settleClientName" @change="custChange" :disabled="true" /> -->
  48. {{ form.payerName }}
  49. </a-form-model-item>
  50. </a-col>
  51. <a-col :span="12">
  52. <a-form-model-item style="margin-bottom:5px;" label="付款账户类型" prop="payerAccountType">
  53. <v-select
  54. id="fcDetailModal-payerAccountType"
  55. v-model="form.payerAccountType"
  56. showType="radio"
  57. code="PAYER_ACCOUNT_TYPE"
  58. placeholder="请选择付款账户类型"
  59. @change="accountTypeChange"
  60. ></v-select>
  61. </a-form-model-item>
  62. </a-col>
  63. </a-row>
  64. <a-row v-if="form.payerType=='DEALER'" >
  65. <!-- 公户 -->
  66. <a-col :span="12" v-if="form.payerAccountType=='PUBLIC'">
  67. <a-form-model-item style="margin-bottom:5px;" label="营业执照名称">
  68. <a-input id="fcDetailModal-payerAccountInfo" :maxLength="30" placeholder="请输入营业执照名称" v-model="form.payerAccountInfo"></a-input>
  69. </a-form-model-item>
  70. </a-col>
  71. <!-- 私户 -->
  72. <a-col :span="12" v-if="form.payerAccountType=='PRIVATE'">
  73. <a-form-model-item style="margin-bottom:5px;" label="付款账户">
  74. <a-input id="fcDetailModal-payerAccountInfo1" :maxLength="30" placeholder="付款账户" v-model="form.payerAccountInfo"></a-input>
  75. </a-form-model-item>
  76. </a-col>
  77. <a-col :span="12">
  78. <a-form-model-item style="margin-bottom:5px;" label="财务编码">
  79. {{ form.dealerCode||'--' }}
  80. </a-form-model-item>
  81. </a-col>
  82. </a-row>
  83. <!-- 部门或其它 -->
  84. <a-row v-if="form.payerType=='DEPT'" >
  85. <a-col :span="12">
  86. <a-form-model-item style="margin-bottom:5px;" label="付款方" prop="payerName">
  87. <!-- <a-input :maxLength="30" placeholder="请输入付款方名称" disabled v-model="form.payerName"></a-input> -->
  88. {{ form.payerName }}
  89. </a-form-model-item>
  90. </a-col>
  91. <a-col :span="12">
  92. <a-form-model-item style="margin-bottom:5px;" label="付款账户">
  93. <a-input id="fcDetailModal-payerAccountInfo2" :maxLength="30" placeholder="付款账户" v-model="form.payerAccountInfo"></a-input>
  94. </a-form-model-item>
  95. </a-col>
  96. </a-row>
  97. <a-divider />
  98. <a-row>
  99. <a-col :span="12">
  100. <a-form-model-item style="margin-bottom:5px;" label="订单金额">
  101. <a-input-number
  102. style="width:100%"
  103. id="fcDetailModal-orderAmount"
  104. :min="0"
  105. :max="99999999"
  106. :precision="2"
  107. placeholder="请输入订单金额"
  108. v-model="form.orderAmount"></a-input-number>
  109. </a-form-model-item>
  110. </a-col>
  111. <a-col :span="12">
  112. <a-form-model-item style="margin-bottom:5px;" label="收款金额">
  113. <a-input-number
  114. style="width:100%"
  115. id="fcDetailModal-receiptAmount"
  116. :min="0"
  117. :max="99999999"
  118. :precision="2"
  119. placeholder="请输入收款金额"
  120. v-model="form.receiptAmount"></a-input-number>
  121. </a-form-model-item>
  122. </a-col>
  123. <a-col :span="12">
  124. <a-form-model-item style="margin-bottom:5px;" label="使用授信">
  125. <a-checkbox id="fcDetailModal-useCreditFlag" v-model="form.useCreditFlag" @change="form.detailItemUseList=[]">是</a-checkbox>
  126. <span v-if="form.useCreditFlag">合计: {{ useTotalAmount||'--' }}</span>
  127. </a-form-model-item>
  128. </a-col>
  129. <a-col :span="12">
  130. <a-form-model-item style="margin-bottom:5px;" label="授信还款">
  131. <a-checkbox id="fcDetailModal-payCreditFlag" v-model="form.payCreditFlag" @change="form.detailItemPayList=[]">是</a-checkbox>
  132. <span v-if="form.payCreditFlag">合计: {{ payTotalAmount||'--' }}</span>
  133. </a-form-model-item>
  134. </a-col>
  135. <a-col :span="12">
  136. <a-form-model-item style="margin-bottom:5px;" label="余款抵扣">
  137. <a-input-number
  138. id="fcDetailModal-balanceAmount"
  139. style="width:100%"
  140. :min="0"
  141. :max="99999999"
  142. :precision="2"
  143. placeholder="请输入余款抵扣"
  144. v-model="form.balanceAmount"></a-input-number>
  145. </a-form-model-item>
  146. </a-col>
  147. <a-col :span="12">
  148. <a-form-model-item style="margin-bottom:5px;" label="跨月打款">
  149. <a-input-number
  150. style="width:100%"
  151. id="fcDetailModal-nextMonthAmount"
  152. :min="0"
  153. :max="99999999"
  154. :precision="2"
  155. placeholder="请输入跨月打款金额"
  156. v-model="form.nextMonthAmount"></a-input-number>
  157. </a-form-model-item>
  158. </a-col>
  159. <a-col :span="12">
  160. <a-form-model-item style="margin-bottom:5px;" label="特殊申请发货">
  161. <a-input-number
  162. style="width:100%"
  163. id="fcDetailModal-specialSendAmount"
  164. :min="0"
  165. :max="99999999"
  166. :precision="2"
  167. placeholder="请输入特殊申请发货金额"
  168. v-model="form.specialSendAmount"></a-input-number>
  169. </a-form-model-item>
  170. </a-col>
  171. <a-col :span="12">
  172. <a-form-model-item style="margin-bottom:5px;" label="足额打款">
  173. <v-select
  174. showType="radio"
  175. id="fcDetailModal-fullPaymentFlag"
  176. v-model="form.fullPaymentFlag"
  177. code="FLAG"
  178. placeholder="请选择是否足额打款"
  179. allowClear></v-select>
  180. </a-form-model-item>
  181. </a-col>
  182. <a-col :span="12">
  183. <a-form-model-item style="margin-bottom:5px;" label="户名" prop="bankAccount">
  184. <a-select placeholder="请选择户名" v-model="form.bankAccount" id="fcDetailModal-bankAccount" style="width: 100%" @change="handleChange">
  185. <a-select-option v-for="item in bankList" :value="item.bankAccount">
  186. {{ item.bankAccount }}
  187. </a-select-option>
  188. </a-select>
  189. </a-form-model-item>
  190. </a-col>
  191. <a-col :span="12">
  192. <a-form-model-item style="margin-bottom:5px;" label="汇入银行" prop="bankName">
  193. <a-select placeholder="请选择汇入银行" id="fcDetailModal-bankName" v-model="form.bankName" style="width: 100%">
  194. <a-select-option v-for="item in bankNameList" :value="item">
  195. {{ item }}
  196. </a-select-option>
  197. </a-select>
  198. </a-form-model-item>
  199. </a-col>
  200. <a-col :span="24">
  201. <a-form-model-item style="margin-bottom:5px;" label="说明" :labelCol="{span:3}" :wrapper-col="{ span: 20 }">
  202. <a-textarea :rows="2" id="fcDetailModal-explainInfo" :maxLength="500" placeholder="请输入说明(最多500个字符)" v-model="form.explainInfo"></a-textarea>
  203. </a-form-model-item>
  204. </a-col>
  205. <!-- 使用授信列表 -->
  206. <a-col :span="22" :offset="1" v-if="form.useCreditFlag">
  207. <div style="padding:10px 0">使用授信项目:</div>
  208. <fcDetailSxItem title="使用授信" @updateItemAmount="updateUseAmount" :list="form.detailItemUseList" ref="useCreditItem"></fcDetailSxItem>
  209. </a-col>
  210. <!-- 授信还款列表 -->
  211. <a-col :span="22" :offset="1" v-if="form.payCreditFlag">
  212. <div style="padding:10px 0">授信还款项目:</div>
  213. <fcDetailSxItem title="授信还款" @updateItemAmount="updatePayAmount" :list="form.detailItemPayList" ref="payCreditItem"></fcDetailSxItem>
  214. </a-col>
  215. <a-col :span="24">
  216. <a-form-model-item :wrapper-col="{ span: 12, offset: 6 }" style="text-align: center;margin-top: 50px;">
  217. <a-button @click="cancel" style="margin-right: 15px" id="fcDetailModal-btn-back">取消</a-button>
  218. <a-button type="primary" :loading="confirmLoading" @click="handleSubmit" id="fcDetailModal-btn-submit">保存</a-button>
  219. </a-form-model-item>
  220. </a-col>
  221. </a-row>
  222. </a-form-model>
  223. </a-spin>
  224. </a-modal>
  225. </template>
  226. <script>
  227. import moment from 'moment'
  228. import { commonMixin } from '@/utils/mixin'
  229. import { VSelect, Upload } from '@/components'
  230. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  231. import fcDetailSxItem from './fcDetailSxItem.vue'
  232. import { financeBookDetailSave, financeBookDetailQueryBySn, lastPayerAccountInfo } from '@/api/financeBook.js'
  233. import { dealerDetailBySn } from '@/api/dealer'
  234. export default {
  235. name: 'FcDetailModal',
  236. mixins: [commonMixin],
  237. components: { VSelect, Upload, dealerSubareaScopeList, fcDetailSxItem },
  238. props: {
  239. show: {
  240. type: [Boolean],
  241. default: false
  242. },
  243. bookSn: {
  244. type: String,
  245. default: ''
  246. },
  247. bookNo: {
  248. type: String,
  249. default: ''
  250. }
  251. },
  252. data () {
  253. return {
  254. opened: this.show,
  255. spinning: false,
  256. disabled: false,
  257. title: '新增收款明细',
  258. confirmLoading: false,
  259. bookDetailSn: '', // 收款明细sn
  260. formItemLayout: {
  261. labelCol: { span: 6 },
  262. wrapperCol: { span: 16 }
  263. },
  264. form: {
  265. payerType: 'DEALER', // 付款方
  266. payerAccountType: 'PUBLIC', // 付款账户
  267. dealerSn: undefined, // 客户sn
  268. payerName: '', // 付款方名称
  269. payerAccountInfo: '', // 付款账户
  270. licenseName: '', // 营业执照
  271. receiptDate: moment(), // 收款日期
  272. dealerCode: '', // 财务编码
  273. orderAmount: '', // 订单金额
  274. receiptAmount: '', // 收款金额
  275. useCreditFlag: false, // 是否使用授信
  276. detailItemUseList: [], // 授信使用项目
  277. payCreditFlag: false, // 是否授信还款
  278. detailItemPayList: [], // 授信还款项目
  279. balanceAmount: '', // 余额
  280. nextMonthAmount: '', // 下月额度
  281. specialSendAmount: '', // 特批额度
  282. bankAccount: '东莞箭冠', // 汇入银行户名
  283. bankName: '东莞银行', // 汇入银行
  284. fullPaymentFlag: '1', // 足额打款
  285. explainInfo: '' // 说明
  286. },
  287. rules: {
  288. receiptDate: [ { required: true, message: '请选择收款日期', trigger: ['change', 'blur'] } ],
  289. payerType: [ { required: true, message: '请选择付款方类型', trigger: ['change', 'blur'] } ],
  290. dealerSn: [ { required: true, message: '请选择付款方', trigger: ['change', 'blur'] } ],
  291. payerName: [ { required: true, message: '请输入付款方名称', trigger: ['change', 'blur'] } ],
  292. payerAccountType: [ { required: true, message: '请选择付款账户类型', trigger: ['change', 'blur'] } ],
  293. bankAccount: [{ required: true, message: '请选择户名', trigger: ['change', 'blur'] }],
  294. bankName: [{ required: true, message: '请选择汇入银行', trigger: ['change', 'blur'] }]
  295. },
  296. useTotalAmount: '',
  297. payTotalAmount: '',
  298. bankList: [
  299. {
  300. bankAccount: '张丽友',
  301. bankName: ['建设银行', '微信收款']
  302. },
  303. {
  304. bankAccount: '张丽添',
  305. bankName: ['农业银行']
  306. },
  307. {
  308. bankAccount: '东莞箭冠',
  309. bankName: ['东莞银行']
  310. },
  311. {
  312. bankAccount: '江西箭冠',
  313. bankName: ['九江银行']
  314. }
  315. ],
  316. bankNameList: ['东莞银行']
  317. }
  318. },
  319. methods: {
  320. payerTypeChange (v) {
  321. this.$refs.ruleForm.clearValidate()
  322. // 重置数据
  323. this.form.dealerSn = ''
  324. this.form.dealerCode = ''
  325. this.form.licenseName = ''
  326. this.form.payerAccountType = 'PUBLIC'
  327. this.form.bankAccount = '东莞箭冠'
  328. this.form.bankName = '东莞银行'
  329. this.bankNameList = ['东莞银行']
  330. this.form.payerAccountInfo = ''
  331. this.form.payerName = ''
  332. },
  333. accountTypeChange (v) {
  334. this.$refs.ruleForm.clearValidate()
  335. // 已选经销商
  336. if (this.form.dealerSn) {
  337. // 查询账户信息
  338. this.getLastPayerAccount()
  339. } else {
  340. this.form.licenseName = ''
  341. this.form.payerAccountInfo = ''
  342. }
  343. if (this.form.payerAccountType == 'PUBLIC') {
  344. this.form.bankAccount = '东莞箭冠'
  345. this.form.bankName = '东莞银行'
  346. this.bankNameList = ['东莞银行']
  347. } else {
  348. this.form.bankAccount = '张丽添'
  349. this.form.bankName = '农业银行'
  350. this.bankNameList = ['农业银行']
  351. }
  352. },
  353. handleChange (v) {
  354. if (v) {
  355. this.form.bankAccount = v
  356. const row = this.bankList.find(item => item.bankAccount == v)
  357. this.bankNameList = row.bankName
  358. this.form.bankName = undefined
  359. }
  360. },
  361. getLastPayerAccount () {
  362. this.spinning = true
  363. this.confirmLoading = true
  364. lastPayerAccountInfo({
  365. payerAccountType: this.form.payerAccountType,
  366. dealerSn: this.form.dealerSn
  367. }).then(res => {
  368. this.spinning = false
  369. this.confirmLoading = false
  370. this.form.payerAccountInfo = res.data || ''
  371. })
  372. },
  373. // 查询经销商信息
  374. getDealerDetail (sn) {
  375. dealerDetailBySn({ sn: sn }).then(res => {
  376. const val = { key: sn }
  377. val.row = res.data
  378. this.custChange(val)
  379. })
  380. },
  381. // 客户
  382. custChange (v) {
  383. if (v && v.key) {
  384. this.form.dealerSn = v.key
  385. this.form.payerName = v.row ? v.row.dealerName : ''
  386. this.form.dealerCode = v.row ? v.row.kdMidCustomerFnumber : ''
  387. this.form.licenseName = v.row ? v.row.licenseName : ''
  388. // 查询账户信息
  389. this.getLastPayerAccount()
  390. } else {
  391. this.form.dealerSn = ''
  392. this.form.payerName = ''
  393. this.form.dealerCode = ''
  394. this.form.licenseName = ''
  395. this.form.payerAccountInfo = ''
  396. }
  397. },
  398. updateUseAmount (v) {
  399. this.useTotalAmount = v
  400. },
  401. updatePayAmount (v) {
  402. this.payTotalAmount = v
  403. },
  404. // 保存
  405. handleSubmit (e) {
  406. e.preventDefault()
  407. const _this = this
  408. this.$refs.ruleForm.validate(valid => {
  409. if (valid) {
  410. _this.salesSaveFun()
  411. } else {
  412. return false
  413. }
  414. })
  415. },
  416. validItem (data) {
  417. return data.find(item => !item.itemName || !item.itemAmount)
  418. },
  419. // 新建或编辑销售单
  420. salesSaveFun () {
  421. const _this = this
  422. const form = JSON.parse(JSON.stringify(_this.form))
  423. form.receiptDate = moment(form.receiptDate).format('YYYY-MM-DD')
  424. form.payCreditFlag = form.payCreditFlag ? 1 : 0
  425. form.useCreditFlag = form.useCreditFlag ? 1 : 0
  426. form.bookSn = this.bookSn
  427. form.bookNo = this.bookNo
  428. delete form.dealerCode
  429. if (form.payerType == 'DEPT') {
  430. delete form.payerAccountType
  431. }
  432. console.log(form)
  433. if ((form.useCreditFlag && form.detailItemUseList.length == 0) || this.validItem(form.detailItemUseList)) {
  434. this.$message.info('使用授信项目不能为空')
  435. return
  436. }
  437. if ((form.payCreditFlag && form.detailItemPayList.length == 0) || this.validItem(form.detailItemPayList)) {
  438. this.$message.info('授信还款项目不能为空')
  439. return
  440. }
  441. _this.spinning = true
  442. financeBookDetailSave(form).then(res => {
  443. if (res.status == 200) {
  444. _this.$message.success(res.message)
  445. _this.$emit('refashData')
  446. _this.cancel()
  447. _this.spinning = false
  448. } else {
  449. _this.spinning = false
  450. }
  451. })
  452. },
  453. setDetail (data) {
  454. this.form = Object.assign(this.form, { payerTypeDictValue: data.payerTypeDictValue, payerType: data.payerType, dealerSn: data.dealerSn, payerName: data.payerName })
  455. this.$nextTick(() => {
  456. if (this.form.dealerSn) {
  457. // this.$refs.settleClientName.getDetail(this.form.dealerSn)
  458. this.getDealerDetail(this.form.dealerSn)
  459. } else {
  460. this.form.bankAccount = '张丽添'
  461. this.form.bankName = '农业银行'
  462. this.bankNameList = ['农业银行']
  463. }
  464. })
  465. },
  466. // 详情
  467. getDetail (bookDetailSn) {
  468. this.spinning = true
  469. this.confirmLoading = true
  470. this.title = '编辑收款明细'
  471. this.bookDetailSn = bookDetailSn
  472. financeBookDetailQueryBySn({ bookDetailSn: this.bookDetailSn }).then(res => {
  473. if (res.status == 200) {
  474. const data = res.data
  475. this.handleChange(data.bankAccount)
  476. this.form = Object.assign(this.form, data)
  477. this.form.receiptDate = moment(this.form.receiptDate).format('YYYY-MM-DD')
  478. this.form.payCreditFlag = this.form.payCreditFlag == 1
  479. this.form.useCreditFlag = this.form.useCreditFlag == 1
  480. // 回显客户
  481. // if (this.form.dealerSn && this.form.payerType == 'DEALER') {
  482. // this.$nextTick(() => {
  483. // this.$refs.settleClientName.getDetail(this.form.dealerSn)
  484. // })
  485. // }
  486. }
  487. this.spinning = false
  488. this.confirmLoading = false
  489. })
  490. },
  491. cancel () {
  492. this.opened = false
  493. this.$emit('cancel')
  494. this.pageInit()
  495. },
  496. pageInit () {
  497. this.$nextTick(() => {
  498. this.title = '新增收款明细'
  499. })
  500. this.bankNameList = []
  501. this.bankNameList = ['东莞银行']
  502. if (this.$refs.ruleForm) {
  503. this.$refs.ruleForm.resetFields()
  504. }
  505. this.form = {
  506. payerType: 'DEALER',
  507. payerAccountType: 'PUBLIC',
  508. dealerSn: undefined,
  509. payerName: '',
  510. payerAccountInfo: '',
  511. licenseName: '',
  512. receiptDate: moment(),
  513. dealerCode: '',
  514. orderAmount: '',
  515. receiptAmount: '',
  516. useCreditFlag: false,
  517. detailItemUseList: [],
  518. payCreditFlag: false,
  519. detailItemPayList: [],
  520. balanceAmount: '',
  521. nextMonthAmount: '',
  522. specialSendAmount: '',
  523. bankAccount: '东莞箭冠',
  524. bankName: '东莞银行',
  525. fullPaymentFlag: '1',
  526. explainInfo: ''
  527. }
  528. }
  529. },
  530. watch: {
  531. show (newValue, oldValue) {
  532. this.opened = newValue
  533. }
  534. }
  535. }
  536. </script>