Commit 72c5952034a16a457953eb9ada0818f38033cbc8

Authored by Aaron
1 parent 8a88772a
Exists in master and in 1 other branch legacy

支持vue-i18n国际化设置

examples/main.js
@@ -20,7 +20,7 @@ const request = axios.create({ @@ -20,7 +20,7 @@ const request = axios.create({
20 timeout: 1000 * 60, 20 timeout: 1000 * 60,
21 withCredentials: true, 21 withCredentials: true,
22 headers: { 22 headers: {
23 - token: 'be81d1ba777f7081ef6897eec3b4bdf2', 23 + token: 'd2ec639eb3a4e6e2fc3ab2adc6e652fc',
24 'Accept-Language': 'zh-CN' 24 'Accept-Language': 'zh-CN'
25 } 25 }
26 }); 26 });
packages/confirm/index.vue
@@ -19,11 +19,11 @@ @@ -19,11 +19,11 @@
19 <div> 19 <div>
20 <p class="eagle-confirm-title"> 20 <p class="eagle-confirm-title">
21 <i class="el-icon-info eagle-confirm-icon"></i> 21 <i class="el-icon-info eagle-confirm-icon"></i>
22 - <span>{{ title }}</span> 22 + <span>{{ title || i18n('eagle.confirm.title') || '是否执行当前操作?' }}</span>
23 </p> 23 </p>
24 <p class="eagle-confirm-button-panel"> 24 <p class="eagle-confirm-button-panel">
25 - <el-button size="mini" plain @click="cancel">否</el-button>  
26 - <el-button size="mini" type="primary" style="margin-left: 5px" @click="confirm">是</el-button> 25 + <el-button size="mini" plain @click="cancel">{{ i18n('eagle.confirm.no') || '否' }}</el-button>
  26 + <el-button size="mini" type="primary" style="margin-left: 5px" @click="confirm">{{ i18n('eagle.confirm.yes') || '是' }}</el-button>
27 </p> 27 </p>
28 </div> 28 </div>
29 <span @click.stop slot="reference"> 29 <span @click.stop slot="reference">
@@ -37,7 +37,6 @@ export default { @@ -37,7 +37,6 @@ export default {
37 props: { 37 props: {
38 title: { 38 title: {
39 type: String, 39 type: String,
40 - default: "是否执行当前操作?"  
41 }, 40 },
42 placement: { 41 placement: {
43 type: String, 42 type: String,
packages/detail/index.vue
@@ -117,7 +117,7 @@ export default { @@ -117,7 +117,7 @@ export default {
117 } else { 117 } else {
118 if (!groupSet['group-default']) { 118 if (!groupSet['group-default']) {
119 groupSet['group-default'] = { 119 groupSet['group-default'] = {
120 - label: '基本信息', 120 + label: this.i18n('eagle.detail.basic') || '基本信息',
121 list: [] 121 list: []
122 }; 122 };
123 } 123 }
packages/form/index.vue
@@ -45,8 +45,8 @@ @@ -45,8 +45,8 @@
45 </el-row> 45 </el-row>
46 <slot v-if="$scopedSlots['footer'] || $slots['footer']" name="footer" :model="model" :submit="handleSubmit" :cancel="handleCancel"></slot> 46 <slot v-if="$scopedSlots['footer'] || $slots['footer']" name="footer" :model="model" :submit="handleSubmit" :cancel="handleCancel"></slot>
47 <el-row :gutter="15" v-else :style="footerStyle"> 47 <el-row :gutter="15" v-else :style="footerStyle">
48 - <el-button type="primary" size="small" :loading="submitting" @click="handleSubmit">确定</el-button>  
49 - <el-button plain size="small" @click="handleCancel" style="margin-left: 8px">取消</el-button> 48 + <el-button type="primary" size="small" :loading="submitting" @click="handleSubmit">{{ i18n('eagle.form.confirm') || '确定' }}</el-button>
  49 + <el-button plain size="small" @click="handleCancel" style="margin-left: 8px">{{ i18n('eagle.form.cancel') || '取消' }}</el-button>
50 </el-row> 50 </el-row>
51 </el-form> 51 </el-form>
52 </template> 52 </template>
@@ -141,7 +141,7 @@ export default { @@ -141,7 +141,7 @@ export default {
141 } else { 141 } else {
142 if (!groupSet['group-default']) { 142 if (!groupSet['group-default']) {
143 groupSet['group-default'] = { 143 groupSet['group-default'] = {
144 - label: '基本信息', 144 + label: this.i18n('eagle.form.basic') || '基本信息',
145 list: [] 145 list: []
146 }; 146 };
147 } 147 }
packages/index.js
@@ -46,6 +46,14 @@ const install = function (Vue, opts = {}) { @@ -46,6 +46,14 @@ const install = function (Vue, opts = {}) {
46 // 配置组件名称 46 // 配置组件名称
47 const name = prefix + component.name 47 const name = prefix + component.name
48 component.name = name 48 component.name = name
  49 + const defaultI18n = () => undefined;
  50 + // if (opts.i18n) {
  51 + if (component.methods) {
  52 + component.methods.i18n = opts.i18n || defaultI18n;
  53 + } else {
  54 + component.methods = { i18n: opts.i18n || defaultI18n }
  55 + }
  56 + // }
49 // 给每个子组件配置install方法 57 // 给每个子组件配置install方法
50 component.install = function (Vue) { 58 component.install = function (Vue) {
51 Vue.component(name, component) 59 Vue.component(name, component)
packages/scheme/index.vue
@@ -63,10 +63,10 @@ @@ -63,10 +63,10 @@
63 <div v-if="option.showActionBar !== false" class="eagle-scheme__action" v-loading="tableLoading" element-loading-spinner="none" element-loading-background="rgba(255, 255, 255, 0.6)"> 63 <div v-if="option.showActionBar !== false" class="eagle-scheme__action" v-loading="tableLoading" element-loading-spinner="none" element-loading-background="rgba(255, 255, 255, 0.6)">
64 <slot v-if="$scopedSlots['action-bar'] || $slots['action-bar']" name="action-bar" :handleNew="handleNew" :handleDelete="handleDelete" :model="formModel" :selection="tableSelection" :setDialog="setDialog"></slot> 64 <slot v-if="$scopedSlots['action-bar'] || $slots['action-bar']" name="action-bar" :handleNew="handleNew" :handleDelete="handleDelete" :model="formModel" :selection="tableSelection" :setDialog="setDialog"></slot>
65 <template v-else> 65 <template v-else>
66 - <el-button class="eagle-scheme__action-btn" type="primary" size="small" @click="handleNew">新增</el-button>  
67 - <el-button v-if="hasSelectionSlot" :disabled="tableSelection && tableSelection.length <= 0" class="eagle-scheme__action-btn" plain size="small" @click="handleDelete('more')">删除</el-button> 66 + <el-button class="eagle-scheme__action-btn" type="primary" size="small" @click="handleNew">{{ i18n('eagle.scheme.new') || '新增' }}</el-button>
  67 + <el-button v-if="hasSelectionSlot" :disabled="tableSelection && tableSelection.length <= 0" class="eagle-scheme__action-btn" plain size="small" @click="handleDelete('more')">{{ i18n('eagle.scheme.delete') || '删除' }}</el-button>
68 <slot v-if="$scopedSlots['action-button'] || $slots['action-button']" name="action-button" class="eagle-scheme__action-btn" :model="formModel" :selection="tableSelection" :setDialog="setDialog"></slot> 68 <slot v-if="$scopedSlots['action-button'] || $slots['action-button']" name="action-button" class="eagle-scheme__action-btn" :model="formModel" :selection="tableSelection" :setDialog="setDialog"></slot>
69 - <div v-if="hasSelectionSlot && tableSelection && tableSelection.length > 0" class="eagle-scheme__action-btn eagle-scheme__text-selection">已选中<span class="eagle-scheme__text-selection-highlight">{{ tableSelection.length }}</span>项</div> 69 + <div v-if="hasSelectionSlot && tableSelection && tableSelection.length > 0" class="eagle-scheme__action-btn eagle-scheme__text-selection">{{ i18n('eagle.scheme.checked') || '已选中' }}<span class="eagle-scheme__text-selection-highlight">{{ tableSelection.length }}</span>{{ i18n('eagle.scheme.item') || '项' }}</div>
70 </template> 70 </template>
71 </div> 71 </div>
72 <div class="eagle-scheme__table"> 72 <div class="eagle-scheme__table">
@@ -94,14 +94,14 @@ @@ -94,14 +94,14 @@
94 <slot name="table-operation" slot="$end"></slot> 94 <slot name="table-operation" slot="$end"></slot>
95 </template> 95 </template>
96 <!-- 表格操作栏插槽 - 默认 --> 96 <!-- 表格操作栏插槽 - 默认 -->
97 - <el-table-column v-else slot="$end" prop="$operation" label="操作" min-width="140" fixed="right"> 97 + <el-table-column v-else slot="$end" prop="$operation" :label="i18n('eagle.scheme.operation') || '操作'" min-width="140" fixed="right">
98 <div class="eagle-scheme__table-operation" slot-scope="slotScope"> 98 <div class="eagle-scheme__table-operation" slot-scope="slotScope">
99 <!-- 表格操作栏插槽 - 前置插槽 --> 99 <!-- 表格操作栏插槽 - 前置插槽 -->
100 <slot v-if="$scopedSlots['table-operation-btn'] || $slots['table-operation-btn']" name="table-operation-btn"></slot> 100 <slot v-if="$scopedSlots['table-operation-btn'] || $slots['table-operation-btn']" name="table-operation-btn"></slot>
101 - <el-button v-if="option.showViewBtn !== false" class="eagle-scheme__table-btn" type="text" icon="el-icon-view" title="查看" @click="handleView(slotScope)"></el-button>  
102 - <el-button class="eagle-scheme__table-btn" type="text" icon="el-icon-edit" title="编辑" @click="handleEdit(slotScope)"></el-button>  
103 - <eagle-confirm class="eagle-scheme__table-btn" title="是否删除?" @confirm="handleDelete('one', slotScope)">  
104 - <el-button type="text" icon="el-icon-delete" title="删除"></el-button> 101 + <el-button v-if="option.showViewBtn !== false" class="eagle-scheme__table-btn" type="text" icon="el-icon-view" :title="i18n('eagle.scheme.view') || '详情'" @click="handleView(slotScope)"></el-button>
  102 + <el-button class="eagle-scheme__table-btn" type="text" icon="el-icon-edit" :title="i18n('eagle.scheme.edit') || '编辑'" @click="handleEdit(slotScope)"></el-button>
  103 + <eagle-confirm class="eagle-scheme__table-btn" :title="i18n('eagle.scheme.deleteConfirm') || '是否删除?'" @confirm="handleDelete('one', slotScope)">
  104 + <el-button type="text" icon="el-icon-delete" :title="i18n('eagle.scheme.delete') || '删除'"></el-button>
105 </eagle-confirm> 105 </eagle-confirm>
106 <!-- 表格操作栏插槽 - 后置插槽 --> 106 <!-- 表格操作栏插槽 - 后置插槽 -->
107 <slot v-if="$scopedSlots['table-operation-btn-append'] || $slots['table-operation-btn-append']" name="table-operation-btn-append"></slot> 107 <slot v-if="$scopedSlots['table-operation-btn-append'] || $slots['table-operation-btn-append']" name="table-operation-btn-append"></slot>
@@ -330,7 +330,7 @@ export default { @@ -330,7 +330,7 @@ export default {
330 }, 330 },
331 // 查看按钮 331 // 查看按钮
332 handleView({ row }) { 332 handleView({ row }) {
333 - this.dialogTitle = '详情'; 333 + this.dialogTitle = this.i18n('eagle.scheme.detail') || '详情';
334 this.dialogType = 'dialog-view'; 334 this.dialogType = 'dialog-view';
335 this.tableCurrentRow = row; 335 this.tableCurrentRow = row;
336 this.formModel = {}; 336 this.formModel = {};
@@ -372,7 +372,7 @@ export default { @@ -372,7 +372,7 @@ export default {
372 }, 372 },
373 // 新增按钮 373 // 新增按钮
374 handleNew({ row }) { 374 handleNew({ row }) {
375 - this.dialogTitle = '新增'; 375 + this.dialogTitle = this.i18n('eagle.scheme.new') || '新增';
376 this.dialogType = 'dialog-form'; 376 this.dialogType = 'dialog-form';
377 this.tableCurrentRow = row; 377 this.tableCurrentRow = row;
378 this.formModel = {}; 378 this.formModel = {};
@@ -382,7 +382,7 @@ export default { @@ -382,7 +382,7 @@ export default {
382 }, 382 },
383 // 编辑按钮 383 // 编辑按钮
384 async handleEdit({ row }) { 384 async handleEdit({ row }) {
385 - this.dialogTitle = '编辑'; 385 + this.dialogTitle = this.i18n('eagle.scheme.edit') || '编辑';
386 this.dialogType = 'dialog-form'; 386 this.dialogType = 'dialog-form';
387 this.tableCurrentRow = row; 387 this.tableCurrentRow = row;
388 this.formModel = {}; 388 this.formModel = {};
@@ -429,9 +429,9 @@ export default { @@ -429,9 +429,9 @@ export default {
429 if (type === 'one') { 429 if (type === 'one') {
430 this.doDelete([scope.row]); 430 this.doDelete([scope.row]);
431 } else if (type === 'more') { 431 } else if (type === 'more') {
432 - this.$confirm(`是否删除已选中的 [ ${this.tableSelection.length} ] 项`, '提示', {  
433 - confirmButtonText: '确定',  
434 - cancelButtonText: '取消', 432 + this.$confirm(`${this.i18n('eagle.scheme.mulDeleteConfirm') || '是否删除已选中的'} [ ${this.tableSelection.length} ] ${this.i18n('eagle.scheme.item') || '项'}`, this.i18n('eagle.scheme.tip') || '提示', {
  433 + confirmButtonText: this.i18n('eagle.scheme.confirm') || '确定',
  434 + cancelButtonText: this.i18n('eagle.scheme.cancel') || '取消',
435 type: 'warning' 435 type: 'warning'
436 }).then(() => { 436 }).then(() => {
437 this.doDelete(this.tableSelection || []); 437 this.doDelete(this.tableSelection || []);
@@ -452,7 +452,7 @@ export default { @@ -452,7 +452,7 @@ export default {
452 if (success) { 452 if (success) {
453 this.hideDialog(); 453 this.hideDialog();
454 this.handleSearch(); 454 this.handleSearch();
455 - if (this.$message) { this.$message({ message: '删除成功', type: 'success' }); } 455 + if (this.$message) { this.$message({ message: this.i18n('eagle.scheme.deleteSuccess') || '删除成功', type: 'success' }); }
456 } 456 }
457 } catch (error) { 457 } catch (error) {
458 console.error(error); 458 console.error(error);
@@ -469,7 +469,7 @@ export default { @@ -469,7 +469,7 @@ export default {
469 if (`${code}` === '0') { 469 if (`${code}` === '0') {
470 this.hideDialog(); 470 this.hideDialog();
471 this.handleSearch(); 471 this.handleSearch();
472 - if (this.$message) { this.$message({ message: '删除成功', type: 'success' }); } 472 + if (this.$message) { this.$message({ message: this.i18n('eagle.scheme.deleteSuccess') || '删除成功', type: 'success' }); }
473 } 473 }
474 }) 474 })
475 .finally(() => { 475 .finally(() => {
@@ -518,7 +518,7 @@ export default { @@ -518,7 +518,7 @@ export default {
518 if (success) { 518 if (success) {
519 this.hideDialog(); 519 this.hideDialog();
520 this.handleSearch(); 520 this.handleSearch();
521 - if (this.$message) { this.$message({ message: '提交成功', type: 'success' }); } 521 + if (this.$message) { this.$message({ message: this.i18n('eagle.scheme.submitSuccess') || '提交成功', type: 'success' }); }
522 } 522 }
523 } catch (error) { 523 } catch (error) {
524 console.error(error); 524 console.error(error);
@@ -536,7 +536,7 @@ export default { @@ -536,7 +536,7 @@ export default {
536 if (`${code}` === '0') { 536 if (`${code}` === '0') {
537 this.hideDialog(); 537 this.hideDialog();
538 this.handleSearch(); 538 this.handleSearch();
539 - if (this.$message) { this.$message({ message: '提交成功', type: 'success' }); } 539 + if (this.$message) { this.$message({ message: this.i18n('eagle.scheme.submitSuccess') || '提交成功', type: 'success' }); }
540 } 540 }
541 }) 541 })
542 .finally(() => { 542 .finally(() => {
@@ -554,7 +554,7 @@ export default { @@ -554,7 +554,7 @@ export default {
554 if (success) { 554 if (success) {
555 this.hideDialog(); 555 this.hideDialog();
556 this.handleSearch(); 556 this.handleSearch();
557 - if (this.$message) { this.$message({ message: '编辑成功', type: 'success' }); } 557 + if (this.$message) { this.$message({ message: this.i18n('eagle.scheme.editSuccess') || '编辑成功', type: 'success' }); }
558 } 558 }
559 } catch (error) { 559 } catch (error) {
560 console.error(error); 560 console.error(error);
@@ -570,7 +570,7 @@ export default { @@ -570,7 +570,7 @@ export default {
570 if (`${code}` === '0') { 570 if (`${code}` === '0') {
571 this.hideDialog(); 571 this.hideDialog();
572 this.handleSearch(); 572 this.handleSearch();
573 - if (this.$message) { this.$message({ message: '编辑成功', type: 'success' }); } 573 + if (this.$message) { this.$message({ message: this.i18n('eagle.scheme.editSuccess') || '编辑成功', type: 'success' }); }
574 } 574 }
575 }) 575 })
576 .finally(() => { 576 .finally(() => {
packages/search/index.vue
@@ -25,10 +25,10 @@ @@ -25,10 +25,10 @@
25 :model="model" :collapse="collapse" :doSearch="handleSearch" :doReset="handleReset" :doCollapse="handleCollapse" 25 :model="model" :collapse="collapse" :doSearch="handleSearch" :doReset="handleReset" :doCollapse="handleCollapse"
26 ></slot> 26 ></slot>
27 <el-button-group v-else> 27 <el-button-group v-else>
28 - <el-button size="small" type="primary" :loading="searching" @click="handleSearch" icon="el-icon-search">查询</el-button>  
29 - <el-button size="small" @click="handleReset">重置</el-button> 28 + <el-button size="small" type="primary" :loading="searching" @click="handleSearch" icon="el-icon-search">{{ i18n('eagle.search.search') || '查询' }}</el-button>
  29 + <el-button size="small" @click="handleReset">{{ i18n('eagle.search.reset') || '重置' }}</el-button>
30 <el-button size="small" v-if="list.length > visibleColNum" :icon="collapse ? 'ios-arrow-down' : 'ios-arrow-up'" @click="handleCollapse"> 30 <el-button size="small" v-if="list.length > visibleColNum" :icon="collapse ? 'ios-arrow-down' : 'ios-arrow-up'" @click="handleCollapse">
31 - {{ collapse ? '展开' : '收起' }} 31 + {{ collapse ? i18n('eagle.search.unfold') || '展开' : i18n('eagle.search.fold') || '收起' }}
32 </el-button> 32 </el-button>
33 </el-button-group> 33 </el-button-group>
34 </el-col> 34 </el-col>
packages/select/index.vue
1 <template> 1 <template>
2 - <el-select :size="size" v-model="model" :disabled="disabled" :remote="remote" :remote-method="remote ? remoteMethod : undefined" :placeholder="placeholder" clearable :filterable="filterable" :multiple="multiple" :value-key="format == 'text' ? undefined : valueKey" @change="handleChange" @focus="handleFocus" :loading="loading"> 2 + <el-select :size="size" v-model="model" :disabled="disabled" :remote="remote" :remote-method="remote ? remoteMethod : undefined" :placeholder="placeholder || i18n('eagle.select.select') || '请选择'" clearable :filterable="filterable" :multiple="multiple" :value-key="format == 'text' ? undefined : valueKey" @change="handleChange" @focus="handleFocus" :loading="loading">
3 <el-option v-for="item in option" :key="format == 'text' ? item[valueProps.value] : item[valueKey]" :label="item[valueProps.label]" :value="format == 'text' ? item[valueProps.value] : item"></el-option> 3 <el-option v-for="item in option" :key="format == 'text' ? item[valueProps.value] : item[valueKey]" :label="item[valueProps.label]" :value="format == 'text' ? item[valueProps.value] : item"></el-option>
4 </el-select> 4 </el-select>
5 </template> 5 </template>
@@ -17,7 +17,6 @@ export default { @@ -17,7 +17,6 @@ export default {
17 // 选择框提示 17 // 选择框提示
18 placeholder: { 18 placeholder: {
19 type: String, 19 type: String,
20 - default: '请选择'  
21 }, 20 },
22 // 选择框大小 21 // 选择框大小
23 size: String, 22 size: String,