发票管理修改

main
mo 1 year ago
parent 954077c816
commit 4192e681c0

@ -17,3 +17,12 @@ export function uploadFileApi(data) {
data: data data: data
}) })
} }
// 文件上传
export function uploadInvoiceApi(data) {
return request({
url: '/accounting/invoices/identify',
method: 'post',
data: data
})
}

@ -1,17 +1,48 @@
<!-- --> <!-- -->
<template> <template>
<div class="out"> <div class="out">
<el-upload :class="{ hide: hideUpload }" ref="imgListRef" :limit="1" :file-list="fileList" :on-change="onUploadChange" :before-upload="beforeFileUpload" action="#" :accept="imgType" list-type="picture-card" :auto-upload="false"> <el-upload
:class="{ hide: hideUpload }"
ref="imgListRef"
:limit="1"
:file-list="fileList"
:on-change="onUploadChange"
:before-upload="beforeFileUpload"
action="#"
:accept="imgType"
list-type="picture-card"
:auto-upload="false"
>
<i class="el-icon-plus"></i> <i class="el-icon-plus"></i>
<div slot="file" slot-scope="{file}" style="position: relative;height: 100%;"> <div
<img class="el-upload-list__item-thumbnail" v-if="!isPdf" :src="file.url" alt /> slot="file"
<img class="el-upload-list__item-thumbnail" v-else src="~@/assets/images/pdf.png" alt /> slot-scope="{ file }"
style="position: relative; height: 100%"
>
<img
class="el-upload-list__item-thumbnail"
v-if="!isPdf"
:src="file.url"
alt
/>
<img
class="el-upload-list__item-thumbnail"
v-else
src="~@/assets/images/pdf.png"
alt
/>
<div v-if="isPdf" class="pdf-name">{{ pdfName }}</div> <div v-if="isPdf" class="pdf-name">{{ pdfName }}</div>
<span class="el-upload-list__item-actions"> <span class="el-upload-list__item-actions">
<span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)"> <span
class="el-upload-list__item-preview"
@click="handlePictureCardPreview(file)"
>
<i class="el-icon-zoom-in"></i> <i class="el-icon-zoom-in"></i>
</span> </span>
<span class="el-upload-list__item-delete" @click="handleRemove(file, fileList)"> <span
class="el-upload-list__item-delete"
@click="handleRemove(file, fileList)"
>
<i class="el-icon-delete"></i> <i class="el-icon-delete"></i>
</span> </span>
</span> </span>
@ -19,40 +50,53 @@
</el-upload> </el-upload>
<div class="title">支持pngpdfjpg格式上传</div> <div class="title">支持pngpdfjpg格式上传</div>
<div class="inside"> <div class="inside">
<el-button type="primary" @click="handleScan" size="small" plain>发票识别</el-button> <el-button type="primary" @click="handleScan" size="small" plain
<el-button type="primary" @click="handleCheck" size="small" plain>发票验真</el-button> >发票识别</el-button
>
<el-button type="primary" @click="handleCheck" size="small" plain
>发票验真</el-button
>
</div> </div>
<el-image-viewer v-if="dialogVisible" :zIndex="9999" :on-close="closeImgViewer" :url-list="imgList" /> <el-image-viewer
v-if="dialogVisible"
:zIndex="9999"
:on-close="closeImgViewer"
:url-list="imgList"
/>
<!-- 文件在线预览 --> <!-- 文件在线预览 -->
<FilePreview :previewFile="previewFile" :fileUrl="fileUrl" @update="previewFile=false" /> <FilePreview
:previewFile="previewFile"
:fileUrl="fileUrl"
@update="previewFile = false"
/>
</div> </div>
</template> </template>
<script> <script>
import ElImageViewer from "element-ui/packages/image/src/image-viewer"; import ElImageViewer from "element-ui/packages/image/src/image-viewer";
import { uploadFileApi } from "@/api/common" import { uploadFileApi } from "@/api/common";
export default { export default {
name: '', name: "",
props: { props: {
files: Array, files: Array,
}, },
watch: { watch: {
files: { files: {
handler(list) { handler(list) {
this.fileList = list this.fileList = list;
if (list.length >= 1) { if (list.length >= 1) {
this.hideUpload = true this.hideUpload = true;
} else { } else {
this.hideUpload = false this.hideUpload = false;
} }
}, },
}, },
deep: true deep: true,
}, },
data() { data() {
return { return {
hideUpload: false, hideUpload: false,
imgType: '.jpeg, .jpg, .png, .pdf', imgType: ".jpeg, .jpg, .png, .pdf",
fileList: [], fileList: [],
dialogVisible: false, dialogVisible: false,
isPdf: false, isPdf: false,
@ -60,81 +104,84 @@ export default {
imgList: null, imgList: null,
fileUrl: null, fileUrl: null,
previewFile: false, previewFile: false,
} };
}, },
components: { components: {
ElImageViewer, ElImageViewer,
FilePreview: () => import('@/components/FilePreview'), FilePreview: () => import("@/components/FilePreview"),
}, },
computed: {}, computed: {},
methods: { methods: {
// //
handleRemove(file, files) { handleRemove(file, files) {
this.fileList = files.filter(item => file.uid !== item.uid) this.fileList = files.filter((item) => file.uid !== item.uid);
this.$emit('onConfirm', this.fileList) this.$emit("onConfirm", this.fileList);
return false return false;
}, },
// //
onUploadChange(file, fileList) { onUploadChange(file, fileList) {
this.beforeFileUpload(file, fileList) this.beforeFileUpload(file, fileList);
}, },
beforeFileUpload(file, fileList) { beforeFileUpload(file, fileList) {
//before-upload使 //before-upload使
const isImage = file.raw.type == 'image/png' || file.raw.type == 'image/jpg' || file.raw.type == 'image/jpeg' || file.raw.type == 'application/pdf'; const isImage =
file.raw.type == "image/png" ||
file.raw.type == "image/jpg" ||
file.raw.type == "image/jpeg" ||
file.raw.type == "application/pdf";
// const isLt5M = file.size < 1024 * 1024 * 5; // const isLt5M = file.size < 1024 * 1024 * 5;
if (!isImage) { if (!isImage) {
this.$message.warning('上传只能是png,jpg,jpeg,.pdf格式!'); this.$message.warning("上传只能是png,jpg,jpeg,.pdf格式!");
} }
if (file.raw.type == 'application/pdf') { if (file.raw.type == "application/pdf") {
this.isPdf = true this.isPdf = true;
this.pdfName = file.raw.name this.pdfName = file.raw.name;
} else { } else {
this.isPdf = false this.isPdf = false;
} }
let FormDatas = new FormData() let FormDatas = new FormData();
FormDatas.append('file', file.raw); FormDatas.append("file", file.raw);
FormDatas.append('path', file.raw.name); FormDatas.append("path", file.raw.name);
this.$modal.loading("正在上传,请稍候..."); this.$modal.loading("正在上传,请稍候...");
uploadFileApi(FormDatas).then((res) => { uploadFileApi(FormDatas).then((res) => {
this.fileList.push({ name: file.name, url: res.data }); // this.fileList.push({ name: file.name, url: res.data }); //
this.$emit('onConfirm', this.fileList) this.$emit("onConfirm", this.fileList);
this.$modal.closeLoading() this.$modal.closeLoading();
}) });
}, },
closeImgViewer() { closeImgViewer() {
this.dialogVisible = false; this.dialogVisible = false;
}, },
handlePictureCardPreview(file) { handlePictureCardPreview(file) {
if (file.name.indexOf('.pdf') > -1) { if (file.name.indexOf(".pdf") > -1) {
this.fileUrl = this.fileList[0].url this.fileUrl = this.fileList[0].url;
this.previewFile = true this.previewFile = true;
} else { } else {
this.imgList = [file.url] this.imgList = [file.url];
this.dialogVisible = true this.dialogVisible = true;
} }
}, },
// //
handleScan() { handleScan() {
if (this.fileList.length) { if (this.fileList.length) {
this.$emit('onScan') this.$emit("onScan");
} else { } else {
this.$fm('请先上传发票!') this.$fm("请先上传发票!");
} }
}, },
// //
handleCheck() { handleCheck() {
if (this.fileList.length) { if (this.fileList.length) {
this.$emit('onCheck') this.$emit("onCheck");
} else { } else {
this.$fm('请先上传发票!') this.$fm("请先上传发票!");
} }
}, },
} },
} };
</script> </script>
<style lang='scss' scoped> <style lang="scss" scoped>
@import '@/assets/styles/form/index.scss'; @import "@/assets/styles/form/index.scss";
.pdf-name { .pdf-name {
text-align: center; text-align: center;
position: absolute; position: absolute;

@ -0,0 +1,221 @@
<!-- -->
<template>
<div class="out">
<el-upload
:class="{ hide: hideUpload }"
ref="imgListRef"
:limit="1"
:file-list="fileList"
:on-change="onUploadChange"
:before-upload="beforeFileUpload"
action="#"
:accept="imgType"
list-type="picture-card"
:auto-upload="false"
>
<i class="el-icon-plus"></i>
<div
slot="file"
slot-scope="{ file }"
style="position: relative; height: 100%"
>
<!-- pdf -->
<img
class="el-upload-list__item-thumbnail"
v-if="!isPdf"
:src="file.url"
alt
/>
<img
class="el-upload-list__item-thumbnail"
v-else
src="~@/assets/images/pdf.png"
alt
/>
<div v-if="isPdf" class="pdf-name">{{ pdfName }}</div>
<!-- ofd -->
<img
class="el-upload-list__item-thumbnail"
v-if="!isOfd"
:src="file.url"
alt
/>
<img class="el-upload-list__item-thumbnail" v-else alt />
<div v-if="isOfd" class="pdf-name">{{ ofdName }}</div>
<span class="el-upload-list__item-actions">
<span
class="el-upload-list__item-preview"
@click="handlePictureCardPreview(file)"
>
<i class="el-icon-zoom-in"></i>
</span>
<span
class="el-upload-list__item-delete"
@click="handleRemove(file, fileList)"
>
<i class="el-icon-delete"></i>
</span>
</span>
</div>
</el-upload>
<div class="title">支持图片pdfofd格式上传</div>
<div class="inside">
<el-button type="primary" @click="handleScan" size="small" plain
>发票识别</el-button
>
<el-button type="primary" @click="handleCheck" size="small" plain
>发票验真</el-button
>
</div>
<el-image-viewer
v-if="dialogVisible"
:zIndex="9999"
:on-close="closeImgViewer"
:url-list="imgList"
/>
<!-- 文件在线预览 -->
<FilePreview
:previewFile="previewFile"
:fileUrl="fileUrl"
@update="previewFile = false"
/>
</div>
</template>
<script>
import ElImageViewer from "element-ui/packages/image/src/image-viewer";
import { uploadInvoiceApi } from "@/api/common";
export default {
name: "",
props: {
files: Array,
},
watch: {
files: {
handler(list) {
this.fileList = list;
if (list.length >= 1) {
this.hideUpload = true;
} else {
this.hideUpload = false;
}
},
},
deep: true,
},
data() {
return {
hideUpload: false,
imgType: ".jpeg, .jpg, .png, .pdf ,.ofd",
fileList: [],
dialogVisible: false,
isPdf: false,
isOfd: false,
pdfName: null,
ofdName: null,
imgList: null,
fileUrl: null,
previewFile: false,
invoiceForm: {},
};
},
components: {
ElImageViewer,
FilePreview: () => import("@/components/FilePreview"),
},
computed: {},
methods: {
//
handleRemove(file, files) {
this.fileList = [];
this.$emit("onConfirm", this.fileList);
return false;
},
//
onUploadChange(file, fileList) {
this.beforeFileUpload(file, fileList);
},
beforeFileUpload(file, fileList) {
console.log(file);
//before-upload使
const isImage =
file.raw.type == "image/png" ||
file.raw.type == "image/jpg" ||
file.raw.type == "image/jpeg" ||
file.raw.type == "application/pdf" ||
file.raw.type == "application/ofd";
// const isLt5M = file.size < 1024 * 1024 * 5;
if (!isImage) {
this.$message.warning("上传只能是png,jpg,jpeg格式!");
}
if (file.raw.type == "application/pdf") {
this.isPdf = true;
this.pdfName = file.raw.name;
} else {
this.isPdf = false;
}
if (file.raw.type == "application/ofd") {
this.isOfd = true;
this.pdfName = file.raw.name;
} else {
this.isOfd = false;
}
let FormDatas = new FormData();
FormDatas.append("multipartFile", file.raw);
this.$modal.loading("正在上传,请稍候...");
uploadInvoiceApi(FormDatas).then((res) => {
this.invoiceForm = res.data;
this.fileList.push({ name: file.name, url: res.data.fileUrl }); //
this.$emit("onConfirm", this.fileList);
this.$modal.closeLoading();
});
},
closeImgViewer() {
this.dialogVisible = false;
},
//
handlePictureCardPreview(file) {
if (file.name.indexOf(".pdf") > -1) {
this.fileUrl = this.fileList[0].url;
this.previewFile = true;
} else {
this.imgList = [file.url];
this.dialogVisible = true;
}
},
//
handleScan() {
if (this.fileList.length) {
this.$emit("onScan", this.invoiceForm);
} else {
this.$fm("请先上传发票!");
}
},
//
handleCheck() {
if (this.fileList.length) {
this.$emit("onCheck");
} else {
this.$fm("请先上传发票!");
}
},
},
};
</script>
<style lang="scss" scoped>
@import "@/assets/styles/form/index.scss";
.pdf-name {
text-align: center;
position: absolute;
width: 100%;
top: 115px;
line-height: 15px;
font-size: smaller;
bottom: 0;
}
.el-upload-list--picture-card .el-upload-list__item-thumbnail {
// height: auto !important;
object-fit: cover;
}
</style>

@ -10,20 +10,25 @@
label-width="68px" label-width="68px"
> >
<el-form-item label="会计年度" prop="year"> <el-form-item label="会计年度" prop="year">
<el-input <el-date-picker
format="yyyy年"
v-model="queryParams.year" v-model="queryParams.year"
placeholder="请输入会计年度" value-format="yyyy"
clearable type="year"
@keyup.enter.native="handleQuery" placeholder="请选择会计年度"
/> >
</el-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="会计期间" prop="period"> <el-form-item label="会计期间" prop="period">
<el-input <el-date-picker
popper-class="due_month"
v-model="queryParams.period" v-model="queryParams.period"
placeholder="请输入会计期间" format="M月"
clearable value-format="M"
@keyup.enter.native="handleQuery" type="month"
/> placeholder="请选择会计期间"
>
</el-date-picker>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery" <el-button type="primary" icon="el-icon-search" @click="handleQuery"
@ -64,7 +69,13 @@
<!-- 列表 --> <!-- 列表 -->
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list">
<el-table-column label="账簿名称" align="center" prop="name" /> <el-table-column label="账簿名称" align="center" prop="name">
<!-- <template slot-scope="scope">
<el-button type="text" @click="openLink(scope.row.uri)">
{{ scope.row.name }}
</el-button>
</template> -->
</el-table-column>
<el-table-column label="业务实体" align="center" prop="company" /> <el-table-column label="业务实体" align="center" prop="company" />
<el-table-column label="细分类型" align="center" prop="type" /> <el-table-column label="细分类型" align="center" prop="type" />
<el-table-column label="会计年度" align="center" prop="year" /> <el-table-column label="会计年度" align="center" prop="year" />
@ -220,7 +231,6 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div></div>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button type="primary" @click="submitForm"> </el-button>
@ -311,6 +321,16 @@ export default {
this.getOrganizationList(); this.getOrganizationList();
}, },
methods: { methods: {
// /**
// *
// * @param fileUrl
// */
// openLink(fileUrl) {
// const url = `http://139.224.253.31:48012/onlinePreview?url=${encodeURIComponent(
// this.base64Encode(fileUrl)
// )}`;
// window.open(url);
// },
/** 查询列表 */ /** 查询列表 */
getList() { getList() {
this.loading = true; this.loading = true;
@ -327,6 +347,7 @@ export default {
this.organizationList = response.data.list; this.organizationList = response.data.list;
}); });
}, },
//
handleCompanyChange(val) { handleCompanyChange(val) {
var data = this.organizationList.find((item) => item.id == val); var data = this.organizationList.find((item) => item.id == val);
console.log(data); console.log(data);

@ -256,7 +256,7 @@
width="1300px" width="1300px"
append-to-body append-to-body
> >
<el-upload <!-- <el-upload
class="upload-demo" class="upload-demo"
drag drag
:action="uploadUrl" :action="uploadUrl"
@ -272,9 +272,19 @@
<div class="el-upload__tip" slot="tip" style="margin-bottom: 20px"> <div class="el-upload__tip" slot="tip" style="margin-bottom: 20px">
只能上传图片PDFOFD文件 只能上传图片PDFOFD文件
</div> </div>
</el-upload> </el-upload> -->
<el-form ref="form" :model="form" :rules="rules" label-width="140px"> <el-form ref="form" :model="form" :rules="rules" label-width="140px">
<el-row>
<el-col :span="8">
<UploadInvoice
:files="fileList"
@onConfirm="handleImg"
@onScan="handleScan"
/>
</el-col>
</el-row>
<el-divider>发票信息</el-divider>
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="发票代码" prop="invoiceCode"> <el-form-item label="发票代码" prop="invoiceCode">
@ -567,7 +577,7 @@ import { getAccessToken } from "@/utils/auth";
export default { export default {
name: "Invoices", name: "Invoices",
components: {}, components: { UploadInvoice: () => import("@/components/UploadInvoice") },
data() { data() {
return { return {
// //
@ -585,6 +595,7 @@ export default {
// //
open: false, open: false,
accountingType: "in", accountingType: "in",
fileList: [],
// //
queryParams: { queryParams: {
pageNo: 1, pageNo: 1,
@ -678,6 +689,16 @@ export default {
}, },
methods: { methods: {
//
handleImg(list) {
this.fileList = list;
this.reset();
},
handleScan(form) {
const num = form.duplicateMark.toString();
this.form = form;
this.form.duplicateMark = num;
},
/** /**
* 文件预览 * 文件预览
* @param fileUrl * @param fileUrl
@ -841,6 +862,7 @@ export default {
this.reset(); this.reset();
this.open = true; this.open = true;
this.title = "添加发票"; this.title = "添加发票";
this.fileList = [];
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
@ -918,3 +940,10 @@ export default {
}, },
}; };
</script> </script>
<style scoped>
.el-divider__text.is-center {
font-weight: bold;
font-size: large;
}
</style>

@ -6,17 +6,27 @@
<el-row type="flex" class="mt10" justify="space-around"> <el-row type="flex" class="mt10" justify="space-around">
<el-col :span="8"></el-col> <el-col :span="8"></el-col>
<el-col :span="8" class="formTitle"> {{ title }}</el-col> <el-col :span="8" class="formTitle"> {{ title }}</el-col>
<el-col :span="8" style="text-align: right;padding-right: 20px;"> <el-col :span="8" style="text-align: right; padding-right: 20px">
<!-- <el-button type="primary" icon="el-icon-printer" size="mini" @click="handlePrint"></el-button> --> <!-- <el-button type="primary" icon="el-icon-printer" size="mini" @click="handlePrint"></el-button> -->
<el-button type="primary" plain icon="el-icon-check" size="mini" @click="submitForm" v-if="!isNewShow"></el-button> <el-button
<el-button type="primary" size="mini" @click="handleBack"></el-button> type="primary"
plain
icon="el-icon-check"
size="mini"
@click="submitForm"
v-if="!isNewShow"
>保存</el-button
>
<el-button type="primary" size="mini" @click="handleBack"
>返回</el-button
>
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
<div class="table-card table-card-content"> <div class="table-card table-card-content">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="8" class="line-rt pr-4"> <el-col :span="8" class="line-rt pr-4">
<el-form-item label="上传发票" style="margin-left: -50px;"> <el-form-item label="上传发票" style="margin-left: -50px">
<UploadImgPdf :files="fileList" @onConfirm="handleImg" /> <UploadImgPdf :files="fileList" @onConfirm="handleImg" />
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -24,48 +34,90 @@
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="发票类型" prop="invoiceType"> <el-form-item label="发票类型" prop="invoiceType">
<el-select v-model="form.invoiceType" class="wd100" size="small" placeholder="请选择" filterable> <el-select
<el-option v-for="it of typeList" :key="it.value" :value="it.value" :label="it.label"></el-option> v-model="form.invoiceType"
class="wd100"
size="small"
placeholder="请选择"
filterable
>
<el-option
v-for="it of typeList"
:key="it.value"
:value="it.value"
:label="it.label"
></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="发票代码" prop="invoiceCode"> <el-form-item label="发票代码" prop="invoiceCode">
<el-input size="small" v-model="form.invoiceCode" placeholder="请输入发票代码" /> <el-input
size="small"
v-model="form.invoiceCode"
placeholder="请输入发票代码"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="发票号码" prop="invoiceNum"> <el-form-item label="发票号码" prop="invoiceNum">
<el-input size="small" v-model="form.invoiceNum" placeholder="请输入发票号码" /> <el-input
size="small"
v-model="form.invoiceNum"
placeholder="请输入发票号码"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="开票日期" prop="invoiceDate"> <el-form-item label="开票日期" prop="invoiceDate">
<el-date-picker clearable v-model="form.invoiceDate" value-format="yyyy/MM/dd" class=" wd100" type="date" placeholder="选择开票日期" /> <el-date-picker
clearable
v-model="form.invoiceDate"
value-format="yyyy/MM/dd"
class="wd100"
type="date"
placeholder="选择开票日期"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="税额" prop="taxAmount"> <el-form-item label="税额" prop="taxAmount">
<el-input size="small" v-model="form.taxAmount" placeholder="请输入税额" /> <el-input
size="small"
v-model="form.taxAmount"
placeholder="请输入税额"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="不含税金额" prop="excludingTaxAmount"> <el-form-item label="不含税金额" prop="excludingTaxAmount">
<el-input size="small" v-model="form.excludingTaxAmount" placeholder="请输入不含税金额" /> <el-input
size="small"
v-model="form.excludingTaxAmount"
placeholder="请输入不含税金额"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="价税合计" prop="totalAmount"> <el-form-item label="价税合计" prop="totalAmount">
<el-input size="small" v-model="form.totalAmount" placeholder="请输入价税合计" /> <el-input
size="small"
v-model="form.totalAmount"
placeholder="请输入价税合计"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="销售方" prop="seller"> <el-form-item label="销售方" prop="seller">
<el-input size="small" v-model="form.seller" placeholder="请输入销售方" /> <el-input
size="small"
v-model="form.seller"
placeholder="请输入销售方"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -128,25 +180,25 @@
<script> <script>
import { createInvoice, updateInvoice, getInvoice } from "@/api/bs/invoice"; import { createInvoice, updateInvoice, getInvoice } from "@/api/bs/invoice";
import { listData } from "@/api/system/dict/data"; import { listData } from "@/api/system/dict/data";
import dayjs from 'dayjs'; import dayjs from "dayjs";
export default { export default {
name: '', name: "",
components: { components: {
UploadImgPdf: () => import('@/components/UploadImgPdf'), UploadImgPdf: () => import("@/components/UploadImgPdf"),
// printHtml: () => import('./printHtml'), // printHtml: () => import('./printHtml'),
}, },
computed: { computed: {
title() { title() {
return this.$route.query.id ? '修改我的发票' : '添加我的发票' return this.$route.query.id ? "修改我的发票" : "添加我的发票";
}, },
isNewShow() { isNewShow() {
return this.$route.query.isShow return this.$route.query.isShow;
} },
}, },
created() { created() {
this.handleInitList() this.handleInitList();
if (this.$route.query.id) { if (this.$route.query.id) {
this.handleInitForm(this.$route.query.id) this.handleInitForm(this.$route.query.id);
} }
}, },
data() { data() {
@ -162,87 +214,96 @@ export default {
// //
rules: { rules: {
files: [{ required: true, message: "附件不能为空", trigger: "blur" }], files: [{ required: true, message: "附件不能为空", trigger: "blur" }],
invoiceType: [{ required: true, message: "发票类型不能为空", trigger: "change" }], invoiceType: [
invoiceCode: [{ required: true, message: "发票代码不能为空", trigger: "blur" }], { required: true, message: "发票类型不能为空", trigger: "change" },
invoiceNum: [{ required: true, message: " 发票号码不能为空", trigger: "blur" }], ],
invoiceDate: [{ required: true, message: "开票日期不能为空", trigger: "blur" }], invoiceCode: [
{ required: true, message: "发票代码不能为空", trigger: "blur" },
],
invoiceNum: [
{ required: true, message: " 发票号码不能为空", trigger: "blur" },
],
invoiceDate: [
{ required: true, message: "开票日期不能为空", trigger: "blur" },
],
}, },
typeList: [], typeList: [],
} };
}, },
methods: { methods: {
handleImg(list) { handleImg(list) {
this.fileList = list this.fileList = list;
}, },
handleTimeChange(val) { handleTimeChange(val) {
console.log('266+6', val); console.log("266+6", val);
this.$set(this.form, 'invoiceDate', dayjs(val).format('YYYY/MM/DD')) this.$set(this.form, "invoiceDate", dayjs(val).format("YYYY/MM/DD"));
}, },
handleInitList() { handleInitList() {
listData({ listData({
pageNo: 1, pageNo: 1,
pageSize: 50, pageSize: 50,
dictType: 'bs_invoice_type', dictType: "bs_invoice_type",
}).then((res) => { }).then((res) => {
this.typeList = res.data.list || [] this.typeList = res.data.list || [];
}) });
}, },
handleBack() { handleBack() {
history.back() history.back();
}, },
handleInitForm(id) { handleInitForm(id) {
getInvoice(id).then(res => { getInvoice(id).then((res) => {
this.form = { this.form = {
...res.data || {}, ...(res.data || {}),
invoiceDate: new Date(res.data.invoiceDate) invoiceDate: new Date(res.data.invoiceDate),
} };
this.fileList = this.form.files this.fileList = this.form.files;
console.log('form...', this.form); console.log("form...", this.form);
}); });
}, },
submitForm() { submitForm() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate((valid) => {
if (!valid) { if (!valid) {
return; return;
} }
let form = { let form = {
...this.form, ...this.form,
files: this.fileList, files: this.fileList,
invoiceDate: dayjs(this.form.invoiceDate).valueOf() invoiceDate: dayjs(this.form.invoiceDate).valueOf(),
} };
// //
if (this.form.id != null) { if (this.form.id != null) {
updateInvoice(form).then(response => { updateInvoice(form).then((response) => {
// this.form = {} // this.form = {}
// this.fileList = [] // this.fileList = []
// this.$refs.form.resetFields() // this.$refs.form.resetFields()
history.back() history.back();
this.$modal.msgSuccess("修改成功!"); this.$modal.msgSuccess("修改成功!");
}); });
return; return;
} }
// //
createInvoice(form).then(response => { createInvoice(form).then((response) => {
this.$nextTick(() => { this.$nextTick(() => {
this.form = {} this.form = {};
this.fileList = [] this.fileList = [];
this.$refs.form.resetFields() this.$refs.form.resetFields();
this.$modal.msgSuccess("新增成功,本页面可以重复添加发票!如需退出,请点击返回按钮!"); this.$modal.msgSuccess(
}) "新增成功,本页面可以重复添加发票!如需退出,请点击返回按钮!"
);
});
// history.back() // history.back()
}); });
}); });
}, },
cancel() { cancel() {
this.$emit('onCancel') this.$emit("onCancel");
}, },
} },
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '@/assets/styles/form/index.scss'; @import "@/assets/styles/form/index.scss";
.my-process-designer { .my-process-designer {
background: #fff !important; background: #fff !important;
} }

Loading…
Cancel
Save