74 changed files with 5051 additions and 4372 deletions
@ -0,0 +1,60 @@ |
|||||
|
import request from '@/utils/request' |
||||
|
|
||||
|
|
||||
|
|
||||
|
// USER_CODE_BEGIN -- student
|
||||
|
/** |
||||
|
* 获取学员列表 |
||||
|
* @param params |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function getStudentList(params: Record<string, any>) { |
||||
|
return request.get(`student/student`, {params}) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取学员详情 |
||||
|
* @param id 学员id |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function getStudentInfo(id: number) { |
||||
|
return request.get(`student/student/${id}`); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 添加学员 |
||||
|
* @param params |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function addStudent(params: Record<string, any>) { |
||||
|
return request.post('student/student', params, { showErrorMessage: true, showSuccessMessage: true }) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 编辑学员 |
||||
|
* @param id |
||||
|
* @param params |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function editStudent(params: Record<string, any>) { |
||||
|
return request.put(`student/student/${params.id}`, params, { showErrorMessage: true, showSuccessMessage: true }) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除学员 |
||||
|
* @param id |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function deleteStudent(id: number) { |
||||
|
return request.delete(`student/student/${id}`, { showErrorMessage: true, showSuccessMessage: true }) |
||||
|
} |
||||
|
|
||||
|
export function getWithCampusList(params: Record<string,any>){ |
||||
|
return request.get('student/campus_all', {params}) |
||||
|
}export function getWithClassGradeList(params: Record<string,any>){ |
||||
|
return request.get('student/class_grade_all', {params}) |
||||
|
}export function getWithMemberList(params: Record<string,any>){ |
||||
|
return request.get('student/member_all', {params}) |
||||
|
} |
||||
|
|
||||
|
// USER_CODE_END -- student
|
||||
@ -1,29 +1,21 @@ |
|||||
{ |
{ |
||||
"id": "考勤编号", |
"campusId":"校区", |
||||
"idPlaceholder": "请输入考勤编号", |
"campusIdPlaceholder":"全部", |
||||
"campusId": "校区ID", |
"staffId":"人员", |
||||
"campusIdPlaceholder": "请输入校区ID", |
"staffIdPlaceholder":"全部", |
||||
"staffId": "人员ID", |
"attendanceDate":"考勤日期", |
||||
"staffIdPlaceholder": "请输入人员ID", |
"attendanceDatePlaceholder":"请输入考勤日期", |
||||
"attendanceDate": "考勤日期", |
"checkInTime":"签到时间", |
||||
"attendanceDatePlaceholder": "请输入考勤日期", |
"checkInTimePlaceholder":"请输入签到时间", |
||||
"checkInTime": "签到时间", |
"checkOutTime":"签退时间", |
||||
"checkInTimePlaceholder": "请输入签到时间", |
"checkOutTimePlaceholder":"请输入签退时间", |
||||
"checkOutTime": "签退时间", |
"remarks":"备注", |
||||
"checkOutTimePlaceholder": "请输入签退时间", |
"remarksPlaceholder":"请输入备注", |
||||
"status": "考勤状态", |
"status":"考勤状态", |
||||
"statusPlaceholder": "请输入考勤状态", |
"statusPlaceholder":"请输入考勤状态", |
||||
"remarks": "备注", |
"addAttendance":"添加考勤", |
||||
"remarksPlaceholder": "请输入备注", |
"updateAttendance":"编辑考勤", |
||||
"createdAt": "创建时间", |
"attendanceDeleteTips":"确定要删除该数据吗?", |
||||
"createdAtPlaceholder": "请输入创建时间", |
"startDate":"请选择开始时间", |
||||
"updatedAt": "修改时间", |
"endDate":"请选择结束时间" |
||||
"updatedAtPlaceholder": "请输入修改时间", |
|
||||
"coordinate": "坐标", |
|
||||
"coordinatePlaceholder": "请输入坐标", |
|
||||
"addAttendance": "添加考勤", |
|
||||
"updateAttendance": "编辑考勤", |
|
||||
"attendanceDeleteTips": "确定要删除该数据吗?", |
|
||||
"startDate": "请选择开始时间", |
|
||||
"endDate": "请选择结束时间" |
|
||||
} |
} |
||||
@ -1,25 +1,19 @@ |
|||||
{ |
{ |
||||
"id": "合同编号", |
"contractName":"合同名称", |
||||
"idPlaceholder": "请输入合同编号", |
"contractNamePlaceholder":"请输入合同名称", |
||||
"contractName": "合同名称", |
"contractTemplate":"合同模板", |
||||
"contractNamePlaceholder": "请输入合同名称", |
"contractTemplatePlaceholder":"请输入合同模板", |
||||
"contractTemplate": "合同模板", |
"contractStatus":"合同状态", |
||||
"contractTemplatePlaceholder": "请输入合同模板", |
"contractStatusPlaceholder":"请输入合同状态", |
||||
"contractStatus": "合同状态", |
"contractType":"合同类型", |
||||
"contractStatusPlaceholder": "请输入合同状态", |
"contractTypePlaceholder":"请输入合同类型", |
||||
"contractType": "合同类型", |
"remarks":"合同备注", |
||||
"contractTypePlaceholder": "请输入合同类型", |
"remarksPlaceholder":"请输入合同备注", |
||||
"remarks": "合同备注", |
"createdAt":"创建时间", |
||||
"remarksPlaceholder": "请输入合同备注", |
"createdAtPlaceholder":"请输入创建时间", |
||||
"createdAt": "创建时间", |
"addContract":"添加合同", |
||||
"createdAtPlaceholder": "请输入创建时间", |
"updateContract":"编辑合同", |
||||
"updatedAt": "修改时间", |
"contractDeleteTips":"确定要删除该数据吗?", |
||||
"updatedAtPlaceholder": "请输入修改时间", |
"startDate":"请选择开始时间", |
||||
"deletedAt": "逻辑删除时间", |
"endDate":"请选择结束时间" |
||||
"deletedAtPlaceholder": "请输入逻辑删除时间", |
|
||||
"addContract": "添加合同", |
|
||||
"updateContract": "编辑合同", |
|
||||
"contractDeleteTips": "确定要删除该数据吗?", |
|
||||
"startDate": "请选择开始时间", |
|
||||
"endDate": "请选择结束时间" |
|
||||
} |
} |
||||
@ -1,19 +1,18 @@ |
|||||
{ |
{ |
||||
"id": "答题记录编号", |
"campusId":"校区", |
||||
"idPlaceholder": "请输入答题记录编号", |
"campusIdPlaceholder":"全部", |
||||
"campusId": "校区ID", |
"userId":"人员", |
||||
"campusIdPlaceholder": "请输入校区ID", |
"userIdPlaceholder":"请输入人员", |
||||
"userId": "人员ID", |
"questionId":"试题", |
||||
"userIdPlaceholder": "请输入人员ID", |
"questionIdPlaceholder":"请输入试题", |
||||
"questionId": "试题ID", |
"answer":"用户答案", |
||||
"questionIdPlaceholder": "请输入试题ID", |
"answerPlaceholder":"请输入用户答案", |
||||
"answer": "用户答案", |
"isCorrect":"是否正确", |
||||
"answerPlaceholder": "请输入用户答案", |
"isCorrectPlaceholder":"请输入是否正确", |
||||
"isCorrect": "是否正确", |
"createdAt":"创建时间", |
||||
"isCorrectPlaceholder": "请输入是否正确", |
"addExamAnswers":"添加答题记录", |
||||
"addExamAnswers": "添加答题记录", |
"updateExamAnswers":"编辑答题记录", |
||||
"updateExamAnswers": "编辑答题记录", |
"examAnswersDeleteTips":"确定要删除该数据吗?", |
||||
"examAnswersDeleteTips": "确定要删除该数据吗?", |
"startDate":"请选择开始时间", |
||||
"startDate": "请选择开始时间", |
"endDate":"请选择结束时间" |
||||
"endDate": "请选择结束时间" |
|
||||
} |
} |
||||
@ -1,15 +1,17 @@ |
|||||
{ |
{ |
||||
"id": "试卷编号", |
"selectionMode":"题目选择模式", |
||||
"idPlaceholder": "请输入试卷编号", |
"selectionModePlaceholder":"请输入题目选择模式", |
||||
"selectionMode": "题目选择模式: random-随机主题, manual-自选题目", |
"questionsIds":"自选试题", |
||||
"selectionModePlaceholder": "请输入题目选择模式: random-随机主题, manual-自选题目", |
"questionsIdsPlaceholder":"请输入自选试题", |
||||
"totalScore": "总分", |
"totalScore":"总分", |
||||
"totalScorePlaceholder": "请输入总分", |
"totalScorePlaceholder":"请输入总分", |
||||
"passingScore": "合格分数", |
"passingScore":"合格分数", |
||||
"passingScorePlaceholder": "请输入合格分数", |
"passingScorePlaceholder":"请输入合格分数", |
||||
"addExamPapers": "添加试卷", |
"createdAt":"创建时间", |
||||
"updateExamPapers": "编辑试卷", |
"createdAtPlaceholder":"请输入创建时间", |
||||
"examPapersDeleteTips": "确定要删除该数据吗?", |
"addExamPapers":"添加试卷", |
||||
"startDate": "请选择开始时间", |
"updateExamPapers":"编辑试卷", |
||||
"endDate": "请选择结束时间" |
"examPapersDeleteTips":"确定要删除该数据吗?", |
||||
|
"startDate":"请选择开始时间", |
||||
|
"endDate":"请选择结束时间" |
||||
} |
} |
||||
@ -1,33 +1,22 @@ |
|||||
{ |
{ |
||||
"id": "试题编号", |
"title":"题目标题", |
||||
"idPlaceholder": "请输入试题编号", |
"titlePlaceholder":"请输入题目标题", |
||||
"questionType": "题型: single_choice-单选, multiple_choice-多选, true_false-判断", |
"questionType":"题型", |
||||
"questionTypePlaceholder": "请输入题型: single_choice-单选, multiple_choice-多选, true_false-判断", |
"questionTypePlaceholder":"请输入题型", |
||||
"questionContentType": "题干类型: text-文本, image-图片", |
"questionContentType":"题干类型", |
||||
"questionContentTypePlaceholder": "请输入题干类型: text-文本, image-图片", |
"questionContentTypePlaceholder":"请输入题干类型", |
||||
"questionContent": "题干内容(如果是图片则存储URL)", |
"questionContent":"题干内容", |
||||
"questionContentPlaceholder": "请输入题干内容(如果是图片则存储URL)", |
"questionContentPlaceholder":"请输入题干内容", |
||||
"optionAContentType": "选项A类型: text-文本, image-图片", |
"optionJson":"选项", |
||||
"optionAContentTypePlaceholder": "请输入选项A类型: text-文本, image-图片", |
"optionJsonPlaceholder":"请输入选项", |
||||
"optionAContent": "选项A内容(如果是图片则存储URL)", |
"correctAnswer":"正确答案", |
||||
"optionAContentPlaceholder": "请输入选项A内容(如果是图片则存储URL)", |
"correctAnswerPlaceholder":"请输入正确答案", |
||||
"optionBContentType": "选项B类型: text-文本, image-图片", |
"createdAt":"创建时间", |
||||
"optionBContentTypePlaceholder": "请输入选项B类型: text-文本, image-图片", |
"createdAtPlaceholder":"请输入创建时间", |
||||
"optionBContent": "选项B内容(如果是图片则存储URL)", |
"updatedAt":"修改时间", |
||||
"optionBContentPlaceholder": "请输入选项B内容(如果是图片则存储URL)", |
"addExamQuestions":"添加试题", |
||||
"optionCContentType": "选项C类型: text-文本, image-图片", |
"updateExamQuestions":"编辑试题", |
||||
"optionCContentTypePlaceholder": "请输入选项C类型: text-文本, image-图片", |
"examQuestionsDeleteTips":"确定要删除该数据吗?", |
||||
"optionCContent": "选项C内容(如果是图片则存储URL)", |
"startDate":"请选择开始时间", |
||||
"optionCContentPlaceholder": "请输入选项C内容(如果是图片则存储URL)", |
"endDate":"请选择结束时间" |
||||
"optionDContentType": "选项D类型: text-文本, image-图片", |
|
||||
"optionDContentTypePlaceholder": "请输入选项D类型: text-文本, image-图片", |
|
||||
"optionDContent": "选项D内容(如果是图片则存储URL)", |
|
||||
"optionDContentPlaceholder": "请输入选项D内容(如果是图片则存储URL)", |
|
||||
"correctAnswer": "正确答案(如果是多选,答案格式为如A,B,D)", |
|
||||
"correctAnswerPlaceholder": "请输入正确答案(如果是多选,答案格式为如A,B,D)", |
|
||||
"addExamQuestions": "添加试题", |
|
||||
"updateExamQuestions": "编辑试题", |
|
||||
"examQuestionsDeleteTips": "确定要删除该数据吗?", |
|
||||
"startDate": "请选择开始时间", |
|
||||
"endDate": "请选择结束时间" |
|
||||
} |
} |
||||
@ -1,23 +1,21 @@ |
|||||
{ |
{ |
||||
"id": "记录编号", |
"campusId":"校区", |
||||
"idPlaceholder": "请输入记录编号", |
"campusIdPlaceholder":"全部", |
||||
"campusId": "校区ID", |
"userId":"人员", |
||||
"campusIdPlaceholder": "请输入校区ID", |
"userIdPlaceholder":"请输入人员", |
||||
"userId": "人员ID", |
"paperId":"试卷", |
||||
"userIdPlaceholder": "请输入人员ID", |
"paperIdPlaceholder":"全部", |
||||
"paperId": "试卷ID", |
"score":"得分", |
||||
"paperIdPlaceholder": "请输入试卷ID", |
"scorePlaceholder":"请输入得分", |
||||
"score": "得分", |
"status":"考试状态", |
||||
"scorePlaceholder": "请输入得分", |
"statusPlaceholder":"请输入考试状态", |
||||
"status": "考试状态: in_progress-进行中, completed-已完成", |
"startTime":"考试开始时间", |
||||
"statusPlaceholder": "请输入考试状态: in_progress-进行中, completed-已完成", |
"startTimePlaceholder":"请输入考试开始时间", |
||||
"startTime": "考试开始时间", |
"endTime":"考试结束时间", |
||||
"startTimePlaceholder": "请输入考试开始时间", |
"endTimePlaceholder":"请输入考试结束时间", |
||||
"endTime": "考试结束时间", |
"addExamRecords":"添加考试记录", |
||||
"endTimePlaceholder": "请输入考试结束时间", |
"updateExamRecords":"编辑考试记录", |
||||
"addExamRecords": "添加考试记录", |
"examRecordsDeleteTips":"确定要删除该数据吗?", |
||||
"updateExamRecords": "编辑考试记录", |
"startDate":"请选择开始时间", |
||||
"examRecordsDeleteTips": "确定要删除该数据吗?", |
"endDate":"请选择结束时间" |
||||
"startDate": "请选择开始时间", |
|
||||
"endDate": "请选择结束时间" |
|
||||
} |
} |
||||
@ -1,23 +1,21 @@ |
|||||
{ |
{ |
||||
"id": "绩效编号", |
"staffId":"员工", |
||||
"idPlaceholder": "请输入绩效编号", |
"staffIdPlaceholder":"全部", |
||||
"staffId": "员工ID", |
"resourceId":"资源", |
||||
"staffIdPlaceholder": "请输入员工ID", |
"resourceIdPlaceholder":"请输入资源", |
||||
"resourceId": "资源ID", |
"orderStatus":"订单状态", |
||||
"resourceIdPlaceholder": "请输入资源ID", |
"orderStatusPlaceholder":"请输入订单状态", |
||||
"orderId": "订单ID", |
"performanceType":"绩效类型", |
||||
"orderIdPlaceholder": "请输入订单ID", |
"performanceTypePlaceholder":"请输入绩效类型", |
||||
"orderStatus": "订单状态: pending-待处理, completed-已完成, cancelled-已取消", |
"performanceValue":"绩效金额或分值", |
||||
"orderStatusPlaceholder": "请输入订单状态: pending-待处理, completed-已完成, cancelled-已取消", |
"performanceValuePlaceholder":"请输入绩效金额或分值", |
||||
"performanceType": "绩效类型: sales-销售绩效, marketing-市场绩效, other-其他", |
"remarks":"备注", |
||||
"performanceTypePlaceholder": "请输入绩效类型: sales-销售绩效, marketing-市场绩效, other-其他", |
"remarksPlaceholder":"请输入备注", |
||||
"performanceValue": "绩效金额或分值", |
"createdAt":"创建时间", |
||||
"performanceValuePlaceholder": "请输入绩效金额或分值", |
"createdAtPlaceholder":"请输入创建时间", |
||||
"remarks": "备注", |
"addPerformanceRecords":"添加绩效记录", |
||||
"remarksPlaceholder": "请输入备注", |
"updatePerformanceRecords":"编辑绩效记录", |
||||
"addPerformanceRecords": "添加绩效记录", |
"performanceRecordsDeleteTips":"确定要删除该数据吗?", |
||||
"updatePerformanceRecords": "编辑绩效记录", |
"startDate":"请选择开始时间", |
||||
"performanceRecordsDeleteTips": "确定要删除该数据吗?", |
"endDate":"请选择结束时间" |
||||
"startDate": "请选择开始时间", |
|
||||
"endDate": "请选择结束时间" |
|
||||
} |
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
{ |
||||
|
"campusId":"校区", |
||||
|
"campusIdPlaceholder":"全部", |
||||
|
"classId":"班级", |
||||
|
"classIdPlaceholder":"请输入班级", |
||||
|
"userId":"用户", |
||||
|
"userIdPlaceholder":"请输入用户", |
||||
|
"name":"学员姓名", |
||||
|
"namePlaceholder":"请输入学员姓名", |
||||
|
"gender":"性别", |
||||
|
"genderPlaceholder":"请输入性别", |
||||
|
"age":"年龄", |
||||
|
"agePlaceholder":"请输入年龄", |
||||
|
"birthday":"生日", |
||||
|
"birthdayPlaceholder":"请输入生日", |
||||
|
"emergencyContact":"紧急联系人", |
||||
|
"emergencyContactPlaceholder":"请输入紧急联系人", |
||||
|
"contactPhone":"联系人电话", |
||||
|
"contactPhonePlaceholder":"请输入联系人电话", |
||||
|
"note":"备注信息", |
||||
|
"notePlaceholder":"请输入备注信息", |
||||
|
"status":"学员状态", |
||||
|
"statusPlaceholder":"请输入学员状态", |
||||
|
"createdAt":"创建时间", |
||||
|
"createdAtPlaceholder":"请输入创建时间", |
||||
|
"addStudent":"添加学员", |
||||
|
"updateStudent":"编辑学员", |
||||
|
"studentDeleteTips":"确定要删除该数据吗?", |
||||
|
"startDate":"请选择开始时间", |
||||
|
"endDate":"请选择结束时间" |
||||
|
} |
||||
@ -1,205 +1,298 @@ |
|||||
<template> |
<template> |
||||
<el-dialog |
<el-dialog v-model="showDialog" :title="formData.id ? t('updateExamPapers') : t('addExamPapers')" width="50%" |
||||
v-model="showDialog" |
class="diy-dialog-wrap" :destroy-on-close="true"> |
||||
:title="formData.id ? t('updateExamPapers') : t('addExamPapers')" |
<el-form :model="formData" label-width="120px" ref="formRef" :rules="formRules" class="page-form" |
||||
width="50%" |
v-loading="loading"> |
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
<el-form-item label="试卷标题"> |
||||
> |
<el-input v-model="formData.title" class="input-width" /> |
||||
<el-form |
</el-form-item> |
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
<el-form-item :label="t('selectionMode')" prop="selection_mode"> |
||||
:rules="formRules" |
<el-select class="input-width" v-model="formData.selection_mode" clearable |
||||
class="page-form" |
:placeholder="t('selectionModePlaceholder')"> |
||||
v-loading="loading" |
<el-option label="请选择" value=""></el-option> |
||||
> |
<el-option v-for="(item, index) in selection_modeList" :key="index" :label="item.name" |
||||
<el-form-item :label="t('selectionMode')" prop="selection_mode"> |
:value="item.value" /> |
||||
<el-input |
</el-select> |
||||
v-model="formData.selection_mode" |
</el-form-item> |
||||
clearable |
|
||||
:placeholder="t('selectionModePlaceholder')" |
<!-- <el-form-item :label="t('questionsIds')" > |
||||
class="input-width" |
<el-input v-model="formData.questions_ids" clearable :placeholder="t('questionsIdsPlaceholder')" class="input-width" /> |
||||
/> |
</el-form-item> --> |
||||
</el-form-item> |
|
||||
|
<el-form-item :label="t('questionsIds')" v-if="formData.selection_mode == 'manual'"> |
||||
<el-form-item :label="t('totalScore')" prop="total_score"> |
<div class="mt-[10px]"> |
||||
<el-input |
<el-table ref="tableRef" :data="questionsList" style="width: 100%" |
||||
v-model="formData.total_score" |
@selection-change="handleSelectionChange" :loading="loadinga"> |
||||
clearable |
<el-table-column type="selection" width="55" /> |
||||
:placeholder="t('totalScorePlaceholder')" |
<el-table-column prop="title" label="题目标题" /> |
||||
class="input-width" |
|
||||
/> |
<el-table-column label="题型" min-width="180" align="center" :show-overflow-tooltip="true"> |
||||
</el-form-item> |
<template #default="{ row }"> |
||||
|
<div v-for="(item, index) in question_typeList"> |
||||
<el-form-item :label="t('passingScore')" prop="passing_score"> |
<div v-if="item.value == row.question_type">{{ item.name }}</div> |
||||
<el-input |
</div> |
||||
v-model="formData.passing_score" |
</template> |
||||
clearable |
</el-table-column> |
||||
:placeholder="t('passingScorePlaceholder')" |
|
||||
class="input-width" |
<el-table-column label="题干类型" min-width="180" align="center" :show-overflow-tooltip="true"> |
||||
/> |
<template #default="{ row }"> |
||||
</el-form-item> |
<div v-for="(item, index) in question_content_typeList"> |
||||
</el-form> |
<div v-if="item.value == row.question_content_type">{{ item.name }}</div> |
||||
|
</div> |
||||
<template #footer> |
</template> |
||||
<span class="dialog-footer"> |
</el-table-column> |
||||
<el-button @click="showDialog = false">{{ t('cancel') }}</el-button> |
|
||||
<el-button |
<el-table-column label="题干内容" width="100" align="left"> |
||||
type="primary" |
<template #default="{ row }"> |
||||
:loading="loading" |
<el-avatar v-if="row.question_content_type == 'image'" |
||||
@click="confirm(formRef)" |
:src="img(row.question_content)" /> |
||||
>{{ t('confirm') }}</el-button |
<div v-if="row.question_content_type == 'text'">{{ row.question_content }}</div> |
||||
> |
</template> |
||||
</span> |
</el-table-column> |
||||
</template> |
|
||||
</el-dialog> |
|
||||
|
</el-table> |
||||
|
|
||||
|
<div class="mt-[16px] flex justify-end"> |
||||
|
<el-pagination v-model:current-page="currentPage" v-model:page-size="pageSize" |
||||
|
layout="total, sizes, prev, pager, next, jumper" :total="total" |
||||
|
@size-change="fetchQuestions()" @current-change="fetchQuestions" /> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('totalScore')" prop="total_score"> |
||||
|
<el-input-number v-model="formData.total_score" clearable :placeholder="t('totalScorePlaceholder')" |
||||
|
class="input-width" :min="0" max="100" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('passingScore')" prop="passing_score"> |
||||
|
<el-input-number v-model="formData.passing_score" clearable :placeholder="t('passingScorePlaceholder')" |
||||
|
class="input-width" :min="0" max="100" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
</el-form> |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
<template #footer> |
||||
|
<span class="dialog-footer"> |
||||
|
<el-button @click="showDialog = false">{{ t('cancel') }}</el-button> |
||||
|
<el-button type="primary" :loading="loading" @click="confirm(formRef)">{{ |
||||
|
t('confirm') |
||||
|
}}</el-button> |
||||
|
</span> |
||||
|
</template> |
||||
|
</el-dialog> |
||||
|
|
||||
|
|
||||
|
|
||||
</template> |
</template> |
||||
|
|
||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||
import { ref, reactive, computed, watch } from 'vue' |
import { ref, reactive, computed, watch ,nextTick } from 'vue' |
||||
import { useDictionary } from '@/app/api/dict' |
import { useDictionary } from '@/app/api/dict' |
||||
import { t } from '@/lang' |
import { t } from '@/lang' |
||||
import type { FormInstance } from 'element-plus' |
import type { FormInstance } from 'element-plus' |
||||
import { |
import { addExamPapers, editExamPapers, getExamPapersInfo } from '@/app/api/exam_papers' |
||||
addExamPapers, |
import { getExamQuestionsList } from '@/app/api/exam_questions' |
||||
editExamPapers, |
|
||||
getExamPapersInfo, |
let showDialog = ref(false) |
||||
} from '@/app/api/exam_papers' |
const loading = ref(false) |
||||
|
|
||||
let showDialog = ref(false) |
/** |
||||
const loading = ref(false) |
* 表单数据 |
||||
|
*/ |
||||
/** |
const initialFormData = { |
||||
* 表单数据 |
id: '', |
||||
*/ |
title: '', |
||||
const initialFormData = { |
selection_mode: '', |
||||
id: '', |
questions_ids: '', |
||||
selection_mode: '', |
total_score: '', |
||||
total_score: '', |
passing_score: '', |
||||
passing_score: '', |
|
||||
} |
} |
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
// 字典数据 |
||||
|
const question_typeList = ref([] as any[]) |
||||
// 表单验证规则 |
const question_typeDictList = async () => { |
||||
const formRules = computed(() => { |
question_typeList.value = await (await useDictionary('question_type')).data.dictionary |
||||
return { |
} |
||||
selection_mode: [ |
question_typeDictList(); |
||||
{ |
const question_content_typeList = ref([] as any[]) |
||||
required: true, |
const question_content_typeDictList = async () => { |
||||
message: t('selectionModePlaceholder'), |
question_content_typeList.value = await (await useDictionary('question_content_type')).data.dictionary |
||||
trigger: 'blur', |
} |
||||
}, |
question_content_typeDictList(); |
||||
], |
|
||||
total_score: [ |
|
||||
{ required: true, message: t('totalScorePlaceholder'), trigger: 'blur' }, |
const dialogVisible = ref(false) |
||||
], |
|
||||
passing_score: [ |
// 列表数据 |
||||
{ |
const questionsList = ref([]) |
||||
required: true, |
const loadinga = ref(false) |
||||
message: t('passingScorePlaceholder'), |
const total = ref(0) |
||||
trigger: 'blur', |
const pageSize = 10 |
||||
}, |
const currentPage = ref(1) |
||||
], |
|
||||
} |
const selectedQuestions = ref([]) |
||||
}) |
const tableRef = ref() |
||||
|
|
||||
const emit = defineEmits(['complete']) |
const fetchQuestions = async (page = 1) => { |
||||
|
loadinga.value = true |
||||
/** |
currentPage.value = page |
||||
* 确认 |
getExamQuestionsList({ |
||||
* @param formEl |
page: page, |
||||
*/ |
limit: pageSize |
||||
const confirm = async (formEl: FormInstance | undefined) => { |
}).then(res => { |
||||
if (loading.value || !formEl) return |
questionsList.value = res.data.data |
||||
let save = formData.id ? editExamPapers : addExamPapers |
total.value = res.data.total |
||||
|
loadinga.value = false |
||||
await formEl.validate(async (valid) => { |
|
||||
if (valid) { |
}).catch(() => { |
||||
loading.value = true |
loadinga.value = false |
||||
|
}) |
||||
let data = formData |
} |
||||
|
|
||||
save(data) |
fetchQuestions() |
||||
.then((res) => { |
|
||||
loading.value = false |
const handleSelectionChange = (val) => { |
||||
showDialog.value = false |
selectedQuestions.value = val |
||||
emit('complete') |
} |
||||
}) |
|
||||
.catch((err) => { |
|
||||
loading.value = false |
|
||||
}) |
const formData : Record<string, any> = reactive({ ...initialFormData }) |
||||
} |
|
||||
}) |
const formRef = ref<FormInstance>() |
||||
} |
|
||||
|
// 表单验证规则 |
||||
// 获取字典数据 |
const formRules = computed(() => { |
||||
|
return { |
||||
const setFormData = async (row: any = null) => { |
selection_mode: [ |
||||
Object.assign(formData, initialFormData) |
{ required: true, message: t('selectionModePlaceholder'), trigger: 'blur' }, |
||||
loading.value = true |
|
||||
if (row) { |
] |
||||
const data = await (await getExamPapersInfo(row.id)).data |
} |
||||
if (data) |
}) |
||||
Object.keys(formData).forEach((key: string) => { |
|
||||
if (data[key] != undefined) formData[key] = data[key] |
const emit = defineEmits(['complete']) |
||||
}) |
|
||||
} |
/** |
||||
loading.value = false |
* 确认 |
||||
} |
* @param formEl |
||||
|
*/ |
||||
// 验证手机号格式 |
const confirm = async (formEl : FormInstance | undefined) => { |
||||
const mobileVerify = (rule: any, value: any, callback: any) => { |
if (loading.value || !formEl) return |
||||
if (value && !/^1[3-9]\d{9}$/.test(value)) { |
let save = formData.id ? editExamPapers : addExamPapers |
||||
callback(new Error(t('generateMobile'))) |
|
||||
} else { |
await formEl.validate(async (valid) => { |
||||
callback() |
if (valid) { |
||||
} |
loading.value = true |
||||
} |
|
||||
|
if (formData.selection_mode == 'manual') { |
||||
// 验证身份证号 |
const ids = selectedQuestions.value.map(item => item.id).join(',') |
||||
const idCardVerify = (rule: any, value: any, callback: any) => { |
formData.questions_ids = ids |
||||
if ( |
} |
||||
value && |
|
||||
!/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test( |
let data = formData |
||||
value |
|
||||
) |
save(data).then(res => { |
||||
) { |
loading.value = false |
||||
callback(new Error(t('generateIdCard'))) |
showDialog.value = false |
||||
} else { |
emit('complete') |
||||
callback() |
}).catch(err => { |
||||
} |
loading.value = false |
||||
} |
}) |
||||
|
} |
||||
// 验证邮箱号 |
}) |
||||
const emailVerify = (rule: any, value: any, callback: any) => { |
} |
||||
if (value && !/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(value)) { |
|
||||
callback(new Error(t('generateEmail'))) |
// 获取字典数据 |
||||
} else { |
let selection_modeList = ref([]) |
||||
callback() |
const selection_modeDictList = async () => { |
||||
} |
selection_modeList.value = await (await useDictionary('selection_mode')).data.dictionary |
||||
} |
} |
||||
|
selection_modeDictList(); |
||||
// 验证请输入整数 |
watch(() => selection_modeList.value, () => { formData.selection_mode = selection_modeList.value[0].value }) |
||||
const numberVerify = (rule: any, value: any, callback: any) => { |
|
||||
if (!Number.isInteger(value)) { |
|
||||
callback(new Error(t('generateNumber'))) |
|
||||
} else { |
const setFormData = async (row : any = null) => { |
||||
callback() |
Object.assign(formData, initialFormData) |
||||
} |
loading.value = true |
||||
} |
if (row) { |
||||
|
const data = await (await getExamPapersInfo(row.id)).data |
||||
defineExpose({ |
if (data) Object.keys(formData).forEach((key : string) => { |
||||
showDialog, |
if (data[key] != undefined) formData[key] = data[key] |
||||
setFormData, |
}) |
||||
}) |
} |
||||
|
|
||||
|
nextTick(() => { |
||||
|
const ids = formData.questions_ids?.split(',') || [] |
||||
|
console.log(ids); |
||||
|
questionsList.value.forEach(row => { |
||||
|
if (ids.includes(String(row.id))) { |
||||
|
tableRef.value.toggleRowSelection(row) |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
|
|
||||
|
|
||||
|
loading.value = false |
||||
|
} |
||||
|
|
||||
|
// 验证手机号格式 |
||||
|
const mobileVerify = (rule : any, value : any, callback : any) => { |
||||
|
if (value && !/^1[3-9]\d{9}$/.test(value)) { |
||||
|
callback(new Error(t('generateMobile'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 验证身份证号 |
||||
|
const idCardVerify = (rule : any, value : any, callback : any) => { |
||||
|
if (value && !/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(value)) { |
||||
|
callback(new Error(t('generateIdCard'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 验证邮箱号 |
||||
|
const emailVerify = (rule : any, value : any, callback : any) => { |
||||
|
if (value && !/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(value)) { |
||||
|
callback(new Error(t('generateEmail'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 验证请输入整数 |
||||
|
const numberVerify = (rule : any, value : any, callback : any) => { |
||||
|
if (!Number.isInteger(value)) { |
||||
|
callback(new Error(t('generateNumber'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
defineExpose({ |
||||
|
showDialog, |
||||
|
setFormData |
||||
|
}) |
||||
</script> |
</script> |
||||
|
|
||||
<style lang="scss" scoped></style> |
<style lang="scss" scoped></style> |
||||
<style lang="scss"> |
<style lang="scss"> |
||||
.diy-dialog-wrap .el-form-item__label { |
.diy-dialog-wrap .el-form-item__label { |
||||
height: auto !important; |
height: auto !important; |
||||
} |
} |
||||
</style> |
</style> |
||||
@ -0,0 +1,287 @@ |
|||||
|
<template> |
||||
|
<el-dialog v-model="showDialog" :title="formData.id ? t('updateExamQuestions') : t('addExamQuestions')" width="50%" |
||||
|
class="diy-dialog-wrap" :destroy-on-close="true"> |
||||
|
<el-form :model="formData" label-width="120px" ref="formRef" :rules="formRules" class="page-form" |
||||
|
v-loading="loading"> |
||||
|
<el-form-item :label="t('title')" prop="title"> |
||||
|
<el-input v-model="formData.title" clearable :placeholder="t('titlePlaceholder')" class="input-width" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('questionType')" prop="question_type"> |
||||
|
<el-select class="input-width" v-model="formData.question_type" clearable |
||||
|
:placeholder="t('questionTypePlaceholder')"> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option v-for="(item, index) in question_typeList" :key="index" :label="item.name" |
||||
|
:value="item.value" /> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('questionContentType')" prop="question_content_type"> |
||||
|
<el-select class="input-width" v-model="formData.question_content_type" clearable |
||||
|
:placeholder="t('questionContentTypePlaceholder')"> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option v-for="(item, index) in question_content_typeList" :key="index" :label="item.name" |
||||
|
:value="item.value" /> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('questionContent')" v-if="formData.question_content_type == 'text'"> |
||||
|
<el-input v-model="formData.question_content" clearable class="input-width" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
|
||||
|
<el-form-item :label="t('questionContent')" v-if="formData.question_content_type == 'image'"> |
||||
|
<upload-image v-model="formData.question_content" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<!-- <el-form-item :label="t('optionJson')" prop="option_json"> |
||||
|
<el-input v-model="formData.option_json" clearable :placeholder="t('optionJsonPlaceholder')" class="input-width" /> |
||||
|
</el-form-item> --> |
||||
|
|
||||
|
<el-form-item :label="t('optionJson')"> |
||||
|
<div v-for="(option, index) in formData.option_json" :key="index" class="option-item"> |
||||
|
<el-card class="box-card" shadow="never"> |
||||
|
|
||||
|
<el-form-item label="类型" label-width="60"> |
||||
|
<el-select v-model="option.option_content_type" placeholder="请选择类型"> |
||||
|
<el-option label="文本" value="text" /> |
||||
|
<el-option label="图片" value="image" /> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item label="内容" label-width="60" style="margin-top:5px;"> |
||||
|
<template v-if="option.option_content_type === 'text'"> |
||||
|
<el-input v-model="option.option_content" placeholder="请输入选项文本" /> |
||||
|
</template> |
||||
|
<template v-else> |
||||
|
<upload-file v-model="option.option_content" /> |
||||
|
</template> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item label="答案" label-width="60"> |
||||
|
<el-switch v-model="option.correct_answer" |
||||
|
:disabled="formData.question_type === 'single_choice' && option.correct_answer" |
||||
|
@change="handleCorrectAnswerChange(index)" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item label="操作" label-width="60"> |
||||
|
<el-button @click="removeOption(index)" type="danger" size="small" plain>删除</el-button> |
||||
|
</el-form-item> |
||||
|
|
||||
|
|
||||
|
|
||||
|
</el-card> |
||||
|
</div> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item> |
||||
|
<el-button type="primary" @click="addOption">添加选项</el-button> |
||||
|
</el-form-item> |
||||
|
|
||||
|
|
||||
|
</el-form> |
||||
|
|
||||
|
<template #footer> |
||||
|
<span class="dialog-footer"> |
||||
|
<el-button @click="showDialog = false">{{ t('cancel') }}</el-button> |
||||
|
<el-button type="primary" :loading="loading" @click="confirm(formRef)">{{ |
||||
|
t('confirm') |
||||
|
}}</el-button> |
||||
|
</span> |
||||
|
</template> |
||||
|
</el-dialog> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts" setup> |
||||
|
import { ref, reactive, computed, watch } from 'vue' |
||||
|
import { useDictionary } from '@/app/api/dict' |
||||
|
import { t } from '@/lang' |
||||
|
import type { FormInstance } from 'element-plus' |
||||
|
import { addExamQuestions, editExamQuestions, getExamQuestionsInfo } from '@/app/api/exam_questions' |
||||
|
|
||||
|
let showDialog = ref(false) |
||||
|
const loading = ref(false) |
||||
|
|
||||
|
/** |
||||
|
* 表单数据 |
||||
|
*/ |
||||
|
const initialFormData = { |
||||
|
id: '', |
||||
|
title: '', |
||||
|
question_type: '', |
||||
|
question_content_type: '', |
||||
|
question_content: '', |
||||
|
option_json: [] |
||||
|
} |
||||
|
|
||||
|
const addOption = () => { |
||||
|
formData.option_json.push({ |
||||
|
option_content_type: 'text', |
||||
|
option_content: '', |
||||
|
correct_answer: false |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
const removeOption = (index) => { |
||||
|
formData.option_json.splice(index, 1) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
const handleCorrectAnswerChange = (changedIndex) => { |
||||
|
if (formData.question_type === 'single_choice') { |
||||
|
formData.options.forEach((opt, i) => { |
||||
|
if (i !== changedIndex) opt.correct_answer = false |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
const formData : Record<string, any> = reactive({ ...initialFormData }) |
||||
|
|
||||
|
const formRef = ref<FormInstance>() |
||||
|
|
||||
|
// 表单验证规则 |
||||
|
const formRules = computed(() => { |
||||
|
return { |
||||
|
title: [ |
||||
|
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
question_type: [ |
||||
|
{ required: true, message: t('questionTypePlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
question_content_type: [ |
||||
|
{ required: true, message: t('questionContentTypePlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
question_content: [ |
||||
|
{ required: true, message: t('questionContentPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
option_json: [ |
||||
|
{ required: true, message: t('optionJsonPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
correct_answer: [ |
||||
|
{ required: true, message: t('correctAnswerPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
const emit = defineEmits(['complete']) |
||||
|
|
||||
|
/** |
||||
|
* 确认 |
||||
|
* @param formEl |
||||
|
*/ |
||||
|
const confirm = async (formEl : FormInstance | undefined) => { |
||||
|
if (loading.value || !formEl) return |
||||
|
let save = formData.id ? editExamQuestions : addExamQuestions |
||||
|
|
||||
|
await formEl.validate(async (valid) => { |
||||
|
if (valid) { |
||||
|
loading.value = true |
||||
|
|
||||
|
let data = formData |
||||
|
|
||||
|
save(data).then(res => { |
||||
|
loading.value = false |
||||
|
showDialog.value = false |
||||
|
emit('complete') |
||||
|
}).catch(err => { |
||||
|
loading.value = false |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
// 获取字典数据 |
||||
|
let question_typeList = ref([]) |
||||
|
const question_typeDictList = async () => { |
||||
|
question_typeList.value = await (await useDictionary('question_type')).data.dictionary |
||||
|
} |
||||
|
question_typeDictList(); |
||||
|
watch(() => question_typeList.value, () => { formData.question_type = question_typeList.value[0].value }) |
||||
|
let question_content_typeList = ref([]) |
||||
|
const question_content_typeDictList = async () => { |
||||
|
question_content_typeList.value = await (await useDictionary('question_content_type')).data.dictionary |
||||
|
} |
||||
|
question_content_typeDictList(); |
||||
|
watch(() => question_content_typeList.value, () => { formData.question_content_type = question_content_typeList.value[0].value }) |
||||
|
|
||||
|
|
||||
|
|
||||
|
const setFormData = async (row : any = null) => { |
||||
|
Object.assign(formData, initialFormData) |
||||
|
loading.value = true |
||||
|
if (row) { |
||||
|
const data = await (await getExamQuestionsInfo(row.id)).data |
||||
|
if (data) Object.keys(formData).forEach((key : string) => { |
||||
|
if (data[key] != undefined) formData[key] = data[key] |
||||
|
}) |
||||
|
} |
||||
|
loading.value = false |
||||
|
} |
||||
|
|
||||
|
// 验证手机号格式 |
||||
|
const mobileVerify = (rule : any, value : any, callback : any) => { |
||||
|
if (value && !/^1[3-9]\d{9}$/.test(value)) { |
||||
|
callback(new Error(t('generateMobile'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 验证身份证号 |
||||
|
const idCardVerify = (rule : any, value : any, callback : any) => { |
||||
|
if (value && !/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(value)) { |
||||
|
callback(new Error(t('generateIdCard'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 验证邮箱号 |
||||
|
const emailVerify = (rule : any, value : any, callback : any) => { |
||||
|
if (value && !/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(value)) { |
||||
|
callback(new Error(t('generateEmail'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 验证请输入整数 |
||||
|
const numberVerify = (rule : any, value : any, callback : any) => { |
||||
|
if (!Number.isInteger(value)) { |
||||
|
callback(new Error(t('generateNumber'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
defineExpose({ |
||||
|
showDialog, |
||||
|
setFormData |
||||
|
}) |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped></style> |
||||
|
<style lang="scss"> |
||||
|
.diy-dialog-wrap .el-form-item__label { |
||||
|
height: auto !important; |
||||
|
} |
||||
|
|
||||
|
.option-item { |
||||
|
margin-bottom: 20px; |
||||
|
margin-right: 10px; |
||||
|
|
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,315 @@ |
|||||
|
<template> |
||||
|
<el-dialog v-model="showDialog" :title="formData.id ? t('updateStudent') : t('addStudent')" width="50%" class="diy-dialog-wrap" :destroy-on-close="true"> |
||||
|
<el-form :model="formData" label-width="120px" ref="formRef" :rules="formRules" class="page-form" v-loading="loading"> |
||||
|
<el-form-item :label="t('campusId')" > |
||||
|
<el-select class="input-width" v-model="formData.campus_id" clearable :placeholder="t('campusIdPlaceholder')"> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="(item, index) in campusIdList" |
||||
|
:key="index" |
||||
|
:label="item['campus_name']" |
||||
|
:value="item['id']" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('classId')" prop="class_id"> |
||||
|
<el-select class="input-width" v-model="formData.class_id" clearable :placeholder="t('classIdPlaceholder')"> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="(item, index) in classIdList" |
||||
|
:key="index" |
||||
|
:label="item['class_name']" |
||||
|
:value="item['id']" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('userId')" prop="user_id"> |
||||
|
<el-select class="input-width" v-model="formData.user_id" clearable :placeholder="t('userIdPlaceholder')"> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="(item, index) in userIdList" |
||||
|
:key="index" |
||||
|
:label="item['nickname']" |
||||
|
:value="item['member_id']" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('name')" prop="name"> |
||||
|
<el-input v-model="formData.name" clearable :placeholder="t('namePlaceholder')" class="input-width" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('gender')" prop="gender"> |
||||
|
<el-select class="input-width" v-model="formData.gender" clearable :placeholder="t('genderPlaceholder')"> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="(item, index) in genderList" |
||||
|
:key="index" |
||||
|
:label="item.name" |
||||
|
:value="item.value" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('age')" > |
||||
|
<el-input v-model="formData.age" clearable :placeholder="t('agePlaceholder')" class="input-width" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('birthday')" class="input-width"> |
||||
|
<el-date-picker |
||||
|
class="flex-1 !flex" |
||||
|
v-model="formData.birthday" |
||||
|
clearable |
||||
|
type="datetime" |
||||
|
value-format="YYYY-MM-DD HH:mm:ss" |
||||
|
:placeholder="t('birthdayPlaceholder')"> |
||||
|
</el-date-picker> |
||||
|
</el-form-item> |
||||
|
<el-form-item :label="t('emergencyContact')" > |
||||
|
<el-input v-model="formData.emergency_contact" clearable :placeholder="t('emergencyContactPlaceholder')" class="input-width" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('contactPhone')" > |
||||
|
<el-input v-model="formData.contact_phone" clearable :placeholder="t('contactPhonePlaceholder')" class="input-width" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('note')" > |
||||
|
<el-input v-model="formData.note" clearable :placeholder="t('notePlaceholder')" class="input-width" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('status')" prop="status"> |
||||
|
<el-select class="input-width" v-model="formData.status" clearable :placeholder="t('statusPlaceholder')"> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="(item, index) in statusList" |
||||
|
:key="index" |
||||
|
:label="item.name" |
||||
|
:value="Number(item.value)" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
</el-form> |
||||
|
|
||||
|
<template #footer> |
||||
|
<span class="dialog-footer"> |
||||
|
<el-button @click="showDialog = false">{{ t('cancel') }}</el-button> |
||||
|
<el-button type="primary" :loading="loading" @click="confirm(formRef)">{{ |
||||
|
t('confirm') |
||||
|
}}</el-button> |
||||
|
</span> |
||||
|
</template> |
||||
|
</el-dialog> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts" setup> |
||||
|
import { ref, reactive, computed, watch } from 'vue' |
||||
|
import { useDictionary } from '@/app/api/dict' |
||||
|
import { t } from '@/lang' |
||||
|
import type { FormInstance } from 'element-plus' |
||||
|
import { addStudent, editStudent, getStudentInfo, getWithCampusList, getWithClassGradeList, getWithMemberList } from '@/app/api/student' |
||||
|
|
||||
|
let showDialog = ref(false) |
||||
|
const loading = ref(false) |
||||
|
|
||||
|
/** |
||||
|
* 表单数据 |
||||
|
*/ |
||||
|
const initialFormData = { |
||||
|
id: '', |
||||
|
campus_id: '', |
||||
|
class_id: '', |
||||
|
user_id: '', |
||||
|
name: '', |
||||
|
gender: '', |
||||
|
age: '', |
||||
|
birthday: '', |
||||
|
emergency_contact: '', |
||||
|
contact_phone: '', |
||||
|
note: '', |
||||
|
status: '', |
||||
|
} |
||||
|
const formData: Record<string, any> = reactive({ ...initialFormData }) |
||||
|
|
||||
|
const formRef = ref<FormInstance>() |
||||
|
|
||||
|
// 表单验证规则 |
||||
|
const formRules = computed(() => { |
||||
|
return { |
||||
|
campus_id: [ |
||||
|
{ required: true, message: t('campusIdPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
class_id: [ |
||||
|
{ required: true, message: t('classIdPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
user_id: [ |
||||
|
{ required: true, message: t('userIdPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
name: [ |
||||
|
{ required: true, message: t('namePlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
gender: [ |
||||
|
{ required: true, message: t('genderPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
age: [ |
||||
|
{ required: true, message: t('agePlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
birthday: [ |
||||
|
{ required: true, message: t('birthdayPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
emergency_contact: [ |
||||
|
{ required: true, message: t('emergencyContactPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
contact_phone: [ |
||||
|
{ required: true, message: t('contactPhonePlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
note: [ |
||||
|
{ required: true, message: t('notePlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
status: [ |
||||
|
{ required: true, message: t('statusPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
const emit = defineEmits(['complete']) |
||||
|
|
||||
|
/** |
||||
|
* 确认 |
||||
|
* @param formEl |
||||
|
*/ |
||||
|
const confirm = async (formEl: FormInstance | undefined) => { |
||||
|
if (loading.value || !formEl) return |
||||
|
let save = formData.id ? editStudent : addStudent |
||||
|
|
||||
|
await formEl.validate(async (valid) => { |
||||
|
if (valid) { |
||||
|
loading.value = true |
||||
|
|
||||
|
let data = formData |
||||
|
|
||||
|
save(data).then(res => { |
||||
|
loading.value = false |
||||
|
showDialog.value = false |
||||
|
emit('complete') |
||||
|
}).catch(err => { |
||||
|
loading.value = false |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
// 获取字典数据 |
||||
|
let genderList = ref([]) |
||||
|
const genderDictList = async () => { |
||||
|
genderList.value = await (await useDictionary('gender')).data.dictionary |
||||
|
} |
||||
|
genderDictList(); |
||||
|
watch(() => genderList.value, () => { formData.gender = genderList.value[0].value }) |
||||
|
let statusList = ref([]) |
||||
|
const statusDictList = async () => { |
||||
|
statusList.value = await (await useDictionary('xy_status')).data.dictionary |
||||
|
} |
||||
|
statusDictList(); |
||||
|
watch(() => statusList.value, () => { formData.status = statusList.value[0].value }) |
||||
|
|
||||
|
|
||||
|
const campusIdList = ref([] as any[]) |
||||
|
const setCampusIdList = async () => { |
||||
|
campusIdList.value = await (await getWithCampusList({})).data |
||||
|
} |
||||
|
setCampusIdList() |
||||
|
const classIdList = ref([] as any[]) |
||||
|
const setClassIdList = async () => { |
||||
|
classIdList.value = await (await getWithClassGradeList({})).data |
||||
|
} |
||||
|
setClassIdList() |
||||
|
const userIdList = ref([] as any[]) |
||||
|
const setUserIdList = async () => { |
||||
|
userIdList.value = await (await getWithMemberList({})).data |
||||
|
} |
||||
|
setUserIdList() |
||||
|
const setFormData = async (row: any = null) => { |
||||
|
Object.assign(formData, initialFormData) |
||||
|
loading.value = true |
||||
|
if(row){ |
||||
|
const data = await (await getStudentInfo(row.id)).data |
||||
|
if (data) Object.keys(formData).forEach((key: string) => { |
||||
|
if (data[key] != undefined) formData[key] = data[key] |
||||
|
}) |
||||
|
} |
||||
|
loading.value = false |
||||
|
} |
||||
|
|
||||
|
// 验证手机号格式 |
||||
|
const mobileVerify = (rule: any, value: any, callback: any) => { |
||||
|
if (value && !/^1[3-9]\d{9}$/.test(value)) { |
||||
|
callback(new Error(t('generateMobile'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 验证身份证号 |
||||
|
const idCardVerify = (rule: any, value: any, callback: any) => { |
||||
|
if (value && !/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(value)) { |
||||
|
callback(new Error(t('generateIdCard'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 验证邮箱号 |
||||
|
const emailVerify = (rule: any, value: any, callback: any) => { |
||||
|
if (value && !/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(value)) { |
||||
|
callback(new Error(t('generateEmail'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 验证请输入整数 |
||||
|
const numberVerify = (rule: any, value: any, callback: any) => { |
||||
|
if (!Number.isInteger(value)) { |
||||
|
callback(new Error(t('generateNumber'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
defineExpose({ |
||||
|
showDialog, |
||||
|
setFormData |
||||
|
}) |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped></style> |
||||
|
<style lang="scss"> |
||||
|
.diy-dialog-wrap .el-form-item__label{ |
||||
|
height: auto !important; |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,240 @@ |
|||||
|
<template> |
||||
|
<div class="main-container"> |
||||
|
<el-card class="box-card !border-none" shadow="never"> |
||||
|
|
||||
|
<div class="flex justify-between items-center"> |
||||
|
<span class="text-lg">{{pageName}}</span> |
||||
|
<el-button type="primary" @click="addEvent"> |
||||
|
{{ t('addStudent') }} |
||||
|
</el-button> |
||||
|
</div> |
||||
|
|
||||
|
<el-card class="box-card !border-none my-[10px] table-search-wrap" shadow="never"> |
||||
|
<el-form :inline="true" :model="studentTable.searchParam" ref="searchFormRef"> |
||||
|
|
||||
|
<el-form-item :label="t('campusId')" prop="campus_id"> |
||||
|
<el-select class="w-[280px]" v-model="studentTable.searchParam.campus_id" clearable :placeholder="t('campusIdPlaceholder')"> |
||||
|
<el-option |
||||
|
v-for="(item, index) in campusIdList" |
||||
|
:key="index" |
||||
|
:label="item['campus_name']" |
||||
|
:value="item['id']" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('name')" prop="name"> |
||||
|
<el-input v-model="studentTable.searchParam.name" :placeholder="t('namePlaceholder')" /> |
||||
|
</el-form-item> |
||||
|
<el-form-item :label="t('emergencyContact')" prop="emergency_contact"> |
||||
|
<el-input v-model="studentTable.searchParam.emergency_contact" :placeholder="t('emergencyContactPlaceholder')" /> |
||||
|
</el-form-item> |
||||
|
<el-form-item :label="t('contactPhone')" prop="contact_phone"> |
||||
|
<el-input v-model="studentTable.searchParam.contact_phone" :placeholder="t('contactPhonePlaceholder')" /> |
||||
|
</el-form-item> |
||||
|
<el-form-item :label="t('createdAt')" prop="created_at"> |
||||
|
<el-date-picker v-model="studentTable.searchParam.created_at" type="datetimerange" format="YYYY-MM-DD hh:mm:ss" |
||||
|
:start-placeholder="t('startDate')" :end-placeholder="t('endDate')" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item> |
||||
|
<el-button type="primary" @click="loadStudentList()">{{ t('search') }}</el-button> |
||||
|
<el-button @click="resetForm(searchFormRef)">{{ t('reset') }}</el-button> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
</el-card> |
||||
|
|
||||
|
<div class="mt-[10px]"> |
||||
|
<el-table :data="studentTable.data" size="large" v-loading="studentTable.loading"> |
||||
|
<template #empty> |
||||
|
<span>{{ !studentTable.loading ? t('emptyData') : '' }}</span> |
||||
|
</template> |
||||
|
<el-table-column prop="campus_id_name" :label="t('campusId')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column prop="class_id_name" :label="t('classId')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column prop="user_id_name" :label="t('userId')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column prop="name" :label="t('name')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column :label="t('gender')" min-width="180" align="center" :show-overflow-tooltip="true"> |
||||
|
<template #default="{ row }"> |
||||
|
<div v-for="(item, index) in genderList"> |
||||
|
<div v-if="item.value == row.gender">{{ item.name }}</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
|
||||
|
<el-table-column prop="age" :label="t('age')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column prop="emergency_contact" :label="t('emergencyContact')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column prop="contact_phone" :label="t('contactPhone')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column prop="note" :label="t('note')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column :label="t('status')" min-width="180" align="center" :show-overflow-tooltip="true"> |
||||
|
<template #default="{ row }"> |
||||
|
<div v-for="(item, index) in statusList"> |
||||
|
<div v-if="item.value == row.status">{{ item.name }}</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
|
||||
|
<el-table-column :label="t('operation')" fixed="right" min-width="120"> |
||||
|
<template #default="{ row }"> |
||||
|
<el-button type="primary" link @click="editEvent(row)">{{ t('edit') }}</el-button> |
||||
|
<el-button type="primary" link @click="deleteEvent(row.id)">{{ t('delete') }}</el-button> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
|
||||
|
</el-table> |
||||
|
<div class="mt-[16px] flex justify-end"> |
||||
|
<el-pagination v-model:current-page="studentTable.page" v-model:page-size="studentTable.limit" |
||||
|
layout="total, sizes, prev, pager, next, jumper" :total="studentTable.total" |
||||
|
@size-change="loadStudentList()" @current-change="loadStudentList" /> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<edit ref="editStudentDialog" @complete="loadStudentList" /> |
||||
|
</el-card> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts" setup> |
||||
|
import { reactive, ref, watch } from 'vue' |
||||
|
import { t } from '@/lang' |
||||
|
import { useDictionary } from '@/app/api/dict' |
||||
|
import { getStudentList, deleteStudent, getWithCampusList, getWithClassGradeList, getWithMemberList } from '@/app/api/student' |
||||
|
import { img } from '@/utils/common' |
||||
|
import { ElMessageBox,FormInstance } from 'element-plus' |
||||
|
import Edit from '@/app/views/student/components/student-edit.vue' |
||||
|
import { useRoute } from 'vue-router' |
||||
|
const route = useRoute() |
||||
|
const pageName = route.meta.title; |
||||
|
|
||||
|
let studentTable = reactive({ |
||||
|
page: 1, |
||||
|
limit: 10, |
||||
|
total: 0, |
||||
|
loading: true, |
||||
|
data: [], |
||||
|
searchParam:{ |
||||
|
"campus_id":"", |
||||
|
"name":"", |
||||
|
"emergency_contact":"", |
||||
|
"contact_phone":"", |
||||
|
"created_at":[] |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
const searchFormRef = ref<FormInstance>() |
||||
|
|
||||
|
// 选中数据 |
||||
|
const selectData = ref<any[]>([]) |
||||
|
|
||||
|
// 字典数据 |
||||
|
const genderList = ref([] as any[]) |
||||
|
const genderDictList = async () => { |
||||
|
genderList.value = await (await useDictionary('gender')).data.dictionary |
||||
|
} |
||||
|
genderDictList(); |
||||
|
const statusList = ref([] as any[]) |
||||
|
const statusDictList = async () => { |
||||
|
statusList.value = await (await useDictionary('xy_status')).data.dictionary |
||||
|
} |
||||
|
statusDictList(); |
||||
|
|
||||
|
/** |
||||
|
* 获取学员列表 |
||||
|
*/ |
||||
|
const loadStudentList = (page: number = 1) => { |
||||
|
studentTable.loading = true |
||||
|
studentTable.page = page |
||||
|
|
||||
|
getStudentList({ |
||||
|
page: studentTable.page, |
||||
|
limit: studentTable.limit, |
||||
|
...studentTable.searchParam |
||||
|
}).then(res => { |
||||
|
studentTable.loading = false |
||||
|
studentTable.data = res.data.data |
||||
|
studentTable.total = res.data.total |
||||
|
}).catch(() => { |
||||
|
studentTable.loading = false |
||||
|
}) |
||||
|
} |
||||
|
loadStudentList() |
||||
|
|
||||
|
const editStudentDialog: Record<string, any> | null = ref(null) |
||||
|
|
||||
|
/** |
||||
|
* 添加学员 |
||||
|
*/ |
||||
|
const addEvent = () => { |
||||
|
editStudentDialog.value.setFormData() |
||||
|
editStudentDialog.value.showDialog = true |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 编辑学员 |
||||
|
* @param data |
||||
|
*/ |
||||
|
const editEvent = (data: any) => { |
||||
|
editStudentDialog.value.setFormData(data) |
||||
|
editStudentDialog.value.showDialog = true |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除学员 |
||||
|
*/ |
||||
|
const deleteEvent = (id: number) => { |
||||
|
ElMessageBox.confirm(t('studentDeleteTips'), t('warning'), |
||||
|
{ |
||||
|
confirmButtonText: t('confirm'), |
||||
|
cancelButtonText: t('cancel'), |
||||
|
type: 'warning', |
||||
|
} |
||||
|
).then(() => { |
||||
|
deleteStudent(id).then(() => { |
||||
|
loadStudentList() |
||||
|
}).catch(() => { |
||||
|
}) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
const campusIdList = ref([]) |
||||
|
const setCampusIdList = async () => { |
||||
|
campusIdList.value = await (await getWithCampusList({})).data |
||||
|
} |
||||
|
setCampusIdList() |
||||
|
const classIdList = ref([]) |
||||
|
const setClassIdList = async () => { |
||||
|
classIdList.value = await (await getWithClassGradeList({})).data |
||||
|
} |
||||
|
setClassIdList() |
||||
|
const userIdList = ref([]) |
||||
|
const setUserIdList = async () => { |
||||
|
userIdList.value = await (await getWithMemberList({})).data |
||||
|
} |
||||
|
setUserIdList() |
||||
|
|
||||
|
const resetForm = (formEl: FormInstance | undefined) => { |
||||
|
if (!formEl) return |
||||
|
formEl.resetFields() |
||||
|
loadStudentList() |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
/* 多行超出隐藏 */ |
||||
|
.multi-hidden { |
||||
|
word-break: break-all; |
||||
|
text-overflow: ellipsis; |
||||
|
overflow: hidden; |
||||
|
display: -webkit-box; |
||||
|
-webkit-line-clamp: 2; |
||||
|
-webkit-box-orient: vertical; |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,121 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\adminapi\controller\student; |
||||
|
|
||||
|
use core\base\BaseAdminController; |
||||
|
use app\service\admin\student\StudentService; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 学员控制器 |
||||
|
* Class Student |
||||
|
* @package app\adminapi\controller\student |
||||
|
*/ |
||||
|
class Student extends BaseAdminController |
||||
|
{ |
||||
|
/** |
||||
|
* 获取学员列表 |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function lists(){ |
||||
|
$data = $this->request->params([ |
||||
|
["campus_id",""], |
||||
|
["name",""], |
||||
|
["emergency_contact",""], |
||||
|
["contact_phone",""], |
||||
|
["created_at",["",""]] |
||||
|
]); |
||||
|
return success((new StudentService())->getPage($data)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 学员详情 |
||||
|
* @param int $id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function info(int $id){ |
||||
|
return success((new StudentService())->getInfo($id)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 添加学员 |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function add(){ |
||||
|
$data = $this->request->params([ |
||||
|
["campus_id",0], |
||||
|
["class_id",0], |
||||
|
["user_id",0], |
||||
|
["name",""], |
||||
|
["gender",0], |
||||
|
["age",0.00], |
||||
|
["birthday","2025-05-23 17:31:39"], |
||||
|
["emergency_contact",""], |
||||
|
["contact_phone",""], |
||||
|
["note",""], |
||||
|
["status",0], |
||||
|
|
||||
|
]); |
||||
|
$this->validate($data, 'app\validate\student\Student.add'); |
||||
|
$id = (new StudentService())->add($data); |
||||
|
return success('ADD_SUCCESS', ['id' => $id]); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 学员编辑 |
||||
|
* @param $id 学员id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function edit(int $id){ |
||||
|
$data = $this->request->params([ |
||||
|
["campus_id",0], |
||||
|
["class_id",0], |
||||
|
["user_id",0], |
||||
|
["name",""], |
||||
|
["gender",0], |
||||
|
["age",0.00], |
||||
|
["birthday","2025-05-23 17:31:39"], |
||||
|
["emergency_contact",""], |
||||
|
["contact_phone",""], |
||||
|
["note",""], |
||||
|
["status",0], |
||||
|
|
||||
|
]); |
||||
|
$this->validate($data, 'app\validate\student\Student.edit'); |
||||
|
(new StudentService())->edit($id, $data); |
||||
|
return success('EDIT_SUCCESS'); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 学员删除 |
||||
|
* @param $id 学员id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function del(int $id){ |
||||
|
(new StudentService())->del($id); |
||||
|
return success('DELETE_SUCCESS'); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public function getCampusAll(){ |
||||
|
return success(( new StudentService())->getCampusAll()); |
||||
|
} |
||||
|
|
||||
|
public function getClassGradeAll(){ |
||||
|
return success(( new StudentService())->getClassGradeAll()); |
||||
|
} |
||||
|
|
||||
|
public function getMemberAll(){ |
||||
|
return success(( new StudentService())->getMemberAll()); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,44 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
use think\facade\Route; |
||||
|
|
||||
|
use app\adminapi\middleware\AdminCheckRole; |
||||
|
use app\adminapi\middleware\AdminCheckToken; |
||||
|
use app\adminapi\middleware\AdminLog; |
||||
|
|
||||
|
// USER_CODE_BEGIN -- student |
||||
|
|
||||
|
Route::group('student', function () { |
||||
|
|
||||
|
//学员列表 |
||||
|
Route::get('student', 'student.Student/lists'); |
||||
|
//学员详情 |
||||
|
Route::get('student/:id', 'student.Student/info'); |
||||
|
//添加学员 |
||||
|
Route::post('student', 'student.Student/add'); |
||||
|
//编辑学员 |
||||
|
Route::put('student/:id', 'student.Student/edit'); |
||||
|
//删除学员 |
||||
|
Route::delete('student/:id', 'student.Student/del'); |
||||
|
|
||||
|
Route::get('campus_all','student.Student/getCampusAll'); |
||||
|
|
||||
|
Route::get('class_grade_all','student.Student/getClassGradeAll'); |
||||
|
|
||||
|
Route::get('member_all','student.Student/getMemberAll'); |
||||
|
|
||||
|
})->middleware([ |
||||
|
AdminCheckToken::class, |
||||
|
AdminCheckRole::class, |
||||
|
AdminLog::class |
||||
|
]); |
||||
|
// USER_CODE_END -- student |
||||
@ -0,0 +1,117 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\service\admin\student; |
||||
|
|
||||
|
use app\model\student\Student; |
||||
|
use app\model\campus\Campus; |
||||
|
use app\model\class_grade\ClassGrade; |
||||
|
use app\model\member\Member; |
||||
|
|
||||
|
use core\base\BaseAdminService; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 学员服务层 |
||||
|
* Class StudentService |
||||
|
* @package app\service\admin\student |
||||
|
*/ |
||||
|
class StudentService extends BaseAdminService |
||||
|
{ |
||||
|
public function __construct() |
||||
|
{ |
||||
|
parent::__construct(); |
||||
|
$this->model = new Student(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取学员列表 |
||||
|
* @param array $where |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function getPage(array $where = []) |
||||
|
{ |
||||
|
$field = 'id,campus_id,class_id,user_id,name,gender,age,birthday,emergency_contact,contact_phone,note,status,created_at,updated_at,deleted_at'; |
||||
|
$order = 'id asc'; |
||||
|
|
||||
|
$search_model = $this->model->withSearch(["campus_id","name","emergency_contact","contact_phone","created_at"], $where)->with(['campus','classGrade','member'])->field($field)->order($order); |
||||
|
$list = $this->pageQuery($search_model); |
||||
|
return $list; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取学员信息 |
||||
|
* @param int $id |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function getInfo(int $id) |
||||
|
{ |
||||
|
$field = 'id,campus_id,class_id,user_id,name,gender,age,birthday,emergency_contact,contact_phone,note,status,created_at,updated_at,deleted_at'; |
||||
|
|
||||
|
$info = $this->model->field($field)->where([['id', "=", $id]])->with(['campus','classGrade','member'])->findOrEmpty()->toArray(); |
||||
|
return $info; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 添加学员 |
||||
|
* @param array $data |
||||
|
* @return mixed |
||||
|
*/ |
||||
|
public function add(array $data) |
||||
|
{ |
||||
|
$res = $this->model->create($data); |
||||
|
return $res->id; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 学员编辑 |
||||
|
* @param int $id |
||||
|
* @param array $data |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function edit(int $id, array $data) |
||||
|
{ |
||||
|
|
||||
|
$this->model->where([['id', '=', $id]])->update($data); |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除学员 |
||||
|
* @param int $id |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function del(int $id) |
||||
|
{ |
||||
|
$model = $this->model->where([['id', '=', $id]])->find(); |
||||
|
$res = $model->delete(); |
||||
|
return $res; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public function getCampusAll(){ |
||||
|
$campusModel = new Campus(); |
||||
|
return $campusModel->select()->toArray(); |
||||
|
} |
||||
|
|
||||
|
public function getClassGradeAll(){ |
||||
|
$classGradeModel = new ClassGrade(); |
||||
|
return $classGradeModel->select()->toArray(); |
||||
|
} |
||||
|
|
||||
|
public function getMemberAll(){ |
||||
|
$memberModel = new Member(); |
||||
|
return $memberModel->select()->toArray(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,43 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\validate\student; |
||||
|
use core\base\BaseValidate; |
||||
|
/** |
||||
|
* 学员验证器 |
||||
|
* Class Student |
||||
|
* @package addon\app\validate\student |
||||
|
*/ |
||||
|
class Student extends BaseValidate |
||||
|
{ |
||||
|
|
||||
|
protected $rule = [ |
||||
|
'class_id' => 'require', |
||||
|
'user_id' => 'require', |
||||
|
'name' => 'require', |
||||
|
'gender' => 'require', |
||||
|
'status' => 'require', |
||||
|
]; |
||||
|
|
||||
|
protected $message = [ |
||||
|
'class_id.require' => ['common_validate.require', ['class_id']], |
||||
|
'user_id.require' => ['common_validate.require', ['user_id']], |
||||
|
'name.require' => ['common_validate.require', ['name']], |
||||
|
'gender.require' => ['common_validate.require', ['gender']], |
||||
|
'status.require' => ['common_validate.require', ['status']], |
||||
|
]; |
||||
|
|
||||
|
protected $scene = [ |
||||
|
"add" => ['campus_id', 'class_id', 'user_id', 'name', 'gender', 'age', 'birthday', 'emergency_contact', 'contact_phone', 'note', 'status'], |
||||
|
"edit" => ['campus_id', 'class_id', 'user_id', 'name', 'gender', 'age', 'birthday', 'emergency_contact', 'contact_phone', 'note', 'status'] |
||||
|
]; |
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue