新增开票页面

master
shilei 2 days ago
parent b464b1cbe3
commit c01fe5b003

@ -0,0 +1,70 @@
import request from '@/config/axios'
// 开票 VO
export interface InvoiceVO {
// id
id: number
// 用户编号
userId: number
// 开票金额
actualPay: number
// 状态 0未开票 1开票中 2开票完成
invoiceStatus: number
// 开票订单号:多个订单用,分割
orderNo: string
// 发票类型1企业 2个人
type: number
// 订单类型1换电订单 2站外充电订单
orderType: number
// 文件表id
infraFileId: number
// 发票抬头
invoiceTitle: string
// 税号
dutyNumber: string
// 注册地址
registeredAddress: string
// 开户行
bankOfDeposit: string
// 开票联系人姓名
contactPerson: string
// 开票联系人电话
contactNumber: string
// 电子邮箱
emailAddress: string
// 开户行账户
openBankAccount: string
}
// 开票 API
export const InvoiceApi = {
// 查询开票分页
getInvoicePage: async (params: any) => {
return await request.get({ url: `/cloud/invoice/page`, params })
},
// 查询开票详情
getInvoice: async (id: number) => {
return await request.get({ url: `/cloud/invoice/get?id=` + id })
},
// 新增开票
createInvoice: async (data: InvoiceVO) => {
return await request.post({ url: `/cloud/invoice/create`, data })
},
// 修改开票
updateInvoice: async (data: InvoiceVO) => {
return await request.put({ url: `/cloud/invoice/update`, data })
},
// 删除开票
deleteInvoice: async (id: number) => {
return await request.delete({ url: `/cloud/invoice/delete?id=` + id })
},
// 导出开票 Excel
exportInvoice: async (params) => {
return await request.download({ url: `/cloud/invoice/export-excel`, params })
},
}

@ -0,0 +1,170 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="100px"
v-loading="formLoading"
>
<el-form-item label="用户编号" prop="userId">
<el-input v-model="formData.userId" placeholder="请输入用户编号" />
</el-form-item>
<el-form-item label="开票金额" prop="actualPay">
<el-input v-model="formData.actualPay" placeholder="请输入开票金额" />
</el-form-item>
<el-form-item label="状态 0未开票 1开票中 2开票完成" prop="invoiceStatus">
<el-radio-group v-model="formData.invoiceStatus">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="开票订单号:多个订单用,分割" prop="orderNo">
<el-input v-model="formData.orderNo" placeholder="请输入开票订单号:多个订单用,分割" />
</el-form-item>
<el-form-item label="发票类型1企业 2个人" prop="type">
<el-select v-model="formData.type" placeholder="请选择发票类型1企业 2个人">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="订单类型1换电订单 2站外充电订单" prop="orderType">
<el-select v-model="formData.orderType" placeholder="请选择订单类型1换电订单 2站外充电订单">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="文件表id" prop="infraFileId">
<el-input v-model="formData.infraFileId" placeholder="请输入文件表id" />
</el-form-item>
<el-form-item label="发票抬头" prop="invoiceTitle">
<el-input v-model="formData.invoiceTitle" placeholder="请输入发票抬头" />
</el-form-item>
<el-form-item label="税号" prop="dutyNumber">
<el-input v-model="formData.dutyNumber" placeholder="请输入税号" />
</el-form-item>
<el-form-item label="注册地址" prop="registeredAddress">
<el-input v-model="formData.registeredAddress" placeholder="请输入注册地址" />
</el-form-item>
<el-form-item label="开户行" prop="bankOfDeposit">
<el-input v-model="formData.bankOfDeposit" placeholder="请输入开户行" />
</el-form-item>
<el-form-item label="开票联系人姓名" prop="contactPerson">
<el-input v-model="formData.contactPerson" placeholder="请输入开票联系人姓名" />
</el-form-item>
<el-form-item label="开票联系人电话" prop="contactNumber">
<el-input v-model="formData.contactNumber" placeholder="请输入开票联系人电话" />
</el-form-item>
<el-form-item label="电子邮箱" prop="emailAddress">
<el-input v-model="formData.emailAddress" placeholder="请输入电子邮箱" />
</el-form-item>
<el-form-item label="开户行账户" prop="openBankAccount">
<el-input v-model="formData.openBankAccount" placeholder="请输入开户行账户" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import { InvoiceApi, InvoiceVO } from '@/api/system/orderManagement/invoice'
/** 开票 表单 */
defineOptions({ name: 'InvoiceForm' })
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formData = ref({
id: undefined,
userId: undefined,
actualPay: undefined,
invoiceStatus: undefined,
orderNo: undefined,
type: undefined,
orderType: undefined,
infraFileId: undefined,
invoiceTitle: undefined,
dutyNumber: undefined,
registeredAddress: undefined,
bankOfDeposit: undefined,
contactPerson: undefined,
contactNumber: undefined,
emailAddress: undefined,
openBankAccount: undefined,
})
const formRules = reactive({
invoiceStatus: [{ required: true, message: '状态 0未开票 1开票中 2开票完成不能为空', trigger: 'blur' }],
invoiceTitle: [{ required: true, message: '发票抬头不能为空', trigger: 'blur' }],
dutyNumber: [{ required: true, message: '税号不能为空', trigger: 'blur' }],
})
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
//
if (id) {
formLoading.value = true
try {
formData.value = await InvoiceApi.getInvoice(id)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
await formRef.value.validate()
//
formLoading.value = true
try {
const data = formData.value as unknown as InvoiceApi.InvoiceVO
if (formType.value === 'create') {
await InvoiceApi.createInvoice(data)
message.success(t('common.createSuccess'))
} else {
await InvoiceApi.updateInvoice(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
userId: undefined,
actualPay: undefined,
invoiceStatus: undefined,
orderNo: undefined,
type: undefined,
orderType: undefined,
infraFileId: undefined,
invoiceTitle: undefined,
dutyNumber: undefined,
registeredAddress: undefined,
bankOfDeposit: undefined,
contactPerson: undefined,
contactNumber: undefined,
emailAddress: undefined,
openBankAccount: undefined,
}
formRef.value?.resetFields()
}
</script>

@ -0,0 +1,401 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="120px"
>
<el-form-item label="开票状态" prop="invoiceStatus">
<el-select
v-model="queryParams.invoiceStatus"
placeholder="请选择状态"
clearable
class="!w-240px"
>
<el-option label="未开票" :value="0" />
<el-option label="开票中" :value="1" />
<el-option label="开票完成" :value="2" />
</el-select>
</el-form-item>
<el-form-item label="发票类型" prop="type">
<el-select v-model="queryParams.type" placeholder="" clearable class="!w-240px">
<el-option label="企业" :value="1" />
<el-option label="个人" :value="2" />
</el-select>
</el-form-item>
<el-form-item label="订单类型" prop="orderType">
<el-select
v-model="queryParams.orderType"
placeholder="请选择订单类型"
clearable
class="!w-240px"
>
<el-option label="换电订单" :value="1" />
<el-option label="站外充电订单" :value="2" />
</el-select>
</el-form-item>
<el-form-item label="发票抬头" prop="invoiceTitle">
<el-input
v-model="queryParams.invoiceTitle"
placeholder="请输入"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="税号" prop="dutyNumber">
<el-input
v-model="queryParams.dutyNumber"
placeholder="请输入"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="注册地址" prop="registeredAddress">
<el-input
v-model="queryParams.registeredAddress"
placeholder="请输入"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="开户行" prop="bankOfDeposit">
<el-input
v-model="queryParams.bankOfDeposit"
placeholder="请输入"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="开票联系人姓名" prop="contactPerson">
<el-input
v-model="queryParams.contactPerson"
placeholder="请输入"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="开票联系人电话" prop="contactNumber">
<el-input
v-model="queryParams.contactNumber"
placeholder="请输入"
clearable
@keyup.enter="handleQuery"
type="number"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="queryParams.createTime"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="开户行账户" prop="openBankAccount">
<el-input
v-model="queryParams.openBankAccount"
placeholder="请输入开户行账户"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<!-- <el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['cloud:invoice:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button> -->
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['cloud:invoice:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<!-- <el-table-column label="id" align="center" prop="id" /> -->
<el-table-column label="序号" type="index" align="center" width="100" />
<el-table-column label="开票订单号" align="center" prop="orderNo" />
<!-- <el-table-column label="用户编号" align="center" prop="userId" /> -->
<el-table-column label="开票金额(元)" align="center" prop="actualPay">
<template #default="scope">
{{ scope.row.actualPay / 100 }}
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="invoiceStatus">
<template #default="scope">
<!-- {{ ['未开票','开票中','开票完成'][scope.row.invoiceStatus] }} -->
<el-tag type="info" v-if="scope.row.invoiceStatus == 0"></el-tag>
<el-tag type="danger" v-if="scope.row.invoiceStatus == 1"></el-tag>
<el-tag type="success" v-if="scope.row.invoiceStatus == 2"></el-tag>
</template>
</el-table-column>
<el-table-column label="发票类型" align="center" prop="type">
<template #default="scope">
<el-tag type="info" v-if="scope.row.type == 1"></el-tag>
<el-tag type="warning" v-if="scope.row.type == 2"></el-tag>
</template>
</el-table-column>
<el-table-column label="订单类型" align="center" prop="orderType">
<template #default="scope">
<el-tag type="info" v-if="scope.row.orderType == 1"></el-tag>
<el-tag type="warning" v-if="scope.row.orderType == 2"></el-tag>
</template>
</el-table-column>
<!-- <el-table-column label="文件表id" align="center" prop="infraFileId" /> -->
<el-table-column label="发票抬头" align="center" prop="invoiceTitle" />
<el-table-column label="税号" align="center" prop="dutyNumber" />
<el-table-column label="注册地址" align="center" prop="registeredAddress" />
<el-table-column label="开户行" align="center" prop="bankOfDeposit" />
<el-table-column label="开票联系人姓名" align="center" prop="contactPerson" />
<el-table-column label="开票联系人电话" align="center" prop="contactNumber" />
<!-- <el-table-column label="电子邮箱" align="center" prop="emailAddress" /> -->
<!-- <el-table-column
label="创建时间"
align="center"
prop="createTime"
:formatter="dateFormatter"
width="180px"
/> -->
<el-table-column label="开户行账户" align="center" prop="openBankAccount" />
<el-table-column label="文件地址" align="center" prop="fileUrl" />
<el-table-column label="操作" align="center">
<template #default="scope">
<!-- <el-button link type="primary" @click="openForm('update', scope.row.id)">
编辑
</el-button> -->
<!-- <el-button link type="danger" @click="handleDelete(scope.row.id)"> </el-button> -->
<el-button
link
type="primary"
@click="upload_pdf(scope.row)"
v-if="scope.row.invoiceStatus != 2"
>
上传发票
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- -->
<el-dialog v-model="upload_dialogVisible" title="上传发票" width="500" center>
<div style="display: flex; justify-content: space-evenly">
<!-- <UploadImgs v-model:modelValue="upload_formData.avatar" /> -->
<el-upload
class="upload-demo"
ref="upload_pdf_file"
style="width: 100%"
:headers="uploadHeaders"
drag
action="https://www.zzpower.net/admin-api/infra/file/uploadFile"
multiple
:on-success="upload_success"
:on-progress="upload_progress"
>
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
<div class="el-upload__text"> 拖动文件 or <em>点击上传</em> </div>
<!-- <template #tip>
<div class="el-upload__tip"> </div>
</template> -->
</el-upload>
</div>
<template #footer>
<div class="dialog-footer">
<el-button @click="upload_dialogVisible = false">取消</el-button>
<el-button type="primary" @click="upload_submit"> </el-button>
</div>
</template>
</el-dialog>
<!-- 表单弹窗添加/修改 -->
<InvoiceForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { InvoiceApi, InvoiceVO } from '@/api/system/orderManagement/invoice'
import InvoiceForm from './InvoiceForm.vue'
import { UploadFilled } from '@element-plus/icons-vue'
import { getAccessToken, getTenantId } from '@/utils/auth'
/** 开票 列表 */
defineOptions({ name: 'Invoice' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const list = ref<InvoiceVO[]>([]) //
const upload_pdf_file = ref(null)
//
const total = ref(0)
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
userId: undefined,
actualPay: undefined,
invoiceStatus: undefined,
orderNo: undefined,
type: undefined,
orderType: undefined,
infraFileId: undefined,
invoiceTitle: undefined,
dutyNumber: undefined,
registeredAddress: undefined,
bankOfDeposit: undefined,
contactPerson: undefined,
contactNumber: undefined,
emailAddress: undefined,
createTime: [],
openBankAccount: undefined
})
const upload_dialogVisible = ref(false) //
const upload_formData = ref({})
const queryFormRef = ref() //
const exportLoading = ref(false) //
const uploadHeaders = ref({
Authorization: 'Bearer ' + getAccessToken(),
'tenant-id': getTenantId()
})
/** 查询列表 */
const getList = async () => {
loading.value = true
console.log(queryParams, 'queryParams')
try {
const data = await InvoiceApi.getInvoicePage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await InvoiceApi.deleteInvoice(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await InvoiceApi.exportInvoice(queryParams)
download.excel(data, '开票.xls')
} catch {
} finally {
exportLoading.value = false
}
}
const upload_pdf = (row: any) => {
console.log(row)
// console.log(id)
upload_formData.value = row
upload_dialogVisible.value = true
}
const upload_submit = async () => {
// let queryParams = { ...upload_formData }
loading.value = true
try {
upload_formData.value.invoiceStatus = 2
await InvoiceApi.updateInvoice(upload_formData.value)
message.success('上传成功')
} finally {
loading.value = false
}
upload_dialogVisible.value = false
upload_pdf_file.value.clearFiles()
getList()
}
const upload_success = (res: any, file: any) => {
// console.log(res, file)
upload_formData.value.infraFileId = res.data.id
}
const upload_progress = (ev: any, file: any) => {
// console.log(ev, file)
// console.log(file.raw.type, 'leixing ')
if (file.raw.type != 'application/pdf') {
message.error('请上传pdf格式文件')
setTimeout(() => {
upload_pdf_file.value.clearFiles()
upload_dialogVisible.value = false
}, 2000)
}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>
Loading…
Cancel
Save