refactor(webapp): 优化发票查验组件布局和功能
-调整发票代码输入框位置,移到发票类型下方 -修复文件上传服务中的错误提示信息 - 优化文件哈希计算方法,改为静态方法 - 更新后端接口命名,使用下划线风格 - 调整发票列表展示字段,将销方信息移到上方
This commit is contained in:
parent
813a317ff6
commit
1170d5238a
@ -2,7 +2,6 @@
|
||||
from typing import Any
|
||||
|
||||
from flask import Request
|
||||
from werkzeug.datastructures import FileStorage
|
||||
from werkzeug.utils import secure_filename
|
||||
import os , time, hashlib
|
||||
from alibabacloud_sample.dataservice import DataService
|
||||
@ -18,10 +17,10 @@ class FileService:
|
||||
if request.method == 'POST':
|
||||
# 检查是否有文件在请求中
|
||||
if 'file' not in request.files:
|
||||
return 'No file part'
|
||||
return '没有文件被上传'
|
||||
file = request.files['file']
|
||||
if file.filename == '':
|
||||
return 'No selected file'
|
||||
return '请重新选择文件'
|
||||
if file:
|
||||
date = time.strftime("%Y%m%d", time.localtime())
|
||||
filetype = secure_filename(file.filename)
|
||||
@ -30,7 +29,7 @@ class FileService:
|
||||
os.makedirs(os.path.dirname(filepath), exist_ok=True)
|
||||
file.save(filepath)
|
||||
file_size = os.path.getsize(filepath)
|
||||
file_hash = self.getHash(filepath)
|
||||
file_hash = self.get_hash(filepath)
|
||||
v_file = dataservice.get_file(file_hash,file_size)
|
||||
if v_file:
|
||||
os.remove(filepath)
|
||||
@ -39,8 +38,11 @@ class FileService:
|
||||
v_file = dataservice.insert_file_data(file.filename, filepath, file_size, filetype, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),file_hash)
|
||||
print("insert v_file:", v_file)
|
||||
return v_file
|
||||
return None
|
||||
|
||||
# 获取文件md5
|
||||
def getHash(self, file_path: str) -> str:
|
||||
@staticmethod
|
||||
def get_hash(file_path: str) -> str:
|
||||
with open(file_path, 'rb') as f:
|
||||
md5 = hashlib.md5()
|
||||
while True:
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
|
||||
|
||||
from flask import Flask, request, render_template, send_from_directory
|
||||
from flask_cors import CORS
|
||||
from alibabacloud_sample.dataservice import DataService
|
||||
from alibabacloud_sample.fileservice import FileService
|
||||
from alibabacloud_sample.service import Service
|
||||
from dateutil import parser
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app)
|
||||
app.config['UPLOAD_FOLDER'] = 'uploads' # 指定上传文件夹
|
||||
@ -66,22 +64,22 @@ def reverify():
|
||||
return service.verify(data=data,file_path=file_path,reverify=True)
|
||||
# 发票列表
|
||||
@app.route('/listInvoice',methods=['POST'])
|
||||
def listInvoice():
|
||||
def list_invoice():
|
||||
value = request.form.get('value')
|
||||
verify_status = request.form.get('verifyStatus')
|
||||
return dataservice.get_invoice_list(value=value,verify_status=verify_status)
|
||||
@app.route('/listInvoiceTimeOut',methods=['POST'])
|
||||
def listInvoiceTimeOut():
|
||||
def list_invoice_time_out():
|
||||
time_out = request.form.get('timeOut')
|
||||
return dataservice.get_invoice_list(value='',verify_status='',time_out=time_out)
|
||||
# 发票日志列表
|
||||
@app.route('/listLogs',methods=['GET'])
|
||||
def listLogs():
|
||||
def list_logs():
|
||||
file_path = request.args.get('filePath')
|
||||
return dataservice.get_verify_log_list(file_path=file_path)
|
||||
# 更新发票标注
|
||||
@app.route('/updateInvoice',methods=['POST'])
|
||||
def updateInvoice():
|
||||
def update_invoice():
|
||||
invoice_id = request.form.get('invoiceId')
|
||||
status = request.form.get('status')
|
||||
desc = request.form.get('desc')
|
||||
|
||||
@ -24,9 +24,7 @@
|
||||
@finish="onFinish"
|
||||
@finishFailed="onFinishFailed"
|
||||
>
|
||||
<a-form-item label="发票代码">
|
||||
<a-input v-model:value="formState.invoiceCode" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="发票类型">
|
||||
<a-input v-model:value="formState.invoiceType" />
|
||||
</a-form-item>
|
||||
@ -57,6 +55,9 @@
|
||||
<a-form-item label="购方税号">
|
||||
<a-input v-model:value="formState.purchaserTaxNumber" />
|
||||
</a-form-item>
|
||||
<a-form-item label="发票代码">
|
||||
<a-input v-model:value="formState.invoiceCode" />
|
||||
</a-form-item>
|
||||
<!-- <a-form-item >-->
|
||||
<!-- <a-row>-->
|
||||
<!-- <a-col :span="12" offset="24">-->
|
||||
|
||||
@ -15,6 +15,16 @@ const columns = [
|
||||
dataIndex: 'invoiceNumber',
|
||||
key: 'invoiceNumber',
|
||||
},
|
||||
{
|
||||
title: '销方名称',
|
||||
dataIndex: 'sellerName',
|
||||
key: 'sellerName',
|
||||
},
|
||||
{
|
||||
title: '销方税号',
|
||||
dataIndex: 'sellerTaxNumber',
|
||||
key: 'sellerTaxNumber',
|
||||
},
|
||||
{
|
||||
title: '不含税金额',
|
||||
dataIndex: 'invoiceAmountPreTax',
|
||||
@ -35,16 +45,7 @@ const columns = [
|
||||
dataIndex: 'invoiceDate',
|
||||
key: 'invoiceDate',
|
||||
},
|
||||
{
|
||||
title: '销方名称',
|
||||
dataIndex: 'sellerName',
|
||||
key: 'sellerName',
|
||||
},
|
||||
{
|
||||
title: '销方税号',
|
||||
dataIndex: 'sellerTaxNumber',
|
||||
key: 'sellerTaxNumber',
|
||||
},
|
||||
|
||||
{
|
||||
title: '查验结果',
|
||||
dataIndex: 'cyjgxx',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user