mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-13 12:56:45 +08:00
fix:路径图和项目编辑时原名字显示冲突问题
This commit is contained in:
@@ -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("名称重复");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user