diff --git a/src/api/indexExternalChain.js b/src/api/indexExternalChain.js
index 653a5883..6bc219d3 100644
--- a/src/api/indexExternalChain.js
+++ b/src/api/indexExternalChain.js
@@ -15,7 +15,7 @@ export const deleteLink = (obj) => http.post('/link/deleteLink', { params: obj }
})
//获取外链详细信息接口
-export const getLink = (obj) => http.post('/link/getOne', { params: obj })
+export const getLink = (obj) => http.post('/link/getOne', obj)
// 更新外链数据
export const updateLinks = (obj) => http.post('/link/updateLinks', obj, {
diff --git a/src/components/drawers/AddRef.vue b/src/components/drawers/AddRef.vue
index 5e24516f..28e78e79 100644
--- a/src/components/drawers/AddRef.vue
+++ b/src/components/drawers/AddRef.vue
@@ -15,6 +15,8 @@
@click="closeDrawer"
/>
+
+
@@ -81,6 +84,7 @@ import * as api from "../../api/indexExternalChain";
import * as apiTask from "../../api/indexTaskadd";
import { message } from "ant-design-vue";
import { RouterEditTask } from "@/api/indexTask";
+//import { query } from "express";
const rowSelection = ref({
checkStrictly: false,
onChange: (selectedRowKeys, selectedRows) => {
@@ -143,12 +147,111 @@ export default {
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();
+ };
+ const handleFinish = values => {
+ console.log(values);
+ updateRef(props.workId)
+ };
+ 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({
+ 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 updateExternalChain = () => {
+ 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
+ .updateLinks(obj)
+ .then((res) => {
+ console.log("编辑成功", res);
+ message.success("编辑成功");
+ closeDrawer();
+ })
+ .catch((err) => console.log(err));
+
+ };
+ const createExternalRef = () => {
if (!state.inputV1) return message.warning("请输入外链名称");
if (!state.inputV2) return message.warning("请输入链接");
let obj = {
@@ -163,8 +266,9 @@ export default {
updateTime: "",
updateUser: 0,
};
+
//编辑外链
- if (props.isRefEdit == 2) {
+ if (props.isRefEdit) {
api
.updateLinks(obj)
.then((res) => {
@@ -229,6 +333,103 @@ export default {
});
}
};
+ 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);
+ api
+ .getLink(p).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;
+ state.textV1 =res.data.data.linkDescription;
+ console.log("查询成功=====inputv1",state.inputV1);
+ }).catch(() => {
+ message.error(`查询失败`)
+ })
+ };
//不生效
onMounted(() => {
state.title = props.isRefEdit == 2 ? "编辑" : "添加";
@@ -239,6 +440,9 @@ export default {
closeDrawer,
rowSelection,
createExternalChain,
+ handleFinish,
+ handleFinishFailed,
+ updateRef,
};
},
};
diff --git a/src/views/projectcenter/TaskAdd.vue b/src/views/projectcenter/TaskAdd.vue
index 8315f1ee..c75ccbfb 100644
--- a/src/views/projectcenter/TaskAdd.vue
+++ b/src/views/projectcenter/TaskAdd.vue
@@ -183,6 +183,7 @@
v-model:chooseStageId="chooseStageId"
v-model:isLiveEdit="isLiveEdit"
v-model:EditLiveId="EditLiveId"
+ v-model:projectTaskId="projectTaskId"
/>
@@ -199,11 +200,13 @@
@@ -857,8 +860,8 @@ export default {
: null,
chooseStageId: null,
edit: false,
- isRefEdit: 1, //外链编辑
- isLiveEdit: 1, //直播编辑
+ isRefEdit: false, //外链编辑
+ isLiveEdit:false, //直播编辑
EditRefId: null, //要编辑的外链的id
EditLiveId: null, //要编辑的直播的id
editDiscussId:null,//要编辑的讨论的id
@@ -1694,7 +1697,9 @@ export default {
const showDrawerAddLive = () => {
state.addlivevisible = true;
};
- const showDrawerAddRef = () => {
+ const showDrawerAddRef = (id,eleId) => {
+ state.EditRefId = id
+ state.projectTaskId = eleId;
state.addrefvisible = true;
};
const showDrawerAddDiscuss = () => {
@@ -1804,7 +1809,7 @@ export default {
//打开编辑外链的弹窗
const showEditRefDrawer = (id) => {
state.addrefvisible = true;
- state.isRefEdit = 2;
+ state.isRefEdit = true;
state.EditRefId = id;
};
//打开编辑直播的弹窗