|
@@ -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': # 查询销售额数据
|
|
@@ -247,19 +247,19 @@ class HomeDataView(View):
|
|
|
table_data = eval(table_data)
|
|
|
file_name = sheet_name + '.xlsx'
|
|
|
try:
|
|
|
- response = HttpResponse(content_type='application/vnd.ms-excel')
|
|
|
- response['Content-Disposition'] = 'attachment; filename={}'.format(file_name)
|
|
|
+ res = HttpResponse(content_type='application/vnd.ms-excel')
|
|
|
+ res['Content-Disposition'] = 'attachment; filename={}'.format(file_name)
|
|
|
wb = openpyxl.Workbook()
|
|
|
sh = wb.create_sheet(sheet_name, 0)
|
|
|
for row, data in enumerate(table_data):
|
|
|
if row == 0:
|
|
|
sh.append(list(data.keys()))
|
|
|
sh.append(list(data.values()))
|
|
|
- wb.save(response)
|
|
|
+ wb.save(res)
|
|
|
# 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
|
|
|
+ return res
|
|
|
except Exception as e:
|
|
|
return response.json(500, repr(e))
|