sadais-piui 1.2.7-beta2 → 1.2.7-beta22
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/components/pi-calendar-panel/components/calendar-days/index.vue +371 -0
- package/components/pi-calendar-panel/index.vue +173 -151
- package/components/pi-checkbox/index.vue +2 -2
- package/components/pi-checkbox-group/index.vue +4 -0
- package/components/pi-circle-progress/index.vue +65 -9
- package/components/pi-collapse/index.vue +114 -0
- package/components/pi-collapse-item/index.vue +347 -0
- package/components/pi-date-picker/index.vue +20 -6
- package/components/pi-dropdown/components/dropdown-tab.vue +33 -24
- package/components/pi-dropdown/index.vue +39 -20
- package/components/pi-dropdown-item/index.vue +15 -8
- package/components/pi-form/index.vue +5 -4
- package/components/pi-form-item/index.vue +4 -1
- package/components/pi-input/index.vue +2 -2
- package/components/pi-radio/index.vue +2 -2
- package/components/pi-radio-group/index.vue +4 -0
- package/components/pi-steps/index.vue +85 -33
- package/components/pi-tabs/index.vue +4 -3
- package/components/pi-tag/index.vue +488 -0
- package/config/calendarPanel.js +3 -1
- package/config/circleProgress.js +7 -8
- package/config/collapse.js +7 -0
- package/config/collapseItem.js +11 -0
- package/config/datePicker.js +1 -0
- package/config/dropdown.js +3 -1
- package/config/steps.js +1 -1
- package/config/tag.js +21 -0
- package/package.json +1 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="pi-collapse" :class="[customClass]" :style="[customStyle]">
|
|
3
|
+
<pi-divider v-if="border" />
|
|
4
|
+
<slot />
|
|
5
|
+
</view>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
import { getConfig } from '../../config'
|
|
10
|
+
const { collapse } = getConfig()
|
|
11
|
+
/**
|
|
12
|
+
* collapse 折叠面板
|
|
13
|
+
* @description 通过折叠面板收纳内容区域
|
|
14
|
+
* @tutorial http://piui.sadais.com/docs/components/collapse.html
|
|
15
|
+
* @event {Function} change 当前激活面板展开时触发(如果是手风琴模式,参数activeNames类型为String,否则为Array)
|
|
16
|
+
* @example <pi-collapse />
|
|
17
|
+
*/
|
|
18
|
+
export default {
|
|
19
|
+
name: 'PiCollapse',
|
|
20
|
+
props: {
|
|
21
|
+
// 当前展开面板的name,非手风琴模式:[<string | number>],手风琴模式:string | number
|
|
22
|
+
value: {
|
|
23
|
+
type: [String, Number, Array],
|
|
24
|
+
default: collapse.value
|
|
25
|
+
},
|
|
26
|
+
// 是否手风琴模式
|
|
27
|
+
accordion: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
// false
|
|
30
|
+
default: collapse.accordion
|
|
31
|
+
},
|
|
32
|
+
// 是否显示外边框
|
|
33
|
+
border: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
// true
|
|
36
|
+
default: collapse.border
|
|
37
|
+
},
|
|
38
|
+
// 自定义折叠面板的样式类名
|
|
39
|
+
customClass: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: collapse.customClass
|
|
42
|
+
},
|
|
43
|
+
// 自定义折叠面板的样式
|
|
44
|
+
customStyle: {
|
|
45
|
+
type: Object,
|
|
46
|
+
default: () => {
|
|
47
|
+
return collapse.customStyle
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
computed: {
|
|
52
|
+
needInit() {
|
|
53
|
+
// 通过computed,同时监听accordion和value值的变化
|
|
54
|
+
// 再通过watch去执行init()方法,进行再一次的初始化
|
|
55
|
+
return [this.accordion, this.value]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
watch: {
|
|
59
|
+
needInit() {
|
|
60
|
+
this.init()
|
|
61
|
+
},
|
|
62
|
+
// 当父组件需要子组件需要共享的参数发生了变化,手动通知子组件
|
|
63
|
+
parentData() {
|
|
64
|
+
if (this.children.length) {
|
|
65
|
+
this.children.map(child => {
|
|
66
|
+
// 判断子组件(pi-collapse-item)如果有updateParentData方法的话,就就执行(执行的结果是子组件重新从父组件拉取了最新的值)
|
|
67
|
+
typeof child.updateParentData === 'function' && child.updateParentData()
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
created() {
|
|
73
|
+
this.children = []
|
|
74
|
+
},
|
|
75
|
+
methods: {
|
|
76
|
+
// 重新初始化一次内部的所有子元素
|
|
77
|
+
init() {
|
|
78
|
+
this.children.map(child => {
|
|
79
|
+
child.init()
|
|
80
|
+
})
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* collapse-item被点击时触发,由collapse统一处理各子组件的状态
|
|
84
|
+
* @param {Object} target 被操作的面板的实例
|
|
85
|
+
*/
|
|
86
|
+
onChange(target) {
|
|
87
|
+
let changeArr = []
|
|
88
|
+
this.children.map((child, index) => {
|
|
89
|
+
// 如果是手风琴模式,将其他的折叠面板收起来
|
|
90
|
+
if (this.accordion) {
|
|
91
|
+
child.expanded = child === target ? !target.expanded : false
|
|
92
|
+
child.setContentAnimate()
|
|
93
|
+
} else {
|
|
94
|
+
if (child === target) {
|
|
95
|
+
child.expanded = !child.expanded
|
|
96
|
+
child.setContentAnimate()
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// 拼接change事件中,数组元素的状态
|
|
100
|
+
changeArr.push({
|
|
101
|
+
// 如果没有定义name属性,则默认返回组件的index索引
|
|
102
|
+
name: child.name || index,
|
|
103
|
+
status: child.expanded ? 'open' : 'close'
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
// 触发change事件
|
|
107
|
+
this.$emit('change', changeArr)
|
|
108
|
+
this.$emit(target.expanded ? 'open' : 'close', target.name)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
</script>
|
|
113
|
+
|
|
114
|
+
<style lang="scss" scoped></style>
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="pi-collapse-item"
|
|
4
|
+
:class="[customClass]"
|
|
5
|
+
:style="[customStyle]"
|
|
6
|
+
@click="clickHandler"
|
|
7
|
+
>
|
|
8
|
+
<!-- 标题 -->
|
|
9
|
+
<view
|
|
10
|
+
class="pi-collapse-item__title pi-justify-between pi-align-center"
|
|
11
|
+
:class="{ disabled: disabled, border: border }"
|
|
12
|
+
>
|
|
13
|
+
<!-- 左侧 -->
|
|
14
|
+
<view class="pi-flex-column pi-lh-44">
|
|
15
|
+
<!-- 一级标题 -->
|
|
16
|
+
<slot name="title">
|
|
17
|
+
<text v-if="title" class="text">{{ title }}</text>
|
|
18
|
+
</slot>
|
|
19
|
+
<!-- 二级标题 -->
|
|
20
|
+
<text v-if="checkDesc" class="desc">{{ desc }}</text>
|
|
21
|
+
</view>
|
|
22
|
+
<!-- 右侧 -->
|
|
23
|
+
<view class="pi-align-center pi-lh-44">
|
|
24
|
+
<!-- 自定义内容 -->
|
|
25
|
+
<slot name="value">
|
|
26
|
+
<text v-if="checkValue" class="value">{{ value }}</text>
|
|
27
|
+
</slot>
|
|
28
|
+
<!-- 图标 -->
|
|
29
|
+
<view class="icon pi-mg-left-8" :class="getIconClass">
|
|
30
|
+
<pi-icon name="right" />
|
|
31
|
+
</view>
|
|
32
|
+
</view>
|
|
33
|
+
</view>
|
|
34
|
+
<!-- 内容 -->
|
|
35
|
+
<view ref="animation" class="pi-collapse-item__content" :animation="animationData">
|
|
36
|
+
<view :id="elId" :ref="elId" class="pi-collapse-item__content__text content-class">
|
|
37
|
+
<slot />
|
|
38
|
+
</view>
|
|
39
|
+
</view>
|
|
40
|
+
<pi-divider v-if="expanded && border" />
|
|
41
|
+
</view>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
// #ifdef APP-NVUE
|
|
46
|
+
const animation = uni.requireNativePlugin('animation')
|
|
47
|
+
const dom = uni.requireNativePlugin('dom')
|
|
48
|
+
// #endif
|
|
49
|
+
import { getConfig } from '../../config'
|
|
50
|
+
const { collapseItem } = getConfig()
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* collapseItem 折叠面板Item
|
|
54
|
+
* @description 通过折叠面板收纳内容区域(搭配pi-collapse使用)
|
|
55
|
+
* @tutorial http://piui.sadais.com/docs/components/collapse.html
|
|
56
|
+
* @event {Function} change 某个item被打开或者收起时触发
|
|
57
|
+
* @example <pi-collapse-item :title="item.head" v-for="(item, index) in itemList" :key="index">{{item.body}}</pi-collapse-item>
|
|
58
|
+
*/
|
|
59
|
+
export default {
|
|
60
|
+
name: 'PiCollapseItem',
|
|
61
|
+
props: {
|
|
62
|
+
// 标题
|
|
63
|
+
title: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: collapseItem.title
|
|
66
|
+
},
|
|
67
|
+
// 自定义内容
|
|
68
|
+
value: {
|
|
69
|
+
type: String,
|
|
70
|
+
default: collapseItem.value
|
|
71
|
+
},
|
|
72
|
+
// 唯一标识
|
|
73
|
+
name: {
|
|
74
|
+
type: [Number, String],
|
|
75
|
+
default: collapseItem.name
|
|
76
|
+
},
|
|
77
|
+
// 描述
|
|
78
|
+
desc: {
|
|
79
|
+
type: String,
|
|
80
|
+
default: collapseItem.desc
|
|
81
|
+
},
|
|
82
|
+
// 是否禁用折叠面板
|
|
83
|
+
disabled: {
|
|
84
|
+
type: Boolean,
|
|
85
|
+
default: collapseItem.disabled
|
|
86
|
+
},
|
|
87
|
+
// 是否显示内边框
|
|
88
|
+
border: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
default: collapseItem.border
|
|
91
|
+
},
|
|
92
|
+
// 面板展开收起的过渡时间,单位ms
|
|
93
|
+
duration: {
|
|
94
|
+
type: Number,
|
|
95
|
+
default: collapseItem.duration
|
|
96
|
+
},
|
|
97
|
+
// 自定义折叠面板列表的样式类名
|
|
98
|
+
customClass: {
|
|
99
|
+
type: String,
|
|
100
|
+
default: collapseItem.customClass
|
|
101
|
+
},
|
|
102
|
+
// 自定义折叠面板列表的样式
|
|
103
|
+
customStyle: {
|
|
104
|
+
type: Object,
|
|
105
|
+
default: () => {
|
|
106
|
+
return collapseItem.customStyle
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
data() {
|
|
111
|
+
return {
|
|
112
|
+
elId: this.$pi.guid(), // 全局唯一标识符
|
|
113
|
+
// uni.createAnimation的导出数据
|
|
114
|
+
animationData: {},
|
|
115
|
+
// 是否展开状态
|
|
116
|
+
expanded: false,
|
|
117
|
+
// 根据expanded确定是否显示border,为了控制展开时,cell的下划线更好的显示效果,进行一定时间的延时
|
|
118
|
+
showBorder: false,
|
|
119
|
+
// 是否动画中,如果是则不允许继续触发点击
|
|
120
|
+
animating: false,
|
|
121
|
+
// 父组件pi-collapse的参数
|
|
122
|
+
parentData: {
|
|
123
|
+
accordion: false,
|
|
124
|
+
border: false
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
computed: {
|
|
129
|
+
// 动态改变折叠面板的展开收起状态
|
|
130
|
+
getIconClass() {
|
|
131
|
+
return this.expanded ? 'up' : 'down'
|
|
132
|
+
},
|
|
133
|
+
// 检查自定义内容是否为空
|
|
134
|
+
checkValue() {
|
|
135
|
+
return !this.$pi.lang.isEmpty(this.value)
|
|
136
|
+
},
|
|
137
|
+
// 检查自定义描述是否为空
|
|
138
|
+
checkDesc() {
|
|
139
|
+
return !this.$pi.lang.isEmpty(this.desc)
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
watch: {
|
|
143
|
+
expanded(n) {
|
|
144
|
+
clearTimeout(this.timer)
|
|
145
|
+
this.timer = null
|
|
146
|
+
// 这里根据expanded的值来进行一定的延时,是为了cell的下划线更好的显示效果
|
|
147
|
+
this.timer = setTimeout(
|
|
148
|
+
() => {
|
|
149
|
+
this.showBorder = n
|
|
150
|
+
},
|
|
151
|
+
n ? 10 : 290
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
mounted() {
|
|
156
|
+
this.init()
|
|
157
|
+
},
|
|
158
|
+
methods: {
|
|
159
|
+
// 异步获取内容,或者动态修改了内容时,需要重新初始化
|
|
160
|
+
init() {
|
|
161
|
+
// 初始化数据
|
|
162
|
+
this.updateParentData()
|
|
163
|
+
if (!this.parent) {
|
|
164
|
+
return console.error('pi-collapse-item必须要搭配pi-collapse组件使用')
|
|
165
|
+
}
|
|
166
|
+
const { value, accordion } = this.parent
|
|
167
|
+
if (accordion) {
|
|
168
|
+
if (this.$pi.lang.isArray(value)) {
|
|
169
|
+
return console.error('手风琴模式下,pi-collapse组件的value参数不能为数组')
|
|
170
|
+
}
|
|
171
|
+
this.expanded = this.name == value
|
|
172
|
+
} else {
|
|
173
|
+
if (!this.$pi.lang.isArray(value) && value !== null) {
|
|
174
|
+
return console.error('非手风琴模式下,pi-collapse组件的value参数必须为数组')
|
|
175
|
+
}
|
|
176
|
+
this.expanded = (value || []).some(item => item == this.name)
|
|
177
|
+
}
|
|
178
|
+
// 设置组件的展开或收起状态
|
|
179
|
+
this.$nextTick(function () {
|
|
180
|
+
this.setContentAnimate()
|
|
181
|
+
})
|
|
182
|
+
},
|
|
183
|
+
updateParentData() {
|
|
184
|
+
// 传组件Name给父组件,用于组件展开或收起时,改变父组件的值
|
|
185
|
+
this.getParentData('PiCollapse')
|
|
186
|
+
},
|
|
187
|
+
async setContentAnimate() {
|
|
188
|
+
// 每次面板打开或者收起时,都查询元素尺寸
|
|
189
|
+
// 好处是,父组件从服务端获取内容后,变更折叠面板后可以获得最新的高度
|
|
190
|
+
const rect = await this.queryRect()
|
|
191
|
+
const height = this.expanded ? rect.height : 0
|
|
192
|
+
this.animating = true
|
|
193
|
+
// #ifdef APP-NVUE
|
|
194
|
+
const ref = this.$refs['animation'].ref
|
|
195
|
+
animation.transition(
|
|
196
|
+
ref,
|
|
197
|
+
{
|
|
198
|
+
styles: {
|
|
199
|
+
height: height + 'px'
|
|
200
|
+
},
|
|
201
|
+
duration: this.duration,
|
|
202
|
+
// 必须设置为true,否则会到面板收起或展开时,页面其他元素不会随之调整它们的布局
|
|
203
|
+
needLayout: true,
|
|
204
|
+
timingFunction: 'ease-in-out'
|
|
205
|
+
},
|
|
206
|
+
() => {
|
|
207
|
+
this.animating = false
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
// #endif
|
|
211
|
+
|
|
212
|
+
// #ifndef APP-NVUE
|
|
213
|
+
const animation = uni.createAnimation({
|
|
214
|
+
timingFunction: 'ease-in-out'
|
|
215
|
+
})
|
|
216
|
+
animation
|
|
217
|
+
.height(height)
|
|
218
|
+
.step({
|
|
219
|
+
duration: this.duration
|
|
220
|
+
})
|
|
221
|
+
.step()
|
|
222
|
+
// 导出动画数据给面板的animationData值
|
|
223
|
+
this.animationData = animation.export()
|
|
224
|
+
// 标识动画结束
|
|
225
|
+
this.sleep(this.duration).then(() => {
|
|
226
|
+
this.animating = false
|
|
227
|
+
})
|
|
228
|
+
// #endif
|
|
229
|
+
},
|
|
230
|
+
// 点击collapsehead头部
|
|
231
|
+
clickHandler() {
|
|
232
|
+
if (this.disabled || this.animating) return
|
|
233
|
+
// 设置本组件为相反的状态
|
|
234
|
+
this.parent && this.parent.onChange(this)
|
|
235
|
+
},
|
|
236
|
+
/**
|
|
237
|
+
* @description 进行延时,以达到可以简写代码的目的
|
|
238
|
+
* @param {number} value 堵塞时间 单位ms 毫秒
|
|
239
|
+
* @returns {Promise} 返回promise
|
|
240
|
+
*/
|
|
241
|
+
sleep(value) {
|
|
242
|
+
return new Promise(resolve => {
|
|
243
|
+
setTimeout(() => {
|
|
244
|
+
resolve()
|
|
245
|
+
}, value)
|
|
246
|
+
})
|
|
247
|
+
},
|
|
248
|
+
// 查询内容高度
|
|
249
|
+
queryRect() {
|
|
250
|
+
return new Promise(resolve => {
|
|
251
|
+
// #ifndef APP-NVUE
|
|
252
|
+
this.$pi.common.queryRect(this, `#${this.elId}`).then(size => {
|
|
253
|
+
resolve(size)
|
|
254
|
+
})
|
|
255
|
+
// #endif
|
|
256
|
+
|
|
257
|
+
// #ifdef APP-NVUE
|
|
258
|
+
// nvue下,使用dom模块查询元素高度
|
|
259
|
+
// 返回一个promise,让调用此方法的主体能使用then回调
|
|
260
|
+
dom.getComponentRect(this.$refs[this.elId], res => {
|
|
261
|
+
resolve(res.size)
|
|
262
|
+
})
|
|
263
|
+
// #endif
|
|
264
|
+
})
|
|
265
|
+
},
|
|
266
|
+
getParentData(parentName = '') {
|
|
267
|
+
// 避免在created中去定义parent变量
|
|
268
|
+
if (!this.parent) this.parent = {}
|
|
269
|
+
this.parent = this.$pi.parent(this, parentName)
|
|
270
|
+
if (this.parent.children) {
|
|
271
|
+
// 如果父组件的children不存在本组件的实例,才将本实例添加到父组件的children中
|
|
272
|
+
this.parent.children.indexOf(this) === -1 && this.parent.children.push(this)
|
|
273
|
+
}
|
|
274
|
+
if (this.parent && this.parentData) {
|
|
275
|
+
// 历遍parentData中的属性,将parent中的同名属性赋值给parentData
|
|
276
|
+
Object.keys(this.parentData).map(key => {
|
|
277
|
+
this.parentData[key] = this.parent[key]
|
|
278
|
+
})
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
</script>
|
|
284
|
+
|
|
285
|
+
<style lang="scss" scoped>
|
|
286
|
+
.pi-collapse-item {
|
|
287
|
+
&__title {
|
|
288
|
+
padding: 15px;
|
|
289
|
+
// 边框
|
|
290
|
+
&.border {
|
|
291
|
+
position: relative;
|
|
292
|
+
&:after {
|
|
293
|
+
content: ' ';
|
|
294
|
+
position: absolute;
|
|
295
|
+
left: 0;
|
|
296
|
+
bottom: 0;
|
|
297
|
+
right: 0;
|
|
298
|
+
height: 1px;
|
|
299
|
+
border-bottom: 1px solid rgb(214, 228, 239);
|
|
300
|
+
color: rgb(214, 228, 239);
|
|
301
|
+
-webkit-transform-origin: 0 0;
|
|
302
|
+
transform-origin: 0 0;
|
|
303
|
+
-webkit-transform: scaleY(0.5);
|
|
304
|
+
transform: scaleY(0.5);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
&:active {
|
|
308
|
+
background-color: #f3f4f6;
|
|
309
|
+
}
|
|
310
|
+
.text {
|
|
311
|
+
color: #303133;
|
|
312
|
+
}
|
|
313
|
+
.desc {
|
|
314
|
+
font-size: 24rpx;
|
|
315
|
+
color: #8c8c8c;
|
|
316
|
+
}
|
|
317
|
+
.icon {
|
|
318
|
+
color: #909399;
|
|
319
|
+
transition: transform 0.3s;
|
|
320
|
+
&.up {
|
|
321
|
+
transform: rotate(-90deg);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
&.down {
|
|
325
|
+
transform: rotate(90deg);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
&.disabled {
|
|
329
|
+
cursor: not-allowed;
|
|
330
|
+
.text,
|
|
331
|
+
.icon {
|
|
332
|
+
color: #cccccc;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
&__content {
|
|
337
|
+
overflow: hidden;
|
|
338
|
+
height: 0;
|
|
339
|
+
|
|
340
|
+
&__text {
|
|
341
|
+
padding: 24rpx 30rpx;
|
|
342
|
+
color: #606266;
|
|
343
|
+
line-height: 36rpx;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
</style>
|
|
@@ -119,6 +119,13 @@ export default {
|
|
|
119
119
|
// ''
|
|
120
120
|
default: datePicker.defaultValue
|
|
121
121
|
},
|
|
122
|
+
// 单位数组,默认值:['年', '月', '日', '时', '分', '秒']
|
|
123
|
+
units: {
|
|
124
|
+
type: Array,
|
|
125
|
+
default() {
|
|
126
|
+
return datePicker.units
|
|
127
|
+
}
|
|
128
|
+
},
|
|
122
129
|
// 返回的日期格式
|
|
123
130
|
format: {
|
|
124
131
|
type: String,
|
|
@@ -227,33 +234,40 @@ export default {
|
|
|
227
234
|
const itemHeight = uni.upx2px(this.itemHeight)
|
|
228
235
|
return `height: ${itemHeight}px;line-height: ${itemHeight}px;`
|
|
229
236
|
},
|
|
237
|
+
getUnits() {
|
|
238
|
+
return this.$pi.mergeDeep(datePicker.units, this.units, {
|
|
239
|
+
arrayMerge: (target, source, options) => {
|
|
240
|
+
return target.map((t, index) => source[index] || t)
|
|
241
|
+
}
|
|
242
|
+
})
|
|
243
|
+
},
|
|
230
244
|
columns() {
|
|
231
245
|
const monthDays = new Date(this.date.year, this.date.month, 0).getDate()
|
|
232
246
|
let columns = [
|
|
233
247
|
{
|
|
234
248
|
field: 'year',
|
|
235
|
-
unit:
|
|
249
|
+
unit: this.getUnits[0],
|
|
236
250
|
key: 'year',
|
|
237
251
|
setMethod: 'setYear',
|
|
238
252
|
items: this.$pi.common.generateArray(this.startYear, this.endYear)
|
|
239
253
|
},
|
|
240
254
|
{
|
|
241
255
|
field: 'month',
|
|
242
|
-
unit:
|
|
256
|
+
unit: this.getUnits[1],
|
|
243
257
|
key: 'month',
|
|
244
258
|
setMethod: 'setMonth',
|
|
245
259
|
items: this.$pi.common.generateArray(1, 12)
|
|
246
260
|
},
|
|
247
261
|
{
|
|
248
262
|
field: 'day',
|
|
249
|
-
unit:
|
|
263
|
+
unit: this.getUnits[2],
|
|
250
264
|
key: 'date',
|
|
251
265
|
setMethod: 'setDate',
|
|
252
266
|
items: this.$pi.common.generateArray(1, monthDays)
|
|
253
267
|
},
|
|
254
268
|
{
|
|
255
269
|
field: 'hour',
|
|
256
|
-
unit:
|
|
270
|
+
unit: this.getUnits[3],
|
|
257
271
|
key: 'hour',
|
|
258
272
|
setMethod: 'setHours',
|
|
259
273
|
type: 'time',
|
|
@@ -261,7 +275,7 @@ export default {
|
|
|
261
275
|
},
|
|
262
276
|
{
|
|
263
277
|
field: 'minute',
|
|
264
|
-
unit:
|
|
278
|
+
unit: this.getUnits[4],
|
|
265
279
|
key: 'minute',
|
|
266
280
|
setMethod: 'setMinutes',
|
|
267
281
|
type: 'time',
|
|
@@ -269,7 +283,7 @@ export default {
|
|
|
269
283
|
},
|
|
270
284
|
{
|
|
271
285
|
field: 'second',
|
|
272
|
-
unit:
|
|
286
|
+
unit: this.getUnits[5],
|
|
273
287
|
key: 'second',
|
|
274
288
|
setMethod: 'setSeconds',
|
|
275
289
|
type: 'time',
|
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
<!-- 注意:slot内不能使用父组件data -->
|
|
3
|
+
<view
|
|
4
|
+
class="dropdown-tab-item pi-justify-center pi-align-center"
|
|
5
|
+
:style="[getTabItemStyle]"
|
|
6
|
+
:class="[{ opened: item.opened }]"
|
|
7
|
+
@tap.stop="handleClick"
|
|
8
|
+
>
|
|
9
|
+
<pi-icon
|
|
10
|
+
v-if="item.showIcon"
|
|
11
|
+
:name="item.iconOption.name"
|
|
12
|
+
:dot="item.iconOption.dot"
|
|
13
|
+
:badge="item.iconOption.badge"
|
|
14
|
+
:color="item.iconOption.color"
|
|
15
|
+
:size="item.iconOption.size"
|
|
16
|
+
:class-prefix="item.iconOption.classPrefix"
|
|
17
|
+
:custom-style="item.iconOption.customStyle"
|
|
18
|
+
:custom-class="`pi-mg-right-8 ${item.iconOption.customClass}`"
|
|
19
|
+
/>
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
</view>
|
|
21
|
+
<text class="pi-pd-right-12 pi-fz-28">
|
|
22
|
+
{{ item.text }}
|
|
23
|
+
</text>
|
|
24
|
+
<pi-icon :class="{ rotate: item.opened }" name="arrow-down_fill" size="26" color="#999" />
|
|
26
25
|
</view>
|
|
27
26
|
</template>
|
|
28
27
|
|
|
@@ -39,6 +38,15 @@ export default {
|
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
},
|
|
41
|
+
computed: {
|
|
42
|
+
getTabItemStyle() {
|
|
43
|
+
const styles = {}
|
|
44
|
+
if (this.item.opened && this.item.activeColor) {
|
|
45
|
+
styles.color = this.item.activeColor
|
|
46
|
+
}
|
|
47
|
+
return styles
|
|
48
|
+
}
|
|
49
|
+
},
|
|
42
50
|
methods: {
|
|
43
51
|
handleClick() {
|
|
44
52
|
this.$emit('click', this.item)
|
|
@@ -49,7 +57,8 @@ export default {
|
|
|
49
57
|
|
|
50
58
|
<style lang="scss" scoped>
|
|
51
59
|
.dropdown-tab-item {
|
|
52
|
-
|
|
60
|
+
width: 100%;
|
|
61
|
+
height: 100%;
|
|
53
62
|
&.opened {
|
|
54
63
|
color: $pi-primary-color;
|
|
55
64
|
}
|