n20-common-lib 1.3.28 → 1.3.31
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.
- package/package.json +1 -1
- package/src/assets/css/el-button.scss +1 -4
- package/src/assets/css/el-table.scss +0 -9
- package/src/components/ChildRange/index.vue +40 -37
- package/src/components/ChildRange/style.scss +28 -28
- package/src/components/FileExportAsync/index.vue +44 -31
- package/src/components/FileUploadTable/index.vue +5 -1
- package/src/components/Filters/form-item-input.vue +133 -0
- package/src/components/Filters/index.vue +95 -246
- package/src/components/InputNumber/index.vue +10 -0
- package/src/components/ShowColumn/index.vue +54 -15
- package/src/components/Table/ThSelectHeader.vue +5 -5
- package/src/components/Table/filters.js +60 -0
- package/src/components/Table/index.vue +12 -137
- package/src/components/TableOperateColumn/OperateBtns.vue +73 -0
- package/src/components/TableOperateColumn/index.vue +26 -0
- package/src/index.js +3 -0
- package/style/index.css +1 -1
- package/style/index.css.map +1 -1
- package/theme/blue.css +1 -1
- package/theme/green.css +1 -1
- package/theme/lightBlue.css +1 -1
- package/theme/orange.css +1 -1
- package/theme/purple.css +1 -1
- package/theme/red.css +1 -1
- package/theme/yellow.css +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<el-table
|
|
3
|
-
v-if="!pageObj"
|
|
4
3
|
ref="el-table"
|
|
5
4
|
:header-cell-style="{ 'text-align': 'center' }"
|
|
6
5
|
:data="data"
|
|
@@ -25,68 +24,23 @@
|
|
|
25
24
|
:filters="item.filters | colftF(filtersMap)"
|
|
26
25
|
v-bind="item"
|
|
27
26
|
>
|
|
28
|
-
<template slot="header">
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/>
|
|
37
|
-
</span>
|
|
27
|
+
<template v-if="item.filterPre" slot="header">
|
|
28
|
+
{{ item.label }}
|
|
29
|
+
<th-select-header
|
|
30
|
+
:property="item.prop"
|
|
31
|
+
:data-list="dataList"
|
|
32
|
+
:check-list="checkList"
|
|
33
|
+
@selectChange="selectChange"
|
|
34
|
+
/>
|
|
38
35
|
</template>
|
|
39
36
|
</el-table-column>
|
|
40
37
|
</template>
|
|
41
38
|
</el-table>
|
|
42
|
-
|
|
43
|
-
<div v-else :style="{ height: heightW }">
|
|
44
|
-
<el-table
|
|
45
|
-
ref="el-table"
|
|
46
|
-
:header-cell-style="{ 'text-align': 'center' }"
|
|
47
|
-
style="width: 100%"
|
|
48
|
-
:data="data"
|
|
49
|
-
v-bind="$attrs"
|
|
50
|
-
:height="heightC"
|
|
51
|
-
v-on="$listeners"
|
|
52
|
-
>
|
|
53
|
-
<template v-for="(item, i) in columns">
|
|
54
|
-
<slot v-if="item.slotName" :name="item.slotName"></slot>
|
|
55
|
-
<el-table-column
|
|
56
|
-
v-else-if="item.render"
|
|
57
|
-
:key="'cl-table-' + i"
|
|
58
|
-
v-bind="item"
|
|
59
|
-
>
|
|
60
|
-
<columnRender
|
|
61
|
-
slot-scope="{ row }"
|
|
62
|
-
:c-render="item.render"
|
|
63
|
-
:row="row"
|
|
64
|
-
/>
|
|
65
|
-
</el-table-column>
|
|
66
|
-
<el-table-column
|
|
67
|
-
v-else
|
|
68
|
-
:key="'cl-table-' + i"
|
|
69
|
-
:formatter="item.formatter | colfF"
|
|
70
|
-
v-bind="item"
|
|
71
|
-
/>
|
|
72
|
-
</template>
|
|
73
|
-
</el-table>
|
|
74
|
-
<div v-if="pageObj" class="flex-box flex-r m-t-s">
|
|
75
|
-
<Pagination
|
|
76
|
-
:page-obj="pageObj"
|
|
77
|
-
:page-key="pageKey"
|
|
78
|
-
@change="(obj) => $emit('pageChange', obj)"
|
|
79
|
-
/>
|
|
80
|
-
</div>
|
|
81
|
-
</div>
|
|
82
39
|
</template>
|
|
83
40
|
|
|
84
41
|
<script>
|
|
85
|
-
import
|
|
86
|
-
import
|
|
87
|
-
import Pagination from '../Pagination/index.vue'
|
|
88
|
-
|
|
89
|
-
import ThSelectHeader from './ThSelectHeader.vue'
|
|
42
|
+
import thSelectHeader from './ThSelectHeader.vue'
|
|
43
|
+
import { colfF, colftF } from './filters'
|
|
90
44
|
|
|
91
45
|
const columnRender = {
|
|
92
46
|
props: {
|
|
@@ -102,69 +56,11 @@ const columnRender = {
|
|
|
102
56
|
}
|
|
103
57
|
}
|
|
104
58
|
|
|
105
|
-
function colfF(colf, map) {
|
|
106
|
-
if (typeof colf !== 'string') return colf
|
|
107
|
-
let sc = colf.split(/{.+?}/g) || []
|
|
108
|
-
let mc = colf.match(/{.+?}/g) || []
|
|
109
|
-
let mck = []
|
|
110
|
-
mc.forEach((t) => {
|
|
111
|
-
t = t.replace(/^{|\s+|}$/g, '').split('|')
|
|
112
|
-
mck.push(t)
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
return (row) => tplFn(row, sc, mck, map)
|
|
116
|
-
}
|
|
117
|
-
function tplFn(row, sc, mck, map = {}) {
|
|
118
|
-
let str = ''
|
|
119
|
-
sc.forEach((s, i) => {
|
|
120
|
-
str += s
|
|
121
|
-
let kA = mck[i]
|
|
122
|
-
if (kA && kA.length) {
|
|
123
|
-
let key = kA[0]
|
|
124
|
-
if (kA.length === 1) {
|
|
125
|
-
str += row[key]
|
|
126
|
-
} else {
|
|
127
|
-
let type = kA[1]
|
|
128
|
-
switch (type) {
|
|
129
|
-
case 'money':
|
|
130
|
-
str += numerify(row[key], '0,0.00')
|
|
131
|
-
break
|
|
132
|
-
case 'rate':
|
|
133
|
-
str += numerify(row[key], '0.000000')
|
|
134
|
-
break
|
|
135
|
-
case 'map':
|
|
136
|
-
str += map[row[key]]
|
|
137
|
-
break
|
|
138
|
-
case 'date':
|
|
139
|
-
str += dayjs(row[key]).format('YYYY-MM-DD')
|
|
140
|
-
break
|
|
141
|
-
case 'datetime':
|
|
142
|
-
str += dayjs(row[key]).format('YYYY-MM-DD HH:mm:ss')
|
|
143
|
-
break
|
|
144
|
-
case 'time':
|
|
145
|
-
str += dayjs(row[key]).format('HH:mm:ss')
|
|
146
|
-
break
|
|
147
|
-
default:
|
|
148
|
-
str += row[key]
|
|
149
|
-
break
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
})
|
|
154
|
-
return str
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function colftF(colft, fMap) {
|
|
158
|
-
if (typeof colft !== 'string') return colft
|
|
159
|
-
return fMap[colft]
|
|
160
|
-
}
|
|
161
|
-
|
|
162
59
|
export default {
|
|
163
60
|
name: 'Table',
|
|
164
61
|
components: {
|
|
165
|
-
Pagination,
|
|
166
62
|
columnRender,
|
|
167
|
-
|
|
63
|
+
thSelectHeader
|
|
168
64
|
},
|
|
169
65
|
filters: {
|
|
170
66
|
colfF,
|
|
@@ -208,21 +104,6 @@ export default {
|
|
|
208
104
|
dataList: []
|
|
209
105
|
}
|
|
210
106
|
},
|
|
211
|
-
computed: {
|
|
212
|
-
heightW() {
|
|
213
|
-
if (this.height === undefined) {
|
|
214
|
-
return undefined
|
|
215
|
-
}
|
|
216
|
-
if (/\D/.test(this.height)) {
|
|
217
|
-
return this.height
|
|
218
|
-
} else {
|
|
219
|
-
return this.height + 'px'
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
heightC() {
|
|
223
|
-
return this.pageObj ? 'calc(100% - 38px)' : '100%'
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
107
|
created() {
|
|
227
108
|
this.dataList = JSON.parse(JSON.stringify(this.data))
|
|
228
109
|
for (let k in this.dataList[0]) {
|
|
@@ -230,17 +111,11 @@ export default {
|
|
|
230
111
|
}
|
|
231
112
|
for (let i in this.dataList) {
|
|
232
113
|
for (let k in this.dataList[i]) {
|
|
233
|
-
if (
|
|
234
|
-
this.checkList[k].findIndex((item) => item == this.dataList[i][k]) ==
|
|
235
|
-
-1
|
|
236
|
-
) {
|
|
114
|
+
if (!this.checkList[k].some((item) => item === this.dataList[i][k])) {
|
|
237
115
|
this.checkList[k].push(this.dataList[i][k])
|
|
238
116
|
}
|
|
239
117
|
}
|
|
240
118
|
}
|
|
241
|
-
if (this.column) {
|
|
242
|
-
console.warn('调整列顺序,请使用ShowColumn组件')
|
|
243
|
-
}
|
|
244
119
|
},
|
|
245
120
|
methods: {
|
|
246
121
|
selectChange(val) {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span>
|
|
3
|
+
<el-button
|
|
4
|
+
v-for="item in dfBtns"
|
|
5
|
+
:key="item.label"
|
|
6
|
+
type="text"
|
|
7
|
+
size="mini"
|
|
8
|
+
@click="$emit('command', item.command)"
|
|
9
|
+
>{{ item.label }}</el-button
|
|
10
|
+
>
|
|
11
|
+
<el-dropdown v-if="moreBtns.length" @command="(c) => $emit('command', c)">
|
|
12
|
+
<el-button class="n20-icon-moren" type="text" size="mini" />
|
|
13
|
+
<el-dropdown-menu slot="dropdown" class="text-c">
|
|
14
|
+
<el-dropdown-item
|
|
15
|
+
v-for="item in moreBtns"
|
|
16
|
+
:key="item.label"
|
|
17
|
+
:command="item.command"
|
|
18
|
+
>{{ item.label }}</el-dropdown-item
|
|
19
|
+
>
|
|
20
|
+
</el-dropdown-menu>
|
|
21
|
+
</el-dropdown>
|
|
22
|
+
</span>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script>
|
|
26
|
+
export default {
|
|
27
|
+
props: {
|
|
28
|
+
btnList: {
|
|
29
|
+
type: Array,
|
|
30
|
+
default: () => []
|
|
31
|
+
},
|
|
32
|
+
row: {
|
|
33
|
+
type: Object,
|
|
34
|
+
default: () => ({})
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
data() {
|
|
38
|
+
return {}
|
|
39
|
+
},
|
|
40
|
+
computed: {
|
|
41
|
+
hasBtns() {
|
|
42
|
+
return this.btnList.filter((btn) => this.hasBtn(btn.isHas, this.row))
|
|
43
|
+
},
|
|
44
|
+
dfBtns() {
|
|
45
|
+
if (this.hasBtns.length > 3) {
|
|
46
|
+
return this.hasBtns.slice(0, 2)
|
|
47
|
+
} else {
|
|
48
|
+
return this.hasBtns
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
moreBtns() {
|
|
52
|
+
if (this.hasBtns.length > 3) {
|
|
53
|
+
return this.hasBtns.slice(2)
|
|
54
|
+
} else {
|
|
55
|
+
return []
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
methods: {
|
|
60
|
+
hasBtn(isHas, row) {
|
|
61
|
+
if (isHas === undefined || isHas === null) {
|
|
62
|
+
return true
|
|
63
|
+
} else if (typeof isHas === 'boolean') {
|
|
64
|
+
return isHas
|
|
65
|
+
} else if (typeof isHas === 'string' || Array.isArray(isHas)) {
|
|
66
|
+
return this.$has(isHas)
|
|
67
|
+
} else if (typeof isHas === 'function') {
|
|
68
|
+
return isHas(row)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
</script>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-table-column v-bind="$attrs">
|
|
3
|
+
<OperateBtns
|
|
4
|
+
slot-scope="{ row, $index }"
|
|
5
|
+
:btn-list="btnList"
|
|
6
|
+
:row="row"
|
|
7
|
+
@command="(c) => $emit(c, row, $index)"
|
|
8
|
+
/>
|
|
9
|
+
</el-table-column>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
import OperateBtns from './OperateBtns.vue'
|
|
14
|
+
export default {
|
|
15
|
+
name: 'TableOperateColumn',
|
|
16
|
+
components: {
|
|
17
|
+
OperateBtns
|
|
18
|
+
},
|
|
19
|
+
props: {
|
|
20
|
+
btnList: {
|
|
21
|
+
type: Array,
|
|
22
|
+
default: () => []
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
</script>
|
package/src/index.js
CHANGED
|
@@ -35,6 +35,7 @@ import FileUploadTable from './components/FileUploadTable/index.vue'
|
|
|
35
35
|
import FooterBox from './components/FooterBox/index.vue'
|
|
36
36
|
import Filters from './components/Filters/index.vue'
|
|
37
37
|
import Table from './components/Table/index.vue'
|
|
38
|
+
import TableOperateColumn from './components/TableOperateColumn/index.vue'
|
|
38
39
|
import Button from './components/Button/index.vue'
|
|
39
40
|
import ButtonGroup from './components/Button/button-group.vue'
|
|
40
41
|
import ShowColumn from './components/ShowColumn/index.vue'
|
|
@@ -124,6 +125,7 @@ const components = [
|
|
|
124
125
|
FooterBox,
|
|
125
126
|
Filters,
|
|
126
127
|
Table,
|
|
128
|
+
TableOperateColumn,
|
|
127
129
|
Button,
|
|
128
130
|
ButtonGroup,
|
|
129
131
|
ShowColumn,
|
|
@@ -232,6 +234,7 @@ export {
|
|
|
232
234
|
FooterBox,
|
|
233
235
|
Filters,
|
|
234
236
|
Table,
|
|
237
|
+
TableOperateColumn,
|
|
235
238
|
Button,
|
|
236
239
|
ButtonGroup,
|
|
237
240
|
ShowColumn,
|