Files
laws_weilai/jero-web/src/views/documentTools/documentTranslation/components/addModel.vue
T
2022-07-26 11:24:16 +08:00

374 lines
11 KiB
Java

<template>
<div>
<a-modal
:title="$t('UploadFile')"
:width="600"
:visible="visible"
:confirm-loading="confirmLoading"
:maskClosable="false"
@ok="handleOk"
@cancel="handleCancel"
>
<a-form-model :model="formInline" class="formAdd" :rules="rules" ref="ruleForm">
<a-row :gutter="24">
<a-col :span="24">
<div class="box-title-text">
<div class="title-text">
<span class="Required">*</span>
<span class="title-text-text"
:title="$t('file')">{{$t('file')}}</span>
</div>
<a-form-model-item class="itemModel" prop="sourceFileId">
<a-button type="primary" class="button-text"
@click="clickButtonToUpload('sourceFileId')">
{{ (formInline.sourceFileId === 'null' || formInline.sourceFileId === '' ||
formInline.sourceFileId == null) ? $t('clickUpload') : $t('viewUploadedFiles')
}}
</a-button>
</a-form-model-item>
</div>
</a-col>
<a-col :span="24">
<div class="box-title-text">
<div class="title-text">
<span class="Required">*</span>
<span class="title-text-text" :title="$t('standard')">{{$t('standard')}}</span>
</div>
<a-form-model-item class="itemModel" prop="serialNumber">
<a-input class="box-input"
readonly
v-model="formInline.serialNumber"
@click.native="standardClick"
:placeholder="$t('PleaseSelect')+$t('standard')"/>
</a-form-model-item>
</div>
</a-col>
<a-col :span="24">
<div class="box-title-text">
<div class="title-text">
<span class="Required">*</span>
<span class="title-text-text" :title="$t('TextStatus')">{{$t('TextStatus')}}</span>
</div>
<a-form-model-item class="itemModel" prop="textStatus">
<a-select :placeholder="$t('PleaseSelect')+$t('TextStatus')"
class="box-input"
:getPopupContainer="triggerNode=> triggerNode.parentNode"
allowClear
v-model="formInline.textStatus">
<a-select-option v-for="(item, key) in translationResultsList"
:key="key"
:value="item.id">
<span style="display: inline-block;width: 100%" :title=" item.dbFieldTxt">
{{ item.dbFieldTxt }}
</span>
</a-select-option>
</a-select>
</a-form-model-item>
</div>
</a-col>
<a-col :span="24">
<div class="box-title-text">
<div class="title-text" style="margin-left: 13px">
<span class="Required">*</span>
<span class="title-text-text" :title="$t('translationLanguage')">{{$t('translationLanguage')}}</span>
</div>
<a-form-model-item class="itemModel" style="width: calc(50% - 20px)" prop="sourceLanguage">
<j-dict-select-tag class="box-input" v-model="formInline.sourceLanguage"
@input="handleInput('sourceLanguage')"
:placeholder="$t('PleaseSelect')+$t('translationLanguage')"
:type="'select'"
:triggerChange="false" dictCode="source_language"/>
</a-form-model-item>
<span class="text-icon">
<a-icon type="arrow-right" style="font-size: 20px"/>
</span>
<a-form-model-item class="itemModel" style="width: calc(50% - 20px)" prop="targetLanguage">
<j-dict-select-tag class="box-input" v-model="formInline.targetLanguage"
@input="handleInput('targetLanguage')"
:placeholder="$t('PleaseSelect')+$t('translationLanguage')"
:type="'select'"
:triggerChange="false" dictCode="target_language"/>
</a-form-model-item>
</div>
</a-col>
</a-row>
</a-form-model>
</a-modal>
<uploadFile ref="uploadFile" :restrictUploads="true" :isMultiple="true" @uploadSuccess="uploadSuccess"/>
<standardData ref="standardDataRef" @standardDataForm="standardDataForm"/>
</div>
</template>
<script>
import { getAction, postAction } from '@/api/manage'
import uploadFile from '@/components/uploadFile/file'
import standardData from './standardData'
export default {
name: 'addModel',
components: {
uploadFile,
standardData
},
data() {
return {
visible: false,
uploadName: '',
confirmLoading: false,
formInline: {},
rules: {
sourceFileId: [
{
required: true,
message: this.$t('file') + this.$t('cannotEmpty'),
trigger: 'change'
}
],
serialNumber: [
{
required: true,
message: this.$t('standard') + this.$t('cannotEmpty'),
trigger: 'change'
}
],
textStatus: [
{
required: true,
message: this.$t('TextStatus') + this.$t('cannotEmpty'),
trigger: 'change'
}
],
sourceLanguage: [
{
required: true,
message: this.$t('translationLanguage') + this.$t('cannotEmpty'),
trigger: 'change'
}
],
targetLanguage: [
{
required: true,
message: this.$t('translationLanguage') + this.$t('cannotEmpty'),
trigger: 'change'
}
]
},
ids: [],
translationResultsList: [],
LanguageList: []
}
},
mounted() {
this.getTextStatus()
},
methods: {
getTextStatus() {
getAction('/docTranslation/docTranslationEO/queryTextStatusVal', {}).then((res) => {
if (res.success) {
this.translationResultsList = res.result || []
} else {
this.translationResultsList = []
}
})
},
add() {
this.visible = true
this.formInline = {}
this.$nextTick(() => {
this.$refs.ruleForm.clearValidate()
})
},
handleInput(value) {
this.$nextTick(() => {
this.formInline = { ...this.formInline }
this.$refs.ruleForm.validateField([value])
})
},
handleOk() {
this.$refs.ruleForm.validate(valid => {
if (valid) {
let query = {
...this.formInline
}
this.confirmLoading = true
postAction('/docTranslation/docTranslationEO/add', query).then((res) => {
if (res.success) {
this.$message.success(this.$t('OperationSuccessful'))
this.visible = false
this.confirmLoading = false
this.$emit('addModelForm')
} else {
this.$message.warning(this.$t('operationFailed'))
this.confirmLoading = false
}
})
}
})
},
handleCancel() {
this.formInline = {}
this.visible = false
},
clickButtonToUpload(item) {
this.$refs.uploadFile.perentHandleFunc()
this.$refs.uploadFile.visible = true
this.uploadName = item
getAction('sys/common/getFileInfos', { id: this.formInline[item] }).then((res) => {
if (res.success) {
this.$refs.uploadFile.perentHandleFunc(res.result)
} else {
this.$refs.uploadFile.perentHandleFunc()
}
})
},
/** 上传文件的回调 */
uploadSuccess(data) {
let attIdList = []
let fileName = []
if (data && data.length > 0) {
data.map(item => {
attIdList.push(item.id || data.name)
fileName.push(item.fileName)
})
}
/** 赋值给当前对应的表单文件 */
this.formInline[this.uploadName] = attIdList.join(',')
this.formInline.fileName = fileName.join(',')
this.formInline = { ...this.formInline }
this.$nextTick(() => {
if (this.formInline[this.uploadName]) {
this.$refs.ruleForm.validateField([this.uploadName])
}
})
},
standardClick() {
this.$refs.standardDataRef.addModel()
},
standardDataForm(row) {
this.formInline.serialNumber = row.serial_number
this.formInline.title = row.title
this.formInline.bussDocumentLibraryId = row.id
this.formInline = { ...this.formInline }
this.$nextTick(() => {
if (this.formInline.serialNumber) {
this.$refs.ruleForm.validateField(['serialNumber'])
}
})
}
}
}
</script>
<style>
.formAdd .ant-form-item-label {
width: 130px;
}
.formAdd .ant-form-item-control-wrapper {
display: inline-block;
width: 100%;
}
/*.formAdd .ant-form-item {*/
/* margin-bottom: 20px;*/
/*}*/
.itemModel .ant-form-item-control-wrapper {
width: 100%;
}
.box-input .ant-select-selection--single {
height: 38px;
}
.box-input .ant-select-selection--multiple {
height: 38px;
}
.box-input .ant-select-selection__rendered {
line-height: 38px;
height: 38px;
}
.box-input .ant-select-selection--multiple .ant-select-selection__rendered > ul > li {
margin-top: 6px;
}
.box-input .ant-calendar-picker {
line-height: 38px;
height: 38px;
}
.box-input .ant-calendar-picker-input {
height: 38px;
}
.box-input .ant-input-number-input-wrap {
line-height: 38px;
height: 38px;
}
.box-input .ant-calendar-picker-input {
padding: 4px 30px 4px 11px;
}
</style>
<style scoped>
.box-title-text {
line-height: 1.4;
display: flex;
}
.title-text {
width: 84px;
text-align: right;
display: inline-block;
font-weight: 500;
font-size: 14px;
margin-right: 16px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
height: 42px;
line-height: 42px;
}
.box-input {
display: inline-block;
height: 38px;
width: 100%;
}
.itemModel {
width: calc(100% - 84px);
display: inline-block;
margin-top: 2px;
}
.title-text-text {
margin-top: 9px;
}
.formAdd {
margin-bottom: 40px;
}
.button-text {
height: 38px;
width: calc(100% - 100px);
line-height: 38px;
background: #fff;
border: 1px #00B3BE solid;
color: #00B3BE;
}
.text-icon {
display: inline-block;
width: 40px;
text-align: center;
margin-top: 11px;
}
.Required {
color: red;
}
</style>