黎星凯
2024-05-08 b4adff68a07b783fc90da1c9370d8be5f383e700
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import * as DateFormatter from '@/utils/DateFormatter';
import {mapGetters} from 'vuex';
import * as dataExport from "@/api/exportExcel"
import {downLoad} from "@/utils/base";
 
export default {
  data() {
    return {
      loading: false,
      list: [],
      items: [],
      filterFrom: {},
      editSetting: {
        title: '',
        id: '',
        orgId: '',
        show: false,
      },
      uploadPageSetting: {
        title: '上传页面',
        id: '',
        orgId: '',
        show: false,
      },
      detailSetting: {
        title: '详情',
        id: '',
        show: false,
      },
      pageNum: 1,
      pageSize: 10,
      total: 0,
    }
  },
  computed: {
    ...mapGetters(['userInfo']),
    clientHeight() {
      return document.documentElement.clientHeight;
    },
  },
  created() {
  },
  filters: {
    formatTime(time) {
      if (!time) return '-';
      return DateFormatter.LongToDateTime(time);
    },
  },
  methods: {
    // 导出
    handleExport(api, fileName, params) {
      let loading = this.$loading({
        lock: true,
        text: '导出中,请稍候...',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)',
      });
      // 判断总条数是否大于最大支持条数
      dataExport[api](params)
        .then((res) => {
          console.log(res)
          downLoad(res)
          this.$message.success('导出成功!');
          loading.close();
        })
        .catch(() => {
          loading.close();
        });
    },
    // 新增
    handleAdd() {
      this.editSetting.id = null;
      this.editSetting.info = null;
      this.editSetting.title = '新增';
      this.editSetting.show = true;
    },
    // 编辑
    handleEdit(row) {
      this.editSetting.id = row.id;
      this.editSetting.info = null;
      this.editSetting.title = '编辑';
      this.editSetting.show = true;
    },
    // 详情
    handleDetail(row) {
      this.detailSetting.id = row.id;
      this.detailSetting.title = '详情';
      this.detailSetting.show = true;
    },
    // 导入
    handleUploadPage(row) {
      this.uploadPageSetting.id = row.id;
      this.uploadPageSetting.title = '导入';
      this.uploadPageSetting.show = true;
    },
    // 分页
    handleSizeChange(pageSize) {
      this.pageSize = pageSize;
      this.search({pageNum: 1});
    },
    handleCurrentChange(pageNum) {
      this.pageNum = pageNum;
      this.search();
    },
    // 查询table列表
    search(pageNum) {
      if (pageNum) {
        this.pageNum = pageNum
      }
      this.fetchData();
    },
    refreshData() {
      this.pageNum = 1;
      this.pageSize = 10;
      this.search();
    },
    fifterForm(params) {
      this.filterFrom = Object.assign(this.filterFrom, params);
      this.search(1);
    },
  }
}