From 7dc07507ec0d74babadd096b32a4e19ae87b1724 Mon Sep 17 00:00:00 2001
From: zhongrj <123456>
Date: Fri, 29 Jul 2022 10:40:53 +0800
Subject: [PATCH] 种养品新增监测报告

---
 src/views/farm/farmReport.vue     |    2 
 src/views/farmplant/detection.vue |  308 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/views/farmplant/farmplant.vue |   49 ++++++--
 3 files changed, 345 insertions(+), 14 deletions(-)

diff --git a/src/views/farm/farmReport.vue b/src/views/farm/farmReport.vue
index 5b48fbf..f01492c 100644
--- a/src/views/farm/farmReport.vue
+++ b/src/views/farm/farmReport.vue
@@ -155,7 +155,7 @@
   methods: {
     //新增
     rowSave(row, done, loading) {
-      row["deptId"] = this.farmId;
+      row["farmId"] = this.farmId;
       row["type"] = 1;
       save(row).then(
         () => {
diff --git a/src/views/farmplant/detection.vue b/src/views/farmplant/detection.vue
new file mode 100644
index 0000000..1bf1f36
--- /dev/null
+++ b/src/views/farmplant/detection.vue
@@ -0,0 +1,308 @@
+  <template>
+  <div>
+    <el-dialog
+      title="检测报告"
+      :modal-append-to-body="false"
+      :append-to-body="true"
+      :close-on-click-modal="false"
+      @close="close"
+      width="60%"
+      :visible.sync="visible"
+      center
+    >
+    <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"
+    >
+      <template slot="menuLeft">
+        <el-button
+          type="danger"
+          size="small"
+          icon="el-icon-delete"
+          plain
+          @click="handleDelete"
+          >删 除
+        </el-button>
+      </template>
+    </avue-crud>
+  </el-dialog>
+</div>
+</template>
+
+
+<script>
+import { getDetail, getList, update, remove, save } from "@/api/farm/farmPaper";
+import { mapGetters } from "vuex";
+export default {
+  props: ["farmId"],
+  data() {
+    return {
+      farmPlantId:null,
+      visible: true,
+      form: {},
+      query: {},
+      loading: true,
+      excelBox: false,
+      page: {
+        pageSize: 10,
+        currentPage: 1,
+        total: 0,
+      },
+      selectionList: [],
+      option: {
+        tip: false,
+        searchSize: "mini",
+        searchMenuSpan: 8,
+        height: "400",
+        editBtn: true,
+        delBtn: true,
+        viewBtn: true,
+        menuWidth: 200,
+        menuAlign: "center",
+        align: "center",
+        selection: true,
+        column: [
+          {
+            label: "检测项目",
+            prop: "name",
+            rules: [
+              {
+                required: true,
+                message: "请输入检测项目",
+                trigger: "blur",
+              },
+            ],
+          },
+          {
+            label: "检测机构",
+            prop: "organName",
+            rules: [
+              {
+                required: true,
+                message: "请输入检测机构",
+                trigger: "blur",
+              },
+            ],
+          },
+          {
+            label: "报告编号",
+            prop: "code",
+            rules: [
+              {
+                required: true,
+                message: "请输入报告编号",
+                trigger: "blur",
+              },
+            ],
+          },
+          {
+            label: "颁发日期",
+            prop: "time",
+            type: "date",
+            format: "yyyy-MM-dd",
+            valueFormat: "yyyy-MM-dd",
+            rules: [
+              {
+                required: true,
+                message: "请选择颁发日期",
+                trigger: "blur",
+              },
+            ],
+          },
+          {
+            label: "报告图片",
+            prop: "pictures",
+            type: "upload",
+            dataType: "string",
+            span: 24,
+            limit: 3,
+            listType: "picture-card",
+            tip: "只能上传jpg/png文件,最多上传3张",
+            propsHttp: {
+              res: "data",
+              url: "url"
+            },
+            action: "/api/blade-resource/oss/endpoint/put-files"
+          },
+        ],
+      },
+      data: [],
+    };
+  },
+  created() { 
+    
+  },
+  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: {
+    init(id) {
+      this.visible = true;
+      this.farmPlantId = id;
+      this.onLoad(this.page);
+    },
+    //新增
+    rowSave(row, done, loading) {
+      row["farmId"] = this.farmPlantId;
+      //种养品
+      row["type"] = 3;
+      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;
+      params['type'] = 3;
+      params['farmId'] = this.farmPlantId;
+      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 984346b..b6aec24 100644
--- a/src/views/farmplant/farmplant.vue
+++ b/src/views/farmplant/farmplant.vue
@@ -30,7 +30,18 @@
           >删 除
         </el-button>
       </template>
+      <template slot-scope="{ type, size, row }" slot="menu">
+        <el-button
+          :type="type"
+          :size="size"
+          icon="el-icon-money"
+          @click="handleDetection(row)"
+          >检测报告
+        </el-button>
+      </template>
     </avue-crud>
+    <!-- 检测报告 -->
+    <detection v-if="detectionVisible" ref="detection"></detection>
   </basic-container>
 </template>
 
@@ -39,12 +50,17 @@
 import { getStrainList } from "@/api/farmplant/strain";
 import { getLandList } from "@/api/land/land";
 import { mapGetters } from "vuex";
+import detection from "./detection.vue";
 export default {
+  components: {
+    detection
+  },
    props:[
     "type","activeName"
   ],
   data() {
     return {
+      detectionVisible:false,
       visible: true,
       form: {},
       query: {},
@@ -63,7 +79,7 @@
         editBtn: true,
         delBtn: true,
         viewBtn: true,
-        menuWidth: 200,
+        menuWidth: 280,
         menuAlign: "center",
         align: "center",
         selection: true,
@@ -259,7 +275,7 @@
                 required: true,
                 message: "请输入作业方式",
                 trigger: "blur",
-              },  
+              },
             ],
             // display:false,
           },
@@ -275,7 +291,7 @@
                 required: true,
                 message: "请选择移栽时间",
                 trigger: "blur",
-              },  
+              },
             ],
             // display:false,
           },
@@ -292,7 +308,7 @@
                 required: false,
                 message: "请选预计采收时间",
                 trigger: "blur",
-              },  
+              },
             ],
             // display:false,
           },
@@ -307,13 +323,13 @@
                 required: false,
                 message: "请输入预计亩产",
                 trigger: "blur",
-              },  
+              },
             ],
             // display:false,
           },
           {
             label: "株数",
-            prop: "plantNumber", 
+            prop: "plantNumber",
             labelWidth:110,
             type:"number",
             hide:true,
@@ -322,7 +338,7 @@
                 required: false,
                 message: "请输入株数",
                 trigger: "blur",
-              },  
+              },
             ],
             // display:false,
           },
@@ -337,7 +353,7 @@
                 required: false,
                 message: "请输入株间距",
                 trigger: "blur",
-              },  
+              },
             ],
             // display:false,
           },
@@ -354,7 +370,7 @@
           //       required: true,
           //       message: "请选择投苗时间",
           //       trigger: "blur",
-          //     },  
+          //     },
           //   ],
           //   display:false,
           // },
@@ -369,7 +385,7 @@
           //       required: true,
           //       message: "请输入养殖数量",
           //       trigger: "blur",
-          //     },  
+          //     },
           //   ],
           //   display:false,
           // },
@@ -440,7 +456,7 @@
     //             required: false,
     //             message: "请输入预计亩产",
     //             trigger: "blur",
-    //           }, 
+    //           },
     //         ],
     //       plantNumbercolumn.display = true;
     //       plantSpacingcolumn.display = true;
@@ -490,7 +506,7 @@
     //             required: true,
     //             message: "请输入养殖数量",
     //             trigger: "blur",
-    //           },  
+    //           },
     //         ],
     //       plantNumbercolumn.display = false;
     //       plantSpacingcolumn.display = false;
@@ -557,7 +573,7 @@
               strainId.dicData = res.data.data;
           }
       })
-      
+
     },
     //新增
     rowSave(row, done, loading) {
@@ -685,6 +701,13 @@
         this.selectionClear();
       });
     },
+    //检测报告
+    handleDetection(row){
+      this.detectionVisible = true;
+      this.$nextTick(() => {
+        this.$refs.detection.init(row.id);
+      });
+    },
   },
 };
 </script>

--
Gitblit v1.9.3