refactor: 移除组件内置i18n翻译,改为调用方自行处理
1. 调整菜单路由路径与API基础路径匹配生产配置更名 2. 优化page-table和page-dialog-form组件,移除内置的$t翻译逻辑,由调用方传入已翻译的文本 3. 为无menu_id的菜单项生成默认空路径
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { request } from '@/api/_service'
|
||||
|
||||
const BASE = 'production_master_data/factory_model/factory_area/'
|
||||
const BASE = 'production_configuration/factory_model/factory_area/'
|
||||
|
||||
function apiParams (method, data = {}) {
|
||||
return {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
不支持复杂表单联动——如有需要,通过默认插槽自定义内容。
|
||||
|
||||
依赖:element-ui 的 <el-dialog> <el-form> <el-input> <el-select>
|
||||
i18n:title / label / placeholder / confirm/cancel 按钮 全部自动 $t() 翻译
|
||||
i18n:由调用方负责翻译,组件直接渲染传入的文本
|
||||
|
||||
@author 前端团队
|
||||
@since 2026-05
|
||||
@@ -22,7 +22,7 @@
|
||||
-->
|
||||
<el-dialog
|
||||
:visible.sync="visibleProxy"
|
||||
:title="$t(title)"
|
||||
:title="title"
|
||||
:width="width"
|
||||
:close-on-click-modal="false"
|
||||
:destroy-on-close="true"
|
||||
@@ -46,12 +46,12 @@
|
||||
- type='input' → <el-input>(支持 textarea、密码等)
|
||||
- type='select' → <el-select> + <el-option>
|
||||
|
||||
label / placeholder 会自动调用 $t() 翻译,传 i18n key 即可
|
||||
由调用方负责翻译,传已翻译的文本即可
|
||||
-->
|
||||
<el-form-item
|
||||
v-for="col in flatFormCols"
|
||||
:key="col.prop"
|
||||
:label="$t(col.label)"
|
||||
:label="col.label"
|
||||
:prop="col.prop"
|
||||
>
|
||||
<!-- ===== 输入框类型 ===== -->
|
||||
@@ -64,7 +64,7 @@
|
||||
<el-input
|
||||
v-if="col.type === 'input'"
|
||||
v-model="formData[col.prop]"
|
||||
:placeholder="$t(col.placeholder)"
|
||||
:placeholder="col.placeholder"
|
||||
:type="col.inputType || 'text'"
|
||||
:autosize="col.autosize"
|
||||
:clearable="col.clearable !== false"
|
||||
@@ -79,7 +79,7 @@
|
||||
<el-select
|
||||
v-else-if="col.type === 'select'"
|
||||
v-model="formData[col.prop]"
|
||||
:placeholder="$t(col.placeholder)"
|
||||
:placeholder="col.placeholder"
|
||||
:clearable="col.clearable !== false"
|
||||
:style="col.style"
|
||||
:filterable="col.filterable !== false"
|
||||
@@ -87,7 +87,7 @@
|
||||
<el-option
|
||||
v-for="opt in col.options"
|
||||
:key="opt.value"
|
||||
:label="$t(opt.label)"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
@@ -104,11 +104,11 @@
|
||||
<!--
|
||||
确定:type='primary' + submitting loading 状态
|
||||
取消:调用 onClose → 重置表单 + 关闭弹框
|
||||
按钮文字自动 $t() 翻译
|
||||
由调用方负责翻译,传已翻译的文本即可
|
||||
-->
|
||||
<template #footer>
|
||||
<el-button @click="onClose">{{ $t(cancelText) }}</el-button>
|
||||
<el-button type="primary" :loading="submitting" @click="onSubmit">{{ $t(confirmText) }}</el-button>
|
||||
<el-button @click="onClose">{{ cancelText }}</el-button>
|
||||
<el-button type="primary" :loading="submitting" @click="onSubmit">{{ confirmText }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -175,7 +175,7 @@ export default {
|
||||
visible: { type: Boolean, default: false },
|
||||
|
||||
/**
|
||||
* 弹框标题,支持 i18n key(组件自动 $t() 翻译)
|
||||
* 弹框标题,由调用方负责翻译
|
||||
*/
|
||||
title: { type: String, default: '' },
|
||||
|
||||
@@ -217,12 +217,12 @@ export default {
|
||||
submitting: { type: Boolean, default: false },
|
||||
|
||||
/**
|
||||
* 确定按钮文字,默认 '确定',支持 i18n key
|
||||
* 确定按钮文字,默认 '确定',由调用方负责 i18n 翻译
|
||||
*/
|
||||
confirmText: { type: String, default: '确定' },
|
||||
|
||||
/**
|
||||
* 取消按钮文字,默认 '取消',支持 i18n key
|
||||
* 取消按钮文字,默认 '取消',由调用方负责 i18n 翻译
|
||||
*/
|
||||
cancelText: { type: String, default: '取消' }
|
||||
},
|
||||
@@ -262,7 +262,7 @@ export default {
|
||||
const firstKey = Object.keys(invalidFields)[0]
|
||||
if (firstKey && invalidFields[firstKey].length) {
|
||||
const msg = invalidFields[firstKey][0].message
|
||||
this.$message.warning(this.$t(msg) || msg)
|
||||
this.$message.warning(msg)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
适合 80% 的增删改查页面,你只需要传列定义、按钮定义、数据和分页参数即可。
|
||||
|
||||
依赖:element-ui 的 <el-table> <el-button> <el-pagination>
|
||||
i18n:所有 label / 按钮文字 / 列标题 自动调用 $t() 翻译,传 i18n key 即可
|
||||
i18n:由调用方负责翻译,组件直接渲染传入的文本
|
||||
|
||||
@author 前端团队
|
||||
@since 2026-05
|
||||
@@ -35,7 +35,7 @@
|
||||
:disabled="btn.needSelection && !selectedCount"
|
||||
@click="btn.onClick"
|
||||
>
|
||||
{{ $t(btn.label) }}
|
||||
{{ btn.label }}
|
||||
</el-button>
|
||||
<!-- 自定义工具栏内容:如打印按钮、列筛选器等 -->
|
||||
<slot name="toolbar-extra" />
|
||||
@@ -48,7 +48,7 @@
|
||||
icon="el-icon-question"
|
||||
@click="openHelp"
|
||||
>
|
||||
{{ $t(helpText) }}
|
||||
{{ helpText }}
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<div ref="tableWrapper" class="page-table__body">
|
||||
<el-table
|
||||
ref="table"
|
||||
:data="tableData"
|
||||
:data="data"
|
||||
:height="tableHeight"
|
||||
:border="border"
|
||||
:row-key="rowKey"
|
||||
@@ -91,7 +91,7 @@
|
||||
:key="'idx-' + col.idx"
|
||||
type="index"
|
||||
:width="col.width"
|
||||
:label="$t(col.label || '#')"
|
||||
:label="col.label || '#'"
|
||||
/>
|
||||
<!-- 3. 操作列:自动渲染 rowButtons(编辑/删除等行内按钮) -->
|
||||
<!--
|
||||
@@ -314,7 +314,7 @@ export default {
|
||||
helpUrl: { type: String, default: '' },
|
||||
|
||||
/**
|
||||
* 帮助按钮的文字,支持 i18n key(组件自动 $t() 翻译)
|
||||
* 帮助按钮的文字,由调用方负责 i18n 翻译
|
||||
* 默认 '帮助'
|
||||
*/
|
||||
helpText: { type: String, default: '帮助' }
|
||||
@@ -382,9 +382,6 @@ export default {
|
||||
delete attrs.idx
|
||||
delete attrs.slot
|
||||
delete attrs.headerSlot
|
||||
if (attrs.label) {
|
||||
attrs.label = this.$t(attrs.label)
|
||||
}
|
||||
return attrs
|
||||
},
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ function getMenuData (arr) {
|
||||
}
|
||||
|
||||
const menuItem = {
|
||||
path: value.url,
|
||||
path: value.url || ('d2-menu-empty-' + value.menu_id),
|
||||
title: value.name,
|
||||
icon: value.icon,
|
||||
type: value.type,
|
||||
|
||||
18
src/router/modules/production-master-data.js
Normal file
18
src/router/modules/production-master-data.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import layoutHeaderAside from '@/layout/header-aside'
|
||||
|
||||
const meta = { auth: true }
|
||||
|
||||
const _import = require('@/libs/util.import.' + process.env.NODE_ENV)
|
||||
|
||||
export default {
|
||||
path: '/production_configuration',
|
||||
component: layoutHeaderAside,
|
||||
children: (pre => [
|
||||
{
|
||||
path: 'factory_model/factory_area',
|
||||
name: `${pre}factory_model-factory_area`,
|
||||
meta: { ...meta, cache: true, title: '工厂区域' },
|
||||
component: _import('production-master-data/factory-model/factory-area')
|
||||
}
|
||||
])('production_configuration-')
|
||||
}
|
||||
Reference in New Issue
Block a user