fixed some components bug that can not translate when using vue-i18n
This commit is contained in:
parent
ed91d9b0c7
commit
e5337c810c
8 changed files with 185 additions and 153 deletions
|
@ -1,40 +1,45 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<i-button @click.native="modal2 = true">自定义页头和页脚</i-button>
|
<Button @click="confirm">标准</Button>
|
||||||
<Modal v-model="modal2" width="360">
|
<Button @click="custom">自定义按钮文字</Button>
|
||||||
<p slot="header" style="color:#f60;text-align:center">
|
<Button @click="async">异步关闭</Button>
|
||||||
<Icon type="information-circled"></Icon>
|
|
||||||
<span>删除确认</span>
|
|
||||||
</p>
|
|
||||||
<div style="text-align:center">
|
|
||||||
<p>此任务删除后,下游 10 个任务将无法执行。</p>
|
|
||||||
<p>是否继续删除?</p>
|
|
||||||
</div>
|
|
||||||
<div slot="footer">
|
|
||||||
<i-button type="error" size="large" long :loading="modal_loading" @click.native="del">删除</i-button>
|
|
||||||
</div>
|
|
||||||
</Modal>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
modal2: false,
|
|
||||||
modal_loading: false,
|
|
||||||
modal3: false,
|
|
||||||
modal4: false,
|
|
||||||
modal5: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
del () {
|
confirm () {
|
||||||
this.modal_loading = true;
|
this.$Modal.confirm({
|
||||||
setTimeout(() => {
|
title: '确认对话框标题',
|
||||||
this.modal_loading = false;
|
content: '<p>一些对话框内容</p><p>一些对话框内容</p>',
|
||||||
this.modal2 = false;
|
onOk: () => {
|
||||||
this.$Message.success('删除成功');
|
this.$Message.info('点击了确定');
|
||||||
}, 2000);
|
},
|
||||||
|
onCancel: () => {
|
||||||
|
this.$Message.info('点击了取消');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
custom () {
|
||||||
|
this.$Modal.confirm({
|
||||||
|
title: '确认对话框标题',
|
||||||
|
content: '<p>一些对话框内容</p><p>一些对话框内容</p>',
|
||||||
|
okText: 'OK',
|
||||||
|
cancelText: 'Cancel'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
async () {
|
||||||
|
this.$Modal.confirm({
|
||||||
|
title: '确认对话框标题',
|
||||||
|
content: '<p>对话框将在 2秒 后关闭</p>',
|
||||||
|
loading: true,
|
||||||
|
onOk: () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$Modal.remove();
|
||||||
|
this.$Message.info('异步关闭了对话框');
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import Modal from './modal.vue';
|
||||||
import Icon from '../icon/icon.vue';
|
import Icon from '../icon/icon.vue';
|
||||||
import iButton from '../button/button.vue';
|
import iButton from '../button/button.vue';
|
||||||
import { camelcaseToHyphen } from '../../utils/assist';
|
import { camelcaseToHyphen } from '../../utils/assist';
|
||||||
import { t } from '../../locale';
|
import Locale from '../../mixins/locale';
|
||||||
|
|
||||||
const prefixCls = 'ivu-modal-confirm';
|
const prefixCls = 'ivu-modal-confirm';
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ Modal.newInstance = properties => {
|
||||||
<div v-html="body"></div>
|
<div v-html="body"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="${prefixCls}-footer">
|
<div class="${prefixCls}-footer">
|
||||||
<i-button type="text" size="large" v-if="showCancel" @click.native="cancel">{{ cancelText }}</i-button>
|
<i-button type="text" size="large" v-if="showCancel" @click.native="cancel">{{ localeCancelText }}</i-button>
|
||||||
<i-button type="primary" size="large" :loading="buttonLoading" @click.native="ok">{{ okText }}</i-button>
|
<i-button type="primary" size="large" :loading="buttonLoading" @click.native="ok">{{ localeOkText }}</i-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
@ -37,6 +37,7 @@ Modal.newInstance = properties => {
|
||||||
|
|
||||||
const modal = new Vue({
|
const modal = new Vue({
|
||||||
el: div,
|
el: div,
|
||||||
|
mixins: [ Locale ],
|
||||||
components: { Modal, iButton, Icon },
|
components: { Modal, iButton, Icon },
|
||||||
data: Object.assign(_props, {
|
data: Object.assign(_props, {
|
||||||
visible: false,
|
visible: false,
|
||||||
|
@ -45,8 +46,8 @@ Modal.newInstance = properties => {
|
||||||
body: '',
|
body: '',
|
||||||
iconType: '',
|
iconType: '',
|
||||||
iconName: '',
|
iconName: '',
|
||||||
okText: t('i.modal.okText'),
|
okText: undefined,
|
||||||
cancelText: t('i.modal.cancelText'),
|
cancelText: undefined,
|
||||||
showCancel: false,
|
showCancel: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
buttonLoading: false,
|
buttonLoading: false,
|
||||||
|
@ -64,6 +65,20 @@ Modal.newInstance = properties => {
|
||||||
'ivu-icon',
|
'ivu-icon',
|
||||||
`ivu-icon-${this.iconName}`
|
`ivu-icon-${this.iconName}`
|
||||||
];
|
];
|
||||||
|
},
|
||||||
|
localeOkText () {
|
||||||
|
if (this.okText) {
|
||||||
|
return this.okText;
|
||||||
|
} else {
|
||||||
|
return this.t('i.modal.okText');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
localeCancelText () {
|
||||||
|
if (this.cancelText) {
|
||||||
|
return this.cancelText;
|
||||||
|
} else {
|
||||||
|
return this.t('i.modal.cancelText');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
<div :class="[prefixCls + '-body']"><slot></slot></div>
|
<div :class="[prefixCls + '-body']"><slot></slot></div>
|
||||||
<div :class="[prefixCls + '-footer']" v-if="!footerHide">
|
<div :class="[prefixCls + '-footer']" v-if="!footerHide">
|
||||||
<slot name="footer">
|
<slot name="footer">
|
||||||
<i-button type="text" size="large" @click.native="cancel">{{ cancelText }}</i-button>
|
<i-button type="text" size="large" @click.native="cancel">{{ localeCancelText }}</i-button>
|
||||||
<i-button type="primary" size="large" :loading="buttonLoading" @click.native="ok">{{ okText }}</i-button>
|
<i-button type="primary" size="large" :loading="buttonLoading" @click.native="ok">{{ localeOkText }}</i-button>
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -30,11 +30,13 @@
|
||||||
import Icon from '../icon';
|
import Icon from '../icon';
|
||||||
import iButton from '../button/button.vue';
|
import iButton from '../button/button.vue';
|
||||||
import { getScrollBarSize } from '../../utils/assist';
|
import { getScrollBarSize } from '../../utils/assist';
|
||||||
import { t } from '../../locale';
|
import Locale from '../../mixins/locale';
|
||||||
|
|
||||||
const prefixCls = 'ivu-modal';
|
const prefixCls = 'ivu-modal';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
name: 'Modal',
|
||||||
|
mixins: [ Locale ],
|
||||||
components: { Icon, iButton },
|
components: { Icon, iButton },
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
|
@ -57,16 +59,10 @@
|
||||||
default: 520
|
default: 520
|
||||||
},
|
},
|
||||||
okText: {
|
okText: {
|
||||||
type: String,
|
type: String
|
||||||
default () {
|
|
||||||
return t('i.modal.okText');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
cancelText: {
|
cancelText: {
|
||||||
type: String,
|
type: String
|
||||||
default () {
|
|
||||||
return t('i.modal.cancelText');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
loading: {
|
loading: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -125,6 +121,20 @@
|
||||||
Object.assign(style, styleWidth, customStyle);
|
Object.assign(style, styleWidth, customStyle);
|
||||||
|
|
||||||
return style;
|
return style;
|
||||||
|
},
|
||||||
|
localeOkText () {
|
||||||
|
if (this.okText === undefined) {
|
||||||
|
return this.t('i.modal.okText');
|
||||||
|
} else {
|
||||||
|
return this.okText;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
localeCancelText () {
|
||||||
|
if (this.cancelText === undefined) {
|
||||||
|
return this.t('i.modal.cancelText');
|
||||||
|
} else {
|
||||||
|
return this.cancelText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
<div :class="[prefixCls + '-body-message']"><slot name="title">{{ title }}</slot></div>
|
<div :class="[prefixCls + '-body-message']"><slot name="title">{{ title }}</slot></div>
|
||||||
</div>
|
</div>
|
||||||
<div :class="[prefixCls + '-footer']">
|
<div :class="[prefixCls + '-footer']">
|
||||||
<i-button type="text" size="small" @click.native="cancel">{{ cancelText }}</i-button>
|
<i-button type="text" size="small" @click.native="cancel">{{ localeCancelText }}</i-button>
|
||||||
<i-button type="primary" size="small" @click.native="ok">{{ okText }}</i-button>
|
<i-button type="primary" size="small" @click.native="ok">{{ localeOkText }}</i-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div :class="[prefixCls + '-inner']" v-if="!confirm">
|
<div :class="[prefixCls + '-inner']" v-if="!confirm">
|
||||||
|
@ -42,13 +42,13 @@
|
||||||
import iButton from '../button/button.vue';
|
import iButton from '../button/button.vue';
|
||||||
import clickoutside from '../../directives/clickoutside';
|
import clickoutside from '../../directives/clickoutside';
|
||||||
import { oneOf } from '../../utils/assist';
|
import { oneOf } from '../../utils/assist';
|
||||||
import { t } from '../../locale';
|
import Locale from '../../mixins/locale';
|
||||||
|
|
||||||
const prefixCls = 'ivu-poptip';
|
const prefixCls = 'ivu-poptip';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Poptip',
|
name: 'Poptip',
|
||||||
mixins: [Popper],
|
mixins: [ Popper, Locale ],
|
||||||
directives: { clickoutside },
|
directives: { clickoutside },
|
||||||
components: { iButton },
|
components: { iButton },
|
||||||
props: {
|
props: {
|
||||||
|
@ -79,16 +79,10 @@
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
okText: {
|
okText: {
|
||||||
type: String,
|
type: String
|
||||||
default () {
|
|
||||||
return t('i.poptip.okText');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
cancelText: {
|
cancelText: {
|
||||||
type: String,
|
type: String
|
||||||
default () {
|
|
||||||
return t('i.poptip.cancelText');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
|
@ -114,6 +108,20 @@
|
||||||
style.width = `${this.width}px`;
|
style.width = `${this.width}px`;
|
||||||
}
|
}
|
||||||
return style;
|
return style;
|
||||||
|
},
|
||||||
|
localeOkText () {
|
||||||
|
if (this.okText === undefined) {
|
||||||
|
return this.t('i.poptip.okText');
|
||||||
|
} else {
|
||||||
|
return this.okText;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
localeCancelText () {
|
||||||
|
if (this.cancelText === undefined) {
|
||||||
|
return this.t('i.poptip.cancelText');
|
||||||
|
} else {
|
||||||
|
return this.cancelText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -8,14 +8,14 @@
|
||||||
<span class="ivu-tag-text">{{ item.label }}</span>
|
<span class="ivu-tag-text">{{ item.label }}</span>
|
||||||
<Icon type="ios-close-empty" @click.native.stop="removeTag(index)"></Icon>
|
<Icon type="ios-close-empty" @click.native.stop="removeTag(index)"></Icon>
|
||||||
</div>
|
</div>
|
||||||
<span :class="[prefixCls + '-placeholder']" v-show="showPlaceholder && !filterable">{{ placeholder }}</span>
|
<span :class="[prefixCls + '-placeholder']" v-show="showPlaceholder && !filterable">{{ localePlaceholder }}</span>
|
||||||
<span :class="[prefixCls + '-selected-value']" v-show="!showPlaceholder && !multiple && !filterable">{{ selectedSingle }}</span>
|
<span :class="[prefixCls + '-selected-value']" v-show="!showPlaceholder && !multiple && !filterable">{{ selectedSingle }}</span>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
v-if="filterable"
|
v-if="filterable"
|
||||||
v-model="query"
|
v-model="query"
|
||||||
:class="[prefixCls + '-input']"
|
:class="[prefixCls + '-input']"
|
||||||
:placeholder="showPlaceholder ? placeholder : ''"
|
:placeholder="showPlaceholder ? localePlaceholder : ''"
|
||||||
:style="inputStyle"
|
:style="inputStyle"
|
||||||
@blur="handleBlur"
|
@blur="handleBlur"
|
||||||
@keydown="resetInputState"
|
@keydown="resetInputState"
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
</div>
|
</div>
|
||||||
<transition name="slide-up">
|
<transition name="slide-up">
|
||||||
<Drop v-show="visible" ref="dropdown">
|
<Drop v-show="visible" ref="dropdown">
|
||||||
<ul v-show="notFound" :class="[prefixCls + '-not-found']"><li>{{ notFoundText }}</li></ul>
|
<ul v-show="notFound" :class="[prefixCls + '-not-found']"><li>{{ localeNotFoundText }}</li></ul>
|
||||||
<ul v-show="!notFound" :class="[prefixCls + '-dropdown-list']" ref="options"><slot></slot></ul>
|
<ul v-show="!notFound" :class="[prefixCls + '-dropdown-list']" ref="options"><slot></slot></ul>
|
||||||
</Drop>
|
</Drop>
|
||||||
</transition>
|
</transition>
|
||||||
|
@ -37,14 +37,14 @@
|
||||||
import Drop from './dropdown.vue';
|
import Drop from './dropdown.vue';
|
||||||
import clickoutside from '../../directives/clickoutside';
|
import clickoutside from '../../directives/clickoutside';
|
||||||
import { oneOf, findComponentDownward } from '../../utils/assist';
|
import { oneOf, findComponentDownward } from '../../utils/assist';
|
||||||
import { t } from '../../locale';
|
|
||||||
import Emitter from '../../mixins/emitter';
|
import Emitter from '../../mixins/emitter';
|
||||||
|
import Locale from '../../mixins/locale';
|
||||||
|
|
||||||
const prefixCls = 'ivu-select';
|
const prefixCls = 'ivu-select';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'iSelect',
|
name: 'iSelect',
|
||||||
mixins: [ Emitter ],
|
mixins: [ Emitter, Locale ],
|
||||||
components: { Icon, Drop },
|
components: { Icon, Drop },
|
||||||
directives: { clickoutside },
|
directives: { clickoutside },
|
||||||
props: {
|
props: {
|
||||||
|
@ -65,10 +65,7 @@
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
placeholder: {
|
placeholder: {
|
||||||
type: String,
|
type: String
|
||||||
default () {
|
|
||||||
return t('i.select.placeholder');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
filterable: {
|
filterable: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -87,10 +84,7 @@
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
notFoundText: {
|
notFoundText: {
|
||||||
type: String,
|
type: String
|
||||||
default () {
|
|
||||||
return t('i.select.noMatch');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
|
@ -153,6 +147,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return style;
|
return style;
|
||||||
|
},
|
||||||
|
localePlaceholder () {
|
||||||
|
if (this.placeholder === undefined) {
|
||||||
|
return this.t('i.select.placeholder');
|
||||||
|
} else {
|
||||||
|
return this.placeholder;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
localeNotFoundText () {
|
||||||
|
if (this.notFoundText === undefined) {
|
||||||
|
return this.t('i.select.noMatch');
|
||||||
|
} else {
|
||||||
|
return this.notFoundText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
:data="rebuildData"></table-head>
|
:data="rebuildData"></table-head>
|
||||||
</div>
|
</div>
|
||||||
<div :class="[prefixCls + '-body']" :style="bodyStyle" ref="body" @scroll="handleBodyScroll"
|
<div :class="[prefixCls + '-body']" :style="bodyStyle" ref="body" @scroll="handleBodyScroll"
|
||||||
v-show="!((!!noDataText && (!data || data.length === 0)) || (!!noFilteredDataText && (!rebuildData || rebuildData.length === 0)))">
|
v-show="!((!!localeNoDataText && (!data || data.length === 0)) || (!!localeNoFilteredDataText && (!rebuildData || rebuildData.length === 0)))">
|
||||||
<table-body
|
<table-body
|
||||||
ref="tbody"
|
ref="tbody"
|
||||||
:prefix-cls="prefixCls"
|
:prefix-cls="prefixCls"
|
||||||
|
@ -24,13 +24,13 @@
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
:class="[prefixCls + '-tip']"
|
:class="[prefixCls + '-tip']"
|
||||||
v-show="((!!noDataText && (!data || data.length === 0)) || (!!noFilteredDataText && (!rebuildData || rebuildData.length === 0)))">
|
v-show="((!!localeNoDataText && (!data || data.length === 0)) || (!!localeNoFilteredDataText && (!rebuildData || rebuildData.length === 0)))">
|
||||||
<table cellspacing="0" cellpadding="0" border="0">
|
<table cellspacing="0" cellpadding="0" border="0">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td :style="{ 'height': bodyStyle.height }">
|
<td :style="{ 'height': bodyStyle.height }">
|
||||||
<span v-html="noDataText" v-if="!data || data.length === 0"></span>
|
<span v-html="localeNoDataText" v-if="!data || data.length === 0"></span>
|
||||||
<span v-html="noFilteredDataText" v-else></span>
|
<span v-html="localeNoFilteredDataText" v-else></span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -88,13 +88,15 @@
|
||||||
import tableHead from './table-head.vue';
|
import tableHead from './table-head.vue';
|
||||||
import tableBody from './table-body.vue';
|
import tableBody from './table-body.vue';
|
||||||
import { oneOf, getStyle, deepCopy, getScrollBarSize } from '../../utils/assist';
|
import { oneOf, getStyle, deepCopy, getScrollBarSize } from '../../utils/assist';
|
||||||
import { t } from '../../locale';
|
|
||||||
import Csv from '../../utils/csv';
|
import Csv from '../../utils/csv';
|
||||||
import ExportCsv from './export-csv';
|
import ExportCsv from './export-csv';
|
||||||
|
import Locale from '../../mixins/locale';
|
||||||
|
|
||||||
const prefixCls = 'ivu-table';
|
const prefixCls = 'ivu-table';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Table',
|
name: 'Table',
|
||||||
|
mixins: [ Locale ],
|
||||||
components: { tableHead, tableBody },
|
components: { tableHead, tableBody },
|
||||||
props: {
|
props: {
|
||||||
data: {
|
data: {
|
||||||
|
@ -146,16 +148,10 @@
|
||||||
type: Object
|
type: Object
|
||||||
},
|
},
|
||||||
noDataText: {
|
noDataText: {
|
||||||
type: String,
|
type: String
|
||||||
default () {
|
|
||||||
return t('i.table.noDataText');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
noFilteredDataText: {
|
noFilteredDataText: {
|
||||||
type: String,
|
type: String
|
||||||
default () {
|
|
||||||
return t('i.table.noFilteredDataText');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
|
@ -178,6 +174,20 @@
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
localeNoDataText () {
|
||||||
|
if (this.noDataText === undefined) {
|
||||||
|
return this.t('i.table.noDataText');
|
||||||
|
} else {
|
||||||
|
return this.noDataText;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
localeNoFilteredDataText () {
|
||||||
|
if (this.noFilteredDataText === undefined) {
|
||||||
|
return this.t('i.table.noFilteredDataText');
|
||||||
|
} else {
|
||||||
|
return this.noFilteredDataText;
|
||||||
|
}
|
||||||
|
},
|
||||||
wrapClasses () {
|
wrapClasses () {
|
||||||
return [
|
return [
|
||||||
`${prefixCls}-wrapper`,
|
`${prefixCls}-wrapper`,
|
||||||
|
|
|
@ -1,55 +1,13 @@
|
||||||
<!-- <template>
|
|
||||||
<div :class="classes">
|
|
||||||
<List
|
|
||||||
ref="left"
|
|
||||||
:prefix-cls="prefixCls + '-list'"
|
|
||||||
:data="leftData"
|
|
||||||
:render-format="renderFormat"
|
|
||||||
:checked-keys="leftCheckedKeys"
|
|
||||||
@on-checked-keys-change="handleLeftCheckedKeysChange"
|
|
||||||
:valid-keys-count="leftValidKeysCount"
|
|
||||||
:style="listStyle"
|
|
||||||
:title="titles[0]"
|
|
||||||
:filterable="filterable"
|
|
||||||
:filter-placeholder="filterPlaceholder"
|
|
||||||
:filter-method="filterMethod"
|
|
||||||
:not-found-text="notFoundText">
|
|
||||||
<slot></slot>
|
|
||||||
</List>
|
|
||||||
<Operation
|
|
||||||
:prefix-cls="prefixCls"
|
|
||||||
:operations="operations"
|
|
||||||
:left-active="leftValidKeysCount > 0"
|
|
||||||
:right-active="rightValidKeysCount > 0">
|
|
||||||
</Operation>
|
|
||||||
<List
|
|
||||||
ref="right"
|
|
||||||
:prefix-cls="prefixCls + '-list'"
|
|
||||||
:data="rightData"
|
|
||||||
:render-format="renderFormat"
|
|
||||||
:checked-keys="rightCheckedKeys"
|
|
||||||
@on-checked-keys-change="handleRightCheckedKeysChange"
|
|
||||||
:valid-keys-count="rightValidKeysCount"
|
|
||||||
:style="listStyle"
|
|
||||||
:title="titles[1]"
|
|
||||||
:filterable="filterable"
|
|
||||||
:filter-placeholder="filterPlaceholder"
|
|
||||||
:filter-method="filterMethod"
|
|
||||||
:not-found-text="notFoundText">
|
|
||||||
<slot></slot>
|
|
||||||
</List>
|
|
||||||
</div>
|
|
||||||
</template> -->
|
|
||||||
<script>
|
<script>
|
||||||
import List from './list.vue';
|
import List from './list.vue';
|
||||||
import Operation from './operation.vue';
|
import Operation from './operation.vue';
|
||||||
import { t } from '../../locale';
|
import Locale from '../../mixins/locale';
|
||||||
import Emitter from '../../mixins/emitter';
|
import Emitter from '../../mixins/emitter';
|
||||||
|
|
||||||
const prefixCls = 'ivu-transfer';
|
const prefixCls = 'ivu-transfer';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [ Emitter ],
|
mixins: [ Emitter, Locale ],
|
||||||
render (createElement) {
|
render (createElement) {
|
||||||
|
|
||||||
function cloneVNode (vnode) {
|
function cloneVNode (vnode) {
|
||||||
|
@ -82,11 +40,11 @@
|
||||||
checkedKeys: this.leftCheckedKeys,
|
checkedKeys: this.leftCheckedKeys,
|
||||||
validKeysCount: this.leftValidKeysCount,
|
validKeysCount: this.leftValidKeysCount,
|
||||||
style: this.listStyle,
|
style: this.listStyle,
|
||||||
title: this.titles[0],
|
title: this.localeTitles[0],
|
||||||
filterable: this.filterable,
|
filterable: this.filterable,
|
||||||
filterPlaceholder: this.filterPlaceholder,
|
filterPlaceholder: this.localeFilterPlaceholder,
|
||||||
filterMethod: this.filterMethod,
|
filterMethod: this.filterMethod,
|
||||||
notFoundText: this.notFoundText
|
notFoundText: this.localeNotFoundText
|
||||||
},
|
},
|
||||||
on: {
|
on: {
|
||||||
'on-checked-keys-change': this.handleLeftCheckedKeysChange
|
'on-checked-keys-change': this.handleLeftCheckedKeysChange
|
||||||
|
@ -111,11 +69,11 @@
|
||||||
checkedKeys: this.rightCheckedKeys,
|
checkedKeys: this.rightCheckedKeys,
|
||||||
validKeysCount: this.rightValidKeysCount,
|
validKeysCount: this.rightValidKeysCount,
|
||||||
style: this.listStyle,
|
style: this.listStyle,
|
||||||
title: this.titles[1],
|
title: this.localeTitles[1],
|
||||||
filterable: this.filterable,
|
filterable: this.filterable,
|
||||||
filterPlaceholder: this.filterPlaceholder,
|
filterPlaceholder: this.localeFilterPlaceholder,
|
||||||
filterMethod: this.filterMethod,
|
filterMethod: this.filterMethod,
|
||||||
notFoundText: this.notFoundText
|
notFoundText: this.localeNotFoundText
|
||||||
},
|
},
|
||||||
on: {
|
on: {
|
||||||
'on-checked-keys-change': this.handleRightCheckedKeysChange
|
'on-checked-keys-change': this.handleRightCheckedKeysChange
|
||||||
|
@ -157,10 +115,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
titles: {
|
titles: {
|
||||||
type: Array,
|
type: Array
|
||||||
default () {
|
|
||||||
return [t('i.transfer.titles.source'), t('i.transfer.titles.target')];
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
operations: {
|
operations: {
|
||||||
type: Array,
|
type: Array,
|
||||||
|
@ -173,10 +128,7 @@
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
filterPlaceholder: {
|
filterPlaceholder: {
|
||||||
type: String,
|
type: String
|
||||||
default () {
|
|
||||||
return t('i.transfer.filterPlaceholder');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
filterMethod: {
|
filterMethod: {
|
||||||
type: Function,
|
type: Function,
|
||||||
|
@ -186,10 +138,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
notFoundText: {
|
notFoundText: {
|
||||||
type: String,
|
type: String
|
||||||
default () {
|
|
||||||
return t('i.transfer.notFoundText');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
|
@ -212,6 +161,27 @@
|
||||||
},
|
},
|
||||||
rightValidKeysCount () {
|
rightValidKeysCount () {
|
||||||
return this.getValidKeys('right').length;
|
return this.getValidKeys('right').length;
|
||||||
|
},
|
||||||
|
localeFilterPlaceholder () {
|
||||||
|
if (this.filterPlaceholder === undefined) {
|
||||||
|
return this.t('i.transfer.filterPlaceholder');
|
||||||
|
} else {
|
||||||
|
return this.filterPlaceholder;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
localeNotFoundText () {
|
||||||
|
if (this.notFoundText === undefined) {
|
||||||
|
return this.t('i.transfer.notFoundText');
|
||||||
|
} else {
|
||||||
|
return this.notFoundText;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
localeTitles () {
|
||||||
|
if (this.titles === undefined) {
|
||||||
|
return [this.t('i.transfer.titles.source'), this.t('i.transfer.titles.target')];
|
||||||
|
} else {
|
||||||
|
return this.titles;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -8,20 +8,20 @@
|
||||||
:multiple="multiple"
|
:multiple="multiple"
|
||||||
:show-checkbox="showCheckbox">
|
:show-checkbox="showCheckbox">
|
||||||
</Tree-node>
|
</Tree-node>
|
||||||
<div :class="[prefixCls + '-empty']" v-if="!data.length">{{ emptyText }}</div>
|
<div :class="[prefixCls + '-empty']" v-if="!data.length">{{ localeEmptyText }}</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import TreeNode from './node.vue';
|
import TreeNode from './node.vue';
|
||||||
import { findComponentsDownward } from '../../utils/assist';
|
import { findComponentsDownward } from '../../utils/assist';
|
||||||
import Emitter from '../../mixins/emitter';
|
import Emitter from '../../mixins/emitter';
|
||||||
import { t } from '../../locale';
|
import Locale from '../../mixins/locale';
|
||||||
|
|
||||||
const prefixCls = 'ivu-tree';
|
const prefixCls = 'ivu-tree';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Tree',
|
name: 'Tree',
|
||||||
mixins: [ Emitter ],
|
mixins: [ Emitter, Locale ],
|
||||||
components: { TreeNode },
|
components: { TreeNode },
|
||||||
props: {
|
props: {
|
||||||
data: {
|
data: {
|
||||||
|
@ -39,10 +39,7 @@
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
emptyText: {
|
emptyText: {
|
||||||
type: String,
|
type: String
|
||||||
default () {
|
|
||||||
return t('i.tree.emptyText');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
|
@ -50,6 +47,15 @@
|
||||||
prefixCls: prefixCls
|
prefixCls: prefixCls
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
localeEmptyText () {
|
||||||
|
if (this.emptyText === undefined) {
|
||||||
|
return this.t('i.tree.emptyText');
|
||||||
|
} else {
|
||||||
|
return this.emptyText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getSelectedNodes () {
|
getSelectedNodes () {
|
||||||
const nodes = findComponentsDownward(this, 'TreeNode');
|
const nodes = findComponentsDownward(this, 'TreeNode');
|
||||||
|
|
Loading…
Add table
Reference in a new issue