Browse Source

销售开票

intex
yufei_wang 1 week ago
parent
commit
f95465e509
  1. 250
      src/views/wms/deliversettlementManage/customerSaleInvoiceRequestMain/CustomerSaleInvoiceBasicForm.vue
  2. 255
      src/views/wms/deliversettlementManage/customerSaleInvoiceRequestMain/index.vue

250
src/views/wms/deliversettlementManage/customerSaleInvoiceRequestMain/CustomerSaleInvoiceBasicForm.vue

@ -0,0 +1,250 @@
<template>
<!-- 表单弹窗添加/修改 -->
<BasicForm
ref="formRef"
:isShowButton="false"
:isShowReduceButton="false"
:isShowReduceButtonSelection="false"
:rules="CustomerSaleInvoiceMainRules"
:formAllSchemas="CustomerSaleInvoiceMain.allSchemas"
:tableAllSchemas="CustomerSaleInvoiceDetail.allSchemas"
:tableFormRules="CustomerSaleInvoiceDetailRules"
:tableData="tableData"
:apiUpdate="CustomerSaleInvoiceMainApi.updateCustomerSaleInvoiceMain"
:apiCreate="CustomerSaleInvoiceMainApi.createCustomerSaleInvoiceMain"
:isBusiness="true"
@handleAddTable="handleAddTable"
@handleDeleteTable="handleDeleteTable"
@tableSelectionDelete="tableSelectionDelete"
@searchTableSuccess="searchTableSuccess"
@submitForm="submitForm"
@inputNumberChange="inputNumberChange"
@onChange="onChange"
:sumFormDataByTableCustom="
(formRef, formModel, tableData) => {
const { taxRate = 0 } = formModel
// 1 mainBeforeTaxAmount :
let mainBeforeTaxAmount = tableData.reduce(
(prev, item) =>
prev + Number(item['beforeTaxAmount']),
0
)
// 2. mainTaxAmount = */100
let mainTaxAmount = Number(Number(mainBeforeTaxAmount*taxRate*0.01).toFixed(2))
const sumObject = {
//
beforeTaxAmount:mainBeforeTaxAmount,
//
taxAmount:mainTaxAmount,
// mainAdTaxAmount =+
adTaxAmount:mainBeforeTaxAmount+mainTaxAmount
}
formRef.value.setValues(sumObject)
}
"
/>
</template>
<script setup lang="ts">
import { CustomerSaleInvoiceMain,CustomerSaleInvoiceMainRules,CustomerSaleInvoiceDetailRules,CustomerSaleInvoiceDetail} from './customerSaleInvoiceRequestMain.data'
import * as CustomerSaleInvoiceMainApi from '@/api/wms/customerSaleInvoiceMain'
import * as CustomerStatementDetailApi from '@/api/wms/customerStatementDetail'
//
const emit = defineEmits([
'buttonBaseClick','getList'
])
const message = useMessage() //
const { t } = useI18n() //
/** 添加/修改操作 */
const formRef = ref()
const openForm =async (type: string, row?: any) => {
CustomerSaleInvoiceMain.allSchemas.formSchema.forEach((item) => {
if(item.field == 'customerStatementNumber'){
item.componentProps.disabled = type=='update'
item.componentProps.isSearchList = type!='update'
item.componentProps.enterSearch = type!='update'
}
})
tableData.value = [] //
formRef.value.open(type, row)
}
const onChange = (field, cur, formRef)=>{
console.log('onChange',field, cur, formRef)
if(field == 'taxRate'){
// taxAmount */100,2
tableData.value.forEach(item=>{
item['taxAmount'] = (item['beforeTaxAmount'] * cur)/100 //
})
}
}
const inputNumberChange = (field, index, row, val) => {
console.log('inputNumberChange',field, index, row, val)
// = +
row['sumPrice'] = row['price'] + row['allocationPrice']
// = +,2
row['afterTaxAmount'] = row['beforeTaxAmount'] + row['taxAmount']
// /-
row['allocationPrice'] = row['beforeTaxAmount']/row['qty'] - row['price']
}
const flag = ref(false)
//
const submitForm = async (formType, submitData) => {
let data = {...submitData}
if(data.masterId){
data.id = data.masterId
}
data.subList = tableData.value //
data.subList.forEach(item=>{
item.toWarehouseCode = data.toWarehouseCode
item.toLocationCode = data.toLocationCode
})
//
let isExist = false
tableData.value.forEach(item => {
let rs = tableData.value.filter(filterItem => (filterItem.itemCode == item.itemCode))
if(rs.length > 1) isExist = true
})
if (isExist) {
formRef.value.formLoading = false
return message.warning('物料代码重复')
}
data.subList.forEach(obj => {
if(obj.qty == 0){
message.error(`数量不能为0!`)
flag.value = true
return;
}
})
if(flag.value){
return
}
var isHave =CustomerSaleInvoiceMain.allSchemas.formSchema.some(function (item) {
return item.field === 'beginTime' || item.field === 'endTime';
});
if(isHave){
if(data.beginTime && data.endTime && data.beginTime >=data.expireTime){
message.error('结束时间要大于开始时间')
return;
}
}
console.log(data.beginTime)
if(!data.beginTime)data.beginTime = null;
if(!data.planDate)data.planDate = null;
if(!data.endTime)data.endTime = null;
formRef.value.formLoading = true
try {
if (formType === 'create') {
await CustomerSaleInvoiceMainApi.createCustomerSaleInvoiceMain(data)
message.success(t('common.createSuccess'))
} else {
await CustomerSaleInvoiceMainApi.updateCustomerSaleInvoiceMain(data)
message.success(t('common.updateSuccess'))
}
formRef.value.dialogVisible = false
//
if (formType === 'create') {
emit('getList', 'refresh')
}else{
emit('buttonBaseClick', 'refresh')
}
} finally {
formRef.value.formLoading = false
}
}
//
const searchTableSuccess = (formField, searchField, val, formRef, type, row ) => {
nextTick(async () => {
if (type == 'tableForm') {
if(formField == 'itemCode') {
let itemCodes = val.filter(item=>tableData.value.find(item1=>item1['itemCode']==item['itemCode']))
if(itemCodes.length>0){
itemCodes = itemCodes.map(item=>(item['itemCode']))
message.warning(`物料${itemCodes.join(',')}已经存在`)
}
val = val.filter(item=>!tableData.value.find(item1=>item1['itemCode']==item['itemCode']))
if(val.length==0) return
val.forEach(item=>{
const newRow = JSON.parse(JSON.stringify({...tableFormKeys,...item}))
row[formField] = item[searchField]
newRow['uom'] = item['customerUom']
newRow['id'] = item['id']
tableData.value.push(newRow)
})
}else{
row[formField] = val[0][searchField]
}
// if(formField == 'itemCode') {
// row['uom'] = val[0]['customerUom']
// }
//
} else {
const setV = {}
if(formField == 'customerStatementNumber') {
//
setV['customerCode'] = val[0]['customerCode']
setV['customerName'] = val[0]['customerName']
CustomerStatementDetailApi.getCustomerStatementDetailPage({
pageNo:1,
pageNSize: 100,
masterId:val[0]['id']
}).then((res) => {
console.log(55,res)
tableData.value = res.list && res.list.length > 0 ?res.list : []
tableData.value.forEach(item=>{
item['sumPrice'] = item['price'] + item['allocationPrice']
// *2
item['beforeTaxAmount'] = item['sumPrice']*item['qty']
// +,2
item['afterTaxAmount'] = item['beforeTaxAmount'] + item['taxAmount'] //
// taxAmount */100,2
item['taxAmount'] = (item['beforeTaxAmount'] * formRef.formModel['taxRate'])/100 //
})
})
// tableData.value = []
}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
}
})
}
const tableData = ref([])
const tableFormKeys = {}
CustomerSaleInvoiceDetail.allSchemas.tableFormColumns.forEach(item => {
tableFormKeys[item.field] = item.default ? item.default : ''
})
//
const handleAddTable = () => {
tableData.value.push(JSON.parse(JSON.stringify(tableFormKeys)))
}
//
const handleDeleteTable = (item, index) => {
let itemIndex = tableData.value.indexOf(item)
if(itemIndex>-1){
tableData.value.splice(itemIndex, 1)
}
}
const tableSelectionDelete = (selection) => {
tableData.value = tableData.value.filter(item => !selection.includes(item))
}
defineExpose({openForm})
</script>
<style lang="scss" scoped></style>

255
src/views/wms/deliversettlementManage/customerSaleInvoiceRequestMain/index.vue

@ -39,49 +39,7 @@
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<BasicForm
ref="formRef"
:isShowButton="false"
:isShowReduceButton="false"
:isShowReduceButtonSelection="false"
:rules="CustomerSaleInvoiceMainRules"
:formAllSchemas="CustomerSaleInvoiceMain.allSchemas"
:tableAllSchemas="CustomerSaleInvoiceDetail.allSchemas"
:tableFormRules="CustomerSaleInvoiceDetailRules"
:tableData="tableData"
:apiUpdate="CustomerSaleInvoiceMainApi.updateCustomerSaleInvoiceMain"
:apiCreate="CustomerSaleInvoiceMainApi.createCustomerSaleInvoiceMain"
:isBusiness="true"
@handleAddTable="handleAddTable"
@handleDeleteTable="handleDeleteTable"
@tableSelectionDelete="tableSelectionDelete"
@searchTableSuccess="searchTableSuccess"
@submitForm="submitForm"
@inputNumberChange="inputNumberChange"
@onChange="onChange"
:sumFormDataByTableCustom="
(formRef, formModel, tableData) => {
const { taxRate = 0 } = formModel
// 1 mainBeforeTaxAmount :
let mainBeforeTaxAmount = tableData.reduce(
(prev, item) =>
prev + Number(item['beforeTaxAmount']),
0
)
// 2. mainTaxAmount = */100
let mainTaxAmount = Number(Number(mainBeforeTaxAmount*taxRate*0.01).toFixed(2))
const sumObject = {
//
beforeTaxAmount:mainBeforeTaxAmount,
//
taxAmount:mainTaxAmount,
// mainAdTaxAmount =+
adTaxAmount:mainBeforeTaxAmount+mainTaxAmount
}
formRef.value.setValues(sumObject)
}
"
/>
<CustomerSaleInvoiceBasicForm ref="formRef" @getList="getList" @buttonBaseClick="buttonBaseClick"/>
<!-- 详情 -->
<Detail
@ -108,6 +66,7 @@
<script setup lang="ts">
import download from '@/utils/download'
import CustomerSaleInvoiceBasicForm from './CustomerSaleInvoiceBasicForm.vue'
import { CustomerSaleInvoiceMain,CustomerSaleInvoiceMainRules,CustomerSaleInvoiceDetailRules,CustomerSaleInvoiceDetail} from './customerSaleInvoiceRequestMain.data'
import * as CustomerSaleInvoiceMainApi from '@/api/wms/customerSaleInvoiceMain'
import * as CustomerSaleInvoiceDetailApi from '@/api/wms/customerSaleInvoiceDetail'
@ -143,68 +102,7 @@ const updataTableColumns = (val) => {
tableColumns.value = val
}
//
const searchTableSuccess = (formField, searchField, val, formRef, type, row ) => {
nextTick(async () => {
if (type == 'tableForm') {
if(formField == 'itemCode') {
let itemCodes = val.filter(item=>tableData.value.find(item1=>item1['itemCode']==item['itemCode']))
if(itemCodes.length>0){
itemCodes = itemCodes.map(item=>(item['itemCode']))
message.warning(`物料${itemCodes.join(',')}已经存在`)
}
val = val.filter(item=>!tableData.value.find(item1=>item1['itemCode']==item['itemCode']))
if(val.length==0) return
val.forEach(item=>{
const newRow = JSON.parse(JSON.stringify({...tableFormKeys,...item}))
row[formField] = item[searchField]
newRow['uom'] = item['customerUom']
newRow['id'] = item['id']
tableData.value.push(newRow)
})
}else{
row[formField] = val[0][searchField]
}
// if(formField == 'itemCode') {
// row['uom'] = val[0]['customerUom']
// }
//
} else {
const setV = {}
if(formField == 'customerStatementNumber') {
//
setV['customerCode'] = val[0]['customerCode']
setV['customerName'] = val[0]['customerName']
CustomerStatementDetailApi.getCustomerStatementDetailPage({
pageNo:1,
pageNSize: 100,
masterId:val[0]['id']
}).then((res) => {
console.log(55,res)
tableData.value = res.list && res.list.length > 0 ?res.list : []
tableData.value.forEach(item=>{
item['sumPrice'] = item['price'] + item['allocationPrice']
// *2
item['beforeTaxAmount'] = item['sumPrice']*item['qty']
// +,2
item['afterTaxAmount'] = item['beforeTaxAmount'] + item['taxAmount'] //
// taxAmount */100,2
item['taxAmount'] = (item['beforeTaxAmount'] * formRef.formModel['taxRate'])/100 //
})
})
// tableData.value = []
}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
}
})
}
//
const searchTableSuccessDetail = (formField, searchField, val, formRef ) => {
nextTick(() => {
@ -282,13 +180,7 @@ const butttondata = (row,$index) => {
return []
}
return [
// defaultButtons.mainListPlanOpeBtn({hide:isShowMainButton(row,['5']),hasPermi:`wms:customer-sale-invoice-request-main:open`}), //
// defaultButtons.mainListPlanCloBtn({hide:isShowMainButton(row,['1','2','3','4']),hasPermi:`wms:customer-sale-invoice-request-main:close`}), //
// defaultButtons.mainListPlanSubBtn({hide:isShowMainButton(row,['1']),hasPermi:`wms:customer-sale-invoice-request-main:submit`}), //
// defaultButtons.mainListPlanTurBtn({hide:isShowMainButton(row,['2']),hasPermi:`wms:customer-sale-invoice-request-main:reject`}), //
// defaultButtons.mainListPlanAppBtn({hide:isShowMainButton(row,['2']),hasPermi:`wms:customer-sale-invoice-request-main:agree`}), //
defaultButtons.mainListPlanPubBtn({hide:isShowMainButton(row,['0']),hasPermi:`wms:customer-sale-invoice-request-main:publish`}), //
// defaultButtons.mainListPlanResBtn({hide:isShowMainButton(row,['4']),hasPermi:`wms:customer-sale-invoice-request-main:resetting`}), //
defaultButtons.mainListEditBtn({hide:isShowMainButton(row,['0']),hasPermi:`wms:customer-sale-invoice-request-main:update`}), //
defaultButtons.mainListCancelBtn({hide: isShowMainButton(row,['0']),hasPermi:'wms:customer-sale-invoice-request-main:cancel'}), //
@ -329,16 +221,7 @@ const buttonTableClick = async (val, row) => {
/** 添加/修改操作 */
const formRef = ref()
const openForm =async (type: string, row?: any) => {
CustomerSaleInvoiceMain.allSchemas.formSchema.forEach((item) => {
if(item.field == 'customerStatementNumber'){
item.componentProps.disabled = type=='update'
item.componentProps.isSearchList = type!='update'
item.componentProps.enterSearch = type!='update'
}
})
tableData.value = [] //
formRef.value.open(type, row)
formRef.value.openForm(type,row)
}
/** 详情操作 */
@ -347,20 +230,7 @@ const openDetail = (row: any, titleName: any, titleValue: any) => {
detailRef.value.openDetail(row, titleName, titleValue,'planDeliverMain')
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
tableObject.loading = true
//
await CustomerSaleInvoiceMainApi.deleteCustomerSaleInvoiceMain(id)
tableObject.loading = false
message.success(t('common.delSuccess'))
//
buttonBaseClick('refresh',null)
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
@ -378,123 +248,6 @@ const handleExport = async () => {
}
}
/**
* tableForm方法
*/
const tableFormKeys = {}
CustomerSaleInvoiceDetail.allSchemas.tableFormColumns.forEach(item => {
tableFormKeys[item.field] = item.default ? item.default : ''
})
const tableData = ref([])
//
const handleAddTable = () => {
tableData.value.push(JSON.parse(JSON.stringify(tableFormKeys)))
}
//
const handleDeleteTable = (item, index) => {
let itemIndex = tableData.value.indexOf(item)
if(itemIndex>-1){
tableData.value.splice(itemIndex, 1)
}
}
const tableSelectionDelete = (selection) => {
tableData.value = tableData.value.filter(item => !selection.includes(item))
}
const onChange = (field, cur, formRef)=>{
console.log('onChange',field, cur, formRef)
if(field == 'taxRate'){
// taxAmount */100,2
tableData.value.forEach(item=>{
item['taxAmount'] = (item['beforeTaxAmount'] * cur)/100 //
})
}
}
const inputNumberChange = (field, index, row, val) => {
console.log('inputNumberChange',field, index, row, val)
// = +
row['sumPrice'] = row['price'] + row['allocationPrice']
// = +,2
row['afterTaxAmount'] = row['beforeTaxAmount'] + row['taxAmount']
// /-
row['allocationPrice'] = row['beforeTaxAmount']/row['qty'] - row['price']
}
//true0
const flag = ref(false)
//
const submitForm = async (formType, submitData) => {
let data = {...submitData}
if(data.masterId){
data.id = data.masterId
}
data.subList = tableData.value //
data.subList.forEach(item=>{
item.toWarehouseCode = data.toWarehouseCode
item.toLocationCode = data.toLocationCode
})
data.businessType = businessType.value
//
let isExist = false
tableData.value.forEach(item => {
let rs = tableData.value.filter(filterItem => (filterItem.itemCode == item.itemCode))
if(rs.length > 1) isExist = true
})
if (isExist) {
formRef.value.formLoading = false
return message.warning('物料代码重复')
}
data.subList.forEach(obj => {
if(obj.qty == 0){
message.error(`数量不能为0!`)
flag.value = true
return;
}
})
if(flag.value){
return
}
var isHave =CustomerSaleInvoiceMain.allSchemas.formSchema.some(function (item) {
return item.field === 'beginTime' || item.field === 'endTime';
});
if(isHave){
if(data.beginTime && data.endTime && data.beginTime >=data.expireTime){
message.error('结束时间要大于开始时间')
return;
}
}
console.log(data.beginTime)
if(!data.beginTime)data.beginTime = null;
if(!data.planDate)data.planDate = null;
if(!data.endTime)data.endTime = null;
formRef.value.formLoading = true
try {
if (formType === 'create') {
await CustomerSaleInvoiceMainApi.createCustomerSaleInvoiceMain(data)
message.success(t('common.createSuccess'))
} else {
await CustomerSaleInvoiceMainApi.updateCustomerSaleInvoiceMain(data)
message.success(t('common.updateSuccess'))
}
formRef.value.dialogVisible = false
//
if (formType === 'create') {
getList()
}else{
buttonBaseClick('refresh',null)
}
} finally {
formRef.value.formLoading = false
}
}
/** 导入 */
const importFormRef = ref()

Loading…
Cancel
Save