无人机管理后台前端(已迁走)
张含笑
2025-08-05 c832bf2e80ac465e71b7a1c1f7a59d4252030989
src/views/monitor/log/api.vue
@@ -1,31 +1,19 @@
<template>
  <basic-container>
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      ref="crud"
      v-model="form"
      :permission="permissionList"
      :before-open="beforeOpen"
      v-model:page="page"
      @search-change="searchChange"
      @search-reset="searchReset"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
    <avue-crud :option="option" :table-loading="loading" :data="data" ref="crud" v-model="form"
      :permission="permissionList" :before-open="beforeOpen" v-model:page="page" @search-change="searchChange"
      @search-reset="searchReset" @current-change="currentChange" @size-change="sizeChange"
      @refresh-change="refreshChange" @on-load="onLoad">
    </avue-crud>
  </basic-container>
</template>
<script>
import { getApiList, getApiLogs } from '@/api/logs';
import { mapGetters } from 'vuex';
import { getApiList, getApiLogs } from '@/api/logs'
import { mapGetters } from 'vuex'
export default {
  data() {
  data () {
    return {
      form: {},
      selectionList: [],
@@ -37,8 +25,8 @@
        total: 0,
      },
      option: {
        height: 'auto',
        calcHeight: 32,
        // height: 'auto',
        // calcHeight: 32,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
@@ -50,6 +38,10 @@
        delBtn: false,
        menuWidth: 120,
        dialogType: 'drawer',
        height: 'auto',
        calcHeight: 20,
        column: [
          {
            label: '操作名称',
@@ -120,14 +112,14 @@
            label: '操作时间',
            prop: 'daterange',
            type: 'daterange',
            search:true,
            search: true,
            searchRange: true,
            searchSpan:6,
            searchSpan: 6,
            format: 'YYYY-MM-DD',
            valueFormat: 'YYYY-MM-DD',
            startPlaceholder: '开始时间',
            endPlaceholder: '结束时间',
            viewDisplay:false,
            viewDisplay: false,
            hide: true,
            rules: [
              {
@@ -145,70 +137,69 @@
        ],
      },
      data: [],
    };
    }
  },
  computed: {
    ...mapGetters(['permission']),
    permissionList() {
    permissionList () {
      return {
        viewBtn: this.validData(this.permission.log_api_view, false),
      };
      }
    },
  },
  methods: {
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    searchReset () {
      this.query = {}
      this.onLoad(this.page)
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    searchChange (params, done) {
      this.query = params
      this.page.currentPage = 1
      this.onLoad(this.page, params)
      done()
    },
    beforeOpen(done, type) {
    beforeOpen (done, type) {
      if (['edit', 'view'].includes(type)) {
        getApiLogs(this.form.id).then(res => {
          this.form = res.data.data;
        });
          this.form = res.data.data
        })
      }
      done();
      done()
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    currentChange (currentPage) {
      this.page.currentPage = currentPage
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    sizeChange (pageSize) {
      this.page.pageSize = pageSize
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    refreshChange () {
      this.onLoad(this.page, this.query)
    },
    onLoad(page, params = {}) {
      const { daterange } = this.query;
      console.log(daterange,999)
    onLoad (page, params = {}) {
      const { daterange } = this.query
      let values = {
        ...params,
        ...this.query,
      };
      }
      if (daterange) {
        values = {
          ...values,
          startTime: daterange[0],
          endTime: daterange[1],
        };
        values.daterange = null;
        }
        values.daterange = null
      }
      this.loading = true;
      this.loading = true
      getApiList(page.currentPage, page.pageSize, values).then(res => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
      });
        const data = res.data.data
        this.page.total = data.total
        this.data = data.records
        this.loading = false
      })
    },
  },
};
}
</script>
<style></style>
<style scoped lang="scss"></style>