智慧农业后台管理页面
guoshilong
2022-11-08 082613d446e29e4ec1c16bfaa52345106a498b23
src/views/land/cs.vue
@@ -9,7 +9,7 @@
                        size="small"
                        @change="stypeChange"
                    >
                        <el-option label="全部分类" value=""></el-option>
                        <el-option label="全部分类" value></el-option>
                        <el-option label="大田" value="0"></el-option>
                        <el-option label="大棚" value="1"></el-option>
                        <el-option label="果园" value="2"></el-option>
@@ -41,28 +41,27 @@
                </div>
            </div>
            <div class="edit">
                <el-button size="small"
                @click="goToMapModel(row)">
                  <span style="color: #5abf78">进入地图模式</span>
                <el-button size="small" @click="goToMapModel(row)">
                    <span style="color: #5abf78">进入地图模式</span>
                </el-button>
                <el-button
                  type="success"
                  size="small"
                  @click="land"
                  style="margin-right: 50px;width: 80px;"
                    type="success"
                    size="small"
                    @click="land"
                    style="margin-right: 50px;width: 80px;"
                >圈地</el-button>
            </div>
        </div>
        <div class="el-page" style="text-align: center;">
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="page.currentPage"
              :hide-on-single-page="value"
              :page-size="page.pageSize"
              background
              layout="total, prev, pager, next"
              :total="page.total"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="page.currentPage"
                :hide-on-single-page="value"
                :page-size="page.pageSize"
                background
                layout="total, prev, pager, next"
                :total="page.total"
            ></el-pagination>
        </div>
@@ -76,11 +75,37 @@
                <div class="land-img">
                    <img v-if="item.url" :src="item.url" class="landimg" />
                    <img v-else src="../../../public/img/bg/noimage.jpg" class="landimg" />
                    <!-- <div v-for="(url,index) in item.urls" :key="index" class="strainimg">
                        <img  v-if="url" :src="url" width="30px" height="30px"  />
                    </div>-->
                    <div
                        v-if="item.urls.length >0"
                        class="strainimg"
                        :class="{strainimg1:item.urls.length==1,strainimg2:item.urls.length==2,strainimg3:item.urls.length==3,strainimg4:item.urls.length==4,strainimg5:item.urls.length>=5}"
                    >
                        <img
                            v-for="(url,index) in item.urls"
                            :key="index"
                            :src="url"
                            width="30px"
                            height="30px"
                        />
                    </div>
                    <!-- <img
                        src="../../../public/img/97ae6951541f46e1bb2468adb5d69403.png"
                        class="pzIcon"
                    />
                    <img
                        src="../../../public/img/97ae6951541f46e1bb2468adb5d69403.png"
                        class="pzIcon"
                    />-->
                </div>
                <div class="text">
                    <div class="land-name">{{ item.landName }}</div>
                    <div class="land-area">
                        <div class="box">{{ item.landArea>10000?(item.landArea/10000).toFixed(2)+"万":item.landArea}} {{ item.dica }}</div>
                        <div class="box">{{ item.landArea}} {{ item.dica }}</div>
                    </div>
                </div>
            </div>
@@ -93,6 +118,7 @@
import { mapGetters } from "vuex"
import { getList } from "@/api/land/land"
import landAdd from "./landAdd"
import fixed from "@/util/mathHandler"
export default {
    components: {
        landAdd,
@@ -106,7 +132,7 @@
                keyword: "",
            },
            query: {},
            farm:{},
            farm: {},
            value: true,
            farmingCount: 0,
            landVisible: false,
@@ -130,19 +156,30 @@
        }
    },
    computed: {
        ...mapGetters(["userInfo","$farmId"]),
        ...mapGetters(["userInfo", "$farmId"]),
    },
    watch: {
        '$farmId':{
        handler (newName, oldName) {
            this.farm.id = newName
            //地块页面
            this.onLoad()
        }
        '$farmId': {
            handler (newName, oldName) {
                // this.farm.id = newName
                this.page.currentPage = 1
                //地块页面
                setTimeout(() => {
                    this.onLoad()
                }, 100)
            }
        }
    },
    created () {
        this.farm.id = this.$farmId
        this.$EventBus.$on('getFarmObj', (farmObj) => {
            // this.$nextTick(() => {
            //     this.$EventBus.$emit("setFarmId", farmObj.id);
            // });
            setTimeout(() => {
                this.$EventBus.$emit("setFarmId", farmObj.id)
            }, 100)
        })
        this.onLoad(this.page)
    },
    methods: {
@@ -180,27 +217,36 @@
            this.onLoad(this.page)
        },
        landInfo (item) {
          var arr = [];
          this.$store.state.tags.tagList.forEach((item) => {
            if (item.label != "地块详情") {
              arr.push(item);
            }
          });
          this.$store.state.tags.tagList = arr;
            var arr = []
            this.$store.state.tags.tagList.forEach((item) => {
                if (item.label != "地块详情") {
                    arr.push(item)
                }
            })
            this.$store.state.tags.tagList = arr
            this.$router.push({
                path: `/LandDetail`,
                query: item,
            })
        },
        onLoad (page, params = {}) {
            if(typeof(page) == "undefined" ){
            if (typeof (page) == "undefined") {
                page = this.page
            }
            Object.assign(params,{farmId:this.farm.id})
            Object.assign(params, { farmId: this.$farmId })
            getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
                const data = res.data.data
                this.page.total = data.total
                this.farmPlanList = data.records
                this.farmPlanList.forEach((e) => {
                    e.landArea = fixed.fixedNum(e.landArea)
                    if (e.strainUrl == "") {
                        e["urls"] = []
                    } else {
                        e["urls"] = e.strainUrl.split(",")
                    }
                })
            })
        },
        //进入地图模式
@@ -265,6 +311,7 @@
            height: 240px;
            margin: 0 auto;
            text-align: center;
            position: relative;
            .landimg {
                width: 100%;
@@ -274,6 +321,15 @@
                //margin-top: 25px;
                //margin-left: -25px;
            }
            // .pzIcon {
            //     width: 40px;
            //     height: 40px;
            //     border-radius: 50%;
            //     // position: absolute;
            //     // left: calc(50% - 20px);
            //     // top: 100px;
            //     justify-content: center;
            // }
        }
        .text {
@@ -301,7 +357,7 @@
                    left: 1;
                    bottom: 0;
                    margin: auto;
                    width: 80px;
                    width: 120px;
                    height: 24px;
                    line-height: 24px;
                    border: 1px solid #64c3a4;
@@ -328,4 +384,40 @@
.edit {
    padding-left: 13px;
}
.strainimg {
    position: absolute;
    // display:flex;
    // align-content:center
    // flex-direction: row;
    // align-items: center;
}
.strainimg1 {
    width: 31px;
    top: 45%;
    left: 45%;
}
.strainimg2 {
    width: 60px;
    top: 45%;
    left: 40%;
}
.strainimg3 {
    width: 60px;
    top: 38%;
    left: 36%;
}
.strainimg4 {
    width: 60px;
    top: 38%;
    left: 36%;
}
.strainimg5 {
    width: 90px;
    top: 38%;
    left: 30%;
}
.strainimg img {
    border-radius: 50%;
}
</style>