Commit c2d9aa73 authored by 骆瑛's avatar 骆瑛

修改数据字典编辑新增重复

parent cd65df1b
......@@ -23,4 +23,7 @@ export default {
getallanditems() {
return api.get(u('getallanditems'))
},
list(paras) {
return api.post(u('list'), paras)
},
}
\ No newline at end of file
......@@ -260,10 +260,12 @@ export default {
},
async loadDictionary() {
let r = await api.getallanditems();
this.dictionaryItems = r.result.filter((u) => {
return u.items && u.items.length > 0;
});
this.completeList = this.dictionaryItems;
if (r.result.length > 0) {
this.dictionaryItems = r.result.filter((u) => {
return u.items && u.items.length > 0;
});
this.completeList = this.dictionaryItems;
}
},
handleSearch(v) {
if (v == "") {
......@@ -281,30 +283,17 @@ export default {
},
introduceBtn() {
if (this.dictionaryId != "") {
// console.log(this.dictionaryId);
let p = this.completeList.filter((v) => {
return v.code == this.dictionaryId;
});
if (p.items && p.items.length > 0) {
p.items.map((u) => {
if (p[0].items && p[0].items.length > 0) {
p[0].items.map((u) => {
delete u.id;
delete u.upId;
this.entity.items.push(u);
});
this.completeValue = "";
}
this.completeList.map((item, index) => {
if (item.code == this.dictionaryId) {
// this.replceList.push(item);
// item.items.map((element) => {
// this.parentList.push(element);
// });
this.completeList.splice(index, 1);
}
// this.parentList.forEach((u) => {
// u.parentCode = this.dictionaryId;
// });
});
// console.log(this.parentList);
}
},
changeName(row, index) {
......@@ -325,32 +314,6 @@ export default {
},
remove(row, index) {
this.entity.items.splice(index, 1);
// console.log(this.replceList);
// if (this.parentList.length > 0) {
// var nameCode = "";
// this.parentList.map((p) => {
// this.entity.items.map((r, index) => {
// if (p.parentCode != r.code) {
// nameCode = r.code;
// }
// console.log(r);
// });
// });
// }
// this.parentList.map((team, index) => {
// if (team.parentCode == nameCode) {
// this.parentList.splice(index, 1);
// }
// });
// debugger;
// this.replceList.map((k) => {
// if (nameCode == k.code) {
// console.log(k);
// this.completeList.push(k);
// }
// });
// }
// console.log(this.completeList);
},
async setColor(col, name, i, row) {
if (name == "color") {
......@@ -374,14 +337,12 @@ export default {
return (flag = true);
}
});
if (this.entity.items.length >= 2) {
for (let a = 0; a < this.entity.items.length; a++) {
for (let b = 1; b <= this.entity.items.length; b++) {
if (this.entity.items[a].code == this.entity.items[b].code) {
this.$Message.error("编码不能重复!");
flag = true;
return;
}
for (var i = 0; i < this.entity.items.length - 1; i++) {
for (var j = i + 1; j < this.entity.items.length; j++) {
if (this.entity.items[i].code === this.entity.items[j].code) {
this.$Message.error("编码不能重复!");
flag = true;
return;
}
}
}
......
......@@ -13,7 +13,14 @@
<Row class="rowTitle100">
<FormItem label="名称" prop="name">
<Input v-model="entity.name">
<ColorPicker v-model="entity.color" slot="prepend" transfer size="small" transfer recommend />
<ColorPicker
v-model="entity.color"
slot="prepend"
transfer
size="small"
transfer
recommend
/>
</Input>
</FormItem>
</Row>
......@@ -23,8 +30,8 @@
</FormItem>
</Row>
<Row class="rowTitle100">
<FormItem label="图标" prop="icon">
<InputIcon v-model="entity.icon"></InputIcon>
<FormItem label="图标" prop="icon">
<InputIcon v-model="entity.icon"></InputIcon>
</FormItem>
</Row>
<FormItem label="状态" prop="number">
......@@ -51,55 +58,85 @@
</Form>
</template>
<script>
import api from "../api.js";
export default {
name: 'Edit',
name: "Edit",
data() {
const changeCode = (rule, value, callback) => {
if (value === "") {
callback(new Error("请填写编码"));
} else {
if (this.entity.upId) {
let par = {
conditions: [
{
fieldName: "upId",
conditionalType: "Equal",
fieldValue: this.entity.upId,
},
{
fieldName: "code",
conditionalType: "Equal",
fieldValue: this.entity.code,
},
],
};
let flag = false;
api.list(par).then((r) => {
if (r.result.length >= 1) {
callback(new Error("编码不可重复"));
}else{
callback();
}
});
}
}
};
return {
entity: {
color:""
color: "",
},
rules: {
name: [{ required: true, message: '必填', trigger: 'blur' }],
code: [{ required: true, message: '必填', trigger: 'blur' }]
}
}
name: [{ required: true, message: "必填", trigger: "blur" }],
code: [{ validator: changeCode, trigger: "blur" }],
},
};
},
props: {
v: Object
v: Object,
},
mounted(){
this.entity = this.v
if(!this.entity.color){
this.entity.color="";
}
mounted() {
this.entity = this.$u.clone(this.v);
if (!this.entity.color) {
this.entity.color = "";
}
},
methods: {
handleSubmit() {
this.$refs.form.validate((v) => {
if (v) {
var url2 = `${systemUrl}/Dictionary/createorupdate`
var url2 = `${systemUrl}/Dictionary/createorupdate`;
this.$api.post(url2, { Dictionary: this.entity }).then((r) => {
if (r.success) {
this.$Message.success('保存成功')
this.$emit('on-ok')
this.$Message.success("保存成功");
this.$emit("on-ok");
}
})
});
}
})
});
},
handleClose() {
this.$emit('on-close')
}
this.$emit("on-close");
},
},
watch: {
v(v) {
this.entity = this.v
if(!this.entity.color){
this.entity.color="";
}
console.info(this.entity)
}
}
}
// this.entity = this.v;
// if (!this.entity.color) {
// this.entity.color = "";
// }
// console.info(this.entity);
},
},
};
</script>
......@@ -358,6 +358,7 @@ export default {
// },
//右键点击事件
contextmenu: (e, v, a) => {
debugger;
e.preventDefault();
this.$refs.contentMenu.$refs.reference = event.target;
this.$refs.contentMenu.currentVisible = !this.$refs
......@@ -549,6 +550,7 @@ export default {
this.data.pop();
},
save() {
console.log(this.node);
if (this.cur.name == "") {
this.$Message.error("名称不能为空");
return;
......@@ -557,21 +559,40 @@ export default {
this.$Message.error("值不能为空");
return;
}
for (let a = 0; a < this.data.length; a++) {
for (let b = 1; b < this.data.length; b++) {
if (this.data[a].code == this.data[b].code) {
this.$Message.error("编码不能重复");
return;
if (this.node) {
let par = {
conditions: [
{
fieldName: "upId",
conditionalType: "Equal",
fieldValue: this.node.id,
},
],
};
let flag = false;
api.list(par).then((r) => {
console.log(r.result);
if (r.result.length > 0) {
r.result.map((z) => { console.log(z.code, this.cur.code)
if (z.code == this.cur.code) {
this.$Message.error("编码不能重复!");
flag = true
return ;
}
});
if (flag == false) {
api.save(this.cur).then((r) => {
if (r.success) {
this.$Message.success("添加成功");
this.load();
}
});
}
}
}
});
}
api.save(this.cur).then((r) => {
// console.warn(r);
if (r.success) {
this.$Message.success("添加成功");
this.load();
}
});
},
},
};
......
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