@@ -738,7 +720,9 @@ export default {
setup() {
const store = useStore();
const router = useRouter();
+ const userInfo = computed(()=>store.state.userInfo)
const state = reactive({
+ confirmLoading:false,
tableLoading: false,
out: false,
out1: false,
@@ -866,17 +850,16 @@ export default {
const handleOut = () => {
console.log(store.state);
// console.log("打开创建路径弹窗");
+ state.confirmLoading = false;
state.pathName = "";
state.pathBg = "";
state.pathBgId = "";
state.pathIntro = "";
state.out = !state.out;
- setTimeout(() => {
- if (store.state.userInfo.departId && store.state.userInfo.departName) {
- state.organizationSelectName = store.state.userInfo.departName;
- state.organizationSelectId = store.state.userInfo.departId;
- }
- }, 2000);
+ if (userInfo.value.departId && userInfo.value.departName) {
+ state.organizationSelectName =userInfo.value.departName;
+ state.organizationSelectId = userInfo.value.departId;
+ }
};
const handleOut1 = () => {
state.pathName = "";
@@ -1175,24 +1158,30 @@ export default {
};
//创建学习路径图
const createLearnPath = async () => {
+ state.confirmLoading = true
if (!state.pathName) {
message.destroy();
+ state.confirmLoading = false
return message.warning("请输入路径图名称");
}
if (!state.organizationSelectName) {
message.destroy();
+ state.confirmLoading = false
return message.warning("请选择归属组织");
}
if (!state.pathBg) {
message.destroy();
+ state.confirmLoading = false
return message.warning("请选择背景图");
}
if (!state.mobilePicUrl) {
message.destroy();
+ state.confirmLoading = false
return message.warning("未配置H5背景图,请联系管理员!");
}
if (!state.validate) {
message.destroy();
+ state.confirmLoading = false
message.warning("路径图名称重复");
return;
}
@@ -1205,9 +1194,9 @@ export default {
});
if (offName) {
message.destroy();
+ state.confirmLoading = false
return message.warning("项目名称重复,请重新填写");
}
- state.lpLoading = true;
api.createLearnPath({
name: state.pathName,
remark: state.pathIntro,
@@ -1218,8 +1207,8 @@ export default {
mobilePicUrl: state.mobilePicUrl,
}).then(id => {
message.destroy();
+ state.confirmLoading = false
message.success("创建成功");
- state.lpLoading = false;
router.push( {path: "/leveladd",query:{routerId: id.data.data }})
})
};
@@ -1268,49 +1257,38 @@ export default {
};
//删除学习路径图
const deleteLearnPath = () => {
- let obj = {
- routerId: state.deletePathId,
- type: -2,
- };
- api
- .handleLearnPath(obj)
- .then((res) => {
- if (res.data.code === 200) {
- console.log("删除成功", res);
- message.destroy();
- message.success("删除成功");
- state.deleteModal = false;
- getLearnPath();
- }
- if (res.data.code === -1) {
- message.warning(res.data.msg);
- }
- })
- .catch((err) => {
- console.log("删除失败", err);
- });
+ state.deleteModal = false;
+ state.tableLoading = true;
+ message.success("删除成功");
+ api.handleLearnPath({routerId: state.deletePathId, type: -2}).then(() => {getLearnPath()})
};
//编辑学习路径图
const editLearnPath = async () => {
+ state.confirmLoading = true
if (!state.pathName) {
message.destroy();
+ state.confirmLoading = false
return message.warning("请输入路径图名称");
}
if (!state.organizationSelectName) {
message.destroy();
+ state.confirmLoading = false
return message.warning("请选择归属组织");
}
if (!state.pathBgId) {
message.destroy();
+ state.confirmLoading = false
return message.warning("请选择背景图");
}
if (!state.mobilePicUrl) {
message.destroy();
+ state.confirmLoading = false
return message.warning("未配置H5背景图,请联系管理员!");
}
if (!state.validate) {
message.destroy();
+ state.confirmLoading = false
return message.warning("路径图名称重复");
}
// state.pathName = detail.name;
@@ -1330,10 +1308,15 @@ export default {
});
if (offName) {
message.destroy();
+ state.confirmLoading = false
return message.warning("项目名称重复,请重新填写");
}
+ state.out1 = false;
+ state.confirmLoading = false
+ message.success("修改成功");
+ state.tableLoading = true;
let obj = {
- routerId: state.editPathId,
+ id: state.editPathId,
name: state.pathName,
picUrl: state.pathBg,
mobilePicUrl: state.mobilePicUrl,
@@ -1342,40 +1325,10 @@ export default {
organizationId: state.organizationSelectId,
status: 0,
};
- api
- .createLearnPath(obj)
- .then((res) => {
- if (res.data.code === 200) {
- console.log("修改成功", res);
- message.destroy();
- message.success("修改成功");
- // state.createLoading = false;
- // state.currentPage = 1;
- state.out1 = false;
- // router.push("/leveladd");
- getLearnPath();
- // setTimeout(() => {
- // console.log("修改成功", res);
- // message.success("修改成功");
- // // state.createLoading = false;
- // // state.currentPage = 1;
- // state.out1 = false;
- // // router.push("/leveladd");
- // getLearnPath();
- // }, 1000);
- }
- if (res.data.code === -1) {
- message.warning(res.data.msg);
- }
- })
- .catch((err) => {
- console.log("修改失败", err);
- // state.createLoading = false;
- });
+ api.createLearnPath(obj).then(() => {getLearnPath()})
};
//选择状态
const selectStatusClassify = (e, v) => {
- // console.log("eee", e, v);
state.statusValue = e;
state.statusClassify = v.classify;
};