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("名称重复");
}

View File

@@ -335,6 +335,7 @@
v-model:validated="validated"
:maxlength="20"
show-count
:onceName="onceName"
:type="3"
:id="editPathId"
></NameInput>
@@ -824,6 +825,7 @@ export default {
//
//创建、编辑-------------------------
pathName: "", //创建/编辑路径图名称
onceName: "",
organizationList: [
// {
// id: 1,
@@ -903,6 +905,7 @@ export default {
// console.log("打开创建路径弹窗");
state.confirmLoading = false;
state.pathName = "";
state.onceName = "";
state.pathBg = "";
state.pathBgId = "";
state.pathIntro = "";
@@ -914,6 +917,7 @@ export default {
};
const handleOut1 = () => {
state.pathName = "";
state.onceName = "";
state.pathBg = "";
state.pathBgId = 1;
state.organizationSelectName = null;
@@ -1532,6 +1536,7 @@ export default {
console.log("获取学习路径详情成功", res.data.data);
let detail = res.data.data.routerInfo;
state.pathName = detail.name;
state.onceName = detail.name;
state.pathBg = detail.picUrl;
state.mobilePicUrl = detail.mobilePicUrl;
state.pathBgId = "";

View File

@@ -308,6 +308,7 @@
:type="1"
:maxlength="30"
show-count
:onceName="onceName"
:id="projectInfo.projectId"
></NameInput>
</div>
@@ -1029,6 +1030,7 @@ export default {
currentPage1: 1, //项目经理分页
pageSize1: 10,
projectInfo: {},
onceName:"",
projectClass: [],
managerList: [],
managerLoading: false,
@@ -1102,7 +1104,7 @@ export default {
message.warning("项目名称重复,请修改名称!");
return;
} */
const offName = await validateName({
const offName = state.projectInfo.name == state.onceName ? false : await validateName({
name: state.projectInfo.name,
type: 1,
id: state.projectInfo.projectId,
@@ -1126,6 +1128,7 @@ export default {
// 取消按钮 清空输入的数据
const closeModal2 = () => {
state.projectInfo = {};
state.onceName = "";
// value1.value = "";
// type = "";
// manager = "";
@@ -1565,6 +1568,7 @@ export default {
if (record.type === 1 || record.type === 2) {
state.doublepro = true;
state.projectInfo = record;
state.onceName = record.name;
} else {
router.push({
path: "/projectadd",
@@ -1591,6 +1595,7 @@ export default {
};
const showModal1 = () => {
state.projectInfo = {};
state.onceName = "";
state.estabish = true;
};
const closeModal1 = () => {
@@ -1692,6 +1697,7 @@ export default {
systemId: record.systemId,
type: 2,
};
state.onceName = "";
state.estabish = true;
}