feat:外链编辑弹窗

This commit is contained in:
songwc
2022-11-07 11:59:09 +08:00
parent 9e531dd237
commit f2f0eb5be6
3 changed files with 214 additions and 186 deletions

View File

@@ -558,6 +558,7 @@ export default {
state.obj = {
afterSignIn: state.inputV6,
beforeSignIn: state.inputV7,
assessmentId: 0,
createTime: "",
createUser: 0,
// liveCover: state.fileList,//直播封面

View File

@@ -3,7 +3,6 @@
:visible="addrefVisible"
class="drawerStyle addrefDrawer"
width="80%"
title="添加外链"
placement="right"
@after-visible-change="afterVisibleChange"
>
@@ -77,7 +76,7 @@
</a-drawer>
</template>
<script>
import { reactive, toRefs, ref } from "vue";
import { reactive, toRefs, ref, onMounted } from "vue";
import * as api from "../../api/indexExternalChain";
import * as apiTask from "../../api/indexTaskadd";
import { message } from "ant-design-vue";
@@ -123,17 +122,22 @@ export default {
type: Number,
default: null,
},
EditRefId: {
type: Number,
default: null,
},
},
setup(props, ctx) {
const state = reactive({
inputV1: "",
inputV2: "",
textV1: "",
title: props.isRefEdit == 2 ? "编辑" : "添加",
title: null,
});
const closeDrawer = () => {
console.log(props, 1111);
ctx.emit("update:addrefVisible", false);
ctx.emit("update:isRefEdit", 1);
console.log("props", props.routerId);
state.inputV2 = "";
state.inputV1 = "";
@@ -142,7 +146,7 @@ export default {
const afterVisibleChange = (bool) => {
console.log("state", bool);
};
//编辑外链
//创建外链
const createExternalChain = () => {
if (!state.inputV1) return message.warning("请输入外链名称");
@@ -153,66 +157,82 @@ export default {
linkAddress: state.inputV2,
linkDescription: state.textV1,
linkFlag: "",
linkId: 0,
linkId: props.EditRefId == null ? 0 : props.EditRefId,
linkName: state.inputV1,
linkTag: "",
updateTime: "",
updateUser: 0,
};
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({
//编辑外链
if (props.isRefEdit == 2) {
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,
projectId: props.projectId,
projectTaskId: 0,
stageId: props.chooseStageId,
routerId: 92,
routerTaskId: 0,
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);
});
};
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);
});
}
};
//不生效
onMounted(() => {
state.title = props.isRefEdit == 2 ? "编辑" : "添加";
});
return {
...toRefs(state),
afterVisibleChange,

View File

@@ -192,6 +192,7 @@
v-model:projectId="projectId"
v-model:chooseStageId="chooseStageId"
v-model:isRefEdit="isRefEdit"
v-model:EditRefId="EditRefId"
/>
</div>
<!-- 添加外链侧弹窗 -->
@@ -480,6 +481,7 @@
margin-right: 25px;
cursor: pointer;
"
@click="decideType(element.lei, element.courseId)"
>
编辑
</span>
@@ -827,6 +829,7 @@ export default {
: null,
chooseStageId: null,
isRefEdit: 1, //外链编辑
EditRefId: null, //要编辑的外链的id
projectNameList: [
{
id: 1,
@@ -1055,6 +1058,7 @@ export default {
cretime: value.duration ? value.duration : "-",
checked1: value.flag ? true : false,
checked: false, //是否选中类型
courseId: value.courseId,
};
array.push(obj);
});
@@ -1078,135 +1082,128 @@ export default {
state.level = array;
};
const tableDataFunc = () => {
const columns = [
{
title: "类型",
dataIndex: "state",
// width: "30%",
key: "state",
width: 60,
align: "left",
className: "classify",
scopedSlots: { customRender: "action" },
customRender: (text) => {
// console.log(text.record.checked1);
return (
<div class="racona">
<div
class="img"
style={{ cursor: "pointer" }}
onClick={() => {
console.log("点击了");
}}
></div>
<span> {text.record.lei}</span>
{/**
<div class="img"></div>
<a-checkbox class="ch" checked={text.record.checkedd}>
{text.record.lei}
</a-checkbox>
*/}
</div>
);
},
},
{
title: "任务名称",
dataIndex: "creater",
// width: "30%",
key: "creater",
width: 200,
align: "center",
className: "h",
},
{
title: "必修/选修",
dataIndex: "pubtime",
key: "pubtime",
// width: 100,
align: "center",
className: "h",
scopedSlots: { customRender: "action" },
customRender: (text) => {
// console.log(text.record.checked1);
return (
<div class="opat">
<div class="opacationt clearfix">
<a-switch
style="margin-left:-50px;margin-top:3px"
checked={text.record.checked1}
size="small"
active-color="red"
onClick={() => {
console.log("点击了");
text.record.checked1 = !text.record.checked1;
}}
/>
<div class="showt clearfix">
<div
class="bi"
style={
text.record.checked1 ? "z-index:999" : "z-index:998"
}
>
必修
</div>
<div class="xuan">选修</div>
</div>
</div>
</div>
);
},
},
{
title: "时长",
dataIndex: "cretime",
key: "cretime",
// width: 100,
align: "center",
className: "h",
},
{
title: "操作",
className: "h",
dataIndex: "opacation",
key: "opacation",
// width: 100,
align: "center",
scopedSlots: { customRender: "action" },
customRender: (text) => {
return (
<div class="opa">
<div class="opacation">
<span
onClick={() => {
state.editonlinevisible = true;
console.log(text, "编辑text");
editInvistPath();
}}
style="color:#4EA6FF;margin-right:25px;cursor:pointer"
>
编辑
</span>
<span
style="color:#4EA6FF;cursor:pointer"
onClick={() => {
showDelete();
state.deleteID = text.record.id;
}}
>
删除
</span>
</div>
</div>
);
},
},
];
return columns;
};
// const tableDataFunc = () => {
// const columns = [
// {
// title: "类型",
// dataIndex: "state",
// // width: "30%",
// key: "state",
// width: 60,
// align: "left",
// className: "classify",
// scopedSlots: { customRender: "action" },
// customRender: (text) => {
// // console.log(text.record.checked1);
// return (
// <div class="racona">
// <div
// class="img"
// style={{ cursor: "pointer" }}
// onClick={() => {
// console.log("点击了");
// }}
// ></div>
// <span> {text.record.lei}</span>
// </div>
// );
// },
// },
// {
// title: "任务名称",
// dataIndex: "creater",
// // width: "30%",
// key: "creater",
// width: 200,
// align: "center",
// className: "h",
// },
// {
// title: "必修/选修",
// dataIndex: "pubtime",
// key: "pubtime",
// // width: 100,
// align: "center",
// className: "h",
// scopedSlots: { customRender: "action" },
// customRender: (text) => {
// // console.log(text.record.checked1);
// return (
// <div class="opat">
// <div class="opacationt clearfix">
// <a-switch
// style="margin-left:-50px;margin-top:3px"
// checked={text.record.checked1}
// size="small"
// active-color="red"
// onClick={() => {
// console.log("点击了");
// text.record.checked1 = !text.record.checked1;
// }}
// />
// <div class="showt clearfix">
// <div
// class="bi"
// style={
// text.record.checked1 ? "z-index:999" : "z-index:998"
// }
// >
// 必修
// </div>
// <div class="xuan">选修</div>
// </div>
// </div>
// </div>
// );
// },
// },
// {
// title: "时长",
// dataIndex: "cretime",
// key: "cretime",
// // width: 100,
// align: "center",
// className: "h",
// },
// {
// title: "操作",
// className: "h",
// dataIndex: "opacation",
// key: "opacation",
// // width: 100,
// align: "center",
// scopedSlots: { customRender: "action" },
// customRender: (text) => {
// return (
// <div class="opa">
// <div class="opacation">
// <span
// onClick={() => {
// state.editonlinevisible = true;
// console.log(text, "编辑text");
// editInvistPath();
// }}
// style="color:#4EA6FF;margin-right:25px;cursor:pointer"
// >
// 编辑
// </span>
// <span
// style="color:#4EA6FF;cursor:pointer"
// onClick={() => {
// showDelete();
// state.deleteID = text.record.id;
// }}
// >
// 删除
// </span>
// </div>
// </div>
// );
// },
// },
// ];
// return columns;
// };
//获取任务列表
const getTask = () => {
@@ -1911,15 +1908,24 @@ export default {
const changeCourseType = (id) => {
console.log("任务id", id);
};
//展示编辑外链弹窗
const showDrawerEditRef = () => {
//打开编辑外链弹窗
const showEditRefDrawer = (id) => {
state.addrefvisible = true;
state.isRefEdit = 2;
state.EditRefId = id;
};
//编辑的按钮
const decideType = (type, id) => {
console.log(type, id);
if (type == "外链") {
showEditRefDrawer(id);
}
};
return {
...toRefs(state),
selectProjectName,
selectProjectName2,
tableDataFunc,
// tableDataFunc,
showModal,
closeModal,
// showDrawer,
@@ -1975,7 +1981,8 @@ export default {
updateWork,
deleteTest,
deleteWork,
showDrawerEditRef,
decideType,
showEditRefDrawer,
};
},
};