取消重复名称

This commit is contained in:
zhangsir
2024-02-26 16:14:56 +08:00
parent d9d0a644c8
commit 4c69f9b248
3 changed files with 45 additions and 41 deletions

View File

@@ -196,6 +196,7 @@
<span style="margin-top: 10px;width: 34px;">权重</span> <span style="margin-top: 10px;width: 34px;">权重</span>
<div style="display: flex;"> <div style="display: flex;">
<a-button v-if="index===0" shape="circle" class="btn-circle btn-add" @click="inputAdd">+</a-button> <a-button v-if="index===0" shape="circle" class="btn-circle btn-add" @click="inputAdd">+</a-button>
<a-button v-else shape="circle" class="btn-circle btn-add" @click="inputAdd"></a-button>
<a-button shape="circle" class="btn-circle" @click="inputRemove(index)" :disabled="formData.offteachers.length == 1"><template #icon><delete-outlined class="custom-icon"/></template></a-button> <a-button shape="circle" class="btn-circle" @click="inputRemove(index)" :disabled="formData.offteachers.length == 1"><template #icon><delete-outlined class="custom-icon"/></template></a-button>
</div> </div>
</div> </div>
@@ -738,7 +739,8 @@ const projectInfo = ref({});
const emit = defineEmits(['call-parent-method']); const emit = defineEmits(['call-parent-method']);
const confirm = async()=>{ const confirm = async()=>{
closeDrawer(); closeDrawer();
await api.getDraftTask({projectId: route.query.projectId}).then((res) => { if(route.query.projectId){
await api.getDraftTask({projectId: route.query.projectId}).then((res) => {
projectInfo.value = res.data.data projectInfo.value = res.data.data
}); });
request(PROJECT_DETAIL_MODIFY, { ...projectInfo.value }); request(PROJECT_DETAIL_MODIFY, { ...projectInfo.value });
@@ -746,6 +748,8 @@ const confirm = async()=>{
request(PROJECT_RELEASE, {projectId: route.query.projectId}) request(PROJECT_RELEASE, {projectId: route.query.projectId})
} }
emit('call-parent-method'); emit('call-parent-method');
}
} }
const createNewCourse = () => { const createNewCourse = () => {
@@ -861,14 +865,17 @@ async function coursePlanConfirm() {
formData.value.beginTime = dateTime.value[0] formData.value.beginTime = dateTime.value[0]
formData.value.endTime = dateTime.value[1] formData.value.endTime = dateTime.value[1]
await request(COURSE_PLAN_EDIT, { ...formData.value }); await request(COURSE_PLAN_EDIT, { ...formData.value });
await api.getDraftTask({projectId: route.query.projectId}).then((res) => { if(route.query.projectId){
projectInfo.value = res.data.data await api.getDraftTask({projectId: route.query.projectId}).then((res) => {
}); projectInfo.value = res.data.data
request(PROJECT_DETAIL_MODIFY, { ...projectInfo.value }); });
if(projectInfo.value.projectInfo.status==3){ request(PROJECT_DETAIL_MODIFY, { ...projectInfo.value });
request(PROJECT_RELEASE, {projectId: route.query.projectId}) if(projectInfo.value.projectInfo.status==3){
request(PROJECT_RELEASE, {projectId: route.query.projectId})
}
emit('call-parent-method');
} }
emit('call-parent-method');
handleCancelStu(); handleCancelStu();
tableRef.value.fetch(); tableRef.value.fetch();
} }

View File

@@ -8,12 +8,13 @@
@focus="onFocus" @focus="onFocus"
@blur="onBlur" @blur="onBlur"
/> />
<div style="color: red; font-size: 10px" v-if="modelV.value && validated===0 && isExistName"> <div style="color: blue; font-size: 10px" v-if="modelV.value && validated===0 && isExistName">
名称重复请重新输入 <!-- 名称重复请重新输入 -->
开课名称已自动带入请自行修改
</div> </div>
<div style="color: red; font-size: 10px" v-if="newNamess"> <!-- <div style="color: red; font-size: 10px" v-if="newNamess">
名称重复已自动生成不重复名称可自行修改 名称重复已自动生成不重复名称可自行修改
</div> </div> -->
</template> </template>
<script setup> <script setup>
import {defineProps, defineEmits, watch, ref, onMounted} from "vue"; import {defineProps, defineEmits, watch, ref, onMounted} from "vue";
@@ -86,31 +87,31 @@ onMounted(() => {
isExistName.value = true; isExistName.value = true;
} }
}) })
const newNamess = ref(false) const newNamess = ref(true)
const generateUniqueName = () => { // const generateUniqueName = () => {
let baseName = modelV.value.value; // let baseName = modelV.value.value;
let randomSuffix = '_' + Math.floor(Math.random() * 1000); // let randomSuffix = Math.floor(Math.random() * 1000);
let newName = baseName + randomSuffix; // let newName = baseName + randomSuffix;
emit("update:value", newName); // emit("update:value", newName);
newNamess.value = true // newNamess.value = true
} // }
const watchChange = ref(true) // const watchChange = ref(true)
const onFocus = ()=>{ // const onFocus = ()=>{
newNamess.value = false // newNamess.value = false
watchChange.value = false // watchChange.value = false
} // }
const onBlur = ()=>{ // const onBlur = ()=>{
watchChange.value = true // watchChange.value = true
} // }
watch(props,()=>{ // watch(props,()=>{
if(props.changeName){ // if(props.changeName){
if (watchChange.value && modelV.value.value && props.validated === 0 && isExistName.value) { // if (watchChange.value && modelV.value.value && props.validated === 0 && isExistName.value) {
generateUniqueName(); // generateUniqueName();
} // }
}else{ // }else{
newNamess.value = false // newNamess.value = false
} // }
},{immediate: true}) // },{immediate: true})
watch(props, () => { watch(props, () => {
if(props.onceName==modelV.value.value){ if(props.onceName==modelV.value.value){
isExistName.value = false; isExistName.value = false;

View File

@@ -5243,10 +5243,6 @@ export default {
coursePlanRef, coursePlanRef,
openCourse, openCourse,
exportScore, exportScore,
}; };
}, },
}; };