ソースを参照

Merge branch 'master' of http://39.104.94.153:3000/yf_zd/second

yf_ymm 5 年 前
コミット
fbdc28054b

+ 1 - 1
apps/AppInfo/models.py

@@ -539,7 +539,7 @@ class Store_Manage(models.Model):
 # 区域种植统计
 class Areacrop(models.Model):
     cropname = models.CharField(u'作物名称', max_length=20, blank=True, null=True)
-    area = models.ForeignKey(GardenArea,blank=True, null=True,verbose_name=u'所属地块')
+    area = models.ForeignKey(FarmList,blank=True, null=True,verbose_name=u'所属地块')
     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)

+ 38 - 29
apps/Equipment/views.py

@@ -2027,10 +2027,10 @@ class Park_Land(ListView):
         data = []
         if current_user.is_superuser != True and current_user.is_staff != True:
             #用户
-            art_list = GardenArea.objects.filter(user=current_user)
+            art_list = FarmList.objects.filter(user=current_user)
         else:
             #管理员
-            art_list = GardenArea.objects.all()
+            art_list = FarmList.objects.all()
         for i in art_list:
             data.append({"name":i.name,"id":i.id})
         data = json.dumps(data)
@@ -2048,7 +2048,7 @@ class Garden_Manage_New(ListView):
         garden = GardenArea.objects.get(id=gardenid)
         art_list = FarmList.objects.filter(garden=garden)
 
-        nums = art_list.count()
+        nums = len(art_list)
         page = int(request.GET.get('page'))
         art = art_list[(9*(page-1)):(page*9)]
         return render(request, 'backstageNet/production/gardenNew.html', context={"art":art,"nums":nums})
@@ -2085,25 +2085,19 @@ class Garden_Manage_New(ListView):
                         })
         #删除数据  
         if req == 'del':
-            pickid = Pick_Pub.objects.filter(farm=farm_id)
-            storeid = Store_Manage.objects.filter(farm=farm_id)
-            art = FarmList.objects.get(id=farm_id)
-            if pickid.count() ==0 and storeid.count() ==0:
-                art.delete()
-                data="1"
-            elif pickid.count() !=0 and storeid.count() ==0:
-                pickid.delete()
-                art.delete()
-                data="1"
-            elif pickid.count()  ==0 and storeid.count()  !=0:
-                storeid.delete()
-                art.delete()
-                data="1"
-            elif pickid.count()  !=0 and storeid.count()  !=0:
-                pickid.delete()
-                storeid.delete()
-                art.delete()
-                data="1"
+            try:
+                Pick_Pub.objects.filter(farm=farm_id).delete()
+                FarmList.objects.filter(id=farm_id).delete()
+                data = "1"
+            except:
+                data = "0"
+            # if len(pickid) == 0:
+            #     art.delete()
+            #     data="1"
+            # elif len(pickid) != 0:
+            #     pickid.delete()
+            #     art.delete()
+            #     data="1"
         data = json.dumps(data,ensure_ascii=False)
         return HttpResponse(data)
             
@@ -2467,7 +2461,7 @@ 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 %H:%M:%S')
+                        "time":x.upl_time.strftime('%Y-%m-%d')
                     })
         except Exception as e:
             print(e)
@@ -2545,7 +2539,22 @@ class Cropdata(ListView):
 # 种植统计
 class CropCount(ListView):
     def get(self,request):
-        return render(request, 'backstageNet/production/cropcount.html', context={})
+        username = request.user.username
+        print('username:',username)
+        current_user = MyUser.objects.get(username=username)
+        gardenname = request.GET.get("name")
+        if current_user.is_staff == True:
+            garden = GardenArea.objects.all()
+        elif current_user.is_staff != True:
+            garden = GardenArea.objects.filter(user=current_user)
+        if gardenname:
+            garden = GardenArea.objects.filter(name=gardenname)
+        farm = FarmList.objects.filter(garden=garden[0])
+        if current_user.is_staff == True:
+            garden = GardenArea.objects.all()
+        elif current_user.is_staff != True:
+            garden = GardenArea.objects.filter(user=current_user)
+        return render(request, 'backstageNet/production/cropcount.html', context={"garden":garden,"farm":farm})
     def post(self,request):
         username = request.user.username
         crop_count = request.POST.get('crop_count')
@@ -2560,7 +2569,7 @@ class CropCount(ListView):
         if crop_id:
             print("修改")
             try:
-                crops =GardenArea.objects.get(name=area)
+                crops =FarmList.objects.get(name=area)
                 crop = Areacrop.objects.filter(id=crop_id).update(
                     cropname=cropname,
                     area=crops,
@@ -2575,7 +2584,7 @@ class CropCount(ListView):
             print("新增")
             #新增
             try:
-                crops =GardenArea.objects.get(name=area)
+                crops =FarmList.objects.get(name=area)
                 Areacrop.objects.create(
                     cropname=cropname,
                     area=crops,
@@ -2600,7 +2609,7 @@ class CropCount_View(ListView):
         gardenid = request.GET.get("ids")
         page = int(request.GET.get("page"))
         dat = []
-        art = GardenArea.objects.filter(id=gardenid)
+        art = FarmList.objects.filter(id=gardenid)
         if art:
             for i in art:
                 art_list = Areacrop.objects.filter(area=i)
@@ -2613,7 +2622,7 @@ class CropCount_View(ListView):
                     h2 = {"cropname":x.cropname,
                         "area":x.area.name,
                         "crop_count":x.crop_count,
-                        "img":x.area.img,
+                        "img":x.area.farm_img,
                         "time":data,
                         "id":x.id,
                         "upl_time":x.upl_time.strftime('%Y-%m-%d')
@@ -3227,7 +3236,7 @@ class SetMap_View(ListView):
         uname = request.GET.get("uname")
         user_list = MyUser.objects.all()
         nums = user_list.count()
-        pic_list = Pic_Info.objects.get(pic_user=current_user)
+        pic_list = Pic_Info.objects.filter(pic_user=current_user)
         return render(request, 'backstageNet/systemSet/mapManage.html', context={"nums": nums,"page":page,"uname":uname,"pic_list":pic_list})
 
     def post(self, request):

+ 2 - 2
templates/backstageNet/infoList/myPub.html

@@ -335,10 +335,10 @@
         }
 
         // 删除
-        function delFun(id) {
+        function delFun(url,id) {
             layer.confirm('真的删除行么',{title:'删除'}, function (index) {
                 $.ajax({
-                    url: 'news_check',
+                    url: url,
                     type: 'post',
                     data: {
                         id: id,

+ 1 - 1
templates/backstageNet/infoList/myPubList.html

@@ -31,7 +31,7 @@
                 <td>空</td>
             {% endif %} 
             <td>
-                <a href="JavaScript:;" class="delBtn" onclick="delFun('{{msg.id}}')">删除</a>
+                <a href="JavaScript:;" class="delBtn" onclick="delFun('news_check','{{msg.id}}')">删除</a>
                 |
             {% if type == '5' %}
                 <a href="news_view?id={{msg.id}}" target="_blank" class="lokBtn">查看</a>

+ 12 - 0
templates/backstageNet/map/map.html

@@ -179,7 +179,19 @@
     // 添加设备
     var WeatherstationMarker = [];//气象站
     var CameraMarker = [];//摄像头
+
     GetMonitorMark(1);
+    function getData(){
+        $.ajax({
+            url:'',
+            type:'post',
+            data:'',
+            dataType:'json',
+            success:function(data){
+                
+            }
+        })
+    }
 
     //监测数据
     function GetMonitorMark(ShowStatus) {

+ 459 - 0
templates/backstageNet/systemSet/partners.html

@@ -0,0 +1,459 @@
+{% load staticfiles %}
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <meta http-equiv="X-UA-Compatible" content="ie=edge">
+    <title>新闻发布</title>
+    <link rel="stylesheet" href="{% static '/lib/layui/css/layui.css' %}">
+    <link rel="stylesheet" href="{% static '/lib/css/reset.css' %}">
+    <style>
+        .breadcrumbs {
+            padding: 12px 0 12px 30px;
+            border-bottom: 1px solid #dbdbdb;
+        }
+
+        .layui-breadcrumb>* {
+            font-size: 16px;
+        }
+
+        .fixedDiv {
+            position: fixed;
+            width: 100%;
+            z-index: 999;
+            box-shadow: 0px 3px 5px 0px #ececec;
+            background: #fff;
+        }
+
+        /* 发布类型 */
+
+        .widget-title {
+            position: relative;
+            padding-left: 10px;
+            font-size: 16px;
+            padding: 5px 0 5px 10px;
+        }
+
+        .widget-title::after {
+            position: absolute;
+            content: '';
+            left: 0;
+            top: 9px;
+            height: 15px;
+            border-left: 5px solid #23a3ee;
+            padding-left: 10px;
+            font-size: 16px;
+            padding: 5px 0 5px 10px;
+        }
+
+        .widget-title h2 {
+            font-weight: 700;
+            line-height: 33px;
+        }
+
+        .widget-title h2 span {
+            font-size: 13px;
+            font-weight: 100;
+            margin-left: 20px;
+            color: #333;
+        }
+
+
+
+        /* 上传详情 */
+
+        .layui-form-item .layui-input-inline {
+            width: 50%;
+        }
+
+        .uploadContent {
+            /* border-top: 7px solid #f0f0f0; */
+            padding: 25px;
+        }
+
+        .uploadUl>li {
+            display: none;
+        }
+
+        .uploadUl>li:first-child {
+            display: block;
+        }
+
+        .innerDiv {
+            max-width: 500px;
+        }
+
+        /* 图片预览 */
+
+        .layui-upload-img {
+            width: 92px;
+            height: 92px;
+            margin: 0 10px 10px 0;
+        }
+
+        #progressBar {
+            display: none;
+        }
+
+        
+        /* 表单样式 */
+
+        .layui-form-item .layui-input-inline {
+            width: 50%;
+        }
+
+        .layui-form-item .layui-input-textarea {
+            width: 50%;
+        }
+
+        .uploadImg {
+            position: absolute;
+            margin: 10px 0;
+            width: 92px;
+            height: 92px;
+            background: none;
+            border: 1px solid #b8b8b8;
+            cursor: pointer;
+        }
+
+        .uploadImgIcon {
+            background: url(../../static/imgs/uploadImgIcon.png) no-repeat center;
+            background-size: 80% 80%;
+        }
+        #popBox{
+            display: none;
+            padding-top: 20px;
+        }
+        .delBtn, .delBtn:hover {
+            color: #c12525;
+        }
+    </style>
+</head>
+
+<body>
+    <div class="content">
+        <div class="floatNav">
+            <!-- 导航 -->
+            <div class="breadcrumbs">
+                <span class="layui-breadcrumb">
+                    <a target="BoardRight">首页</a>
+                    <a>
+                        <cite>合作伙伴</cite>
+                    </a>
+                </span>
+            </div>
+        </div>
+
+        <!-- 内容 -->
+        <div>
+            <!-- 发布详情 -->
+            <div class="uploadContent" id="uploadContent">
+                <div class="widget-title">
+                    <h2>合作伙伴
+                        <span id="Uptime"></span>
+                    </h2>
+                </div>
+                <div class="">
+                    <button style="margin-bottom: 20px;" class="layui-btn layui-btn-sm layui-btn-normal btn-shaixuan fr" onclick="addPartner()">创建合作伙伴</button>
+                    <div class="innerTable">
+                        <table id="datatable" class="layui-table" lay-skin="line">
+                            <thead>
+                                <tr>
+                                    <th>合作单位</th>
+                                    <th>单位连接</th>
+                                    <th>创建时间</th>
+                                    <th style="width:270px">操作</th>
+                                </tr>
+                            </thead>
+                            <tbody>
+        
+                            </tbody>
+                        </table>
+                        <div class="fenpei-bottom">
+                            <input type="hidden" id="totalPage" value={{ nums }}>
+                            <div id="page"></div>
+                        </div>
+                    </div>
+                </div>
+                <div id="popBox">
+                    <form class="layui-form" action="" id="formDiv" lay-filter="newsFormDiv">
+                        <div class="layui-form-item">
+                            <label class="layui-form-label">合作单位:</label>
+                            <div class="layui-input-inline">
+                                <input type="text" name="name" required lay-verify="required" placeholder="请输入合作单位"
+                                    autocomplete="off" class="layui-input">
+                            </div>
+                        </div>
+                        <div class="layui-form-item">
+                            <label class="layui-form-label">单位链接:</label>
+                            <div class="layui-input-inline">
+                                <input type="text" name="relation" required lay-verify="required" placeholder="请填写单位链接"
+                                    autocomplete="off" class="layui-input">
+                            </div>
+                        </div>
+                        <!-- <div class="layui-form-item">
+                            <label class="layui-form-label">文章简介:</label>
+                            <div class="layui-input-inline layui-input-textarea">
+                                <textarea name="intro" lay-verify="required" placeholder="请输入内容"
+                                    class="layui-textarea"></textarea>
+                            </div>
+                        </div> -->
+                        <div class="layui-form-item">
+                            <label class="layui-form-label">单位图标:</label>
+                            <div class="layui-input-inline">
+                                <button type="button" class="uploadImg uploadImgIcon" id="newsUpImg"></button>
+                                <!-- 隐藏的input -->
+                                <input type="hidden" id="img_url" name="pic" value="" />
+                                <div class="layui-upload-list">
+                                    <img class="layui-upload-img" id="demo1" :src=head_img>
+                                    <p id="demoText"></p>
+                                </div>
+                            </div>
+                        </div>
+
+                        <!-- <div class="layui-form-item layui-form-text">
+                            <label class="layui-form-label">文章正文:</label>
+                            <div class="layui-input-block">
+                                <textarea name="content" id="editor1" rows="10" cols="80"></textarea>
+                            </div>
+                        </div> -->
+                        <div class="layui-form-item">
+                            <div class="layui-input-block">
+                                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
+                                <!-- <button type="reset" class="layui-btn layui-btn-primary">重置</button> -->
+                                <button class="layui-btn layui-btn-primary" type="button"
+                                    onclick="clearForm()">取消</button>
+                            </div>
+                        </div>
+                    </form>
+                </div>
+            </div>
+        </div>
+    </div>
+
+
+    <script src="{% static '/lib/js/jquery-2.1.4.min.js'%}"></script>
+    <script src="{% static '/lib/layui/layui.js'%}"></script>
+    <script src="{% static '/js/backstageNet/common.js'%}"></script>
+    <script>
+        var element, form, upload,laypage;
+        layui.use(['element', 'form', 'upload','laypage'], function () {
+            element = layui.element;
+            form = layui.form;
+            upload = layui.upload;
+            laypage = layui.laypage;
+            //一些事件监听
+            element.on('tab(demo)', function (data) {
+                console.log(data);
+            });
+            getData('add_relation_list', 1)
+            //新闻图片上传
+            var uploadInst = upload.render({
+                elem: '#newsUpImg'
+                , url: 'expert_img'
+                , field: 'upload'
+                , accept: 'images' //只允许上传图片
+                // , acceptMime: 'image/*' //只筛选图片
+                // ,exts: 'jpg|jpeg' 
+                , size: 1024 * 2 //限定大小
+                , xhr: function () { } //上传视频进度条
+                , before: function (obj) {
+                    $('.uploadImg').removeClass('uploadImgIcon')
+                    //预读本地文件示例,不支持ie8
+                    obj.preview(function (index, file, result) {
+                        $('#demo1').attr('src', result); //图片链接(base64)
+                    });
+                }
+                , done: function (res) {
+                    //如果上传失败
+                    if (res.code == 0) {
+                        //上传成功
+                        document.getElementById("img_url").value = res.data.src;
+                    } else {
+                        return layer.msg('上传失败');
+                    }
+
+
+                }
+                , error: function () {
+                    //演示失败状态,并实现重传
+                    var demoText = $('#demoText');
+                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
+                    demoText.find('.demo-reload').on('click', function () {
+                        uploadInst.upload();
+                    });
+                }
+            });
+
+            //监听提交
+            form.on('submit(formDemo)', function (data) {
+                var img_url = $('#img_url').val();
+                if (!img_url) {
+                    layer.msg("请上传单位图标", { icon: 5 });
+                    return false;
+                }
+
+                $.ajax({
+                    url: 'add_relation',
+                    data: $("#formDiv").serialize(),
+                    type: 'post',
+                    success: function (data) {
+                        if (data) {
+                            layer.msg("发布成功", { icon: 1 });
+                            clearForm()
+                            layer.closeAll()
+                            getData('add_relation_list', $('.layui-laypage-curr em').eq(1).html())
+
+                        } else {
+                            layer.msg("发布失败", { icon: 2 });
+                        }
+                    },
+                    error: function (type) {
+
+                    }
+                })
+                return false;
+
+            });
+
+        });
+
+        function clearForm() {
+            form.val('newsFormDiv', {
+                "name": "",
+                "relation": "",
+                "pic": ""
+            });
+            $('#img_url').val('');
+            $('.uploadImg').addClass('uploadImgIcon');
+            $('#demo1').removeAttr('src'); //图片链接(base64)
+        }
+
+        function addPartner(){
+            layui.use(['layer'], function () {
+                var layer = layui.layer;
+                layer.open({
+                    title: '新增'
+                    ,type:'1'
+                    ,area:['600px','400px']
+                    ,content: $('#popBox')
+                });
+            })
+        }
+
+        function getData(url, page) {
+            $.ajax({
+                url: url,
+                type: 'get',
+                data: {
+                    page: page,
+                },
+                dataType: 'html',
+                success: function (data) {
+                    $('#datatable').children('tbody').html(data);
+                    laypage.render({
+                        elem: 'page' //注意,这里的 test1 是 ID,不用加 # 号
+                        // , count: 30
+                        , count: $('#totalPage').val()
+                        , theme: '#2ca9f9'
+                        , curr:page
+                        , layout: ['prev', 'page', 'next', 'skip']
+                        , jump: function (obj, first) {
+                            if (!first) {
+                                $.ajax({
+                                    url: url,
+                                    type: 'get',
+                                    data: { page: obj.curr},
+                                    dataType: 'html',
+                                    success: function (data) {
+                                        alert(1)
+                                        $('#datatable').children('tbody').html(data);
+                                    },
+                                    error: function (type) {
+                                        console.log(type)
+                                    }
+                                })
+                            }
+                        }
+                    });
+                },
+                error: function (type) {
+                    console.log(type)
+                }
+            })
+        }
+        // 删除
+        function delFun(url,id) {
+            layer.confirm('真的删除行么',{title:'删除'}, function (index) {
+                $.ajax({
+                    url: url,
+                    type: 'post',
+                    data: {
+                        id: id,
+                    },
+                    dataType: 'json',
+                    success: function (data) {
+                        if (data) {
+                            // obj.del(); //删除对应行(tr)的DOM结构,并更新缓存
+                            // $(".layui-laypage-btn")[0].click();//点击分页刷新当前页
+                            layer.close(index);
+                            // parent.layer.msg("操作成功!", {time: 1000}, function () {
+                            //重新加载父页面
+                            // location.reload();
+                            getData('add_relation_list', $('.layui-laypage-curr em').eq(1).html(),$('.permission .active').data('type'),$('#selectType').val()) //url,page,信息类型
+                        }
+                    }
+                })
+                layer.close(index);
+
+            });
+        }
+        windowAddMouseWheel();
+        function windowAddMouseWheel() {
+            var scrollFunc = function (e) {
+                e = e || window.event;
+                var top = $(window).scrollTop();
+                if (e.wheelDelta) {  //判断浏览器IE,谷歌滑轮事件
+                    if (e.wheelDelta > 0) { //当滑轮向上滚动时
+                        if (top < 60) {
+                            if ($(".floatNav").hasClass("fixedDiv")) {
+                                $(".floatNav").removeClass("fixedDiv");
+                                $(window).scrollTop(0)
+                            }
+                        }
+                    }
+                    if (e.wheelDelta < 0) { //当滑轮向下滚动时
+                        if (top >= 60) {
+                            $(".floatNav").addClass("fixedDiv");
+                        }
+                    }
+                } else if (e.detail) {  //Firefox滑轮事件
+                    if (e.detail > 0) { //当滑轮向上滚动时
+                        if (top < 60) {
+                            if ($(".floatNav").hasClass("fixedDiv")) {
+                                $(".floatNav").removeClass("fixedDiv");
+                                $(window).scrollTop(0)
+                            }
+                        }
+                    }
+                    if (e.detail < 0) { //当滑轮向下滚动时
+                        if (top >= 60) {
+                            $(".floatNav").addClass("fixedDiv");
+                        }
+                    }
+                }
+            };
+            //给页面绑定滑轮滚动事件
+            if (document.addEventListener) {
+                document.addEventListener('DOMMouseScroll', scrollFunc, false);
+            }
+            //滚动滑轮触发scrollFunc方法
+            window.onmousewheel = document.onmousewheel = scrollFunc;
+        }
+
+    </script>
+</body>
+
+</html>

+ 17 - 0
templates/backstageNet/systemSet/partnersList.html

@@ -0,0 +1,17 @@
+{% load staticfiles %}
+{% if partner|length %} {% for user in partner %}
+<tr>
+	<td>{{ user.name }}</td>
+	<td>{{ user.relation }}</td>
+	<td>{{ user.upl_time }}</td>
+	<td>
+        <a href="JavaScript:;" class="delBtn" onclick="delFun('add_relation','{{user.id}}')">删除</a>
+
+    </td>
+</tr>
+{% endfor %} {% else %}
+<tr>
+	<td colspan="4" style="text-align:center;">暂无数据</td>
+</tr>
+{% endif %}
+<input type="hidden" value="{{nums}}" id="totalPage">

+ 6 - 0
templates/static/js/limit/limit.js

@@ -277,6 +277,12 @@ var navList = [
                 "title": "地图设置",
                 "url": "setMap",
                 "disabled": "true",
+            },
+            {
+                "id": 13.3,
+                "title": "合作伙伴",
+                "url": "add_relation",
+                "disabled": "true",
             }
         ]
     },