response js_code
This commit is contained in:
@ -1,3 +1,6 @@
|
||||
body {
|
||||
background-color: azure;
|
||||
}
|
||||
main {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
|
@ -7,8 +7,9 @@
|
||||
<a href="/"><button type="button">返回</button></a>
|
||||
<div></div><div></div>
|
||||
</div>
|
||||
<hr>
|
||||
<form method=post enctype=multipart/form-data action="/import">
|
||||
<div><input style="width:300px;" type=file name=选择></div>
|
||||
<div><input style="width:300px;" type=file name=file></div>
|
||||
<div class="handler"><div></div><input style="width:100px;"type=submit value=上传></div>
|
||||
</form>
|
||||
<div>
|
||||
|
@ -21,9 +21,16 @@ def index():
|
||||
@app.route('/check', methods=['GET'])
|
||||
def check():
|
||||
inventory = Inventory.query.filter_by(checked=False).first()
|
||||
print(inventory)
|
||||
if not inventory:
|
||||
return "All checked"
|
||||
js_code = '''
|
||||
<script>
|
||||
alert("未导入Excel或已完成!");
|
||||
location.href="https://a.yum2.cc";
|
||||
</script>
|
||||
'''
|
||||
response = make_response(js_code)
|
||||
response.headers['Content-Type'] = 'application/javascript'
|
||||
return response
|
||||
return render_template('check.html',inventory=inventory)
|
||||
|
||||
@app.route('/get_inventory', methods=['POST'])
|
||||
@ -90,7 +97,15 @@ def import_file():
|
||||
file_path = 'data.xlsx'
|
||||
file.save(file_path)
|
||||
import_from_xlsx(file_path)
|
||||
return '<script>alert("文件导入成功!");location.href="https://a.yum2.cc";</script>'
|
||||
js_code = '''
|
||||
<script>
|
||||
alert("文件导入成功!");
|
||||
location.href="https://a.yum2.cc";
|
||||
</script>
|
||||
'''
|
||||
response = make_response(js_code)
|
||||
response.headers['Content-Type'] = 'application/javascript'
|
||||
return response
|
||||
|
||||
return redirect(url_for('upload_form'))
|
||||
|
||||
@ -108,7 +123,7 @@ def download_xlsx():
|
||||
# 设置工作表名称
|
||||
ws.title = "Inventory"
|
||||
# 设置工作表列名
|
||||
ws.append(["sort", "location", "tag", "amount", "checked"])
|
||||
ws.append(["序号", "位置", "标签", "数量", "已确认"])
|
||||
# 写入数据
|
||||
for inventory in inventorys:
|
||||
ws.append([inventory.sort, inventory.location, inventory.tag, inventory.amount, inventory.checked])
|
||||
|
Reference in New Issue
Block a user