fix:路径图和项目编辑时原名字显示冲突问题

This commit is contained in:
wyx
2023-03-08 01:11:33 +08:00
parent 32601f080b
commit d78f47d795
3 changed files with 34 additions and 5 deletions

View File

@@ -5,12 +5,12 @@
:show-count="showCount"
:maxlength="maxlength"
/>
<div style="color: red; font-size: 10px" v-if="modelV.value && validated===0">
<div style="color: red; font-size: 10px" v-if="modelV.value && validated===0 && isExistName">
名称重复请重新输入
</div>
</template>
<script setup>
import {defineProps, defineEmits, watch, ref} from "vue";
import {defineProps, defineEmits, watch, ref, onMounted} from "vue";
import {validateName} from "@/api/index1";
import {Form} from "ant-design-vue";
@@ -39,7 +39,10 @@ const props = defineProps({
validated: {
type: Number,
default: 0,
}
},
onceName: {
type: String,
},
});
const emit = defineEmits(["update:value",'update:validated']);
@@ -48,6 +51,8 @@ const modelV = ref({
value: props.value
});
const isExistName = ref(true);
const rulesRef = ref({
value: [{
required: true,
@@ -60,7 +65,20 @@ const rulesRef = ref({
Form.useForm(modelV, rulesRef, { debounce: { wait: 800 } });
onMounted(() => {
if(props.onceName==modelV.value.value){
isExistName.value = false;
}else{
isExistName.value = true;
}
})
watch(props, () => {
if(props.onceName==modelV.value.value){
isExistName.value = false;
}else{
isExistName.value = true;
}
modelV.value.value = props.value;
});
@@ -74,7 +92,7 @@ async function validateValue() {
return Promise.reject("请输入名称");
}
return validateName({ name: modelV.value.value, type: props.type, id: props.id }).then(res => {
if (res.data.data === 1) {
if (res.data.data === 1 && isExistName.value) {
emit("update:validated", 0);
return Promise.reject("名称重复");
}