<!doctype html>
|
<html>
|
<head>
|
<meta charset="utf-8"><meta http-equiv="Expires" content="0"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-control" content="no-cache"><meta http-equiv="Cache" content="no-cache">
|
<title>发票信息</title>
|
|
<script type="text/javascript">
|
var pageVue = null;
|
function loadJsCss(callback) {
|
var jscss_urls = [];
|
window.top.initJsCss(document, jscss_urls, callback);
|
};
|
|
function initVue() {
|
new FormVue({
|
el: "#vbody",
|
data: {
|
dataname: "so_implant_detail",
|
title: "发票",
|
tabs: [
|
{code: "e_invoice", name: "数电票"},
|
{code: "o_invoice", name: "其他发票"},
|
],
|
activeTabName: "",
|
|
formAttr: {
|
istitle: false,
|
title: "表单名称",
|
columnnumber: 1,
|
labelwidth: "130px",
|
labelposition: "left",//"left",// right//top
|
size: "mini",
|
border: "10px solid #c6c6c600"
|
},
|
|
formFields_o: [
|
{isshow: "T", field: "invoiceCode", name: "发票代码", type: "input", required: true},
|
{isshow: "T", field: "invoiceNo", name: "发票号码", type: "input", required: true}, //, required: true,
|
{isshow: "T", field: "invoiceDate", name: "开票日期", type: "date", required: true},
|
{isshow: "F", field: "invoiceMoney", name: "开具金额(不含税)", type: "input", required: true},
|
{isshow: "F", field: "checkCode", name: "校验码", type: "input", placeholder: '后6位', required: true},
|
],
|
formFields_e: [
|
{isshow: "T", field: "invoiceNo", name: "发票号码", type: "input", placeholder: '电子发票号码为20位', required: true}, //, required: true,
|
{isshow: "T", field: "invoiceDate", name: "开票日期", type: "date", required: true},
|
{isshow: "T", field: "totalAmount", name: "价税合计", type: "input", required: true},
|
],
|
|
formFields: [],
|
|
newformData: {},
|
formData: {
|
invoiceCode: "",
|
invoiceNo: "",
|
invoiceDate: "",
|
invoiceMoney: "",
|
checkCode: "",
|
totalAmount: "",
|
},
|
|
//按键权限设置
|
isedit: false,//提交前编辑,保存/提交
|
isrefuseedit: false,//拒绝后编辑,保存/再次提交
|
isapproval: false,//审批,同意/拒绝/转办/退回
|
|
//弹窗参数
|
popupParames: {},
|
//字段设置
|
tablefieldClick: {},
|
formfieldClick: {},
|
loading_check: false,
|
realBillNo: "",
|
is_bill: false,
|
is_real: false,
|
ocr_invoice: {},
|
isRefresh: true,
|
},
|
created() {
|
this.popupParames = clone(Root.popupParames);
|
this.title = this.popupParames.title || this.popupParames.text
|
if (this.popupParames.data) {
|
this.formData.file_id = clone(this.popupParames.data.fileid);
|
if (this.popupParames.data.invoice_date) {
|
var invoiceDate_ = dateFormat(new Date(this.popupParames.data.invoice_date), "yyyy-MM-dd")
|
this.formData.invoiceDate = clone(invoiceDate_);
|
}
|
}
|
|
if (this.popupParames.sceneCode) {
|
if (this.popupParames.sceneCode == "add") {//新增
|
if (this.newformData) {
|
let formData_ = clone(this.formData);
|
|
for (var k in this.newformData) {
|
formData_[k] = this.newformData[k];
|
}
|
this.formData = formData_;
|
}
|
this.isedit = true;
|
}
|
else if (this.popupParames.sceneCode == "browse") {//只读
|
this.formAttr.disabled = true;
|
}
|
else if (this.popupParames.sceneCode == "edit") {//编辑
|
this.isedit = true;
|
}
|
else if (this.popupParames.sceneCode == "approval") {//审批
|
this.formAttr.disabled = true;
|
this.isapproval = true;
|
}
|
else if (this.popupParames.sceneCode == "refuseedit") {//拒绝后的编辑
|
this.isrefuseedit = true;
|
}
|
}
|
},
|
|
mounted() {
|
var me = this;
|
this.activeTabName = "e_invoice";
|
this.formFields = clone(this.formFields_e);
|
//预加载数据
|
if (this.dataRequest && this.dataRequest.length) {
|
var result = {};
|
this.loadRequestData(this.dataRequest, result, function(data) {
|
me.dataRequestObj = data;
|
//预加载数据后给哪些字段设置options或formatterjson
|
});
|
}
|
else {
|
|
}
|
|
//设置字段事件
|
me.tableFieldClick();
|
|
// 以服务的方式调用的 Loading 需要异步关闭
|
this.$nextTick(() => {
|
hideLoading();
|
|
//重新设置弹窗宽高
|
this.$nextTick(function(){
|
//let w_ = this.$refs.popup_body.offsetWidth + "px";
|
let w_ = "800px";
|
// let h_ = "400px";
|
let h_ = this.$refs.popup_body.offsetHeight + "px";
|
Root.setPopupWH(w_, h_);
|
})
|
});
|
},
|
|
methods:{
|
//关闭弹窗
|
closeDialog() {
|
var me = this;
|
if (me.popupParames.totab){
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, false);
|
}
|
else {
|
Root.hidePopup();
|
}
|
},
|
//关闭前调回调
|
saveAfter() {
|
var me = this;
|
if(this.popupParames.callback) {
|
let obj = {
|
realBillNo: me.realBillNo || "",
|
filetxt: me.ocr_invoice,
|
}
|
this.popupParames.callback(obj, function() {
|
me.closeDialog();
|
});
|
}
|
else {
|
me.closeDialog();
|
}
|
},
|
|
handleClick(tab, event) {
|
this.isRefresh = false;
|
this.activeTabName = tab.name;
|
var formData_ = {
|
invoiceCode: "",
|
invoiceNo: "",
|
invoiceDate: "",
|
invoiceMoney: "",
|
checkCode: "",
|
totalAmount: "",
|
};
|
|
if (this.popupParames.data.invoice_date) {
|
// formData_.invoiceDate = clone(this.popupParames.data.invoice_date);
|
var invoiceDate_ = dateFormat(new Date(this.popupParames.data.invoice_date), "yyyy-MM-dd")
|
formData_.invoiceDate = clone(invoiceDate_);
|
}
|
this.formData = clone(formData_);
|
this.formFields = [];
|
if (this.activeTabName == "e_invoice") { // 电子发票
|
this.formFields = clone(this.formFields_e)
|
}
|
else {
|
this.formFields = clone(this.formFields_o)
|
}
|
this.$nextTick(function(){
|
this.isRefresh = true;
|
})
|
|
},
|
|
tableFieldClick() {
|
var me = this;
|
//表格字段事件设置
|
this.tablefieldClick = {};
|
|
//表单字段事件设置
|
this.formfieldClick = {
|
invoiceCode: {//字段事件设置
|
input: {
|
onchange: function(obj) {//输入更改事件
|
if (me.activeTabName == "o_invoice") {
|
var formFields_ = clone(me.formFields);
|
if (me.formData.invoiceCode && me.formData.invoiceCode.length == 10) { // 增值税专用发票,需要填写开具金额(不含税)
|
formFields_.map(f=>{
|
if (f.field == "invoiceMoney") { // 开具金额(不含税)
|
f.isshow = "T"
|
}
|
else if (f.field == "checkCode") { // 校验码
|
f.isshow = "F"
|
}
|
})
|
}
|
else if (me.formData.invoiceCode && me.formData.invoiceCode.length == 12) {// 增值税普通发票,需要填写校验码(后六位)
|
formFields_.map(f=>{
|
if (f.field == "invoiceMoney") { // 开具金额(不含税)
|
f.isshow = "F"
|
}
|
else if (f.field == "checkCode") { // 校验码
|
f.isshow = "T"
|
}
|
})
|
}
|
else {
|
formFields_.map(f=>{
|
if (f.field == "invoiceMoney") { // 开具金额(不含税)
|
f.isshow = "F"
|
}
|
else if (f.field == "checkCode") { // 校验码
|
f.isshow = "F"
|
}
|
})
|
}
|
me.formFields = clone(formFields_);
|
}
|
}
|
},
|
},
|
};
|
},
|
|
checkInvoice() {
|
var me = this;
|
var bo = this.$refs.form1.checkForm();
|
if(!bo) {
|
Root.message({
|
type: 'error',
|
message: '请填写必填项'
|
});
|
return;
|
}
|
me.onCheckInvoive();
|
},
|
|
onCheckInvoive() {
|
var me = this;
|
me.loading_check = true;
|
let param = {
|
invoiceCode: me.formData.invoiceCode,
|
invoiceNo: me.formData.invoiceNo,
|
invoiceDate: me.formData.invoiceDate,
|
invoiceMoney: me.formData.invoiceMoney,
|
checkCode: me.formData.checkCode,
|
totalAmount: me.formData.totalAmount,
|
// id: me.formData.file_id,
|
}
|
|
Server.call("root/ocr/getInvoiceIdentifyByCode", param, function(result) {
|
console.log(result);
|
if (result.success) {
|
me.loading_check = false;
|
|
if (result && result.ocr && result.ocr.invoicelist && result.ocr.invoicelist[0]) {
|
var ocr_dataobj = result.ocr.invoicelist[0];
|
if (ocr_dataobj.is_bill) {
|
// var content = JSON.parse(decodeURI(result.ocr.content));
|
// var content = JSON.parse(result.ocr.content);
|
|
if (ocr_dataobj.is_distinct && (ocr_dataobj.invoice_status == "normal" || ocr_dataobj.invoice_status == "partialRedOffset")) {
|
me.ocr_invoice = clone(ocr_dataobj);
|
me.saveAfter();
|
}
|
else {
|
if (!ocr_dataobj.is_distinct) {
|
Root.message({
|
type: 'error',
|
message: '发票已经被上报,不能再次上报'
|
});
|
}
|
else {
|
var cancelMarkMap = {
|
"normal": "正常",
|
"outOfControl": "失控",
|
"invalid": "作废",
|
"redOffset": "红冲",
|
"exceptional": "异常",
|
"abnormal": "非正常",
|
"redInvoice": "红字发票待确认",
|
"partialRedOffset": "部分红冲",
|
"allRedOffsets": "全部红冲"
|
}
|
Root.message({
|
type: 'error',
|
message: '查验为' + cancelMarkMap[ocr_dataobj.invoice_status] + '发票,不能上报'
|
});
|
}
|
|
|
}
|
}
|
else if (!ocr_dataobj.is_bill) {
|
// Root.message({
|
// type: 'error',
|
// message: ocr_dataobj.description
|
// });
|
// invoice_status: "notKnow"
|
var content = JSON.parse(result.ocr.content);
|
var formData_ = clone(me.formData);
|
|
if (content && content.description) {
|
content.description.replace("【编辑】","【取消】")
|
}
|
Root.confirm(content.description + ',继续仅返回录入信息', '识别失败', {
|
confirmButtonText: '继续',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
me.ocr_invoice = {
|
code: me.formData.invoiceCode, // 发票代码
|
number: me.formData.invoiceNo, // 发票号码
|
invoice_date: me.formData.invoiceDate, // 开票日期
|
check_code: me.formData.checkCode, // 校验码
|
invoice_status: "exceptional", //
|
};
|
me.saveAfter();
|
}).catch(() => {
|
|
});
|
|
}
|
else {
|
Root.message({
|
type: 'error',
|
message: '查验为假发票'
|
});
|
// me.realBillNo = "";
|
}
|
// me.realBillNo = result.data.ocr.billno;
|
// if (result.data && result.data.ocr && result.data.ocr.is_repeat) {
|
// me.realBillNo = result.data.ocr.billno + "重复";
|
// }
|
} else {
|
// Root.message({
|
// type: 'error',
|
// message: '识别失败'
|
// });
|
// me.realBillNo = "";
|
var content = JSON.parse(result.ocr.content);
|
var formData_ = clone(me.formData);
|
if (content && content.description) {
|
content.description.replace("【编辑】","【取消】")
|
}
|
Root.confirm(content.description + ',继续仅返回录入信息', '识别失败', {
|
confirmButtonText: '继续',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
me.ocr_invoice = {
|
code: me.formData.invoiceCode, // 发票代码
|
number: me.formData.invoiceNo, // 发票号码
|
invoice_date: me.formData.invoiceDate, // 开票日期
|
check_code: me.formData.checkCode, // 校验码
|
invoice_status: "exceptional", //
|
};
|
me.saveAfter();
|
}).catch(() => {
|
|
});
|
|
}
|
// me.saveAfter();
|
}
|
}, function(errorresult) {
|
console.log("错误信息", errorresult);
|
me.loading_check = false;
|
if (errorresult.messages && errorresult.messages.count && errorresult.messages.count.error) {
|
if (errorresult.messages.list) {
|
var config = {
|
totab: false,
|
icon: "icon-product",
|
text: "错误信息",
|
url: "module/tool/page/popup_error_messages.html",
|
data: "",
|
delta: errorresult.messages.list,
|
callback: function(obj, callback) {
|
if (callback) {
|
callback();
|
}
|
}
|
};
|
me.doPopupByPublic(config);
|
}
|
}
|
else {
|
Root.message({
|
type: 'error',
|
message: '查验失败'
|
});
|
}
|
});
|
},
|
}
|
});
|
};
|
|
loadJsCss(function () {
|
initVue();
|
});
|
</script>
|
<style>
|
/* 在vue.js中 v-cloak 这个指令是防止页面加载时出现 vuejs 的变量名而设计的 */
|
[v-cloak] {
|
display: none !important;
|
}
|
</style>
|
|
</head>
|
|
<body style="margin: 0px;">
|
<div v-cloak id="vbody">
|
<div id="page_root">
|
<div ref="popup_body" style="padding: 0 20px;">
|
<div class="popup_el-dialog__header">
|
<div class="dialog-title">
|
<i class="iconfont icon-customermanagement"></i>
|
<span> {{title}}</span>
|
</div>
|
</div>
|
<div style="height:350px; overflow-y: auto;">
|
<div>
|
<el-tabs v-model="activeTabName" @tab-click="handleClick">
|
<el-tab-pane v-for="(tab, k) in tabs" :label="tab.name" :name="tab.code" :key="k"></el-tab-pane>
|
</el-tabs>
|
</div>
|
<div class="el-dialog__body" v-if="isRefresh">
|
<h-form
|
ref="form1"
|
:form-attr="formAttr"
|
:table-fields="formFields"
|
:form-data="formData"
|
:table-field-click="formfieldClick"
|
>
|
</h-form>
|
</div>
|
</div>
|
<div class="el-dialog__footer">
|
<el-button size="small" type="default" @click="closeDialog">取 消</el-button>
|
<el-button size="small" v-if="isedit || isrefuseedit" type="primary" @click="checkInvoice" :loading="loading_check">查验发票</el-button>
|
</div>
|
</div>
|
</div>
|
</div>
|
|
<div id="page_loading" style="position: absolute; top:0px; width: 100vw; height: 50vh;">
|
<div class="spinner">
|
<div class="cube1"></div>
|
<div class="cube2"></div>
|
</div>
|
</div>
|
</body>
|
</html>
|