Files
laws_weilai/jero-web/src/views/businessSupport/problemKnowledgeBase/components/countryCardReleaseModelAdd.vue
T
2022-08-09 14:07:10 +08:00

349 lines
11 KiB
Java

<template>
<div>
<a-modal
:title="title"
:width="700"
: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('LabelName')">{{$t('LabelName')}}</span>
</div>
<a-form-model-item class="itemModel" prop="lableName">
<a-input class="box-input"
:disabled="disabled"
v-model="formInline.lableName"
:placeholder="$t('PleaseEnter')+$t('LabelName')"/>
</a-form-model-item>
</div>
</a-col>
</a-row>
<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('LabelType')">{{$t('LabelType')}}</span>
</div>
<a-form-model-item class="itemModel" prop="lableType">
<a-select :placeholder="$t('PleaseSelect')+$t('LabelType')"
:disabled="lableTypeDisabled"
@change="lableTypeChange"
v-model="formInline.lableType">
<a-select-option v-for="(item, key) in lableTypeList"
:key="key"
:value="item.value">
<span style="display: inline-block;width: 100%" :title=" item.name ">
{{ item.name}}
</span>
</a-select-option>
</a-select>
</a-form-model-item>
</div>
</a-col>
</a-row>
<a-row :gutter="24" v-if="isDisplay">
<a-col :span="24">
<div class="box-title-text">
<div class="title-text">
<span class="title-text-text"
:title="$t('dropDownOptions')">{{$t('dropDownOptions')}}</span>
</div>
<a-form-model-item class="itemModel" prop="dropDownOptions">
<a-button class="submit" @click="dropDownOptionsClick" type="primary">
{{$t('dropDownOptionMaintenance')}}
</a-button>
</a-form-model-item>
</div>
</a-col>
</a-row>
<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('DisplayOrder')">{{$t('DisplayOrder')}}</span>
</div>
<a-form-model-item class="itemModel" prop="orderNum">
<a-input-number class="box-input"
:disabled="disabled"
v-model="formInline.orderNum"
:placeholder="$t('PleaseEnter')+$t('DisplayOrder')"/>
</a-form-model-item>
</div>
</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('associatedWebsite')">{{$t('associatedWebsite')}}</span>
</div>
<a-form-model-item class="itemModel" prop="relevantUrl">
<a-input class="box-input"
:disabled="disabled"
v-model="formInline.relevantUrl"
:placeholder="$t('PleaseEnter')+$t('associatedWebsite')"/>
</a-form-model-item>
</div>
</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('describe')">{{$t('describe')}}</span>
</div>
<a-form-model-item class="itemModel" prop="description">
<a-textarea
:placeholder="$t('PleaseEnter')+$t('describe')"
:disabled="disabled"
v-model="formInline.description" :rows="4"/>
</a-form-model-item>
</div>
</a-col>
</a-row>
</a-form-model>
</a-modal>
<optionMaintenance ref="optionMaintenanceRef"/>
</div>
</template>
<script>
import { getAction, postAction, downloadFile, deleteAction } from '@/api/manage'
import optionMaintenance from './optionMaintenance'
export default {
name: 'countryCardReleaseModelAdd',
components: {
optionMaintenance
},
data() {
return {
visible: false,
disabled: false,
confirmLoading: false,
formInline: {},
lableTypeDisabled: false,
isDisplay: false,
lableTypeList: [
{
name: this.$t('optionDropDownBox'),
value: '3'
},
{
name: this.$t('attachmentUpload'),
value: '7'
},
{
name: this.$t('textInput'),
value: '8'
}
],
rules: {
lableName: [
{
required: true,
message: this.$t('LabelName') + this.$t('cannotEmpty'),
trigger: 'blur'
},
{
max: 100,
message: this.$t('LabelName') + this.$t('cannotExceed') + 100 + this.$t('Characters'),
trigger: 'blur'
}
],
lableType: [
{
required: true,
message: this.$t('LabelType') + this.$t('cannotEmpty'),
trigger: 'change'
}
],
orderNum: [
{
required: true,
message: this.$t('DisplayOrder') + this.$t('cannotEmpty'),
trigger: 'blur'
}
],
relevantUrl: [
{
max: 100,
message: this.$t('associatedWebsite') + this.$t('cannotExceed') + 100 + this.$t('Characters'),
trigger: 'blur'
}
],
description: [
{
max: 300,
message: this.$t('describe') + this.$t('cannotExceed') + 300 + this.$t('Characters'),
trigger: 'blur'
}
]
},
title: '',
dropDownOptionsId: '',
url: {
add: '/problemKnowledgeBase/countryCardTempEO/add',
edit: '/problemKnowledgeBase/countryCardTempEO/edit',
deleteOne: '/problemKnowledgeBase/countryCardTempItemEO/deleteByCountryCardTempId'
}
}
},
mounted() {
},
methods: {
lableTypeChange(event) {
if (event == 3) {
this.isDisplay = true
} else {
this.isDisplay = false
}
},
getUUID() {
var str = []
var Chars = '0123456789abcdefghijklmnopqrstuvwxyz'
for (var i = 0; i < 36; i++) {
str[i] = Chars.substr(Math.floor(Math.random() * 16), 1)
}
str[0] = str[8] = str[13] = str[18] = str[23] = '-'
return str.join('')
},
dropDownOptionsClick() {
if (!this.dropDownOptionsId) {
this.dropDownOptionsId = this.getUUID()
}
this.$refs.optionMaintenanceRef.getData(this.dropDownOptionsId)
},
add() {
this.visible = true
this.isDisplay = false
this.title = this.$t('addLabel')
this.dropDownOptionsId = ''
this.lableTypeDisabled = false
this.$nextTick(() => {
this.formInline = {}
this.$refs.ruleForm.clearValidate()
})
},
edit(data) {
this.visible = true
this.title = this.$t('editLabel')
this.lableTypeDisabled = true
this.$nextTick(() => {
this.formInline = data
this.dropDownOptionsId = this.formInline.id
if (this.formInline.lableType == 3) {
this.isDisplay = true
} else {
this.isDisplay = false
}
this.$refs.ruleForm.clearValidate()
})
},
PersonnelSelectionChange(value, id) {
this.formInline[value] = id
this.formInline = { ...this.formInline }
},
handleOk() {
this.$refs.ruleForm.validate(valid => {
if (valid) {
let url = ''
if (this.formInline.id) {
url = this.url.edit
} else {
url = this.url.add
if (this.formInline.lableType == 3) {
this.formInline.id = this.dropDownOptionsId
}
}
this.confirmLoading = true
postAction(url, this.formInline).then((res) => {
if (res.success) {
this.$message.success(this.$t('OperationSuccessful'))
this.visible = false
this.confirmLoading = false
this.$emit('countryCardReleaseModelAddForm')
} else {
this.confirmLoading = false
this.$message.warning(this.$t('operationFailed'))
}
})
}
})
},
handleCancel() {
this.visible = false
if (this.formInline.lableType == 3 && !this.formInline.id) {
deleteAction(this.url.deleteOne, { countryCardTempId: this.dropDownOptionsId }).then((res) => {
})
}
}
}
}
</script>
<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% - 130px);
display: inline-block;
margin-top: 2px;
}
.title-text-text {
margin-top: 9px;
}
.formAdd {
margin-bottom: 40px;
}
.Required {
color: red;
margin-right: 4px;
}
.submit {
height: 38px;
}
</style>