response js_code
This commit is contained in:
@ -1,3 +1,6 @@
|
|||||||
|
body {
|
||||||
|
background-color: azure;
|
||||||
|
}
|
||||||
main {
|
main {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
@ -21,9 +21,16 @@ def index():
|
|||||||
@app.route('/check', methods=['GET'])
|
@app.route('/check', methods=['GET'])
|
||||||
def check():
|
def check():
|
||||||
inventory = Inventory.query.filter_by(checked=False).first()
|
inventory = Inventory.query.filter_by(checked=False).first()
|
||||||
print(inventory)
|
|
||||||
if not 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)
|
return render_template('check.html',inventory=inventory)
|
||||||
|
|
||||||
@app.route('/get_inventory', methods=['POST'])
|
@app.route('/get_inventory', methods=['POST'])
|
||||||
@ -90,7 +97,15 @@ def import_file():
|
|||||||
file_path = 'data.xlsx'
|
file_path = 'data.xlsx'
|
||||||
file.save(file_path)
|
file.save(file_path)
|
||||||
import_from_xlsx(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'))
|
return redirect(url_for('upload_form'))
|
||||||
|
|
||||||
@ -108,7 +123,7 @@ def download_xlsx():
|
|||||||
# 设置工作表名称
|
# 设置工作表名称
|
||||||
ws.title = "Inventory"
|
ws.title = "Inventory"
|
||||||
# 设置工作表列名
|
# 设置工作表列名
|
||||||
ws.append(["sort", "location", "tag", "amount", "checked"])
|
ws.append(["序号", "位置", "标签", "数量", "已确认"])
|
||||||
# 写入数据
|
# 写入数据
|
||||||
for inventory in inventorys:
|
for inventory in inventorys:
|
||||||
ws.append([inventory.sort, inventory.location, inventory.tag, inventory.amount, inventory.checked])
|
ws.append([inventory.sort, inventory.location, inventory.tag, inventory.amount, inventory.checked])
|
||||||
|
Reference in New Issue
Block a user