From c7d469efc2bc11d2c54d2aafef90d16e27088eb8 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Tue, 02 Aug 2022 11:43:42 +0800
Subject: [PATCH] Merge branch 'master' of http://s16s652780.51mypc.cn:49896/r/zhny_web

---
 src/views/mapPattern/index.vue |  644 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 641 insertions(+), 3 deletions(-)

diff --git a/src/views/mapPattern/index.vue b/src/views/mapPattern/index.vue
index c486356..c045e43 100644
--- a/src/views/mapPattern/index.vue
+++ b/src/views/mapPattern/index.vue
@@ -1,12 +1,650 @@
 <template>
-    <div></div>
+    <div @click="bodyClick($event)" style="position: relative; height: 100%;">
+        <plot-map ref="plotMap" style="position: absolute; width: 100%; height: 100%;"></plot-map>
+        <div class="top">
+            <div class="logo">
+                <img src="../../../public/mg.png" />
+            </div>
+            <div class="farm-info">
+                <div class="farm-name">
+                    <span>{{ farmInfo.farmName }}</span>
+                </div>
+                <div class="farm-area">
+                    <span>地块总面积:</span>
+                    <span style="font-size: 16px;font-weight: bold;">&nbsp;{{landAreaInfo.zarea}}亩</span>
+                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+                    <span>在田面积:</span>
+                    <span style="font-size: 16px;font-weight: bold;">&nbsp;{{landAreaInfo.sarea}}亩</span>
+                </div>
+            </div>
+            <div class="out" @click="goToBack">
+                <img src="../../../public/img/out.png" />
+                <span>&nbsp;&nbsp;返回</span>
+            </div>
+        </div>
+        <div class="farm-plant">
+            <div class="title">
+                <span>种养品种 · {{ this.plotPlantBreed.length }}种</span>
+            </div>
+            <div class="content">
+                <div class="list-item" v-for="(item, index) in plotPlantBreed" :key="index">
+                    <div class="item-img">
+                        <img :src="item.url" />
+                        <span>{{ item.strainName }}</span>
+                    </div>
+                    <div class="item-num">{{ item.area }}亩</div>
+                </div>
+            </div>
+        </div>
+        <div class="land-info">
+            <div class="content">
+                <div>
+                    有轮廓的地块:
+                    <span
+                        style="font-size: 26px;font-weight: bold;color: #5ABF78;"
+                    >{{landIsAreaStatistic.length > 0 ? landIsAreaStatistic[0] : 0}}</span>
+                </div>
+
+                <div>
+                    无轮廓的地块:
+                    <span
+                        style="font-size: 26px;font-weight: bold;color: #E3B745;"
+                    >{{landIsAreaStatistic.length > 1 ? landIsAreaStatistic[1] : 0}}</span>
+                </div>
+            </div>
+        </div>
+        <div class="farm-land">
+            <div class="title">
+                <span>地块 · {{ this.pageLand.total }}种</span>
+            </div>
+            <div class="content">
+                <div
+                    class="list-item"
+                    v-for="(item, index) in landList"
+                    :key="index"
+                    @click="setCenter(item)"
+                >
+                    <div class="item-img">
+                        <img :src="item.url" />
+                        <span>{{ item.landName }}</span>
+                    </div>
+                    <div class="item-num">{{ item.landArea }}亩</div>
+                </div>
+            </div>
+        </div>
+
+        <div class="plot-detail-popup" v-show="cPShow" ref="showCP">
+            <div class="header">
+                <div class="plot-name">
+                    <div class="name">{{ currentPlotDetails.landName }}</div>
+                    <i class="el-icon-edit-outline" title="编辑地块名称"></i>
+                </div>
+                <div class="plot-area-type">
+                    <div class="l">
+                        占地面积:{{ currentPlotDetails.landArea }}{{ currentPlotDetails.dica }}
+                        <span
+                            class="type"
+                        >{{ currentPlotDetails.dic }}</span>
+                    </div>
+                    <div class="r">
+                        进入地块
+                        <i class="el-icon-arrow-right"></i>
+                    </div>
+                </div>
+            </div>
+
+            <div class="body">
+                <div class="list" v-for="(item, index) in cPPBreed" :key="index">
+                    <div class="l">
+                        <img :src="item.url" />
+                        {{ item.strainName }}
+                    </div>
+                    <div
+                        class="r"
+                    >{{ item.createTime }}{{ item.plantingWay == 0 ? "移摘" : item.plantingWay == 1 ? "播种" : "秧苗" }}</div>
+                </div>
+            </div>
+        </div>
+    </div>
 </template>
 
 <script>
+import { mapGetters } from "vuex"
+import { getList } from "@/api/farmplant/farmplant"
+import { getList as getLandList, selectCount, getLandIsAreaStatistic } from "@/api/land/land"
+import { getDetails } from "@/api/farm/farm"
 export default {
+    components: {
+    },
+    data () {
+        return {
+            page: {
+                pageSize: 10,
+                currentPage: 1,
+                total: 0,
+            },
+            pageLand: {
+                pageSize: 10,
+                currentPage: 1,
+                total: 0,
+            },
+            farmPlantList: [],
 
+            // 数据合并后的种养品种
+            plotPlantBreed: [],
+
+            // 当前地块种养品种
+            cPPBreed: [],
+
+            // 当前地块对应弹框
+            cPShow: false,
+
+            // 当前点击地块详情
+            currentPlotDetails: {},
+
+            plotClickNum: 0,
+
+            landList: [],
+            farmInfo: {},
+            landAreaInfo: {},
+            landIsAreaStatistic: [],
+        }
+
+    },
+    computed: {
+        ...mapGetters(["userInfo"]),
+    },
+    created () {
+        //获取种样品列表
+        this.getFarmPlantList(this.page)
+        //获取地块列表
+        this.getLandList(this.pageLand)
+        //获取农场信息
+        this.getFarmInfo()
+        //获取统计面积信息
+        this.getLandCount()
+        //获取地块轮廓统计信息
+        this.getLandIsAreaStatistic()
+    },
+    methods: {
+        //获取种养品列表
+        getFarmPlantList (page, params = {}) {
+            params['farmId'] = this.userInfo.farmId
+            this.loading = true
+            getList(
+                page.currentPage,
+                page.pageSize,
+                Object.assign(params)
+            ).then((res) => {
+                const data = res.data.data
+                this.page.total = data.total
+                this.farmPlantList = data.records
+
+                let arr = []
+                this.farmPlantList.forEach(item => {
+                    if (arr.length > 0) {
+                        let result = arr.some(it => {
+                            if (item.strainName == it.strainName) {
+                                it.area += Number(item.area)
+
+                                return true
+                            }
+                        })
+
+                        if (!result) {
+                            arr.push({
+                                strainName: item.strainName,
+                                area: Number(item.area),
+                                url: item.url
+                            })
+                        }
+                    } else {
+                        arr.push({
+                            strainName: item.strainName,
+                            area: Number(item.area),
+                            url: item.url
+                        })
+                    }
+                })
+
+                this.plotPlantBreed = arr
+
+
+                this.loading = false
+
+
+
+                // this.selectionClear()
+            })
+        },
+        //获取地块列表
+        getLandList (page, params = {}) {
+            params['farmId'] = this.userInfo.farmId
+            params['tenantId'] = this.userInfo.tenant_id
+            this.loading = true
+            getLandList(
+                page.currentPage,
+                page.pageSize,
+                Object.assign(params)
+            ).then((res) => {
+                const data = res.data.data
+
+                data.records.forEach(item => {
+                    if (item.landRange != '' || item.landRange != null) {
+                        item.landRange = item.landRange.replace(/POLYGON\(\(/g, '')
+                        item.landRange = item.landRange.replace(/\)\)/g, '')
+
+                        const arr = item.landRange.split(',')
+                        var brr = []
+                        arr.forEach(it => {
+                            brr.push(it.split(' '))
+                        })
+
+                        this.$refs.plotMap.addPlotPolygon(brr, item)
+                    }
+                })
+
+                this.pageLand.total = data.total
+                this.landList = data.records
+                this.loading = false
+                // this.selectionClear()
+            })
+        },
+        //返回上一页
+        goToBack () {
+            this.$router.go(-1)
+        },
+        //获取农场信息
+        getFarmInfo () {
+            var that = this
+            getDetails(this.userInfo.farmId).then(res => {
+                that.farmInfo = res.data.data
+            })
+        },
+        //获取统计面积信息
+        getLandCount () {
+            selectCount(this.userInfo.farmId).then(res => {
+                this.landAreaInfo = res.data.data
+            })
+        },
+        //获取地块轮廓统计信息
+        getLandIsAreaStatistic () {
+            getLandIsAreaStatistic(this.userInfo.farmId).then(res => {
+                console.log(res)
+                this.landIsAreaStatistic = res.data.data
+            })
+        },
+
+        // 地块定位
+        setCenter (item) {
+            this.$refs.plotMap.setPlotCenter(item.landName)
+        },
+
+        plotDetailsPopupShow (params) {
+            this.currentPlotDetails = params
+
+            let arr = []
+
+            this.farmPlantList.forEach((item, index) => {
+                if (params.id == item.landId) {
+                    arr.push(item)
+                }
+            })
+
+            this.cPPBreed = arr
+
+            this.cPShow = true
+        },
+
+        bodyClick (e) {
+            if (this.plotClickNum == 0) {
+                this.plotClickNum++
+                return
+            }
+
+            if (this.$refs.showCP) {
+                console.log(1)
+                let isSelf = this.$refs.showCP.contains(e.target)
+                if (!isSelf) {
+                    this.plotClickNum = 0
+                    this.cPShow = false
+                }
+            }
+        }
+    }
 }
 </script>
 
-<style>
-</style>
\ No newline at end of file
+<style lang="scss" scope>
+.top {
+    position: absolute;
+    top: 0;
+    width: 100%;
+    height: 80px;
+    background: rgba(0, 0, 0, 0.5);
+    z-index: 9;
+
+    .logo {
+        position: absolute;
+        left: 36px;
+        top: 12px;
+
+        img {
+            height: 55px;
+        }
+    }
+
+    .farm-info {
+        height: 100%;
+        width: 100%;
+
+        .farm-name {
+            width: 100%;
+            height: 33px;
+            font-size: 25px;
+            font-weight: bold;
+            color: #5abf78;
+            text-align: center;
+            padding-top: 13px;
+        }
+
+        .farm-area {
+            width: 100%;
+            height: 19px;
+            font-size: 14px;
+            font-weight: 400;
+            color: #ffffff;
+            text-align: center;
+            padding-top: 6px;
+        }
+    }
+
+    .out {
+        width: 136px;
+        height: 33px;
+        line-height: 33px;
+        background: rgba(236, 95, 89, 0.8);
+        border-radius: 4px 4px 4px 4px;
+        opacity: 1;
+        border: 1px solid #ec5f59;
+        position: absolute;
+        top: 24px;
+        right: 33px;
+        text-align: center;
+        cursor: pointer;
+
+        img {
+            width: 12px;
+            height: 18px;
+            position: relative;
+            top: 4px;
+        }
+
+        span {
+            font-size: 14px;
+            color: #ffffff;
+            font-weight: 400;
+        }
+    }
+}
+
+.land-info {
+    width: 100%;
+    position: absolute;
+    top: 112px;
+
+    .content {
+        display: flex;
+        align-items: center;
+        justify-content: space-between;
+        margin: auto;
+        padding: 0 40px;
+        width: 431px;
+        height: 56px;
+        background: rgba(0, 0, 0, 0.5);
+        border-radius: 28px 28px 28px 28px;
+        font-size: 16px;
+        font-weight: 400;
+        color: #ffffff;
+
+        & > div {
+            display: flex;
+            align-items: center;
+        }
+    }
+}
+
+.farm-plant {
+    position: absolute;
+    left: 30px;
+    top: 242px;
+    z-index: 99;
+
+    width: 292px;
+    height: 550px;
+
+    .title {
+        width: 292px;
+        height: 50px;
+        background: #5abf78;
+        border-radius: 4px 4px 0px 0px;
+        opacity: 1;
+        line-height: 50px;
+        font-size: 17px;
+        font-weight: bold;
+        color: #ffffff;
+
+        span {
+            margin-left: 20px;
+        }
+    }
+
+    .content {
+        width: 292px;
+        height: calc(100% - 50px);
+        background: rgba(8, 85, 30, 0.9);
+        // height: 500px;
+        border-radius: 4px 4px 0px 0px;
+        opacity: 0.9;
+        padding-bottom: 30px;
+
+        overflow-x: hidden;
+        overflow-y: auto;
+
+        .list-item {
+            width: 252px;
+            margin: auto;
+            display: flex;
+            height: 64px;
+            line-height: 64px;
+            border-bottom: 1px solid #cccccc;
+            flex-flow: row nowrap;
+            justify-content: space-between;
+
+            .item-img {
+                margin-left: 5px;
+                display: flex;
+
+                img {
+                    margin-top: 12px;
+                    width: 40px;
+                    height: 40px;
+                    background: #2389ef;
+                    border-radius: 84px 84px 84px 84px;
+                    opacity: 1;
+                }
+
+                span {
+                    margin-left: 11px;
+                    font-size: 14px;
+                    font-weight: 400;
+                    color: #ffffff;
+                }
+            }
+
+            .item-num {
+                font-size: 14px;
+                font-weight: 400;
+                color: #ffffff;
+            }
+        }
+    }
+}
+
+.farm-land {
+    position: absolute;
+    right: 30px;
+    top: 242px;
+
+    z-index: 99;
+
+    width: 292px;
+    height: 550px;
+
+    .title {
+        width: 292px;
+        height: 50px;
+        background: #5abf78;
+        border-radius: 4px 4px 0px 0px;
+        opacity: 1;
+        line-height: 50px;
+        font-size: 17px;
+        font-weight: bold;
+        color: #ffffff;
+
+        span {
+            margin-left: 20px;
+        }
+    }
+
+    .content {
+        width: 292px;
+        height: calc(100% - 50px);
+        background: rgba(8, 85, 30, 0.9);
+        // height: 500px;
+
+        border-radius: 4px 4px 0px 0px;
+        opacity: 0.9;
+        padding-bottom: 30px;
+
+        overflow-x: hidden;
+        overflow-y: auto;
+
+        .list-item {
+            width: 252px;
+            margin: auto;
+            display: flex;
+            height: 64px;
+            line-height: 64px;
+            border-bottom: 1px solid #cccccc;
+            flex-flow: row nowrap;
+            justify-content: space-between;
+            cursor: pointer;
+
+            .item-img {
+                margin-left: 5px;
+                display: flex;
+
+                img {
+                    margin-top: 12px;
+                    width: 40px;
+                    height: 40px;
+                    background: #2389ef;
+                    border-radius: 84px 84px 84px 84px;
+                    opacity: 1;
+                }
+
+                span {
+                    margin-left: 11px;
+                    font-size: 14px;
+                    font-weight: 400;
+                    color: #ffffff;
+                }
+            }
+
+            .item-num {
+                font-size: 14px;
+                font-weight: 400;
+                color: #ffffff;
+            }
+        }
+    }
+}
+
+.plot-detail-popup {
+    position: fixed;
+    top: 50%;
+    left: 50%;
+
+    width: 462px;
+    height: 262px;
+
+    transform: translate(-50%, -50%);
+    z-index: 11;
+    background: rgba(255, 255, 255, 0.9);
+    border-radius: 8px;
+    overflow: hidden;
+
+    .header {
+        display: flex;
+        flex-direction: column;
+        padding: 0 20px;
+        height: 80px;
+        background: #2cd2a9;
+        color: #fff;
+
+        & > div {
+            flex: 1;
+            display: flex;
+            align-items: center;
+        }
+
+        .plot-name {
+        }
+
+        .plot-area-type {
+            justify-content: space-between;
+        }
+    }
+
+    .body {
+        padding: 10px 20px;
+        height: calc(100% - 80px);
+        background: rgba(0, 0, 0, 0);
+        box-sizing: border-box;
+        overflow-x: hidden;
+        overflow-y: auto;
+
+        .list:first-child {
+            margin: 0;
+        }
+
+        .list {
+            margin-top: 10px;
+            padding: 0 10px;
+            display: flex;
+            justify-content: space-between;
+            align-items: center;
+            height: 50px;
+            background: #fff;
+            font-size: 14px;
+
+            .l {
+                display: flex;
+                align-items: center;
+                color: #2cd2a9;
+
+                img {
+                    margin-right: 10px;
+                    width: 30px;
+                    height: 30px;
+                }
+            }
+
+            .r {
+                color: #999;
+            }
+        }
+    }
+}
+</style>

--
Gitblit v1.9.3