|
@@ -2443,6 +2443,33 @@ class Sell_Land(ListView):
|
|
|
return HttpResponse(data)
|
|
return HttpResponse(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+#销售图片
|
|
|
|
|
+class Sell_Photo(ListView):
|
|
|
|
|
+ def post(self,request):
|
|
|
|
|
+ gar_photo = request.FILES.get('gar_img')
|
|
|
|
|
+ if gar_photo:
|
|
|
|
|
+ print("视频图片:", gar_photo)
|
|
|
|
|
+ garden_photo_dir = 'sell_photo/'
|
|
|
|
|
+ end_name = gar_photo.name.split('.')[-1]
|
|
|
|
|
+ # 判断如果路径不存在,即创建路径
|
|
|
|
|
+ if os.path.exists(garden_photo_dir) == False:
|
|
|
|
|
+ os.makedirs(garden_photo_dir)
|
|
|
|
|
+ img = Image.open(gar_photo)
|
|
|
|
|
+ now_time = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
|
|
|
|
|
+ pic_name = now_time + '.' + end_name
|
|
|
|
|
+ print("pic_name:", pic_name)
|
|
|
|
|
+ img.save(garden_photo_dir + pic_name)
|
|
|
|
|
+ gar_photo = garden_photo_dir + pic_name
|
|
|
|
|
+ print("gar_photo:",gar_photo)
|
|
|
|
|
+ data = {"code": 0,"msg": "","data": {"src": gar_photo}}
|
|
|
|
|
+ else:
|
|
|
|
|
+ pro_photo = "0"
|
|
|
|
|
+ data = {"code": 404,"msg": "","data": {"src": gar_photo}}
|
|
|
|
|
+ data = json.dumps(data)
|
|
|
|
|
+ return HttpResponse(data)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
# 销售管理
|
|
# 销售管理
|
|
|
class Sell_View(ListView):
|
|
class Sell_View(ListView):
|
|
|
def get(self,request):
|
|
def get(self,request):
|
|
@@ -2472,7 +2499,8 @@ class Sell_View(ListView):
|
|
|
"id":x.id,
|
|
"id":x.id,
|
|
|
"farm":x.farm.name,"name":x.name,
|
|
"farm":x.farm.name,"name":x.name,
|
|
|
"num":x.num,"money":x.money,
|
|
"num":x.num,"money":x.money,
|
|
|
- "time":x.upl_time.strftime('%Y-%m-%d')
|
|
|
|
|
|
|
+ "time":x.upl_time.strftime('%Y-%m-%d'),
|
|
|
|
|
+ "sell_img":x.sell_img
|
|
|
})
|
|
})
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
print(e)
|
|
print(e)
|
|
@@ -2495,6 +2523,7 @@ class Sell_New(ListView):
|
|
|
money = request.POST.get("money")
|
|
money = request.POST.get("money")
|
|
|
time = request.POST.get("time")
|
|
time = request.POST.get("time")
|
|
|
s_id = request.POST.get("id")
|
|
s_id = request.POST.get("id")
|
|
|
|
|
+ sell_img = request.POST.get("sell_img")
|
|
|
username = request.user.id
|
|
username = request.user.id
|
|
|
|
|
|
|
|
if s_id:
|
|
if s_id:
|
|
@@ -2506,6 +2535,7 @@ class Sell_New(ListView):
|
|
|
sell_obj.num = num
|
|
sell_obj.num = num
|
|
|
sell_obj.money = money
|
|
sell_obj.money = money
|
|
|
sell_obj.upl_time = time
|
|
sell_obj.upl_time = time
|
|
|
|
|
+ sell_obj.sell_img = sell_img
|
|
|
sell_obj.save()
|
|
sell_obj.save()
|
|
|
data = "1"
|
|
data = "1"
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
@@ -2514,7 +2544,7 @@ class Sell_New(ListView):
|
|
|
else:
|
|
else:
|
|
|
try:
|
|
try:
|
|
|
farm_obj = FarmList.objects.get(name=farm,user=username)
|
|
farm_obj = FarmList.objects.get(name=farm,user=username)
|
|
|
- Sell_Manage.objects.create(farm=farm_obj,name=name,num=num,money=money,upl_time=time)
|
|
|
|
|
|
|
+ Sell_Manage.objects.create(farm=farm_obj,name=name,num=num,money=money,upl_time=time,sell_img=sell_img)
|
|
|
data = "1"
|
|
data = "1"
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
print(e)
|
|
print(e)
|
|
@@ -2574,6 +2604,7 @@ class CropCount(ListView):
|
|
|
upl_time = request.POST.get("upl_time")
|
|
upl_time = request.POST.get("upl_time")
|
|
|
cropname = request.POST.get('cropname')
|
|
cropname = request.POST.get('cropname')
|
|
|
city = request.POST.get("city")
|
|
city = request.POST.get("city")
|
|
|
|
|
+ crop_img = request.POST.get("crop_img")
|
|
|
count=crop_count + city
|
|
count=crop_count + city
|
|
|
print(count)
|
|
print(count)
|
|
|
#修改
|
|
#修改
|
|
@@ -2586,6 +2617,7 @@ class CropCount(ListView):
|
|
|
area=crops,
|
|
area=crops,
|
|
|
upl_time=upl_time,
|
|
upl_time=upl_time,
|
|
|
crop_count=count,
|
|
crop_count=count,
|
|
|
|
|
+ crop_img=crop_img,
|
|
|
)
|
|
)
|
|
|
data = "1"
|
|
data = "1"
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
@@ -2601,6 +2633,7 @@ class CropCount(ListView):
|
|
|
area=crops,
|
|
area=crops,
|
|
|
upl_time=upl_time,
|
|
upl_time=upl_time,
|
|
|
crop_count=count,
|
|
crop_count=count,
|
|
|
|
|
+ crop_img=crop_img,
|
|
|
)
|
|
)
|
|
|
data = "1"
|
|
data = "1"
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
@@ -2610,6 +2643,33 @@ class CropCount(ListView):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+#种植管理
|
|
|
|
|
+class CropCount_Photo(ListView):
|
|
|
|
|
+ def get(self,request):
|
|
|
|
|
+ pass
|
|
|
|
|
+ def post(self,request):
|
|
|
|
|
+ gar_photo = request.FILES.get('gar_img')
|
|
|
|
|
+ if gar_photo:
|
|
|
|
|
+ print("视频图片:", gar_photo)
|
|
|
|
|
+ garden_photo_dir = 'cropcount_photo/'
|
|
|
|
|
+ end_name = gar_photo.name.split('.')[-1]
|
|
|
|
|
+ # 判断如果路径不存在,即创建路径
|
|
|
|
|
+ if os.path.exists(garden_photo_dir) == False:
|
|
|
|
|
+ os.makedirs(garden_photo_dir)
|
|
|
|
|
+ img = Image.open(gar_photo)
|
|
|
|
|
+ now_time = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
|
|
|
|
|
+ pic_name = now_time + '.' + end_name
|
|
|
|
|
+ print("pic_name:", pic_name)
|
|
|
|
|
+ img.save(garden_photo_dir + pic_name)
|
|
|
|
|
+ gar_photo = garden_photo_dir + pic_name
|
|
|
|
|
+ print("gar_photo:",gar_photo)
|
|
|
|
|
+ data = {"code": 0,"msg": "","data": {"src": gar_photo}}
|
|
|
|
|
+ else:
|
|
|
|
|
+ pro_photo = "0"
|
|
|
|
|
+ data = {"code": 404,"msg": "","data": {"src": gar_photo}}
|
|
|
|
|
+ data = json.dumps(data)
|
|
|
|
|
+ return HttpResponse(data)
|
|
|
|
|
+
|
|
|
|
|
|
|
|
# 种植管理
|
|
# 种植管理
|
|
|
class CropCount_View(ListView):
|
|
class CropCount_View(ListView):
|
|
@@ -2636,7 +2696,8 @@ class CropCount_View(ListView):
|
|
|
"img":x.area.farm_img,
|
|
"img":x.area.farm_img,
|
|
|
"time":data,
|
|
"time":data,
|
|
|
"id":x.id,
|
|
"id":x.id,
|
|
|
- "upl_time":x.upl_time.strftime('%Y-%m-%d')
|
|
|
|
|
|
|
+ "upl_time":x.upl_time.strftime('%Y-%m-%d'),
|
|
|
|
|
+ "crop_img":x.crop_img,
|
|
|
}
|
|
}
|
|
|
dat.append({"data":h2,"curro":curro})
|
|
dat.append({"data":h2,"curro":curro})
|
|
|
nums = len(dat)
|
|
nums = len(dat)
|
|
@@ -2663,7 +2724,9 @@ class CropCount_View(ListView):
|
|
|
"area":i.area.name,
|
|
"area":i.area.name,
|
|
|
"crop_count":i.crop_count,
|
|
"crop_count":i.crop_count,
|
|
|
"cropname":i.cropname,
|
|
"cropname":i.cropname,
|
|
|
- "upl_time":i.upl_time.strftime('%Y-%m-%d')
|
|
|
|
|
|
|
+ "upl_time":i.upl_time.strftime('%Y-%m-%d'),
|
|
|
|
|
+ "crop_img":i.crop_img,
|
|
|
|
|
+
|
|
|
})
|
|
})
|
|
|
#删除
|
|
#删除
|
|
|
elif req == "del":
|
|
elif req == "del":
|