田源
2024-03-20 d598404c814ad8556159c0922c90dccbb7ee649f
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
<template>
  <div>
    <!--表格基础按钮-->
    <div v-if="type === 'table'">
      <!--top展示表格上方区域 menu展示表格操作栏区域 -->
      <el-button v-for="item in basicButtonList.top"
                 v-if="LocationType === 'top'"
                 :key="item.oid" :icon="item.icon"
                 :type="item.paramVOS.buttonType || 'primary'" plain
                 size="small"
                 @click="buttonClick(item)">
        {{ item.name }}
      </el-button>
 
      <el-button v-for="item in basicButtonList.menu"
                 v-if="LocationType === 'menu'"
                 :key="item.oid"
                 :icon="item.paramVOS.icon ? item.paramVOS.icon : (item.paramVOS.buttonMethods === 'edit' ? 'el-icon-edit' : (item.paramVOS.buttonMethods === 'delete' ? 'el-icon-delete' : ''))"
                 :type="item.paramVOS.buttonType || 'text'" plain
                 size="small"
                 @click="buttonClick(item,scope)">
        {{ item.name }}
      </el-button>
    </div>
    <div v-if="type === 'form'">
      <el-button v-for="item in basicButtonList"
                 :key="item.oid"
                 :type="(item.paramVOS.buttonType !== 'text' ? item.paramVOS.buttonType : 'primary') || 'primary'" plain
                 size="small"
                 :icon="item.icon"
                 @click="buttonClick(item)">
        {{item.name}}
      </el-button>
    </div>
  </div>
</template>
 
<script>
import func from "@/util/func";
import {validatenull} from "@/util/validate";
 
export default {
  name: "dynamic-button",
  props: {
    type: {
      type: String
    },
    LocationType: {
      type: String,
    },
    scope: {
      type: Object,
    },
    butttonList: {
      type: Array
    }
  },
  data() {
    return {
      visible: false,
      formName: '',
    }
  },
  computed: {
    basicButtonList() {
      // const basicColumn = this.butttonList.filter(item => item.id !== 'launchworkflow'); // 首先过滤出来基础表单事件的按钮
      const basicColumn = this.butttonList;
 
      if (this.type === 'form') {
        console.log('basicColumn',basicColumn)
        return basicColumn;
      } else if (this.type === 'table') {
        const top = basicColumn.filter(item => item.paramVOS.location === 'top' || func.isEmpty(item.paramVOS.location)); // 过滤出来表格上面区域展示的按钮
        const menu = basicColumn.filter(item => item.paramVOS.location === 'menu'); // 过滤出来操作栏展示的按钮
        return {
          top: top,
          menu: menu
        };
      }
    }
  },
  methods: {
    buttonClick(item) {
      this.$emit('buttonClick', this.scope, item)
    }
  }
}
</script>
 
<style scoped>
 
</style>