|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <m-dialog :title="`${itemData ? '编辑' : '新增'}字典`" ref="dialog" @sure="onSure">
|
|
|
+ <m-dialog title="字典配置" ref="dialog" @sure="onSure">
|
|
|
<m-form ref="form" :items="formItems" v-model="formValues" v-loading="loading">
|
|
|
<template #dictTitle>
|
|
|
<el-tag>{{ formValues.dictTitle }}</el-tag>
|
|
@@ -16,17 +16,24 @@
|
|
|
>
|
|
|
<template #dictTitle="{ $index }">
|
|
|
<el-form-item :prop="`items.${$index}.dictTitle`" :rules="{ required: true, trigger: 'blur' }">
|
|
|
- <el-input placeholder="字典项名称" v-model="formValues.items[$index].dictTitle"></el-input>
|
|
|
+ <el-input placeholder="字典项名称" v-model="formValues.items[$index].dictTitle" clearable></el-input>
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
<template #dictValue="{ $index }">
|
|
|
<el-form-item :prop="`items.${$index}.dictValue`" :rules="{ required: true, trigger: 'blur' }">
|
|
|
- <el-input placeholder="字典项值" v-model="formValues.items[$index].dictValue"></el-input>
|
|
|
+ <el-input placeholder="字典项值" v-model="formValues.items[$index].dictValue" clearable></el-input>
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
<template #dictColor="{ $index }">
|
|
|
- <el-form-item :prop="`items.${$index}.dictColor`" :rules="{ required: true, trigger: 'blur' }">
|
|
|
- <el-input placeholder="色值" v-model="formValues.items[$index].dictColor"></el-input>
|
|
|
+ <el-form-item :prop="`items.${$index}.dictColor`">
|
|
|
+ <el-select placeholder="色值" v-model="formValues.items[$index].dictColor" clearable>
|
|
|
+ <el-option
|
|
|
+ v-for="item in options"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
<template #actions="{ $index }">
|
|
@@ -43,14 +50,41 @@
|
|
|
|
|
|
<script>
|
|
|
import {
|
|
|
- getDictionariesDetails
|
|
|
+ getDictionariesDetails,
|
|
|
+ saveDictionaries
|
|
|
} from '@/api/system'
|
|
|
export default {
|
|
|
name: 'dictionariesEdit',
|
|
|
data () {
|
|
|
return {
|
|
|
loading: false,
|
|
|
- itemData: null,
|
|
|
+ options: [
|
|
|
+ {
|
|
|
+ value: 'orange',
|
|
|
+ label: 'orange'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 'primary',
|
|
|
+ label: 'primary'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 'success',
|
|
|
+ label: 'success'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 'info',
|
|
|
+ label: 'info'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 'warning',
|
|
|
+ label: 'warning'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 'danger',
|
|
|
+ label: 'danger'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ itemData: {},
|
|
|
headers: [
|
|
|
{ label: '字典项名称', prop: 'dictTitle' },
|
|
|
{ label: '字典项值', prop: 'dictValue' },
|
|
@@ -72,9 +106,9 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
async open (item) {
|
|
|
- this.itemData = item ?? null
|
|
|
+ this.itemData = item
|
|
|
this.formValues = {
|
|
|
- dictTitle: item?.dictTitle ?? null,
|
|
|
+ dictTitle: item.dictTitle,
|
|
|
items: [
|
|
|
{ dictTitle: null, dictValue: null, dictColor: null }
|
|
|
]
|
|
@@ -91,7 +125,7 @@ export default {
|
|
|
this.formValues.items = data.map(e => ({
|
|
|
dictTitle: e.dictTitle,
|
|
|
dictValue: e.dictValue,
|
|
|
- dictColor: null
|
|
|
+ ...e.webContent
|
|
|
}))
|
|
|
} catch (error) {
|
|
|
this.$message.error(error)
|
|
@@ -110,8 +144,33 @@ export default {
|
|
|
this.formValues.items.splice(index, 1)
|
|
|
},
|
|
|
onSure () {
|
|
|
- this.$refs.form.validate(valid => {
|
|
|
- console.log(valid)
|
|
|
+ this.$refs.form.validate(async valid => {
|
|
|
+ if (!valid) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.loading = true
|
|
|
+ try {
|
|
|
+ await saveDictionaries({
|
|
|
+ dictCode: this.itemData.dictValue,
|
|
|
+ level: 1,
|
|
|
+ itemReqVoList: this.formValues.items.map(e => {
|
|
|
+ return {
|
|
|
+ dictTitle: e.dictTitle,
|
|
|
+ dictValue: e.dictValue,
|
|
|
+ webContent: {
|
|
|
+ dictColor: e.dictColor
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ this.$message.success('保存成功')
|
|
|
+ this.$refs.dialog.close()
|
|
|
+ this.$emit('success')
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ } finally {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
}
|