切换单据中的客户时候,自动变换商品单价

This commit is contained in:
季圣华 2023-06-11 23:50:32 +08:00
parent 4b280f60cf
commit dc340912d4
5 changed files with 87 additions and 9 deletions

View File

@ -1,9 +1,19 @@
import { FormTypes, getListData } from '@/utils/JEditableTableUtil'
import {findBySelectSup,findBySelectCus,findBySelectRetail,getMaterialByBarCode,findStockByDepotAndBarCode,getAccount,
getPersonByNumType, getBatchNumberList, getCurrentSystemConfig, getPlatformConfigByKey} from '@/api/api'
import { getAction,putAction } from '@/api/manage'
import { getMpListShort, getNowFormatDateTime, getCheckFlag } from "@/utils/util"
import { USER_INFO } from "@/store/mutation-types"
import {
findBySelectCus,
findBySelectRetail,
findBySelectSup,
findStockByDepotAndBarCode,
getAccount,
getBatchNumberList,
getCurrentSystemConfig,
getMaterialByBarCode,
getPersonByNumType,
getPlatformConfigByKey
} from '@/api/api'
import { getAction } from '@/api/manage'
import { getCheckFlag, getMpListShort, getNowFormatDateTime } from '@/utils/util'
import { USER_INFO } from '@/store/mutation-types'
import Vue from 'vue'
export const BillModalMixin = {
@ -693,6 +703,74 @@ export const BillModalMixin = {
this.form.setFieldsValue({'debt':debtNew})
});
},
//切换客户信息改变商品单价
handleOrganChange(value) {
let organId = value
this.getAllTable().then(tables => {
return getListData(this.form, tables)
}).then(allValues => {
let detailArr = allValues.tablesValue[0].values
let barCodeStr = ''
for(let detail of detailArr){
if(detail.barCode) {
barCodeStr += detail.barCode + ','
}
}
let param = {
barCode: barCodeStr,
organId: organId,
mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
prefixNo: this.prefixNo
}
getMaterialByBarCode(param).then((res) => {
if (res && res.code === 200) {
let allLastMoney = 0
let allTaxLastMoney = 0
//获取单据明细列表信息
let detailArr = allValues.tablesValue[0].values
//构造新的列表数组用于存放单据明细信息
let newDetailArr = []
for(let detail of detailArr){
if(detail.barCode) {
//如果条码重复就在给原来的数量加1
let mList = res.data
for (let i = 0; i < mList.length; i++) {
if(detail.barCode === mList[i].mBarCode) {
//由于改变了商品单价需要同时更新相关金额和价税合计
let taxRate = detail.taxRate-0 //税率
detail.unitPrice = mList[i].billPrice-0 //单价
detail.allPrice = (detail.unitPrice*detail.operNumber).toFixed(2)-0
detail.taxMoney = ((taxRate*0.01)*detail.allPrice).toFixed(2)-0
detail.taxLastMoney = (detail.allPrice + detail.taxMoney).toFixed(2)-0
}
}
newDetailArr.push(detail)
}
}
this.materialTable.dataSource = newDetailArr
//更新优惠后金额本次付款等信息
for(let newDetail of newDetailArr){
allLastMoney = allLastMoney + (newDetail.allPrice-0)
allTaxLastMoney = allTaxLastMoney + (newDetail.taxLastMoney-0)
}
let discount = this.form.getFieldValue('discount')-0
let otherMoney = this.form.getFieldValue('otherMoney')?this.form.getFieldValue('otherMoney')-0:0
let deposit = this.form.getFieldValue('deposit')
let discountMoney = (discount*0.01*allTaxLastMoney).toFixed(2)-0
let discountLastMoney = (allTaxLastMoney-discountMoney).toFixed(2)-0
let changeAmountNew = (discountLastMoney + otherMoney).toFixed(2)-0
if(deposit) {
changeAmountNew = (changeAmountNew - deposit).toFixed(2)-0
}
this.$nextTick(() => {
changeAmountNew = this.prefixNo === 'XSDD'?0:changeAmountNew
this.form.setFieldsValue({'discount':discount,'discountMoney':discountMoney,'discountLastMoney':discountLastMoney,
'changeAmount':changeAmountNew,'debt':0})
});
}
})
})
},
scanEnter() {
this.scanStatus = false
this.$nextTick(() => {

View File

@ -22,7 +22,7 @@
<a-col :lg="6" :md="12" :sm="24">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="客户">
<a-select placeholder="选择客户" v-decorator="[ 'organId' ]"
:dropdownMatchSelectWidth="false" showSearch optionFilterProp="children">
:dropdownMatchSelectWidth="false" showSearch optionFilterProp="children" @change="handleOrganChange">
<div slot="dropdownRender" slot-scope="menu">
<v-nodes :vnodes="menu" />
<a-divider style="margin: 4px 0;" />

View File

@ -22,7 +22,7 @@
<a-col :lg="6" :md="12" :sm="24">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="客户">
<a-select placeholder="选择客户" v-decorator="[ 'organId', validatorRules.organId ]" :disabled="!rowCanEdit"
:dropdownMatchSelectWidth="false" showSearch optionFilterProp="children">
:dropdownMatchSelectWidth="false" showSearch optionFilterProp="children" @change="handleOrganChange">
<div slot="dropdownRender" slot-scope="menu">
<v-nodes :vnodes="menu" />
<a-divider style="margin: 4px 0;" />

View File

@ -27,7 +27,7 @@
data-intro="客户必须选择,如果发现需要选择的客户尚未录入,可以在下拉框中点击新增客户进行录入。
特别注意客户如果录入之后在下拉框中不显示请检查是否给当前用户分配对应的客户权限">
<a-select placeholder="选择客户" v-decorator="[ 'organId', validatorRules.organId ]"
:dropdownMatchSelectWidth="false" showSearch optionFilterProp="children">
:dropdownMatchSelectWidth="false" showSearch optionFilterProp="children" @change="handleOrganChange">
<div slot="dropdownRender" slot-scope="menu">
<v-nodes :vnodes="menu" />
<a-divider style="margin: 4px 0;" />

View File

@ -27,7 +27,7 @@
data-intro="客户必须选择,如果发现需要选择的客户尚未录入,可以在下拉框中点击新增客户进行录入。
特别注意客户如果录入之后在下拉框中不显示请检查是否给当前用户分配对应的客户权限">
<a-select placeholder="选择客户" v-decorator="[ 'organId', validatorRules.organId ]" :disabled="!rowCanEdit"
:dropdownMatchSelectWidth="false" showSearch optionFilterProp="children">
:dropdownMatchSelectWidth="false" showSearch optionFilterProp="children" @change="handleOrganChange">
<div slot="dropdownRender" slot-scope="menu">
<v-nodes :vnodes="menu" />
<a-divider style="margin: 4px 0;" />