123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493 |
- <template>
- <a-modal
- v-model="opened"
- :title="title"
- centered
- :maskClosable="false"
- width="60%"
- :footer="null"
- @cancel="cancel"
- >
- <a-spin :spinning="spinning" tip="Loading...">
- <a-form-model
- ref="ruleForm"
- :model="form"
- :rules="rules"
- :label-col="formItemLayout.labelCol"
- :wrapper-col="formItemLayout.wrapperCol">
- <a-row>
- <a-col :span="12">
- <a-form-model-item style="margin-bottom:5px;" label="收款日期" prop="receiptDate">
- <a-date-picker inputReadOnly style="width:100%" format="YYYY-MM-DD" v-model="form.receiptDate" placeholder="请选择收款日期" />
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item style="margin-bottom:5px;" label="付款方类型" prop="payerType">
- <!-- <v-select
- v-model="form.payerType"
- showType="radio"
- code="PAYER_TYPE"
- placeholder="请选择付款方类型"
- @change="payerTypeChange"
- ></v-select> -->
- {{ form.payerTypeDictValue }}
- </a-form-model-item>
- </a-col>
- </a-row>
- <!-- 经销售 -->
- <a-row v-if="form.payerType=='DEALER'" >
- <a-col :span="12">
- <a-form-model-item style="margin-bottom:5px;" label="付款方" prop="dealerSn">
- <!-- <dealerSubareaScopeList ref="settleClientName" @change="custChange" :disabled="true" /> -->
- {{form.payerName}}
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item style="margin-bottom:5px;" label="付款账户类型" prop="payerAccountType">
- <v-select
- v-model="form.payerAccountType"
- showType="radio"
- code="PAYER_ACCOUNT_TYPE"
- placeholder="请选择付款账户类型"
- @change="accountTypeChange"
- ></v-select>
- </a-form-model-item>
- </a-col>
- </a-row>
- <a-row v-if="form.payerType=='DEALER'" >
- <!-- 公户 -->
- <a-col :span="12" v-if="form.payerAccountType=='PUBLIC'">
- <a-form-model-item style="margin-bottom:5px;" label="营业执照名称">
- <a-input :maxLength="30" placeholder="请输入营业执照名称" v-model="form.payerAccountInfo"></a-input>
- </a-form-model-item>
- </a-col>
- <!-- 私户 -->
- <a-col :span="12" v-if="form.payerAccountType=='PRIVATE'">
- <a-form-model-item style="margin-bottom:5px;" label="付款账户">
- <a-input :maxLength="30" placeholder="付款账户" v-model="form.payerAccountInfo"></a-input>
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item style="margin-bottom:5px;" label="财务编码">
- {{ form.dealerCode||'--' }}
- </a-form-model-item>
- </a-col>
- </a-row>
- <!-- 部门或其它 -->
- <a-row v-if="form.payerType=='DEPT'" >
- <a-col :span="12">
- <a-form-model-item style="margin-bottom:5px;" label="付款方" prop="payerName">
- <!-- <a-input :maxLength="30" placeholder="请输入付款方名称" disabled v-model="form.payerName"></a-input> -->
- {{form.payerName}}
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item style="margin-bottom:5px;" label="付款账户">
- <a-input :maxLength="30" placeholder="付款账户" v-model="form.payerAccountInfo"></a-input>
- </a-form-model-item>
- </a-col>
- </a-row>
- <a-divider />
- <a-row>
- <a-col :span="12">
- <a-form-model-item style="margin-bottom:5px;" label="订单金额">
- <a-input-number
- style="width:100%"
- :min="0"
- :max="999999"
- :precision="2"
- placeholder="请输入订单金额"
- v-model="form.orderAmount"></a-input-number>
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item style="margin-bottom:5px;" label="收款金额">
- <a-input-number
- style="width:100%"
- :min="0"
- :max="999999"
- :precision="2"
- placeholder="请输入收款金额"
- v-model="form.receiptAmount"></a-input-number>
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item style="margin-bottom:5px;" label="使用授信">
- <a-checkbox v-model="form.useCreditFlag" @change="form.detailItemUseList=[]">是</a-checkbox>
- <span v-if="form.useCreditFlag">合计: {{ useTotalAmount||'--' }}</span>
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item style="margin-bottom:5px;" label="授信还款">
- <a-checkbox v-model="form.payCreditFlag" @change="form.detailItemPayList=[]">是</a-checkbox>
- <span v-if="form.payCreditFlag">合计: {{ payTotalAmount||'--' }}</span>
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item style="margin-bottom:5px;" label="余款抵扣">
- <a-input-number
- style="width:100%"
- :min="0"
- :max="999999"
- :precision="2"
- placeholder="请输入余款抵扣"
- v-model="form.balanceAmount"></a-input-number>
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item style="margin-bottom:5px;" label="跨月打款">
- <a-input-number
- style="width:100%"
- :min="0"
- :max="999999"
- :precision="2"
- placeholder="请输入跨月打款金额"
- v-model="form.nextMonthAmount"></a-input-number>
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item style="margin-bottom:5px;" label="户名">
- <a-select placeholder="请选择户名" v-model="form.bankAccount" style="width: 100%" @change="handleChange">
- <a-select-option v-for="item in bankList" :value="item.bankAccount">
- {{ item.bankAccount }}
- </a-select-option>
- </a-select>
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item style="margin-bottom:5px;" label="汇入银行">
- <a-select placeholder="请选择汇入银行" v-model="form.bankName" style="width: 100%">
- <a-select-option v-for="item in bankNameList" :value="item">
- {{ item }}
- </a-select-option>
- </a-select>
- </a-form-model-item>
- </a-col>
- <a-col :span="12">
- <a-form-model-item style="margin-bottom:5px;" label="足额打款">
- <v-select
- v-model="form.fullPaymentFlag"
- code="FLAG"
- placeholder="请选择是否足额打款"
- allowClear></v-select>
- </a-form-model-item>
- </a-col>
- <a-col :span="24">
- <a-form-model-item style="margin-bottom:5px;" label="说明" :labelCol="{span:3}" :wrapper-col="{ span: 20 }">
- <a-textarea :rows="2" :maxLength="500" placeholder="请输入说明(最多500个字符)" v-model="form.explainInfo"></a-textarea>
- </a-form-model-item>
- </a-col>
- <!-- 使用授信列表 -->
- <a-col :span="22" :offset="1" v-if="form.useCreditFlag">
- <div style="padding:10px 0">使用授信项目:</div>
- <fcDetailSxItem title="使用授信" @updateItemAmount="updateUseAmount" :list="form.detailItemUseList" ref="useCreditItem"></fcDetailSxItem>
- </a-col>
- <!-- 授信还款列表 -->
- <a-col :span="22" :offset="1" v-if="form.payCreditFlag">
- <div style="padding:10px 0">授信还款项目:</div>
- <fcDetailSxItem title="授信还款" @updateItemAmount="updatePayAmount" :list="form.detailItemPayList" ref="payCreditItem"></fcDetailSxItem>
- </a-col>
- <a-col :span="24">
- <a-form-model-item :wrapper-col="{ span: 12, offset: 6 }" style="text-align: center;margin-top: 50px;">
- <a-button type="primary" :loading="confirmLoading" @click="handleSubmit" id="chooseCustom-btn-submit">保存</a-button>
- <a-button @click="cancel" style="margin-left: 15px" id="chooseCustom-btn-back">取消</a-button>
- </a-form-model-item>
- </a-col>
- </a-row>
- </a-form-model>
- </a-spin>
- </a-modal>
- </template>
- <script>
- import moment from 'moment'
- import { commonMixin } from '@/utils/mixin'
- import { VSelect, Upload } from '@/components'
- import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
- import fcDetailSxItem from './fcDetailSxItem.vue'
- import { financeBookDetailSave, financeBookDetailQueryBySn, lastPayerAccountInfo } from '@/api/financeBook.js'
- import { dealerDetailBySn } from '@/api/dealer'
- export default {
- name: 'FcDetailModal',
- mixins: [commonMixin],
- components: { VSelect, Upload, dealerSubareaScopeList, fcDetailSxItem },
- props: {
- show: {
- type: [Boolean],
- default: false
- },
- bookSn: {
- type: String,
- default: ''
- },
- bookNo: {
- type: String,
- default: ''
- }
- },
- data () {
- return {
- opened: this.show,
- spinning: false,
- disabled: false,
- title: '新增收款明细',
- confirmLoading: false,
- bookDetailSn: '',
- formItemLayout: {
- labelCol: { span: 6 },
- wrapperCol: { span: 16 }
- },
- form: {
- payerType: 'DEALER',
- payerAccountType: 'PUBLIC',
- dealerSn: undefined,
- payerName: '',
- payerAccountInfo: '',
- licenseName: '',
- receiptDate: moment(),
- dealerCode: '',
- orderAmount: '',
- receiptAmount: '',
- useCreditFlag: false,
- detailItemUseList: [],
- payCreditFlag: false,
- detailItemPayList: [],
- balanceAmount: '',
- nextMonthAmount: '',
- bankAccount: undefined,
- bankName: undefined,
- fullPaymentFlag: '1',
- explainInfo: ''
- },
- rules: {
- receiptDate: [ { required: true, message: '请选择收款日期', trigger: ['change', 'blur'] } ],
- payerType: [ { required: true, message: '请选择付款方类型', trigger: ['change', 'blur'] } ],
- dealerSn: [ { required: true, message: '请选择付款方', trigger: ['change', 'blur'] } ],
- payerName: [ { required: true, message: '请输入付款方名称', trigger: ['change', 'blur'] } ],
- payerAccountType: [ { required: true, message: '请选择付款账户类型', trigger: ['change', 'blur'] } ]
- },
- useTotalAmount: '',
- payTotalAmount: '',
- bankList: [
- {
- bankAccount: '张丽友',
- bankName: ['建设银行', '微信收款']
- },
- {
- bankAccount: '张丽添',
- bankName: ['农业银行']
- },
- {
- bankAccount: '东莞箭冠',
- bankName: ['东莞银行']
- },
- {
- bankAccount: '江西箭冠',
- bankName: ['九江银行']
- }
- ],
- bankNameList: []
- }
- },
- methods: {
- payerTypeChange (v) {
- this.$refs.ruleForm.clearValidate()
- // 重置数据
- this.form.dealerSn = ''
- this.form.dealerCode = ''
- this.form.licenseName = ''
- this.form.payerAccountType = 'PUBLIC'
- this.form.payerAccountInfo = ''
- this.form.payerName = ''
- },
- accountTypeChange (v) {
- this.$refs.ruleForm.clearValidate()
- // 已选经销商
- if (this.form.dealerSn) {
- // 查询账户信息
- this.getLastPayerAccount()
- } else {
- this.form.licenseName = ''
- this.form.payerAccountInfo = ''
- }
- },
- handleChange (v) {
- console.log(v)
- const row = this.bankList.find(item => item.bankAccount == v)
- this.bankNameList = row.bankName
- this.form.bankName = undefined
- },
- getLastPayerAccount () {
- this.spinning = true
- this.confirmLoading = true
- lastPayerAccountInfo({
- payerAccountType: this.form.payerAccountType,
- dealerSn: this.form.dealerSn
- }).then(res => {
- this.spinning = false
- this.confirmLoading = false
- this.form.payerAccountInfo = res.data || ''
- })
- },
- // 查询经销商信息
- getDealerDetail (sn) {
- dealerDetailBySn({ sn: sn }).then(res => {
- const val = { key: sn }
- val.row = res.data
- this.custChange(val)
- })
- },
- // 客户
- custChange (v) {
- console.log(v)
- if (v && v.key) {
- this.form.dealerSn = v.key
- this.form.payerName = v.row ? v.row.dealerName : ''
- this.form.dealerCode = v.row ? v.row.kdMidCustomerFnumber : ''
- this.form.licenseName = v.row ? v.row.licenseName : ''
- // 查询账户信息
- this.getLastPayerAccount()
- } else {
- this.form.dealerSn = ''
- this.form.payerName = ''
- this.form.dealerCode = ''
- this.form.licenseName = ''
- this.form.payerAccountInfo = ''
- }
- },
- updateUseAmount (v) {
- this.useTotalAmount = v
- },
- updatePayAmount (v) {
- this.payTotalAmount = v
- },
- // 保存
- handleSubmit (e) {
- e.preventDefault()
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- _this.salesSaveFun()
- } else {
- return false
- }
- })
- },
- validItem (data) {
- return data.find(item => !item.itemName || !item.itemAmount)
- },
- // 新建或编辑销售单
- salesSaveFun () {
- const _this = this
- const form = JSON.parse(JSON.stringify(_this.form))
- form.receiptDate = moment(form.receiptDate).format('YYYY-MM-DD')
- form.payCreditFlag = form.payCreditFlag ? 1 : 0
- form.useCreditFlag = form.useCreditFlag ? 1 : 0
- form.bookSn = this.bookSn
- form.bookNo = this.bookNo
- delete form.dealerCode
- if (form.payerType == 'DEPT') {
- delete form.payerAccountType
- }
- console.log(form)
- if ((form.useCreditFlag && form.detailItemUseList.length == 0) || this.validItem(form.detailItemUseList)) {
- this.$message.info('使用授信项目不能为空')
- return
- }
- if ((form.payCreditFlag && form.detailItemPayList.length == 0) || this.validItem(form.detailItemPayList)) {
- this.$message.info('授信还款项目不能为空')
- return
- }
- _this.spinning = true
- financeBookDetailSave(form).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$emit('refashData')
- _this.cancel()
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- },
- setDetail (data) {
- this.form = Object.assign(this.form, { payerTypeDictValue: data.payerTypeDictValue, payerType: data.payerType, dealerSn: data.dealerSn, payerName: data.payerName })
- this.$nextTick(() => {
- if(this.form.dealerSn){
- // this.$refs.settleClientName.getDetail(this.form.dealerSn)
- this.getDealerDetail(this.form.dealerSn)
- }
- })
- },
- // 详情
- getDetail (bookDetailSn) {
- this.spinning = true
- this.confirmLoading = true
- this.title = '编辑收款明细'
- this.bookDetailSn = bookDetailSn
- financeBookDetailQueryBySn({ bookDetailSn: this.bookDetailSn }).then(res => {
- if (res.status == 200) {
- const data = res.data
- this.form = Object.assign(this.form, data)
- this.form.receiptDate = moment(this.form.receiptDate).format('YYYY-MM-DD')
- this.form.payCreditFlag = this.form.payCreditFlag == 1
- this.form.useCreditFlag = this.form.useCreditFlag == 1
- // 回显客户
- // if (this.form.dealerSn && this.form.payerType == 'DEALER') {
- // this.$nextTick(() => {
- // this.$refs.settleClientName.getDetail(this.form.dealerSn)
- // })
- // }
- }
- this.spinning = false
- this.confirmLoading = false
- })
- },
- cancel () {
- this.opened = false
- this.$emit('cancel')
- this.pageInit()
- },
- pageInit () {
- this.$nextTick(() => {
- this.title = '新增收款明细'
- // if (this.$refs.settleClientName) {
- // this.$refs.settleClientName.resetForm()
- // }
- })
- this.bankNameList = []
- this.form = {
- payerType: 'DEALER',
- payerAccountType: 'PUBLIC',
- dealerSn: undefined,
- payerName: '',
- payerAccountInfo: '',
- licenseName: '',
- receiptDate: moment(),
- dealerCode: '',
- orderAmount: '',
- receiptAmount: '',
- useCreditFlag: false,
- detailItemUseList: [],
- payCreditFlag: false,
- detailItemPayList: [],
- balanceAmount: '',
- nextMonthAmount: '',
- bankAccount: undefined,
- bankName: undefined,
- fullPaymentFlag: '1',
- explainInfo: ''
- }
- this.$refs.ruleForm.resetFields()
- }
- },
- watch: {
- show (newValue, oldValue) {
- this.opened = newValue
- if (!newValue) {
- this.pageInit()
- }
- }
- }
- }
- </script>
|