'修改路径下的学习模式'

This commit is contained in:
fooperage
2023-02-02 09:24:26 +08:00
parent e15cabe750
commit 6b1638e55c
2 changed files with 89 additions and 11 deletions

View File

@@ -73,7 +73,7 @@
</div> </div>
<div class="btnn"> <div class="btnn">
<button class="btn1" @click="closeDrawer">取消</button> <button class="btn1" @click="closeDrawer">取消</button>
<button class="btn2" @click="closeDrawer">确定</button> <button class="btn2" @click="saveUnlock">确定</button>
</div> </div>
</div> </div>
</a-drawer> </a-drawer>
@@ -81,15 +81,31 @@
<script> <script>
import { reactive, toRefs } from "vue"; import { reactive, toRefs } from "vue";
import { editRoutered } from '@/api/indexLearningPath'
import { message } from "ant-design-vue";
// import { watch } from '@vue/runtime-core'
export default { export default {
name: "UnlockMode", name: "UnlockMode",
props: { props:{
unlockModeVisible: { unlockModeVisible:{
type: Boolean, type: Boolean,
default: false, default: false
}, },
routerInfo:{
type: Object
}
}, },
// watch:{
// unlockModeVisible(val){
// if(val){
// for(let key in this.formData){
// this.formData[key] = this.routerInfo[key]
// }
// }
// }
// },
setup(props, ctx) { setup(props, ctx) {
console.log("获取属性",props)
const state = reactive({ const state = reactive({
classify: [ classify: [
{ {
@@ -108,6 +124,22 @@ export default {
selectClassifyType: 1, selectClassifyType: 1,
checked: true, checked: true,
radioSelect: 1, radioSelect: 1,
formData: {
routerId:'',
organizationName:'',
organizationId:'',
name:'',
picUrl:'',
remark:'',
status:'', // 0 草稿 1 已发布 -1 已停用
attach:'',
attachSwitch:'',
enablePreview:'',
previewSetting:'',
enableStudy:'',
studySetting:'',
unlockMode:'',
}
}); });
const closeDrawer = () => { const closeDrawer = () => {
state.selectClassifyType = 1; state.selectClassifyType = 1;
@@ -116,17 +148,50 @@ export default {
ctx.emit("update:unlockModeVisible", false); ctx.emit("update:unlockModeVisible", false);
}; };
const saveUnlock =() =>{
editRoutered(state.formData).then(res=>{
if(res.data.code == 200){
message.success(res.data.msg)
ctx.emit("successA")
closeDrawer()
}else{
message.error(res.data.msg)
}
})
}
// watch:{
// unlockModeVisible(val){
// if(val){
// for(let key in this.formData){
// this.formData[key] = this.routerInfo[key]
// }
// }
// }
// },
const afterVisibleChange = (bool) => { const afterVisibleChange = (bool) => {
console.log("state", bool); if(bool){
for(let key in state.formData){
state.formData[key] = props.routerInfo[key]
}
}
}; };
const selectClassify = (e) => { const selectClassify = (e) => {
state.selectClassifyType = e.type; state.selectClassifyType = e.type;
state.formData.unlockMode = e.type
}; };
return { return {
...toRefs(state), ...toRefs(state),
afterVisibleChange, afterVisibleChange,
closeDrawer, closeDrawer,
saveUnlock,
// change, // change,
selectClassify, selectClassify,
}; };

View File

@@ -195,12 +195,12 @@
<div class="select" style="margin-right:90px;"> <div class="select" style="margin-right:90px;">
<span>学习模式</span> <span>学习模式</span>
<div class="inputbox"> <div class="inputbox">
<input type="text" placeholder="按学习时间解锁" /> <input type="text" :placeholder="unlockMode === 1?'自由学习模式':unlockMode === 2?'按学习时间解锁':''" />
<div class="bottonbox" @click="showModeVisible"> <div class="bottonbox" @click="showModeVisible">
<div class="btnText">切换模式</div> <div class="btnText">切换模式</div>
</div> </div>
</div> </div>
<unlock-mode v-model:unlockModeVisible="unlockModeVisible" /> <unlock-mode ref="unlockModeModal" v-model:unlockModeVisible="unlockModeVisible" :routerInfo="routerInfo" @successA="successA"/>
</div> </div>
<div class="line"></div> <div class="line"></div>
<router-link to="/leveladd"> <router-link to="/leveladd">
@@ -784,12 +784,12 @@
<div class="select"> <div class="select">
<span>学习模式</span> <span>学习模式</span>
<div class="inputbox"> <div class="inputbox">
<input type="text" placeholder="按学习时间解锁" /> <input type="text" :placeholder="unlockMode === 1?'自由学习模式':unlockMode === 2?'按学习时间解锁':''" />
<div class="bottonbox" @click="showModeVisible"> <div class="bottonbox" @click="showModeVisible">
<div class="btnText">切换模式</div> <div class="btnText">切换模式</div>
</div> </div>
</div> </div>
<unlock-mode v-model:unlockModeVisible="unlockModeVisible" /> <unlock-mode ref="unlockModeModal" v-model:unlockModeVisible="unlockModeVisible" :routerInfo="routerInfo" @successA="successA"/>
</div> </div>
<div class="line"></div> <div class="line"></div>
<router-link to="/leveladd"> <router-link to="/leveladd">
@@ -1061,7 +1061,7 @@
</div> </div>
</template> </template>
<script> <script>
import { reactive, toRefs, onMounted, onUnmounted } from "vue"; import { reactive, toRefs, onMounted, onUnmounted ,ref } from "vue";
import AddStu from "../../components/drawers/AddLevelAddStu"; import AddStu from "../../components/drawers/AddLevelAddStu";
import ImpStu from "../../components/drawers/AddLevelImportStu"; import ImpStu from "../../components/drawers/AddLevelImportStu";
import AddOnline from "../../components/drawers/AddOnline.vue"; import AddOnline from "../../components/drawers/AddOnline.vue";
@@ -1111,6 +1111,7 @@ export default {
}, },
setup() { setup() {
const router = useRouter(); const router = useRouter();
const unlockModeModal = ref()
const state = reactive({ const state = reactive({
routerId: storage.get("routerId") routerId: storage.get("routerId")
? JSON.parse(storage.get("routerId")) ? JSON.parse(storage.get("routerId"))
@@ -1122,6 +1123,7 @@ export default {
// name: "默认关卡", // name: "默认关卡",
// }, // },
], ],
unlockMode: 1, // 学习模式
tableData: [ tableData: [
// { // {
// key: 1, // key: 1,
@@ -1211,6 +1213,7 @@ export default {
styTitle: null, styTitle: null,
creTime: null, creTime: null,
picUrl: null, picUrl: null,
routerInfo:{},
//项目抽屉参数 //项目抽屉参数
time: undefined, time: undefined,
projId: null, //选项选到的id projId: null, //选项选到的id
@@ -1250,6 +1253,11 @@ export default {
state.value2 = ""; state.value2 = "";
state.updateChapterID = null; state.updateChapterID = null;
}; };
const successA = () =>{
getDetail()
}
//新建关卡 //新建关卡
const editChapter = () => { const editChapter = () => {
if (!state.value1) return message.warning("请输入关卡名称"); if (!state.value1) return message.warning("请输入关卡名称");
@@ -1465,6 +1473,7 @@ export default {
getDetail(); getDetail();
}; };
const getDetail = () => { const getDetail = () => {
console.log('调用查询')
GetRouterDetail(state.routerId,"N") GetRouterDetail(state.routerId,"N")
.then((res) => { .then((res) => {
//给level赋初始值 //给level赋初始值
@@ -1472,6 +1481,8 @@ export default {
state.styTitle = res.data.data.routerInfo.name; state.styTitle = res.data.data.routerInfo.name;
state.creTime = res.data.data.routerInfo.createTime; state.creTime = res.data.data.routerInfo.createTime;
state.picUrl = res.data.data.routerInfo.picUrl; state.picUrl = res.data.data.routerInfo.picUrl;
state.unlockMode = res.data.data.routerInfo.unlockMode
state.routerInfo = res.data.data.routerInfo
//增加两个字段 //增加两个字段
state.level.forEach((item) => { state.level.forEach((item) => {
item["value"] = item.chapterId; item["value"] = item.chapterId;
@@ -1933,6 +1944,7 @@ export default {
}; };
return { return {
...toRefs(state), ...toRefs(state),
unlockModeModal,
// tableDataFunc, // tableDataFunc,
tableDataFunc2, tableDataFunc2,
showModal, showModal,
@@ -1989,6 +2001,7 @@ export default {
closedeleteAll, closedeleteAll,
subdeleteAll, subdeleteAll,
successA
}; };
}, },
}; };