n20-common-lib 3.1.1 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,141 +0,0 @@
1
- <template>
2
- <div class="flex-box flex-v">
3
- <template v-for="(item, i) in dfBtns" class="flex-box flex-v">
4
- <el-dropdown
5
- v-if="item.children && item.children.length"
6
- :key="item.label"
7
- class="m-l-b"
8
- @command="(c) => $emit('command', c)"
9
- >
10
- <div class="flex-box flex-v">
11
- <el-link
12
- :key="item.label"
13
- :class="i ? 'm-l-b' : ''"
14
- type="primary"
15
- :underline="false"
16
- :disabled="item.disabled | dbdBtn(row)"
17
- @click="$emit('command', item.command)"
18
- >
19
- <span v-if="item.tip" v-title="`${item.tip}`">{{ item.label }}</span>
20
- <span v-else>{{ item.label }}</span>
21
- </el-link>
22
- <i class="el-icon-arrow-down color-primary"></i>
23
- </div>
24
- <el-dropdown-menu slot="dropdown" class="text-c">
25
- <el-dropdown-item
26
- v-for="item1 in item.children"
27
- :key="item1.label"
28
- :command="item1.command"
29
- :disabled="item1.disabled | dbdBtn(row)"
30
- >
31
- <el-link v-if="item1.type" :type="item1.type" :underline="false">{{ item1.label }}</el-link>
32
- <template v-else>{{ item1.label }}</template>
33
- </el-dropdown-item>
34
- </el-dropdown-menu>
35
- </el-dropdown>
36
- <el-link
37
- v-else
38
- :key="item.label"
39
- :class="i ? 'm-l-b' : ''"
40
- :type="item.type || 'primary'"
41
- :underline="false"
42
- :disabled="item.disabled | dbdBtn(row)"
43
- @click="$emit('command', item.command)"
44
- >
45
- <span v-if="item.tip" v-title="`${item.tip}`">{{ item.label }}</span>
46
- <span v-else>{{ item.label }}</span>
47
- </el-link>
48
- </template>
49
-
50
- <el-dropdown v-if="moreBtns.length" class="m-l-b" @command="(c) => $emit('command', c)">
51
- <el-button class="n20-icon-moren" type="text" size="mini" />
52
- <el-dropdown-menu slot="dropdown" class="text-c">
53
- <template v-for="(item, i) in moreBtns">
54
- <el-dropdown-item v-if="item.children && item.children.length" :key="i">
55
- <template>{{ item.label }}</template>
56
- <el-dropdown class="m-l-b" @command="(c) => $emit('command', c)">
57
- <i class="el-icon-arrow-down"></i>
58
- <el-dropdown-menu slot="dropdown" class="text-c">
59
- <el-dropdown-item
60
- v-for="item2 in item.children"
61
- :key="item2.label"
62
- :command="item2.command"
63
- :disabled="item2.disabled | dbdBtn(row)"
64
- >
65
- <el-link v-if="item2.type" :type="item2.type" :underline="false">{{ item2.label }}</el-link>
66
- <template v-else>{{ item2.label }}</template>
67
- </el-dropdown-item>
68
- </el-dropdown-menu>
69
- </el-dropdown>
70
- </el-dropdown-item>
71
- <el-dropdown-item v-else :key="item.label" :command="item.command" :disabled="item.disabled | dbdBtn(row)">
72
- <el-link v-if="item.type" :type="item.type" :underline="false">{{ item.label }}</el-link>
73
- <template v-else>{{ item.label }}</template>
74
- </el-dropdown-item>
75
- </template>
76
- </el-dropdown-menu>
77
- </el-dropdown>
78
- </div>
79
- </template>
80
-
81
- <script>
82
- export default {
83
- name: 'TableOperate',
84
- filters: {
85
- dbdBtn(dbd, row) {
86
- if (dbd === undefined || dbd === null) {
87
- return false
88
- } else if (typeof dbd === 'boolean') {
89
- return dbd
90
- } else if (typeof dbd === 'function') {
91
- return dbd(row)
92
- }
93
- }
94
- },
95
- props: {
96
- btnList: {
97
- type: Array,
98
- default: () => []
99
- },
100
- row: {
101
- type: Object,
102
- default: () => ({})
103
- }
104
- },
105
- data() {
106
- return {}
107
- },
108
- computed: {
109
- hasBtns() {
110
- return this.btnList.filter((btn) => this.hasBtn(btn.isHas, this.row))
111
- },
112
- dfBtns() {
113
- if (this.hasBtns.length > 3) {
114
- return this.hasBtns.slice(0, 2)
115
- } else {
116
- return this.hasBtns
117
- }
118
- },
119
- moreBtns() {
120
- if (this.hasBtns.length > 3) {
121
- return this.hasBtns.slice(2)
122
- } else {
123
- return []
124
- }
125
- }
126
- },
127
- methods: {
128
- hasBtn(isHas, row) {
129
- if (isHas === undefined || isHas === null) {
130
- return true
131
- } else if (typeof isHas === 'boolean') {
132
- return isHas
133
- } else if (typeof isHas === 'string' || Array.isArray(isHas)) {
134
- return this.$has(isHas)
135
- } else if (typeof isHas === 'function') {
136
- return isHas(row)
137
- }
138
- }
139
- }
140
- }
141
- </script>