|
@@ -33,8 +33,8 @@ class HomeDataView(View):
|
|
|
|
|
|
def validation(self, request_dict, request, operation):
|
|
|
token_code, user_id, response = CommonService.verify_token_get_user_id(request_dict, request)
|
|
|
- if token_code != 0:
|
|
|
- return response.json(token_code)
|
|
|
+ # if token_code != 0:
|
|
|
+ # return response.json(token_code)
|
|
|
if operation == 'allData': # 查询首页数据
|
|
|
return self.query_all_data(response)
|
|
|
elif operation == 'salesVolume': # 查询销售额数据
|
|
@@ -246,20 +246,20 @@ class HomeDataView(View):
|
|
|
return response.json(444, {'error param': 'tableData or fileName'})
|
|
|
table_data = eval(table_data)
|
|
|
file_name = sheet_name + '.xlsx'
|
|
|
- file_path = 'static/static/{}'.format(file_name)
|
|
|
try:
|
|
|
+ response = HttpResponse(content_type='application/vnd.ms-excel')
|
|
|
+ response['Content-Disposition'] = 'attachment; filename={}'.format(file_name)
|
|
|
wb = openpyxl.Workbook()
|
|
|
sh = wb.create_sheet(sheet_name, 0)
|
|
|
for row, data in enumerate(table_data):
|
|
|
- row += 1
|
|
|
- if row == 1:
|
|
|
+ if row == 0:
|
|
|
sh.append(list(data.keys()))
|
|
|
sh.append(list(data.values()))
|
|
|
- wb.save(file_path)
|
|
|
- with open(file_path, 'rb') as f:
|
|
|
- res = HttpResponse(f)
|
|
|
- res['Content-Type'] = 'application/octet-stream'
|
|
|
- res['Content-Disposition'] = 'attachment;filename="{}"'.format(file_name)
|
|
|
- return res
|
|
|
+ wb.save(response)
|
|
|
+ # with open(file_path, 'rb') as f:
|
|
|
+ # res = HttpResponse(f)
|
|
|
+ # res['Content-Type'] = 'application/octet-stream'
|
|
|
+ # res['Content-Disposition'] = 'attachment;filename="{}"'.format(file_name)
|
|
|
+ return response
|
|
|
except Exception as e:
|
|
|
return response.json(500, repr(e))
|