From 335f9ce8a5efb5be1c8d7c422d2beee6fd77cd97 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Fri, 08 Jul 2022 10:13:42 +0800
Subject: [PATCH] 多农场修改
---
src/views/farm/farm.vue | 554 +++++++++++++++++++++++++++++++++----------------------
1 files changed, 334 insertions(+), 220 deletions(-)
diff --git a/src/views/farm/farm.vue b/src/views/farm/farm.vue
index 73b048f..3a00a56 100644
--- a/src/views/farm/farm.vue
+++ b/src/views/farm/farm.vue
@@ -1,217 +1,209 @@
<template>
- <el-tabs v-model="activeName" @tab-click="handleClick">
- <!-- 基本信息 -->
- <el-tab-pane label="基本信息" name="tab1">
- <basic-container>
- <avue-form
- ref="form"
- v-model="objBase"
- :option="optionBase"
- @submit="submitBase"
- >
- <!-- 地图插入 -->
- <template slot-scope="{}" slot="position">
- <getMapDataInThere
- ref="getMapData"
- id="getMapData"
- @setMapData="setMapData"
- ></getMapDataInThere>
- </template>
- </avue-form>
- </basic-container>
- </el-tab-pane>
- <!-- 检测报告信息 -->
- <el-tab-pane label="检测报告信息" name="tab2">
- <farmReport
- :farmId="farmId"
- ></farmReport>
- </el-tab-pane>
- <!-- 认证证书信息 -->
- <el-tab-pane label="认证证书信息" name="tab3">
- <farmPaper
- :farmId="farmId"
- ></farmPaper>
- </el-tab-pane>
- </el-tabs>
+ <basic-container>
+ <avue-crud
+ class="tablesss"
+ :before-open="beforeOpen"
+ :option="option"
+ :data="data"
+ :page.sync="page"
+ v-model="form"
+ ref="crud"
+ :permission="permissionList"
+ @on-load="onLoad"
+ :table-loading="loading"
+ @row-save="rowSave"
+ @search-change="searchChange"
+ @search-reset="searchReset"
+ @row-update="rowUpdate"
+ @row-del="rowDel"
+ @selection-change="selectionChange"
+ @refresh-change="refreshChange"
+ >
+ <template slot="menuLeft">
+ <el-button
+ type="danger"
+ size="small"
+ plain
+ icon="el-icon-delete"
+ v-if="permission.farm_delete"
+ @click="handleDelete"
+ >删 除
+ </el-button>
+ </template>
+ <!-- 地图插入 -->
+ <template slot-scope="{ type, disabled }" slot="lineForm">
+ <getMapDataInThere
+ ref="getMapData"
+ id="getMapData"
+ @setMapData="setMapData"
+ ></getMapDataInThere>
+ </template>
+ <template slot-scope="{ type, size, row }" slot="menu">
+ <el-button
+ icon="el-icon-view"
+ type="text"
+ size="mini"
+ @click="goToFarmDetail(row)"
+ :size="size"
+ >查看
+ </el-button>
+ </template>
+ </avue-crud>
+ </basic-container>
</template>
<script>
import getMapDataInThere from "./getMapDataInThere.vue";
-import farmPaper from "./farmPaper.vue";
-import farmReport from "./farmReport.vue";
-import { update, getDetails } from "@/api/farm/farm";
+
+import { getList,add,update, remove,getDetails } from "@/api/farm/farm";
import { mapGetters } from "vuex";
export default {
components: {
- getMapDataInThere,
- farmPaper,
- farmReport
+ getMapDataInThere
},
data() {
return {
- farmId:"",
- activeName: "tab1",
- objBase: {},
- optionBase: {
- emptyBtn: false,
- submitText: "保存",
- gutter: 30,
- group: [
- {
- icon: "",
- label: "农场基本信息",
- collapse: true,
- prop: "group1",
- column: [
- {
- label: "",
- labelWidth: 20,
- type: "title",
- prop: "title",
- span: 24,
- styles: {
- fontSize: "24px",
- },
- },
- {
- label: "农场名称",
- prop: "farmName",
- span: 12,
- labelWidth: 145,
- rules: [
- {
- required: true,
- message: "请输入农场名称",
- trigger: "blur",
- },
- ],
- },
- {
- label: "农场地址",
- prop: "farmAddress",
- span: 12,
- labelWidth: 145,
- width: 110,
- rules: [
- {
- required: true,
- message: "请输入农场地址",
- trigger: "click",
- },
- ],
- },
- {
- label: "农场面积",
- prop: "farmArea",
- span: 12,
- labelWidth: 145,
- width: 110,
- rules: [
- {
- required: true,
- message: "请输入农场面积",
- trigger: "click",
- },
- ],
- },
- ],
- },
- {
- icon: "",
- label: "农场介绍",
- prop: "group2",
- column: [
- {
- label: "口号",
- prop: "slogan",
- span: 12,
- labelWidth: 145,
- rules: [
- {
- required: true,
- message: "请输入口号",
- trigger: "blur",
- },
- ],
- },
- {
- label: "介绍",
- type: "textarea",
- prop: "introduce",
- span: 24,
- labelWidth: 145,
- rules: [
- {
- required: true,
- message: "请输入介绍",
- trigger: "blur",
- },
- ],
- },
- {
- label: "农场环境图片",
- prop: "picture",
- type: "upload",
- labelWidth: 145,
- dataType: "string",
- span: 24,
- limit: 5,
- listType: "picture-card",
- tip: "建议上传手机横屏拍摄的照片,宽高比16:9,最多上传5张",
- canvasOption: {
- text: "",
- ratio: 1.0,
- },
- propsHttp: {
- res: "data",
- url: "url"
- },
- action: "/api/blade-resource/oss/endpoint/put-files"
- },
- {
- label: "农场位置",
- prop: "position",
- className: "mapClass",
- span: 24,
- formslot: true,
- labelWidth: 145,
- },
- ],
- },
- ],
+ loading: true,
+ selectionList: [],
+ page: {
+ pageSize: 10,
+ currentPage: 1,
+ total: 0
},
+ form: {},
+ query: {},
+ data: [],
+ option: {
+ index: true,
+ tip: false,
+ addBtn: true,
+ searchMenuSpan: 6,
+ height: 583,
+ menuWidth: 300,
+ border: true,
+ viewBtn:false,
+ align: "center",
+ selection: true,
+ column: [
+ {
+ label: "农场名称",
+ search: true,
+ prop: "farmName",
+ labelWidth: 145,
+ rules: [{
+ required: true,
+ message: "请输入农场名称",
+ trigger: "blur"
+ }]
+ },
+ {
+ label: "农场地址",
+ prop: "farmAddress",
+ rules: [{
+ required: true,
+ message: "请输入农场地址",
+ trigger: "blur"
+ }],
+ labelWidth: 145,
+ overHidden:true
+ },
+
+ {
+ label: "农场面积",
+ prop: "farmArea",
+ labelWidth: 145,
+ rules: [{
+ required: true,
+ message: "请输入农场面积",
+ trigger: "blur"
+ }],
+ },
+ {
+ label: "口号",
+ prop: "slogan",
+ labelWidth: 145,
+ rules: [{
+ required: true,
+ message: "请输入农场口号",
+ trigger: "blur"
+ }],
+ },
+ {
+ label: "介绍",
+ prop: "introduce",
+ type:"textarea",
+ span: 24,
+ labelWidth: 145,
+ rules: [{
+ required: true,
+ message: "请输入农场介绍",
+ trigger: "blur"
+ }],
+ overHidden:true
+ },
+ {
+ label: "农场环境图片",
+ prop: "picture",
+ type: "upload",
+ labelWidth: 145,
+ dataType: "string",
+ span: 24,
+ limit: 5,
+ listType: "picture-card",
+ tip: "建议上传手机横屏拍摄的照片,宽高比16:9,最多上传5张",
+ canvasOption: {
+ text: "",
+ ratio: 1.0,
+ },
+ propsHttp: {
+ res: "data",
+ url: "url"
+ },
+ action: "/api/blade-resource/oss/endpoint/put-files"
+ },
+ {
+ label: "路线展示",
+ labelWidth: 145,
+ prop: "line",
+ className: "mapClass",
+ hide: true,
+ display: true,
+ span: 24,
+ formslot: true,
+ addDisplay: true
+ }
+ ],
+ }
};
+ },
+ created() {
+ // this.getRailLazyTree();
},
computed: {
...mapGetters(["userInfo", "permission", "polygonsFarm"]),
+ permissionList() {
+ return {
+ addBtn: this.vaildData(this.permission.farm_delete, false),
+ viewBtn: this.vaildData(this.permission.farm_delete, false),
+ delBtn: this.vaildData(this.permission.farm_delete, false),
+ editBtn: this.vaildData(this.permission.farm_delete, false)
+ };
+ },
+ ids() {
+ let ids = [];
+ this.selectionList.forEach(ele => {
+ ids.push(ele.id);
+ });
+ return ids.join(",");
+ }
},
mounted() {
- var that = this;
- this.$nextTick(() => {
- getDetails(this.userInfo.dept_id).then((res) => {
- console.log( res.data.data,123)
- if (res.data.code == 200) {
- that.objBase = res.data.data;
- that.farmId = that.objBase.id;
- let usePolygons = that.objBase.position
- .split("POLYGON((")[1]
- .split("))")[0]
- .split(",");
- for (let k in usePolygons) {
- usePolygons[k] = {
- lng: +usePolygons[k].split(" ")[0],
- lat: +usePolygons[k].split(" ")[1],
- };
- }
- this.$refs.getMapData.draw(usePolygons);
- }
- });
- });
},
methods: {
- //农场基本信息提交
- submitBase(form, loading, done) {
+ rowSave(row, done, loading) {
+ row['tenantId'] = this.userInfo.tenant_id;
+ row['deptId'] = this.userInfo.dept_id;
if (this.polygonsFarm.length == 0) {
//没有面的数据
this.$refs.getMapData.isCheck = true;
@@ -228,10 +220,41 @@
}
}
//设置坐标点
- form.position = usePolygons;
+ row.position = usePolygons;
+ }
+ add(row).then(() => {
+ this.onLoad(this.page);
+ this.$message({
+ type: "success",
+ message: "操作成功!"
+ });
+ done();
+ }, error => {
+ loading();
+ window.console.log(error);
+ });
+ },
+ rowUpdate(row, index, done, loading) {
+ if (this.polygonsFarm.length == 0) {
+ //没有面的数据
+ this.$refs.getMapData.isCheck = true;
+ loading();
+ } else {
+ //如果有值,空间坐标转换
+ let pol = this.polygonsFarm;
+ let polLength = this.polygonsFarm.length - 1;
+ let usePolygons = "";
+ for (let k in pol) {
+ usePolygons += pol[k].lng + "," + pol[k].lat;
+ if (k != polLength) {
+ usePolygons += ";";
+ }
+ }
+ //设置坐标点
+ row.position = usePolygons;
}
// 修改
- update(form).then((res) => {
+ update(row).then((res) => {
if (res.data.success) {
this.$message({
message: "操作成功",
@@ -248,39 +271,130 @@
}
});
},
- setMapData(val) {
- this.LineData = val[0];
- this.PointData = val[1];
+ rowDel(row) {
+ this.$confirm("确定将选择数据删除?", {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ type: "warning"
+ })
+ .then(() => {
+ return remove(row.id);
+ })
+ .then(() => {
+ this.onLoad(this.page);
+ this.$message({
+ type: "success",
+ message: "操作成功!"
+ });
+ });
},
- },
- watch: {},
+ handleDelete() {
+ if (this.selectionList.length === 0) {
+ this.$message.warning("请选择至少一条数据");
+ return;
+ }
+ this.$confirm("确定将选择数据删除?", {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ type: "warning"
+ })
+ .then(() => {
+ return remove(this.ids);
+ })
+ .then(() => {
+ this.onLoad(this.page);
+ this.$message({
+ type: "success",
+ message: "操作成功!"
+ });
+ this.$refs.crud.toggleSelection();
+ });
+ },
+ beforeOpen(done, type) {
+ //先清空面的数据
+ this.$store.commit('clear_polygonsFarm');
+ if (["edit", "view"].includes(type)) {
+ getDetails(this.form.id).then((res) => {
+ if (res.data.code == 200) {
+ this.form = res.data.data;
+ let usePolygons = this.form.position
+ .split("POLYGON((")[1]
+ .split("))")[0]
+ .split(",");
+ for (let k in usePolygons) {
+ usePolygons[k] = {
+ lng: +usePolygons[k].split(" ")[0],
+ lat: +usePolygons[k].split(" ")[1],
+ };
+ }
+ this.$refs.getMapData.draw(usePolygons);
+ }
+ });
+ }
+ done();
+ },
+ //查看农场详情
+ goToFarmDetail(row) {
+ this.$router.push({
+ path: `/farm/farmInfoDetail`,
+ query: row
+ });
+ },
+ searchReset() {
+ this.query = {};
+ this.onLoad(this.page);
+ },
+ searchChange(params, done) {
+ this.query = params;
+ this.page.currentPage = 1;
+ this.onLoad(this.page, params);
+ done();
+ },
+ selectionChange(list) {
+ this.selectionList = list;
+ },
+ selectionClear() {
+ this.selectionList = [];
+ this.$refs.crud.toggleSelection();
+ },
+ currentChange(currentPage) {
+ this.page.currentPage = currentPage;
+ },
+ sizeChange(pageSize) {
+ this.page.pageSize = pageSize;
+ },
+ refreshChange() {
+ this.onLoad(this.page, this.query);
+ },
+ onLoad(page, params = {}) {
+ this.loading = true;
+ getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
+ const data = res.data.data;
+ this.page.total = data.total;
+ this.data = data.records;
+ this.loading = false;
+ this.selectionClear();
+ });
+ }
+ }
};
</script>
-<style lang="scss" scoped>
+<style lang="scss">
+
.mapClass div label {
display: none;
}
-#getMapData {
- width: 80%;
- position: relative;
- height: 500px;
- top: 10px;
+.mapClassMain {
+ padding-left: 5rem !important;
}
-// .el-collapse-item {
-// padding-top: 15px !important;
-// }
-// .tab {
-// position: relative;
-// // border: 1px solid red;
-// background-color: #fff;
-// height: 92%;
-// display: inline-block;
-// width: 100%;
-// overflow: hidden;
-// top: -10px;
-// }
-</style>
+#getMapData {
+ width: calc(100% + 90px);
+ position: relative;
+ left: -90px;
+ height: 400px;
+}
+</style>
\ No newline at end of file
--
Gitblit v1.9.3