You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.6 KiB
59 lines
1.6 KiB
import baseComponent from '../helpers/baseComponent'
|
|
import classNames from '../helpers/classNames'
|
|
|
|
baseComponent({
|
|
relations: {
|
|
'../grid/index': {
|
|
type: 'child',
|
|
observer() {
|
|
this.debounce(this.changeCurrent)
|
|
},
|
|
},
|
|
},
|
|
properties: {
|
|
prefixCls: {
|
|
type: String,
|
|
value: 'wux-grids',
|
|
},
|
|
col: {
|
|
type: Number,
|
|
value: 3,
|
|
observer: 'changeCurrent',
|
|
},
|
|
bordered: {
|
|
type: Boolean,
|
|
value: true,
|
|
observer: 'changeCurrent',
|
|
},
|
|
square: {
|
|
type: Boolean,
|
|
value: false,
|
|
observer: 'changeCurrent',
|
|
},
|
|
},
|
|
computed: {
|
|
classes: ['prefixCls, bordered', function(prefixCls, bordered) {
|
|
const wrap = classNames(prefixCls, {
|
|
[`${prefixCls}--bordered`]: bordered,
|
|
})
|
|
|
|
return {
|
|
wrap,
|
|
}
|
|
}],
|
|
},
|
|
methods: {
|
|
changeCurrent() {
|
|
const elements = this.getRelationNodes('../grid/index')
|
|
const { col, bordered, square } = this.data
|
|
const colNum = parseInt(col) > 0 ? parseInt(col) : 1
|
|
const width = `${100 / colNum}%`
|
|
|
|
if (elements.length > 0) {
|
|
elements.forEach((element, index) => {
|
|
element.changeCurrent(width, bordered, square, index)
|
|
})
|
|
}
|
|
},
|
|
},
|
|
})
|
|
|