fix:修改路径编辑回显

This commit is contained in:
lixg
2022-12-02 15:07:19 +08:00
parent be71d6b9fe
commit 90051c0e62
5 changed files with 161 additions and 119 deletions

View File

@@ -867,7 +867,7 @@ export default {
state.editPathId = null;
};
const chooseImg = (item) => {
// console.log(item);
console.log(item);
state.pathBgId = item.dictCode;
state.pathBg = item.dictValue;
};
@@ -1148,7 +1148,7 @@ export default {
onClick={() => {
// console.log("text.record", text.record);
getLearnPathInfo(text.record);
getLearnPathInfo(text.record.id);
}}
>
编辑
@@ -1409,8 +1409,8 @@ export default {
};
const selectorganization = (e, v) => {
console.log("eee", e, v);
state.organizationSelectName = e;
state.organizationSelectId = v.id;
state.organizationSelectName = v[0];
state.organizationSelectId = e;
};
//创建学习路径图
const createLearnPath = () => {
@@ -1429,37 +1429,42 @@ export default {
state.lpLoading = true;
let obj = {
name: state.pathName,
picUrl: "",
remark: state.pathIntro,
status: 0,
organizationId: state.organizationSelectId,
organizationName: state.organizationSelectName,
picUrl: state.pathBg,
};
api
.createLearnPath(obj)
.then((res) => {
let chapterObj = {
name: "关卡一",
remark: "",
routerId: res.data.data.routerId,
};
//创建关卡
api
.editChapter(chapterObj)
.then((chapterRes) => {
console.log("关卡创建成功", chapterRes);
setTimeout(() => {
console.log("创建成功", res);
message.destroy();
message.success("创建成功");
state.lpLoading = false;
state.currentPage = 1;
router.push("/leveladd");
storage.set("routerId", res.data.data.routerId);
// getLearnPath();
}, commonData.timeout);
})
.catch((chapterErr) => {
console.log("关卡创建失败", chapterErr);
});
console.log("创建学习路径成功", res);
if (res.data.code === 200) {
let chapterObj = {
name: "关卡一",
remark: "",
routerId: res.data.data.routerId,
};
//创建关卡
api
.editChapter(chapterObj)
.then((chapterRes) => {
console.log("关卡创建成功", chapterRes);
setTimeout(() => {
console.log("创建成功", res);
message.destroy();
message.success("创建成功");
state.lpLoading = false;
state.currentPage = 1;
router.push("/leveladd");
storage.set("routerId", res.data.data.routerId);
// getLearnPath();
}, commonData.timeout);
})
.catch((chapterErr) => {
console.log("关卡创建失败", chapterErr);
});
}
})
.catch((err) => {
console.log("创建失败", err);
@@ -1525,23 +1530,36 @@ export default {
};
//获取路径图详细信息
const getLearnPathInfo = (item) => {
console.log("item", item);
const getLearnPathInfo = (id) => {
// console.log("编辑学习路径图id", id);
//获取学习路径详情
api
.getRouterDetail(id)
.then((res) => {
if (res.data.code === 200) {
let detail = res.data.data.routerInfo;
// console.log("获取详情成功", detail);
state.pathName = detail.name;
state.pathBg = detail.picUrl;
state.pathBgId = "";
state.organizationSelectName = detail.organizationName;
state.organizationSelectId = detail.organizationId;
state.pathIntro = detail.remark;
state.editPathId = id;
// console.log("state.imgData", state.imgData);
let arr = state.imgData;
for (let i = 0; i < arr.length; i++) {
// console.log("arr[i].dictValue", arr[i].dictValue, state.pathBg);
if (arr[i].dictValue === state.pathBg) {
state.pathBgId = arr[i].dictCode;
}
}
}
})
.catch((err) => {
console.log("获取详情失败", err);
});
state.out1 = true;
state.pathName = item.manager;
state.pathBg = "";
state.pathBgId = "";
state.organizationSelectName = null;
state.organizationSelectId = null;
state.pathIntro = item.remark;
state.editPathId = item.id;
console.log("state.imgData", state.imgData);
let arr = state.imgData;
for (let i = 0; i < arr.length; i++) {
if (arr[i].dictCode === state.pathBgId) {
state.pathBgId = arr[i].dictValue;
}
}
};
//编辑学习路径图
const editLearnPath = () => {
@@ -1557,12 +1575,21 @@ export default {
message.destroy();
return message.warning("请选择背景图");
}
// state.pathName = detail.name;
// state.pathBg = detail.picUrl;
// state.pathBgId = "";
// state.organizationSelectName = detail.organizationName;
// state.organizationSelectId = detail.organizationId;
// state.pathIntro = detail.remark;
// state.editPathId = id;
// state.createLoading = true;
let obj = {
routerId: state.editPathId,
name: state.pathName,
picUrl: "",
picUrl: state.pathBg,
remark: state.pathIntro,
organizationName: state.organizationSelectName,
organizationId: state.organizationSelectId,
status: 0,
};
api
@@ -1642,30 +1669,30 @@ export default {
// }
// choiceEvaluation()
//字典获取路径图背景
const getDictList = (param) => {
let obj = {
pageNo: 1,
pageSize: 20,
setCode: param,
};
api
.getDict(obj)
.then((res) => {
console.log("获取字典成功", res);
if (res.status === 200) {
if (param === "pathmapPic") {
if (res.data.data.rows.length > 0) {
state.imgData = [res.data.data.rows[0]];
}
}
}
})
.catch((err) => {
console.log("获取字典失败", err);
});
};
getDictList("pathmapPic");
// //字典获取路径图背景
// const getDictList = (param) => {
// let obj = {
// pageNo: 1,
// pageSize: 20,
// setCode: param,
// };
// api
// .getDict(obj)
// .then((res) => {
// console.log("获取字典成功", res);
// if (res.status === 200) {
// if (param === "pathmapPic") {
// if (res.data.data.rows.length > 0) {
// state.imgData = [res.data.data.rows[0]];
// }
// }
// }
// })
// .catch((err) => {
// console.log("获取字典失败", err);
// });
// };
// getDictList("pathmapPic");
//显示更多路径背景弹窗
const showLearnBgMore = () => {
state.learnBgMore = true;
@@ -1677,6 +1704,10 @@ export default {
onMounted(() => {
// console.log("执行");
getLearnPath();
if (store.state.pathmapPic.length > 0) {
console.log("store.state.pathmapPic", store.state.pathmapPic);
state.imgData = [store.state.pathmapPic[0]];
}
});
//添加权限
watch(