智慧农业后台管理页面
shuishen
2022-07-29 e57c42d8338904f0045a72665f2ad43b5012cc53
src/views/process/process.vue
@@ -1,6 +1,7 @@
<template>
  <basic-container>
    <avue-crud :option="option"
        <avue-crud
            :option="option"
               :table-loading="loading"
               :data="data"
               :page.sync="page"
@@ -17,23 +18,25 @@
               @current-change="currentChange"
               @size-change="sizeChange"
               @refresh-change="refreshChange"
               @on-load="onLoad">
            @on-load="onLoad"
        >
      <template slot="menuLeft">
        <el-button type="danger"
                <el-button
                    type="danger"
                   size="small"
                   icon="el-icon-delete"
                   plain
                   v-if="permission.process_delete"
                   @click="handleDelete">删 除
        </el-button>
                    @click="handleDelete"
                >删 除</el-button>
      </template>
    </avue-crud>
  </basic-container>
</template>
<script>
  import {getList, getDetail, add, update, remove} from "@/api/process/process";
  import {mapGetters} from "vuex";
import { getList, getDetail, addjg, update, remove } from "@/api/process/process"
import { mapGetters } from "vuex"
  export default {
    data() {
@@ -116,7 +119,7 @@
          ]
        },
        data: []
      };
        }
    },
    computed: {
      ...mapGetters(["permission"]),
@@ -126,42 +129,42 @@
          viewBtn: this.vaildData(this.permission.process_view, false),
          delBtn: this.vaildData(this.permission.process_delete, false),
          editBtn: this.vaildData(this.permission.process_edit, false)
        };
            }
      },
      ids() {
        let ids = [];
            let ids = []
        this.selectionList.forEach(ele => {
          ids.push(ele.id);
        });
        return ids.join(",");
                ids.push(ele.id)
            })
            return ids.join(",")
      }
    },
    methods: {
      rowSave(row, done, loading) {
        add(row).then(() => {
          this.onLoad(this.page);
            addjg(row).then(() => {
                this.onLoad(this.page)
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
                })
                done()
        }, error => {
          loading();
          window.console.log(error);
        });
                loading()
                window.console.log(error)
            })
      },
      rowUpdate(row, index, done, loading) {
        update(row).then(() => {
          this.onLoad(this.page);
                this.onLoad(this.page)
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
                })
                done()
        }, error => {
          loading();
          console.log(error);
        });
                loading()
                console.log(error)
            })
      },
      rowDel(row) {
        this.$confirm("确定将选择数据删除?", {
@@ -170,20 +173,20 @@
          type: "warning"
        })
          .then(() => {
            return remove(row.id);
                    return remove(row.id)
          })
          .then(() => {
            this.onLoad(this.page);
                    this.onLoad(this.page)
            this.$message({
              type: "success",
              message: "操作成功!"
            });
          });
                    })
                })
      },
      handleDelete() {
        if (this.selectionList.length === 0) {
          this.$message.warning("请选择至少一条数据");
          return;
                this.$message.warning("请选择至少一条数据")
                return
        }
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
@@ -191,60 +194,60 @@
          type: "warning"
        })
          .then(() => {
            return remove(this.ids);
                    return remove(this.ids)
          })
          .then(() => {
            this.onLoad(this.page);
                    this.onLoad(this.page)
            this.$message({
              type: "success",
              message: "操作成功!"
            });
            this.$refs.crud.toggleSelection();
          });
                    })
                    this.$refs.crud.toggleSelection()
                })
      },
      beforeOpen(done, type) {
        if (["edit", "view"].includes(type)) {
          getDetail(this.form.id).then(res => {
            this.form = res.data.data;
          });
                    this.form = res.data.data
                })
        }
        done();
            done()
      },
      searchReset() {
        this.query = {};
        this.onLoad(this.page);
            this.query = {}
            this.onLoad(this.page)
      },
      searchChange(params, done) {
        this.query = params;
        this.page.currentPage = 1;
        this.onLoad(this.page, params);
        done();
            this.query = params
            this.page.currentPage = 1
            this.onLoad(this.page, params)
            done()
      },
      selectionChange(list) {
        this.selectionList = list;
            this.selectionList = list
      },
      selectionClear() {
        this.selectionList = [];
        this.$refs.crud.toggleSelection();
            this.selectionList = []
            this.$refs.crud.toggleSelection()
      },
      currentChange(currentPage){
        this.page.currentPage = currentPage;
            this.page.currentPage = currentPage
      },
      sizeChange(pageSize){
        this.page.pageSize = pageSize;
            this.page.pageSize = pageSize
      },
      refreshChange() {
        this.onLoad(this.page, this.query);
            this.onLoad(this.page, this.query)
      },
      onLoad(page, params = {}) {
        this.loading = true;
            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();
        });
                const data = res.data.data
                this.page.total = data.total
                this.data = data.records
                this.loading = false
                this.selectionClear()
            })
      }
    }
  };