添加传参方法

This commit is contained in:
宋文超
2022-11-17 16:26:17 +08:00
parent 429e8339c9
commit 5bd067c4d0
13 changed files with 1724 additions and 1491 deletions

View File

@@ -9,7 +9,7 @@
>
<div class="drawerMain">
<div class="header">
<div class="headerTitle">{{edit?'编辑':'添加'}}测评</div>
<div class="headerTitle">{{ edit ? "编辑" : "添加" }}测评</div>
<img
style="width: 29px; height: 29px; cursor: pointer"
src="../../assets/images/basicinfo/close.png"
@@ -48,16 +48,18 @@
<span style="margin-right: 3px">选择测评</span>
</div>
<div class="btnbox">
<button class="checkEval" @click="showEvalDrawer">选择测评</button>
<button class="checkEval" @click="showEvalDrawer">
选择测评
</button>
</div>
<div>
<div><EvList
v-model:EvalListVisible="EvalListVisible"
v-model:evaluationTypeId="evaluationTypeId"
v-model:evaluationTypeName="evaluationTypeName"
/>
</div>
<div>
<EvList
v-model:EvalListVisible="EvalListVisible"
v-model:evaluationTypeId="evaluationTypeId"
v-model:evaluationTypeName="evaluationTypeName"
/>
</div>
</div>
</div>
<div class="main_item">
@@ -78,8 +80,12 @@
<span style="margin-right: 3px">测评说明</span>
</div>
<div class="textarea">
<a-textarea v-model:value="description" placeholder="请输入测评说明" style="width:424px; height: 120px;" allowClear/>
<a-textarea
v-model:value="description"
placeholder="请输入测评说明"
style="width: 424px; height: 120px"
allowClear
/>
</div>
</div>
</div>
@@ -102,11 +108,11 @@ import * as api from "../../api/indexEval";
import * as apitaskadd from "../../api/indexTaskadd";
import { message } from "ant-design-vue";
import { RouterEditTask } from "@/api/indexTask";
import dayjs from 'dayjs';
import dayjs from "dayjs";
// const router = useRouter();
export default {
name: "AddEval",
components: {
components: {
EvList,
},
props: {
@@ -118,7 +124,8 @@ export default {
type: Number,
default: null,
},
edit: { // 是否为编辑
edit: {
// 是否为编辑
type: Boolean,
default: null,
},
@@ -134,11 +141,13 @@ export default {
type: Number,
default: 0,
},
isLevel: { // 是否是关卡页面触发
isLevel: {
// 是否是关卡页面触发
type: Number,
default: null,
},
projectTaskId: { // 要编辑的projectId
projectTaskId: {
// 要编辑的projectId
type: Number,
default: null,
},
@@ -157,10 +166,10 @@ export default {
inputV2: "",
time: undefined,
EvalId: null,
evaluationTypeId:null,
evaluationTypeName:"",
description:"",
EvalListVisible:false,
evaluationTypeId: null,
evaluationTypeName: "",
description: "",
EvalListVisible: false,
// addLoading:false,
});
@@ -169,67 +178,72 @@ export default {
ctx.emit("update:edit", false);
state.inputV1 = "";
state.inputV2 = "";
localStorage.setItem("stageId", props.chooseStageId);
localStorage.setItem("chapterId", props.isactive);
};
const afterVisibleChange = (bool) => {
if(props.edit && bool){
if (props.edit && bool) {
queryEval();
}
};
const showEvalDrawer = () =>{
const showEvalDrawer = () => {
state.EvalListVisible = true;
console.log("进来了吗");
};
const queryEval = () =>{
const queryEval = () => {
api
.queryEvaluationDetailById({evaluationId:props.evaluationId})
.then((res) => {
console.log("调用项目添加接口后", res.data.data);
state.inputV1 = res.data.data.evaluationName;
state.time = [dayjs(res.data.data.evaluationStartTime, "YYYY-MM-DD"), dayjs(res.data.data.evaluationEndTime, "YYYY-MM-DD")];
state.evaluationTypeId = res.data.data.evaluationTypeId;
state.evaluationTypeName =res.data.data.evaluationTypeName;
//state.description =
.queryEvaluationDetailById({ evaluationId: props.evaluationId })
.then((res) => {
console.log("调用项目添加接口后", res.data.data);
state.inputV1 = res.data.data.evaluationName;
state.time = [
dayjs(res.data.data.evaluationStartTime, "YYYY-MM-DD"),
dayjs(res.data.data.evaluationEndTime, "YYYY-MM-DD"),
];
state.evaluationTypeId = res.data.data.evaluationTypeId;
state.evaluationTypeName = res.data.data.evaluationTypeName;
//state.description =
})
.catch((err) => {
console.log(err);
});
}
const updateTask = (res)=>{
if(props.isLevel ==1){
};
const updateTask = (res) => {
if (props.isLevel == 1) {
apitaskadd
.addTask({
courseId: res.data.data.evaluationId,
name: res.data.data.evaluationName,
projectId: props.projectId,
projectTaskId: props.projectTaskId || 0,
stageId: props.chooseStageId,
type: 10,
})
.then((res) => {
console.log("调用项目添加接口后", res.data);
})
.catch((err) => {
console.log(err);
});
}else if(props.isLevel ==2){
.addTask({
courseId: res.data.data.evaluationId,
name: res.data.data.evaluationName,
projectId: props.projectId,
projectTaskId: props.projectTaskId || 0,
stageId: props.chooseStageId,
type: 10,
})
.then((res) => {
console.log("调用项目添加接口后", res.data);
})
.catch((err) => {
console.log(err);
});
} else if (props.isLevel == 2) {
RouterEditTask({
chapterId: props.isactive,
courseId: res.data.data.evaluationId,
name: res.data.data.evaluationName,
routerId: props.routerId,
routerTaskId: props.routerTaskId || 0,
type: 10,
}).then((res) => {
console.log("调用项目添加接口后", res.data);
}).catch((err) => {
console.log(err);
});
}else if(props.isLevel ==3){
console.log("模板库任务")
chapterId: props.isactive,
courseId: res.data.data.evaluationId,
name: res.data.data.evaluationName,
routerId: props.routerId,
routerTaskId: props.routerTaskId || 0,
type: 10,
})
.then((res) => {
console.log("调用项目添加接口后", res.data);
})
.catch((err) => {
console.log(err);
});
} else if (props.isLevel == 3) {
console.log("模板库任务");
}
}
};
//创建或编辑测评信息
const createEvalText = () => {
if (!state.inputV1) {
@@ -248,36 +262,36 @@ export default {
let obj = {
evaluationName: state.inputV1,
evaluationEndTime: dayjs(state.time[1]).format("YYYY-MM-DD"),
evaluationId: props.edit?props.evaluationId:0,
evaluationId: props.edit ? props.evaluationId : 0,
evaluationStartTime: dayjs(state.time[0]).format("YYYY-MM-DD"),
evaluationTypeId:state.evaluationTypeId,
evaluationTypeName:state.evaluationTypeName,
evaluationTypeId: state.evaluationTypeId,
evaluationTypeName: state.evaluationTypeName,
//state.description
};
if(props.edit){
if (props.edit) {
api
.createEvaluation(obj)
.then((res) => {
updateTask(res);
message.success("创建成功");
closeDrawer();
ctx.emit("changeData", false);
})
.catch((err) => {
console.log(err);
});
}else{
.createEvaluation(obj)
.then((res) => {
updateTask(res);
message.success("创建成功");
closeDrawer();
ctx.emit("changeData", false);
})
.catch((err) => {
console.log(err);
});
} else {
api
.updateEvaluation(obj)
.then((res) => {
updateTask(res);
message.success("创建成功");
closeDrawer();
ctx.emit("changeData", false);
})
.catch((err) => {
console.log(err);
});
.updateEvaluation(obj)
.then((res) => {
updateTask(res);
message.success("创建成功");
closeDrawer();
ctx.emit("changeData", false);
})
.catch((err) => {
console.log(err);
});
}
};
@@ -318,7 +332,7 @@ export default {
display: flex;
justify-content: space-between;
.main_left {
margin-top:32px;
margin-top: 32px;
padding-right: 30px;
flex: 1;
border-right: 1px solid #e8e8e8;