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 20 timeout: 1000 * 60,
21 21 withCredentials: true,
22 22 headers: {
23   - token: 'be81d1ba777f7081ef6897eec3b4bdf2',
  23 + token: 'd2ec639eb3a4e6e2fc3ab2adc6e652fc',
24 24 'Accept-Language': 'zh-CN'
25 25 }
26 26 });
... ...
packages/confirm/index.vue
... ... @@ -19,11 +19,11 @@
19 19 <div>
20 20 <p class="eagle-confirm-title">
21 21 <i class="el-icon-info eagle-confirm-icon"></i>
22   - <span>{{ title }}</span>
  22 + <span>{{ title || i18n('eagle.confirm.title') || '是否执行当前操作?' }}</span>
23 23 </p>
24 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 27 </p>
28 28 </div>
29 29 <span @click.stop slot="reference">
... ... @@ -37,7 +37,6 @@ export default {
37 37 props: {
38 38 title: {
39 39 type: String,
40   - default: "是否执行当前操作?"
41 40 },
42 41 placement: {
43 42 type: String,
... ...
packages/detail/index.vue
... ... @@ -117,7 +117,7 @@ export default {
117 117 } else {
118 118 if (!groupSet['group-default']) {
119 119 groupSet['group-default'] = {
120   - label: '基本信息',
  120 + label: this.i18n('eagle.detail.basic') || '基本信息',
121 121 list: []
122 122 };
123 123 }
... ...
packages/form/index.vue
... ... @@ -45,8 +45,8 @@
45 45 </el-row>
46 46 <slot v-if="$scopedSlots['footer'] || $slots['footer']" name="footer" :model="model" :submit="handleSubmit" :cancel="handleCancel"></slot>
47 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 50 </el-row>
51 51 </el-form>
52 52 </template>
... ... @@ -141,7 +141,7 @@ export default {
141 141 } else {
142 142 if (!groupSet['group-default']) {
143 143 groupSet['group-default'] = {
144   - label: '基本信息',
  144 + label: this.i18n('eagle.form.basic') || '基本信息',
145 145 list: []
146 146 };
147 147 }
... ...
packages/index.js
... ... @@ -46,6 +46,14 @@ const install = function (Vue, opts = {}) {
46 46 // 配置组件名称
47 47 const name = prefix + component.name
48 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 57 // 给每个子组件配置install方法
50 58 component.install = function (Vue) {
51 59 Vue.component(name, component)
... ...
packages/scheme/index.vue
... ... @@ -63,10 +63,10 @@
63 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 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 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 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 70 </template>
71 71 </div>
72 72 <div class="eagle-scheme__table">
... ... @@ -94,14 +94,14 @@
94 94 <slot name="table-operation" slot="$end"></slot>
95 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 98 <div class="eagle-scheme__table-operation" slot-scope="slotScope">
99 99 <!-- 表格操作栏插槽 - 前置插槽 -->
100 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 105 </eagle-confirm>
106 106 <!-- 表格操作栏插槽 - 后置插槽 -->
107 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 330 },
331 331 // 查看按钮
332 332 handleView({ row }) {
333   - this.dialogTitle = '详情';
  333 + this.dialogTitle = this.i18n('eagle.scheme.detail') || '详情';
334 334 this.dialogType = 'dialog-view';
335 335 this.tableCurrentRow = row;
336 336 this.formModel = {};
... ... @@ -372,7 +372,7 @@ export default {
372 372 },
373 373 // 新增按钮
374 374 handleNew({ row }) {
375   - this.dialogTitle = '新增';
  375 + this.dialogTitle = this.i18n('eagle.scheme.new') || '新增';
376 376 this.dialogType = 'dialog-form';
377 377 this.tableCurrentRow = row;
378 378 this.formModel = {};
... ... @@ -382,7 +382,7 @@ export default {
382 382 },
383 383 // 编辑按钮
384 384 async handleEdit({ row }) {
385   - this.dialogTitle = '编辑';
  385 + this.dialogTitle = this.i18n('eagle.scheme.edit') || '编辑';
386 386 this.dialogType = 'dialog-form';
387 387 this.tableCurrentRow = row;
388 388 this.formModel = {};
... ... @@ -429,9 +429,9 @@ export default {
429 429 if (type === 'one') {
430 430 this.doDelete([scope.row]);
431 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 435 type: 'warning'
436 436 }).then(() => {
437 437 this.doDelete(this.tableSelection || []);
... ... @@ -452,7 +452,7 @@ export default {
452 452 if (success) {
453 453 this.hideDialog();
454 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 457 } catch (error) {
458 458 console.error(error);
... ... @@ -469,7 +469,7 @@ export default {
469 469 if (`${code}` === '0') {
470 470 this.hideDialog();
471 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 475 .finally(() => {
... ... @@ -518,7 +518,7 @@ export default {
518 518 if (success) {
519 519 this.hideDialog();
520 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 523 } catch (error) {
524 524 console.error(error);
... ... @@ -536,7 +536,7 @@ export default {
536 536 if (`${code}` === '0') {
537 537 this.hideDialog();
538 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 542 .finally(() => {
... ... @@ -554,7 +554,7 @@ export default {
554 554 if (success) {
555 555 this.hideDialog();
556 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 559 } catch (error) {
560 560 console.error(error);
... ... @@ -570,7 +570,7 @@ export default {
570 570 if (`${code}` === '0') {
571 571 this.hideDialog();
572 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 576 .finally(() => {
... ...
packages/search/index.vue
... ... @@ -25,10 +25,10 @@
25 25 :model="model" :collapse="collapse" :doSearch="handleSearch" :doReset="handleReset" :doCollapse="handleCollapse"
26 26 ></slot>
27 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 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 32 </el-button>
33 33 </el-button-group>
34 34 </el-col>
... ...
packages/select/index.vue
1 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 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 4 </el-select>
5 5 </template>
... ... @@ -17,7 +17,6 @@ export default {
17 17 // 选择框提示
18 18 placeholder: {
19 19 type: String,
20   - default: '请选择'
21 20 },
22 21 // 选择框大小
23 22 size: String,
... ...