@vtj/materials 0.10.1-alpha.1 → 0.10.1-alpha.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.
- package/dist/assets/antdv/index.umd.js +2 -2
- package/dist/assets/charts/index.umd.js +2 -2
- package/dist/assets/element/index.umd.js +2 -2
- package/dist/assets/ui/index.umd.js +2 -2
- package/dist/assets/uni-h5/index.umd.js +2 -2
- package/dist/assets/uni-ui/index.umd.js +3 -3
- package/dist/assets/vant/index.umd.js +2 -2
- package/dist/deps/@vtj/charts/index.umd.js +2 -2
- package/dist/deps/@vtj/icons/index.umd.js +2 -2
- package/dist/deps/@vtj/ui/index.umd.js +2 -2
- package/dist/deps/@vtj/uni/index.umd.js +2 -2
- package/dist/deps/@vtj/utils/index.umd.js +2 -2
- package/dist/deps/mockjs/mock-min.js +10 -0
- package/dist/deps/uni-ui/index.umd.js +1 -1
- package/dist/deps/uni-ui/style.css +1 -1
- package/package.json +5 -5
- package/src/uni-ui/components/badge.ts +52 -0
- package/src/uni-ui/index.ts +197 -3
- package/src/uni-ui/lib/uni-datetime-picker/calendar-item.vue +177 -0
- package/src/uni-ui/lib/uni-datetime-picker/calendar.vue +947 -0
- package/src/uni-ui/lib/uni-datetime-picker/i18n/en.json +22 -0
- package/src/uni-ui/lib/uni-datetime-picker/i18n/index.js +8 -0
- package/src/uni-ui/lib/uni-datetime-picker/i18n/zh-Hans.json +22 -0
- package/src/uni-ui/lib/uni-datetime-picker/i18n/zh-Hant.json +22 -0
- package/src/uni-ui/lib/uni-datetime-picker/time-picker.vue +940 -0
- package/src/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +1232 -0
- package/src/uni-ui/lib/uni-datetime-picker/util.js +421 -0
- package/src/uni-ui/lib/uni-forms/uni-forms.vue +416 -0
- package/src/uni-ui/lib/uni-forms/utils.js +293 -0
- package/src/uni-ui/lib/uni-forms/validate.js +486 -0
- package/src/uni-ui/lib/uni-popup/i18n/en.json +7 -0
- package/src/uni-ui/lib/uni-popup/i18n/index.js +8 -0
- package/src/uni-ui/lib/uni-popup/i18n/zh-Hans.json +7 -0
- package/src/uni-ui/lib/uni-popup/i18n/zh-Hant.json +7 -0
- package/src/uni-ui/lib/uni-popup/keypress.js +45 -0
- package/src/uni-ui/lib/uni-popup/popup.js +26 -0
- package/src/uni-ui/lib/uni-popup/uni-popup.uvue +90 -0
- package/src/uni-ui/lib/uni-popup/uni-popup.vue +552 -0
- package/src/uni-ui/lib/uni-swipe-action-item/bindingx.js +302 -0
- package/src/uni-ui/lib/uni-swipe-action-item/isPC.js +12 -0
- package/src/uni-ui/lib/uni-swipe-action-item/mpalipay.js +195 -0
- package/src/uni-ui/lib/uni-swipe-action-item/mpother.js +260 -0
- package/src/uni-ui/lib/uni-swipe-action-item/mpwxs.js +84 -0
- package/src/uni-ui/lib/uni-swipe-action-item/render.js +270 -0
- package/src/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +494 -0
- package/src/uni-ui/lib/uni-swipe-action-item/wx.wxs +341 -0
- package/src/uni-ui/lib/uni-th/filter-dropdown.vue +511 -0
- package/src/uni-ui/lib/uni-th/uni-th.vue +295 -0
- package/src/uni-ui/lib/uni-tr/table-checkbox.vue +179 -0
- package/src/uni-ui/lib/uni-tr/uni-tr.vue +184 -0
- package/src/uni-ui/lib/uni.scss +76 -0
- package/src/uni-ui/polyfill.ts +41 -0
- package/src/version.ts +2 -2
@@ -0,0 +1,295 @@
|
|
1
|
+
<template>
|
2
|
+
<!-- #ifdef H5 -->
|
3
|
+
<th :rowspan="rowspan" :colspan="colspan" class="uni-table-th" :class="{ 'table--border': border }" :style="{ width: customWidth + 'px', 'text-align': align }">
|
4
|
+
<view class="uni-table-th-row">
|
5
|
+
<view class="uni-table-th-content" :style="{ 'justify-content': contentAlign }" @click="sort">
|
6
|
+
<slot></slot>
|
7
|
+
<view v-if="sortable" class="arrow-box">
|
8
|
+
<text class="arrow up" :class="{ active: ascending }" @click.stop="ascendingFn"></text>
|
9
|
+
<text class="arrow down" :class="{ active: descending }" @click.stop="descendingFn"></text>
|
10
|
+
</view>
|
11
|
+
</view>
|
12
|
+
<dropdown v-if="filterType || filterData.length" :filterDefaultValue="filterDefaultValue" :filterData="filterData" :filterType="filterType" @change="ondropdown"></dropdown>
|
13
|
+
</view>
|
14
|
+
</th>
|
15
|
+
<!-- #endif -->
|
16
|
+
<!-- #ifndef H5 -->
|
17
|
+
<view class="uni-table-th" :class="{ 'table--border': border }" :style="{ width: customWidth + 'px', 'text-align': align }"><slot></slot></view>
|
18
|
+
<!-- #endif -->
|
19
|
+
</template>
|
20
|
+
|
21
|
+
<script>
|
22
|
+
// #ifdef H5
|
23
|
+
import dropdown from './filter-dropdown.vue'
|
24
|
+
// #endif
|
25
|
+
/**
|
26
|
+
* Th 表头
|
27
|
+
* @description 表格内的表头单元格组件
|
28
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=3270
|
29
|
+
* @property {Number | String} width 单元格宽度(支持纯数字、携带单位px或rpx)
|
30
|
+
* @property {Boolean} sortable 是否启用排序
|
31
|
+
* @property {Number} align = [left|center|right] 单元格对齐方式
|
32
|
+
* @value left 单元格文字左侧对齐
|
33
|
+
* @value center 单元格文字居中
|
34
|
+
* @value right 单元格文字右侧对齐
|
35
|
+
* @property {Array} filterData 筛选数据
|
36
|
+
* @property {String} filterType [search|select] 筛选类型
|
37
|
+
* @value search 关键字搜素
|
38
|
+
* @value select 条件选择
|
39
|
+
* @event {Function} sort-change 排序触发事件
|
40
|
+
*/
|
41
|
+
export default {
|
42
|
+
name: 'uniTh',
|
43
|
+
options: {
|
44
|
+
// #ifdef MP-TOUTIAO
|
45
|
+
virtualHost: false,
|
46
|
+
// #endif
|
47
|
+
// #ifndef MP-TOUTIAO
|
48
|
+
virtualHost: true
|
49
|
+
// #endif
|
50
|
+
},
|
51
|
+
components: {
|
52
|
+
// #ifdef H5
|
53
|
+
dropdown
|
54
|
+
// #endif
|
55
|
+
},
|
56
|
+
emits:['sort-change','filter-change'],
|
57
|
+
props: {
|
58
|
+
width: {
|
59
|
+
type: [String, Number],
|
60
|
+
default: ''
|
61
|
+
},
|
62
|
+
align: {
|
63
|
+
type: String,
|
64
|
+
default: 'left'
|
65
|
+
},
|
66
|
+
rowspan: {
|
67
|
+
type: [Number, String],
|
68
|
+
default: 1
|
69
|
+
},
|
70
|
+
colspan: {
|
71
|
+
type: [Number, String],
|
72
|
+
default: 1
|
73
|
+
},
|
74
|
+
sortable: {
|
75
|
+
type: Boolean,
|
76
|
+
default: false
|
77
|
+
},
|
78
|
+
filterType: {
|
79
|
+
type: String,
|
80
|
+
default: ""
|
81
|
+
},
|
82
|
+
filterData: {
|
83
|
+
type: Array,
|
84
|
+
default () {
|
85
|
+
return []
|
86
|
+
}
|
87
|
+
},
|
88
|
+
filterDefaultValue: {
|
89
|
+
type: [Array,String],
|
90
|
+
default () {
|
91
|
+
return ""
|
92
|
+
}
|
93
|
+
}
|
94
|
+
},
|
95
|
+
data() {
|
96
|
+
return {
|
97
|
+
border: false,
|
98
|
+
ascending: false,
|
99
|
+
descending: false
|
100
|
+
}
|
101
|
+
},
|
102
|
+
computed: {
|
103
|
+
// 根据props中的width属性 自动匹配当前th的宽度(px)
|
104
|
+
customWidth(){
|
105
|
+
if(typeof this.width === 'number'){
|
106
|
+
return this.width
|
107
|
+
} else if(typeof this.width === 'string') {
|
108
|
+
let regexHaveUnitPx = new RegExp(/^[1-9][0-9]*px$/g)
|
109
|
+
let regexHaveUnitRpx = new RegExp(/^[1-9][0-9]*rpx$/g)
|
110
|
+
let regexHaveNotUnit = new RegExp(/^[1-9][0-9]*$/g)
|
111
|
+
if (this.width.match(regexHaveUnitPx) !== null) { // 携带了 px
|
112
|
+
return this.width.replace('px', '')
|
113
|
+
} else if (this.width.match(regexHaveUnitRpx) !== null) { // 携带了 rpx
|
114
|
+
let numberRpx = Number(this.width.replace('rpx', ''))
|
115
|
+
// #ifdef MP-WEIXIN
|
116
|
+
let widthCoe = uni.getWindowInfo().screenWidth / 750
|
117
|
+
// #endif
|
118
|
+
// #ifndef MP-WEIXIN
|
119
|
+
// let widthCoe = uni.getSystemInfoSync().screenWidth / 750
|
120
|
+
// #endif
|
121
|
+
return Math.round(numberRpx * widthCoe)
|
122
|
+
} else if (this.width.match(regexHaveNotUnit) !== null) { // 未携带 rpx或px 的纯数字 String
|
123
|
+
return this.width
|
124
|
+
} else { // 不符合格式
|
125
|
+
return ''
|
126
|
+
}
|
127
|
+
} else {
|
128
|
+
return ''
|
129
|
+
}
|
130
|
+
},
|
131
|
+
contentAlign() {
|
132
|
+
let align = 'left'
|
133
|
+
switch (this.align) {
|
134
|
+
case 'left':
|
135
|
+
align = 'flex-start'
|
136
|
+
break
|
137
|
+
case 'center':
|
138
|
+
align = 'center'
|
139
|
+
break
|
140
|
+
case 'right':
|
141
|
+
align = 'flex-end'
|
142
|
+
break
|
143
|
+
}
|
144
|
+
return align
|
145
|
+
}
|
146
|
+
},
|
147
|
+
created() {
|
148
|
+
this.root = this.getTable('uniTable')
|
149
|
+
this.rootTr = this.getTable('uniTr')
|
150
|
+
this.rootTr.minWidthUpdate(this.customWidth ? this.customWidth : 140)
|
151
|
+
this.border = this.root.border
|
152
|
+
this.root.thChildren.push(this)
|
153
|
+
},
|
154
|
+
methods: {
|
155
|
+
sort() {
|
156
|
+
if (!this.sortable) return
|
157
|
+
this.clearOther()
|
158
|
+
if (!this.ascending && !this.descending) {
|
159
|
+
this.ascending = true
|
160
|
+
this.$emit('sort-change', { order: 'ascending' })
|
161
|
+
return
|
162
|
+
}
|
163
|
+
if (this.ascending && !this.descending) {
|
164
|
+
this.ascending = false
|
165
|
+
this.descending = true
|
166
|
+
this.$emit('sort-change', { order: 'descending' })
|
167
|
+
return
|
168
|
+
}
|
169
|
+
|
170
|
+
if (!this.ascending && this.descending) {
|
171
|
+
this.ascending = false
|
172
|
+
this.descending = false
|
173
|
+
this.$emit('sort-change', { order: null })
|
174
|
+
}
|
175
|
+
},
|
176
|
+
ascendingFn() {
|
177
|
+
this.clearOther()
|
178
|
+
this.ascending = !this.ascending
|
179
|
+
this.descending = false
|
180
|
+
this.$emit('sort-change', { order: this.ascending ? 'ascending' : null })
|
181
|
+
},
|
182
|
+
descendingFn() {
|
183
|
+
this.clearOther()
|
184
|
+
this.descending = !this.descending
|
185
|
+
this.ascending = false
|
186
|
+
this.$emit('sort-change', { order: this.descending ? 'descending' : null })
|
187
|
+
},
|
188
|
+
clearOther() {
|
189
|
+
this.root.thChildren.map(item => {
|
190
|
+
if (item !== this) {
|
191
|
+
item.ascending = false
|
192
|
+
item.descending = false
|
193
|
+
}
|
194
|
+
return item
|
195
|
+
})
|
196
|
+
},
|
197
|
+
ondropdown(e) {
|
198
|
+
this.$emit("filter-change", e)
|
199
|
+
},
|
200
|
+
/**
|
201
|
+
* 获取父元素实例
|
202
|
+
*/
|
203
|
+
getTable(name) {
|
204
|
+
let parent = this.$parent
|
205
|
+
let parentName = parent.$options.name
|
206
|
+
while (parentName !== name) {
|
207
|
+
parent = parent.$parent
|
208
|
+
if (!parent) return false
|
209
|
+
parentName = parent.$options.name
|
210
|
+
}
|
211
|
+
return parent
|
212
|
+
}
|
213
|
+
}
|
214
|
+
}
|
215
|
+
</script>
|
216
|
+
|
217
|
+
<style lang="scss">
|
218
|
+
$border-color: #ebeef5;
|
219
|
+
$uni-primary: #007aff !default;
|
220
|
+
|
221
|
+
.uni-table-th {
|
222
|
+
padding: 12px 10px;
|
223
|
+
/* #ifndef APP-NVUE */
|
224
|
+
display: table-cell;
|
225
|
+
box-sizing: border-box;
|
226
|
+
/* #endif */
|
227
|
+
font-size: 14px;
|
228
|
+
font-weight: bold;
|
229
|
+
color: #909399;
|
230
|
+
border-bottom: 1px $border-color solid;
|
231
|
+
}
|
232
|
+
|
233
|
+
.uni-table-th-row {
|
234
|
+
/* #ifndef APP-NVUE */
|
235
|
+
display: flex;
|
236
|
+
/* #endif */
|
237
|
+
flex-direction: row;
|
238
|
+
}
|
239
|
+
|
240
|
+
.table--border {
|
241
|
+
border-right: 1px $border-color solid;
|
242
|
+
}
|
243
|
+
.uni-table-th-content {
|
244
|
+
display: flex;
|
245
|
+
align-items: center;
|
246
|
+
flex: 1;
|
247
|
+
}
|
248
|
+
.arrow-box {
|
249
|
+
}
|
250
|
+
.arrow {
|
251
|
+
display: block;
|
252
|
+
position: relative;
|
253
|
+
width: 10px;
|
254
|
+
height: 8px;
|
255
|
+
// border: 1px red solid;
|
256
|
+
left: 5px;
|
257
|
+
overflow: hidden;
|
258
|
+
cursor: pointer;
|
259
|
+
}
|
260
|
+
.down {
|
261
|
+
top: 3px;
|
262
|
+
::after {
|
263
|
+
content: '';
|
264
|
+
width: 8px;
|
265
|
+
height: 8px;
|
266
|
+
position: absolute;
|
267
|
+
left: 2px;
|
268
|
+
top: -5px;
|
269
|
+
transform: rotate(45deg);
|
270
|
+
background-color: #ccc;
|
271
|
+
}
|
272
|
+
&.active {
|
273
|
+
::after {
|
274
|
+
background-color: $uni-primary;
|
275
|
+
}
|
276
|
+
}
|
277
|
+
}
|
278
|
+
.up {
|
279
|
+
::after {
|
280
|
+
content: '';
|
281
|
+
width: 8px;
|
282
|
+
height: 8px;
|
283
|
+
position: absolute;
|
284
|
+
left: 2px;
|
285
|
+
top: 5px;
|
286
|
+
transform: rotate(45deg);
|
287
|
+
background-color: #ccc;
|
288
|
+
}
|
289
|
+
&.active {
|
290
|
+
::after {
|
291
|
+
background-color: $uni-primary;
|
292
|
+
}
|
293
|
+
}
|
294
|
+
}
|
295
|
+
</style>
|
@@ -0,0 +1,179 @@
|
|
1
|
+
<template>
|
2
|
+
<view class="uni-table-checkbox" @click="selected">
|
3
|
+
<view v-if="!indeterminate" class="checkbox__inner" :class="{'is-checked':isChecked,'is-disable':isDisabled}">
|
4
|
+
<view class="checkbox__inner-icon"></view>
|
5
|
+
</view>
|
6
|
+
<view v-else class="checkbox__inner checkbox--indeterminate">
|
7
|
+
<view class="checkbox__inner-icon"></view>
|
8
|
+
</view>
|
9
|
+
</view>
|
10
|
+
</template>
|
11
|
+
|
12
|
+
<script>
|
13
|
+
export default {
|
14
|
+
name: 'TableCheckbox',
|
15
|
+
emits:['checkboxSelected'],
|
16
|
+
props: {
|
17
|
+
indeterminate: {
|
18
|
+
type: Boolean,
|
19
|
+
default: false
|
20
|
+
},
|
21
|
+
checked: {
|
22
|
+
type: [Boolean,String],
|
23
|
+
default: false
|
24
|
+
},
|
25
|
+
disabled: {
|
26
|
+
type: Boolean,
|
27
|
+
default: false
|
28
|
+
},
|
29
|
+
index: {
|
30
|
+
type: Number,
|
31
|
+
default: -1
|
32
|
+
},
|
33
|
+
cellData: {
|
34
|
+
type: Object,
|
35
|
+
default () {
|
36
|
+
return {}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
},
|
40
|
+
watch:{
|
41
|
+
checked(newVal){
|
42
|
+
if(typeof this.checked === 'boolean'){
|
43
|
+
this.isChecked = newVal
|
44
|
+
}else{
|
45
|
+
this.isChecked = true
|
46
|
+
}
|
47
|
+
},
|
48
|
+
indeterminate(newVal){
|
49
|
+
this.isIndeterminate = newVal
|
50
|
+
}
|
51
|
+
},
|
52
|
+
data() {
|
53
|
+
return {
|
54
|
+
isChecked: false,
|
55
|
+
isDisabled: false,
|
56
|
+
isIndeterminate:false
|
57
|
+
}
|
58
|
+
},
|
59
|
+
created() {
|
60
|
+
if(typeof this.checked === 'boolean'){
|
61
|
+
this.isChecked = this.checked
|
62
|
+
}
|
63
|
+
this.isDisabled = this.disabled
|
64
|
+
},
|
65
|
+
methods: {
|
66
|
+
selected() {
|
67
|
+
if (this.isDisabled) return
|
68
|
+
this.isIndeterminate = false
|
69
|
+
this.isChecked = !this.isChecked
|
70
|
+
this.$emit('checkboxSelected', {
|
71
|
+
checked: this.isChecked,
|
72
|
+
data: this.cellData
|
73
|
+
})
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
</script>
|
78
|
+
|
79
|
+
<style lang="scss">
|
80
|
+
$uni-primary: #007aff !default;
|
81
|
+
$border-color: #DCDFE6;
|
82
|
+
$disable:0.4;
|
83
|
+
|
84
|
+
.uni-table-checkbox {
|
85
|
+
display: flex;
|
86
|
+
flex-direction: row;
|
87
|
+
align-items: center;
|
88
|
+
justify-content: center;
|
89
|
+
position: relative;
|
90
|
+
margin: 5px 0;
|
91
|
+
cursor: pointer;
|
92
|
+
|
93
|
+
// 多选样式
|
94
|
+
.checkbox__inner {
|
95
|
+
/* #ifndef APP-NVUE */
|
96
|
+
flex-shrink: 0;
|
97
|
+
box-sizing: border-box;
|
98
|
+
/* #endif */
|
99
|
+
position: relative;
|
100
|
+
width: 16px;
|
101
|
+
height: 16px;
|
102
|
+
border: 1px solid $border-color;
|
103
|
+
border-radius: 2px;
|
104
|
+
background-color: #fff;
|
105
|
+
z-index: 1;
|
106
|
+
|
107
|
+
.checkbox__inner-icon {
|
108
|
+
position: absolute;
|
109
|
+
/* #ifdef APP-NVUE */
|
110
|
+
top: 2px;
|
111
|
+
/* #endif */
|
112
|
+
/* #ifndef APP-NVUE */
|
113
|
+
top: 2px;
|
114
|
+
/* #endif */
|
115
|
+
left: 5px;
|
116
|
+
height: 7px;
|
117
|
+
width: 3px;
|
118
|
+
border: 1px solid #fff;
|
119
|
+
border-left: 0;
|
120
|
+
border-top: 0;
|
121
|
+
opacity: 0;
|
122
|
+
transform-origin: center;
|
123
|
+
transform: rotate(45deg);
|
124
|
+
box-sizing: content-box;
|
125
|
+
}
|
126
|
+
|
127
|
+
&.checkbox--indeterminate {
|
128
|
+
border-color: $uni-primary;
|
129
|
+
background-color: $uni-primary;
|
130
|
+
|
131
|
+
.checkbox__inner-icon {
|
132
|
+
position: absolute;
|
133
|
+
opacity: 1;
|
134
|
+
transform: rotate(0deg);
|
135
|
+
height: 2px;
|
136
|
+
top: 0;
|
137
|
+
bottom: 0;
|
138
|
+
margin: auto;
|
139
|
+
left: 0px;
|
140
|
+
right: 0px;
|
141
|
+
bottom: 0;
|
142
|
+
width: auto;
|
143
|
+
border: none;
|
144
|
+
border-radius: 2px;
|
145
|
+
transform: scale(0.5);
|
146
|
+
background-color: #fff;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
&:hover{
|
150
|
+
border-color: $uni-primary;
|
151
|
+
}
|
152
|
+
// 禁用
|
153
|
+
&.is-disable {
|
154
|
+
/* #ifdef H5 */
|
155
|
+
cursor: not-allowed;
|
156
|
+
/* #endif */
|
157
|
+
background-color: #F2F6FC;
|
158
|
+
border-color: $border-color;
|
159
|
+
}
|
160
|
+
|
161
|
+
// 选中
|
162
|
+
&.is-checked {
|
163
|
+
border-color: $uni-primary;
|
164
|
+
background-color: $uni-primary;
|
165
|
+
|
166
|
+
.checkbox__inner-icon {
|
167
|
+
opacity: 1;
|
168
|
+
transform: rotate(45deg);
|
169
|
+
}
|
170
|
+
|
171
|
+
// 选中禁用
|
172
|
+
&.is-disable {
|
173
|
+
opacity: $disable;
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
}
|
178
|
+
}
|
179
|
+
</style>
|
@@ -0,0 +1,184 @@
|
|
1
|
+
<template>
|
2
|
+
<!-- #ifdef H5 -->
|
3
|
+
<tr class="uni-table-tr">
|
4
|
+
<th v-if="selection === 'selection' && ishead" class="checkbox" :class="{ 'tr-table--border': border }">
|
5
|
+
<table-checkbox :checked="checked" :indeterminate="indeterminate" :disabled="disabled"
|
6
|
+
@checkboxSelected="checkboxSelected"></table-checkbox>
|
7
|
+
</th>
|
8
|
+
<slot></slot>
|
9
|
+
<!-- <uni-th class="th-fixed">123</uni-th> -->
|
10
|
+
</tr>
|
11
|
+
<!-- #endif -->
|
12
|
+
<!-- #ifndef H5 -->
|
13
|
+
<view class="uni-table-tr">
|
14
|
+
<view v-if="selection === 'selection' " class="checkbox" :class="{ 'tr-table--border': border }">
|
15
|
+
<table-checkbox :checked="checked" :indeterminate="indeterminate" :disabled="disabled"
|
16
|
+
@checkboxSelected="checkboxSelected"></table-checkbox>
|
17
|
+
</view>
|
18
|
+
<slot></slot>
|
19
|
+
</view>
|
20
|
+
<!-- #endif -->
|
21
|
+
</template>
|
22
|
+
|
23
|
+
<script>
|
24
|
+
import tableCheckbox from './table-checkbox.vue'
|
25
|
+
/**
|
26
|
+
* Tr 表格行组件
|
27
|
+
* @description 表格行组件 仅包含 th,td 组件
|
28
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=
|
29
|
+
*/
|
30
|
+
export default {
|
31
|
+
name: 'uniTr',
|
32
|
+
components: {
|
33
|
+
tableCheckbox
|
34
|
+
},
|
35
|
+
props: {
|
36
|
+
disabled: {
|
37
|
+
type: Boolean,
|
38
|
+
default: false
|
39
|
+
},
|
40
|
+
keyValue: {
|
41
|
+
type: [String, Number],
|
42
|
+
default: ''
|
43
|
+
}
|
44
|
+
},
|
45
|
+
options: {
|
46
|
+
// #ifdef MP-TOUTIAO
|
47
|
+
virtualHost: false,
|
48
|
+
// #endif
|
49
|
+
// #ifndef MP-TOUTIAO
|
50
|
+
virtualHost: true
|
51
|
+
// #endif
|
52
|
+
},
|
53
|
+
data() {
|
54
|
+
return {
|
55
|
+
value: false,
|
56
|
+
border: false,
|
57
|
+
selection: false,
|
58
|
+
widthThArr: [],
|
59
|
+
ishead: true,
|
60
|
+
checked: false,
|
61
|
+
indeterminate: false
|
62
|
+
}
|
63
|
+
},
|
64
|
+
created() {
|
65
|
+
this.root = this.getTable()
|
66
|
+
this.head = this.getTable('uniThead')
|
67
|
+
if (this.head) {
|
68
|
+
this.ishead = false
|
69
|
+
this.head.init(this)
|
70
|
+
}
|
71
|
+
this.border = this.root.border
|
72
|
+
this.selection = this.root.type
|
73
|
+
this.root.trChildren.push(this)
|
74
|
+
const rowData = this.root.data.find(v => v[this.root.rowKey] === this.keyValue)
|
75
|
+
if (rowData) {
|
76
|
+
this.rowData = rowData
|
77
|
+
}
|
78
|
+
this.root.isNodata()
|
79
|
+
},
|
80
|
+
mounted() {
|
81
|
+
if (this.widthThArr.length > 0) {
|
82
|
+
const selectionWidth = this.selection === 'selection' ? 50 : 0
|
83
|
+
this.root.minWidth = Number(this.widthThArr.reduce((a, b) => Number(a) + Number(b))) + selectionWidth;
|
84
|
+
}
|
85
|
+
},
|
86
|
+
// #ifndef VUE3
|
87
|
+
destroyed() {
|
88
|
+
const index = this.root.trChildren.findIndex(i => i === this)
|
89
|
+
this.root.trChildren.splice(index, 1)
|
90
|
+
this.root.isNodata()
|
91
|
+
},
|
92
|
+
// #endif
|
93
|
+
// #ifdef VUE3
|
94
|
+
unmounted() {
|
95
|
+
const index = this.root.trChildren.findIndex(i => i === this)
|
96
|
+
this.root.trChildren.splice(index, 1)
|
97
|
+
this.root.isNodata()
|
98
|
+
},
|
99
|
+
// #endif
|
100
|
+
methods: {
|
101
|
+
minWidthUpdate(width) {
|
102
|
+
this.widthThArr.push(width)
|
103
|
+
if (this.widthThArr.length > 0) {
|
104
|
+
const selectionWidth = this.selection === 'selection' ? 50 : 0;
|
105
|
+
this.root.minWidth = Number(this.widthThArr.reduce((a, b) => Number(a) + Number(b))) + selectionWidth;
|
106
|
+
}
|
107
|
+
},
|
108
|
+
// 选中
|
109
|
+
checkboxSelected(e) {
|
110
|
+
let rootData = this.root.data.find(v => v[this.root.rowKey] === this.keyValue)
|
111
|
+
this.checked = e.checked
|
112
|
+
this.root.check(rootData || this, e.checked, rootData ? this.keyValue : null)
|
113
|
+
},
|
114
|
+
change(e) {
|
115
|
+
this.root.trChildren.forEach(item => {
|
116
|
+
if (item === this) {
|
117
|
+
this.root.check(this, e.detail.value.length > 0 ? true : false)
|
118
|
+
}
|
119
|
+
})
|
120
|
+
},
|
121
|
+
/**
|
122
|
+
* 获取父元素实例
|
123
|
+
*/
|
124
|
+
getTable(name = 'uniTable') {
|
125
|
+
let parent = this.$parent
|
126
|
+
let parentName = parent.$options.name
|
127
|
+
while (parentName !== name) {
|
128
|
+
parent = parent.$parent
|
129
|
+
if (!parent) return false
|
130
|
+
parentName = parent.$options.name
|
131
|
+
}
|
132
|
+
return parent
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
136
|
+
</script>
|
137
|
+
|
138
|
+
<style lang="scss">
|
139
|
+
$border-color: #ebeef5;
|
140
|
+
|
141
|
+
.uni-table-tr {
|
142
|
+
/* #ifndef APP-NVUE */
|
143
|
+
display: table-row;
|
144
|
+
transition: all 0.3s;
|
145
|
+
box-sizing: border-box;
|
146
|
+
/* #endif */
|
147
|
+
}
|
148
|
+
|
149
|
+
.checkbox {
|
150
|
+
padding: 0 8px;
|
151
|
+
width: 26px;
|
152
|
+
padding-left: 12px;
|
153
|
+
/* #ifndef APP-NVUE */
|
154
|
+
display: table-cell;
|
155
|
+
vertical-align: middle;
|
156
|
+
/* #endif */
|
157
|
+
color: #333;
|
158
|
+
font-weight: 500;
|
159
|
+
border-bottom: 1px $border-color solid;
|
160
|
+
font-size: 14px;
|
161
|
+
// text-align: center;
|
162
|
+
}
|
163
|
+
|
164
|
+
.tr-table--border {
|
165
|
+
border-right: 1px $border-color solid;
|
166
|
+
}
|
167
|
+
|
168
|
+
/* #ifndef APP-NVUE */
|
169
|
+
.uni-table-tr {
|
170
|
+
::v-deep .uni-table-th {
|
171
|
+
&.table--border:last-child {
|
172
|
+
// border-right: none;
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
::v-deep .uni-table-td {
|
177
|
+
&.table--border:last-child {
|
178
|
+
// border-right: none;
|
179
|
+
}
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
/* #endif */
|
184
|
+
</style>
|