| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- <template lang="html">
- <div id="example">
- <ul class="switch-list">
- <li class="switch-item" v-for="item in propList">
- <span>{{ item.name }}: </span>
- <zk-switch v-model="props[item.name]"></zk-switch>
- </li>
- </ul>
- <tree-table
- ref="table"
- sum-text="sum"
- index-text="#"
- :data="data"
- :columns="columns"
- :stripe="props.stripe"
- :border="props.border"
- :show-header="props.showHeader"
- :show-summary="props.showSummary"
- :show-row-hover="props.showRowHover"
- :show-index="props.showIndex"
- :tree-type="props.treeType"
- select-type="radio"
- :is-fold="props.isFold"
- :expand-type="props.expandType"
- expand-key="sex"
- @radio-click="handleRadioClick"
- :selection-type="props.selectable">
- <!-- <tree-table
- :columns="columns"
- :expand-type="false"
- :selection-type="false"
- :data="data"> -->
- <template slot="$expand" slot-scope="scope">
- {{ `My name is ${scope.row.name},
- this rowIndex is ${scope.rowIndex}.`
- }}
- </template>
- <template slot="likes" slot-scope="scope">
- <button>123</button>
- </template>
- </tree-table>
- </div>
- </template>
- <script>
- import ZkSwitch from './Switch/Switch';
- export default {
- name: 'example',
- components: {
- ZkSwitch,
- },
- data() {
- return {
- props: {
- stripe: false,
- border: false,
- showHeader: true,
- showSummary: false,
- showRowHover: true,
- showIndex: false,
- treeType: true,
- isFold: true,
- expandType: false,
- selectable: false,
- },
- data: [
- {
- name: 'Jack',
- sex: 'male',
- likes: ['football', 'basketball'],
- score: 10,
- children: [
- {
- name: 'Ashley',
- sex: 'female',
- likes: ['football', 'basketball'],
- score: 20,
- children: [
- {
- name: 'Ashley',
- sex: 'female',
- likes: ['football', 'basketball'],
- score: 20,
- },
- {
- name: 'Taki',
- sex: 'male',
- likes: ['football', 'basketball'],
- score: 10,
- children: [
- {
- name: 'Ashley',
- sex: 'female',
- likes: ['football', 'basketball'],
- score: 20,
- },
- {
- name: 'Taki',
- sex: 'male',
- likes: ['football', 'basketball'],
- score: 10,
- children: [
- {
- name: 'Ashley',
- sex: 'female',
- likes: ['football', 'basketball'],
- score: 20,
- },
- {
- name: 'Taki',
- sex: 'male',
- likes: ['football', 'basketball'],
- score: 10,
- },
- ],
- },
- ],
- },
- ],
- },
- {
- name: 'Taki',
- sex: 'male',
- likes: ['football', 'basketball'],
- score: 10,
- },
- ],
- },
- {
- name: 'Tom',
- sex: 'male',
- likes: ['football', 'basketball'],
- score: 20,
- children: [
- {
- name: 'Ashley',
- sex: 'female',
- likes: ['football', 'basketball'],
- score: 20,
- children: [
- {
- name: 'Ashley',
- sex: 'female',
- likes: ['football', 'basketball'],
- score: 20,
- },
- {
- name: 'Taki',
- sex: 'male',
- likes: ['football', 'basketball'],
- score: 10,
- },
- ],
- },
- {
- name: 'Taki',
- sex: 'male',
- likes: ['football', 'basketball'],
- score: 10,
- children: [
- {
- name: 'Ashley',
- sex: 'female',
- likes: ['football', 'basketball'],
- score: 20,
- },
- {
- name: 'Taki',
- sex: 'male',
- likes: ['football', 'basketball'],
- score: 10,
- },
- ],
- },
- ],
- },
- {
- name: 'Tom',
- sex: 'male',
- likes: ['football', 'basketball'],
- score: 20,
- },
- {
- name: 'Tom',
- sex: 'male',
- likes: ['football', 'basketball'],
- score: 20,
- children: [
- {
- name: 'Ashley',
- sex: 'female',
- likes: ['football', 'basketball'],
- score: 20,
- },
- {
- name: 'Taki',
- sex: 'male',
- likes: ['football', 'basketball'],
- score: 10,
- },
- ],
- },
- ],
- columns: [
- {
- title: 'name',
- key: 'name',
- width: '400px',
- },
- {
- title: 'sex',
- key: 'sex',
- minWidth: '50px',
- },
- {
- title: 'score',
- key: 'score',
- },
- {
- title: 'likes',
- key: 'likes',
- minWidth: '200px',
- type: 'template',
- template: 'likes',
- },
- ],
- };
- },
- computed: {
- propList() {
- return Object.keys(this.props).map(item => ({
- name: item,
- }));
- },
- },
- methods: {
- handleRadioClick(option) {
- console.log(option); // eslint-disable-line
- },
- },
- };
- </script>
- <style scoped lang="less">
- * {
- margin: 0;
- padding: 0;
- }
- .switch-list {
- margin: 20px 0;
- list-style: none;
- overflow: hidden;
- }
- .switch-item {
- margin: 20px;
- float: left;
- }
- </style>
|