Commit 6c634aa6319f6173ea7765be40840fefdf2676f0
1 parent
c2d74eca
fixed #2078
Showing
2 changed files
with
358 additions
and
247 deletions
Show diff stats
examples/routers/table.vue
| ... | ... | @@ -109,292 +109,401 @@ |
| 109 | 109 | <!--}--> |
| 110 | 110 | <!--</script>--> |
| 111 | 111 | |
| 112 | -<style scoped> | |
| 113 | - .layout{ | |
| 114 | - border: 1px solid #d7dde4; | |
| 115 | - background: #f5f7f9; | |
| 116 | - position: relative; | |
| 117 | - border-radius: 4px; | |
| 118 | - overflow: hidden; | |
| 119 | - } | |
| 120 | - .layout-breadcrumb{ | |
| 121 | - padding: 10px 15px 0; | |
| 122 | - } | |
| 123 | - .layout-content{ | |
| 124 | - min-height: 200px; | |
| 125 | - margin: 15px; | |
| 126 | - overflow: hidden; | |
| 127 | - background: #fff; | |
| 128 | - border-radius: 4px; | |
| 129 | - } | |
| 130 | - .layout-content-main{ | |
| 131 | - padding: 10px; | |
| 132 | - } | |
| 133 | - .layout-copy{ | |
| 134 | - text-align: center; | |
| 135 | - padding: 10px 0 20px; | |
| 136 | - color: #9ea7b4; | |
| 137 | - } | |
| 138 | - .layout-menu-left{ | |
| 139 | - background: #464c5b; | |
| 140 | - } | |
| 141 | - .layout-header{ | |
| 142 | - height: 60px; | |
| 143 | - background: #fff; | |
| 144 | - box-shadow: 0 1px 1px rgba(0,0,0,.1); | |
| 145 | - } | |
| 146 | - .layout-logo-left{ | |
| 147 | - width: 90%; | |
| 148 | - height: 30px; | |
| 149 | - background: #5b6270; | |
| 150 | - border-radius: 3px; | |
| 151 | - margin: 15px auto; | |
| 152 | - } | |
| 153 | - .layout-ceiling-main a{ | |
| 154 | - color: #9ba7b5; | |
| 155 | - } | |
| 156 | - .layout-hide-text .layout-text{ | |
| 157 | - display: none; | |
| 158 | - } | |
| 159 | - .ivu-col{ | |
| 160 | - /*transition: width .2s ease-in-out;*/ | |
| 161 | - } | |
| 162 | -</style> | |
| 112 | +<!--<style scoped>--> | |
| 113 | + <!--.layout{--> | |
| 114 | + <!--border: 1px solid #d7dde4;--> | |
| 115 | + <!--background: #f5f7f9;--> | |
| 116 | + <!--position: relative;--> | |
| 117 | + <!--border-radius: 4px;--> | |
| 118 | + <!--overflow: hidden;--> | |
| 119 | + <!--}--> | |
| 120 | + <!--.layout-breadcrumb{--> | |
| 121 | + <!--padding: 10px 15px 0;--> | |
| 122 | + <!--}--> | |
| 123 | + <!--.layout-content{--> | |
| 124 | + <!--min-height: 200px;--> | |
| 125 | + <!--margin: 15px;--> | |
| 126 | + <!--overflow: hidden;--> | |
| 127 | + <!--background: #fff;--> | |
| 128 | + <!--border-radius: 4px;--> | |
| 129 | + <!--}--> | |
| 130 | + <!--.layout-content-main{--> | |
| 131 | + <!--padding: 10px;--> | |
| 132 | + <!--}--> | |
| 133 | + <!--.layout-copy{--> | |
| 134 | + <!--text-align: center;--> | |
| 135 | + <!--padding: 10px 0 20px;--> | |
| 136 | + <!--color: #9ea7b4;--> | |
| 137 | + <!--}--> | |
| 138 | + <!--.layout-menu-left{--> | |
| 139 | + <!--background: #464c5b;--> | |
| 140 | + <!--}--> | |
| 141 | + <!--.layout-header{--> | |
| 142 | + <!--height: 60px;--> | |
| 143 | + <!--background: #fff;--> | |
| 144 | + <!--box-shadow: 0 1px 1px rgba(0,0,0,.1);--> | |
| 145 | + <!--}--> | |
| 146 | + <!--.layout-logo-left{--> | |
| 147 | + <!--width: 90%;--> | |
| 148 | + <!--height: 30px;--> | |
| 149 | + <!--background: #5b6270;--> | |
| 150 | + <!--border-radius: 3px;--> | |
| 151 | + <!--margin: 15px auto;--> | |
| 152 | + <!--}--> | |
| 153 | + <!--.layout-ceiling-main a{--> | |
| 154 | + <!--color: #9ba7b5;--> | |
| 155 | + <!--}--> | |
| 156 | + <!--.layout-hide-text .layout-text{--> | |
| 157 | + <!--display: none;--> | |
| 158 | + <!--}--> | |
| 159 | + <!--.ivu-col{--> | |
| 160 | + <!--/*transition: width .2s ease-in-out;*/--> | |
| 161 | + <!--}--> | |
| 162 | +<!--</style>--> | |
| 163 | +<!--<template>--> | |
| 164 | + <!--<div class="layout" :class="{'layout-hide-text': spanLeft < 5}">--> | |
| 165 | + <!--<Row type="flex">--> | |
| 166 | + <!--<Col :span="spanLeft" class="layout-menu-left">--> | |
| 167 | + <!--<Menu active-name="1" theme="dark" width="auto">--> | |
| 168 | + <!--<div class="layout-logo-left"></div>--> | |
| 169 | + <!--<MenuItem name="1">--> | |
| 170 | + <!--<Icon type="ios-navigate" :size="iconSize"></Icon>--> | |
| 171 | + <!--<span class="layout-text">选项 1</span>--> | |
| 172 | + <!--</MenuItem>--> | |
| 173 | + <!--<MenuItem name="2">--> | |
| 174 | + <!--<Icon type="ios-keypad" :size="iconSize"></Icon>--> | |
| 175 | + <!--<span class="layout-text">选项 2</span>--> | |
| 176 | + <!--</MenuItem>--> | |
| 177 | + <!--<MenuItem name="3">--> | |
| 178 | + <!--<Icon type="ios-analytics" :size="iconSize"></Icon>--> | |
| 179 | + <!--<span class="layout-text">选项 3</span>--> | |
| 180 | + <!--</MenuItem>--> | |
| 181 | + <!--</Menu>--> | |
| 182 | + <!--</Col>--> | |
| 183 | + <!--<Col :span="spanRight">--> | |
| 184 | + <!--<div class="layout-header">--> | |
| 185 | + <!--<Button type="text" @click="toggleClick">--> | |
| 186 | + <!--<Icon type="navicon" size="32"></Icon>--> | |
| 187 | + <!--</Button>--> | |
| 188 | + <!--</div>--> | |
| 189 | + <!--<div class="layout-breadcrumb">--> | |
| 190 | + <!--<Breadcrumb>--> | |
| 191 | + <!--<BreadcrumbItem href="#">首页</BreadcrumbItem>--> | |
| 192 | + <!--<BreadcrumbItem href="#">应用中心</BreadcrumbItem>--> | |
| 193 | + <!--<BreadcrumbItem>某应用</BreadcrumbItem>--> | |
| 194 | + <!--</Breadcrumb>--> | |
| 195 | + <!--</div>--> | |
| 196 | + <!--<div class="layout-content">--> | |
| 197 | + <!--<div class="layout-content-main">--> | |
| 198 | + <!--<Table stripe :columns="columns1" :data="data1"></Table>--> | |
| 199 | + <!--</div>--> | |
| 200 | + <!--<hr style="margin: 10px 0;" />--> | |
| 201 | + <!--<div class="layout-content-main">--> | |
| 202 | + <!--<Table stripe :columns="columns2" :data="data2" ref="csvTable" @on-row-click="cc" />--> | |
| 203 | + <!--<i-button type="primary" size="large" @click="exportCSV">--> | |
| 204 | + <!--<icon type="ios-download-outline"></icon> Export to CSV--> | |
| 205 | + <!--</i-button>--> | |
| 206 | + <!--</div>--> | |
| 207 | + <!--</div>--> | |
| 208 | + <!--</Col>--> | |
| 209 | + <!--</Row>--> | |
| 210 | + <!--</div>--> | |
| 211 | +<!--</template>--> | |
| 212 | +<!--<script>--> | |
| 213 | + <!--export default {--> | |
| 214 | + <!--data () {--> | |
| 215 | + <!--return {--> | |
| 216 | + <!--spanLeft: 5,--> | |
| 217 | + <!--spanRight: 19,--> | |
| 218 | + <!--columns1: [--> | |
| 219 | + <!--{--> | |
| 220 | + <!--title: '姓名',--> | |
| 221 | + <!--key: 'name'--> | |
| 222 | + <!--},--> | |
| 223 | + <!--{--> | |
| 224 | + <!--title: '年龄',--> | |
| 225 | + <!--key: 'age'--> | |
| 226 | + <!--},--> | |
| 227 | + <!--{--> | |
| 228 | + <!--title: '地址',--> | |
| 229 | + <!--key: 'address'--> | |
| 230 | + <!--},--> | |
| 231 | + <!--{--> | |
| 232 | + <!--title: '姓名',--> | |
| 233 | + <!--key: 'name'--> | |
| 234 | + <!--},--> | |
| 235 | + <!--{--> | |
| 236 | + <!--title: '年龄',--> | |
| 237 | + <!--key: 'age'--> | |
| 238 | + <!--},--> | |
| 239 | + <!--{--> | |
| 240 | + <!--title: '地址',--> | |
| 241 | + <!--key: 'address'--> | |
| 242 | + <!--},--> | |
| 243 | + <!--{--> | |
| 244 | + <!--title: '姓名',--> | |
| 245 | + <!--key: 'name'--> | |
| 246 | + <!--},--> | |
| 247 | + <!--{--> | |
| 248 | + <!--title: '年龄',--> | |
| 249 | + <!--key: 'age'--> | |
| 250 | + <!--},--> | |
| 251 | + <!--{--> | |
| 252 | + <!--title: '地址',--> | |
| 253 | + <!--key: 'address'--> | |
| 254 | + <!--}--> | |
| 255 | + <!--],--> | |
| 256 | + <!--data1: [--> | |
| 257 | + <!--{--> | |
| 258 | + <!--name: '王小明',--> | |
| 259 | + <!--age: 18,--> | |
| 260 | + <!--address: '北京市朝阳区芍药居'--> | |
| 261 | + <!--},--> | |
| 262 | + <!--{--> | |
| 263 | + <!--name: '张小刚',--> | |
| 264 | + <!--age: 25,--> | |
| 265 | + <!--address: '北京市海淀区西二旗'--> | |
| 266 | + <!--},--> | |
| 267 | + <!--{--> | |
| 268 | + <!--name: '李小红',--> | |
| 269 | + <!--age: 30,--> | |
| 270 | + <!--address: '上海市浦东新区世纪大道'--> | |
| 271 | + <!--},--> | |
| 272 | + <!--{--> | |
| 273 | + <!--name: '周小伟',--> | |
| 274 | + <!--age: 26,--> | |
| 275 | + <!--address: '深圳市南山区深南大道'--> | |
| 276 | + <!--},--> | |
| 277 | + <!--{--> | |
| 278 | + <!--name: '王小明',--> | |
| 279 | + <!--age: 18,--> | |
| 280 | + <!--address: '北京市朝阳区芍药居'--> | |
| 281 | + <!--},--> | |
| 282 | + <!--{--> | |
| 283 | + <!--name: '张小刚',--> | |
| 284 | + <!--age: 25,--> | |
| 285 | + <!--address: '北京市海淀区西二旗'--> | |
| 286 | + <!--},--> | |
| 287 | + <!--{--> | |
| 288 | + <!--name: '李小红',--> | |
| 289 | + <!--age: 30,--> | |
| 290 | + <!--address: '上海市浦东新区世纪大道'--> | |
| 291 | + <!--},--> | |
| 292 | + <!--{--> | |
| 293 | + <!--name: '周小伟',--> | |
| 294 | + <!--age: 26,--> | |
| 295 | + <!--address: '深圳市南山区深南大道'--> | |
| 296 | + <!--},--> | |
| 297 | + <!--{--> | |
| 298 | + <!--name: '王小明',--> | |
| 299 | + <!--age: 18,--> | |
| 300 | + <!--address: '北京市朝阳区芍药居'--> | |
| 301 | + <!--},--> | |
| 302 | + <!--{--> | |
| 303 | + <!--name: '张小刚',--> | |
| 304 | + <!--age: 25,--> | |
| 305 | + <!--address: '北京市海淀区西二旗'--> | |
| 306 | + <!--},--> | |
| 307 | + <!--{--> | |
| 308 | + <!--name: '李小红',--> | |
| 309 | + <!--age: 30,--> | |
| 310 | + <!--address: '上海市浦东新区世纪大道'--> | |
| 311 | + <!--},--> | |
| 312 | + <!--{--> | |
| 313 | + <!--name: '周小伟',--> | |
| 314 | + <!--age: 26,--> | |
| 315 | + <!--address: '深圳市南山区深南大道'--> | |
| 316 | + <!--},--> | |
| 317 | + <!--{--> | |
| 318 | + <!--name: '王小明',--> | |
| 319 | + <!--age: 18,--> | |
| 320 | + <!--address: '北京市朝阳区芍药居'--> | |
| 321 | + <!--},--> | |
| 322 | + <!--{--> | |
| 323 | + <!--name: '张小刚',--> | |
| 324 | + <!--age: 25,--> | |
| 325 | + <!--address: '北京市海淀区西二旗'--> | |
| 326 | + <!--},--> | |
| 327 | + <!--{--> | |
| 328 | + <!--name: '李小红',--> | |
| 329 | + <!--age: 30,--> | |
| 330 | + <!--address: '上海市浦东新区世纪大道'--> | |
| 331 | + <!--},--> | |
| 332 | + <!--{--> | |
| 333 | + <!--name: '周小伟',--> | |
| 334 | + <!--age: 26,--> | |
| 335 | + <!--address: '深圳市南山区深南大道'--> | |
| 336 | + <!--}--> | |
| 337 | + <!--],--> | |
| 338 | + <!--columns2: [--> | |
| 339 | + <!--{--> | |
| 340 | + <!--title: '姓名',--> | |
| 341 | + <!--key: 'name'--> | |
| 342 | + <!--},--> | |
| 343 | + <!--{--> | |
| 344 | + <!--title: '年龄',--> | |
| 345 | + <!--key: 'age'--> | |
| 346 | + <!--},--> | |
| 347 | + <!--{--> | |
| 348 | + <!--title: '地址',--> | |
| 349 | + <!--key: 'address',--> | |
| 350 | + <!--render: (h) => {--> | |
| 351 | + <!--return h('Button', {--> | |
| 352 | + <!--nativeOn: {--> | |
| 353 | + <!--click: (event) => {--> | |
| 354 | + <!--console.log(2)--> | |
| 355 | + <!--event.stopPropagation();--> | |
| 356 | + <!--}--> | |
| 357 | + <!--}--> | |
| 358 | + <!--}, 'click')--> | |
| 359 | + <!--}--> | |
| 360 | + <!--}--> | |
| 361 | + <!--],--> | |
| 362 | + <!--data2: [--> | |
| 363 | + <!--{--> | |
| 364 | + <!--name: '王小明',--> | |
| 365 | + <!--age: 18,--> | |
| 366 | + <!--address: '北京市朝\n阳区芍药居'--> | |
| 367 | + <!--},--> | |
| 368 | + <!--{--> | |
| 369 | + <!--name: '张小刚',--> | |
| 370 | + <!--age: 25,--> | |
| 371 | + <!--address: '北京市海,淀区西二旗'--> | |
| 372 | + <!--},--> | |
| 373 | + <!--{--> | |
| 374 | + <!--name: '李小红',--> | |
| 375 | + <!--age: 30,--> | |
| 376 | + <!--address: '上海市浦东\r新区世纪大道'--> | |
| 377 | + <!--},--> | |
| 378 | + <!--{--> | |
| 379 | + <!--name: '周小伟',--> | |
| 380 | + <!--age: 26,--> | |
| 381 | + <!--address: '深圳市南山区深南大道'--> | |
| 382 | + <!--}--> | |
| 383 | + <!--]--> | |
| 384 | + <!--};--> | |
| 385 | + <!--},--> | |
| 386 | + <!--computed: {--> | |
| 387 | + <!--iconSize () {--> | |
| 388 | + <!--return this.spanLeft === 5 ? 14 : 24;--> | |
| 389 | + <!--}--> | |
| 390 | + <!--},--> | |
| 391 | + <!--methods: {--> | |
| 392 | + <!--toggleClick () {--> | |
| 393 | + <!--if (this.spanLeft === 5) {--> | |
| 394 | + <!--this.spanLeft = 2;--> | |
| 395 | + <!--this.spanRight = 22;--> | |
| 396 | + <!--} else {--> | |
| 397 | + <!--this.spanLeft = 5;--> | |
| 398 | + <!--this.spanRight = 19;--> | |
| 399 | + <!--}--> | |
| 400 | + <!--},--> | |
| 401 | + <!--exportCSV () {--> | |
| 402 | + <!--this.$refs.csvTable.exportCsv({--> | |
| 403 | + <!--filename: '原始数据',--> | |
| 404 | + <!--separator: ';',--> | |
| 405 | + <!--quoted: true--> | |
| 406 | + <!--});--> | |
| 407 | + <!--},--> | |
| 408 | + <!--cc () {--> | |
| 409 | + <!--console.log(1)--> | |
| 410 | + <!--}--> | |
| 411 | + <!--}--> | |
| 412 | + <!--};--> | |
| 413 | +<!--</script>--> | |
| 414 | + | |
| 163 | 415 | <template> |
| 164 | - <div class="layout" :class="{'layout-hide-text': spanLeft < 5}"> | |
| 165 | - <Row type="flex"> | |
| 166 | - <Col :span="spanLeft" class="layout-menu-left"> | |
| 167 | - <Menu active-name="1" theme="dark" width="auto"> | |
| 168 | - <div class="layout-logo-left"></div> | |
| 169 | - <MenuItem name="1"> | |
| 170 | - <Icon type="ios-navigate" :size="iconSize"></Icon> | |
| 171 | - <span class="layout-text">选项 1</span> | |
| 172 | - </MenuItem> | |
| 173 | - <MenuItem name="2"> | |
| 174 | - <Icon type="ios-keypad" :size="iconSize"></Icon> | |
| 175 | - <span class="layout-text">选项 2</span> | |
| 176 | - </MenuItem> | |
| 177 | - <MenuItem name="3"> | |
| 178 | - <Icon type="ios-analytics" :size="iconSize"></Icon> | |
| 179 | - <span class="layout-text">选项 3</span> | |
| 180 | - </MenuItem> | |
| 181 | - </Menu> | |
| 182 | - </Col> | |
| 183 | - <Col :span="spanRight"> | |
| 184 | - <div class="layout-header"> | |
| 185 | - <Button type="text" @click="toggleClick"> | |
| 186 | - <Icon type="navicon" size="32"></Icon> | |
| 187 | - </Button> | |
| 188 | - </div> | |
| 189 | - <div class="layout-breadcrumb"> | |
| 190 | - <Breadcrumb> | |
| 191 | - <BreadcrumbItem href="#">首页</BreadcrumbItem> | |
| 192 | - <BreadcrumbItem href="#">应用中心</BreadcrumbItem> | |
| 193 | - <BreadcrumbItem>某应用</BreadcrumbItem> | |
| 194 | - </Breadcrumb> | |
| 195 | - </div> | |
| 196 | - <div class="layout-content"> | |
| 197 | - <div class="layout-content-main"> | |
| 198 | - <Table stripe :columns="columns1" :data="data1"></Table> | |
| 199 | - </div> | |
| 200 | - <hr style="margin: 10px 0;" /> | |
| 201 | - <div class="layout-content-main"> | |
| 202 | - <Table stripe :columns="columns2" :data="data2" ref="csvTable" /> | |
| 203 | - <i-button type="primary" size="large" @click="exportCSV"> | |
| 204 | - <icon type="ios-download-outline"></icon> Export to CSV | |
| 205 | - </i-button> | |
| 206 | - </div> | |
| 207 | - </div> | |
| 208 | - </Col> | |
| 209 | - </Row> | |
| 210 | - </div> | |
| 416 | + <Table border :columns="columns6" :data="data5" @on-filter-change="cc"></Table> | |
| 211 | 417 | </template> |
| 212 | 418 | <script> |
| 213 | 419 | export default { |
| 214 | 420 | data () { |
| 215 | 421 | return { |
| 216 | - spanLeft: 5, | |
| 217 | - spanRight: 19, | |
| 218 | - columns1: [ | |
| 219 | - { | |
| 220 | - title: '姓名', | |
| 221 | - key: 'name' | |
| 222 | - }, | |
| 223 | - { | |
| 224 | - title: '年龄', | |
| 225 | - key: 'age' | |
| 226 | - }, | |
| 227 | - { | |
| 228 | - title: '地址', | |
| 229 | - key: 'address' | |
| 230 | - }, | |
| 231 | - { | |
| 232 | - title: '姓名', | |
| 233 | - key: 'name' | |
| 234 | - }, | |
| 235 | - { | |
| 236 | - title: '年龄', | |
| 237 | - key: 'age' | |
| 238 | - }, | |
| 239 | - { | |
| 240 | - title: '地址', | |
| 241 | - key: 'address' | |
| 242 | - }, | |
| 243 | - { | |
| 244 | - title: '姓名', | |
| 245 | - key: 'name' | |
| 246 | - }, | |
| 247 | - { | |
| 248 | - title: '年龄', | |
| 249 | - key: 'age' | |
| 250 | - }, | |
| 422 | + columns6: [ | |
| 251 | 423 | { |
| 252 | - title: '地址', | |
| 253 | - key: 'address' | |
| 254 | - } | |
| 255 | - ], | |
| 256 | - data1: [ | |
| 257 | - { | |
| 258 | - name: '王小明', | |
| 259 | - age: 18, | |
| 260 | - address: '北京市朝阳区芍药居' | |
| 261 | - }, | |
| 262 | - { | |
| 263 | - name: '张小刚', | |
| 264 | - age: 25, | |
| 265 | - address: '北京市海淀区西二旗' | |
| 266 | - }, | |
| 267 | - { | |
| 268 | - name: '李小红', | |
| 269 | - age: 30, | |
| 270 | - address: '上海市浦东新区世纪大道' | |
| 271 | - }, | |
| 272 | - { | |
| 273 | - name: '周小伟', | |
| 274 | - age: 26, | |
| 275 | - address: '深圳市南山区深南大道' | |
| 424 | + title: '日期', | |
| 425 | + key: 'date' | |
| 276 | 426 | }, |
| 277 | 427 | { |
| 278 | - name: '王小明', | |
| 279 | - age: 18, | |
| 280 | - address: '北京市朝阳区芍药居' | |
| 281 | - }, | |
| 282 | - { | |
| 283 | - name: '张小刚', | |
| 284 | - age: 25, | |
| 285 | - address: '北京市海淀区西二旗' | |
| 286 | - }, | |
| 287 | - { | |
| 288 | - name: '李小红', | |
| 289 | - age: 30, | |
| 290 | - address: '上海市浦东新区世纪大道' | |
| 291 | - }, | |
| 292 | - { | |
| 293 | - name: '周小伟', | |
| 294 | - age: 26, | |
| 295 | - address: '深圳市南山区深南大道' | |
| 296 | - }, | |
| 297 | - { | |
| 298 | - name: '王小明', | |
| 299 | - age: 18, | |
| 300 | - address: '北京市朝阳区芍药居' | |
| 301 | - }, | |
| 302 | - { | |
| 303 | - name: '张小刚', | |
| 304 | - age: 25, | |
| 305 | - address: '北京市海淀区西二旗' | |
| 306 | - }, | |
| 307 | - { | |
| 308 | - name: '李小红', | |
| 309 | - age: 30, | |
| 310 | - address: '上海市浦东新区世纪大道' | |
| 311 | - }, | |
| 312 | - { | |
| 313 | - name: '周小伟', | |
| 314 | - age: 26, | |
| 315 | - address: '深圳市南山区深南大道' | |
| 316 | - }, | |
| 317 | - { | |
| 318 | - name: '王小明', | |
| 319 | - age: 18, | |
| 320 | - address: '北京市朝阳区芍药居' | |
| 321 | - }, | |
| 322 | - { | |
| 323 | - name: '张小刚', | |
| 324 | - age: 25, | |
| 325 | - address: '北京市海淀区西二旗' | |
| 326 | - }, | |
| 327 | - { | |
| 328 | - name: '李小红', | |
| 329 | - age: 30, | |
| 330 | - address: '上海市浦东新区世纪大道' | |
| 331 | - }, | |
| 332 | - { | |
| 333 | - name: '周小伟', | |
| 334 | - age: 26, | |
| 335 | - address: '深圳市南山区深南大道' | |
| 336 | - } | |
| 337 | - ], | |
| 338 | - columns2: [ | |
| 339 | - { | |
| 340 | 428 | title: '姓名', |
| 341 | 429 | key: 'name' |
| 342 | 430 | }, |
| 343 | 431 | { |
| 344 | 432 | title: '年龄', |
| 345 | - key: 'age' | |
| 433 | + key: 'age', | |
| 434 | + filters: [ | |
| 435 | + { | |
| 436 | + label: '大于25岁', | |
| 437 | + value: 1 | |
| 438 | + }, | |
| 439 | + { | |
| 440 | + label: '小于25岁', | |
| 441 | + value: 2 | |
| 442 | + } | |
| 443 | + ], | |
| 444 | + filterMultiple: false, | |
| 445 | + filterMethod (value, row) { | |
| 446 | + if (value === 1) { | |
| 447 | + return row.age > 25; | |
| 448 | + } else if (value === 2) { | |
| 449 | + return row.age < 25; | |
| 450 | + } | |
| 451 | + } | |
| 346 | 452 | }, |
| 347 | 453 | { |
| 348 | 454 | title: '地址', |
| 349 | - key: 'address' | |
| 455 | + key: 'address', | |
| 456 | + filters: [ | |
| 457 | + { | |
| 458 | + label: '北京', | |
| 459 | + value: '北京' | |
| 460 | + }, | |
| 461 | + { | |
| 462 | + label: '上海', | |
| 463 | + value: '上海' | |
| 464 | + }, | |
| 465 | + { | |
| 466 | + label: '深圳', | |
| 467 | + value: '深圳' | |
| 468 | + } | |
| 469 | + ], | |
| 470 | + filterMethod (value, row) { | |
| 471 | + return row.address.indexOf(value) > -1; | |
| 472 | + } | |
| 350 | 473 | } |
| 351 | 474 | ], |
| 352 | - data2: [ | |
| 475 | + data5: [ | |
| 353 | 476 | { |
| 354 | 477 | name: '王小明', |
| 355 | 478 | age: 18, |
| 356 | - address: '北京市朝\n阳区芍药居' | |
| 479 | + address: '北京市朝阳区芍药居', | |
| 480 | + date: '2016-10-03' | |
| 357 | 481 | }, |
| 358 | 482 | { |
| 359 | 483 | name: '张小刚', |
| 360 | 484 | age: 25, |
| 361 | - address: '北京市海,淀区西二旗' | |
| 485 | + address: '北京市海淀区西二旗', | |
| 486 | + date: '2016-10-01' | |
| 362 | 487 | }, |
| 363 | 488 | { |
| 364 | 489 | name: '李小红', |
| 365 | 490 | age: 30, |
| 366 | - address: '上海市浦东\r新区世纪大道' | |
| 491 | + address: '上海市浦东新区世纪大道', | |
| 492 | + date: '2016-10-02' | |
| 367 | 493 | }, |
| 368 | 494 | { |
| 369 | 495 | name: '周小伟', |
| 370 | 496 | age: 26, |
| 371 | - address: '深圳市南山区深南大道' | |
| 497 | + address: '深圳市南山区深南大道', | |
| 498 | + date: '2016-10-04' | |
| 372 | 499 | } |
| 373 | 500 | ] |
| 374 | - }; | |
| 375 | - }, | |
| 376 | - computed: { | |
| 377 | - iconSize () { | |
| 378 | - return this.spanLeft === 5 ? 14 : 24; | |
| 379 | 501 | } |
| 380 | 502 | }, |
| 381 | 503 | methods: { |
| 382 | - toggleClick () { | |
| 383 | - if (this.spanLeft === 5) { | |
| 384 | - this.spanLeft = 2; | |
| 385 | - this.spanRight = 22; | |
| 386 | - } else { | |
| 387 | - this.spanLeft = 5; | |
| 388 | - this.spanRight = 19; | |
| 389 | - } | |
| 390 | - }, | |
| 391 | - exportCSV () { | |
| 392 | - this.$refs.csvTable.exportCsv({ | |
| 393 | - filename: '原始数据', | |
| 394 | - separator: ';', | |
| 395 | - quoted: true | |
| 396 | - }); | |
| 504 | + cc (dd) { | |
| 505 | + console.log(dd); | |
| 397 | 506 | } |
| 398 | 507 | } |
| 399 | - }; | |
| 508 | + } | |
| 400 | 509 | </script> | ... | ... |
src/components/table/table.vue
| ... | ... | @@ -574,6 +574,7 @@ |
| 574 | 574 | |
| 575 | 575 | this.cloneColumns[index]._isFiltered = true; |
| 576 | 576 | this.cloneColumns[index]._filterVisible = false; |
| 577 | + this.$emit('on-filter-change', column); | |
| 577 | 578 | }, |
| 578 | 579 | handleFilterSelect (index, value) { |
| 579 | 580 | this.cloneColumns[index]._filterChecked = [value]; |
| ... | ... | @@ -587,6 +588,7 @@ |
| 587 | 588 | let filterData = this.makeDataWithSort(); |
| 588 | 589 | filterData = this.filterOtherData(filterData, index); |
| 589 | 590 | this.rebuildData = filterData; |
| 591 | + this.$emit('on-filter-change', this.cloneColumns[index]); | |
| 590 | 592 | }, |
| 591 | 593 | makeData () { |
| 592 | 594 | let data = deepCopy(this.data); | ... | ... |