修改教师管理和试卷管理逻辑,优化手机端样式
This commit is contained in:
		
							
								
								
									
										18
									
								
								src/api/userManage.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/api/userManage.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| import service from '@/utils/request' | ||||
| const api = { | ||||
|   // 积分 | ||||
|   getUserList : data => { | ||||
|     return service({ | ||||
|       url: '/user', | ||||
|       method: 'get', | ||||
|       params:data | ||||
|     }) | ||||
|   }, | ||||
|   viewUser : data => { | ||||
|     return service({ | ||||
|       url: '/user/'+data.id, | ||||
|       method: 'get' | ||||
|     }) | ||||
|   } | ||||
| } | ||||
| export default api | ||||
| @@ -1,3 +1,4 @@ | ||||
| import cityList from '@/utils/city.json'; | ||||
| const custom = { | ||||
|   getStdSubject: (data) => { // 获取标准类型格式 | ||||
|     let arr= [] | ||||
| @@ -61,6 +62,11 @@ const custom = { | ||||
|         break; | ||||
|     } | ||||
|     return name | ||||
|   }, | ||||
|   getProvinceName(province) { | ||||
|     if(province < 0 || !province) return '' | ||||
|     return cityList[province].name | ||||
|   } | ||||
|  | ||||
| } | ||||
| export default custom | ||||
|   | ||||
| @@ -129,7 +129,7 @@ function addChapterchildFunc(item) { // 打开新增子章节窗口 | ||||
| function editChapterChildFunc(item,main_index) { // 打开编辑子章节窗口 | ||||
|   dialogChapterChildTitle.value = '编辑子章节' | ||||
|   // current_chapter.value = chapter_data.value[main_index] | ||||
|   item.exam_ids =item.exam_id?[item.exam_id]: [] | ||||
|   // item.exam_ids =item.exam_id?[item.exam_id]: [] | ||||
|   item.examination_id = item.exam_id | ||||
|   chapterChildForm.value = _.cloneDeep(item) | ||||
|   dialogChapterChildVisible.value = true | ||||
| @@ -165,16 +165,10 @@ async function enterChapterChildDialog() { // 提交小章节 | ||||
| function getFilePath(file) { // 获取上传文件之后的地址 | ||||
|   chapterChildForm.value.url = file.url | ||||
|   chapterChildForm.value.url_name = file.url_name | ||||
| } | ||||
| function chooseChapterChildExercises() { // 打开选择习题窗口 | ||||
|  | ||||
| } | ||||
| function openExercisesWinFunc() { // 打开媒体库 | ||||
|  | ||||
| } | ||||
| function addExamFunc(data) { | ||||
|   chapterChildForm.value.examination_id = data[0] | ||||
|   chapterChildForm.value.exam_ids = data | ||||
|   chapterChildForm.value.examination_id = data | ||||
|   chapterChildForm.value.exam_id = data | ||||
| } | ||||
| </script> | ||||
| <template> | ||||
| @@ -299,7 +293,7 @@ function addExamFunc(data) { | ||||
|         </el-form-item> | ||||
|         <el-form-item label="试卷管理"> | ||||
|           <!--          <el-button size="small" @click="chooseChapterChildExercises">添加习题</el-button>--> | ||||
|           <exam-com @addFunc="addExamFunc" :seleted_arr="chapterChildForm.exam_ids" /> | ||||
|           <exam-com @addFunc="addExamFunc" :seleted_id="chapterChildForm.exam_id" /> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="章节价格" prop="price"> | ||||
|           <el-input type="number" v-model="chapterChildForm.price" placeholder="输入章节价格" autocomplete="off" /> | ||||
|   | ||||
| @@ -13,17 +13,17 @@ const route = useRoute() | ||||
| import { useUserStore } from '@/pinia/modules/user' | ||||
| const userStore = useUserStore() | ||||
| // import chapterCom from '../components/chapter.vue' | ||||
| const props = defineProps(['url_name','seleted_arr']) | ||||
| const props = defineProps(['url_name','seleted_id']) | ||||
| const emit = defineEmits(['addFunc']) | ||||
| // import { clients, getNowDate } from '@/utils' | ||||
| import custom from '@/utils/custom' | ||||
| // import { getToken } from '@/utils/auth' | ||||
| // 监听 | ||||
| watch(props,(val1,val2) => { | ||||
|   selected_exam_ids.value = val1.seleted_arr || [] | ||||
|   selected_exam_id.value = val1.seleted_id || '' | ||||
| }) | ||||
| // 变量 | ||||
| const selected_exam_ids = ref(props.seleted_arr || []) | ||||
| const selected_exam_id = ref(props.seleted_id || '') | ||||
|  | ||||
| // const headers = ref({ Authorization: 'Bearer ' + getToken() }) | ||||
| const drawer = ref(false) | ||||
| @@ -37,7 +37,8 @@ const queryParams =ref({ | ||||
| const typeList = custom.getExercisesTypeList() | ||||
| const tableData =ref([]) | ||||
| const total = ref(0) | ||||
| const exam_ids = ref([]) | ||||
| // const exam_ids = ref([]) | ||||
| const exam_id = ref(null) | ||||
| // 生命周期 | ||||
| const subjectList = inject('subjectList') | ||||
| // console.log(subjectList.value) | ||||
| @@ -91,9 +92,6 @@ function onReset() { | ||||
|     status:'', | ||||
|   } | ||||
| } | ||||
| const handleSelectionChange = (val) => { | ||||
|   exam_ids.value = val | ||||
| } | ||||
| function handleCurrentChange(val) { | ||||
|   queryParams.value.page = val | ||||
|   getExaminationList() | ||||
| @@ -103,23 +101,30 @@ function handleSizeChange(val) { | ||||
|   getExaminationList() | ||||
| } | ||||
| function addFunc() { | ||||
|   const list = exam_ids.value.map((item,i) => { | ||||
|     return item.exam.exam_id | ||||
|   }) | ||||
|   // const list = exam_ids.value.map((item,i) => { | ||||
|   //   return item.exam.exam_id | ||||
|   // }) | ||||
|   // console.log(list) | ||||
|   emit('addFunc',list) | ||||
|   emit('addFunc',exam_id.value) | ||||
|   drawer.value = false | ||||
| } | ||||
| const multipleTableRef = ref(null) | ||||
| const toggleSelection = (rows) => { // 判断是否被选中 | ||||
|   // console.log(selected_exam_id.value) | ||||
|   if(!selected_exam_id.value) { | ||||
|     multipleTableRef.value.setCurrentRow() | ||||
|     return | ||||
|   } | ||||
|   if (rows) { | ||||
|     rows.forEach((row) => { | ||||
|       if(selected_exam_ids.value.length>0 && selected_exam_ids.value.includes(row.exam.exam_id)) { | ||||
|         multipleTableRef.value.toggleRowSelection(row, true) | ||||
|       } | ||||
|       else{ | ||||
|         multipleTableRef.value.toggleRowSelection(row, false) | ||||
|       if(selected_exam_id.value == row.exam.exam_id) { | ||||
|         // multipleTableRef.value.toggleRowSelection(row, true) | ||||
|         multipleTableRef.value.setCurrentRow(row) | ||||
|       } | ||||
|       // else{ | ||||
|         // multipleTableRef.value.toggleRowSelection(row, false) | ||||
|         // multipleTableRef.value.setCurrentRow() | ||||
|       // } | ||||
|     }) | ||||
|   } else { | ||||
|     multipleTableRef.value.clearSelection() | ||||
| @@ -138,10 +143,15 @@ function getStateName(state) { | ||||
|   } | ||||
|   return str | ||||
| } | ||||
| function handleChooseChange(row) { | ||||
|   if(row) { | ||||
|     exam_id.value = row.exam.exam_id | ||||
|   } | ||||
| } | ||||
| </script> | ||||
| <template> | ||||
|   <div> | ||||
|     <el-button v-if="selected_exam_ids.length==0" size="small" @click="chooseChapterChildExercises">添加试卷</el-button> | ||||
|     <el-button v-if="!selected_exam_id" size="small" @click="chooseChapterChildExercises">添加试卷</el-button> | ||||
|     <el-button v-else size="small" @click="chooseChapterChildExercises" type="plain">点击查看</el-button> | ||||
|     <div v-if="url_name">{{url_name}}</div> | ||||
|     <el-drawer v-model="drawer" title="试卷库" size="60%"> | ||||
| @@ -170,12 +180,12 @@ function getStateName(state) { | ||||
|         </div> | ||||
|         <!--      数据列表--> | ||||
|         <div class="list-box"> | ||||
|           <el-table ref="multipleTableRef" row-key="exam.exam_id" :data="tableData" @selection-change="handleSelectionChange"> | ||||
|             <el-table-column | ||||
|               type="selection" | ||||
|               width="55" | ||||
|               reserve-selection="true" | ||||
|             /> | ||||
|           <el-table ref="multipleTableRef" row-key="exam.exam_id" :data="tableData" highlight-current-row @current-change="handleChooseChange"> | ||||
| <!--            <el-table-column--> | ||||
| <!--              type="selection"--> | ||||
| <!--              width="55"--> | ||||
| <!--              reserve-selection="true"--> | ||||
| <!--            />--> | ||||
|             <el-table-column align="center" label="ID" min-width="60" prop="exam.exam_id" sortable="custom" /> | ||||
|             <el-table-column align="center" label="试卷名称" min-width="150" prop="exam.name" /> | ||||
|             <el-table-column align="center" label="科目" min-width="150" prop="exam.subject" /> | ||||
| @@ -204,24 +214,6 @@ function getStateName(state) { | ||||
|                 {{formatDate(scope.row.exam.CreatedAt)}} | ||||
|               </template> | ||||
|             </el-table-column> | ||||
| <!--            <el-table-column align="center" fixed="right" label="操作" width="200">--> | ||||
| <!--              <template #default="scope">--> | ||||
| <!--                <el-button--> | ||||
| <!--                  icon="edit"--> | ||||
| <!--                  size="small"--> | ||||
| <!--                  type="primary"--> | ||||
| <!--                  link--> | ||||
| <!--                  @click="editCourseFunc(scope.row)"--> | ||||
| <!--                >编辑</el-button>--> | ||||
| <!--                <el-button--> | ||||
| <!--                  icon="delete"--> | ||||
| <!--                  size="small"--> | ||||
| <!--                  type="danger"--> | ||||
| <!--                  link--> | ||||
| <!--                  @click="deleteExamFunc(scope.row)"--> | ||||
| <!--                >删除</el-button>--> | ||||
| <!--              </template>--> | ||||
| <!--            </el-table-column>--> | ||||
|           </el-table> | ||||
|           <div class="gva-pagination"> | ||||
|             <el-pagination | ||||
|   | ||||
| @@ -51,6 +51,7 @@ const content = ref(null) | ||||
| // const options = ref([]) // 答案选项数组 | ||||
| const exam_types = ref([]) | ||||
| const exam_ids = ref([]) | ||||
| const price_props = ['first','second','third'] | ||||
| // 生命周期 | ||||
| onMounted(() => { | ||||
|   getExaminationList() | ||||
| @@ -58,6 +59,14 @@ onMounted(() => { | ||||
| }) | ||||
| provide('subjectList', subjectList) | ||||
| provide('current_subject', current_subject) | ||||
| const std_group = ref({ | ||||
|   persons:'', | ||||
|   expiry_date:'', | ||||
|   public_date:'', | ||||
|   first:'', | ||||
|   second:'', | ||||
|   third:'' | ||||
| }) | ||||
| // 方法 | ||||
| async function getExaminationList() { | ||||
|   const res = await api.getExaminationList(queryParams.value) | ||||
| @@ -131,7 +140,12 @@ function editCourseFunc(row) { | ||||
|   form.value.course_ids = JSON.parse(row.exam.course_ids) | ||||
|   form.value.question_ids = JSON.parse(row.exam.question_ids) | ||||
|   exam_types.value = row.exam_types.map((item) => { | ||||
|     return item.persons | ||||
|     for(let prop in item) { | ||||
|       if(price_props.includes(prop)) { | ||||
|           item[prop] /= 100 | ||||
|       } | ||||
|     } | ||||
|     return item | ||||
|   }) | ||||
|   current_subject.value = form.value.subject | ||||
|   openDialog('edit') | ||||
| @@ -145,7 +159,7 @@ function deleteExamFunc(row) { | ||||
|   }) | ||||
|   .then(async() => { | ||||
|     const res = await api.delExamination({ | ||||
|           exam_ids:[row.exam_id] | ||||
|           exam_ids:[row.exam.exam_id] | ||||
|     }) | ||||
|     if (res.code === 0) { | ||||
|       ElMessage({ | ||||
| @@ -171,18 +185,27 @@ function closeDialog(){ | ||||
|   form.value = {} | ||||
| } | ||||
| async function enterDialog() { // 提交 | ||||
|   // console.log(Object.keys(std_group.value)) | ||||
|   form.value.teacher_id = 0 | ||||
|   form.value.exam_type = exam_types.value.map((item) => { | ||||
|     return item = parseInt(item) | ||||
|     for(let prop in item) { | ||||
|       if(Object.keys(std_group.value).includes(prop)) { | ||||
|         item[prop] = Number(item[prop]) | ||||
|         if(price_props.includes(prop)) { | ||||
|           item[prop] *= 100 | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|     return item | ||||
|   }) | ||||
|   form.value.duration = parseInt(form.value.duration) | ||||
|   // console.log(form.value,exam_types.value) | ||||
|   // return | ||||
|   const params = { | ||||
|     ...form.value | ||||
|   } | ||||
|   params.question_ids = JSON.stringify(form.value.question_ids) | ||||
|   params.course_ids = JSON.stringify(form.value.course_ids) | ||||
|   // console.log(params) | ||||
|   // return | ||||
|   let func_name = 'addExamination' | ||||
|   if(form.value.exam_id) { // 编辑 | ||||
|     func_name = 'editExamination' | ||||
| @@ -206,10 +229,10 @@ function getExercisesName(row) { | ||||
| } | ||||
| // const std_options_title = ref(['A','B','C','D','E','F']) | ||||
| function addOptionFunc() { | ||||
|   exam_types.value.push('') | ||||
|   exam_types.value.push(_.cloneDeep(std_group.value)) | ||||
| } | ||||
| function delet_func() { | ||||
|   exam_types.value.pop() | ||||
| function delet_func(i) { | ||||
|   exam_types.value.splice(i,1) | ||||
| } | ||||
| function getStateName(state) { | ||||
|   let str = '' | ||||
| @@ -386,14 +409,43 @@ function addCourseFunc(data) { | ||||
|         </el-form-item> | ||||
|         <el-form-item label="测试组别" > | ||||
|           <!--          <el-input v-model="form.score" placeholder="请输入分值" />--> | ||||
|           <view class="options-box"> | ||||
|             <view class="option-item" v-if="exam_types.length>0" v-for="(item,i) in exam_types"> | ||||
|               <view>{{i+1}}</view> | ||||
|               <el-input type="number" style="margin-left:5px" v-model="exam_types[i]" placeholder="请输入组别人数" /> | ||||
|               <el-icon style="margin-left: 5px;cursor: pointer" v-if="(i+1) == exam_types.length" @click="delet_func(item)"><Delete /></el-icon> | ||||
|             </view> | ||||
|           <div class="options-box" style="width: 100%"> | ||||
|             <div class="option-item" v-if="exam_types.length>0" v-for="(item,i) in exam_types"> | ||||
|               <el-form :model="item" > | ||||
|                 <div class="oi-row"> | ||||
|                   <div class="oi-item">{{i+1}}</div> | ||||
|                   <el-input class="oi-item" type="number" style="margin-left:5px;width: 30%" v-model="item.persons" placeholder="请输入组别人数" /> | ||||
|                   <el-date-picker class="oi-item" style="margin-left:5px" | ||||
|                     v-model="item.expiry_date" | ||||
|                     type="date" | ||||
|                     placeholder="截至日期" | ||||
|                     format="YYYY-MM-DD" | ||||
|                     value-format="x" | ||||
|                   /> | ||||
|                   <el-date-picker class="oi-item" style="margin-left:5px" | ||||
|                     v-model="item.public_date" | ||||
|                     type="date" | ||||
|                     placeholder="成绩公布日期" | ||||
|                     format="YYYY-MM-DD" | ||||
|                     value-format="x" | ||||
|                   /> | ||||
|                   <el-icon class="oi-item" style="margin-left: 5px;cursor: pointer" @click="delet_func(i)"><Delete /></el-icon> | ||||
|                 </div> | ||||
|                 <div class="reward-box"> | ||||
|                   <el-form-item class="rb-item" style="margin-right:10px;display: flex" label="第一名"> | ||||
|                     <el-input style="width:auto;margin-right: 5px" type="number" v-model="item.first" placeholder="请输入第一名奖励" /><div>元</div> | ||||
|                   </el-form-item> | ||||
|                   <el-form-item class="rb-item" style="margin-right:10px;" label="第二名"> | ||||
|                     <el-input style="width:auto;margin-right: 5px" type="number" v-model="item.second" placeholder="请输入第二名奖励" />元 | ||||
|                   </el-form-item> | ||||
|                   <el-form-item class="rb-item" style="margin-right:10px;" label="第三名"> | ||||
|                     <el-input style="width:auto;margin-right: 5px" type="number" v-model="item.third" placeholder="请输入第三名奖励" />元 | ||||
|                   </el-form-item> | ||||
|                 </div> | ||||
|               </el-form> | ||||
|             </div> | ||||
|             <el-button @click="addOptionFunc">添加组别</el-button> | ||||
|           </view> | ||||
|           </div> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="添加习题" > | ||||
|           <exercisesPool @addFunc="addExercisesFunc" :seleted_arr="form.question_ids" /> | ||||
| @@ -421,14 +473,24 @@ function addCourseFunc(data) { | ||||
|   </div> | ||||
| </template> | ||||
| <style scoped lang="scss"> | ||||
|   .rb-item{ | ||||
|     margin-bottom: 10px; | ||||
|   } | ||||
|   .e-img{ | ||||
|     width: 150px; | ||||
|     height: 100px; | ||||
|   } | ||||
|   .option-item{ | ||||
|     display: flex; | ||||
|     align-items: center; | ||||
|     border-bottom: 1px solid #ebebeb; | ||||
|     margin-bottom: 10px; | ||||
|     .oi-row{ | ||||
|       display: flex; | ||||
|       align-items: center; | ||||
|       margin-bottom: 10px; | ||||
|       .oi-item{ | ||||
|         //color: red; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   .button-box { | ||||
|     padding: 10px 20px; | ||||
|   | ||||
| @@ -1,375 +1,21 @@ | ||||
|  | ||||
| <script setup> | ||||
| // 引入依赖 | ||||
| import api from '@/api/teacher' | ||||
| import capi from '@/api/course' | ||||
| import custom from '@/utils/custom' | ||||
| import {formatDate} from '@/utils/format' | ||||
| // import { toSQLLine } from '@/utils/stringFun' | ||||
| // import WarningBar from '@/components/warningBar/warningBar.vue' | ||||
| // import coursePool from './components/coursePool.vue' | ||||
| // import exercisesPool from '@/view/course/components/exercisesPool.vue' | ||||
| import {ref,onMounted,provide } from 'vue' | ||||
| import { ElMessage, ElMessageBox } from 'element-plus' | ||||
| import { useRouter, useRoute } from 'vue-router' | ||||
| const router = useRouter() | ||||
| const route = useRoute() | ||||
| // store | ||||
| import { useUserStore } from '@/pinia/modules/user' | ||||
| const userStore = useUserStore() | ||||
| // 变量 | ||||
| const path = ref(import.meta.env.VITE_BASE_API) | ||||
| // const typeList = custom.getExercisesTypeList() | ||||
| const queryParams = ref({ | ||||
|   page:1, | ||||
|   pageSize:10, | ||||
|   name:'' | ||||
| }) | ||||
| const subjectParams = ref({ | ||||
|     pageIndex:1, | ||||
|     pageSize:100, | ||||
| }) | ||||
| const tableData = ref([]) | ||||
| const subjectList = ref([]) | ||||
| const current_subject = ref('') | ||||
| const deleteVisible = ref(false) | ||||
| const question_ids = ref([]) | ||||
| const total = ref(0) | ||||
| const dialogFormVisible = ref(false) | ||||
| const dialogTitle = ref('') | ||||
| const form =ref({}) | ||||
| const rules = ref({ | ||||
|   name: [{ required: true, message: '请输入课程名称', trigger: 'blur' }] | ||||
| }) | ||||
| const question_id = ref(0) | ||||
| const content = ref(null) | ||||
| // const options = ref([]) // 答案选项数组 | ||||
| const exam_types = ref([]) | ||||
| const exam_ids = ref([]) | ||||
| // 生命周期 | ||||
| onMounted(() => { | ||||
|   getTeacherList() | ||||
|   // getSubject() | ||||
| }) | ||||
| provide('subjectList', subjectList) | ||||
| provide('current_subject', current_subject) | ||||
| // 方法 | ||||
| async function getTeacherList() { | ||||
|   const res = await api.getTeacherList(queryParams.value) | ||||
|   if(res.code === 0) { | ||||
|     tableData.value = res.data.records | ||||
|     total.value = res.data.total | ||||
|   } | ||||
| } | ||||
| async function getSubject(){ // 获取课程分类 | ||||
|   const res = await capi.getSubjectList(subjectParams.value) | ||||
|   if(res.code === 0) { | ||||
|     subjectList.value = custom.getStdSubject(res.data.records) | ||||
|   } | ||||
| } | ||||
| function onSubmit() { | ||||
|   getTeacherList() | ||||
| } | ||||
| const onReset = () => { | ||||
|   queryParams.value = { | ||||
|     pageIndex:1, | ||||
|     pageSize:10, | ||||
|     name:'', | ||||
|     status:'', | ||||
|     subject:'' | ||||
|   } | ||||
| } | ||||
| function openDialog(type) { | ||||
|   // let params = {} | ||||
|   switch (type){ | ||||
|     case 'add': | ||||
|       dialogTitle.value = '新增试卷' | ||||
|         form.value = {} | ||||
|       break; | ||||
|     case 'edit': | ||||
|       // params.question_id = question_id.value | ||||
|       dialogTitle.value = '编辑试卷' | ||||
|       break; | ||||
|   } | ||||
|   dialogFormVisible.value = true | ||||
|   // router.push({name:'addCourse',params}) | ||||
| } | ||||
| async function onDelete() { | ||||
|   const ids = exam_ids.value | ||||
|   const res = await api.delExamination({ exam_ids:ids }) | ||||
|   if (res.code === 0) { | ||||
|     ElMessage({ | ||||
|       type: 'success', | ||||
|       message: res.msg | ||||
|     }) | ||||
|     // if (tableData.value.length === ids.length && page.value > 1) { | ||||
|     //   page.value-- | ||||
|     // } | ||||
|     deleteVisible.value = false | ||||
|     getTeacherList() | ||||
|   } | ||||
| } | ||||
| const handleSelectionChange = (val) => { | ||||
|   exam_ids.value = val.map((item) => { | ||||
|       return item.exam_id | ||||
|   }) | ||||
| } | ||||
| function editCourseFunc(row) { | ||||
|   row.course_ids = JSON.parse(row.course_ids) | ||||
|   row.question_ids = JSON.parse(row.question_ids) | ||||
|  | ||||
|   form.value = row.exam | ||||
|   exam_types.value = row.exam_types.map((item) => { | ||||
|     return item.persons | ||||
|   }) | ||||
|   current_subject.value = form.value.subject | ||||
|   openDialog('edit') | ||||
| } | ||||
| function deleteExamFunc(row) { | ||||
|   ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', { | ||||
|     confirmButtonText: '确定', | ||||
|     cancelButtonText: '取消', | ||||
|     type: 'warning' | ||||
|   }) | ||||
|   .then(async() => { | ||||
|     const res = await api.delExamination({ | ||||
|           exam_ids:[row.exam_id] | ||||
|     }) | ||||
|     if (res.code === 0) { | ||||
|       ElMessage({ | ||||
|         type: 'success', | ||||
|         message: '删除成功!' | ||||
|       }) | ||||
|       getTeacherList() | ||||
|     } | ||||
|   },() => { | ||||
|   }) | ||||
| } | ||||
| function handleCurrentChange(val) { | ||||
|   queryParams.value.pageIndex = val | ||||
|   getTeacherList() | ||||
| } | ||||
| function handleSizeChange(val) { | ||||
|   queryParams.value.pageSize = val | ||||
|   getTeacherList() | ||||
| } | ||||
| function closeDialog(){ | ||||
|   dialogFormVisible.value = false | ||||
|   exam_types.value = [] | ||||
|   form.value = {} | ||||
| } | ||||
| async function enterDialog() { // 提交 | ||||
|   form.value.teacher_id = 0 | ||||
|   form.value.exam_type = exam_types.value.map((item) => { | ||||
|     return item = parseInt(item) | ||||
|   }) | ||||
|   form.value.duration = parseInt(form.value.duration) | ||||
|   // return | ||||
|   const params = { | ||||
|     ...form.value | ||||
|   } | ||||
|   params.question_ids = JSON.stringify(form.value.question_ids) | ||||
|   params.course_ids = JSON.stringify(form.value.course_ids) | ||||
|   let func_name = 'addExamination' | ||||
|   if(form.value.exam_id) { // 编辑 | ||||
|     func_name = 'editExamination' | ||||
|   } | ||||
|   const res = await api[func_name](params) | ||||
|   if(res.code === 0) { | ||||
|     ElMessage({ | ||||
|       type: 'success', | ||||
|       message: res.msg | ||||
|     }) | ||||
|     closeDialog() | ||||
|     getTeacherList() | ||||
|   } | ||||
| } | ||||
| function viewTeacherFunc(row) { // 查看订单 | ||||
|   console.log(row) | ||||
|   router.push({name:'teacherDetail',params:{id:row.teacher_info_id}}) | ||||
| } | ||||
| function getExercisesName(row) { | ||||
|   return JSON.parse(row.question).title | ||||
| } | ||||
| // const std_options_title = ref(['A','B','C','D','E','F']) | ||||
| function addOptionFunc() { | ||||
|   exam_types.value.push('') | ||||
| } | ||||
| function delet_func() { | ||||
|   exam_types.value.pop() | ||||
| } | ||||
| function getStateName(state) { | ||||
|   let str = '' | ||||
|   switch (state){ | ||||
|     case 1: | ||||
|         str = '未付款' | ||||
|       break; | ||||
|     case 2: | ||||
|         str = '已付款' | ||||
|       break; | ||||
|     case 3: | ||||
|         str = '已过期' | ||||
|       break; | ||||
|   } | ||||
|   return str | ||||
| } | ||||
| function handleAvatarSuccess(res) { | ||||
|   form.value.cover = res.data.file.url | ||||
|   // handlerChange() | ||||
| } | ||||
| function beforeAvatarUpload(file) { | ||||
|   const isLt05M = file.size / 1024 / 1024 < 20 | ||||
|   const isJPG = file.type.indexOf('image/') === -1 | ||||
|   if (isJPG) { | ||||
|     ElMessage.error('文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件') | ||||
|   } | ||||
|   if (!isLt05M) { | ||||
|     ElMessage.error('上传头像图片大小不能超过 2M!') | ||||
|   } | ||||
|   return !isJPG && isLt05M | ||||
| } | ||||
| function changeSubjectFunc(e) { | ||||
|   current_subject.value = e | ||||
| } | ||||
| function addExercisesFunc(data) { | ||||
|   form.value.question_ids = data | ||||
| } | ||||
| function addCourseFunc(data) { | ||||
|   form.value.course_ids = data | ||||
| } | ||||
| function getTypeName(type) { | ||||
|   let name = "" | ||||
|   switch (type) { | ||||
|     case 1: | ||||
|       name = '课程'; | ||||
|       break; | ||||
|     case 2: | ||||
|       name = '章节'; | ||||
|       break; | ||||
|     case 3: | ||||
|       name = '子章节'; | ||||
|       break; | ||||
|     case 4: | ||||
|       name = '试卷'; | ||||
|       break; | ||||
|   } | ||||
|   return name | ||||
| } | ||||
| </script> | ||||
| <template> | ||||
|   <div> | ||||
|     <!--    搜索框--> | ||||
|     <div class="gva-search-box"> | ||||
|       <el-form ref="searchForm" :inline="true" :model="queryParams"> | ||||
|         <el-form-item label="订单名称"> | ||||
|           <el-input v-model="queryParams.name" placeholder="根据订单名称进行查询" /> | ||||
|         </el-form-item> | ||||
|         <el-form-item> | ||||
|           <el-button size="small" type="primary" icon="search" @click="onSubmit">查询</el-button> | ||||
|           <el-button size="small" icon="refresh" @click="onReset">重置</el-button> | ||||
|         </el-form-item> | ||||
|       </el-form> | ||||
|     </div> | ||||
|     <!--    表格数据--> | ||||
|     <div class="gva-table-box"> | ||||
|       <!--      批量操作--> | ||||
|       <div class="gva-btn-list"> | ||||
|         <el-popover v-model="deleteVisible" placement="top" width="160"> | ||||
|           <p>确定要删除吗?</p> | ||||
|           <div style="text-align: right; margin-top: 8px;"> | ||||
|             <el-button size="small" type="primary" link @click="deleteVisible = false">取消</el-button> | ||||
|             <el-button size="small" type="primary" @click="onDelete">确定</el-button> | ||||
|           </div> | ||||
|         </el-popover> | ||||
|       </div> | ||||
|       <!--      数据列表--> | ||||
|       <el-table :data="tableData" @selection-change="handleSelectionChange"> | ||||
|         <el-table-column align="center" label="ID"  prop="teacher_info_id" sortable="custom" /> | ||||
|         <el-table-column align="center" label="头像"> | ||||
|           <template #default="scope"> | ||||
|             <img class="avatar-box" :src="scope.row.avatar" alt=""> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column align="center" label="姓名" prop="name" /> | ||||
|         <el-table-column align="center" label="手机号" min-width="150" prop="phone" /> | ||||
|         <el-table-column align="center" label="所属区域" min-width="150" prop="province" /> | ||||
|         <el-table-column align="center" label="申请时间" min-width="150" > | ||||
|           <template #default="scope"> | ||||
|             {{formatDate(scope.row.CreatedAt)}} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column align="center" label="推荐人ID" prop="invite_id" /> | ||||
|         <el-table-column align="center" label="授课次数" prop="publish_course" /> | ||||
|         <el-table-column align="center" label="测试次数" prop="publish_exam" /> | ||||
|         <el-table-column align="center" label="累计销售" prop="exam_sale" /> | ||||
|         <el-table-column align="center" label="状态" min-width="150" prop="exam_sale"> | ||||
|           <template #default="scope"> | ||||
|             <div>{{scope.row.status == 1?'查看':scope.row.status == 2?'已拒绝':'已同意'}}</div> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column align="center" fixed="right" label="操作" width="200"> | ||||
|           <template #default="scope"> | ||||
|             <el-button | ||||
|               icon="edit" | ||||
|               size="small" | ||||
|               type="primary" | ||||
|               link | ||||
|               @click="viewTeacherFunc(scope.row)" | ||||
|             >查看</el-button> | ||||
|             <el-button v-if="scope.row.status == 1" | ||||
|               icon="edit" | ||||
|               size="small" | ||||
|               type="primary" | ||||
|               link | ||||
|               @click="viewTeacherFunc(scope.row)" | ||||
|             >同意</el-button> | ||||
|             <el-button v-if="scope.row.status == 1" | ||||
|               icon="delete" | ||||
|               size="small" | ||||
|               type="danger" | ||||
|               link | ||||
|               @click="deleteExamFunc(scope.row)" | ||||
|             >拒绝</el-button> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|       </el-table> | ||||
|       <div class="gva-pagination"> | ||||
|         <el-pagination | ||||
|           :current-page="queryParams.page" | ||||
|           :page-size="queryParams.pageSize" | ||||
|           :page-sizes="[10, 30, 50, 100]" | ||||
|           :total="total" | ||||
|           layout="total, sizes, prev, pager, next, jumper" | ||||
|           @current-change="handleCurrentChange" | ||||
|           @size-change="handleSizeChange" | ||||
|         /> | ||||
|       </div> | ||||
|     </div> | ||||
|     <router-view v-slot="{ Component }"> | ||||
|       <transition mode="out-in" name="el-fade-in-linear"> | ||||
|         <keep-alive :include="routerStore.keepAliveRouters"> | ||||
|           <component :is="Component" /> | ||||
|         </keep-alive> | ||||
|       </transition> | ||||
|     </router-view> | ||||
|   </div> | ||||
| </template> | ||||
| <style scoped lang="scss"> | ||||
|   .avatar-box{ | ||||
|     width: 50px; | ||||
|     height: 50px; | ||||
|     border-radius: 50%; | ||||
|     border: 1px solid #dbdbdb; | ||||
|   } | ||||
|   .e-img{ | ||||
|     width: 150px; | ||||
|     height: 100px; | ||||
|   } | ||||
|   .option-item{ | ||||
|     display: flex; | ||||
|     align-items: center; | ||||
|     margin-bottom: 10px; | ||||
|   } | ||||
|   .button-box { | ||||
|     padding: 10px 20px; | ||||
|     .el-button { | ||||
|       float: right; | ||||
|     } | ||||
|   } | ||||
|   .warning { | ||||
|     color: #dc143c; | ||||
|   } | ||||
| </style> | ||||
|  | ||||
| <script> | ||||
| export default { | ||||
|   name: 'teacherManage' | ||||
| } | ||||
| </script> | ||||
| <script setup> | ||||
| import { useRouterStore } from '@/pinia/modules/router' | ||||
| const routerStore = useRouterStore() | ||||
| </script> | ||||
|   | ||||
							
								
								
									
										405
									
								
								src/view/teacherManage/teacherApply/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										405
									
								
								src/view/teacherManage/teacherApply/index.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,405 @@ | ||||
|  | ||||
| <script setup> | ||||
| // 引入依赖 | ||||
| import api from '@/api/teacher' | ||||
| import capi from '@/api/course' | ||||
| import custom from '@/utils/custom' | ||||
| import {formatDate} from '@/utils/format' | ||||
| import cityList from '@/utils/city.json' | ||||
| // import { toSQLLine } from '@/utils/stringFun' | ||||
| // import WarningBar from '@/components/warningBar/warningBar.vue' | ||||
| // import coursePool from './components/coursePool.vue' | ||||
| // import exercisesPool from '@/view/course/components/exercisesPool.vue' | ||||
| import {ref,onMounted,provide } from 'vue' | ||||
| import { ElMessage, ElMessageBox } from 'element-plus' | ||||
| import { useRouter, useRoute } from 'vue-router' | ||||
| const router = useRouter() | ||||
| const route = useRoute() | ||||
| // store | ||||
| import { useUserStore } from '@/pinia/modules/user' | ||||
| const userStore = useUserStore() | ||||
| // 变量 | ||||
| const path = ref(import.meta.env.VITE_BASE_API) | ||||
| // const typeList = custom.getExercisesTypeList() | ||||
| const queryParams = ref({ | ||||
|   page:1, | ||||
|   pageSize:10, | ||||
|   name:'', | ||||
|   status:'' | ||||
| }) | ||||
| const subjectParams = ref({ | ||||
|     pageIndex:1, | ||||
|     pageSize:100, | ||||
| }) | ||||
| const state_arr = ref([ | ||||
|     { | ||||
|       name:'申请中', | ||||
|       id:1 | ||||
|     }, | ||||
|     { | ||||
|       name:'拒绝', | ||||
|       id:2 | ||||
|     }, | ||||
|     { | ||||
|       name:'同意', | ||||
|       id:3 | ||||
|     } | ||||
| ]) | ||||
| const tableData = ref([]) | ||||
| const subjectList = ref([]) | ||||
| const current_subject = ref('') | ||||
| const deleteVisible = ref(false) | ||||
| const question_ids = ref([]) | ||||
| const total = ref(0) | ||||
| const dialogFormVisible = ref(false) | ||||
| const dialogTitle = ref('') | ||||
| const form =ref({}) | ||||
| const rules = ref({ | ||||
|   name: [{ required: true, message: '请输入课程名称', trigger: 'blur' }] | ||||
| }) | ||||
| const question_id = ref(0) | ||||
| const content = ref(null) | ||||
| // const options = ref([]) // 答案选项数组 | ||||
| const exam_types = ref([]) | ||||
| const exam_ids = ref([]) | ||||
| // 生命周期 | ||||
| onMounted(() => { | ||||
|   getTeacherList() | ||||
|   // getSubject() | ||||
| }) | ||||
| provide('subjectList', subjectList) | ||||
| provide('current_subject', current_subject) | ||||
| // 方法 | ||||
| async function getTeacherList() { | ||||
|   const res = await api.getTeacherList(queryParams.value) | ||||
|   if(res.code === 0) { | ||||
|     tableData.value = res.data.records | ||||
|     total.value = res.data.total | ||||
|   } | ||||
| } | ||||
| async function getSubject(){ // 获取课程分类 | ||||
|   const res = await capi.getSubjectList(subjectParams.value) | ||||
|   if(res.code === 0) { | ||||
|     subjectList.value = custom.getStdSubject(res.data.records) | ||||
|   } | ||||
| } | ||||
| function onSubmit() { | ||||
|   getTeacherList() | ||||
| } | ||||
| const onReset = () => { | ||||
|   queryParams.value = { | ||||
|     pageIndex:1, | ||||
|     pageSize:10, | ||||
|     name:'', | ||||
|     status:'', | ||||
|     subject:'' | ||||
|   } | ||||
| } | ||||
| function openDialog(type) { | ||||
|   // let params = {} | ||||
|   switch (type){ | ||||
|     case 'add': | ||||
|       dialogTitle.value = '新增试卷' | ||||
|         form.value = {} | ||||
|       break; | ||||
|     case 'edit': | ||||
|       // params.question_id = question_id.value | ||||
|       dialogTitle.value = '编辑试卷' | ||||
|       break; | ||||
|   } | ||||
|   dialogFormVisible.value = true | ||||
|   // router.push({name:'addCourse',params}) | ||||
| } | ||||
| async function onDelete() { | ||||
|   const ids = exam_ids.value | ||||
|   const res = await api.delExamination({ exam_ids:ids }) | ||||
|   if (res.code === 0) { | ||||
|     ElMessage({ | ||||
|       type: 'success', | ||||
|       message: res.msg | ||||
|     }) | ||||
|     // if (tableData.value.length === ids.length && page.value > 1) { | ||||
|     //   page.value-- | ||||
|     // } | ||||
|     deleteVisible.value = false | ||||
|     getTeacherList() | ||||
|   } | ||||
| } | ||||
| const handleSelectionChange = (val) => { | ||||
|   exam_ids.value = val.map((item) => { | ||||
|       return item.exam_id | ||||
|   }) | ||||
| } | ||||
| function editCourseFunc(row) { | ||||
|   row.course_ids = JSON.parse(row.course_ids) | ||||
|   row.question_ids = JSON.parse(row.question_ids) | ||||
|  | ||||
|   form.value = row.exam | ||||
|   exam_types.value = row.exam_types.map((item) => { | ||||
|     return item.persons | ||||
|   }) | ||||
|   current_subject.value = form.value.subject | ||||
|   openDialog('edit') | ||||
| } | ||||
| function deleteExamFunc(row) { | ||||
|   ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', { | ||||
|     confirmButtonText: '确定', | ||||
|     cancelButtonText: '取消', | ||||
|     type: 'warning' | ||||
|   }) | ||||
|   .then(async() => { | ||||
|     const res = await api.delExamination({ | ||||
|           exam_ids:[row.exam_id] | ||||
|     }) | ||||
|     if (res.code === 0) { | ||||
|       ElMessage({ | ||||
|         type: 'success', | ||||
|         message: '删除成功!' | ||||
|       }) | ||||
|       getTeacherList() | ||||
|     } | ||||
|   },() => { | ||||
|   }) | ||||
| } | ||||
| function handleCurrentChange(val) { | ||||
|   queryParams.value.pageIndex = val | ||||
|   getTeacherList() | ||||
| } | ||||
| function handleSizeChange(val) { | ||||
|   queryParams.value.pageSize = val | ||||
|   getTeacherList() | ||||
| } | ||||
| function closeDialog(){ | ||||
|   dialogFormVisible.value = false | ||||
|   exam_types.value = [] | ||||
|   form.value = {} | ||||
| } | ||||
| async function enterDialog() { // 提交 | ||||
|   form.value.teacher_id = 0 | ||||
|   form.value.exam_type = exam_types.value.map((item) => { | ||||
|     return item = parseInt(item) | ||||
|   }) | ||||
|   form.value.duration = parseInt(form.value.duration) | ||||
|   // return | ||||
|   const params = { | ||||
|     ...form.value | ||||
|   } | ||||
|   params.question_ids = JSON.stringify(form.value.question_ids) | ||||
|   params.course_ids = JSON.stringify(form.value.course_ids) | ||||
|   let func_name = 'addExamination' | ||||
|   if(form.value.exam_id) { // 编辑 | ||||
|     func_name = 'editExamination' | ||||
|   } | ||||
|   const res = await api[func_name](params) | ||||
|   if(res.code === 0) { | ||||
|     ElMessage({ | ||||
|       type: 'success', | ||||
|       message: res.msg | ||||
|     }) | ||||
|     closeDialog() | ||||
|     getTeacherList() | ||||
|   } | ||||
| } | ||||
| function viewTeacherFunc(row) { // 查看订单 | ||||
|   console.log(row) | ||||
|   router.push({name:'teacherDetail',params:{id:row.teacher_info_id}}) | ||||
| } | ||||
| function getExercisesName(row) { | ||||
|   return JSON.parse(row.question).title | ||||
| } | ||||
| // const std_options_title = ref(['A','B','C','D','E','F']) | ||||
| function addOptionFunc() { | ||||
|   exam_types.value.push('') | ||||
| } | ||||
| function delet_func() { | ||||
|   exam_types.value.pop() | ||||
| } | ||||
| function getStateName(state) { | ||||
|   let str = '' | ||||
|   switch (state){ | ||||
|     case 1: | ||||
|         str = '未付款' | ||||
|       break; | ||||
|     case 2: | ||||
|         str = '已付款' | ||||
|       break; | ||||
|     case 3: | ||||
|         str = '已过期' | ||||
|       break; | ||||
|   } | ||||
|   return str | ||||
| } | ||||
| function handleAvatarSuccess(res) { | ||||
|   form.value.cover = res.data.file.url | ||||
|   // handlerChange() | ||||
| } | ||||
| function beforeAvatarUpload(file) { | ||||
|   const isLt05M = file.size / 1024 / 1024 < 20 | ||||
|   const isJPG = file.type.indexOf('image/') === -1 | ||||
|   if (isJPG) { | ||||
|     ElMessage.error('文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件') | ||||
|   } | ||||
|   if (!isLt05M) { | ||||
|     ElMessage.error('上传头像图片大小不能超过 2M!') | ||||
|   } | ||||
|   return !isJPG && isLt05M | ||||
| } | ||||
| function changeSubjectFunc(e) { | ||||
|   current_subject.value = e | ||||
| } | ||||
| function addExercisesFunc(data) { | ||||
|   form.value.question_ids = data | ||||
| } | ||||
| function addCourseFunc(data) { | ||||
|   form.value.course_ids = data | ||||
| } | ||||
| function getTypeName(type) { | ||||
|   let name = "" | ||||
|   switch (type) { | ||||
|     case 1: | ||||
|       name = '课程'; | ||||
|       break; | ||||
|     case 2: | ||||
|       name = '章节'; | ||||
|       break; | ||||
|     case 3: | ||||
|       name = '子章节'; | ||||
|       break; | ||||
|     case 4: | ||||
|       name = '试卷'; | ||||
|       break; | ||||
|   } | ||||
|   return name | ||||
| } | ||||
| </script> | ||||
| <template> | ||||
|   <div> | ||||
|     <!--    搜索框--> | ||||
|     <div class="gva-search-box"> | ||||
|       <el-form ref="searchForm" :inline="true" :model="queryParams"> | ||||
|         <el-form-item label="教师名称"> | ||||
|           <el-input v-model="queryParams.name" placeholder="根据教师名称进行查询" /> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="教师状态"> | ||||
|           <el-select v-model="queryParams.status" clearable placeholder="请选择"> | ||||
|             <el-option | ||||
|               v-for="item in state_arr" | ||||
|               :key="item.id" | ||||
|               :label="item.name" | ||||
|               :value="item.id" | ||||
|             /> | ||||
|           </el-select> | ||||
|         </el-form-item> | ||||
|         <el-form-item> | ||||
|           <el-button size="small" type="primary" icon="search" @click="onSubmit">查询</el-button> | ||||
|           <el-button size="small" icon="refresh" @click="onReset">重置</el-button> | ||||
|         </el-form-item> | ||||
|       </el-form> | ||||
|     </div> | ||||
|     <!--    表格数据--> | ||||
|     <div class="gva-table-box"> | ||||
|       <!--      批量操作--> | ||||
|       <div class="gva-btn-list"> | ||||
|         <el-popover v-model="deleteVisible" placement="top" width="160"> | ||||
|           <p>确定要删除吗?</p> | ||||
|           <div style="text-align: right; margin-top: 8px;"> | ||||
|             <el-button size="small" type="primary" link @click="deleteVisible = false">取消</el-button> | ||||
|             <el-button size="small" type="primary" @click="onDelete">确定</el-button> | ||||
|           </div> | ||||
|         </el-popover> | ||||
|       </div> | ||||
|       <!--      数据列表--> | ||||
|       <el-table :data="tableData" @selection-change="handleSelectionChange"> | ||||
|         <el-table-column align="center" label="ID"  prop="teacher_info_id" sortable="custom" /> | ||||
|         <el-table-column align="center" label="头像"> | ||||
|           <template #default="scope"> | ||||
|             <img class="avatar-box" :src="scope.row.avatar" alt=""> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column align="center" label="姓名" prop="name" /> | ||||
|         <el-table-column align="center" label="手机号" min-width="150" prop="phone" /> | ||||
|         <el-table-column align="center" label="所属区域" min-width="150" prop="province"> | ||||
|           <template #default="scope"> | ||||
|             {{cityList[scope.row.province].name}} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column align="center" label="申请时间" min-width="150" > | ||||
|           <template #default="scope"> | ||||
|             {{formatDate(scope.row.CreatedAt)}} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column align="center" label="推荐人ID" prop="invite_id" /> | ||||
|         <el-table-column align="center" label="授课次数" prop="publish_course" /> | ||||
|         <el-table-column align="center" label="测试次数" prop="publish_exam" /> | ||||
|         <el-table-column align="center" label="累计销售" prop="exam_sale" /> | ||||
|         <el-table-column align="center" label="状态" prop="exam_sale"> | ||||
|           <template #default="scope"> | ||||
|             <div>{{scope.row.status == 1?'查看':scope.row.status == 2?'已拒绝':'已同意'}}</div> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column align="center" fixed="right" label="操作" width="200"> | ||||
|           <template #default="scope"> | ||||
|             <el-button | ||||
|               icon="view" | ||||
|               size="small" | ||||
|               type="primary" | ||||
|               link | ||||
|               @click="viewTeacherFunc(scope.row)" | ||||
|             >查看</el-button> | ||||
|             <el-button v-if="scope.row.status == 1" | ||||
|               icon="edit" | ||||
|               size="small" | ||||
|               type="primary" | ||||
|               link | ||||
|               @click="viewTeacherFunc(scope.row)" | ||||
|             >同意</el-button> | ||||
|             <el-button v-if="scope.row.status == 1" | ||||
|               icon="delete" | ||||
|               size="small" | ||||
|               type="danger" | ||||
|               link | ||||
|               @click="deleteExamFunc(scope.row)" | ||||
|             >拒绝</el-button> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|       </el-table> | ||||
|       <div class="gva-pagination"> | ||||
|         <el-pagination | ||||
|           :current-page="queryParams.page" | ||||
|           :page-size="queryParams.pageSize" | ||||
|           :page-sizes="[10, 30, 50, 100]" | ||||
|           :total="total" | ||||
|           layout="total, sizes, prev, pager, next, jumper" | ||||
|           @current-change="handleCurrentChange" | ||||
|           @size-change="handleSizeChange" | ||||
|         /> | ||||
|       </div> | ||||
|     </div> | ||||
|   </div> | ||||
| </template> | ||||
| <style scoped lang="scss"> | ||||
|   .avatar-box{ | ||||
|     width: 50px; | ||||
|     height: 50px; | ||||
|     border-radius: 50%; | ||||
|     border: 1px solid #dbdbdb; | ||||
|   } | ||||
|   .e-img{ | ||||
|     width: 150px; | ||||
|     height: 100px; | ||||
|   } | ||||
|   .option-item{ | ||||
|     display: flex; | ||||
|     align-items: center; | ||||
|     margin-bottom: 10px; | ||||
|   } | ||||
|   .button-box { | ||||
|     padding: 10px 20px; | ||||
|     .el-button { | ||||
|       float: right; | ||||
|     } | ||||
|   } | ||||
|   .warning { | ||||
|     color: #dc143c; | ||||
|   } | ||||
| </style> | ||||
							
								
								
									
										405
									
								
								src/view/teacherManage/teacherList/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										405
									
								
								src/view/teacherManage/teacherList/index.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,405 @@ | ||||
|  | ||||
| <script setup> | ||||
| // 引入依赖 | ||||
| import api from '@/api/teacher' | ||||
| import capi from '@/api/course' | ||||
| import custom from '@/utils/custom' | ||||
| import {formatDate} from '@/utils/format' | ||||
| import cityList from '@/utils/city.json' | ||||
| // import { toSQLLine } from '@/utils/stringFun' | ||||
| // import WarningBar from '@/components/warningBar/warningBar.vue' | ||||
| // import coursePool from './components/coursePool.vue' | ||||
| // import exercisesPool from '@/view/course/components/exercisesPool.vue' | ||||
| import {ref,onMounted,provide } from 'vue' | ||||
| import { ElMessage, ElMessageBox } from 'element-plus' | ||||
| import { useRouter, useRoute } from 'vue-router' | ||||
| const router = useRouter() | ||||
| const route = useRoute() | ||||
| // store | ||||
| import { useUserStore } from '@/pinia/modules/user' | ||||
| const userStore = useUserStore() | ||||
| // 变量 | ||||
| const path = ref(import.meta.env.VITE_BASE_API) | ||||
| // const typeList = custom.getExercisesTypeList() | ||||
| const queryParams = ref({ | ||||
|   page:1, | ||||
|   pageSize:10, | ||||
|   name:'', | ||||
|   status:'' | ||||
| }) | ||||
| const subjectParams = ref({ | ||||
|     pageIndex:1, | ||||
|     pageSize:100, | ||||
| }) | ||||
| const state_arr = ref([ | ||||
|     { | ||||
|       name:'申请中', | ||||
|       id:1 | ||||
|     }, | ||||
|     { | ||||
|       name:'拒绝', | ||||
|       id:2 | ||||
|     }, | ||||
|     { | ||||
|       name:'同意', | ||||
|       id:3 | ||||
|     } | ||||
| ]) | ||||
| const tableData = ref([]) | ||||
| const subjectList = ref([]) | ||||
| const current_subject = ref('') | ||||
| const deleteVisible = ref(false) | ||||
| const question_ids = ref([]) | ||||
| const total = ref(0) | ||||
| const dialogFormVisible = ref(false) | ||||
| const dialogTitle = ref('') | ||||
| const form =ref({}) | ||||
| const rules = ref({ | ||||
|   name: [{ required: true, message: '请输入课程名称', trigger: 'blur' }] | ||||
| }) | ||||
| const question_id = ref(0) | ||||
| const content = ref(null) | ||||
| // const options = ref([]) // 答案选项数组 | ||||
| const exam_types = ref([]) | ||||
| const exam_ids = ref([]) | ||||
| // 生命周期 | ||||
| onMounted(() => { | ||||
|   getTeacherList() | ||||
|   // getSubject() | ||||
| }) | ||||
| provide('subjectList', subjectList) | ||||
| provide('current_subject', current_subject) | ||||
| // 方法 | ||||
| async function getTeacherList() { | ||||
|   const res = await api.getTeacherList(queryParams.value) | ||||
|   if(res.code === 0) { | ||||
|     tableData.value = res.data.records | ||||
|     total.value = res.data.total | ||||
|   } | ||||
| } | ||||
| async function getSubject(){ // 获取课程分类 | ||||
|   const res = await capi.getSubjectList(subjectParams.value) | ||||
|   if(res.code === 0) { | ||||
|     subjectList.value = custom.getStdSubject(res.data.records) | ||||
|   } | ||||
| } | ||||
| function onSubmit() { | ||||
|   getTeacherList() | ||||
| } | ||||
| const onReset = () => { | ||||
|   queryParams.value = { | ||||
|     pageIndex:1, | ||||
|     pageSize:10, | ||||
|     name:'', | ||||
|     status:'', | ||||
|     subject:'' | ||||
|   } | ||||
| } | ||||
| function openDialog(type) { | ||||
|   // let params = {} | ||||
|   switch (type){ | ||||
|     case 'add': | ||||
|       dialogTitle.value = '新增试卷' | ||||
|         form.value = {} | ||||
|       break; | ||||
|     case 'edit': | ||||
|       // params.question_id = question_id.value | ||||
|       dialogTitle.value = '编辑试卷' | ||||
|       break; | ||||
|   } | ||||
|   dialogFormVisible.value = true | ||||
|   // router.push({name:'addCourse',params}) | ||||
| } | ||||
| async function onDelete() { | ||||
|   const ids = exam_ids.value | ||||
|   const res = await api.delExamination({ exam_ids:ids }) | ||||
|   if (res.code === 0) { | ||||
|     ElMessage({ | ||||
|       type: 'success', | ||||
|       message: res.msg | ||||
|     }) | ||||
|     // if (tableData.value.length === ids.length && page.value > 1) { | ||||
|     //   page.value-- | ||||
|     // } | ||||
|     deleteVisible.value = false | ||||
|     getTeacherList() | ||||
|   } | ||||
| } | ||||
| const handleSelectionChange = (val) => { | ||||
|   exam_ids.value = val.map((item) => { | ||||
|       return item.exam_id | ||||
|   }) | ||||
| } | ||||
| function editCourseFunc(row) { | ||||
|   row.course_ids = JSON.parse(row.course_ids) | ||||
|   row.question_ids = JSON.parse(row.question_ids) | ||||
|  | ||||
|   form.value = row.exam | ||||
|   exam_types.value = row.exam_types.map((item) => { | ||||
|     return item.persons | ||||
|   }) | ||||
|   current_subject.value = form.value.subject | ||||
|   openDialog('edit') | ||||
| } | ||||
| function deleteExamFunc(row) { | ||||
|   ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', { | ||||
|     confirmButtonText: '确定', | ||||
|     cancelButtonText: '取消', | ||||
|     type: 'warning' | ||||
|   }) | ||||
|   .then(async() => { | ||||
|     const res = await api.delExamination({ | ||||
|           exam_ids:[row.exam_id] | ||||
|     }) | ||||
|     if (res.code === 0) { | ||||
|       ElMessage({ | ||||
|         type: 'success', | ||||
|         message: '删除成功!' | ||||
|       }) | ||||
|       getTeacherList() | ||||
|     } | ||||
|   },() => { | ||||
|   }) | ||||
| } | ||||
| function handleCurrentChange(val) { | ||||
|   queryParams.value.pageIndex = val | ||||
|   getTeacherList() | ||||
| } | ||||
| function handleSizeChange(val) { | ||||
|   queryParams.value.pageSize = val | ||||
|   getTeacherList() | ||||
| } | ||||
| function closeDialog(){ | ||||
|   dialogFormVisible.value = false | ||||
|   exam_types.value = [] | ||||
|   form.value = {} | ||||
| } | ||||
| async function enterDialog() { // 提交 | ||||
|   form.value.teacher_id = 0 | ||||
|   form.value.exam_type = exam_types.value.map((item) => { | ||||
|     return item = parseInt(item) | ||||
|   }) | ||||
|   form.value.duration = parseInt(form.value.duration) | ||||
|   // return | ||||
|   const params = { | ||||
|     ...form.value | ||||
|   } | ||||
|   params.question_ids = JSON.stringify(form.value.question_ids) | ||||
|   params.course_ids = JSON.stringify(form.value.course_ids) | ||||
|   let func_name = 'addExamination' | ||||
|   if(form.value.exam_id) { // 编辑 | ||||
|     func_name = 'editExamination' | ||||
|   } | ||||
|   const res = await api[func_name](params) | ||||
|   if(res.code === 0) { | ||||
|     ElMessage({ | ||||
|       type: 'success', | ||||
|       message: res.msg | ||||
|     }) | ||||
|     closeDialog() | ||||
|     getTeacherList() | ||||
|   } | ||||
| } | ||||
| function viewTeacherFunc(row) { // 查看订单 | ||||
|   console.log(row) | ||||
|   router.push({name:'teacherDetail',params:{id:row.teacher_info_id}}) | ||||
| } | ||||
| function getExercisesName(row) { | ||||
|   return JSON.parse(row.question).title | ||||
| } | ||||
| // const std_options_title = ref(['A','B','C','D','E','F']) | ||||
| function addOptionFunc() { | ||||
|   exam_types.value.push('') | ||||
| } | ||||
| function delet_func() { | ||||
|   exam_types.value.pop() | ||||
| } | ||||
| function getStateName(state) { | ||||
|   let str = '' | ||||
|   switch (state){ | ||||
|     case 1: | ||||
|         str = '未付款' | ||||
|       break; | ||||
|     case 2: | ||||
|         str = '已付款' | ||||
|       break; | ||||
|     case 3: | ||||
|         str = '已过期' | ||||
|       break; | ||||
|   } | ||||
|   return str | ||||
| } | ||||
| function handleAvatarSuccess(res) { | ||||
|   form.value.cover = res.data.file.url | ||||
|   // handlerChange() | ||||
| } | ||||
| function beforeAvatarUpload(file) { | ||||
|   const isLt05M = file.size / 1024 / 1024 < 20 | ||||
|   const isJPG = file.type.indexOf('image/') === -1 | ||||
|   if (isJPG) { | ||||
|     ElMessage.error('文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件') | ||||
|   } | ||||
|   if (!isLt05M) { | ||||
|     ElMessage.error('上传头像图片大小不能超过 2M!') | ||||
|   } | ||||
|   return !isJPG && isLt05M | ||||
| } | ||||
| function changeSubjectFunc(e) { | ||||
|   current_subject.value = e | ||||
| } | ||||
| function addExercisesFunc(data) { | ||||
|   form.value.question_ids = data | ||||
| } | ||||
| function addCourseFunc(data) { | ||||
|   form.value.course_ids = data | ||||
| } | ||||
| function getTypeName(type) { | ||||
|   let name = "" | ||||
|   switch (type) { | ||||
|     case 1: | ||||
|       name = '课程'; | ||||
|       break; | ||||
|     case 2: | ||||
|       name = '章节'; | ||||
|       break; | ||||
|     case 3: | ||||
|       name = '子章节'; | ||||
|       break; | ||||
|     case 4: | ||||
|       name = '试卷'; | ||||
|       break; | ||||
|   } | ||||
|   return name | ||||
| } | ||||
| </script> | ||||
| <template> | ||||
|   <div> | ||||
|     <!--    搜索框--> | ||||
|     <div class="gva-search-box"> | ||||
|       <el-form ref="searchForm" :inline="true" :model="queryParams"> | ||||
|         <el-form-item label="教师名称"> | ||||
|           <el-input v-model="queryParams.name" placeholder="根据教师名称进行查询" /> | ||||
|         </el-form-item> | ||||
| <!--        <el-form-item label="教师状态">--> | ||||
| <!--          <el-select v-model="queryParams.status" clearable placeholder="请选择">--> | ||||
| <!--            <el-option--> | ||||
| <!--              v-for="item in state_arr"--> | ||||
| <!--              :key="item.id"--> | ||||
| <!--              :label="item.name"--> | ||||
| <!--              :value="item.id"--> | ||||
| <!--            />--> | ||||
| <!--          </el-select>--> | ||||
| <!--        </el-form-item>--> | ||||
|         <el-form-item> | ||||
|           <el-button size="small" type="primary" icon="search" @click="onSubmit">查询</el-button> | ||||
|           <el-button size="small" icon="refresh" @click="onReset">重置</el-button> | ||||
|         </el-form-item> | ||||
|       </el-form> | ||||
|     </div> | ||||
|     <!--    表格数据--> | ||||
|     <div class="gva-table-box"> | ||||
|       <!--      批量操作--> | ||||
|       <div class="gva-btn-list"> | ||||
|         <el-popover v-model="deleteVisible" placement="top" width="160"> | ||||
|           <p>确定要删除吗?</p> | ||||
|           <div style="text-align: right; margin-top: 8px;"> | ||||
|             <el-button size="small" type="primary" link @click="deleteVisible = false">取消</el-button> | ||||
|             <el-button size="small" type="primary" @click="onDelete">确定</el-button> | ||||
|           </div> | ||||
|         </el-popover> | ||||
|       </div> | ||||
|       <!--      数据列表--> | ||||
|       <el-table :data="tableData" @selection-change="handleSelectionChange"> | ||||
|         <el-table-column align="center" label="ID"  prop="teacher_info_id" sortable="custom" /> | ||||
|         <el-table-column align="center" label="头像"> | ||||
|           <template #default="scope"> | ||||
|             <img class="avatar-box" :src="scope.row.avatar" alt=""> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column align="center" label="姓名" prop="name" /> | ||||
|         <el-table-column align="center" label="手机号" min-width="150" prop="phone" /> | ||||
|         <el-table-column align="center" label="所属区域" min-width="150" prop="province"> | ||||
|           <template #default="scope"> | ||||
|             {{cityList[scope.row.province].name}} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column align="center" label="申请时间" min-width="150" > | ||||
|           <template #default="scope"> | ||||
|             {{formatDate(scope.row.CreatedAt)}} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column align="center" label="推荐人ID" prop="invite_id" /> | ||||
|         <el-table-column align="center" label="授课次数" prop="publish_course" /> | ||||
|         <el-table-column align="center" label="测试次数" prop="publish_exam" /> | ||||
|         <el-table-column align="center" label="累计销售" prop="exam_sale" /> | ||||
| <!--        <el-table-column align="center" label="状态" prop="exam_sale">--> | ||||
| <!--          <template #default="scope">--> | ||||
| <!--            <div>{{scope.row.status == 1?'查看':scope.row.status == 2?'已拒绝':'已同意'}}</div>--> | ||||
| <!--          </template>--> | ||||
| <!--        </el-table-column>--> | ||||
|         <el-table-column align="center" fixed="right" label="操作" width="200"> | ||||
|           <template #default="scope"> | ||||
|             <el-button | ||||
|               icon="view" | ||||
|               size="small" | ||||
|               type="primary" | ||||
|               link | ||||
|               @click="viewTeacherFunc(scope.row)" | ||||
|             >查看</el-button> | ||||
|             <el-button v-if="scope.row.status == 1" | ||||
|               icon="edit" | ||||
|               size="small" | ||||
|               type="primary" | ||||
|               link | ||||
|               @click="viewTeacherFunc(scope.row)" | ||||
|             >同意</el-button> | ||||
|             <el-button v-if="scope.row.status == 1" | ||||
|               icon="delete" | ||||
|               size="small" | ||||
|               type="danger" | ||||
|               link | ||||
|               @click="deleteExamFunc(scope.row)" | ||||
|             >拒绝</el-button> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|       </el-table> | ||||
|       <div class="gva-pagination"> | ||||
|         <el-pagination | ||||
|           :current-page="queryParams.page" | ||||
|           :page-size="queryParams.pageSize" | ||||
|           :page-sizes="[10, 30, 50, 100]" | ||||
|           :total="total" | ||||
|           layout="total, sizes, prev, pager, next, jumper" | ||||
|           @current-change="handleCurrentChange" | ||||
|           @size-change="handleSizeChange" | ||||
|         /> | ||||
|       </div> | ||||
|     </div> | ||||
|   </div> | ||||
| </template> | ||||
| <style scoped lang="scss"> | ||||
|   .avatar-box{ | ||||
|     width: 50px; | ||||
|     height: 50px; | ||||
|     border-radius: 50%; | ||||
|     border: 1px solid #dbdbdb; | ||||
|   } | ||||
|   .e-img{ | ||||
|     width: 150px; | ||||
|     height: 100px; | ||||
|   } | ||||
|   .option-item{ | ||||
|     display: flex; | ||||
|     align-items: center; | ||||
|     margin-bottom: 10px; | ||||
|   } | ||||
|   .button-box { | ||||
|     padding: 10px 20px; | ||||
|     .el-button { | ||||
|       float: right; | ||||
|     } | ||||
|   } | ||||
|   .warning { | ||||
|     color: #dc143c; | ||||
|   } | ||||
| </style> | ||||
							
								
								
									
										451
									
								
								src/view/userManage/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										451
									
								
								src/view/userManage/index.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,451 @@ | ||||
|  | ||||
| <script setup> | ||||
| // 引入依赖 | ||||
| import api from '@/api/userManage' | ||||
| import capi from '@/api/course' | ||||
| import custom from '@/utils/custom' | ||||
| import {formatDate} from '@/utils/format' | ||||
| // import { toSQLLine } from '@/utils/stringFun' | ||||
| // import WarningBar from '@/components/warningBar/warningBar.vue' | ||||
| // import coursePool from './components/coursePool.vue' | ||||
| // import exercisesPool from '@/view/course/components/exercisesPool.vue' | ||||
| import {ref,onMounted,provide } from 'vue' | ||||
| import { ElMessage, ElMessageBox } from 'element-plus' | ||||
| import { useRouter, useRoute } from 'vue-router' | ||||
| const router = useRouter() | ||||
| const route = useRoute() | ||||
| import cityList from '@/utils/city.json'; | ||||
| // store | ||||
| import { useUserStore } from '@/pinia/modules/user' | ||||
| const userStore = useUserStore() | ||||
| // 变量 | ||||
| const path = ref(import.meta.env.VITE_BASE_API) | ||||
| // const typeList = custom.getExercisesTypeList() | ||||
| const queryParams = ref({ | ||||
|   page:1, | ||||
|   pageSize:10, | ||||
|   name:'', | ||||
|   province:'' | ||||
| }) | ||||
| const subjectParams = ref({ | ||||
|     pageIndex:1, | ||||
|     pageSize:100, | ||||
| }) | ||||
| const tableData = ref([]) | ||||
| const subjectList = ref([]) | ||||
| const current_subject = ref('') | ||||
| const deleteVisible = ref(false) | ||||
| const question_ids = ref([]) | ||||
| const total = ref(0) | ||||
| const dialogFormVisible = ref(false) | ||||
| const dialogTitle = ref('') | ||||
| const form =ref({}) | ||||
| const rules = ref({ | ||||
|   name: [{ required: true, message: '请输入课程名称', trigger: 'blur' }] | ||||
| }) | ||||
| const question_id = ref(0) | ||||
| const content = ref(null) | ||||
| // const options = ref([]) // 答案选项数组 | ||||
| const exam_types = ref([]) | ||||
| const exam_ids = ref([]) | ||||
| // 生命周期 | ||||
| onMounted(() => { | ||||
|   getUserList() | ||||
|   getSubject() | ||||
| }) | ||||
| provide('subjectList', subjectList) | ||||
| provide('current_subject', current_subject) | ||||
| // 方法 | ||||
| async function getUserList() { | ||||
|   const res = await api.getUserList(queryParams.value) | ||||
|   if(res.code === 0) { | ||||
|     tableData.value = res.data.records | ||||
|     total.value = res.data.total | ||||
|   } | ||||
| } | ||||
| async function getSubject(){ // 获取课程分类 | ||||
|   const res = await capi.getSubjectList(subjectParams.value) | ||||
|   if(res.code === 0) { | ||||
|     subjectList.value = custom.getStdSubject(res.data.records) | ||||
|   } | ||||
| } | ||||
| function onSubmit() { | ||||
|   getUserList() | ||||
| } | ||||
| const onReset = () => { | ||||
|   queryParams.value = { | ||||
|     pageIndex:1, | ||||
|     pageSize:10, | ||||
|     name:'', | ||||
|     status:'', | ||||
|     subject:'' | ||||
|   } | ||||
| } | ||||
| function openDialog(type) { | ||||
|   // let params = {} | ||||
|   switch (type){ | ||||
|     case 'add': | ||||
|       dialogTitle.value = '新增试卷' | ||||
|         form.value = {} | ||||
|       break; | ||||
|     case 'edit': | ||||
|       // params.question_id = question_id.value | ||||
|       dialogTitle.value = '编辑试卷' | ||||
|       break; | ||||
|   } | ||||
|   dialogFormVisible.value = true | ||||
|   // router.push({name:'addCourse',params}) | ||||
| } | ||||
| async function onDelete() { | ||||
|   const ids = exam_ids.value | ||||
|   const res = await api.delExamination({ exam_ids:ids }) | ||||
|   if (res.code === 0) { | ||||
|     ElMessage({ | ||||
|       type: 'success', | ||||
|       message: res.msg | ||||
|     }) | ||||
|     // if (tableData.value.length === ids.length && page.value > 1) { | ||||
|     //   page.value-- | ||||
|     // } | ||||
|     deleteVisible.value = false | ||||
|     getUserList() | ||||
|   } | ||||
| } | ||||
| const handleSelectionChange = (val) => { | ||||
|   exam_ids.value = val.map((item) => { | ||||
|       return item.exam_id | ||||
|   }) | ||||
| } | ||||
| function editCourseFunc(row) { | ||||
|   row.course_ids = JSON.parse(row.course_ids) | ||||
|   row.question_ids = JSON.parse(row.question_ids) | ||||
|  | ||||
|   form.value = row.exam | ||||
|   exam_types.value = row.exam_types.map((item) => { | ||||
|     return item.persons | ||||
|   }) | ||||
|   current_subject.value = form.value.subject | ||||
|   openDialog('edit') | ||||
| } | ||||
| function deleteExamFunc(row) { | ||||
|   ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', { | ||||
|     confirmButtonText: '确定', | ||||
|     cancelButtonText: '取消', | ||||
|     type: 'warning' | ||||
|   }) | ||||
|   .then(async() => { | ||||
|     const res = await api.delExamination({ | ||||
|           exam_ids:[row.exam_id] | ||||
|     }) | ||||
|     if (res.code === 0) { | ||||
|       ElMessage({ | ||||
|         type: 'success', | ||||
|         message: '删除成功!' | ||||
|       }) | ||||
|       getUserList() | ||||
|     } | ||||
|   },() => { | ||||
|   }) | ||||
| } | ||||
| function handleCurrentChange(val) { | ||||
|   queryParams.value.pageIndex = val | ||||
|   getUserList() | ||||
| } | ||||
| function handleSizeChange(val) { | ||||
|   queryParams.value.pageSize = val | ||||
|   getUserList() | ||||
| } | ||||
| function closeDialog(){ | ||||
|   dialogFormVisible.value = false | ||||
|   exam_types.value = [] | ||||
|   form.value = {} | ||||
| } | ||||
| async function enterDialog() { // 提交 | ||||
|   form.value.teacher_id = 0 | ||||
|   form.value.exam_type = exam_types.value.map((item) => { | ||||
|     return item = parseInt(item) | ||||
|   }) | ||||
|   form.value.duration = parseInt(form.value.duration) | ||||
|   // return | ||||
|   const params = { | ||||
|     ...form.value | ||||
|   } | ||||
|   params.question_ids = JSON.stringify(form.value.question_ids) | ||||
|   params.course_ids = JSON.stringify(form.value.course_ids) | ||||
|   let func_name = 'addExamination' | ||||
|   if(form.value.exam_id) { // 编辑 | ||||
|     func_name = 'editExamination' | ||||
|   } | ||||
|   const res = await api[func_name](params) | ||||
|   if(res.code === 0) { | ||||
|     ElMessage({ | ||||
|       type: 'success', | ||||
|       message: res.msg | ||||
|     }) | ||||
|     closeDialog() | ||||
|     getUserList() | ||||
|   } | ||||
| } | ||||
| function viewUserFunc(row) { // 查看订单 | ||||
|   router.push({name:'viewUserManage',params:{id:row.user_id}}) | ||||
| } | ||||
| function getExercisesName(row) { | ||||
|   return JSON.parse(row.question).title | ||||
| } | ||||
| // const std_options_title = ref(['A','B','C','D','E','F']) | ||||
| function addOptionFunc() { | ||||
|   exam_types.value.push('') | ||||
| } | ||||
| function delet_func() { | ||||
|   exam_types.value.pop() | ||||
| } | ||||
| function getStateName(state) { | ||||
|   let str = '' | ||||
|   switch (state){ | ||||
|     case 1: | ||||
|         str = '未付款' | ||||
|       break; | ||||
|     case 2: | ||||
|         str = '已付款' | ||||
|       break; | ||||
|     case 3: | ||||
|         str = '已过期' | ||||
|       break; | ||||
|   } | ||||
|   return str | ||||
| } | ||||
| function handleAvatarSuccess(res) { | ||||
|   form.value.cover = res.data.file.url | ||||
|   // handlerChange() | ||||
| } | ||||
| function beforeAvatarUpload(file) { | ||||
|   const isLt05M = file.size / 1024 / 1024 < 20 | ||||
|   const isJPG = file.type.indexOf('image/') === -1 | ||||
|   if (isJPG) { | ||||
|     ElMessage.error('文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件') | ||||
|   } | ||||
|   if (!isLt05M) { | ||||
|     ElMessage.error('上传头像图片大小不能超过 2M!') | ||||
|   } | ||||
|   return !isJPG && isLt05M | ||||
| } | ||||
| function changeSubjectFunc(e) { | ||||
|   current_subject.value = e | ||||
| } | ||||
| function addExercisesFunc(data) { | ||||
|   form.value.question_ids = data | ||||
| } | ||||
| function addCourseFunc(data) { | ||||
|   form.value.course_ids = data | ||||
| } | ||||
| function getTypeName(type) { | ||||
|   let name = "" | ||||
|   switch (type) { | ||||
|     case 1: | ||||
|       name = '课程'; | ||||
|       break; | ||||
|     case 2: | ||||
|       name = '章节'; | ||||
|       break; | ||||
|     case 3: | ||||
|       name = '子章节'; | ||||
|       break; | ||||
|     case 4: | ||||
|       name = '试卷'; | ||||
|       break; | ||||
|   } | ||||
|   return name | ||||
| } | ||||
| function getProvinceName(province) { | ||||
|   if(province < 0) return '' | ||||
|   return cityList[province].name | ||||
| } | ||||
| </script> | ||||
| <template> | ||||
|   <div> | ||||
|     <!--    搜索框--> | ||||
|     <div class="gva-search-box"> | ||||
|       <el-form ref="searchForm" :inline="true" :model="queryParams"> | ||||
|         <el-form-item label="用户名称"> | ||||
|           <el-input v-model="queryParams.name" placeholder="根据用户名称进行查询" /> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="区域"> | ||||
|           <el-select v-model="queryParams.province" clearable placeholder="请选择"> | ||||
|             <el-option | ||||
|               v-for="item in cityList" | ||||
|               :key="item.ProID" | ||||
|               :label="item.name" | ||||
|               :value="item.ProID" | ||||
|             /> | ||||
|           </el-select> | ||||
|         </el-form-item> | ||||
|         <el-form-item> | ||||
|           <el-button size="small" type="primary" icon="search" @click="onSubmit">查询</el-button> | ||||
|           <el-button size="small" icon="refresh" @click="onReset">重置</el-button> | ||||
|         </el-form-item> | ||||
|       </el-form> | ||||
|     </div> | ||||
|     <!--    表格数据--> | ||||
|     <div class="gva-table-box"> | ||||
|       <!--      批量操作--> | ||||
|       <div class="gva-btn-list"> | ||||
| <!--        <el-button size="small" type="primary" icon="plus" @click="openDialog('add')">新增</el-button>--> | ||||
|         <el-popover v-model="deleteVisible" placement="top" width="160"> | ||||
|           <p>确定要删除吗?</p> | ||||
|           <div style="text-align: right; margin-top: 8px;"> | ||||
|             <el-button size="small" type="primary" link @click="deleteVisible = false">取消</el-button> | ||||
|             <el-button size="small" type="primary" @click="onDelete">确定</el-button> | ||||
|           </div> | ||||
| <!--          <template #reference>--> | ||||
| <!--            <el-button icon="delete" size="small" type="danger" :disabled="!exam_ids.length" style="margin-left: 10px;" @click="deleteVisible = true">删除</el-button>--> | ||||
| <!--          </template>--> | ||||
|         </el-popover> | ||||
|       </div> | ||||
|       <!--      数据列表--> | ||||
|       <el-table :data="tableData" @selection-change="handleSelectionChange"> | ||||
| <!--        <el-table-column--> | ||||
| <!--          type="selection"--> | ||||
| <!--          width="55"--> | ||||
| <!--        />--> | ||||
|         <el-table-column align="center" label="ID"  prop="user_id" sortable="custom" /> | ||||
|         <el-table-column align="center" label="头像" min-width="150"> | ||||
|           <template #default="scope"> | ||||
|             <img class="avatar-css" :src="scope.row.avatar" alt=""> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column align="center" label="姓名" prop="nickname" /> | ||||
|         <el-table-column align="center" label="手机号" min-width="150" prop="phone" /> | ||||
|         <el-table-column align="center" label="身份" min-width="150" prop="order_type"> | ||||
|           <template #default="scope"> | ||||
|             {{scope.row.idCard}} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column align="center" label="所属区域" min-width="150"> | ||||
|           <template #default="scope"> | ||||
|             {{getProvinceName(scope.row.province)}} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|          <el-table-column align="center" label="推荐人ID" min-width="150" prop="invite_id" /> | ||||
|         <el-table-column align="center" label="报课次数" min-width="150" prop="name" /> | ||||
|         <el-table-column align="center" label="测试次数" min-width="150" prop="price" /> | ||||
|         <el-table-column align="center" label="累计金额" min-width="150" prop="balance" /> | ||||
|         <el-table-column align="center" label="注册时间" min-width="150" > | ||||
|           <template #default="scope"> | ||||
|             {{formatDate(scope.row.CreatedAt)}} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column align="center" fixed="right" label="操作" width="200"> | ||||
|           <template #default="scope"> | ||||
|             <el-button | ||||
|               icon="edit" | ||||
|               size="small" | ||||
|               type="primary" | ||||
|               link | ||||
|               @click="viewUserFunc(scope.row)" | ||||
|             >查看</el-button> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|       </el-table> | ||||
|       <div class="gva-pagination"> | ||||
|         <el-pagination | ||||
|           :current-page="queryParams.page" | ||||
|           :page-size="queryParams.pageSize" | ||||
|           :page-sizes="[10, 30, 50, 100]" | ||||
|           :total="total" | ||||
|           layout="total, sizes, prev, pager, next, jumper" | ||||
|           @current-change="handleCurrentChange" | ||||
|           @size-change="handleSizeChange" | ||||
|         /> | ||||
|       </div> | ||||
|     </div> | ||||
|     <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="dialogTitle"> | ||||
|       <el-form ref="apiForm" :model="form" :rules="rules" label-width="80px"> | ||||
|         <el-form-item label="试卷名称" > | ||||
|           <el-input v-model="form.name" placeholder="请输入试卷名称" /> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="科目" prop="subject"> | ||||
|           <el-select v-model="form.subject" @change="changeSubjectFunc" clearable placeholder="请选择"> | ||||
|             <el-option | ||||
|               v-for="item in subjectList" | ||||
|               :key="item.id" | ||||
|               :label="item.name" | ||||
|               :value="item.name" | ||||
|             /> | ||||
|           </el-select> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="封面"> | ||||
|           <el-upload | ||||
|             class="avatar-uploader" | ||||
|             :action="`${path}/fileUploadAndDownload/upload`" | ||||
|             :headers="{ 'x-token': userStore.token }" | ||||
|             :show-file-list="false" | ||||
|             :on-success="handleAvatarSuccess" | ||||
|             :before-upload="beforeAvatarUpload" | ||||
|           > | ||||
|             <img v-if="form.cover" :src="form.cover" class="avatar" /> | ||||
|             <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon> | ||||
|           </el-upload> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="测试时长" > | ||||
|           <el-input type="number" v-model="form.duration" placeholder="请输入测试时长(分钟)" /> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="测试组别" > | ||||
|           <!--          <el-input v-model="form.score" placeholder="请输入分值" />--> | ||||
|           <view class="options-box"> | ||||
|             <view class="option-item" v-if="exam_types.length>0" v-for="(item,i) in exam_types"> | ||||
|               <view>{{i+1}}</view> | ||||
|               <el-input type="number" style="margin-left:5px" v-model="exam_types[i]" placeholder="请输入组别人数" /> | ||||
|               <el-icon style="margin-left: 5px;cursor: pointer" v-if="(i+1) == exam_types.length" @click="delet_func(item)"><Delete /></el-icon> | ||||
|             </view> | ||||
|             <el-button @click="addOptionFunc">添加组别</el-button> | ||||
|           </view> | ||||
|         </el-form-item> | ||||
| <!--        <el-form-item label="添加习题" >--> | ||||
| <!--          <exercisesPool @addFunc="addExercisesFunc" :seleted_arr="form.question_ids" />--> | ||||
| <!--        </el-form-item>--> | ||||
| <!--        <el-form-item label="适用课程" >--> | ||||
| <!--          <coursePool @addFunc="addCourseFunc" :seleted_arr="form.course_ids" />--> | ||||
| <!--        </el-form-item>--> | ||||
|         <el-form-item label="受否上架" > | ||||
|           <el-switch | ||||
|             v-model="form.status" | ||||
|             active-text="上架" | ||||
|             inactive-text="下架" | ||||
|             :active-value="1" | ||||
|             :inactive-value="-1" | ||||
|           /> | ||||
|         </el-form-item> | ||||
|       </el-form> | ||||
|       <template #footer> | ||||
|         <div class="dialog-footer"> | ||||
|           <el-button size="small" @click="closeDialog">取 消</el-button> | ||||
|           <el-button size="small" type="primary" @click="enterDialog">确 定</el-button> | ||||
|         </div> | ||||
|       </template> | ||||
|     </el-dialog> | ||||
|   </div> | ||||
| </template> | ||||
| <style scoped lang="scss"> | ||||
|   .avatar-css{ | ||||
|     height: 100px; | ||||
|     width: 150px; | ||||
|   } | ||||
|   .e-img{ | ||||
|     width: 150px; | ||||
|     height: 100px; | ||||
|   } | ||||
|   .option-item{ | ||||
|     display: flex; | ||||
|     align-items: center; | ||||
|     margin-bottom: 10px; | ||||
|   } | ||||
|   .button-box { | ||||
|     padding: 10px 20px; | ||||
|     .el-button { | ||||
|       float: right; | ||||
|     } | ||||
|   } | ||||
|   .warning { | ||||
|     color: #dc143c; | ||||
|   } | ||||
| </style> | ||||
							
								
								
									
										279
									
								
								src/view/userManage/view.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										279
									
								
								src/view/userManage/view.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,279 @@ | ||||
| <script setup> | ||||
| // 引入依赖 | ||||
| import api from '@/api/userManage' | ||||
| import capi from '@/api/course' | ||||
| import custom from '@/utils/custom' | ||||
| import {formatDate} from '@/utils/format' | ||||
| // import { toSQLLine } from '@/utils/stringFun' | ||||
| // import WarningBar from '@/components/warningBar/warningBar.vue' | ||||
| // import coursePool from './components/coursePool.vue' | ||||
| // import exercisesPool from '@/view/course/components/exercisesPool.vue' | ||||
| import {ref,onMounted,provide } from 'vue' | ||||
| import { ElMessage, ElMessageBox } from 'element-plus' | ||||
| import { useRouter, useRoute } from 'vue-router' | ||||
| const router = useRouter() | ||||
| const route = useRoute() | ||||
| // 变量 | ||||
| const userManageInfo = ref({}) | ||||
| const imgs = ref([]) | ||||
| // 生命周期 | ||||
| onMounted(() => { | ||||
|   getUserDetail() | ||||
| }) | ||||
| // funstions | ||||
| async function getUserDetail() { | ||||
|   const res = await api.viewUser({id:route.params.id}) | ||||
|   if(res.code === 0) { | ||||
|     userManageInfo.value = res.data.user | ||||
|     // let teacher_cert = JSON.parse(res.data.teacher_cert) | ||||
|     // let skill_cert = JSON.parse(res.data.skill_cert) | ||||
|     // imgs.value = [...skill_cert,...teacher_cert] | ||||
|     // console.log(imgs.value) | ||||
|   } | ||||
| } | ||||
| const tip_text = ref('') | ||||
| const dialogVisible = ref(false) | ||||
| const a_type = ref(0) | ||||
| function actionFunc(type) { | ||||
|   dialogVisible.value = true | ||||
|   a_type.value = type | ||||
|   switch (type){ | ||||
|     case 3: | ||||
|       tip_text.value = '是否同意该教师申请?'; | ||||
|       break; | ||||
|     case 2: | ||||
|       tip_text.value = '是否拒绝该教师申请?'; | ||||
|       break; | ||||
|   } | ||||
| } | ||||
| async function actionOk() { // 确认提交 | ||||
|   const res = await api.teacherOperator({ | ||||
|     teacher_id:userManageInfo.value.user_id, | ||||
|     status:a_type.value | ||||
|   }) | ||||
|   if(res.code === 0) { | ||||
|     ElMessage({ | ||||
|       type: 'success', | ||||
|       message: res.msg | ||||
|     }) | ||||
|     getUserDetail() | ||||
|   } | ||||
| } | ||||
| function getStateName(state) { | ||||
|   let str = '' | ||||
|   switch (state){ | ||||
|     case 1: | ||||
|         str = '待审核' | ||||
|       break; | ||||
|     case 2: | ||||
|         str = '已拒绝' | ||||
|       break; | ||||
|     case 3: | ||||
|         str = '已同意' | ||||
|       break; | ||||
|   } | ||||
|   return str | ||||
| } | ||||
| </script> | ||||
| <template> | ||||
|   <div> | ||||
|     <!--    基本信息--> | ||||
|     <div class="gva-search-box"> | ||||
|       <div class="baseInfo-box"> | ||||
|         <div class="bb-item"> | ||||
|           <img class="avatar" :src="userManageInfo.avatar" alt=""> | ||||
|         </div> | ||||
|         <div class="bb-item"> | ||||
|           昵称:{{userManageInfo.nickname}} | ||||
|         </div> | ||||
|         <div class="bb-item"> | ||||
|           ID:{{userManageInfo.user_id}} | ||||
|         </div> | ||||
|         <div class="bb-item"> | ||||
|           注册时间:{{userManageInfo.CreatedAt}} | ||||
|         </div> | ||||
|         <div class="bb-item"> | ||||
|           身份:教师 | ||||
|         </div> | ||||
|         <div class="bb-item"> | ||||
|           邀请人数:105人 | ||||
|         </div> | ||||
|       </div> | ||||
|     </div> | ||||
|     <!--    章节信息--> | ||||
|     <div class="gva-table-box"> | ||||
|       <div class="detail-info-box"> | ||||
|         <div class="dib-row"> | ||||
|           <div class="dib-item"> | ||||
|             <div class="di-left">身份证号码:</div> | ||||
|             <div class="di-right">{{userManageInfo.id_card}}</div> | ||||
|           </div> | ||||
|           <div class="dib-item"> | ||||
|             <div class="di-left">手机号码:</div> | ||||
|             <div class="di-right">{{userManageInfo.phone}}</div> | ||||
|           </div> | ||||
|         </div> | ||||
|         <div class="dib-row"> | ||||
|           <div class="dib-item"> | ||||
|             <div class="di-left">区域:</div> | ||||
|             <div class="di-right">{{custom.getProvinceName(userManageInfo.province)}}</div> | ||||
|           </div> | ||||
|         </div> | ||||
|         <div class="dib-row"> | ||||
|           <div class="dib-item"> | ||||
|             <div class="di-left">余额:</div> | ||||
|             <div class="di-right">{{userManageInfo.balance}}元</div> | ||||
|           </div> | ||||
|           <div class="dib-item link-item"> | ||||
|             <div class="di-left">查看交易明细</div> | ||||
|           </div> | ||||
|         </div> | ||||
|         <div class="dib-row"> | ||||
|           <div class="dib-item"> | ||||
|             <div class="di-left">积分:</div> | ||||
|             <div class="di-right">{{userManageInfo.points}}</div> | ||||
|           </div> | ||||
|           <div class="dib-item link-item"> | ||||
|             <div class="di-left">查看交易明细</div> | ||||
|           </div> | ||||
|         </div> | ||||
|         <div class="dib-row"> | ||||
|           <div class="dib-item"> | ||||
|             <div class="di-left">报课次数:</div> | ||||
|             <div class="di-right">{{userManageInfo.course_sale}}次</div> | ||||
|           </div> | ||||
|           <div class="dib-item"> | ||||
|             <div class="di-left">累计金额:</div> | ||||
|             <div class="di-right">{{userManageInfo.course_income}}</div> | ||||
|           </div> | ||||
|           <div class="dib-item link-item"> | ||||
|             <div class="di-left">查看学习记录</div> | ||||
|           </div> | ||||
|         </div> | ||||
|         <div class="dib-row"> | ||||
|           <div class="dib-item"> | ||||
|             <div class="di-left">测试次数:</div> | ||||
|             <div class="di-right">{{userManageInfo.exam_sale}}次</div> | ||||
|           </div> | ||||
|           <div class="dib-item"> | ||||
|             <div class="di-left">累计金额:</div> | ||||
|             <div class="di-right">{{userManageInfo.exam_income}}</div> | ||||
|           </div> | ||||
|           <div class="dib-item link-item"> | ||||
|             <div class="di-left">查看测试记录</div> | ||||
|           </div> | ||||
|         </div> | ||||
|         <div class="dib-row"> | ||||
|           <div class="dib-item"> | ||||
|             <div class="di-left">抽奖次数:</div> | ||||
|             <div class="di-right">{{userManageInfo.exam_sale}}次</div> | ||||
|           </div> | ||||
|           <div class="dib-item"> | ||||
|             <div class="di-left">中奖次数:</div> | ||||
|             <div class="di-right">{{userManageInfo.exam_income}}次</div> | ||||
|           </div> | ||||
|           <div class="dib-item link-item"> | ||||
|             <div class="di-left">查看抽奖记录</div> | ||||
|           </div> | ||||
|         </div> | ||||
|         <div class="dib-row"> | ||||
|           <div class="dib-item"> | ||||
|             <div class="di-left">竞拍次数:</div> | ||||
|             <div class="di-right">{{userManageInfo.exam_sale}}次</div> | ||||
|           </div> | ||||
|           <div class="dib-item"> | ||||
|             <div class="di-left">中奖次数:</div> | ||||
|             <div class="di-right">{{userManageInfo.exam_income}}次</div> | ||||
|           </div> | ||||
|           <div class="dib-item link-item"> | ||||
|             <div class="di-left">查看竞拍记录</div> | ||||
|           </div> | ||||
|         </div> | ||||
|         <div class="dib-row"> | ||||
|           <div class="dib-item"> | ||||
|             <div class="di-left">邀请人姓名:</div> | ||||
|             <div class="di-right">{{userManageInfo.invite_id}}</div> | ||||
|           </div> | ||||
|           <div class="dib-item"> | ||||
|             <div class="di-left">邀请人姓名ID:</div> | ||||
|             <div class="di-right">{{userManageInfo.invite_id}}次</div> | ||||
|           </div> | ||||
|         </div> | ||||
|       </div> | ||||
|     </div> | ||||
|   </div> | ||||
| </template> | ||||
| <style scoped lang="scss"> | ||||
|   .action-box{ | ||||
|     display: flex; | ||||
|     margin-top: 20px; | ||||
|     justify-content: center; | ||||
|     .a-btn{ | ||||
|       background: rgb(60, 106, 112); | ||||
|       color: white; | ||||
|       padding: 10px 50px; | ||||
|       cursor: pointer; | ||||
|       margin: 10px; | ||||
|           border-radius: 5px; | ||||
|     } | ||||
|     .approved{ | ||||
|  | ||||
|     } | ||||
|     .refuse{ | ||||
|       background: white !important; | ||||
|       color:rgb(60, 106, 112) !important; | ||||
|       border: 1px solid rgb(60, 106, 112) !important; | ||||
|     } | ||||
|   } | ||||
|   /*基本信息*/ | ||||
|   .gva-search-box{ | ||||
|     .baseInfo-box{ | ||||
|       display: flex; | ||||
|       align-items: center; | ||||
|       //justify-content: space-around; | ||||
|       .bb-item{ | ||||
|         margin: 10px 20px; | ||||
|         .avatar{ | ||||
|           width: 50px; | ||||
|           height: 50px; | ||||
|           border-radius: 50%; | ||||
|           border: 1px solid #cdcdcd; | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   /*详细信息*/ | ||||
|   .text{ | ||||
|     color: red !important; | ||||
|   } | ||||
|   .state-text{ | ||||
|     font-size: 15px; | ||||
|     color: gray; | ||||
|   } | ||||
|   .gva-table-box{ | ||||
|     .detail-info-box{ | ||||
|       .dib-row{ | ||||
|         overflow: hidden; | ||||
|         .link-item{ | ||||
|           color: #3C6A70 !important; | ||||
|           cursor: pointer; | ||||
|         } | ||||
|         .dib-item{ | ||||
|           //color: gray; | ||||
|           padding: 10px 0; | ||||
|           display: flex; | ||||
|           float: left; | ||||
|           margin-right: 30px; | ||||
|           .di-left{ | ||||
|           } | ||||
|           .img-css{ | ||||
|             width: 100px; | ||||
|             height: 100px; | ||||
|             margin: 0 10px 10px 0; | ||||
|             cursor: pointer; | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| </style> | ||||
		Reference in New Issue
	
	Block a user