智慧农业后台管理页面
shuishen
2022-07-29 d6a0abe9024f87fc517a2b71df0f17c5cadc41a0
src/views/remote/remote.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.remote_delete"
                   @click="handleDelete">删 除
        </el-button>
                    @click="handleDelete"
                >删 除</el-button>
      </template>
    </avue-crud>
  </basic-container>
</template>
<script>
import {getList, getDetail, add, update, remove} from "@/api/remote/remote";
import {mapGetters} from "vuex";
import { getList, getDetail, add, update, remove } from "@/api/remote/remote"
import { mapGetters } from "vuex"
export default {
  data() {
@@ -209,7 +212,7 @@
        ]
      },
      data: []
    };
        }
  },
  computed: {
    ...mapGetters(["permission"]),
@@ -219,42 +222,42 @@
        viewBtn: this.vaildData(this.permission.remote_view, false),
        delBtn: this.vaildData(this.permission.remote_delete, false),
        editBtn: this.vaildData(this.permission.remote_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);
                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("确定将选择数据删除?", {
@@ -263,20 +266,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: "确定",
@@ -284,73 +287,73 @@
        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 = {}) {
      const {releaseTimeRange} = this.query;
            const { releaseTimeRange } = this.query
      let values = {
        ...params,
        ...this.query
      };
            }
      if (releaseTimeRange) {
        values = {
          ...values,
          releaseTime_datege: releaseTimeRange[0],
          releaseTime_datelt: releaseTimeRange[1],
        };
        values.releaseTimeRange = null;
      }
      this.loading = true;
                values.releaseTimeRange = null
            }
            this.loading = true
      getList(page.currentPage, page.pageSize, values).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()
            })
    }
  }
};