src/layout/components/Navbar.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/onlineEducation/courseManage/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/onlineEducation/questionBankManagement/questionManage/components/questionDialog.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/onlineEducation/systemManage/user/components/userDialog.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/layout/components/Navbar.vue
@@ -24,9 +24,10 @@ </template> <div class="avatar-container"> <el-dropdown @command="handleCommand" class="right-menu-item hover-effect" trigger="click"> <div class="avatar-wrapper"> <div class="avatar-wrapper" style="display: flex;align-items: center"> <!-- <img :src="userStore.avatar" class="user-avatar" />--> <img src="../../assets/images/avator.png" class="user-avatar" /> <img src="../../assets/images/avator.png" class="user-avatar" /> <span>{{userName}}</span> <el-icon><caret-bottom /></el-icon> </div> <template #dropdown> @@ -83,9 +84,11 @@ const regRef = ref(null) const superRef = ref(); const userInfo = ref(); const userName = ref('') onMounted(()=>{ if(getToken()){ userInfo.value = JSON.parse(Cookies.get('userInfo')) userName.value = userInfo.value.username console.log("userInfo",userInfo.value ) } // getState(); @@ -214,6 +217,7 @@ height: 100%; line-height: 50px; display: flex; align-items: center; &:focus { outline: none; @@ -241,7 +245,7 @@ margin-right: 40px; .avatar-wrapper { margin-top: 5px; margin-top: 15px; position: relative; .user-avatar { @@ -249,13 +253,13 @@ width: 40px; height: 40px; border-radius: 10px; margin-right: 15px; } i { cursor: pointer; position: absolute; right: -20px; top: 25px; font-size: 12px; } } src/views/onlineEducation/courseManage/index.vue
@@ -11,7 +11,7 @@ <!-- 表格数据 --> <el-table v-loading="loading" :data="dataList" :border="true"> <el-table-column label="序号" type="index" align="center" width="80" /> <el-table-column label="封面" prop="logo" align="center" > <el-table-column label="封面" prop="logo" align="center" width="130"> <template #default="scope"> <div class="demo-image__preview" v-if="scope.row.logo && scope.row.logo.length>0"> <el-image src/views/onlineEducation/questionBankManagement/questionManage/components/questionDialog.vue
@@ -40,60 +40,31 @@ <el-input v-model.trim="state.form.title" type="textarea" placeholder="请输入题目内容"></el-input> </el-form-item> <el-form-item label="选项:" prop="content"> <div v-if="state.form.questionType === 1" style="width: 100%"> <div v-for="(item,index) in 4" :key="index" > <div style="display: flex;"> <span>{{item ===1 ? 'A':item ===2 ? 'B' : item ===3 ? 'C' : 'D'}}</span> <el-input type="textarea" v-model="state.singleQuestion.items[index].content" placeholder="请输入选项内容" style="width: 100%;margin-left: 20px;margin-bottom: 10px"></el-input> <div style="display: flex;flex-direction: column;width: 100%"> <el-button type="primary" @click="addOption" size="default" style="width: 65px;margin-bottom: 15px">添加</el-button> <div v-for="(item,index) in state.optionItem.items" :key="index" style="width: 100%"> <div style="display: flex;align-items: center"> <span>{{String.fromCharCode(index + 65)}}</span> <el-input type="textarea" v-model="state.optionItem.items[index].content" placeholder="请输入选项内容" style="width: 100%;margin-left: 20px;margin-bottom: 10px"></el-input> <Delete style="width: 15px; height: 15px; margin-left: 8px;color: #ed5565" @click="delOption(index)" /> </div> </div> <div style="display: flex"> <span style="width: 50px">解析:</span> <el-input type="textarea" v-model="state.singleQuestion.analyze" placeholder="请输入题目解析" style="width: 100%;margin-bottom: 10px"></el-input> </div> </div> <div v-else-if="state.form.questionType === 2" style="width: 100%"> <div v-for="(item,index) in 4" :key="index" > <div style="display: flex;"> <span>{{item ===1 ? 'A':item ===2 ? 'B' : item ===3 ? 'C' : 'D'}}</span> <el-input type="textarea" v-model="state.multiQuestion.items[index].content" placeholder="请输入选项内容" style="width: 100%;margin-left: 20px;margin-bottom: 10px"></el-input> </div> </div> <div style="display: flex"> <span style="width: 50px">解析:</span> <el-input type="textarea" v-model="state.multiQuestion.analyze" placeholder="请输入题目解析" style="width: 100%;margin-bottom: 10px"></el-input> </div> </div> <div v-else style="width: 100%"> <div v-for="(item,index) in 2" :key="index" > <div style="display: flex;"> <span>{{item ===1 ? 'A': 'B'}}</span> <el-input v-model="state.judgeQuestion.items[index].content" style="width: 100%;margin-left: 20px;margin-bottom: 10px" disabled></el-input> </div> </div> <div style="display: flex"> <span style="width: 50px">解析:</span> <el-input type="textarea" v-model="state.judgeQuestion.analyze" placeholder="请输入题目解析" style="width: 100%;margin-bottom: 10px"></el-input> </div> </div> </el-form-item> <el-form-item label="解析:" prop="answer"> <el-input type="textarea" v-model="state.optionItem.analyze" placeholder="请输入题目解析" style="width: 100%;margin-bottom: 10px"></el-input> </el-form-item> <el-form-item label="正确答案:" prop="answer"> <el-radio-group v-model="state.form.answer" v-if="state.form.questionType === 1"> <el-radio :label="'A'">A</el-radio> <el-radio :label="'B'">B</el-radio> <el-radio :label="'C'">C</el-radio> <el-radio :label="'D'">D</el-radio> <el-radio-group v-model="state.form.answer" v-if="state.form.questionType === 1 || state.form.questionType === 3"> <div v-for="(item,index) in state.optionItem.items"> <el-radio :label="String.fromCharCode(index + 65)" style="margin-left: 20px">{{String.fromCharCode(index + 65)}}</el-radio> </div> </el-radio-group> <el-checkbox-group v-model="state.checkList" v-if="state.form.questionType === 2" @change="changeCheckBox"> <el-checkbox label="A"></el-checkbox> <el-checkbox label="B"></el-checkbox> <el-checkbox label="C"></el-checkbox> <el-checkbox label="D"></el-checkbox> <el-checkbox-group v-model="state.checkList" v-if="state.form.questionType === 2" style="display: flex" > <div v-for="(item,index) in state.optionItem.items"> <el-checkbox :label="String.fromCharCode(index + 65)" style="margin-left: 20px;">{{String.fromCharCode(index + 65)}}</el-checkbox> </div> </el-checkbox-group> <el-radio-group v-model="state.form.answer" v-if="state.form.questionType === 3"> <el-radio :label="'A'">A</el-radio> <el-radio :label="'B'">B</el-radio> </el-radio-group> </el-form-item> </el-form> <template #footer> @@ -108,6 +79,7 @@ <script setup> import {reactive, ref, toRefs} from 'vue' import {ElMessage} from "element-plus"; import {Delete} from "@element-plus/icons-vue"; import { getClassification @@ -135,7 +107,7 @@ form: { id: '', title: '', questionType: 1, questionType: null, bankName: '', bankId: null, answer: '' @@ -166,60 +138,9 @@ name: '判断题' } ], singleQuestion: { optionItem: { analyze: '', items: [ { prefix:"A", content: '' }, { prefix:"B", content: '' }, { prefix:"C", content: '' }, { prefix:"D", content: '' }, ] }, judgeQuestion: { analyze: '', items: [ { prefix:"A", content: '是' }, { prefix:"B", content: '否' }, ] }, multiQuestion: { analyze: '', items: [ { prefix:"A", content: '' }, { prefix:"B", content: '' }, { prefix:"C", content: '' }, { prefix:"D", content: '' }, ] items: [] }, checkList: [], bankList: [], @@ -239,6 +160,19 @@ }) } const addOption = () => { const obj = { prefix:"", content: '' } state.optionItem.items.push(obj) } const delOption = (val) => { state.optionItem.items.splice(val,1) console.log(" state.optionItem.items.", state.optionItem.items) } const openDialog = async (type, value) => { await loadMoreBankData(); const userInfo = JSON.parse(Cookies.get('userInfo')) @@ -257,12 +191,8 @@ const res = await getQuestionById(value.id) if(res.code === 200){ state.form = res.data if(res.data.questionType === 1){ state.singleQuestion = JSON.parse(res.data.content) }else if(res.data.questionType === 3) { state.judgeQuestion = JSON.parse(res.data.content) }else { state.multiQuestion = JSON.parse(res.data.content) state.optionItem = JSON.parse(res.data.content) if(res.data.questionType === 2){ state.checkList = res.data.answer.split(',') } }else{ @@ -300,7 +230,19 @@ if(title.value === '新增'){ const {id,bankName, ...data} = JSON.parse(JSON.stringify(state.form)) data.answer = data.questionType === 1 || data.questionType === 3 ? data.answer : state.checkList.join(',') data.content = data.questionType === 1 ? JSON.stringify(state.singleQuestion) : data.questionType === 2 ? JSON.stringify(state.multiQuestion) : JSON.stringify(state.judgeQuestion) // data.content = data.questionType === 1 ? JSON.stringify(state.singleQuestion) : data.questionType === 2 ? JSON.stringify(state.multiQuestion) : JSON.stringify(state.judgeQuestion) const options = state.optionItem.items.map((op,index) => { return { prefix: String.fromCharCode(index + 65), content: op.content, } }) data.content = JSON.stringify( { analyze: state.optionItem.analyze, items: options } ) console.log('state.form',data) const res = await addQuestion(data) if(res.code === 200){ @@ -318,7 +260,19 @@ }else if(title.value === '编辑'){ const {bankName,...data} = JSON.parse(JSON.stringify(state.form)) data.answer = data.questionType === 1 || data.questionType === 3 ? data.answer : state.checkList.join(',') data.content = data.questionType === 1 ? JSON.stringify(state.singleQuestion) : data.questionType === 2 ? JSON.stringify(state.multiQuestion) : JSON.stringify(state.judgeQuestion) // data.content = data.questionType === 1 ? JSON.stringify(state.singleQuestion) : data.questionType === 2 ? JSON.stringify(state.multiQuestion) : JSON.stringify(state.judgeQuestion) const options = state.optionItem.items.map((op,index) => { return { prefix: String.fromCharCode(index + 65), content: op.content, } }) data.content = JSON.stringify( { analyze: state.optionItem.analyze, items: options } ) const res = await editQuestion(data) if(res.code === 200){ ElMessage({ @@ -347,66 +301,15 @@ state.form = { id: '', title: '', questionType: 1, questionType: null, bankName: '', bankId: null, answer: '' } state.singleQuestion= { state.optionItem = { analyze: '', items: [ { prefix:"A", content: '' }, { prefix:"B", content: '' }, { prefix:"C", content: '' }, { prefix:"D", content: '' }, ] items: [] } state.judgeQuestion= { analyze: '', items: [ { prefix:"A", content: '是' }, { prefix:"B", content: '否' }, ] } state. multiQuestion= { analyze: '', items: [ { prefix:"A", content: '' }, { prefix:"B", content: '' }, { prefix:"C", content: '' }, { prefix:"D", content: '' }, ] }, state.bankPageNum = 1; state.bankPageSize = 10; state.bankList = [] src/views/onlineEducation/systemManage/user/components/userDialog.vue
@@ -31,30 +31,50 @@ <el-form-item label="用户类型:" v-if="state.title !== '修改密码'"> <el-radio-group v-model="state.form.userType" :disabled="disabled" @change="changeType"> <el-radio :label="0" v-if="state.isAdmin">管理员</el-radio> <el-radio :label="1">企业级</el-radio> <el-radio :label="2">部门级</el-radio> <el-radio :label="3">车间(岗位)级</el-radio> <el-radio :label="4">其他</el-radio> <el-radio :label="1" v-if="state.isAdmin">企业级</el-radio> <el-radio :label="2" v-if="!state.isAdmin">部门级</el-radio> <el-radio :label="3" v-if="!state.isAdmin">车间(岗位)级</el-radio> <el-radio :label="4" v-if="state.isAdmin">其他</el-radio> </el-radio-group> </el-form-item> <el-form-item label="选择所属父级账号:" prop="companyId" v-if="state.title !== '修改密码' && state.form.userType !== 0"> <el-select v-if="state.isAdmin" v-model="state.form.companyName" @change="selectValue" style="width: 45%" v-loadMore="loadMore" class="m-2" placeholder="请选择所属企业" popper-class="more_select_dropdown" > <el-option v-for="item in state.companyList" :key="item.id" :label="item.name" :value="item.name" /> </el-select> <el-form-item label="选择上级企业:" prop="companyName" v-if="state.title !== '修改密码' && state.form.userType !== 0"> <el-select v-if="state.isAdmin" v-model="state.form.companyName" filterable remote @change="selectValue" reserve-keyword placeholder="请输入企业名称" remote-show-suffix :remote-method="getCompanyList" :loading="loading" style="width: 240px" > <el-option v-for="item in state.companyList" :key="item.id" :label="item.name" :value="item.name" /> </el-select> <!-- <el-select--> <!-- v-if="state.isAdmin"--> <!-- v-model="state.form.companyName"--> <!-- @change="selectValue"--> <!-- style="width: 45%"--> <!-- v-loadMore="loadMore"--> <!-- class="m-2"--> <!-- placeholder="请选择所属企业"--> <!-- popper-class="more_select_dropdown"--> <!-- >--> <!-- <el-option--> <!-- v-for="item in state.companyList"--> <!-- :key="item.id"--> <!-- :label="item.name"--> <!-- :value="item.name"--> <!-- />--> <!-- </el-select>--> <el-input v-else disabled style="width: 45%" v-model="state.form.companyName"></el-input> <scorllSelect :disabled="disabled" @@ -135,6 +155,38 @@ } } } const startUsername = ref(''); const validateUsername = (rule, value, callback)=>{ if(value === ''){ callback(new Error('请输入用户名')) }else if(state.title == '编辑' && value == startUsername.value){ callback() }else{ if(!verifyUsername(value)){ callback(new Error('用户名须使用字母或数字,长度在5-16之间')) }else{ let param = {} if(state.title=='新增/注册') { param = { username:value } }else if(state.title=='编辑'){ param = { username:value, id: state.registerForm.id } } callback() // checkUserName(param).then((res)=>{ // if(res.data == false){ // callback(new Error('用户名已被占用,请更换其他用户名')) // }else{ // callback() // } // }) } } } const state = reactive({ title: '', @@ -152,7 +204,8 @@ }, formRules:{ name: [{ required: true, message: '请输入公司、部门或者车间岗位名称', trigger: 'blur' }], username: [{ required: true, message: '请输入用户名', trigger: 'blur' }], companyName: [{ required: true, message: '请选择上级企业', trigger: 'blur' }], username: [{ required: true, trigger: "blur", validator: validateUsername }], password: [{ required: true, validator: validatePwd, trigger: 'blur' }], confirmPassword: [{ required: true, validator: equalToPassword, trigger: 'blur' }], phone: [{ required: true, validator: validateUserPhone, trigger: 'blur' }], @@ -192,10 +245,13 @@ } if(type !== 'view' && type !== 'pwd'){ await getCompanyList('open') if(state.isAdmin){ // await getCompanyList('open') } } state.title = type === 'add' ? '新增' : type ==='edit' ? '编辑' : type ==='pwd' ? '修改密码' : '查看' ; if(type === 'edit' || type === 'view') { startUsername.value = value.username if( type === 'view'){ disabled.value = true; } @@ -222,31 +278,47 @@ } const finshed = ref(false) const getCompanyList = async (type)=>{ if (type === 'open' && state.pageNum !== 1) { } else { const loading = ref(false) const getCompanyList = async (val)=>{ if(val != ""){ loading.value = true; const queryParams = { pageNum: state.pageNum, pageSize: state.pageSize, name: val } const res = await getCompany(queryParams) if (res.code == 200) { if (res.data.pageNum === state.pageNum) { finshed.value = false; if (state.pageNum == 1) { state.companyList = res.data.list } else { state.companyList = state.companyList.concat(res.data.list) } } else { finshed.value = true; } loading.value = false; state.companyList = res.data.list } else { ElMessage.warning(res.message) } console.log("state.companyList",state.companyList) } // if (type === 'open' && state.pageNum !== 1) { // } else { // const queryParams = { // pageNum: state.pageNum, // pageSize: state.pageSize, // } // const res = await getCompany(queryParams) // if (res.code == 200) { // if (res.data.pageNum === state.pageNum) { // finshed.value = false; // if (state.pageNum == 1) { // state.companyList = res.data.list // } else { // state.companyList = state.companyList.concat(res.data.list) // } // } else { // finshed.value = true; // } // // } else { // ElMessage.warning(res.message) // } // console.log("state.companyList",state.companyList) // } } const onSubmit = async () => { const valid = await superRef.value.validate(); @@ -301,6 +373,7 @@ scrollRef.value.getList(param,'change'); } const changeType = () => { state.companyList = []; if(state.isAdmin){ state.form.companyId = null; state.form.companyName = ''; @@ -337,16 +410,16 @@ superRef.value.resetFields() dialogVisible.value = false; } //触底函数 const loadMore = () => { console.log(' 触底了'); // 防抖处理 setTimeout(() => { if (finshed.value) return //值为true,则代表没有数据了 state.pageNum += 1 getCompanyList('') }, 500) } // //触底函数 // const loadMore = () => { // console.log(' 触底了'); // // 防抖处理 // setTimeout(() => { // if (finshed.value) return //值为true,则代表没有数据了 // state.pageNum += 1 // getCompanyList('') // }, 500) // } const selectValue = (val) => { state.form.parentId = null;