irc_web/src/views/dictionary/template/sign/components/SceneConfigForm.vue

98 lines
2.9 KiB
Vue

<template>
<el-form
ref="sceneConfigForm"
v-loading="loading"
:model="form"
label-width="160px"
size="small"
:rules="rules"
>
<div class="base-dialog-body">
<el-form-item :label="$t('dictionary:sign:label:code')" prop="Code">
<el-input v-model="form.Code" />
</el-form-item>
<el-form-item :label="$t('dictionary:sign:label:sceneType')" prop="Name">
<el-input v-model="form.Name" />
</el-form-item>
<el-form-item :label="$t('dictionary:sign:label:value')" prop="Value">
<el-input v-model="form.Value" type="textarea" rows="5" />
</el-form-item>
<el-form-item :label="$t('dictionary:sign:label:valueCN')" prop="ValueCN">
<el-input v-model="form.ValueCN" type="textarea" rows="5" />
</el-form-item>
</div>
<div class="base-dialog-footer" style="text-align:right;margin-top:10px;">
<el-form-item style="text-align:right;">
<el-button size="small" type="primary" :disabled="form.Type === '' || form.Name === ''" :loading="saveBtnLoading" @click="handleSave">{{ $t('common:button:save') }}</el-button>
</el-form-item>
</div>
</el-form>
</template>
<script>
import { addOrUpdateSystemBasicData } from '@/api/dictionary'
export default {
props: {
data: {
type: Object,
default() { return {} }
},
parentId: {
type: String,
required: true
}
},
data() {
return {
form: {
Id: '',
Code: '',
Name: '',
Value: '',
ValueCN: '',
ParentId: ''
},
rules: {
Code: [{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: ['blur'] }],
Name: [{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: ['blur'] }],
Value: [{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: ['blur'] }],
ValueCN: [{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: ['blur'] }]
},
scenarioOption: [],
saveBtnLoading: false,
loading: false
}
},
mounted() {
this.initForm()
},
methods: {
async initForm() {
this.loading = true
for (const k in this.form) {
if (this.data.hasOwnProperty(k)) {
this.form[k] = this.data[k]
}
}
this.loading = false
},
// 保存
handleSave() {
this.$refs.sceneConfigForm.validate(valid => {
if (!valid) return
this.saveBtnLoading = true
this.form.ParentId = this.parentId
addOrUpdateSystemBasicData(this.form).then(res => {
this.saveBtnLoading = false
this.$emit('closeDialog')
this.$emit('getList')
this.$message.success(this.$t('common:message:savedSuccessfully'))
}).catch(() => {
this.saveBtnLoading = false
})
})
}
}
}
</script>