From 082613d446e29e4ec1c16bfaa52345106a498b23 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Tue, 08 Nov 2022 09:03:49 +0800
Subject: [PATCH] 农事操作隐藏后四个,地图模式2d改为3d

---
 src/views/farm/farmingrecord.vue |  904 ++++++++++++++++++++++++++++++-------------------------
 1 files changed, 492 insertions(+), 412 deletions(-)

diff --git a/src/views/farm/farmingrecord.vue b/src/views/farm/farmingrecord.vue
index 01a71ed..10d8ce6 100644
--- a/src/views/farm/farmingrecord.vue
+++ b/src/views/farm/farmingrecord.vue
@@ -1,432 +1,512 @@
 <template>
-  <basic-container>
-    <avue-crud
-      :option="option"
-      :table-loading="loading"
-      :data="data"
-      :page.sync="page"
-      :permission="permissionList"
-      :before-open="beforeOpen"
-      v-model="form"
-      ref="crud"
-      @row-update="rowUpdate"
-      @row-save="rowSave"
-      @row-del="rowDel"
-      @search-change="searchChange"
-      @search-reset="searchReset"
-      @selection-change="selectionChange"
-      @current-change="currentChange"
-      @size-change="sizeChange"
-      @refresh-change="refreshChange"
-      @on-load="onLoad"
-    >
-      <template slot="menuLeft">
-        <el-button
-          type="danger"
-          size="small"
-          icon="el-icon-delete"
-          plain
-          @click="handleDelete"
-          >删 除
-        </el-button>
-      </template>
-    </avue-crud>
-  </basic-container>
+    <basic-container>
+        <avue-crud
+            :option="option"
+            :table-loading="loading"
+            :data="data"
+            :page.sync="page"
+            :permission="permissionList"
+            :before-open="beforeOpen"
+            v-model="form"
+            ref="crud"
+            @row-update="rowUpdate"
+            @row-save="rowSave"
+            @row-del="rowDel"
+            @search-change="searchChange"
+            @search-reset="searchReset"
+            @selection-change="selectionChange"
+            @current-change="currentChange"
+            @size-change="sizeChange"
+            @refresh-change="refreshChange"
+            @on-load="onLoad"
+        >
+            <template slot="menuLeft">
+                <el-button
+                    type="danger"
+                    size="small"
+                    icon="el-icon-delete"
+                    plain
+                    @click="handleDelete"
+                >删 除</el-button>
+            </template>
+        </avue-crud>
+    </basic-container>
 </template>
 
 <script>
 import {
-  getDetail,
-  getList,
-  update,
-  remove,
-  save,
-} from "@/api/farm/farmingrecord";
-import { getLandList } from "@/api/land/land";
-import { getUserList } from "@/api/system/user";
-import { selectStockFa } from "@/api/stockfactory/stockfactory";
-import { mapGetters } from "vuex";
+    getDetail,
+    getList,
+    update,
+    remove,
+    save,
+} from "@/api/farm/farmingrecord"
+import { getLandList } from "@/api/land/land"
+import { getStrainList } from "@/api/farmplant/strain"
+import { getUserList } from "@/api/system/user"
+import { selectStockFa } from "@/api/stockfactory/stockfactory"
+import { mapGetters } from "vuex"
 export default {
-  data() {
-    return {
-      visible: true,
-      form: {},
-      query: {},
-      loading: true,
-      excelBox: false,
-      page: {
-        pageSize: 10,
-        currentPage: 1,
-        total: 0,
-      },
-      selectionList: [],
-      landList: [],
-      option: {
-        tip: false,
-        height: "auto",
-        editBtn: true,
-        delBtn: true,
-        viewBtn: true,
-        menuWidth: 200,
-        menuAlign: "center",
-        align: "center",
-        selection: true,
-        searchShow: true,
-        searchMenuSpan: 6,
-        column: [
-          {
-            label: "农事类型",
-            prop: "type",
-            type: "select",
-            labelWidth: 110,
-            dicUrl: "/api/blade-system/dict-biz/dictionary?code=farmingType",
-            props: {
-              label: "dictValue",
-              value: "dictKey",
+    data () {
+        return {
+            visible: true,
+            form: {},
+            query: {},
+            loading: true,
+            excelBox: false,
+            page: {
+                pageSize: 10,
+                currentPage: 1,
+                total: 0,
             },
-            rules: [
-              {
-                required: true,
-                message: "请选择农事类型",
-                trigger: "blur",
-              },
-            ],
-          },
-          {
-            label: "所属地块",
-            prop: "landId",
-            searchSpan: 4,
-            search: true,
-            type: "tree",
-            hide: true,
-            dicData: [],
-            props: {
-              label: "landName",
-              value: "id",
+            selectionList: [],
+            landId: 0,
+            landList: [],
+            option: {
+                tip: false,
+                height: 520,
+                editBtn: true,
+                delBtn: true,
+                viewBtn: true,
+                header:false,
+                menuWidth: 200,
+                menuAlign: "center",
+                align: "center",
+                selection: true,
+                searchShow: true,
+                searchMenuSpan: 6,
+                indexFixed: false,
+                selectionFixed: false,
+                expandFixed: false,
+                menuFixed: false,
+                column: [
+                    {
+                        label: "农事类型",
+                        prop: "type",
+                        type: "select",
+                        search: true,
+                        searchSpan: 4,
+                        labelWidth: 110,
+                        searchValue: this.getType(),
+                        dicUrl: "/api/blade-system/dict-biz/dictionary?code=farmingType",
+                        props: {
+                            label: "dictValue",
+                            value: "dictKey",
+                        },
+                        rules: [
+                            {
+                                required: true,
+                                message: "请选择农事类型",
+                                trigger: "blur",
+                            },
+                        ],
+                    },
+                    {
+                        label: "所属地块",
+                        prop: "landId",
+                        searchSpan: 4,
+                        search: true,
+                        type: "tree",
+                        hide: true,
+                        dicData: [],
+                        props: {
+                            label: "landName",
+                            value: "id",
+                        },
+                        change: (val) => {
+                            this.landId = val.value
+                        },
+                        labelWidth: 110,
+                        rules: [
+                            {
+                                required: true,
+                                message: "请选择所属地块",
+                                trigger: "blur",
+                            },
+                        ],
+                    },
+                    {
+                        label: "所属地块",
+                        prop: "landName",
+                        display: false,
+                    },
+                    // {
+                    //     label: "品种",
+                    //     prop: "strainId",
+                    //     searchSpan: 4,
+                    //     search: true,
+                    //     type: "tree",
+                    //     hide: true,
+                    //     dicData: [],
+                    //     props: {
+                    //         label: "strainName",
+                    //         value: "id",
+                    //     },
+                    //     // change: (val) => {
+                    //     //     this.strainId = val.value
+                    //     // },
+                    //     labelWidth: 110,
+                    //     rules: [
+                    //         {
+                    //             required: true,
+                    //             message: "请选择品种",
+                    //             trigger: "blur",
+                    //         },
+                    //     ],
+                    // },
+                    // {
+                    //     label:"品种",
+                    //     prop:"strainName",
+                    //     display:false
+                    // },
+                    {
+                        label:"详情",
+                        prop:"content",
+                        labelWidth: 110,
+                        editDisplay:false,
+                    },
+                    {
+                        label: "农资",
+                        prop: "stockId",
+                        type: "tree",
+                        hide:true,
+                        editDisabled:true,
+                        // hide:true,
+                        dicData: [],
+                        props: {
+                            label: "spn",
+                            value: "stockId1",
+                        },
+                        labelWidth: 110,
+                        rules: [
+                            {
+                                required: true,
+                                message: "请选择农资",
+                                trigger: "blur",
+                            },
+                        ],
+                        display: false,
+                    },
+                    {
+                        label: "作业方式",
+                        prop: "jobWay",
+                        labelWidth: 110,
+                        type: "select",
+                        dicData: [
+                            {
+                                label: "人工",
+                                value: "0",
+                            },
+                            {
+                                label: "机械",
+                                value: "1",
+                            },
+                        ],
+                        rules: [
+                            {
+                                required: true,
+                                message: "请输入作业方式",
+                                trigger: "blur",
+                            },
+                        ],
+                    },
+                    {
+                        label: "农事操作时间",
+                        prop: "time",
+                        type: "date",
+                        format: "yyyy-MM-dd",
+                        valueFormat: "yyyy-MM-dd",
+                        labelWidth: 110,
+                        rules: [
+                            {
+                                required: true,
+                                message: "请选择农事操作时间",
+                                trigger: "blur",
+                            },
+                        ],
+                    },
+                    {
+                        label: "操作人",
+                        prop: "operator",
+                        type: "tree",
+                        hide: true,
+                        dicData: [],
+                        props: {
+                            label: "realName",
+                            value: "id",
+                        },
+                        labelWidth: 110,
+                        rules: [
+                            {
+                                required: false,
+                                message: "请选择操作人",
+                                trigger: "blur",
+                            },
+                        ],
+                    },
+                    {
+                        label: "农事照片",
+                        prop: "tp",
+                        type: "upload",
+                        labelWidth: 110,
+                        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: "remarks",
+                        type: "textarea",
+                        maxlength:200,
+                        span: 24,
+                        labelWidth: 110,
+                        hide: true,
+                        rules: [
+                            {
+                                required: false,
+                                message: "请输入备注",
+                                trigger: "blur",
+                            },
+                        ],
+                    },
+                ],
             },
-            labelWidth: 110,
-            rules: [
-              {
-                required: true,
-                message: "请选择所属地块",
-                trigger: "blur",
-              },
-            ],
-          },
-          {
-            label: "所属地块",
-            prop: "landName",
-            display: false,
-          },
-          {
-            label: "农资",
-            prop: "stockId",
-            searchSpan: 4,
-            search: true,
-            type: "tree",
-            // hide:true,
-            dicData: [],
-            props: {
-              label: "dictValue",
-              value: "dictKey",
-            },
-            labelWidth: 110,
-            rules: [
-              {
-                required: true,
-                message: "请选择农资",
-                trigger: "blur",
-              },
-            ],
-            display: false,
-          },
-          {
-            label: "作业方式",
-            prop: "jobWay",
-            search: true,
-            searchSpan: 4,
-            labelWidth: 110,
-            type: "select",
-            dicData: [
-              {
-                label: "人工",
-                value: "0",
-              },
-              {
-                label: "机械",
-                value: "1",
-              },
-            ],
-            rules: [
-              {
-                required: true,
-                message: "请输入作业方式",
-                trigger: "blur",
-              },
-            ],
-          },
-          {
-            label: "农事操作时间",
-            prop: "time",
-            type: "date",
-            format: "yyyy-MM-dd",
-            valueFormat: "yyyy-MM-dd",
-            labelWidth: 110,
-            rules: [
-              {
-                required: true,
-                message: "请选择农事操作时间",
-                trigger: "blur",
-              },
-            ],
-          },
-          {
-            label: "操作人",
-            prop: "operator",
-            searchSpan: 4,
-            search: true,
-            type: "tree",
-            hide: true,
-            dicData: [],
-            props: {
-              label: "realName",
-              value: "id",
-            },
-            labelWidth: 110,
-            rules: [
-              {
-                required: false,
-                message: "请选择操作人",
-                trigger: "blur",
-              },
-            ],
-          },
-          {
-            label: "农事照片",
-            type: "upload",
-            listType: "picture-img",
-            propsHttp: {
-              res: "data",
-              url: "url",
-            },
-            canvasOption: {
-              text: " ",
-              ratio: 1.0,
-            },
-            action: "/api/blade-resource/oss/endpoint/put-files",
-            tip: "",
-            span: 24,
-            labelWidth: 110,
-            prop: "tp",
-          },
-          {
-            label: "备注",
-            prop: "remarks",
-            type: "textarea",
-            span: 24,
-            labelWidth: 110,
-            hide: true,
-            rules: [
-              {
-                required: false,
-                message: "请输入备注",
-                trigger: "blur",
-              },
-            ],
-          },
-        ],
-      },
-      data: [],
-    };
-  },
-  watch: {
-    "form.type": {
-      handler(val) {
-        var stockIdcolumn = this.findObject(this.option.column, "stockId");
-        if (val === "0" || val == 4 || val == 5 || val == 8 || val == 9) {
-          stockIdcolumn.display = true;
-        } else {
-          stockIdcolumn.display = false;
+            data: [],
         }
-      },
-      immediate: true,
     },
-  },
-  created() {
-    this.initData();
-  },
-  computed: {
-    ...mapGetters(["permission", "userInfo"]),
-    // permissionList() {
-    //   return {
-    //     addBtn: this.vaildData(this.permission.social_add, true),
-    //     viewBtn: this.vaildData(this.permission.social_view, false),
-    //     delBtn: this.vaildData(this.permission.social_delete, false),
-    //     editBtn: this.vaildData(this.permission.social_edit, false),
-    //   };
-    // },
-    ids() {
-      let ids = [];
-      this.selectionList.forEach((ele) => {
-        ids.push(ele.id);
-      });
-      return ids.join(",");
-    },
-  },
-  mounted() {},
-  methods: {
-    //初始化数据
-    initData() {
-      var that = this;
-      //获取农地数据
-      getLandList(this.userInfo.user_id).then((res) => {
-        if (res.data.code == 200) {
-          var landIdcolumn = that.findObject(that.option.column, "landId");
-          that.landList = res.data.data;
-          landIdcolumn.dicData = res.data.data;
-        }
-      });
-      //获取操作人
-      const user = {
-        tenantId: this.userInfo.tenant_id,
-      };
-      getUserList(user).then((res) => {
-        if (res.data.code == 200) {
-          var operatorcolumn = that.findObject(that.option.column, "operator");
-          operatorcolumn.dicData = res.data.data;
-        }
-      });
-      //获取农资
-      selectStockFa().then((res) => {
-        if (res.data.code == 200) {
-          var stockIdcolumn = that.findObject(that.option.column, "stockId");
-          stockIdcolumn.dicData = res.data.data;
-        }
-      });
-    },
-    //新增
-    rowSave(row, done, loading) {
-      save(row).then(
-        () => {
-          this.onLoad(this.page);
-          this.$message({
-            type: "success",
-            message: "操作成功!",
-          });
-          done();
+    watch: {
+        "form.type": {
+            handler (val) {
+                var stockIdcolumn = this.findObject(this.option.column, "stockId")
+                if (val === "0" || val == 4 || val == 5 || val == 8 || val == 9) {
+                    stockIdcolumn.display = true
+                } else {
+                    stockIdcolumn.display = false
+                }
+            },
+            immediate: true,
         },
-        (error) => {
-          loading();
-          window.console.log(error);
+        '$farmId':{
+            handler (newName, oldName) {
+                //获取农地数据
+                getLandList(this.$farmId).then((res) => {
+                    if (res.data.code == 200) {
+                        var landIdcolumn = this.findObject(this.option.column, "landId")
+                        this.landList = res.data.data
+                        landIdcolumn.dicData = res.data.data
+                    }
+                })
+                this.query={}
+                this.onLoad(this.page)
+            }
         }
-      );
     },
-    //修改
-    rowUpdate(row, index, done, loading) {
-      update(row).then(
-        () => {
-          this.onLoad(this.page);
-          this.$message({
-            type: "success",
-            message: "操作成功!",
-          });
-          done();
+    created () {
+        this.initData()
+    },
+    computed: {
+        ...mapGetters(["permission", "userInfo","$farmId"]),
+        // permissionList() {
+        //   return {
+        //     addBtn: this.vaildData(this.permission.social_add, true),
+        //     viewBtn: this.vaildData(this.permission.social_view, false),
+        //     delBtn: this.vaildData(this.permission.social_delete, false),
+        //     editBtn: this.vaildData(this.permission.social_edit, false),
+        //   };
+        // },
+        ids () {
+            let ids = []
+            this.selectionList.forEach((ele) => {
+                ids.push(ele.id)
+            })
+            return ids.join(",")
         },
-        (error) => {
-          loading();
-          console.log(error);
-        }
-      );
     },
-    //删除
-    rowDel(row) {
-      this.$confirm("确定将选择数据删除?", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        type: "warning",
-      })
-        .then(() => {
-          return remove(row.id);
-        })
-        .then(() => {
-          this.onLoad(this.page);
-          this.$message({
-            type: "success",
-            message: "操作成功!",
-          });
-        });
+    mounted () {
     },
-    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();
-        });
+    methods: {
+        getType () {
+            return this.type
+        },
+        //初始化数据
+        initData () {
+            var that = this
+            //获取农地数据
+            getLandList(this.$farmId).then((res) => {
+                if (res.data.code == 200) {
+                    var landIdcolumn = that.findObject(that.option.column, "landId")
+                    that.landList = res.data.data
+                    landIdcolumn.dicData = res.data.data
+                }
+            })
+            // //获取农产品数据
+            // getStrainList(0).then((res) => {
+            //     if (res.data.code == 200) {
+            //         var strainId = that.findObject(that.option.column, "strainId")
+            //         strainId.dicData = res.data.data
+            //     }
+            // })
+            //获取操作人
+            const user = {
+                tenantId: this.userInfo.tenant_id,
+            }
+            getUserList(user).then((res) => {
+                if (res.data.code == 200) {
+                    var operatorcolumn = that.findObject(that.option.column, "operator")
+                    operatorcolumn.dicData = res.data.data
+                }
+            })
+            //获取农资
+            selectStockFa().then((res) => {
+                if (res.data.code == 200) {
+                    console.log(res.data.data)
+                    var stockIdcolumn = that.findObject(that.option.column, "stockId")
+                    stockIdcolumn.dicData = res.data.data
+                }
+            })
+        },
+        //新增
+        rowSave (row, done, loading) {
+            save(row).then(
+                () => {
+                    this.onLoad(this.page)
+                    this.$message({
+                        type: "success",
+                        message: "操作成功!",
+                    })
+                    done()
+                },
+                (error) => {
+                    loading()
+                    window.console.log(error)
+                }
+            )
+        },
+        //修改
+        rowUpdate (row, index, done, loading) {
+            update(row).then(
+                () => {
+                    this.onLoad(this.page)
+                    this.$message({
+                        type: "success",
+                        message: "操作成功!",
+                    })
+                    done()
+                },
+                (error) => {
+                    loading()
+                    console.log(error)
+                }
+            )
+        },
+        //删除
+        rowDel (row) {
+            this.$confirm("确定将选择数据删除?", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning",
+            })
+                .then(() => {
+                    return remove(row.id)
+                })
+                .then(() => {
+                    this.onLoad(this.page)
+                    this.$message({
+                        type: "success",
+                        message: "操作成功!",
+                    })
+                })
+        },
+        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) {
+            if (["edit", "view"].includes(type)) {
+                getDetail(this.form.id).then((res) => {
+                    console.log(res.data.data)
+                    this.form = res.data.data
+                })
+            }
+            done()
+        },
+        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
+            var datas = this.$route.query.id
+            params.landId = datas
+            params['tenantId'] = this.userInfo.tenant_id
+            params['farmId'] = this.$farmId
+            if (this.landId) {
+                params['landId'] = this.landId
+            }
+            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()
+            })
+        },
     },
-    beforeOpen(done, type) {
-      if (["edit", "view"].includes(type)) {
-        getDetail(this.form.id).then((res) => {
-          this.form = res.data.data;
-        });
-      }
-      done();
-    },
-    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>
 

--
Gitblit v1.9.3