Commit 89670198f382e0612cf18c45247b909b293a650f
1 parent
a81dc06c
publish 0.9.9-rc-5
Table sortable support Safari、IE、Edge
Showing
4 changed files
with
77 additions
and
32 deletions
Show diff stats
package.json
| 1 | 1 | { |
| 2 | 2 | "name": "iview", |
| 3 | - "version": "0.9.9-rc-4", | |
| 3 | + "version": "0.9.9-rc-5", | |
| 4 | 4 | "title": "iView", |
| 5 | 5 | "description": "A high quality UI components Library with Vue.js", |
| 6 | 6 | "homepage": "http://www.iviewui.com", |
| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 | "src" |
| 20 | 20 | ], |
| 21 | 21 | "scripts": { |
| 22 | - "dev": "webpack-dev-server --content-base test/ --open --inline --hot --compress --history-api-fallback --port 8081 --config build/webpack.dev.config.js", | |
| 22 | + "dev": "webpack-dev-server --content-base test/ --open --inline --host 172.30.116.62 --hot --compress --history-api-fallback --port 8081 --config build/webpack.dev.config.js", | |
| 23 | 23 | "dist:style": "gulp --gulpfile build/build-style.js", |
| 24 | 24 | "dist:dev": "webpack --config build/webpack.dist.dev.config.js", |
| 25 | 25 | "dist:prod": "webpack --config build/webpack.dist.prod.config.js", | ... | ... |
src/components/table/table-head.vue
| ... | ... | @@ -36,10 +36,10 @@ |
| 36 | 36 | <div slot="content" :class="[prefixCls + '-filter-list']" v-else> |
| 37 | 37 | <ul :class="[prefixCls + '-filter-list-single']"> |
| 38 | 38 | <li |
| 39 | - :class="[prefixCls + '-filter-select-item', {[prefixCls + '-filter-select-item-selected']: !column._filterChecked.length}]" | |
| 39 | + :class="itemAllClasses(column)" | |
| 40 | 40 | @click="handleReset($index)">全部</li> |
| 41 | 41 | <li |
| 42 | - :class="[prefixCls + '-filter-select-item', {[prefixCls + '-filter-select-item-selected']: column._filterChecked[0] === item.value}]" | |
| 42 | + :class="itemClasses(column, item)" | |
| 43 | 43 | v-for="item in column.filters" |
| 44 | 44 | @click="handleSelect(index, item.value)">{{ item.label }}</li> |
| 45 | 45 | </ul> |
| ... | ... | @@ -98,6 +98,22 @@ |
| 98 | 98 | } |
| 99 | 99 | ] |
| 100 | 100 | }, |
| 101 | + itemClasses (column, item) { | |
| 102 | + return [ | |
| 103 | + `${this.prefixCls}-filter-select-item`, | |
| 104 | + { | |
| 105 | + [`${this.prefixCls}-filter-select-item-selected`]: column._filterChecked[0] === item.value | |
| 106 | + } | |
| 107 | + ] | |
| 108 | + }, | |
| 109 | + itemAllClasses (column) { | |
| 110 | + return [ | |
| 111 | + `${this.prefixCls}-filter-select-item`, | |
| 112 | + { | |
| 113 | + [`${this.prefixCls}-filter-select-item-selected`]: !column._filterChecked.length | |
| 114 | + } | |
| 115 | + ] | |
| 116 | + }, | |
| 101 | 117 | renderHeader (column, $index) { |
| 102 | 118 | if ('renderHeader' in this.columns[$index]) { |
| 103 | 119 | return this.columns[$index].renderHeader(column, $index); | ... | ... |
src/components/table/table.vue
| ... | ... | @@ -368,7 +368,11 @@ |
| 368 | 368 | if (this.cloneColumns[index].sortMethod) { |
| 369 | 369 | return this.cloneColumns[index].sortMethod(a, b); |
| 370 | 370 | } else { |
| 371 | - return type === 'asc' ? a[key] > b[key] : a[key] < b[key]; | |
| 371 | + if (type === 'asc') { | |
| 372 | + return a[key] > b[key] ? 1 : -1; | |
| 373 | + } else if (type === 'desc') { | |
| 374 | + return a[key] < b[key] ? 1 : -1; | |
| 375 | + } | |
| 372 | 376 | } |
| 373 | 377 | }); |
| 374 | 378 | return data; | ... | ... |
test/routers/table.vue
| 1 | 1 | <template> |
| 2 | - <Card> | |
| 3 | - <i-table :content="self" border :columns="columns7" :data="data6"></i-table> | |
| 4 | - </Card> | |
| 2 | + <i-table border :columns="columns6" :data="data5"></i-table> | |
| 5 | 3 | </template> |
| 6 | 4 | <script> |
| 7 | 5 | export default { |
| 8 | 6 | data () { |
| 9 | 7 | return { |
| 10 | - self: this, | |
| 11 | - columns7: [ | |
| 8 | + columns6: [ | |
| 9 | + { | |
| 10 | + title: '日期', | |
| 11 | + key: 'date' | |
| 12 | + }, | |
| 12 | 13 | { |
| 13 | 14 | title: '姓名', |
| 14 | - key: 'name', | |
| 15 | - render (row, column, index) { | |
| 16 | - return `<strong>${row.name}</strong>`; | |
| 17 | - } | |
| 15 | + key: 'name' | |
| 18 | 16 | }, |
| 19 | 17 | { |
| 20 | 18 | title: '年龄', |
| 21 | - key: 'age' | |
| 19 | + key: 'age', | |
| 20 | + filters: [ | |
| 21 | + { | |
| 22 | + label: '大于25岁', | |
| 23 | + value: 1 | |
| 24 | + }, | |
| 25 | + { | |
| 26 | + label: '小于25岁', | |
| 27 | + value: 2 | |
| 28 | + } | |
| 29 | + ], | |
| 30 | + filterMultiple: false, | |
| 31 | + filterMethod (value, row) { | |
| 32 | + if (value === 1) { | |
| 33 | + return row.age > 25; | |
| 34 | + } else if (value === 2) { | |
| 35 | + return row.age < 25; | |
| 36 | + } | |
| 37 | + } | |
| 22 | 38 | }, |
| 23 | 39 | { |
| 24 | 40 | title: '地址', |
| 25 | - key: 'address' | |
| 26 | - }, | |
| 27 | - { | |
| 28 | - title: '操作', | |
| 29 | - key: 'action', | |
| 30 | - render (row, column, index) { | |
| 31 | - return `<i-button type="primary" size="small" @click="show(${index})">查看</i-button> <i-button type="error" size="small" @click="remove(${index})">删除</i-button>`; | |
| 41 | + key: 'address', | |
| 42 | + filters: [ | |
| 43 | + { | |
| 44 | + label: '北京', | |
| 45 | + value: '北京' | |
| 46 | + }, | |
| 47 | + { | |
| 48 | + label: '上海', | |
| 49 | + value: '上海' | |
| 50 | + }, | |
| 51 | + { | |
| 52 | + label: '深圳', | |
| 53 | + value: '深圳' | |
| 54 | + } | |
| 55 | + ], | |
| 56 | + filterMethod (value, row) { | |
| 57 | + return row.address.indexOf(value) > -1; | |
| 32 | 58 | } |
| 33 | 59 | } |
| 34 | 60 | ], |
| 35 | - data6: [ | |
| 61 | + data5: [ | |
| 36 | 62 | { |
| 37 | 63 | name: '王小明', |
| 38 | 64 | age: 18, |
| 39 | - address: '北京市朝阳区芍药居' | |
| 65 | + address: '北京市朝阳区芍药居', | |
| 66 | + date: '2016-10-03' | |
| 40 | 67 | }, |
| 41 | 68 | { |
| 42 | 69 | name: '张小刚', |
| 43 | 70 | age: 25, |
| 44 | - address: '北京市海淀区西二旗' | |
| 71 | + address: '北京市海淀区西二旗', | |
| 72 | + date: '2016-10-01' | |
| 45 | 73 | }, |
| 46 | 74 | { |
| 47 | 75 | name: '李小红', |
| 48 | 76 | age: 30, |
| 49 | - address: '上海市浦东新区世纪大道' | |
| 77 | + address: '上海市浦东新区世纪大道', | |
| 78 | + date: '2016-10-02' | |
| 50 | 79 | }, |
| 51 | 80 | { |
| 52 | 81 | name: '周小伟', |
| 53 | 82 | age: 26, |
| 54 | - address: '深圳市南山区深南大道' | |
| 83 | + address: '深圳市南山区深南大道', | |
| 84 | + date: '2016-10-04' | |
| 55 | 85 | } |
| 56 | 86 | ] |
| 57 | 87 | } |
| 58 | - }, | |
| 59 | - methods: { | |
| 60 | - remove (index) { | |
| 61 | - this.data6.splice(index, 1); | |
| 62 | - } | |
| 63 | 88 | } |
| 64 | 89 | } |
| 65 | 90 | </script> | ... | ... |