Files
laws_weilai/jero-web/src/views/projectManagement/components/addModel.vue
T
2023-03-16 10:45:21 +08:00

617 lines
22 KiB
Java

<template>
<a-drawer
:title="title"
:maskClosable="false"
:width="1000"
placement="right"
:closable="true"
@close="handleCancel"
:visible="visible"
style="height: 100%;overflow: auto;padding-bottom: 53px;">
<a-spin :spinning="confirmLoading">
<a-form-model :model="formInline" class="formAdd" :rules="rules" ref="ruleForm">
<a-row :gutter="24">
<a-col :span="12">
<div class="box-title-text">
<div class="title-text">
<span class="Required">*</span>
<span class="title-text-text" :title="$t('modelName')">{{$t('modelName')}}</span>
</div>
<a-form-model-item class="itemModel" prop="projectNameId">
<a-select :placeholder="$t('PleaseSelect')+$t('modelName')"
@change="projectNameChange"
v-model="formInline.projectNameId">
<a-select-option v-for="(item, key) in projectNameList"
:key="key"
:value="item.id">
<span style="display: inline-block;width: 100%" :title=" item.projectName ">
{{ item.projectName}}
</span>
</a-select-option>
</a-select>
</a-form-model-item>
</div>
</a-col>
<a-col :span="12">
<div class="box-title-text">
<div class="title-text">
<span class="Required">*</span>
<span class="title-text-text" :title="$t('modelYear')">{{$t('modelYear')}}</span>
</div>
<a-form-model-item class="itemModel" prop="yearNameId">
<a-select :placeholder="$t('PleaseSelect')+$t('modelYear')"
v-model="formInline.yearNameId">
<a-select-option v-for="(item, key) in yearNameDataList"
:key="key"
:value="item.id">
<span style="display: inline-block;width: 100%" :title=" item.yearName ">
{{ item.yearName}}
</span>
</a-select-option>
</a-select>
</a-form-model-item>
</div>
</a-col>
</a-row>
<a-row :gutter="24">
<a-col :span="12">
<div class="box-title-text">
<div class="title-text">
<span class="Required">*</span>
<span class="title-text-text" :title="$t('targetMarket')">{{$t('targetMarket')}}</span>
</div>
<a-form-model-item class="itemModel-multi" prop="targetMarket">
<j-multi-select-tag class="box-input" v-model="formInline.targetMarket"
:disabled="disabled"
:placeholder="$t('PleaseSelect')+$t('targetMarket')"
:type="'select'"
:triggerChange="false" :dictCode="'region'"/>
</a-form-model-item>
</div>
</a-col>
<a-col :span="12">
<div class="box-title-text">
<div class="title-text">
<span class="Required">*</span>
<span class="title-text-text" :title="$t('projectVersion')">{{$t('projectVersion')}}</span>
</div>
<a-form-model-item class="itemModel" prop="projectVersion">
<a-input class="box-input"
:disabled="true"
v-model="formInline.projectVersion"
:placeholder="$t('PleaseEnter')+$t('projectVersion')"/>
</a-form-model-item>
</div>
</a-col>
</a-row>
<a-row :gutter="24">
<a-col :span="12">
<div class="box-title-text">
<div class="title-text">
<span class="Required">*</span>
<span class="title-text-text" :title="$t('projectStatus')">{{$t('projectStatus')}}</span>
</div>
<a-form-model-item class="itemModel" prop="projectStatus">
<j-dict-select-tag class="box-input" v-model="formInline.projectStatus"
:disabled="disabled"
@input="handleInput('projectStatus')"
:placeholder="$t('PleaseSelect')+$t('projectStatus')"
:type="'select'"
:triggerChange="false" :dictCode="'project_status'"/>
</a-form-model-item>
</div>
</a-col>
<a-col :span="12">
<div class="box-title-text">
<div class="title-text">
<span class="title-text-text"
:title="$t('brand')">{{$t('brand')}}</span>
</div>
<a-form-model-item class="itemModel" :prop="'brand'">
<j-dict-select-tag v-model="formInline.brand"
:placeholder="$t('PleaseSelect')+$t('brand')"
:type="'select'"
:triggerChange="false" :dictCode="'brand'"/>
</a-form-model-item>
</div>
</a-col>
</a-row>
<a-row :gutter="24">
<a-col :span="12">
<div class="box-title-text">
<div class="title-text">
<span class="Required">*</span>
<span class="title-text-text" :title="$t('StudioEngineer')">{{$t('StudioEngineer')}}</span>
</div>
<a-form-model-item class="itemModel-multi" :prop="'studioEngineerName'">
<PersonnelSelection :query="{db_field_name:'studioEngineer',db_field_txt:$t('StudioEngineer')}"
:isSingleChoice="true"
:personneQuery="formInline"
v-if="visible"
@change="PersonnelSelectionChange"
:disabled="disabled"
v-model="formInline.studioEngineerName"/>
</a-form-model-item>
</div>
</a-col>
<a-col :span="12">
<div class="box-title-text">
<div class="title-text">
<span class="title-text-text" :title="$t('certifiedEngineer')">{{$t('certifiedEngineer')}}</span>
</div>
<a-form-model-item class="itemModel-multi" :prop="'certificationEngineerName'">
<PersonnelSelection
:query="{db_field_name:'certificationEngineer',db_field_txt:$t('certifiedEngineer')}"
:personneQuery="formInline"
v-if="visible"
@change="PersonnelSelectionChange"
:disabled="disabled"
v-model="formInline.certificationEngineerName"/>
</a-form-model-item>
</div>
</a-col>
</a-row>
<a-row :gutter="24">
<a-col :span="12">
<div class="box-title-text">
<div class="title-text">
<span class="title-text-text" :title="$t('DigitalPlatform')">{{$t('DigitalPlatform')}}</span>
</div>
<a-form-model-item class="itemModel" :prop="'digitalPlatform'">
<a-input class="box-input"
:disabled="disabled"
v-model="formInline.digitalPlatform"
:placeholder="$t('PleaseEnter')+$t('DigitalPlatform')"/>
</a-form-model-item>
</div>
</a-col>
<a-col :span="12">
<div class="box-title-text">
<div class="title-text">
<span class="title-text-text" :title="$t('ModelPlatform')">{{$t('ModelPlatform')}}</span>
</div>
<a-form-model-item class="itemModel" prop="vehiclePlatform">
<a-input class="box-input"
:disabled="disabled"
v-model="formInline.vehiclePlatform"
:placeholder="$t('PleaseEnter')+$t('ModelPlatform')"/>
</a-form-model-item>
</div>
</a-col>
</a-row>
<a-row :gutter="24">
<a-col :span="12">
<div class="box-title-text">
<div class="title-text">
<span class="title-text-text"
:title="$t('softwareVersion')">{{$t('softwareVersion')}}</span>
</div>
<a-form-model-item class="itemModel" :prop="'softwareVersion'">
<a-input class="box-input"
:disabled="disabled"
v-model="formInline.softwareVersion"
:placeholder="$t('PleaseEnter')+$t('softwareVersion')"/>
</a-form-model-item>
</div>
</a-col>
<a-col :span="12">
<div class="box-title-text">
<div class="title-text">
<span class="title-text-text"
:title="$t('dehicleDevelopmentPlan')">{{$t('dehicleDevelopmentPlan')}}</span>
</div>
<a-form-model-item class="itemModel" :prop="'vehicleDevelopmentPlan'">
<a-input class="box-input"
:disabled="disabled"
v-model="formInline.vehicleDevelopmentPlan"
:placeholder="$t('PleaseEnter')+$t('dehicleDevelopmentPlan')"/>
</a-form-model-item>
</div>
</a-col>
</a-row>
<a-row :gutter="24">
<a-col :span="12">
<div class="box-title-text">
<div class="title-text">
<span class="title-text-text" :title="$t('certificationProgram')">{{$t('certificationProgram')}}</span>
</div>
<a-form-model-item class="itemModel" prop="attestationPlan">
<a-input class="box-input"
:disabled="disabled"
v-model="formInline.attestationPlan"
:placeholder="$t('PleaseEnter')+$t('certificationProgram')"/>
</a-form-model-item>
</div>
</a-col>
<a-col :span="12">
<div class="box-title-text">
<div class="title-text">
<span class="title-text-text"
:title="$t('configurationInformation')">{{$t('configurationInformation')}}</span>
</div>
<a-form-model-item class="itemModel" prop="ipdInfo">
<a-input class="box-input"
:disabled="disabled"
v-model="formInline.ipdInfo"
:placeholder="$t('PleaseEnter')+$t('configurationInformation')"/>
</a-form-model-item>
</div>
<!-- ^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&amp;%\$#_]*)?$
-->
</a-col>
</a-row>
<a-row :gutter="24">
<a-col :span="24">
<div class="box-title-text">
<div class="title-text">
<span class="title-text-text" :title="$t('explain')">{{$t('explain')}}</span>
</div>
<a-form-model-item class="itemModel" prop="explanation">
<a-textarea :placeholder="$t('pleaseEnter')+$t('explain')"
v-model="formInline.explanation"
:rows="4"/>
</a-form-model-item>
</div>
</a-col>
</a-row>
</a-form-model>
</a-spin>
<div class="drawer-bootom-button">
<a-button style="margin-right: .8rem" @click="handleCancel">{{$t('cancel')}}</a-button>
<a-button @click="handleSubmit" type="primary" :loading="confirmLoading">{{$t('submit')}}</a-button>
</div>
</a-drawer>
</template>
<script>
import PersonnelSelection from '@/components/PersonnelSelection/index'
import { getAction, postAction, downloadFile, putAction } from '@/api/manage'
import { mapGetters } from 'vuex'
export default {
name: 'addModel',
components: {
PersonnelSelection
},
props: ['url'],
data() {
return {
formInline: {},
confirmLoading: false,
visible: false,
yearNameDataList: [],
rules: {
ipdInfo: [
{
pattern: /(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&amp;%$#_]*)?/,
message: this.$t('pleaseEnterTheCorrectWebAddress')
},
{
max: 300,
message: this.$t('configurationInformation') + this.$t('cannotExceed') + 300 + this.$t('Characters'),
trigger: 'blur'
}
],
vehicleDevelopmentPlan: [
{
pattern: /(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&amp;%$#_]*)?/,
message: this.$t('pleaseEnterTheCorrectWebAddress')
},
{
max: 300,
message: this.$t('dehicleDevelopmentPlan') + this.$t('cannotExceed') + 300 + this.$t('Characters'),
trigger: 'blur'
}
],
explanation: [
{
max: 500,
message: this.$t('explain') + this.$t('cannotExceed') + 500 + this.$t('Characters'),
trigger: 'blur'
}
],
attestationPlan: [
{
pattern: /(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&amp;%$#_]*)?/,
message: this.$t('pleaseEnterTheCorrectWebAddress')
},
{
max: 300,
message: this.$t('certificationProgram') + this.$t('cannotExceed') + 300 + this.$t('Characters'),
trigger: 'blur'
}
],
vehiclePlatform: [
{
max: 100,
message: this.$t('ModelPlatform') + this.$t('cannotExceed') + 100 + this.$t('Characters'),
trigger: 'blur'
}
],
digitalPlatform: [
{
max: 100,
message: this.$t('DigitalPlatform') + this.$t('cannotExceed') + 100 + this.$t('Characters'),
trigger: 'blur'
}
],
softwareVersion: [
{
max: 300,
message: this.$t('softwareVersion') + this.$t('cannotExceed') + 300 + this.$t('Characters'),
trigger: 'blur'
}
],
projectNameId: [
{
required: true,
message: this.$t('entryName') + this.$t('cannotEmpty'),
trigger: 'change'
}
],
yearNameId: [
{
required: true,
message: this.$t('modelYear') + this.$t('cannotEmpty'),
trigger: 'change'
}
],
targetMarket: [
{
required: true,
message: this.$t('targetMarket') + this.$t('cannotEmpty'),
trigger: 'change'
}
],
projectStatus: [
{
required: true,
message: this.$t('projectStatus') + this.$t('cannotEmpty'),
trigger: 'change'
}
],
studioEngineerName: [
{
required: true,
message: this.$t('StudioEngineer') + this.$t('cannotEmpty'),
trigger: 'change'
},
{
max: 100,
message: this.$t('StudioEngineer') + this.$t('cannotExceed') + 100 + this.$t('Characters'),
trigger: 'change'
}
],
certificationEngineerName: [
{
max: 100,
message: this.$t('certifiedEngineer') + this.$t('cannotExceed') + 100 + this.$t('Characters'),
trigger: 'change'
}
]
},
disabled: false,
projectNameList: [],
title: ''
}
},
mounted() {
this.getNameList()
},
methods: {
...mapGetters(['userInfo']),
getNameList(value) {
getAction('project/projectNameInfoEO/list', {}).then((res) => {
if (res.success) {
this.projectNameList = res.result || []
if (this.title == this.$t('edit')) {
let content = this.projectNameList.filter(res => {
return res.id == value.projectNameId
})
this.yearNameDataList = content[0].yearNameDataList || []
this.formInline = value
this.formInline = { ...this.formInline }
}
} else {
this.projectNameList = []
}
})
},
addModel() {
this.visible = true
this.title = this.$t('add')
this.formInline = {}
this.getNameList()
this.formInline.studioEngineerName = this.userInfo().username
this.formInline.studioEngineer = this.userInfo().id
this.formInline.projectVersion = '00'
this.formInline = { ...this.formInline }
this.$nextTick(() => {
this.$refs.ruleForm.clearValidate()
})
},
editModel(value) {
this.visible = true
this.title = this.$t('edit')
this.getNameList(value)
this.$nextTick(() => {
this.$refs.ruleForm.clearValidate()
})
},
handleCancel() {
this.visible = false
},
handleSubmit() {
this.$refs.ruleForm.validate(valid => {
if (valid) {
let url = ''
let Action
if (this.formInline.id) {
url = this.url.edit
Action = putAction
} else {
url = this.url.add
Action = postAction
}
let query = JSON.parse(JSON.stringify(this.formInline))
Object.keys(query).forEach(res => {
if (query[res] && query[res] instanceof Array) {
query[res] = query[res].join(',')
}
})
this.confirmLoading = true
Action(url, query).then((res) => {
if (res.success) {
this.confirmLoading = false
this.$message.success(this.$t('OperationSuccessful'))
this.visible = false
this.$emit('addModelList')
} else {
this.$message.warning(res.message)
this.confirmLoading = false
}
})
}
})
},
handleInput(value) {
this.$nextTick(() => {
this.formInline = { ...this.formInline }
this.$refs.ruleForm.validateField([value])
})
},
PersonnelSelectionChange(value, id) {
this.formInline[value] = id
this.formInline = { ...this.formInline }
},
projectNameChange(value) {
this.formInline.yearNameId = undefined
let content = this.projectNameList.filter(res => {
return res.id == value
})
this.formInline.vehiclePlatform = content[0].vehiclePlatform || ''
this.yearNameDataList = content[0].yearNameDataList || []
this.formInline.digitalPlatform = content[0].digitalPlatform || ''
this.formInline = { ...this.formInline }
}
}
}
</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;
}
</style>
<style scoped>
.box-title-text {
line-height: 1.4;
display: flex;
/*align-items: center;*/
}
.title-text {
width: 114px;
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: 48px;
}
.box-input {
display: inline-block;
height: 38px;
width: 100%;
}
.itemModel {
width: calc(100% - 130px);
display: inline-block;
margin-top: 2px;
height: 40px;
margin-bottom: 24px;
}
.Required {
color: red;
margin-right: 4px;
}
.title-text-text {
margin-top: 9px;
}
.formAdd {
margin-bottom: 40px;
}
.drawer-bootom-button {
position: absolute;
bottom: 0;
width: 100%;
border-top: 1px solid #e8e8e8;
padding: 10px 16px;
text-align: right;
left: 0;
z-index: 100;
background: #fff;
border-radius: 0 0 2px 2px;
}
</style>
<style>
.ant-input-disabled {
color: rgba(0, 0, 0, 0.65) !important;
}
</style>