Files
fe-manage/src/components/drawers/UnlockMode.vue
2023-02-02 09:24:26 +08:00

291 lines
7.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<a-drawer
:visible="unlockModeVisible"
class="drawerStyle unlockmode"
placement="right"
width="70%"
@after-visible-change="afterVisibleChange"
>
<div class="drawerMain">
<div class="header">
<div class="headerTitle">选择解锁模式</div>
<img
style="width: 29px; height: 29px; cursor: pointer"
src="../../assets/images/basicinfo/close.png"
@click="closeDrawer"
/>
</div>
<div class="main">
<div class="classify">
<div
v-for="(item, index) in classify"
:key="index"
class="classifyItem"
@click="selectClassify(item)"
:style="{
color: item.type === selectClassifyType ? '#FFFFFF' : '#999999',
'background-color':
item.type === selectClassifyType ? '#4ea6ff' : '#FFFFFF',
border:
item.type === selectClassifyType
? '1px solid #4ea6ff'
: '1px solid #999999',
}"
>
{{ item.text }}
</div>
</div>
<div v-if="selectClassifyType === 1" class="type1">
<span style="font-weight: 500">描述</span
><span>不设学习限制学员可以在任何时间学习</span>
</div>
<div v-if="selectClassifyType === 2" class="type1 type2">
<div>
<span style="font-weight: 500">描述</span
><span>辩论活动测评调研投票按照设置时间</span>
</div>
<div class="radio">
<span>解锁单元</span>
<a-radio v-model:checked="checked">逐个任务解锁</a-radio>
</div>
</div>
<div v-if="selectClassifyType === 3" class="type1 type3">
<div>
<span style="font-weight: 500">描述</span
><span>前一个阶段达成目标后解锁下一个阶段</span>
</div>
<div class="radio" style="display: flex">
<div style="margin-top: 1px">解锁条件</div>
<a-radio-group v-model:value="radioSelect">
<div>
<a-radio :value="1"
>逐个任务解锁完成一个任务后解锁下一个</a-radio
>
</div>
<div style="margin-top: 24px">
<a-radio :value="2"
>完成当前阶段所有必修任务解锁下一阶段</a-radio
>
</div>
</a-radio-group>
</div>
</div>
</div>
<div class="btnn">
<button class="btn1" @click="closeDrawer">取消</button>
<button class="btn2" @click="saveUnlock">确定</button>
</div>
</div>
</a-drawer>
</template>
<script>
import { reactive, toRefs } from "vue";
import { editRoutered } from '@/api/indexLearningPath'
import { message } from "ant-design-vue";
// import { watch } from '@vue/runtime-core'
export default {
name: "UnlockMode",
props:{
unlockModeVisible:{
type: Boolean,
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) {
console.log("获取属性",props)
const state = reactive({
classify: [
{
type: 1,
text: "自由学习模式",
},
{
type: 2,
text: "按学习时间解锁",
},
{
type: 3,
text: "闯关模式",
},
],
selectClassifyType: 1,
checked: true,
radioSelect: 1,
formData: {
routerId:'',
organizationName:'',
organizationId:'',
name:'',
picUrl:'',
remark:'',
status:'', // 0 草稿 1 已发布 -1 已停用
attach:'',
attachSwitch:'',
enablePreview:'',
previewSetting:'',
enableStudy:'',
studySetting:'',
unlockMode:'',
}
});
const closeDrawer = () => {
state.selectClassifyType = 1;
state.checked = true;
state.radioSelect = 1;
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) => {
if(bool){
for(let key in state.formData){
state.formData[key] = props.routerInfo[key]
}
}
};
const selectClassify = (e) => {
state.selectClassifyType = e.type;
state.formData.unlockMode = e.type
};
return {
...toRefs(state),
afterVisibleChange,
closeDrawer,
saveUnlock,
// change,
selectClassify,
};
},
};
</script>
<style lang="scss">
.unlockmode {
.drawerMain {
min-width: 600px;
margin: 0px 32px 0px 32px;
overflow-x: auto;
display: flex;
flex-direction: column;
.header {
height: 73px;
border-bottom: 1px solid #e8e8e8;
display: flex;
justify-content: space-between;
align-items: center;
// background-color: red;
margin-bottom: 20px;
.headerTitle {
font-size: 18px;
font-weight: 600;
color: #333333;
line-height: 25px;
// margin-left: 24px;
}
}
.main {
display: flex;
flex-direction: column;
.classify {
display: flex;
.classifyItem {
width: 160px;
height: 38px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 4px;
border: 1px solid #999999;
font-size: 16px;
font-weight: 500;
color: #999999;
line-height: 22px;
margin-right: 16px;
cursor: pointer;
}
}
.type1 {
margin-top: 50px;
font-size: 14px;
font-weight: 400;
color: #333333;
line-height: 20px;
}
.radio {
margin-top: 24px;
}
}
.btnn {
height: 72px;
width: 100%;
position: absolute;
bottom: 0;
left: 0;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0px 1px 35px 0px rgba(118, 136, 166, 0.16);
.btn1 {
width: 100px;
height: 40px;
border: 1px solid #4ea6ff;
border-radius: 8px;
color: #4ea6ff;
background-color: #fff;
cursor: pointer;
}
.btn2 {
cursor: pointer;
width: 100px;
height: 40px;
background: #4ea6ff;
border-radius: 8px;
border: 0;
margin-left: 15px;
color: #fff;
}
}
}
}
</style>