update 基本完成国际化

This commit is contained in:
2022-09-02 14:09:41 +08:00
parent 12556886b9
commit 076eaa5f2a
15 changed files with 503 additions and 85 deletions

View File

@@ -455,7 +455,7 @@ export default {
.then(({ data: res }) => {
if (res && res.code === 0) {
this.$message({
message: btn.name === 'save' ? '添加成功!' : '更新成功!',
message: btn.name === 'save' ? i18n.t('prompt.success') : '更新成功!',
type: 'success',
duration: 1500,
onClose: () => {

View File

@@ -1,6 +1,8 @@
<template>
<div class="attr-form">
<h3>{{ title }} <el-button style="margin-left: 8px;" type="text" v-if="!isDetail && !showAddAttr" @click="showAddAttr = true">添加</el-button></h3>
<h3>
{{ title }} <el-button style="margin-left: 8px;" type="text" v-if="!isDetail && !showAddAttr" @click="showAddAttr = true">{{ $t('add') }}</el-button>
</h3>
<div v-if="!showAddAttr">
<component
key="sub-table"
@@ -28,7 +30,7 @@
<el-row :gutter="20" style="padding: 0 24px;">
<el-col :span="attrFormFields.length > 6 ? 6 : 12" v-for="field in attrFormFields" :key="field.prop + 'col'">
<el-form-item :key="field.prop" :prop="field.prop" :label="field.name" style="width: 100%">
<el-input v-if="field.formType === 'input' || !field.formType" v-model="AttrForm[field.prop]" placeholder="请填写" clearable />
<el-input v-if="field.formType === 'input' || !field.formType" v-model="AttrForm[field.prop]" :placeholder="$t('hints.input')" clearable />
<el-select v-if="field.formType === 'select'" v-model="AttrForm[field.prop]" clearable>
<el-option v-for="opt in field.formOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
</el-select>
@@ -51,7 +53,7 @@
import i18n from '@/i18n'
import BaseTable from '@/components/base-table'
import { pick } from 'lodash/object'
import { calcMaxHeight } from '@/utils'
export default {
name: 'AttrForm',
components: { BaseTable },
@@ -91,6 +93,7 @@ export default {
},
data() {
return {
calcMaxHeight,
showAddAttr: false,
dataList: [],
pageIndex: 1,
@@ -201,7 +204,7 @@ export default {
deleteHandle(id) {
var ids = id ? [id] : []
this.$confirm(`确定对id=${ids.join(',')}进行${id ? i18n.t('delete') : i18n.t('deleteBatch')}操作?`, i18n.t('prompt.title'), {
this.$confirm(`${i18n.t('prompt.info', { handle: id ? i18n.t('delete').toLowerCase() : i18n.t('deleteBatch').toLowerCase() })}`, i18n.t('prompt.title'), {
confirmButtonText: i18n.t('confirm'),
cancelButtonText: i18n.t('cancel'),
type: 'warning'

View File

@@ -110,7 +110,7 @@ import i18n from '@/i18n'
const title = {
detail: i18n.t('detail'),
add: i18n.t('add'),
edit: '编辑'
edit: i18n.t('edit')
}
// 或者也可以改造成自定义颜色:
@@ -124,9 +124,9 @@ const btnType = {
const btnName = {
// for i18n
save: '保存',
update: '更新',
reset: '重置',
save: i18n.t('save'),
update: i18n.t('update'),
reset: i18n.t('reset'),
cancel: i18n.t('cancel')
// add more...
}
@@ -207,7 +207,7 @@ export default {
},
mounted() {
/** 计算 defaultPlaceholders */
const prefix = '请输入'
const prefix = i18n.t('hints.input')
Object.entries(this.defaultNames).map(([key, value]) => {
this.defaultPlaceholders[key] = prefix + value
})
@@ -251,7 +251,7 @@ export default {
if (item.required) {
const requiredRule = {
required: true,
message: '请输入必填项',
message: i18n.t('validate.required'),
trigger: 'change'
}
/** 检查是否已经存在该字段的规则 */
@@ -296,19 +296,14 @@ export default {
this.configs.extraComponents &&
this.configs.extraComponents.forEach(item => {
if (Object.hasOwn(this.dataForm, [item.name])) {
console.log('有了!')
return
} else {
console.log('新建!')
this.$set(this.dataForm, [item.name], calDefault(item.fieldType))
}
console.log('component: ', item.component)
})
/** 单独设置 id */
this.$set(this.dataForm, 'id', null)
console.log('mounted: this.dataForm', JSON.stringify(this.dataForm))
})
},
@@ -335,7 +330,7 @@ export default {
: this.defaultPlaceholders[opt.name]
? this.defaultPlaceholders[opt.name]
: opt.label
? (opt.type === 'select' ? i18n.t('choose') : '请输入') + opt.label
? (opt.type === 'select' ? i18n.t('choose') : i18n.t('hints.input')) + opt.label
: null
// : opt.type === 'select'
@@ -402,7 +397,6 @@ export default {
this.fileForm[file.typeCode] = [file.id]
}
})
console.log('after分流', this.fileList)
}
}
})
@@ -411,12 +405,12 @@ export default {
if (this.shouldWait)
this.shouldWait.then(() => {
if (this.tempForm.length) {
console.log('create new, tempform', JSON.stringify(this.tempForm.length))
// console.log('create new, tempform', JSON.stringify(this.tempForm.length))
this.tempForm.forEach(item => {
console.log('item data', item.data)
// console.log('item data', item.data)
this.dataForm[item.name] = item.data
})
console.log('create new, dataform', JSON.stringify(this.dataForm))
// console.log('create new, dataform', JSON.stringify(this.dataForm))
}
})
}
@@ -427,9 +421,7 @@ export default {
this.$emit('select-change', { name, id })
},
handleEditorReady(val) {
console.log('editor rready..', val)
},
handleEditorReady(val) {},
handleClick(btn) {
/** 提取url */
@@ -448,7 +440,6 @@ export default {
if (valid) {
/** 对于文件上传的单独处理(合并处理) */
if (Object.keys(this.fileForm).length) {
console.log('fileform 有值')
// LABEL: FILE_RELATED
let fileIds = []
for (const [key, item] of Object.entries(this.fileForm)) {
@@ -471,7 +462,8 @@ export default {
.then(({ data: res }) => {
if (res && res.code === 0) {
this.$message({
message: btn.name === 'save' ? '添加成功!' : '更新成功!',
message: i18n.t('prompt.success'),
// message: btn.name === 'save' ? i18n.t('prompt.success') : '更新成功!',
type: 'success',
duration: 1500,
onClose: () => {
@@ -512,7 +504,7 @@ export default {
// LABEL: FILE_RELATED
handleUploadListUpdate(filelist, typeCode = 'DefaultTypeCode') {
console.log('before handleUploadListUpdate(): ', JSON.parse(JSON.stringify(this.fileForm)))
// console.log('before handleUploadListUpdate(): ', JSON.parse(JSON.stringify(this.fileForm)))
// 设备类型 typeCode: EquipmentTypeFile
// 设备信息 typeCode: EquipmentInfoFile | EquipmentInfoImage
@@ -529,7 +521,7 @@ export default {
typeCode,
filelist.map(item => item.id)
)
console.log('after handleUploadListUpdate(): ', this.fileForm)
// console.log('after handleUploadListUpdate(): ', this.fileForm)
},
handleClose() {

View File

@@ -1,11 +1,5 @@
/**
* @Author: lb
* @CreateDate: 2022.8.8
* @Modifier:
* @ModifiedDate:
* 表格里的文本组件
* 一般用途:展示查看详情入口
*/
import i18n from '@/i18n'
export default {
name: 'TableTextComponent',
props: {
@@ -17,12 +11,12 @@ export default {
data() {
return {
// for i18n inject:
defaultText: '查看详情'
defaultText: i18n.t('viewdetail')
}
},
methods: {
emitClick() {
console.log('inject data:' ,this.injectData)
// console.log('inject data:' ,this.injectData)
this.$emit('emit-data', {
type: this.injectData.head?.actionName || 'view-detail-action',
data: this.injectData.head?.emitFullData ? this.injectData : this.injectData.id

View File

@@ -1,11 +1,5 @@
/**
* @Author: lb
* @CreateDate: 2022.8.8
* @Modifier:
* @ModifiedDate:
* 表格里的操作组件
* 一般用途:展示添加删除按钮
*/
import i18n from '@/i18n'
export default {
name: 'TableOperations',
props: {
@@ -30,12 +24,12 @@ export default {
},
text: {
// TODO: i18n
edit: '编辑',
detail: '详情',
delete: '删除',
viewAttr: '查看属性',
preview: '预览',
design: '设计'
edit: i18n.t('edit'),
detail: i18n.t('detail'),
delete: i18n.t('delete'),
viewAttr: i18n.t('viewattr'),
preview: i18n.t('preview'),
design: i18n.t('design'),
// add more...
}
}

View File

@@ -13,7 +13,7 @@
<!-- :before-remove="beforeRemove" -->
<!-- accept="image/*" -->
<!-- <el-upload class="yd-upload" :action="$http.adornUrl(url)" multiple name="files" :data="extraParams" :file-list="fileList" :on-remove="handleRemove" :before-remove="beforeRemove"> -->
<el-button :disabled="readOnly" size="small" type="primary">{{ buttonContent }}</el-button>
<el-button :disabled="readOnly" type="primary">{{ buttonContent }}</el-button>
<div v-if="tip" slot="tip" class="el-upload__tip">{{ tip }}</div>
</el-upload>
</div>
@@ -101,8 +101,6 @@ export default {
/** 大小验证,由配置文件开启 */
validateFile(file) {
console.log('[*] 验证文件大小')
const isRightSize = file.size / 1024 / 1024 < 2
if (!isRightSize) {
// this.$message.error(this.$t('upload.picSizeAlarm'))
@@ -156,7 +154,6 @@ export default {
alink.style.display = 'none'
alink.target = '_blank'
alink.href = URL.createObjectURL(blob)
console.log('下载地址:', alink.href)
document.body.appendChild(alink)
alink.click()
URL.revokeObjectURL(alink.href)
@@ -184,11 +181,18 @@ export default {
margin-bottom: 20px;
}
.base-upload >>> .el-upload--text {
.base-upload >>> .el-button {
display: block;
width: 200px;
position: relative;
left: -100px;
}
/* .base-upload >>> .el-upload--text {
width: 100px;
position: relative;
left: -72px;
}
left: -100px;
} */
.base-upload >>> .el-upload__tip {
margin-top: 0;