mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-13 04:46:46 +08:00
直播外链活动讨论阶段里关卡里编辑
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
>
|
||||
<div class="drawerMain">
|
||||
<div class="header">
|
||||
<div class="headerTitle">{{ title }}外链</div>
|
||||
<div class="headerTitle">{{edit ? '编辑' : '添加' }}外链</div>
|
||||
<img
|
||||
style="width: 29px; height: 29px; cursor: pointer"
|
||||
src="../../assets/images/basicinfo/close.png"
|
||||
@@ -73,13 +73,13 @@
|
||||
</a-form>
|
||||
<div class="main_btns">
|
||||
<button class="btn1" @click="closeDrawer">取消</button>
|
||||
<button class="btn2" @click="createExternalChain">确定</button>
|
||||
<button class="btn2" @click="updateRef">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
</a-drawer>
|
||||
</template>
|
||||
<script>
|
||||
import { reactive, toRefs, ref, onMounted } from "vue";
|
||||
import { reactive, toRefs, ref } from "vue";
|
||||
import * as api from "../../api/indexExternalChain";
|
||||
import * as apiTask from "../../api/indexTaskadd";
|
||||
import { message } from "ant-design-vue";
|
||||
@@ -110,10 +110,14 @@ export default {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
isStudy: {
|
||||
EditRefId: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
edit: { // 是否为编辑
|
||||
type: Boolean,
|
||||
default: null,
|
||||
},
|
||||
projectId: {
|
||||
type: Number,
|
||||
default: null,
|
||||
@@ -122,15 +126,19 @@ export default {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
isRefEdit: {
|
||||
routerTaskId: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
isLevel: { // 是否是关卡页面触发
|
||||
type: Boolean,
|
||||
default: null,
|
||||
},
|
||||
EditWorkId: { // 要编辑的workId
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
EditRefId: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
isactive: {
|
||||
projectTaskId: { // 要编辑的projectId
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
@@ -138,6 +146,11 @@ export default {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
isactive: {
|
||||
type: Number,
|
||||
default: null,
|
||||
}
|
||||
|
||||
},
|
||||
setup(props, ctx) {
|
||||
const state = reactive({
|
||||
@@ -149,286 +162,103 @@ export default {
|
||||
const closeDrawer = () => {
|
||||
console.log(props, 1111);
|
||||
ctx.emit("update:addrefVisible", false);
|
||||
ctx.emit("update:isRefEdit", 1);
|
||||
ctx.emit("update:edit", false);
|
||||
console.log("props", props.routerId);
|
||||
state.inputV2 = "";
|
||||
state.inputV1 = "";
|
||||
state.textV1 = "";
|
||||
};
|
||||
const updateRef = () => {
|
||||
// 如果是关卡页面进入 ---------------------------------
|
||||
if (props.isLevel) {
|
||||
if(props.isRefEdit){
|
||||
createExternalRef();
|
||||
|
||||
}else{
|
||||
updateExternalRef();
|
||||
}
|
||||
console.log('关卡创建任务***************');
|
||||
} else { // 任务页面进入------------------------------
|
||||
if (props.isRefEdit) { // 编辑任务
|
||||
console.log('编辑任务***************');
|
||||
updateExternalChain();
|
||||
} else { // 创建任务
|
||||
console.log('创建任务***************');
|
||||
createExternalChain();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
const afterVisibleChange = (bool) => {
|
||||
console.log("state", bool);
|
||||
queryRef();
|
||||
|
||||
if(props.edit){
|
||||
queryRef();
|
||||
}
|
||||
|
||||
};
|
||||
const handleFinish = values => {
|
||||
console.log(values);
|
||||
updateRef(props.EditRefId)
|
||||
//updateRef(props.EditRefId)
|
||||
};
|
||||
const handleFinishFailed = errors => {
|
||||
console.log(errors);
|
||||
// message.error("handleFinishFailed");
|
||||
};
|
||||
//创建外链
|
||||
const createExternalChain = () => {
|
||||
if (!state.inputV1) return message.warning("请输入外链名称");
|
||||
if (!state.inputV2) return message.warning("请输入链接");
|
||||
let obj = {
|
||||
linkAddress: state.inputV2,
|
||||
linkDescription: state.textV1,
|
||||
linkId: props.EditRefId == null ? 0 : props.EditRefId,
|
||||
linkName: state.inputV1,
|
||||
};
|
||||
//编辑外链
|
||||
|
||||
api
|
||||
.createExternalChain(obj)
|
||||
.then((res) => {
|
||||
console.log(res.data.data, "外链添加成功了");
|
||||
message.success("提交成功");
|
||||
closeDrawer();
|
||||
|
||||
//项目的创建
|
||||
apiTask
|
||||
.addTask({
|
||||
const updateTask =(res)=>{
|
||||
console.log("jinlaile=================",res.data.data.linkId,props.isLevel,props.isactive,props.routerId,props.routerTaskId)
|
||||
if(props.isLevel){
|
||||
RouterEditTask({
|
||||
chapterId: props.isactive,
|
||||
courseId: res.data.data.linkId,
|
||||
duration: 0,
|
||||
flag: true,
|
||||
name: obj.linkName,
|
||||
name: res.data.data.linkName,
|
||||
routerId: props.routerId,
|
||||
routerTaskId: props.routerTaskId || 0,
|
||||
type: 7,
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res, 11111);
|
||||
message.success(`${props.edit ? '编辑' : '新增'}关卡任务成功`)
|
||||
ctx.emit("changeData", false);
|
||||
closeDrawer();
|
||||
state.addLoading = false;
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err, 1111);
|
||||
});
|
||||
}else{
|
||||
apiTask
|
||||
.addTask({
|
||||
courseId:res.data.data.linkId,
|
||||
name: res.data.data.linkName,
|
||||
projectId: props.projectId,
|
||||
projectTaskId: 0,
|
||||
projectTaskId: props.projectTaskId || 0,
|
||||
stageId: props.chooseStageId,
|
||||
type: 7,
|
||||
})
|
||||
.then((res) => {
|
||||
console.log("调用项目添加接口后111", res.data, 11111);
|
||||
ctx.emit("changeData", false);
|
||||
//重新获取任务列表
|
||||
// apiTask.getTask({ projectId: 28 });
|
||||
// router.push("/taskadd");
|
||||
ctx.emit("changeData", false);
|
||||
closeDrawer();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err, 111111);
|
||||
});
|
||||
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
};
|
||||
const updateExternalChain = () => {
|
||||
}
|
||||
}
|
||||
//创建外链
|
||||
const updateRef = () => {
|
||||
if (!state.inputV1) return message.warning("请输入外链名称");
|
||||
if (!state.inputV2) return message.warning("请输入链接");
|
||||
let obj = {
|
||||
|
||||
let obj = {
|
||||
linkAddress: state.inputV2,
|
||||
linkDescription: state.textV1,
|
||||
linkId: props.EditRefId == null ? 0 : props.EditRefId,
|
||||
linkName: state.inputV1,
|
||||
|
||||
linkId:props.edit?props.EditRefId:0,
|
||||
linkName: state.inputV1,
|
||||
};
|
||||
|
||||
//编辑外链
|
||||
api
|
||||
console.log("编辑的id========",props.EditRefId)
|
||||
if(props.edit){
|
||||
api
|
||||
.updateLinks(obj)
|
||||
.then((res) => {
|
||||
console.log("编辑成功", res);
|
||||
message.success("编辑成功");
|
||||
closeDrawer();
|
||||
})
|
||||
.catch((err) => console.log(err));
|
||||
updateTask(res);
|
||||
}).catch((err) => console.log(err));
|
||||
}else{
|
||||
api
|
||||
.createExternalChain(obj)
|
||||
.then((res) => {
|
||||
message.success("提交成功");
|
||||
updateTask(res);
|
||||
}).catch((err) => console.log(err));
|
||||
}
|
||||
|
||||
};
|
||||
const createExternalRef = () => {
|
||||
if (!state.inputV1) return message.warning("请输入外链名称");
|
||||
if (!state.inputV2) return message.warning("请输入链接");
|
||||
let obj = {
|
||||
createUser: 0,
|
||||
createTime: "",
|
||||
linkAddress: state.inputV2,
|
||||
linkDescription: state.textV1,
|
||||
linkFlag: "",
|
||||
linkId: props.EditRefId == null ? 0 : props.EditRefId,
|
||||
linkName: state.inputV1,
|
||||
linkTag: "",
|
||||
updateTime: "",
|
||||
updateUser: 0,
|
||||
};
|
||||
|
||||
//编辑外链
|
||||
if (props.isRefEdit) {
|
||||
api
|
||||
.updateLinks(obj)
|
||||
.then((res) => {
|
||||
console.log("编辑成功", res);
|
||||
message.success("编辑成功");
|
||||
closeDrawer();
|
||||
})
|
||||
.catch((err) => console.log(err));
|
||||
} else {
|
||||
api
|
||||
.createExternalChain(obj)
|
||||
.then((res) => {
|
||||
console.log(res.data.data, "外链添加成功了");
|
||||
message.success("提交成功");
|
||||
closeDrawer();
|
||||
//学习路径的创建
|
||||
if (props.isStudy == 1) {
|
||||
let objj = {
|
||||
chapterId: props.isactive,
|
||||
courseId: res.data.data.linkId,
|
||||
duration: 0,
|
||||
flag: true,
|
||||
name: obj.linkName,
|
||||
routerId: props.routerId,
|
||||
routerTaskId: 0,
|
||||
type: 7,
|
||||
};
|
||||
RouterEditTask(objj)
|
||||
.then((res) => {
|
||||
console.log(res, 11111);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err, 1111);
|
||||
});
|
||||
} else {
|
||||
//项目的创建
|
||||
apiTask
|
||||
.addTask({
|
||||
courseId: res.data.data.linkId,
|
||||
duration: 0,
|
||||
flag: true,
|
||||
name: obj.linkName,
|
||||
projectId: props.projectId,
|
||||
projectTaskId: 0,
|
||||
stageId: props.chooseStageId,
|
||||
type: 7,
|
||||
})
|
||||
.then((res) => {
|
||||
console.log("调用项目添加接口后111", res.data, 11111);
|
||||
ctx.emit("changeData", false);
|
||||
//重新获取任务列表
|
||||
// apiTask.getTask({ projectId: 28 });
|
||||
// router.push("/taskadd");
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err, 111111);
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
const updateExternalRef = () => {
|
||||
if (!state.inputV1) return message.warning("请输入外链名称");
|
||||
if (!state.inputV2) return message.warning("请输入链接");
|
||||
let obj = {
|
||||
createUser: 0,
|
||||
createTime: "",
|
||||
linkAddress: state.inputV2,
|
||||
linkDescription: state.textV1,
|
||||
linkFlag: "",
|
||||
linkId: props.EditRefId == null ? 0 : props.EditRefId,
|
||||
linkName: state.inputV1,
|
||||
linkTag: "",
|
||||
updateTime: "",
|
||||
updateUser: 0,
|
||||
};
|
||||
|
||||
//编辑外链
|
||||
if (props.isRefEdit) {
|
||||
api
|
||||
.updateLinks(obj)
|
||||
.then((res) => {
|
||||
console.log("编辑成功", res);
|
||||
message.success("编辑成功");
|
||||
closeDrawer();
|
||||
})
|
||||
.catch((err) => console.log(err));
|
||||
} else {
|
||||
api
|
||||
.createExternalChain(obj)
|
||||
.then((res) => {
|
||||
console.log(res.data.data, "外链添加成功了");
|
||||
message.success("提交成功");
|
||||
closeDrawer();
|
||||
//学习路径的创建
|
||||
if (props.isStudy == 1) {
|
||||
let objj = {
|
||||
chapterId: 36,
|
||||
courseId: 0,
|
||||
duration: 0,
|
||||
flag: true,
|
||||
name: obj.linkName,
|
||||
routerId: 92,
|
||||
routerTaskId: 0,
|
||||
type: 7,
|
||||
};
|
||||
RouterEditTask(objj)
|
||||
.then((res) => {
|
||||
console.log(res, 11111);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err, 1111);
|
||||
});
|
||||
} else {
|
||||
//项目的创建
|
||||
apiTask
|
||||
.addTask({
|
||||
courseId: res.data.data.linkId,
|
||||
duration: 0,
|
||||
flag: true,
|
||||
name: obj.linkName,
|
||||
projectId: props.projectId,
|
||||
projectTaskId: 0,
|
||||
stageId: props.chooseStageId,
|
||||
type: 7,
|
||||
})
|
||||
.then((res) => {
|
||||
console.log("调用项目添加接口后111", res.data, 11111);
|
||||
ctx.emit("changeData", false);
|
||||
//重新获取任务列表
|
||||
// apiTask.getTask({ projectId: 28 });
|
||||
// router.push("/taskadd");
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err, 111111);
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
// 查询任务
|
||||
const queryRef = () => {
|
||||
let p =new FormData;
|
||||
p.append('linkId',props.EditRefId);
|
||||
let d =props.EditRefId ;
|
||||
api
|
||||
.getLink(p).then((res) => {
|
||||
.getLink({linkId:d}).then((res) => {
|
||||
// console.log(dayjs(res.data.data.submitStartTime).format("YYYY-MM-DD"));
|
||||
state.inputV1 = res.data.data.linkName;
|
||||
state.inputV2 =res.data.data.linkAddress;
|
||||
@@ -438,16 +268,11 @@ export default {
|
||||
message.error(`查询失败`)
|
||||
})
|
||||
};
|
||||
//不生效
|
||||
onMounted(() => {
|
||||
state.title = props.isRefEdit == 2 ? "编辑" : "添加";
|
||||
});
|
||||
return {
|
||||
...toRefs(state),
|
||||
afterVisibleChange,
|
||||
closeDrawer,
|
||||
rowSelection,
|
||||
createExternalChain,
|
||||
handleFinish,
|
||||
handleFinishFailed,
|
||||
updateRef,
|
||||
|
||||
Reference in New Issue
Block a user