Browse Source

销售开票新增

intex_online20241111
zhang_li 1 month ago
parent
commit
ef8240f531
  1. 171
      src/views/wms/deliversettlementManage/customerSaleInvoiceMain/customerSaleInvoiceMain.data.ts
  2. 439
      src/views/wms/deliversettlementManage/customerSaleInvoiceMain/index.vue

171
src/views/wms/deliversettlementManage/customerSaleInvoiceMain/customerSaleInvoiceMain.data.ts

@ -1,5 +1,9 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import {
CustomerStatementMain,
} from '../../deliversettlementManage/moldAllocation/customerStatement/customerStatementMain.data'
import * as CustomerStatementMainApi from '@/api/wms/customerStatementMain'
// 表单校验 // 表单校验
export const CustomerSaleInvoiceMainRules = reactive({ export const CustomerSaleInvoiceMainRules = reactive({
@ -15,49 +19,100 @@ export const CustomerSaleInvoiceMain = useCrudSchemas(reactive<CrudSchema[]>([
field: 'number', field: 'number',
sort: 'custom', sort: 'custom',
isSearch: true, isSearch: true,
} ,{ isForm: false,
},
{
label: '状态', label: '状态',
field: 'status', field: 'status',
sort: 'custom', sort: 'custom',
isSearch: true, isSearch: true,
isForm:false,
// 0:新增1:已发布2已作废 // 0:新增1:已发布2已作废
}, },
{ {
label: '客户对账单单据号', label: '客户对账单',
field: 'customerStatementNumber', field: 'customerStatementNumber',
sort: 'custom', sort: 'custom',
isSearch: true, isSearch: true,
form: {
componentProps: {
enterSearch: true,
isSearchList: true, // 开启查询弹窗
searchListPlaceholder: '请选择客户对账单', // 输入框占位文本
searchField: 'number', // 查询弹窗赋值字段
searchTitle: '客户对账单信息', // 查询弹窗标题
searchAllSchemas: CustomerStatementMain.allSchemas, // 查询弹窗所需类
searchPage: CustomerStatementMainApi.getCustomerStatementMainPage, // 查询弹窗所需分页方法
searchCondition: [{
key: 'available',
value: 'TRUE',
isMainValue: false
}]
}
}
}, },
{ {
label: '客户代码', label: '客户代码',
field: 'customer', field: 'customer',
sort: 'custom', sort: 'custom',
isSearch: true, isSearch: true,
form: {
componentProps: {
disabled:true
}
}
}, },
{ {
label: '客户名称', label: '客户名称',
field: 'customerName', field: 'customerName',
sort: 'custom', sort: 'custom',
form: {
componentProps: {
disabled: true
}
}
}, },
{ {
label: '未税金额', label: '未税金额',
field: 'beforeTaxAmount', field: 'beforeTaxAmount',
sort: 'custom', sort: 'custom',
form: {
componentProps: {
disabled: true
}
}
}, },
{ {
label: '税率', label: '税率(%)',
field: 'taxRate', field: 'taxRate',
dictType: DICT_TYPE.TAX_RATE_DICT,
dictClass: 'string',
sortTableDefault: 3,
isTable: true,
sort: 'custom', sort: 'custom',
table: {
width: 150
},
}, },
{ {
label: '税额', label: '税额',
field: 'taxAmount', field: 'taxAmount',
sort: 'custom', sort: 'custom',
form: {
componentProps: {
disabled: true
}
}
}, },
{ {
label: '价税合计金额', label: '价税合计金额',
field: 'adTaxAmount', field: 'adTaxAmount',
sort: 'custom', sort: 'custom',
form: {
componentProps: {
disabled: true
}
}
}, },
{ {
label: '金税票号', label: '金税票号',
@ -95,7 +150,8 @@ export const CustomerSaleInvoiceMain = useCrudSchemas(reactive<CrudSchema[]>([
label: '是否可用默认TRUE', label: '是否可用默认TRUE',
field: 'available', field: 'available',
sort: 'custom', sort: 'custom',
isTable:false isTable: false,
isForm:false
}, },
{ {
label: '创建时间', label: '创建时间',
@ -122,3 +178,110 @@ export const CustomerSaleInvoiceMain = useCrudSchemas(reactive<CrudSchema[]>([
} }
} }
])) ]))
// 表单校验
export const CustomerSaleInvoiceDetailRules = reactive({
beforeTaxAmount: [required],
taxRate: [required],
taxAmount: [required],
adTaxAmount: [required],
})
export const CustomerSaleInvoiceDetail = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '品番',
field: 'number',
sort: 'custom',
isSearch: true,
isForm: false,
tableForm: {
disabled:true
}
},
{
label: '品号',
field: 'articleNumber',
sort: 'custom',
isSearch: true,
isForm: false,
// 0:新增1:已发布2已作废
},
{
label: '数量',
field: 'qty',
sort: 'custom',
isSearch: true,
form: {
componentProps: {
enterSearch: true,
isSearchList: true, // 开启查询弹窗
searchListPlaceholder: '请选择客户对账单', // 输入框占位文本
searchField: '', // 查询弹窗赋值字段
searchTitle: '客户对账单信息', // 查询弹窗标题
searchAllSchemas: CustomerStatementMain.allSchemas, // 查询弹窗所需类
searchPage: CustomerStatementMainApi.getCustomerStatementMainPage, // 查询弹窗所需分页方法
searchCondition: [{
key: 'available',
value: 'TRUE',
isMainValue: false
}]
}
}
},
{
label: '销售单价',
field: 'price',
sort: 'custom',
isSearch: true,
form: {
componentProps: {
disabled: true
}
}
},
{
label: '模具分摊单价',
field: 'allocationPrice',
sort: 'custom',
form: {
componentProps: {
disabled: true
}
}
},
{
label: '合计单价',
field: 'beforeTaxAmount',
sort: 'custom',
form: {
componentProps: {
disabled: true
}
}
},
{
label: '未税金额',
field: 'taxRate',
sort: 'custom',
},
{
label: '税额',
field: 'taxAmount',
sort: 'custom',
form: {
componentProps: {
disabled: true
}
}
},
{
label: '含税金额',
field: 'adTaxAmount',
sort: 'custom',
form: {
componentProps: {
disabled: true
}
}
},
]))

439
src/views/wms/deliversettlementManage/customerSaleInvoiceMain/index.vue

@ -1,7 +1,7 @@
<template> <template>
<ContentWrap> <ContentWrap>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<Search :schema="CustomerSaleInvoiceMain.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> <Search :schema="[...CustomerSaleInvoiceMain.allSchemas.searchSchema,...CustomerSaleInvoiceDetail.allSchemas.searchSchema]" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap> </ContentWrap>
<!-- 列表头部 --> <!-- 列表头部 -->
@ -12,11 +12,12 @@
@updataTableColumns="updataTableColumns" @updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick" @searchFormClick="searchFormClick"
:allSchemas="CustomerSaleInvoiceMain.allSchemas" :allSchemas="CustomerSaleInvoiceMain.allSchemas"
:detailAllSchemas="CustomerSaleInvoiceDetail.allSchemas"
/> />
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<Table <Table v-clientTable
:columns="tableColumns" :columns="tableColumns"
:data="tableObject.tableList" :data="tableObject.tableList"
:loading="tableObject.loading" :loading="tableObject.loading"
@ -27,46 +28,72 @@
v-model:currentPage="tableObject.currentPage" v-model:currentPage="tableObject.currentPage"
v-model:sort="tableObject.sort" v-model:sort="tableObject.sort"
> >
<template #code="{row}"> <template #number="{row}">
<el-button type="primary" link @click="openDetail(row, '代码', row.code)"> <el-button type="primary" link @click="openDetail(row, '单据号', row.number)">
<span>{{ row.code }}</span> <span>{{ row.number }}</span>
</el-button> </el-button>
</template> </template>
<template #action="{ row }"> <template #action="{ row,$index }">
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" /> <ButtonBase :Butttondata="butttondata(row,$index)" @button-base-click="buttonTableClick($event,row)" />
</template> </template>
</Table> </Table>
</ContentWrap> </ContentWrap>
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<BasicForm <BasicForm
ref="basicFormRef" ref="formRef"
@success="formsSuccess" :isOpenSearchTable="true"
fieldTableColumn="itemCode"
:rules="CustomerSaleInvoiceMainRules" :rules="CustomerSaleInvoiceMainRules"
:formAllSchemas="CustomerSaleInvoiceMain.allSchemas" :formAllSchemas="CustomerSaleInvoiceMain.allSchemas"
:tableAllSchemas="CustomerSaleInvoiceDetail.allSchemas"
:tableFormRules="CustomerSaleInvoiceDetailRules"
:tableData="tableData"
:apiUpdate="CustomerSaleInvoiceMainApi.updateCustomerSaleInvoiceMain" :apiUpdate="CustomerSaleInvoiceMainApi.updateCustomerSaleInvoiceMain"
:apiCreate="CustomerSaleInvoiceMainApi.createCustomerSaleInvoiceMain" :apiCreate="CustomerSaleInvoiceMainApi.createCustomerSaleInvoiceMain"
:isBusiness="true"
@handleAddTable="handleAddTable"
@handleDeleteTable="handleDeleteTable"
:isShowReduceButtonSelection="true"
@tableSelectionDelete="tableSelectionDelete"
@searchTableSuccess="searchTableSuccess" @searchTableSuccess="searchTableSuccess"
:isBusiness="false" @submitForm="submitForm"
/> />
<!-- 详情 --> <!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="CustomerSaleInvoiceMain.allSchemas" /> <Detail
ref="detailRef"
:isBasic="false"
:allSchemas="CustomerSaleInvoiceMain.allSchemas"
:detailAllSchemas="CustomerSaleInvoiceDetail.allSchemas"
:detailAllSchemasRules="CustomerSaleInvoiceDetailRules"
:apiCreate="CustomerSaleInvoiceDetailApi.createCustomerSaleInvoiceDetail"
:apiUpdate="CustomerSaleInvoiceDetailApi.updateCustomerSaleInvoiceDetail"
:apiPage="CustomerSaleInvoiceDetailApi.getCustomerSaleInvoiceDetailPage"
:apiDelete="CustomerSaleInvoiceDetailApi.deleteCustomerSaleInvoiceDetail"
:Echo="Echo"
@searchTableSuccessDetail="searchTableSuccessDetail"
/>
<!-- 导入 --> <!-- 导入 -->
<ImportForm ref="importFormRef" url="/wms/customer-sale-invoice-main/import" :importTemplateData="importTemplateData" @success="importSuccess" /> <ImportForm ref="importFormRef" url="/wms/deliver-plan-main/import" :importTemplateData="importTemplateData"
@success="importSuccess" :updateIsDisable="true" :coverIsDisable="true" :mode="2" :extend= "businessType"/>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import download from '@/utils/download' import download from '@/utils/download'
import { CustomerSaleInvoiceMain,CustomerSaleInvoiceMainRules } from './customerSaleInvoiceMain.data' import { CustomerSaleInvoiceMain,CustomerSaleInvoiceMainRules,CustomerSaleInvoiceDetailRules,CustomerSaleInvoiceDetail} from './customerSaleInvoiceMain.data'
import * as CustomerSaleInvoiceMainApi from '@/api/wms/customerSaleInvoiceMain' import * as CustomerSaleInvoiceMainApi from '@/api/wms/customerSaleInvoiceMain'
import * as CustomerSaleInvoiceDetailApi from '@/api/wms/customerSaleInvoiceDetail'
import * as CustomerStatementDetailApi from '@/api/wms/customerStatementDetail'
import * as defaultButtons from '@/utils/disposition/defaultButtons' import * as defaultButtons from '@/utils/disposition/defaultButtons'
import TableHead from '@/components/TableHead/src/TableHead.vue' import * as AreabasicApi from '@/api/wms/areabasic'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' import { formatDate } from '@/utils/formatTime'
import Detail from '@/components/Detail/src/Detail.vue' import { usePageLoading } from '@/hooks/web/usePageLoading'
const { loadStart, loadDone } = usePageLoading()
defineOptions({ name: 'CustomerSaleInvoiceMain' }) //
//
defineOptions({ name: 'customerSaleInvoiceMain' })
const message = useMessage() // const message = useMessage() //
const { t } = useI18n() // const { t } = useI18n() //
@ -74,34 +101,126 @@ const { t } = useI18n() // 国际化
const route = useRoute() // const route = useRoute() //
const routeName = ref() const routeName = ref()
routeName.value = route.name routeName.value = route.name
const tableColumns = ref(CustomerSaleInvoiceMain.allSchemas.tableColumns) const businessType = ref()
const importFileName = ref()
console.log(99 , routeName.value)
const customerCode = ref()
const tableColumns = ref([...CustomerSaleInvoiceMain.allSchemas.tableColumns,...CustomerSaleInvoiceDetail.allSchemas.tableMainColumns])
const { tableObject, tableMethods } = useTable({
getListApi: CustomerSaleInvoiceDetailApi.getCustomerSaleInvoiceDetailPage //
})
//
const updataTableColumns = (val) => {
tableColumns.value = val
}
// //
const searchTableSuccess = (formField, searchField, val, formRef) => { 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']
.push(newRow)
})
}else{
row[formField] = val[0][searchField]
}
// if(formField == 'itemCode') {
// row['uom'] = val[0]['customerUom']
// }
//
} else {
const setV = {}
if(formField == 'customerStatementNumber') {
//
setV['customer'] = 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 = []
}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
}
})
}
//
const searchTableSuccessDetail = (formField, searchField, val, formRef ) => {
nextTick(() => { nextTick(() => {
const setV = {} const setV = {}
setV[formField] = val[0][searchField] setV[formField] = val[0][searchField]
// setV['soLine'] = val[0]['lineNumber']
// setV['lineNumber'] = val[0]['lineNumber']
// setV['itemCode'] = val[0]['itemCode']
setV['remark'] = val[0]['remark']
setV['uom'] = val[0]['customerUom']
formRef.setValues(setV) formRef.setValues(setV)
}) })
} }
// // tableform
const updataTableColumns = (val) => { CustomerSaleInvoiceDetail.allSchemas.tableFormColumns.map(item => {
tableColumns.value = val if(item.field == 'itemCode') {
} item.tableForm.searchCondition = [
{
key: 'businessType',
value: businessType.value ,
isMainValue: false
},
{
key: 'customerCode',
value: 'customerCode' ,
isMainValue: true
}]
item.form.componentProps.searchCondition = [
{
key: 'businessType',
value: businessType.value,
isMainValue: false
},
{
key: 'customerCode',
value: 'customerCode' ,
isMainValue: true
}]
}
})
const { tableObject, tableMethods } = useTable({ //
getListApi: CustomerSaleInvoiceMainApi.getCustomerSaleInvoiceMainPage // // const Echo = ['ppNumber','poLine', 'batch', 'altBatch', 'itemCode', 'itemName', 'itemDesc1', 'itemDesc2', 'projectCode', 'qty', 'uom']
}) const Echo = []
// //
const { getList, setSearchParams } = tableMethods const { getList, setSearchParams } = tableMethods
// //
const HeadButttondata = [ const HeadButttondata = [
defaultButtons.defaultAddBtn({hasPermi:'wms:customerSaleInvoiceMain:create'}), // defaultButtons.defaultAddBtn({hasPermi:`wms:${routeName.value}:create` }), //
defaultButtons.defaultImportBtn({hasPermi:'wms:customerSaleInvoiceMain:import'}), // defaultButtons.defaultImportBtn({hasPermi:`wms:${routeName.value}:import` }), //
defaultButtons.defaultExportBtn({hasPermi:'wms:customerSaleInvoiceMain:export'}), // defaultButtons.defaultExportBtn({hasPermi:`wms:${routeName.value}:export` }), //
defaultButtons.defaultFreshBtn(null), // defaultButtons.defaultFreshBtn(null), //
defaultButtons.defaultFilterBtn(null), // defaultButtons.defaultFilterBtn(null), //
defaultButtons.defaultSetBtn(null), // defaultButtons.defaultSetBtn(null), //
@ -124,63 +243,142 @@ const buttonBaseClick = (val, item) => {
} else if (val == 'export') { // } else if (val == 'export') { //
handleExport() handleExport()
} else if (val == 'refresh') { // } else if (val == 'refresh') { //
getList() if (tableObject.params.filters && tableObject.params.filters.length > 0 ) {
searchFormClick({
filters: tableObject.params.filters
})
} else {
getList()
}
} else if (val == 'filtrate') { // } else if (val == 'filtrate') { //
} else { // } else { //
console.log('其他按钮', item) console.log('其他按钮', item)
} }
} }
//
const isShowMainButton = (row,val) => {
if (val.indexOf(row.status) > -1) {
return false
} else {
return true
}
}
// - // -
const butttondata = [ const butttondata = (row,$index) => {
defaultButtons.mainListEditBtn({hasPermi:'wms:customerSaleInvoiceMain:update'}), // const findIndex = row['masterId']?tableObject.tableList.findIndex(item=>item['masterId'] == row['masterId']):-1
defaultButtons.mainListOrderPubBtn({hasPermi:'wms:customerSaleInvoiceMain:publish'}), // if(findIndex>-1&&findIndex<$index){
defaultButtons.mainListOrderPubBtn({hasPermi:'wms:mainListCancelBtn:cancle'}), // return []
] }
return [
defaultButtons.mainListPlanOpeBtn({hide:isShowMainButton(row,['5']),hasPermi:`wms:${routeName.value}:open`}), //
defaultButtons.mainListPlanCloBtn({hide:isShowMainButton(row,['1','2','3','4']),hasPermi:`wms:${routeName.value}:close`}), //
defaultButtons.mainListPlanSubBtn({hide:isShowMainButton(row,['1']),hasPermi:`wms:${routeName.value}:submit`}), //
defaultButtons.mainListPlanTurBtn({hide:isShowMainButton(row,['2']),hasPermi:`wms:${routeName.value}:reject`}), //
defaultButtons.mainListPlanAppBtn({hide:isShowMainButton(row,['2']),hasPermi:`wms:${routeName.value}:agree`}), //
defaultButtons.mainListPlanPubBtn({hide:isShowMainButton(row,['3']),hasPermi:`wms:${routeName.value}:publish`}), //
defaultButtons.mainListPlanResBtn({hide:isShowMainButton(row,['4']),hasPermi:`wms:${routeName.value}:resetting`}), //
defaultButtons.mainListEditBtn({hide:isShowMainButton(row,['1']),hasPermi:`wms:${routeName.value}:update`}), //
]
}
// - // -
const buttonTableClick = async (val, row) => { const buttonTableClick = async (val, row) => {
if (val == 'edit') { // if (val == 'mainPlanOpe') { //
tableObject.loading = true
CustomerSaleInvoiceMainApi.open(row.masterId).then(() => {
message.success(t('common.updateSuccess'))
tableObject.loading = false
buttonBaseClick('refresh',null)
}).catch(err => {
tableObject.loading = false
console.log(err)
})
} else if (val == 'mainPlanClo') { //
await message.confirm('确认要关闭吗?')
tableObject.loading = true
CustomerSaleInvoiceMainApi.close(row.masterId).then(() => {
message.success(t('common.updateSuccess'))
tableObject.loading = false
buttonBaseClick('refresh',null)
}).catch(err => {
tableObject.loading = false
console.log(err)
})
} else if (val == 'mainPlanSub') { //
await message.confirm('确认要提交审批吗?')
tableObject.loading = true
CustomerSaleInvoiceMainApi.submit(row.masterId).then(() => {
message.success(t('common.updateSuccess'))
tableObject.loading = false
buttonBaseClick('refresh',null)
}).catch(err => {
tableObject.loading = false
console.log(err)
})
} else if (val == 'mainPlanTur') { //
await message.confirm('确认要驳回吗?')
tableObject.loading = true
CustomerSaleInvoiceMainApi.reject(row.masterId).then(() => {
message.success(t('common.updateSuccess'))
tableObject.loading = false
buttonBaseClick('refresh',null)
}).catch(err => {
tableObject.loading = false
console.log(err)
})
} else if (val == 'mainPlanApp') { //
await message.confirm('确认要审批通过吗?')
tableObject.loading = true
CustomerSaleInvoiceMainApi.agree(row.masterId).then(() => {
message.success(t('common.updateSuccess'))
tableObject.loading = false
buttonBaseClick('refresh',null)
}).catch(err => {
tableObject.loading = false
console.log(err)
})
} else if (val == 'mainPlanPub') { //
await message.confirm('确认要发布吗?')
tableObject.loading = true
CustomerSaleInvoiceMainApi.publish(row.masterId).then(() => {
message.success(t('common.updateSuccess'))
tableObject.loading = false
buttonBaseClick('refresh',null)
}).catch(err => {
tableObject.loading = false
console.log(err)
})
} else if (val == 'mainPlanRes') { //
await message.confirm('确认要重置吗?')
tableObject.loading = true
CustomerSaleInvoiceMainApi.resetting(row.masterId).then(() => {
message.success(t('common.updateSuccess'))
tableObject.loading = false
buttonBaseClick('refresh',null)
}).catch(err => {
tableObject.loading = false
console.log(err)
})
} else if (val == 'edit') { //
openForm('update', row) openForm('update', row)
} else if (val == 'delete') { // } else if (val == 'delete') { //
handleDelete(row.id) handleDelete(row.masterId)
} }
} }
/** 添加/修改操作 */ /** 添加/修改操作 */
const basicFormRef = ref() const formRef = ref()
const openForm = (type: string, row?: any) => { const openForm =async (type: string, row?: number) => {
basicFormRef.value.open(type, row) tableData.value = [] //
} formRef.value.open(type, row)
// form
const formsSuccess = async (formType,data) => {
var isHave =CustomerSaleInvoiceMain.allSchemas.formSchema.some(function (item) {
return item.field === 'activeTime' || item.field === 'expireTime';
});
if(isHave){
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){
message.error('失效时间要大于生效时间')
return;
}
}
if(data.activeTime==0)data.activeTime = null;
if(data.expireTime==0)data.expireTime = null;
if (formType === 'create') {
await CustomerSaleInvoiceMainApi.createCustomerSaleInvoiceMain(data)
message.success(t('common.createSuccess'))
} else {
await CustomerSaleInvoiceMainApi.updateCustomerSaleInvoiceMain(data)
message.success(t('common.updateSuccess'))
}
basicFormRef.value.dialogVisible = false
getList()
} }
/** 详情操作 */ /** 详情操作 */
const detailRef = ref() const detailRef = ref()
const openDetail = (row: any, titleName: any, titleValue: any) => { const openDetail = (row: any, titleName: any, titleValue: any) => {
detailRef.value.openDetail(row, titleName, titleValue, 'basicCustomerSaleInvoiceMain') detailRef.value.openDetail(row, titleName, titleValue,'planDeliverMain')
} }
/** 删除按钮操作 */ /** 删除按钮操作 */
@ -188,27 +386,121 @@ const handleDelete = async (id: number) => {
try { try {
// //
await message.delConfirm() await message.delConfirm()
tableObject.loading = true
// //
await CustomerSaleInvoiceMainApi.deleteCustomerSaleInvoiceMain(id) await CustomerSaleInvoiceMainApi.deleteCustomerSaleInvoiceMain(id)
tableObject.loading = false
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
// //
await getList() buttonBaseClick('refresh',null)
} catch {} } catch {}
} }
/** 导出按钮操作 */ /** 导出按钮操作 */
const exportLoading = ref(false) //
const handleExport = async () => { const handleExport = async () => {
try { try {
// //
await message.exportConfirm() await message.exportConfirm()
// //
exportLoading.value = true loadStart()
const excelTitle = ref(route.meta.title)
const data = await CustomerSaleInvoiceMainApi.exportCustomerSaleInvoiceMain(tableObject.params) const data = await CustomerSaleInvoiceMainApi.exportCustomerSaleInvoiceMain(tableObject.params)
download.excel(data, '客户销售开票主信息表(WMS).xlsx') download.excel(data, `${excelTitle.value}】【${formatDate(new Date())}】.xlsx`)
} catch { } catch {
} finally { } finally {
exportLoading.value = false loadDone()
}
}
/**
* 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))
}
//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
} }
} }
@ -217,11 +509,13 @@ const importFormRef = ref()
const handleImport = () => { const handleImport = () => {
importFormRef.value.open() importFormRef.value.open()
} }
// //
const importTemplateData = reactive({ const importTemplateData = reactive({
templateUrl: '', templateUrl: '',
templateTitle: '客户销售开票主信息表(WMS)导入模版.xlsx' templateTitle: `${route.meta.title}】导入模版.xlsx`
}) })
// //
const importSuccess = () => { const importSuccess = () => {
getList() getList()
@ -241,5 +535,4 @@ onMounted(async () => {
getList() getList()
importTemplateData.templateUrl = await CustomerSaleInvoiceMainApi.importTemplate() importTemplateData.templateUrl = await CustomerSaleInvoiceMainApi.importTemplate()
}) })
</script> </script>

Loading…
Cancel
Save