fcDetailModal.vue 20 KB

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