From bb142f86352bb0ebc1ffdb5bfc488b774e12667f Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Fri, 13 May 2022 16:12:27 +0800
Subject: [PATCH] 新增农事操作记录页面

---
 src/api/system/user.js               |  190 +++++++------
 src/api/stockfactory/stockfactory.js |   74 ++--
 src/views/farm/farmingrecord.vue     |  434 +++++++++++++++++++++++++++++++
 src/views/farmplant/farmplant.vue    |   25 +
 src/api/farm/farmingrecord.js        |   48 +++
 src/api/stock/stock.js               |   69 ++--
 6 files changed, 672 insertions(+), 168 deletions(-)

diff --git a/src/api/farm/farmingrecord.js b/src/api/farm/farmingrecord.js
new file mode 100644
index 0000000..804fa66
--- /dev/null
+++ b/src/api/farm/farmingrecord.js
@@ -0,0 +1,48 @@
+import request from '@/router/axios';
+
+export const getList = (current, size, params) => {
+    return request({
+        url: '/api/farmingRecord/page',
+        method: 'get',
+        params: {
+            ...params,
+            current,
+            size,
+        }
+    })
+}
+export const remove = (ids) => {
+    return request({
+        url: '/api/farmingRecord/remove',
+        method: 'post',
+        params: {
+            ids,
+        }
+    })
+}
+
+export const save = (row) => {
+    return request({
+        url: '/api/farmingRecord/save',
+        method: 'post',
+        data: row
+    })
+}
+
+export const update = (row) => {
+    return request({
+        url: '/api/farmingRecord/update',
+        method: 'post',
+        data: row
+    })
+}
+
+export const getDetail = (id) => {
+    return request({
+        url: '/api/farmingRecord/detail',
+        method: 'get',
+        params: {
+            id
+        }
+    })
+}
\ No newline at end of file
diff --git a/src/api/stock/stock.js b/src/api/stock/stock.js
index 58511c3..3601db7 100644
--- a/src/api/stock/stock.js
+++ b/src/api/stock/stock.js
@@ -1,50 +1,49 @@
 import request from '@/router/axios';
 
 export const getList = (current, size, params) => {
-  return request({
-    url: '/api/stock/stock/page',
-    method: 'get',
-    params: {
-      ...params,
-      current,
-      size,
-    }
-  })
+    return request({
+        url: '/api/stock/stock/page',
+        method: 'get',
+        params: {
+            ...params,
+            current,
+            size,
+        }
+    })
 }
 
 export const getDetail = (id) => {
-  return request({
-    url: '/api/stock/stock/detail',
-    method: 'get',
-    params: {
-      id
-    }
-  })
+    return request({
+        url: '/api/stock/stock/detail',
+        method: 'get',
+        params: {
+            id
+        }
+    })
 }
 
 export const remove = (ids) => {
-  return request({
-    url: '/api/stock/stock/remove',
-    method: 'post',
-    params: {
-      ids,
-    }
-  })
+    return request({
+        url: '/api/stock/stock/remove',
+        method: 'post',
+        params: {
+            ids,
+        }
+    })
 }
 
 export const add = (row) => {
-  return request({
-    url: '/api/stock/stock/save',
-    method: 'post',
-    data: row
-  })
+    return request({
+        url: '/api/stock/stock/save',
+        method: 'post',
+        data: row
+    })
 }
 
 export const update = (row) => {
-  return request({
-    url: '/api/stock/stock/submit',
-    method: 'post',
-    data: row
-  })
-}
-
+    return request({
+        url: '/api/stock/stock/submit',
+        method: 'post',
+        data: row
+    })
+}
\ No newline at end of file
diff --git a/src/api/stockfactory/stockfactory.js b/src/api/stockfactory/stockfactory.js
index 1d08b04..c23ffe2 100644
--- a/src/api/stockfactory/stockfactory.js
+++ b/src/api/stockfactory/stockfactory.js
@@ -1,50 +1,58 @@
 import request from '@/router/axios';
 
 export const getList = (current, size, params) => {
-  return request({
-    url: '/api/stockfactory/stockfactory/list',
-    method: 'get',
-    params: {
-      ...params,
-      current,
-      size,
-    }
-  })
+    return request({
+        url: '/api/stockfactory/stockfactory/list',
+        method: 'get',
+        params: {
+            ...params,
+            current,
+            size,
+        }
+    })
 }
 
 export const getDetail = (id) => {
-  return request({
-    url: '/api/stockfactory/stockfactory/detail',
-    method: 'get',
-    params: {
-      id
-    }
-  })
+    return request({
+        url: '/api/stockfactory/stockfactory/detail',
+        method: 'get',
+        params: {
+            id
+        }
+    })
 }
 
 export const remove = (ids) => {
-  return request({
-    url: '/api/stockfactory/stockfactory/remove',
-    method: 'post',
-    params: {
-      ids,
-    }
-  })
+    return request({
+        url: '/api/stockfactory/stockfactory/remove',
+        method: 'post',
+        params: {
+            ids,
+        }
+    })
 }
 
 export const add = (row) => {
-  return request({
-    url: '/api/stockfactory/stockfactory/submit',
-    method: 'post',
-    data: row
-  })
+    return request({
+        url: '/api/stockfactory/stockfactory/submit',
+        method: 'post',
+        data: row
+    })
 }
 
 export const update = (row) => {
-  return request({
-    url: '/api/stockfactory/stockfactory/submit',
-    method: 'post',
-    data: row
-  })
+    return request({
+        url: '/api/stockfactory/stockfactory/submit',
+        method: 'post',
+        data: row
+    })
 }
 
+
+export const selectStockFa = () => {
+    return request({
+        url: '/api/stockfactory/stockfactory/selectStockFa',
+        method: 'get',
+        params: {}
+    })
+}
\ No newline at end of file
diff --git a/src/api/system/user.js b/src/api/system/user.js
index c8a8101..e2f01df 100644
--- a/src/api/system/user.js
+++ b/src/api/system/user.js
@@ -1,130 +1,140 @@
 import request from '@/router/axios';
 
 export const getList = (current, size, params, deptId) => {
-  return request({
-    url: '/api/blade-user/page',
-    method: 'get',
-    params: {
-      ...params,
-      current,
-      size,
-      deptId,
-    }
-  })
+    return request({
+        url: '/api/blade-user/page',
+        method: 'get',
+        params: {
+            ...params,
+            current,
+            size,
+            deptId,
+        }
+    })
 }
 
 export const remove = (ids) => {
-  return request({
-    url: '/api/blade-user/remove',
-    method: 'post',
-    params: {
-      ids,
-    }
-  })
+    return request({
+        url: '/api/blade-user/remove',
+        method: 'post',
+        params: {
+            ids,
+        }
+    })
 }
 
 export const add = (row) => {
-  return request({
-    url: '/api/blade-user/submit',
-    method: 'post',
-    data: row
-  })
+    return request({
+        url: '/api/blade-user/submit',
+        method: 'post',
+        data: row
+    })
 }
 
 export const update = (row) => {
-  return request({
-    url: '/api/blade-user/update',
-    method: 'post',
-    data: row
-  })
+    return request({
+        url: '/api/blade-user/update',
+        method: 'post',
+        data: row
+    })
 }
 
 export const updatePlatform = (userId, userType, userExt) => {
-  return request({
-    url: '/api/blade-user/update-platform',
-    method: 'post',
-    params: {
-      userId,
-      userType,
-      userExt,
-    }
-  })
+    return request({
+        url: '/api/blade-user/update-platform',
+        method: 'post',
+        params: {
+            userId,
+            userType,
+            userExt,
+        }
+    })
 }
 
 export const getUser = (id) => {
-  return request({
-    url: '/api/blade-user/detail',
-    method: 'get',
-    params: {
-      id,
-    }
-  })
+    return request({
+        url: '/api/blade-user/detail',
+        method: 'get',
+        params: {
+            id,
+        }
+    })
 }
 
 export const getUserPlatform = (id) => {
-  return request({
-    url: '/api/blade-user/platform-detail',
-    method: 'get',
-    params: {
-      id,
-    }
-  })
+    return request({
+        url: '/api/blade-user/platform-detail',
+        method: 'get',
+        params: {
+            id,
+        }
+    })
 }
 
 export const getUserInfo = () => {
-  return request({
-    url: '/api/blade-user/info',
-    method: 'get',
-  })
+    return request({
+        url: '/api/blade-user/info',
+        method: 'get',
+    })
 }
 
 export const resetPassword = (userIds) => {
-  return request({
-    url: '/api/blade-user/reset-password',
-    method: 'post',
-    params: {
-      userIds,
-    }
-  })
+    return request({
+        url: '/api/blade-user/reset-password',
+        method: 'post',
+        params: {
+            userIds,
+        }
+    })
 }
 
 export const updatePassword = (oldPassword, newPassword, newPassword1) => {
-  return request({
-    url: '/api/blade-user/update-password',
-    method: 'post',
-    params: {
-      oldPassword,
-      newPassword,
-      newPassword1,
-    }
-  })
+    return request({
+        url: '/api/blade-user/update-password',
+        method: 'post',
+        params: {
+            oldPassword,
+            newPassword,
+            newPassword1,
+        }
+    })
 }
 
 export const updateInfo = (row) => {
-  return request({
-    url: '/api/blade-user/update-info',
-    method: 'post',
-    data: row
-  })
+    return request({
+        url: '/api/blade-user/update-info',
+        method: 'post',
+        data: row
+    })
 }
 
 export const grant = (userIds, roleIds) => {
-  return request({
-    url: '/api/blade-user/grant',
-    method: 'post',
-    params: {
-      userIds,
-      roleIds,
-    }
-  })
+    return request({
+        url: '/api/blade-user/grant',
+        method: 'post',
+        params: {
+            userIds,
+            roleIds,
+        }
+    })
 }
 
 export const unlock = (userIds) => {
-  return request({
-    url: '/api/blade-user/unlock',
-    method: 'post',
-    params: {
-      userIds,
-    }
-  })
+    return request({
+        url: '/api/blade-user/unlock',
+        method: 'post',
+        params: {
+            userIds,
+        }
+    })
 }
+
+export const getUserList = (params) => {
+    return request({
+        url: '/api/blade-user/getUserList',
+        method: 'get',
+        params: {
+            ...params,
+        }
+    })
+}
\ No newline at end of file
diff --git a/src/views/farm/farmingrecord.vue b/src/views/farm/farmingrecord.vue
new file mode 100644
index 0000000..01a71ed
--- /dev/null
+++ b/src/views/farm/farmingrecord.vue
@@ -0,0 +1,434 @@
+<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/farm/farmingrecord";
+import { getLandList } from "@/api/land/land";
+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",
+            },
+            rules: [
+              {
+                required: true,
+                message: "请选择农事类型",
+                trigger: "blur",
+              },
+            ],
+          },
+          {
+            label: "所属地块",
+            prop: "landId",
+            searchSpan: 4,
+            search: true,
+            type: "tree",
+            hide: true,
+            dicData: [],
+            props: {
+              label: "landName",
+              value: "id",
+            },
+            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;
+        }
+      },
+      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();
+        },
+        (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>
diff --git a/src/views/farmplant/farmplant.vue b/src/views/farmplant/farmplant.vue
index 527a980..bd86f3a 100644
--- a/src/views/farmplant/farmplant.vue
+++ b/src/views/farmplant/farmplant.vue
@@ -487,7 +487,9 @@
       immediate: true
     },
   },
-  created() {},
+  created() {
+    this.initData();
+  },
   computed: {
     ...mapGetters(["permission", "userInfo"]),
     // permissionList() {
@@ -508,6 +510,18 @@
   },
   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;
+          }
+      })
+    },
     //新增
     rowSave(row, done, loading) {
       save(row).then(
@@ -583,20 +597,11 @@
         });
     },
     beforeOpen(done, type) {
-      var that = this;
       if (["edit", "view"].includes(type)) {
         getDetail(this.form.id).then((res) => {
           this.form = res.data.data;
         });
       }
-      //获取农地数据
-      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;
-          }
-      })
       done();
     },
     searchReset() {

--
Gitblit v1.9.3