Commit f0dea7db authored by 仇晓婷's avatar 仇晓婷

数据字典

parent 8a3ea4fa
<template>
<Form ref="form" :model="entity" :rules="rules" :label-width="100">
<Row class="rowTitle100">
<FormItem label="类别" prop="typeId">
<RadioGroup v-model="entity.typeId">
<Radio :label="0" disabled>系统</Radio>
<Radio :label="1" disabled>分类</Radio>
<Radio :label="2" disabled>字典</Radio>
<Radio :label="3" disabled>字典项</Radio>
</RadioGroup>
</FormItem>
</Row>
<Row class="rowTitle100">
<FormItem label="名称" prop="name">
<Input v-model="entity.name">
<ColorPicker
v-model="entity.color"
slot="prepend"
transfer
size="small"
transfer
recommend
/>
</Input>
</FormItem>
</Row>
<Row class="rowTitle100">
<FormItem label="编码" prop="code">
<Input v-model="entity.code" />
</FormItem>
</Row>
<Row class="rowTitle100">
<FormItem label="图标" prop="icon">
<InputIcon v-model="entity.icon"></InputIcon>
</FormItem>
</Row>
<FormItem label="状态" prop="number">
<RadioGroup v-model="entity.status">
<Radio :label="0">启用</Radio>
<Radio :label="1">禁用(名称和值可以启用或禁用,但不能删除)</Radio>
</RadioGroup>
</FormItem>
<FormItem label="锁定" prop="number">
<RadioGroup v-model="entity.isStatic">
<Radio :label="0">不锁定</Radio>
<Radio :label="1">锁定(锁定后不可改变名称和值,不能删除)</Radio>
</RadioGroup>
</FormItem>
<Row class="rowTitle100">
<FormItem label="描述" prop="description">
<Input v-model="entity.description" type="textarea" :rows="3"></Input>
</FormItem>
</Row>
<FormItem>
<Button type="primary" @click="handleSubmit">保存</Button>
<Button @click="handleClose" class="ml20">取消</Button>
<div>
{{v}}
</div>
</FormItem>
</Form>
</template>
<script>
import api from "../api.js";
export default {
name: "Edit",
data() {
return {
entity: {
upId: 0,
typeId: this.v.typeId,
status: 0,
isStatic: 0,
priority:0,
color:"",
},
rules: {
name: [{ required: true, message: "必填", trigger: "blur" }],
code: [{ required: true, message: "必填", trigger: "blur" }],
},
};
},
props: ["v"],
mounted() {
if (this.v.id) {
this.entity.typeId = this.v.typeId + 1;
this.entity.upId = this.v.id;
}
},
methods: {
handleSubmit() {
this.$refs.form.validate((v) => {
if (v) {
api.save(this.entity).then((r) => {
console.warn(r);
if (r.success) {
this.$Message.success("添加成功");
this.$emit("on-ok");
}
});
}
});
},
handleClose() {
this.$emit("on-close");
},
},
watch: {
},
};
</script>
......@@ -55,7 +55,9 @@ export default {
name: 'Edit',
data() {
return {
entity: this.v,
entity: {
color:""
},
rules: {
name: [{ required: true, message: '必填', trigger: 'blur' }],
code: [{ required: true, message: '必填', trigger: 'blur' }]
......@@ -65,6 +67,13 @@ export default {
props: {
v: Object
},
mounted(){
this.entity = this.v
if(!this.entity.color){
this.entity.color="";
}
},
methods: {
handleSubmit() {
this.$refs.form.validate((v) => {
......@@ -86,6 +95,9 @@ export default {
watch: {
v(v) {
this.entity = this.v
if(!this.entity.color){
this.entity.color="";
}
console.info(this.entity)
}
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment