智慧农业后台管理页面
首页新增农事操作,农资入库,圈地页面,新增操作记录列表,新增库存管理页面,新增采收列表页面
5 files modified
5 files added
2615 ■■■■■ changed files
src/api/farmplant/farmproductstock.js 48 ●●●●● patch | view | raw | blame | history
src/router/views/index.js 404 ●●●● patch | view | raw | blame | history
src/views/farmplant/farmproductstock.vue 354 ●●●●● patch | view | raw | blame | history
src/views/recovery/recovery.vue 439 ●●●●● patch | view | raw | blame | history
src/views/wel/farmDetail.vue 50 ●●●●● patch | view | raw | blame | history
src/views/wel/farming.vue 234 ●●●●● patch | view | raw | blame | history
src/views/wel/getMapDataInThere.vue 345 ●●●●● patch | view | raw | blame | history
src/views/wel/index.vue 57 ●●●●● patch | view | raw | blame | history
src/views/wel/land.vue 361 ●●●● patch | view | raw | blame | history
src/views/wel/stock.vue 323 ●●●●● patch | view | raw | blame | history
src/api/farmplant/farmproductstock.js
New file
@@ -0,0 +1,48 @@
import request from '@/router/axios';
export const getList = (current, size, params) => {
    return request({
        url: '/api/farmProductStock/page',
        method: 'get',
        params: {
            ...params,
            current,
            size,
        }
    })
}
export const remove = (ids) => {
    return request({
        url: '/api/farmProductStock/remove',
        method: 'post',
        params: {
            ids,
        }
    })
}
export const save = (row) => {
    return request({
        url: '/api/farmProductStock/save',
        method: 'post',
        data: row
    })
}
export const update = (row) => {
    return request({
        url: '/api/farmProductStock/update',
        method: 'post',
        data: row
    })
}
export const getDetail = (id) => {
    return request({
        url: '/api/farmProductStock/detail',
        method: 'get',
        params: {
            id
        }
    })
}
src/router/views/index.js
@@ -1,193 +1,221 @@
import Layout from '@/page/index/'
export default [{
  path: '/wel',
  component: Layout,
  redirect: '/wel/index',
  children: [{
    path: 'index',
    name: '首页',
    meta: {
      i18n: 'dashboard'
    },
    component: () =>
      import ( /* webpackChunkName: "views" */ '@/views/wel/index')
  }, {
    path: 'dashboard',
    name: '控制台',
    meta: {
      i18n: 'dashboard',
      menu: false,
    },
    component: () =>
      import ( /* webpackChunkName: "views" */ '@/views/wel/dashboard')
  }]
}, {
  path: '/test',
  component: Layout,
  redirect: '/test/index',
  children: [{
    path: 'index',
    name: '测试页',
    meta: {
      i18n: 'test'
    },
    component: () =>
      import ( /* webpackChunkName: "views" */ '@/views/util/test')
  }]
},
  {
    path: '/framing',
    redirect: '/farmplant/farmplant',
    component: Layout,
    children: [{
      path: 'index',
      name: '农事操作',
      meta: {
        i18n: 'index',
      },
      component: () =>
        import( /* webpackChunkName: "views" */ '@/views/farm/farmPaper')
    }]
  },
  {
    path: '/stockrecord',
    redirect: '/stockrecord/stockrecord',
    component: Layout,
    children: [{
      path: 'stockrecord',
      name: '农资记录',
      meta: {
        i18n: 'index',
      },
      component: () =>
        import( /* webpackChunkName: "views" */ '@/views/stockrecord/stockrecord')
    }]
  },
  {
    path: '/farmingrecord',
    redirect: '/farm/farmingrecord',
    component: Layout,
    children: [{
      path: 'farmingrecord',
      name: '农事记录',
      meta: {
        i18n: 'index',
      },
      component: () =>
        import( /* webpackChunkName: "views" */ '@/views/farm/farmingrecord')
    }]
  },
  {
    path: '/soldrecord',
    redirect: '/soldrecord/soldrecord',
    component: Layout,
    children: [{
      path: 'soldrecord',
      name: '已出库待使用农资',
      meta: {
        i18n: 'index',
      },
      component: () =>
        import( /* webpackChunkName: "views" */ '@/views/soldrecord/soldrecord')
    }]
  },
  {
    path: '/dict-horizontal',
    component: Layout,
    redirect: '/dict-horizontal/index',
    children: [{
      path: 'index',
      name: '字典管理',
      meta: {
        i18n: 'dict'
      },
      component: () =>
        import ( /* webpackChunkName: "views" */ '@/views/util/demo/dict-horizontal')
    }]
  }, {
    path: '/dict-vertical',
    component: Layout,
    redirect: '/dict-vertical/index',
    children: [{
      path: 'index',
      name: '字典管理',
      meta: {
        i18n: 'dict'
      },
      component: () =>
        import ( /* webpackChunkName: "views" */ '@/views/util/demo/dict-vertical')
    }]
  },
  {
    path: '/land',
    component: Layout,
    redirect: '/land/index',
    children: [{
      path: 'index',
      name: '地块管理',
      meta: {
        i18n: 'land'
      },
      component: () =>
        import( /* webpackChunkName: "views" */ '@/views/land/land')
    }]
  },
  {
    path: '/info',
    component: Layout,
    redirect: '/info/index',
    children: [{
      path: 'index',
      name: '个人信息',
      meta: {
        i18n: 'info'
      },
      component: () =>
        import ( /* webpackChunkName: "views" */ '@/views/system/userinfo')
    }]
  }, {
    path: '/work/process/leave',
    component: Layout,
    redirect: '/work/process/leave/form',
    children: [{
      path: 'form/:processDefinitionId',
      name: '请假流程',
      meta: {
        i18n: 'work'
      },
      component: () =>
        import ( /* webpackChunkName: "views" */ '@/views/work/process/leave/form')
        path: '/wel',
        component: Layout,
        redirect: '/wel/index',
        children: [{
            path: 'index',
            name: '首页',
            meta: {
                i18n: 'dashboard'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/wel/index')
        }, {
            path: 'dashboard',
            name: '控制台',
            meta: {
                i18n: 'dashboard',
                menu: false,
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/wel/dashboard')
        }]
    }, {
      path: 'handle/:taskId/:processInstanceId/:businessId',
      name: '处理请假流程',
      meta: {
        i18n: 'work'
      },
      component: () =>
        import ( /* webpackChunkName: "views" */ '@/views/work/process/leave/handle')
        path: '/test',
        component: Layout,
        redirect: '/test/index',
        children: [{
            path: 'index',
            name: '测试页',
            meta: {
                i18n: 'test'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/util/test')
        }]
    },
    {
        path: '/framing',
        redirect: '/farmplant/farmplant',
        component: Layout,
        children: [{
            path: 'index',
            name: '农事操作',
            meta: {
                i18n: 'index',
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/farm/farmPaper')
        }]
    },
    {
        path: '/stockrecord',
        redirect: '/stockrecord/stockrecord',
        component: Layout,
        children: [{
            path: 'stockrecord',
            name: '农资记录',
            meta: {
                i18n: 'index',
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/stockrecord/stockrecord')
        }]
    },
    {
        path: '/farmingrecord',
        redirect: '/farm/farmingrecord',
        component: Layout,
        children: [{
            path: 'farmingrecord',
            name: '农事记录',
            meta: {
                i18n: 'index',
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/farm/farmingrecord')
        }]
    },
    {
        path: '/soldrecord',
        redirect: '/soldrecord/soldrecord',
        component: Layout,
        children: [{
            path: 'soldrecord',
            name: '已出库待使用农资',
            meta: {
                i18n: 'index',
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/soldrecord/soldrecord')
        }]
    },
    {
        path: '/farmDetail',
        redirect: '/wel/farmDetail',
        component: Layout,
        children: [{
            path: '/farmDetail',
            name: '操作记录',
            meta: {
                i18n: 'index',
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/wel/farmDetail')
        }]
    },
    {
        path: '/dict-horizontal',
        component: Layout,
        redirect: '/dict-horizontal/index',
        children: [{
            path: 'index',
            name: '字典管理',
            meta: {
                i18n: 'dict'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/util/demo/dict-horizontal')
        }]
    }, {
      path: 'detail/:processInstanceId/:businessId',
      name: '请假流程详情',
      meta: {
        i18n: 'work'
      },
      component: () =>
        import ( /* webpackChunkName: "views" */ '@/views/work/process/leave/detail')
    }]
  },
  {
    path: '/farm',
    component: Layout,
    redirect: '/farm/index',
    children: [{
      path: 'index',
      name: '农场信息管理',
      meta: {
        i18n: 'farm'
      },
      component: () =>
        import ( /* webpackChunkName: "views" */ '@/views/farm/farm')
    }]
  },
]
        path: '/dict-vertical',
        component: Layout,
        redirect: '/dict-vertical/index',
        children: [{
            path: 'index',
            name: '字典管理',
            meta: {
                i18n: 'dict'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/util/demo/dict-vertical')
        }]
    },
    {
        path: '/land',
        component: Layout,
        redirect: '/land/index',
        children: [{
            path: 'index',
            name: '地块管理',
            meta: {
                i18n: 'land'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/land/land')
        }]
    },
    {
        path: '/farmproductstock',
        component: Layout,
        redirect: '/farmproductstock/index',
        children: [{
            path: 'index',
            name: '农产品库存管理',
            meta: {
                i18n: 'farmproductstock'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/farmplant/farmproductstock')
        }]
    },
    {
        path: '/info',
        component: Layout,
        redirect: '/info/index',
        children: [{
            path: 'index',
            name: '个人信息',
            meta: {
                i18n: 'info'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/system/userinfo')
        }]
    }, {
        path: '/work/process/leave',
        component: Layout,
        redirect: '/work/process/leave/form',
        children: [{
            path: 'form/:processDefinitionId',
            name: '请假流程',
            meta: {
                i18n: 'work'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/work/process/leave/form')
        }, {
            path: 'handle/:taskId/:processInstanceId/:businessId',
            name: '处理请假流程',
            meta: {
                i18n: 'work'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/work/process/leave/handle')
        }, {
            path: 'detail/:processInstanceId/:businessId',
            name: '请假流程详情',
            meta: {
                i18n: 'work'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/work/process/leave/detail')
        }]
    },
    {
        path: '/farm',
        component: Layout,
        redirect: '/farm/index',
        children: [{
            path: 'index',
            name: '农场信息管理',
            meta: {
                i18n: 'farm'
            },
            component: () =>
                import ( /* webpackChunkName: "views" */ '@/views/farm/farm')
        }]
    },
]
src/views/farmplant/farmproductstock.vue
New file
@@ -0,0 +1,354 @@
<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>
</template>
<script>
import {
  getDetail,
  getList,
  update,
  remove,
  save,
} from "@/api/farmplant/farmproductstock";
import { getStrainList } from "@/api/farmplant/strain";
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      visible: true,
      form: {},
      query: {},
      loading: true,
      excelBox: false,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      selectionList: [],
      option: {
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        height: "auto",
        editBtn: true,
        delBtn: true,
        viewBtn: true,
        menuWidth: 200,
        menuAlign: "center",
        align: "center",
        selection: true,
        column: [
          {
            label: "农产品名称",
            prop: "strainId",
            span: 12,
            search:true,
            searchSpan:4,
            searchLabelWidth:100,
            type: "tree",
            dicData: [],
            props: {
              label: "strainName",
              value: "id"
            },
            labelWidth: 145,
            rules: [
              {
                required: true,
                message: "请输入农产品名称",
                trigger: "blur",
              },
            ],
            disabled:true,
          },
          {
            label: "采收重量",
            prop: "weight",
            tip: '公斤',
            span: 12,
            labelWidth: 145,
            controls:false,
            type:'number',
            rules: [
              {
                required: true,
                message: "请输入采收重量 公斤",
                trigger: "click",
              },
            ],
          },
          {
            label: "采收时间",
            prop: "time",
            span: 12,
            labelWidth: 145,
            type: "datetime",
            format: "yyyy-MM-dd HH:mm",
            valueFormat: "yyyy-MM-dd HH:mm",
            rules: [
              {
                required: true,
                message: "请选择采收时间",
                trigger: "click",
              },
            ],
          },
          {
            label: "操作人",
            prop: "operator",
            type: "tree",
            dicData: [],
            props: {
              label: "realName",
              value: "id",
            },
            span: 12,
            labelWidth: 145,
            rules: [
              {
                required: true,
                message: "请输入操作人",
                trigger: "click",
              },
            ],
          },
          {
            label: "产品等级",
            prop: "leaves",
            span: 12,
            labelWidth: 145,
            width: 110,
            search:true,
            searchSpan:4,
            type: "select",
            dicData:[
              {
                label:"一等品",
                value:"0"
              },
              {
                label:"二等品",
                value:"1"
              },
              {
                label:"三等品",
                value:"2"
              },
              {
                label:"四等品",
                value:"3"
              },
              {
                label:"五等品",
                value:"4"
              },
            ],
            rules: [
              {
                required: true,
                message: "请输入产品等级",
                trigger: "click",
              },
            ],
          },
        ],
      },
      data: [],
    };
  },
  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;
      //获取农产品数据
      getStrainList(0).then((res)=>{
          if(res.data.code==200){
              var strainId = that.findObject(that.option.column,"strainId");
              strainId.dicData = res.data.data;
          }
      })
    },
    //新增
    rowSave(row, done, loading) {
      row['strainType'] =0;
      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) => {
          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>
<style>
</style>
src/views/recovery/recovery.vue
New file
@@ -0,0 +1,439 @@
<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>
</template>
<script>
import { getDetail, getList, update, remove, save } from "@/api/farmplant/recovery";
import { getStrainList } from "@/api/farmplant/strain";
import { getLandList } from "@/api/land/land";
import { getUserList } from "@/api/system/user";
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: false,
        delBtn: true,
        viewBtn: false,
        addBtn: false,
        menuWidth: 200,
        menuAlign: "center",
        align: "center",
        selection: true,
        searchShow: true,
        searchMenuSpan: 6,
        column: [
          {
            label: "采收品种",
            prop: "strainId",
            search:true,
            searchSpan:4,
            span: 12,
            type: "tree",
            dicData: [],
            props: {
              label: "strainName",
              value: "id"
            },
            labelWidth: 145,
            rules: [
              {
                required: true,
                message: "请输入采收品种",
                trigger: "blur",
              },
            ],
            disabled:true,
          },
          {
            label: "采收地块",
            span: 12,
            labelWidth: 145,
            prop: "landId",
            type:"tree",
            search:true,
            searchSpan:4,
            hide:true,
            dicData: [],
            props: {
              label: "landName",
              value: "id"
            },
            rules: [
              {
                required: true,
                message: "请选择地块",
                trigger: "click",
              },
            ],
          },
          {
            label: "地块",
            prop: "landName",
            display:false,
          },
          {
            label: "采收重量",
            prop: "weight",
            tip: '公斤',
            span: 12,
            labelWidth: 145,
            controls:false,
            type:'number',
            rules: [
              {
                required: true,
                message: "请输入采收重量 公斤",
                trigger: "click",
              },
            ],
          },
          {
            label: "作业方式",
            prop: "jobWay",
            span: 12,
            labelWidth: 145,
            type: "select",
            search:true,
            searchSpan:4,
            value:"0",
            dicData:[
              {
                label:"人工",
                value:"0"
              },
              {
                label:"机械",
                value:"1"
              },
            ],
            rules: [
              {
                required: true,
                message: "请选择作业方式",
                trigger: "click",
              },
            ],
          },
          {
            label: "采收时间",
            prop: "time",
            span: 12,
            labelWidth: 145,
            type: "datetime",
            format: "yyyy-MM-dd HH:mm",
            valueFormat: "yyyy-MM-dd HH:mm",
            rules: [
              {
                required: true,
                message: "请选择采收时间",
                trigger: "click",
              },
            ],
          },
          {
            label: "操作人",
            prop: "operator",
            type: "tree",
            dicData: [],
            props: {
              label: "realName",
              value: "id",
            },
            span: 12,
            labelWidth: 145,
            rules: [
              {
                required: true,
                message: "请输入操作人",
                trigger: "click",
              },
            ],
          },
          {
            label: "产品等级",
            prop: "leaves",
            span: 12,
            labelWidth: 145,
            value:"0",
            search:true,
            searchSpan:4,
            type: "select",
            dicData:[
              {
                label:"一等品",
                value:"0"
              },
              {
                label:"二等品",
                value:"1"
              },
              {
                label:"三等品",
                value:"2"
              },
              {
                label:"四等品",
                value:"3"
              },
              {
                label:"五等品",
                value:"4"
              },
            ],
            rules: [
              {
                required: true,
                message: "请输入产品等级",
                trigger: "click",
              },
            ],
          },
          {
            label: "备注",
            prop: "remark",
            span: 24,
            type:"textarea",
            labelWidth: 145,
            rules: [
              {
                required: false,
                message: "请输入备注",
                trigger: "click",
              },
            ],
          },
        ],
      },
      data: [],
    };
  },
  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;
          }
      })
      //获取农产品数据
      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;
        }
      });
    },
    //新增
    rowSave(row, done, loading) {
      row['farmType'] = 0;
      row['createUser'] = this.userInfo.user_id;
      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) => {
          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>
<style>
</style>
src/views/wel/farmDetail.vue
New file
@@ -0,0 +1,50 @@
<template>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <!-- 种植记录 -->
      <el-tab-pane label="种养品种" name="tab1">
        <farmplant
        ></farmplant>
      </el-tab-pane>
      <!-- 农事记录 -->
      <el-tab-pane label="农事记录" name="tab2">
        <farming
        ></farming>
      </el-tab-pane>
      <!-- 采收记录 -->
      <el-tab-pane label="采收记录" name="tab3">
        <farming
        ></farming>
      </el-tab-pane>
    </el-tabs>
</template>
<script>
import farmplant from "@/views/farmplant/farmplant.vue";
import farming from "@/views/farm/farmingrecord.vue";
import { mapGetters } from "vuex";
export default {
  components: {
    farmplant,
    farming
  },
  data() {
    return {
      farmId:"",
      activeName: "tab1",
    };
  },
  computed: {
    ...mapGetters(["userInfo", "permission"]),
  },
  created(){
    this.activeName = this.$route.query.activeName;
  },
  methods: {
  },
  watch: {},
};
</script>
<style lang="scss" scoped>
</style>
src/views/wel/farming.vue
@@ -17,12 +17,12 @@
import { mapState } from "vuex";
import { getLandList } from "@/api/land/land";
import { getUserList } from "@/api/system/user";
import { getStrainList } from "@/api/farmplant/strain";
import { save } from "@/api/farmplant/recovery";
import { selectStockFa } from "@/api/stockfactory/stockfactory";
import { save } from "@/api/farm/farmingrecord";
export default {
  data() {
    return {
      title:"采收/捕捞",
      title:"农事操作",
      form: {},
      option: {
        emptyBtn: false,
@@ -30,119 +30,99 @@
        gutter: 30,
        column: [
          {
            label: "采收品种",
            prop: "strainId",
            span: 12,
            type: "tree",
            dicData: [],
            label: "农事类型",
            prop: "type",
            type: "select",
            labelWidth: 110,
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=farmingType",
            props: {
              label: "strainName",
              value: "id"
              label: "dictValue",
              value: "dictKey",
            },
            labelWidth: 145,
            rules: [
              {
                required: true,
                message: "请输入采收品种",
                message: "请选择农事类型",
                trigger: "blur",
              },
            ],
            disabled:true,
          },
          {
            label: "采收地块",
            span: 12,
            labelWidth: 145,
            width: 110,
            label: "所属地块",
            prop: "landId",
            type:"tree",
            type: "tree",
            dicData: [],
            props: {
              label: "landName",
              value: "id"
              value: "id",
            },
            labelWidth: 110,
            rules: [
              {
                required: true,
                message: "请选择采收地块",
                trigger: "click",
                message: "请选择所属地块",
                trigger: "blur",
              },
            ],
          },
          {
            label: "采收重量",
            prop: "weight",
            tip: '公斤',
            span: 12,
            labelWidth: 145,
            width: 110,
            controls:false,
            type:'number',
            label: "农资",
            prop: "stockId",
            type: "tree",
            dicData: [],
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            labelWidth: 110,
            rules: [
              {
                required: true,
                message: "请输入采收重量 公斤",
                trigger: "click",
                message: "请选择农资",
                trigger: "blur",
              },
            ],
            display: false,
          },
          {
            label: "作业方式",
            prop: "jobWay",
            span: 12,
            labelWidth: 145,
            width: 110,
            labelWidth: 110,
            type: "select",
            value:"0",
            dicData:[
            value:'0',
            dicData: [
              {
                label:"人工",
                value:"0"
                label: "人工",
                value: "0",
              },
              {
                label:"机械",
                value:"1"
                label: "机械",
                value: "1",
              },
            ],
            rules: [
              {
                required: true,
                message: "请选择作业方式",
                trigger: "click",
                message: "请输入作业方式",
                trigger: "blur",
              },
            ],
          },
          {
            label: "采收时间",
            label: "农事操作时间",
            prop: "time",
            span: 12,
            labelWidth: 145,
            width: 110,
            type: "datetime",
            format: "yyyy-MM-dd HH:mm",
            valueFormat: "yyyy-MM-dd HH:mm",
            type: "date",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            labelWidth: 110,
            rules: [
              {
                required: true,
                message: "请选择采收时间",
                trigger: "click",
                message: "请选择农事操作时间",
                trigger: "blur",
              },
            ],
          },
          // {
          //   label: "采收产品",
          //   prop: "farmArea",
          //   span: 12,
          //   labelWidth: 145,
          //   width: 110,
          //   rules: [
          //     {
          //       required: true,
          //       message: "请输入采收产品",
          //       trigger: "click",
          //     },
          //   ],
          // },
          {
            label: "操作人",
            prop: "operator",
@@ -152,67 +132,46 @@
              label: "realName",
              value: "id",
            },
            span: 12,
            labelWidth: 145,
            width: 110,
            labelWidth: 110,
            rules: [
              {
                required: true,
                message: "请输入操作人",
                trigger: "click",
                required: false,
                message: "请选择操作人",
                trigger: "blur",
              },
            ],
          },
          {
            label: "产品等级",
            prop: "leaves",
            span: 12,
            labelWidth: 145,
            width: 110,
            value:"0",
            type: "select",
            dicData:[
              {
                label:"一等品",
                value:"0"
              },
              {
                label:"二等品",
                value:"1"
              },
              {
                label:"三等品",
                value:"2"
              },
              {
                label:"四等品",
                value:"3"
              },
              {
                label:"五等品",
                value:"4"
              },
            ],
            rules: [
              {
                required: true,
                message: "请输入产品等级",
                trigger: "click",
              },
            ],
            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: "remark",
            prop: "remarks",
            type: "textarea",
            span: 24,
            type:"textarea",
            labelWidth: 145,
            width: 110,
            labelWidth: 110,
            rules: [
              {
                required: false,
                message: "请输入备注",
                trigger: "click",
                trigger: "blur",
              },
            ],
          },
@@ -225,6 +184,19 @@
    ...mapState({
      userInfo: (state) => state.user.userInfo,
    }),
  },
  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,
    },
  },
  methods: {
    //计算当前时间
@@ -246,25 +218,14 @@
        this.form['time'] = year + '-' 
                          + this.addZero(month) + '-' 
                          + this.addZero(day) + ' ' 
                          + this.addZero(hour) + ':'
                          + this.addZero(minute);
                          + this.addZero(hour);
    },
    //小于10的拼接上0字符串
    addZero(s) {
      return s < 10 ? ('0' + s) : s;
    },
    //初始化
    init(data) {
      this.form = {
        farmPlantId:data.id,
        strainId:data.strainId,
        landId:data.landId,
        weight:data.weight,
        leaves:'0',
        jobWay:data.jobWay,
        operator:data.operator,
        remark:''
      };
    init() {
      this.form['operator'] = this.userInfo.user_id;
      //计算当前时间
      this.getNowTime();
@@ -278,7 +239,6 @@
          landIdcolumn.dicData = res.data.data;
        }
      });
      //获取操作人
      const user = {
        tenantId: this.userInfo.tenant_id,
@@ -289,30 +249,28 @@
          operatorcolumn.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;
          }
      })
      //获取农资
      selectStockFa().then((res) => {
        if (res.data.code == 200) {
          var stockIdcolumn = that.findObject(that.option.column, "stockId");
          stockIdcolumn.dicData = res.data.data;
        }
      });
    },
    // 表单提交
    submit(row,loading,done) {
    submit(row,loading) {
      var that = this;
      row.time = row.time + ":00";
      save(row).then(
        () => {
          this.$refs.form.resetFields();
          that.$refs.form.resetFields();
          that.visible = false;
          this.$message({
            type: "success",
            message: "操作成功!",
          });
           done();
        },
        (error) => {
          done();
          loading();
          window.console.log(error);
        }
      );
src/views/wel/getMapDataInThere.vue
New file
@@ -0,0 +1,345 @@
<template>
  <div class="getMapData" :key="Refresh">
    <MapInThere ref="getMapDataRefs" />
    <div class="notDatas" v-show="isCheck">
      <div style="color: red">*</div>
      未绘画区域
    </div>
    <div class="controlMapWindowTitle">
      <el-button-group>
        <el-button type="primary" icon="el-icon-finished" @click="drawFace"
          >绘画区域</el-button
        >
        <el-button type="danger" @click="giveUp" icon="el-icon-close"
          >取消</el-button
        >
      </el-button-group>
    </div>
  </div>
</template>
<script>
import { mapGetters } from "vuex";
import MapInThere from "@/components/map/mainInThere.vue";
export default {
  name: "getMapData",
  components: {
    MapInThere,
  },
  computed: {
    ...mapGetters(["rotesData", "pointData", "polygons"]),
  },
  watch: {
    ourDatas: {
      handler(val) {
        this.checkDom("getMapDataRefs", (dom) => {
          dom.onceOnlodad(val);
        });
      },
      deep: true,
    },
    polygons() {
      if (this.polygons.length > 0) {
        this.isCheck = false;
      }
    },
  },
  data() {
    return {
      Refresh: false,
      //动画效果
      animateName: "custom-classes-transition",
      animateEnter: "animated fadeIn",
      animateLeave: "animated fadeOut",
      //未输入动画效果
      animateName: "custom-classes-transition",
      animateEnter: "animated fadeInDown",
      animateLeave: "animated fadeOut",
      openTitle: "路径1",
      MapDataShow: false,
      fromView: false,
      ourDatas: [],
      nowId: 0,
      isCheck: false,
    };
  },
  mounted() {
  },
  methods: {
    draw(usePolygons) {
      this.$store.commit("setpolygon", usePolygons); //用vuex传最终数据
      this.doThat(usePolygons)
    },
    doThat(val) {
      this.checkDom("getMapDataRefs", (dom) => {
          dom.addLines(val);
          // 移动位置
          dom.move(val);
      });
    },
    drawFace() {
      this.$refs.getMapDataRefs.drawStart();
    },
    giveUp() {
      this.$refs.getMapDataRefs.closeDraw();
    },
    openDrawLineMethod() {
      let id = this.nowId++;
      this.ourDatas.push({
        label: "路径" + +id,
        value: "",
        name: "",
        notPath: false,
        isLine: true,
        id: +id,
      });
    },
    openDrawPointMethod() {
      let id = this.nowId++;
      this.ourDatas.push({
        label: "标点" + +id,
        value: "",
        name: "",
        notPath: false,
        isLine: false,
        id: +id,
      });
    },
    deleteRowOurs(index) {
      this.ourDatas.splice(index, 1);
    },
    backMapDataOurData(val, index) {
      if (val == "line") {
        this.ourDatas[index].value = this.rotesData;
      } else if (val == "point") {
        this.ourDatas[index].value = this.pointData;
      } else if (val == "notData") {
        this.ourDatas[index].value = "";
      }
      //单个验证
      this.myRules(index);
    },
    //以上是添加数据集方法
    //选择map数据
    openMap(val, num, value) {
      this.MapDataShow = true;
      this.openTitle = val;
      this.$refs.getMapDataRefs.init(val, num, value);
    },
    closeOpenedMap() {
      this.MapDataShow = false;
      // this.openTitle = "";
    },
    //下面是旧代码
    editInit(val) {
      //查看情况逆转String成为当页可使用数据,并做动作
      this.reverseMapData(val);
    },
    viewInit(val) {
      //查看情况逆转String成为当页可使用数据,并做动作
      this.reverseMapData(val);
      this.fromView = true; //查看数据不可改
    },
    reverseMapData(val, label) {
      //解释数据
      let rname = val[0][0].split(";"),
        r = val[0][1].split(";"),
        pname = val[1][0].split(";"),
        p = val[1][1].split(";");
      this.ourDatas = [];
      for (let k in r) {
        this.ourDatas.push({
          label: "路径" + (+k + 1),
          value: r[k],
          name: rname[k],
          notPath: false,
          isLine: true,
          id: this.ourDatas.length,
        });
      }
      for (let k in p) {
        let potion = p[k].split(",");
        this.ourDatas.push({
          label: "标点" + (+k + 1),
          value: [+potion[0], +potion[1]],
          name: pname[k],
          notPath: false,
          isLine: false,
          id: this.ourDatas.length,
        });
      }
      this.nowId = +this.ourDatas.length + 1;
    },
    myRules(index) {
      //单个验证
      if (this.ourDatas[index].name && this.ourDatas[index].value) {
        this.ourDatas[index].notPath = false;
      } else {
        this.ourDatas[index].notPath = 2;
      }
    },
    //自定义验证
    myRulesUse() {
      //把一个数组拆开两个来对应之前的数据
      let ourData = this.ourDatas;
      let lineBefor = [];
      let pointBefor = [];
      for (let o in ourData) {
        if (ourData[o].isLine) {
          lineBefor.push(ourData[o]);
        } else {
          pointBefor.push(ourData[o]);
        }
      }
      let line = this.changeMapData(lineBefor, "name");
      let point = this.changeMapData(pointBefor, "name");
      if (line[0] == "namenot" || point[0] == "namenot") {
        //需要显示验证失败合集
        let errorId = [];
        if (line[0] == "namenot") {
          errorId.push(...line[1]);
        }
        if (point[0] == "namenot") {
          errorId.push(...point[1]);
        }
        for (let x in this.ourDatas) {
          let flog = true;
          for (let k in errorId) {
            if (errorId[k] == this.ourDatas[x].id) {
              flog = false;
            }
          }
          if (flog) {
            this.ourDatas[x].notPath = false;
          } else {
            this.ourDatas[x].notPath = 2;
          }
        }
        return false;
      } else {
        for (let i in this.ourDatas) {
          this.ourDatas[i].notPath = false;
        }
        return [line, point];
      }
    },
    //规则
    changeMapData(item, names) {
      let name = "",
        value = "",
        notData = [];
      let itemLength = item.length - 1;
      for (let k in item) {
        let inItem = item[k];
        for (let kin in inItem) {
          if (
            inItem[kin] == "" &&
            kin != "notPath" &&
            kin != "isLine" &&
            kin != "id"
          ) {
            notData.push(inItem.id);
            break;
          }
          if (kin == names) {
            name += inItem[kin];
            if (k != itemLength) {
              name += ";";
            }
          }
          if (kin == "value") {
            value += inItem[kin];
            if (k != itemLength) {
              value += ";";
            }
          }
        }
      }
      return notData.length > 0 ? [names + "not", notData] : [name, value];
    },
    checkDom(name, fn) {
      //  声明定时器
      let that = this;
      var timer = null;
      //  检查dom是否执行完成
      function checkDom() {
        let dom = that.$refs[name];
        if (dom) {
          //  执行dom加载完成后的操作
          //  清除定时器
          if (!timer) {
            clearTimeout(timer);
          }
          if (fn) {
            //回调函数
            fn(dom);
            return;
          } else {
            return dom;
          }
        } else {
          //  自我调用
          timer = setTimeout(checkDom, 100);
        }
      }
      //  首次执行
      checkDom();
    },
  },
};
</script>
<style lang="scss">
.flexCenter {
  display: flex;
  align-items: center;
  justify-content: center;
}
.getMapData {
  width: 100%;
  height: 100%;
  position: relative;
  .controlMapWindowTitle {
    position: absolute;
    left: calc(50% - 42px);
    top: 0;
  }
  .notPath {
    // border-bottom: 0.5px solid red;
  }
}
//过度动画
.list-enter {
  opacity: 0;
  transform: translateY(10px);
}
.list-leave-to {
  opacity: 0;
  transform: translateY(-10px);
}
.list-enter-to,
.list-leave {
  opacity: 1;
}
​ .list-enter-active,
.list-leave-active {
  transition: all 0.3s;
}
.notDatas {
  width: auto;
  height: auto;
  position: absolute;
  top: 5px;
  left: 100px;
  background-color: #fff;
  border-radius: 5px;
  padding: 2px 8px;
  div {
    display: inline;
  }
}
</style>
src/views/wel/index.vue
@@ -23,7 +23,7 @@
          <div class="farm" v-for="(item, index) in farmPlanList" :key="index">
            <div class="farm-img"><img :src="item.url" class="img" /></div>
            <div class="cai">{{ item.strainName }}</div>
            <div class="area">种植面积:371.13亩</div>
            <div class="area">种植面积:{{item.area}}</div>
            <div class="btn">
              <el-button plain size="small" @click="recovery(item)"
                >采收</el-button
@@ -80,6 +80,15 @@
      </div>
      <div class="statistics">
        <div class="title">生产统计</div>
        <div class="farming-statis">
          <div class="left">
            <div class="farm-text">本年农事操作</div>
            <div class="num"><span>{{total}}</span>&nbsp;次</div>
          </div>
          <div class="right">
            <el-link type="success" :underline="false" @click="farmPlantDetail">明细>></el-link>
          </div>
        </div>
      </div>
      <div class="repertory">
        <div class="title">农资库存</div>
@@ -117,6 +126,7 @@
  name: "wel",
  data() {
    return {
      total:0,
      farmPlanList: [],
      recoveryVisible: false,
      landVisible: false,
@@ -230,6 +240,16 @@
      this.stockVisible = true;
      this.$nextTick(() => {
        this.$refs.stock.init();
      });
    },
    //本年农事操作明细
    farmPlantDetail() {
      const data ={
        activeName:"tab2"
      }
      this.$router.push({
        path: `/farmDetail`,
        query: data
      });
    },
  },
@@ -436,6 +456,41 @@
        font-weight: 550;
        text-align: center;
      }
      .farming-statis{
        width: 94%;
        margin: 0 auto;
        height: 100px;
        display: flex;
        flex-direction: row;
        // background-color: aqua;
        .left{
          width: 60%;
          height: 100px;
          .farm-text{
            font-size: 20px;
            margin-top: 20px;
          }
          .num{
            font-size: 16px;
            margin-top: 10px;
            span{
              font-size: 36px;
              font-weight: 550;
            }
          }
        }
        .right{
           margin-left:60px;
           line-height: 100px;
           height: 100px;
        }
      }
    }
    .repertory {
src/views/wel/land.vue
@@ -8,21 +8,32 @@
    :visible.sync="visible"
  >
    <avue-form ref="form" v-model="form" :option="option" @submit="submit">
      <!-- 地图插入 -->
      <template slot-scope="{ type, disabled }" slot="line">
        <getMapDataInThere
          ref="getMapData"
          id="getMapData"
          @setMapData="setMapData"
        ></getMapDataInThere>
      </template>
    </avue-form>
  </el-dialog>
</template>
<script>
import { mapState } from "vuex";
import {mapGetters} from "vuex";
import { getLandList } from "@/api/land/land";
import { getUserList } from "@/api/system/user";
import { getStrainList } from "@/api/farmplant/strain";
import { save } from "@/api/farmplant/recovery";
import {add} from "@/api/land/land";
import getMapDataInThere from "./getMapDataInThere.vue";
export default {
  components: {
    getMapDataInThere
  },
  data() {
    return {
      title:"采收/捕捞",
      title:"新增地块",
      form: {},
      option: {
        emptyBtn: false,
@@ -30,293 +41,115 @@
        gutter: 30,
        column: [
          {
            label: "采收品种",
            prop: "strainId",
            span: 12,
            type: "tree",
            dicData: [],
            props: {
              label: "strainName",
              value: "id"
            },
            labelWidth: 145,
            rules: [
              {
                required: true,
                message: "请输入采收品种",
                trigger: "blur",
              },
            ],
            disabled:true,
            label: "地块名称",
            prop: "landName",
            rules: [{
              required: true,
              message: "请输入地块名称",
              trigger: "blur"
            }]
          },
          {
            label: "采收地块",
            span: 12,
            labelWidth: 145,
            width: 110,
            prop: "landId",
            type:"tree",
            dicData: [],
            props: {
              label: "landName",
              value: "id"
            },
            rules: [
              {
                required: true,
                message: "请选择采收地块",
                trigger: "click",
              },
            ],
          },
          {
            label: "采收重量",
            prop: "weight",
            tip: '公斤',
            span: 12,
            labelWidth: 145,
            width: 110,
            controls:false,
            type:'number',
            rules: [
              {
                required: true,
                message: "请输入采收重量 公斤",
                trigger: "click",
              },
            ],
          },
          {
            label: "作业方式",
            prop: "jobWay",
            span: 12,
            labelWidth: 145,
            width: 110,
            label: "地块类型",
            type: "select",
            value:"0",
            dicData:[
              {
                label:"人工",
                value:"0"
              },
              {
                label:"机械",
                value:"1"
              },
            ],
            rules: [
              {
                required: true,
                message: "请选择作业方式",
                trigger: "click",
              },
            ],
          },
          {
            label: "采收时间",
            prop: "time",
            span: 12,
            labelWidth: 145,
            width: 110,
            type: "datetime",
            format: "yyyy-MM-dd HH:mm",
            valueFormat: "yyyy-MM-dd HH:mm",
            rules: [
              {
                required: true,
                message: "请选择采收时间",
                trigger: "click",
              },
            ],
          },
          // {
          //   label: "采收产品",
          //   prop: "farmArea",
          //   span: 12,
          //   labelWidth: 145,
          //   width: 110,
          //   rules: [
          //     {
          //       required: true,
          //       message: "请输入采收产品",
          //       trigger: "click",
          //     },
          //   ],
          // },
          {
            label: "操作人",
            prop: "operator",
            type: "tree",
            dicData: [],
            prop: "landType",
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=land",
            props: {
              label: "realName",
              value: "id",
              label: "dictValue",
              value: "dictKey"
            },
            span: 12,
            labelWidth: 145,
            width: 110,
            rules: [
              {
                required: true,
                message: "请输入操作人",
                trigger: "click",
              },
            ],
            dataType: "number",
            rules: [{
              required: true,
              message: "请选择地块类型",
              trigger: "blur"
            }]
          },
          {
            label: "产品等级",
            prop: "leaves",
            span: 12,
            labelWidth: 145,
            width: 110,
            value:"0",
            label: "面积单位",
            prop: "landUnit",
            type: "select",
            dicData:[
              {
                label:"一等品",
                value:"0"
              },
              {
                label:"二等品",
                value:"1"
              },
              {
                label:"三等品",
                value:"2"
              },
              {
                label:"四等品",
                value:"3"
              },
              {
                label:"五等品",
                value:"4"
              },
            ],
            rules: [
              {
                required: true,
                message: "请输入产品等级",
                trigger: "click",
              },
            ],
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=landunit",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
            dataType: "number",
            span: 6,
          },
          {
            label: "备注",
            prop: "remark",
            label: "地块展示",
            labelWidth: "0",
            prop: "line",
            className: "mapClass",
            span: 24,
            type:"textarea",
            labelWidth: 145,
            width: 110,
            rules: [
              {
                required: false,
                message: "请输入备注",
                trigger: "click",
              },
            ],
          },
            formslot: true,
          }
        ],
      },
      visible: false,
    };
  },
  computed: {
    ...mapState({
      userInfo: (state) => state.user.userInfo,
    }),
    ...mapGetters(["userInfo", "permission", "polygons"]),
  },
  methods: {
    //计算当前时间
    getNowTime(){
        var date = new Date();
        //年 getFullYear():四位数字返回年份
        var year = date.getFullYear();  //getFullYear()代替getYear()
        //月 getMonth():0 ~ 11
        var month = date.getMonth() + 1;
        //日 getDate():(1 ~ 31)
        var day = date.getDate();
        //时 getHours():(0 ~ 23)
        var hour = date.getHours();
        //分 getMinutes(): (0 ~ 59)
        var minute = date.getMinutes();
        //秒 getSeconds():(0 ~ 59)
        var second = date.getSeconds();
        //赋值
        this.form['time'] = year + '-'
                          + this.addZero(month) + '-'
                          + this.addZero(day) + ' '
                          + this.addZero(hour) + ':'
                          + this.addZero(minute);
    },
    //小于10的拼接上0字符串
    addZero(s) {
      return s < 10 ? ('0' + s) : s;
    },
    //初始化
    init(data) {
      this.form = {
        farmPlantId:data.id,
        strainId:data.strainId,
        landId:data.landId,
        weight:data.weight,
        leaves:'0',
        jobWay:data.jobWay,
        operator:data.operator,
        remark:''
      };
      this.form['operator'] = this.userInfo.user_id;
    init() {
      //计算当前时间
      this.getNowTime();
      this.visible = true;
      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;
        }
      });
      //获取农产品数据
      getStrainList(0).then((res)=>{
          if(res.data.code==200){
              var strainId = that.findObject(that.option.column,"strainId");
              strainId.dicData = res.data.data;
          }
      })
    },
    // 表单提交
    submit(row,loading,done) {
    submit(row,loading) {
      var that = this;
      row.time = row.time + ":00";
      save(row).then(
        () => {
          this.$refs.form.resetFields();
          that.visible = false;
          this.$message({
            type: "success",
            message: "操作成功!",
          });
           done();
        },
        (error) => {
          done();
          window.console.log(error);
      if (this.polygons.length == 0) {
        //没有面的数据
        this.$refs.getMapData.isCheck = true;
        loading();
      } else {
        //如果有值,空间坐标转换
        let pol = this.polygons;
        let polLength = this.polygons.length - 1;
        let usePolygons = "";
        for (let k in pol) {
          usePolygons += pol[k].lng + "," + pol[k].lat;
          if (k != polLength) {
            usePolygons += ";";
          }
        }
      );
        //设置坐标点
        row.userId = this.userInfo.user_id;
        row.landRange = usePolygons;
      }
      add(row).then(() => {
        that.$refs.form.resetFields();
        that.visible = false;
        this.$message({
          type: "success",
          message: "操作成功!"
        });
      }, error => {
        loading();
        window.console.log(error);
      });
    },
    setMapData(val) {
      this.LineData = val[0];
      this.PointData = val[1];
    },
  },
};
</script>
<style lang="scss" scoped>
.mapClass div label {
  display: none;
}
#getMapData {
  width: 90%;
  position: relative;
  height: 400px;
  top: 10px;
  left: 90px;
}
</style>
src/views/wel/stock.vue
@@ -15,14 +15,11 @@
<script>
import { mapState } from "vuex";
import { getLandList } from "@/api/land/land";
import { getUserList } from "@/api/system/user";
import { getStrainList } from "@/api/farmplant/strain";
import { save } from "@/api/farmplant/recovery";
import { add } from "@/api/stock/stock";
export default {
  data() {
    return {
      title:"采收/捕捞",
      title:"农资入库",
      form: {},
      option: {
        emptyBtn: false,
@@ -30,193 +27,128 @@
        gutter: 30,
        column: [
          {
            label: "采收品种",
            prop: "strainId",
            span: 12,
            type: "tree",
            dicData: [],
            label: "农资",
            prop: "stockId",
            span: 24,
            type: "select",
            dicUrl: "/api/stockfactory/stockfactory/selectStockFa",
            props: {
              label: "strainName",
              value: "id"
              label: "dictValue",
              value: "dictKey"
            },
            labelWidth: 145,
            rules: [
              {
                required: true,
                message: "请输入采收品种",
                trigger: "blur",
              },
            ],
            disabled:true,
            rules: [{
              required: true,
              message: "请输入农资",
              trigger: "blur"
            }]
          },
          {
            label: "采收地块",
            span: 12,
            labelWidth: 145,
            width: 110,
            prop: "landId",
            type:"tree",
            dicData: [],
            label: "规格",
            prop: "specs",
            value:"10",
            span: 6,
            rules: [{
              required: true,
              message: "请输入规格",
              trigger: "blur"
            }]
          },
          {
            label: "规格值1",
            prop: "specsValue1",
            span: 6,
            value:"0",
            type: "select",
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=stockSpecs1",
            props: {
              label: "landName",
              value: "id"
              label: "dictValue",
              value: "dictKey"
            },
            rules: [
              {
                required: true,
                message: "请选择采收地块",
                trigger: "click",
              },
            ],
            dataType: "number",
          },
          {
            label: "采收重量",
            prop: "weight",
            tip: '公斤',
            span: 12,
            labelWidth: 145,
            width: 110,
            controls:false,
            type:'number',
            rules: [
              {
                required: true,
                message: "请输入采收重量 公斤",
                trigger: "click",
              },
            ],
            label: "规格值2",
            prop: "specsValue2",
            value:"0",
            span: 6,
            type: "select",
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=stockSpecs2",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
            dataType: "number",
          },
          {
            label: "作业方式",
            prop: "jobWay",
            span: 12,
            labelWidth: 145,
            width: 110,
            label: "入库数量",
            span: 6,
            type: "number",
            prop: "amount",
            rules: [{
              required: true,
              message: "请输入入库数量",
              trigger: "blur"
            }]
          },
          {
            label: "入库类型",
            prop: "type",
            type: "select",
            value:"0",
            dicData:[
              {
                label:"人工",
                value:"0"
              },
              {
                label:"机械",
                value:"1"
              },
            ],
            rules: [
              {
                required: true,
                message: "请选择作业方式",
                trigger: "click",
              },
            ],
            span: 12,
            searchSpan: 4,
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=stockPurchase",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
            dataType: "number",
            rules: [{
              required: true,
              message: "请输入入库类型",
              trigger: "blur"
            }]
          },
          {
            label: "采收时间",
            label: "入库时间",
            prop: "time",
            type: "date",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            span: 12,
            labelWidth: 145,
            width: 110,
            type: "datetime",
            format: "yyyy-MM-dd HH:mm",
            valueFormat: "yyyy-MM-dd HH:mm",
            rules: [
              {
                required: true,
                message: "请选择采收时间",
                trigger: "click",
              },
            ],
            rules: [{
              required: true,
              message: "请输入入库时间",
              trigger: "blur"
            }]
          },
          // {
          //   label: "采收产品",
          //   prop: "farmArea",
          //   span: 12,
          //   labelWidth: 145,
          //   width: 110,
          //   rules: [
          //     {
          //       required: true,
          //       message: "请输入采收产品",
          //       trigger: "click",
          //     },
          //   ],
          // },
          {
            label: "操作人",
            prop: "operator",
            type: "tree",
            dicData: [],
            props: {
              label: "realName",
              value: "id",
            label: "单据、凭证照片",
            prop: "picture",
            type: "upload",
            labelWidth: 120,
            dataType: "string",
            span: 24,
            limit: 5,
            listType: "picture-card",
            tip: "建议上传手机横屏拍摄的照片,宽高比16:9,最多上传5张",
            canvasOption: {
              text: "",
              ratio: 1.0,
            },
            span: 12,
            labelWidth: 145,
            width: 110,
            rules: [
              {
                required: true,
                message: "请输入操作人",
                trigger: "click",
              },
            ],
          },
          {
            label: "产品等级",
            prop: "leaves",
            span: 12,
            labelWidth: 145,
            width: 110,
            value:"0",
            type: "select",
            dicData:[
              {
                label:"一等品",
                value:"0"
              },
              {
                label:"二等品",
                value:"1"
              },
              {
                label:"三等品",
                value:"2"
              },
              {
                label:"四等品",
                value:"3"
              },
              {
                label:"五等品",
                value:"4"
              },
            ],
            rules: [
              {
                required: true,
                message: "请输入产品等级",
                trigger: "click",
              },
            ],
            propsHttp: {
              res: "data",
              url: "url"
            },
            action: "/api/blade-resource/oss/endpoint/put-files"
          },
          {
            label: "备注",
            prop: "remark",
            type: "textarea",
            prop: "remarks",
            span: 24,
            type:"textarea",
            labelWidth: 145,
            width: 110,
            rules: [
              {
                required: false,
                message: "请输入备注",
                trigger: "click",
              },
            ],
          },
        ],
        ]
      },
      visible: false,
    };
@@ -246,73 +178,32 @@
        this.form['time'] = year + '-' 
                          + this.addZero(month) + '-' 
                          + this.addZero(day) + ' ' 
                          + this.addZero(hour) + ':'
                          + this.addZero(minute);
                          + this.addZero(hour);
    },
    //小于10的拼接上0字符串
    addZero(s) {
      return s < 10 ? ('0' + s) : s;
    },
    //初始化
    init(data) {
      this.form = {
        farmPlantId:data.id,
        strainId:data.strainId,
        landId:data.landId,
        weight:data.weight,
        leaves:'0',
        jobWay:data.jobWay,
        operator:data.operator,
        remark:''
      };
      this.form['operator'] = this.userInfo.user_id;
    init() {
      this.visible = true;
      //计算当前时间
      this.getNowTime();
      this.visible = true;
      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;
        }
      });
      //获取农产品数据
      getStrainList(0).then((res)=>{
          if(res.data.code==200){
              var strainId = that.findObject(that.option.column,"strainId");
              strainId.dicData = res.data.data;
          }
      })
    },
    // 表单提交
    submit(row,loading,done) {
    submit(row,loading) {
      var that = this;
      row.time = row.time + ":00";
      save(row).then(
      add(row).then(
        () => {
          this.$refs.form.resetFields();
          that.$refs.form.resetFields();
          that.visible = false;
          this.$message({
            type: "success",
            message: "操作成功!",
          });
           done();
        },
        (error) => {
          done();
          loading();
          window.console.log(error);
        }
      );