2021-12-26 22:52:28 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="app-container">
|
2021-12-27 17:04:56 +08:00
|
|
|
<el-row>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<div class="grid-content bg-purple" style="height: 100px"></div>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<!-- 翻译区域-->
|
|
|
|
|
<div class="grid-content bg-purple">
|
|
|
|
|
<el-row :gutter="15">
|
|
|
|
|
<el-form ref="translation" :model="translationData" :rules="translationRules" size="medium"
|
|
|
|
|
label-width="100px" label-position="top">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="翻译平台" prop="translationType">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="translationData.translationType"
|
|
|
|
|
placeholder="翻译平台"
|
|
|
|
|
clearable
|
|
|
|
|
size="small"
|
|
|
|
|
style="width: 150px">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="dict in dict.type.translation_type"
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
:label="dict.label"
|
|
|
|
|
:value="dict.value"/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="20">
|
|
|
|
|
<el-form-item label="翻译区域" prop="q">
|
|
|
|
|
<el-input v-model="translationData.q" type="textarea" placeholder="请输入翻译内容" show-word-limit
|
|
|
|
|
:autosize="{minRows: 4, maxRows: 4}" :style="{width: '100%'}"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item size="large">
|
|
|
|
|
<el-button type="primary" @click="submitForm">提交</el-button>
|
|
|
|
|
<el-button @click="resetForm">重置</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-form>
|
|
|
|
|
</el-row>
|
|
|
|
|
</div>
|
2021-12-26 22:52:28 +08:00
|
|
|
</el-col>
|
2021-12-27 17:04:56 +08:00
|
|
|
<el-col :span="12">
|
|
|
|
|
<!-- 翻译结果显示区域-->
|
|
|
|
|
<div class="grid-content bg-purple ">
|
|
|
|
|
<div class="spans">
|
2021-12-27 19:08:03 +08:00
|
|
|
{{ responseTranslation }}
|
2021-12-27 17:04:56 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2021-12-26 22:52:28 +08:00
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-12-27 17:04:56 +08:00
|
|
|
import {translation} from "@/api/business/english/translation";
|
2021-12-27 19:08:03 +08:00
|
|
|
|
2021-12-26 22:52:28 +08:00
|
|
|
export default {
|
2021-12-27 17:04:56 +08:00
|
|
|
dicts: ['translation_type'],
|
2021-12-26 22:52:28 +08:00
|
|
|
name: "Log",
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2021-12-27 17:04:56 +08:00
|
|
|
//翻译响应数据
|
2021-12-27 19:08:03 +08:00
|
|
|
responseTranslation: '',
|
2021-12-27 17:04:56 +08:00
|
|
|
|
|
|
|
|
translationData: {
|
|
|
|
|
translationType: '',
|
|
|
|
|
q: '',
|
2021-12-26 22:52:28 +08:00
|
|
|
},
|
2021-12-27 17:04:56 +08:00
|
|
|
translationRules: {
|
|
|
|
|
translationType: [{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '翻译平台不能为空',
|
|
|
|
|
trigger: 'change'
|
|
|
|
|
}],
|
2021-12-27 19:08:03 +08:00
|
|
|
q: [
|
|
|
|
|
{
|
2021-12-27 17:04:56 +08:00
|
|
|
required: true,
|
|
|
|
|
message: '请输入翻译内容',
|
|
|
|
|
trigger: 'blur'
|
2021-12-27 19:08:03 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
min: 1,
|
|
|
|
|
max: 120,
|
|
|
|
|
message: '长度在 1 到 120 个字符',
|
|
|
|
|
trigger: 'blur'
|
|
|
|
|
}
|
|
|
|
|
],
|
2021-12-27 17:04:56 +08:00
|
|
|
},
|
|
|
|
|
}
|
2021-12-26 22:52:28 +08:00
|
|
|
},
|
|
|
|
|
created() {
|
2021-12-27 17:04:56 +08:00
|
|
|
|
2021-12-26 22:52:28 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
2021-12-27 17:04:56 +08:00
|
|
|
submitForm() {
|
|
|
|
|
this.$refs['translation'].validate(valid => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
translation(this.translationData).then(res => {
|
2021-12-27 19:08:03 +08:00
|
|
|
let result = res.data.transResult
|
2021-12-27 17:04:56 +08:00
|
|
|
let results = ''
|
|
|
|
|
console.log(result)
|
2021-12-27 19:08:03 +08:00
|
|
|
result.forEach(r => {
|
|
|
|
|
results = results + ' ' + r.dst;
|
2021-12-27 17:04:56 +08:00
|
|
|
})
|
2021-12-27 19:08:03 +08:00
|
|
|
this.responseTranslation = results
|
2021-12-27 17:04:56 +08:00
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
2021-12-26 22:52:28 +08:00
|
|
|
},
|
2021-12-27 17:04:56 +08:00
|
|
|
resetForm() {
|
|
|
|
|
this.$refs['translation'].resetFields()
|
2021-12-26 22:52:28 +08:00
|
|
|
},
|
2021-12-27 17:04:56 +08:00
|
|
|
},
|
2021-12-26 22:52:28 +08:00
|
|
|
};
|
|
|
|
|
</script>
|
2021-12-27 17:04:56 +08:00
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.bg-purple {
|
|
|
|
|
box-shadow: 0 0 9px 3px #999;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.grid-content {
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
min-height: 36px;
|
|
|
|
|
height: 500px;
|
|
|
|
|
margin-top: 20px;
|
|
|
|
|
padding: 50px;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-27 19:08:03 +08:00
|
|
|
.spans {
|
|
|
|
|
margin: 50px;
|
|
|
|
|
margin-top: 40px;
|
2021-12-27 17:04:56 +08:00
|
|
|
padding: 50px;
|
|
|
|
|
font-family: Georgia;
|
2021-12-27 19:08:03 +08:00
|
|
|
font-size: 20px;
|
|
|
|
|
height: 300px;
|
2021-12-27 17:04:56 +08:00
|
|
|
box-shadow: 0 0 9px 3px #999;
|
2021-12-27 19:08:03 +08:00
|
|
|
font-style: italic;
|
2021-12-27 17:04:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|