2 Commit-ok e6cac0e5ed ... bae8a7c382

Szerző SHA1 Üzenet Dátum
  Your Name bae8a7c382 屏蔽图片文件夹 5 éve
  Your Name 83e79b4c77 修改种植、销售 5 éve
4 módosított fájl, 77 hozzáadás és 7 törlés
  1. 5 2
      .gitignore
  2. 2 0
      apps/AppInfo/models.py
  3. 3 1
      apps/Equipment/urls.py
  4. 67 4
      apps/Equipment/views.py

+ 5 - 2
.gitignore

@@ -68,5 +68,8 @@ docs/_build/
 /map_photo/
 /.vscode/
 # PyBuilder
-target/
-
+/target/
+/sell_photo/
+/crop_photo/
+/sightsee_photos/
+/user_photo/

+ 2 - 0
apps/AppInfo/models.py

@@ -683,6 +683,7 @@ class Sell_Manage(models.Model):
     num = models.CharField(u'数量', max_length=20, blank=True, null=True)
     money = models.CharField(u'金额', max_length=20, blank=True, null=True)
     upl_time = models.DateTimeField(u'创建时间', blank=True, null=True)
+    sell_img = models.CharField(u'销售图片', max_length=200, blank=True, null=True)
 
     class Meta:
         verbose_name = '销售管理'
@@ -717,6 +718,7 @@ class Areacrop(models.Model):
     crop_count = models.CharField(u'作物数量', max_length=20, blank=True, null=True)
     upl_time = models.DateTimeField(u'种植时间', blank=True, null=True)
     end_time = models.DateTimeField(u'结束时间', blank=True, null=True)
+    crop_img = models.CharField(u'作物图片', max_length=200, blank=True, null=True)
 
     class Meta:
         verbose_name = '区域作物表'

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 3 - 1
apps/Equipment/urls.py


+ 67 - 4
apps/Equipment/views.py

@@ -2485,6 +2485,33 @@ class Sell_Land(ListView):
         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):
     def get(self,request):
@@ -2514,7 +2541,8 @@ class Sell_View(ListView):
                         "id":x.id,
                         "farm":x.farm.name,"name":x.name,
                         "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:
             print(e)
@@ -2537,6 +2565,7 @@ class Sell_New(ListView):
         money = request.POST.get("money")
         time = request.POST.get("time")
         s_id = request.POST.get("id")
+        sell_img = request.POST.get("sell_img")
         username = request.user.id
         
         if s_id:
@@ -2548,6 +2577,7 @@ class Sell_New(ListView):
                 sell_obj.num = num
                 sell_obj.money = money
                 sell_obj.upl_time = time
+                sell_obj.sell_img = sell_img
                 sell_obj.save()
                 data = "1"
             except Exception as e:
@@ -2556,7 +2586,7 @@ class Sell_New(ListView):
         else:
             try:
                 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"
             except Exception as e:
                 print(e)
@@ -2616,6 +2646,7 @@ class CropCount(ListView):
         upl_time = request.POST.get("upl_time")
         cropname = request.POST.get('cropname')
         city = request.POST.get("city")
+        crop_img = request.POST.get("crop_img")
         count=crop_count + city
         print(count)
         #修改
@@ -2628,6 +2659,7 @@ class CropCount(ListView):
                     area=crops,
                     upl_time=upl_time,
                     crop_count=count,
+                    crop_img=crop_img,
                 )
                 data = "1"
             except Exception as e:
@@ -2643,6 +2675,7 @@ class CropCount(ListView):
                     area=crops,
                     upl_time=upl_time,
                     crop_count=count,
+                    crop_img=crop_img,
                 )
                 data = "1"
             except Exception as e:
@@ -2652,6 +2685,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):
@@ -2678,7 +2738,8 @@ class CropCount_View(ListView):
                         "img":x.area.farm_img,
                         "time":data,
                         "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})
         nums = len(dat)
@@ -2705,7 +2766,9 @@ class CropCount_View(ListView):
                     "area":i.area.name,
                     "crop_count":i.crop_count,
                     "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":