19 changed files with 1316 additions and 76 deletions
@ -0,0 +1,62 @@ |
|||||
|
import request from '@/utils/request' |
||||
|
|
||||
|
|
||||
|
|
||||
|
// USER_CODE_BEGIN -- assignment
|
||||
|
/** |
||||
|
* 获取作业管理列表 |
||||
|
* @param params |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function getAssignmentList(params: Record<string, any>) { |
||||
|
return request.get(`assignment/assignment`, {params}) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取作业管理详情 |
||||
|
* @param id 作业管理id |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function getAssignmentInfo(id: number) { |
||||
|
return request.get(`assignment/assignment/${id}`); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 添加作业管理 |
||||
|
* @param params |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function addAssignment(params: Record<string, any>) { |
||||
|
return request.post('assignment/assignment', params, { showErrorMessage: true, showSuccessMessage: true }) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 编辑作业管理 |
||||
|
* @param id |
||||
|
* @param params |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function editAssignment(params: Record<string, any>) { |
||||
|
return request.put(`assignment/assignment/${params.id}`, params, { showErrorMessage: true, showSuccessMessage: true }) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除作业管理 |
||||
|
* @param id |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function deleteAssignment(id: number) { |
||||
|
return request.delete(`assignment/assignment/${id}`, { showErrorMessage: true, showSuccessMessage: true }) |
||||
|
} |
||||
|
|
||||
|
export function getWithClassGradeList(params: Record<string,any>){ |
||||
|
return request.get('assignment/class_grade_all', {params}) |
||||
|
}export function getWithCourseList(params: Record<string,any>){ |
||||
|
return request.get('assignment/course_all', {params}) |
||||
|
}export function getWithPersonnelList(params: Record<string,any>){ |
||||
|
return request.get('assignment/personnel_all', {params}) |
||||
|
}export function getWithStudentList(params: Record<string,any>){ |
||||
|
return request.get('assignment/student_all', {params}) |
||||
|
} |
||||
|
|
||||
|
// USER_CODE_END -- assignment
|
||||
@ -0,0 +1,23 @@ |
|||||
|
{ |
||||
|
"classId":"班级", |
||||
|
"classIdPlaceholder":"全部", |
||||
|
"courseId":"课程", |
||||
|
"courseIdPlaceholder":"全部", |
||||
|
"personnelId":"老师", |
||||
|
"personnelIdPlaceholder":"全部", |
||||
|
"studentId":"学员", |
||||
|
"studentIdPlaceholder":"全部", |
||||
|
"description":"作业描述", |
||||
|
"descriptionPlaceholder":"请输入作业描述", |
||||
|
"contentType":"作业类型", |
||||
|
"contentTypePlaceholder":"请输入作业类型", |
||||
|
"contentText":"学生提交的作业内容", |
||||
|
"contentTextPlaceholder":"请输入学生提交的作业内容", |
||||
|
"status":"状态", |
||||
|
"statusPlaceholder":"请输入状态", |
||||
|
"addAssignment":"添加作业管理", |
||||
|
"updateAssignment":"编辑作业管理", |
||||
|
"assignmentDeleteTips":"确定要删除该数据吗?", |
||||
|
"startDate":"请选择开始时间", |
||||
|
"endDate":"请选择结束时间" |
||||
|
} |
||||
@ -0,0 +1,274 @@ |
|||||
|
<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('addAssignment') }} |
||||
|
</el-button> |
||||
|
</div> |
||||
|
|
||||
|
<el-card class="box-card !border-none my-[10px] table-search-wrap" shadow="never"> |
||||
|
<el-form :inline="true" :model="assignmentTable.searchParam" ref="searchFormRef"> |
||||
|
|
||||
|
<el-form-item :label="t('classId')" prop="class_id"> |
||||
|
<el-select class="w-[280px]" v-model="assignmentTable.searchParam.class_id" clearable :placeholder="t('classIdPlaceholder')"> |
||||
|
<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('courseId')" prop="course_id"> |
||||
|
<el-select class="w-[280px]" v-model="assignmentTable.searchParam.course_id" clearable :placeholder="t('courseIdPlaceholder')"> |
||||
|
<el-option |
||||
|
v-for="(item, index) in courseIdList" |
||||
|
:key="index" |
||||
|
:label="item['course_name']" |
||||
|
:value="item['id']" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
|
||||
|
<el-form-item :label="t('personnelId')" prop="personnel_id"> |
||||
|
<el-select class="w-[280px]" v-model="assignmentTable.searchParam.personnel_id" clearable :placeholder="t('personnelIdPlaceholder')"> |
||||
|
<el-option |
||||
|
v-for="(item, index) in personnelIdList" |
||||
|
:key="index" |
||||
|
:label="item['name']" |
||||
|
:value="item['id']" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
|
||||
|
<el-form-item :label="t('studentId')" prop="student_id"> |
||||
|
<el-select class="w-[280px]" v-model="assignmentTable.searchParam.student_id" clearable :placeholder="t('studentIdPlaceholder')"> |
||||
|
<el-option |
||||
|
v-for="(item, index) in studentIdList" |
||||
|
:key="index" |
||||
|
:label="item['name']" |
||||
|
:value="item['id']" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
|
||||
|
<el-form-item :label="t('status')" prop="status"> |
||||
|
<el-select class="w-[280px]" v-model="assignmentTable.searchParam.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="item.value" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item> |
||||
|
<el-button type="primary" @click="loadAssignmentList()">{{ 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="assignmentTable.data" size="large" v-loading="assignmentTable.loading"> |
||||
|
<template #empty> |
||||
|
<span>{{ !assignmentTable.loading ? t('emptyData') : '' }}</span> |
||||
|
</template> |
||||
|
<el-table-column prop="class_id_name" :label="t('classId')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column prop="course_id_name" :label="t('courseId')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column prop="personnel_id_name" :label="t('personnelId')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column prop="student_id_name" :label="t('studentId')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column prop="description" :label="t('description')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
<!-- |
||||
|
<el-table-column :label="t('contentType')" min-width="180" align="center" :show-overflow-tooltip="true"> |
||||
|
<template #default="{ row }"> |
||||
|
<div v-for="(item, index) in content_typeList"> |
||||
|
<div v-if="item.value == row.content_type">{{ item.name }}</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
</el-table-column> --> |
||||
|
|
||||
|
<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="assignmentTable.page" v-model:page-size="assignmentTable.limit" |
||||
|
layout="total, sizes, prev, pager, next, jumper" :total="assignmentTable.total" |
||||
|
@size-change="loadAssignmentList()" @current-change="loadAssignmentList" /> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<edit ref="editAssignmentDialog" @complete="loadAssignmentList" /> |
||||
|
</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 { getAssignmentList, deleteAssignment, getWithClassGradeList, getWithCourseList, getWithPersonnelList, getWithStudentList } from '@/app/api/assignment' |
||||
|
import { img } from '@/utils/common' |
||||
|
import { ElMessageBox,FormInstance } from 'element-plus' |
||||
|
import Edit from '@/app/views/assignment/components/assignment-edit.vue' |
||||
|
import { useRoute } from 'vue-router' |
||||
|
const route = useRoute() |
||||
|
const pageName = route.meta.title; |
||||
|
|
||||
|
let assignmentTable = reactive({ |
||||
|
page: 1, |
||||
|
limit: 10, |
||||
|
total: 0, |
||||
|
loading: true, |
||||
|
data: [], |
||||
|
searchParam:{ |
||||
|
"class_id":"", |
||||
|
"course_id":"", |
||||
|
"personnel_id":"", |
||||
|
"student_id":"", |
||||
|
"status":"" |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
const searchFormRef = ref<FormInstance>() |
||||
|
|
||||
|
// 选中数据 |
||||
|
const selectData = ref<any[]>([]) |
||||
|
|
||||
|
// 字典数据 |
||||
|
const content_typeList = ref([] as any[]) |
||||
|
const content_typeDictList = async () => { |
||||
|
content_typeList.value = await (await useDictionary('content_type')).data.dictionary |
||||
|
} |
||||
|
content_typeDictList(); |
||||
|
const statusList = ref([] as any[]) |
||||
|
const statusDictList = async () => { |
||||
|
statusList.value = await (await useDictionary('assignment_status')).data.dictionary |
||||
|
} |
||||
|
statusDictList(); |
||||
|
|
||||
|
/** |
||||
|
* 获取作业管理列表 |
||||
|
*/ |
||||
|
const loadAssignmentList = (page: number = 1) => { |
||||
|
assignmentTable.loading = true |
||||
|
assignmentTable.page = page |
||||
|
|
||||
|
getAssignmentList({ |
||||
|
page: assignmentTable.page, |
||||
|
limit: assignmentTable.limit, |
||||
|
...assignmentTable.searchParam |
||||
|
}).then(res => { |
||||
|
assignmentTable.loading = false |
||||
|
assignmentTable.data = res.data.data |
||||
|
assignmentTable.total = res.data.total |
||||
|
}).catch(() => { |
||||
|
assignmentTable.loading = false |
||||
|
}) |
||||
|
} |
||||
|
loadAssignmentList() |
||||
|
|
||||
|
const editAssignmentDialog: Record<string, any> | null = ref(null) |
||||
|
|
||||
|
/** |
||||
|
* 添加作业管理 |
||||
|
*/ |
||||
|
const addEvent = () => { |
||||
|
editAssignmentDialog.value.setFormData() |
||||
|
editAssignmentDialog.value.showDialog = true |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 编辑作业管理 |
||||
|
* @param data |
||||
|
*/ |
||||
|
const editEvent = (data: any) => { |
||||
|
editAssignmentDialog.value.setFormData(data) |
||||
|
editAssignmentDialog.value.showDialog = true |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除作业管理 |
||||
|
*/ |
||||
|
const deleteEvent = (id: number) => { |
||||
|
ElMessageBox.confirm(t('assignmentDeleteTips'), t('warning'), |
||||
|
{ |
||||
|
confirmButtonText: t('confirm'), |
||||
|
cancelButtonText: t('cancel'), |
||||
|
type: 'warning', |
||||
|
} |
||||
|
).then(() => { |
||||
|
deleteAssignment(id).then(() => { |
||||
|
loadAssignmentList() |
||||
|
}).catch(() => { |
||||
|
}) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
const classIdList = ref([]) |
||||
|
const setClassIdList = async () => { |
||||
|
classIdList.value = await (await getWithClassGradeList({})).data |
||||
|
} |
||||
|
setClassIdList() |
||||
|
const courseIdList = ref([]) |
||||
|
const setCourseIdList = async () => { |
||||
|
courseIdList.value = await (await getWithCourseList({})).data |
||||
|
} |
||||
|
setCourseIdList() |
||||
|
const personnelIdList = ref([]) |
||||
|
const setPersonnelIdList = async () => { |
||||
|
personnelIdList.value = await (await getWithPersonnelList({})).data |
||||
|
} |
||||
|
setPersonnelIdList() |
||||
|
const studentIdList = ref([]) |
||||
|
const setStudentIdList = async () => { |
||||
|
studentIdList.value = await (await getWithStudentList({})).data |
||||
|
} |
||||
|
setStudentIdList() |
||||
|
|
||||
|
const resetForm = (formEl: FormInstance | undefined) => { |
||||
|
if (!formEl) return |
||||
|
formEl.resetFields() |
||||
|
loadAssignmentList() |
||||
|
} |
||||
|
</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,291 @@ |
|||||
|
<template> |
||||
|
<el-dialog v-model="showDialog" :title="formData.id ? t('updateAssignment') : t('addAssignment')" 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('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('courseId')" prop="course_id"> |
||||
|
<el-select class="input-width" v-model="formData.course_id" clearable :placeholder="t('courseIdPlaceholder')"> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="(item, index) in courseIdList" |
||||
|
:key="index" |
||||
|
:label="item['course_name']" |
||||
|
:value="item['id']" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('personnelId')" prop="personnel_id"> |
||||
|
<el-select class="input-width" v-model="formData.personnel_id" clearable :placeholder="t('personnelIdPlaceholder')"> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="(item, index) in personnelIdList" |
||||
|
:key="index" |
||||
|
:label="item['name']" |
||||
|
:value="item['id']" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('studentId')" prop="student_id"> |
||||
|
<el-select class="input-width" v-model="formData.student_id" clearable :placeholder="t('studentIdPlaceholder')"> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="(item, index) in studentIdList" |
||||
|
:key="index" |
||||
|
:label="item['name']" |
||||
|
:value="Number(item['id'])" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('description')" > |
||||
|
<el-input v-model="formData.description" type="textarea" rows="4" clearable :placeholder="t('descriptionPlaceholder')" class="input-width"/> |
||||
|
</el-form-item> |
||||
|
<!-- <el-form-item :label="t('contentType')" prop="content_type"> |
||||
|
<el-select class="input-width" v-model="formData.content_type" clearable :placeholder="t('contentTypePlaceholder')"> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="(item, index) in content_typeList" |
||||
|
:key="index" |
||||
|
:label="item.name" |
||||
|
:value="item.value" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('contentText')" > |
||||
|
<el-input v-model="formData.content_text" clearable :placeholder="t('contentTextPlaceholder')" class="input-width" /> |
||||
|
</el-form-item> --> |
||||
|
|
||||
|
<!-- <el-form-item :label="t('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="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 { addAssignment, editAssignment, getAssignmentInfo, getWithClassGradeList, getWithCourseList, getWithPersonnelList, getWithStudentList } from '@/app/api/assignment' |
||||
|
|
||||
|
let showDialog = ref(false) |
||||
|
const loading = ref(false) |
||||
|
|
||||
|
/** |
||||
|
* 表单数据 |
||||
|
*/ |
||||
|
const initialFormData = { |
||||
|
id: '', |
||||
|
class_id: '', |
||||
|
course_id: '', |
||||
|
personnel_id: '', |
||||
|
student_id: '', |
||||
|
description: '', |
||||
|
content_type: '', |
||||
|
content_text: '', |
||||
|
status: '', |
||||
|
} |
||||
|
const formData: Record<string, any> = reactive({ ...initialFormData }) |
||||
|
|
||||
|
const formRef = ref<FormInstance>() |
||||
|
|
||||
|
// 表单验证规则 |
||||
|
const formRules = computed(() => { |
||||
|
return { |
||||
|
class_id: [ |
||||
|
{ required: true, message: t('classIdPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
course_id: [ |
||||
|
{ required: true, message: t('courseIdPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
personnel_id: [ |
||||
|
{ required: true, message: t('personnelIdPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
student_id: [ |
||||
|
{ required: true, message: t('studentIdPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
description: [ |
||||
|
{ required: true, message: t('descriptionPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
content_type: [ |
||||
|
{ required: true, message: t('contentTypePlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
content_text: [ |
||||
|
{ required: true, message: t('contentTextPlaceholder'), 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 ? editAssignment : addAssignment |
||||
|
|
||||
|
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 content_typeList = ref([]) |
||||
|
const content_typeDictList = async () => { |
||||
|
content_typeList.value = await (await useDictionary('content_type')).data.dictionary |
||||
|
} |
||||
|
content_typeDictList(); |
||||
|
watch(() => content_typeList.value, () => { formData.content_type = content_typeList.value[0].value }) |
||||
|
let statusList = ref([]) |
||||
|
const statusDictList = async () => { |
||||
|
statusList.value = await (await useDictionary('assignment_status')).data.dictionary |
||||
|
} |
||||
|
statusDictList(); |
||||
|
watch(() => statusList.value, () => { formData.status = statusList.value[0].value }) |
||||
|
|
||||
|
|
||||
|
const classIdList = ref([] as any[]) |
||||
|
const setClassIdList = async () => { |
||||
|
classIdList.value = await (await getWithClassGradeList({})).data |
||||
|
} |
||||
|
setClassIdList() |
||||
|
const courseIdList = ref([] as any[]) |
||||
|
const setCourseIdList = async () => { |
||||
|
courseIdList.value = await (await getWithCourseList({})).data |
||||
|
} |
||||
|
setCourseIdList() |
||||
|
const personnelIdList = ref([] as any[]) |
||||
|
const setPersonnelIdList = async () => { |
||||
|
personnelIdList.value = await (await getWithPersonnelList({})).data |
||||
|
} |
||||
|
setPersonnelIdList() |
||||
|
const studentIdList = ref([] as any[]) |
||||
|
const setStudentIdList = async () => { |
||||
|
studentIdList.value = await (await getWithStudentList({})).data |
||||
|
} |
||||
|
setStudentIdList() |
||||
|
const setFormData = async (row: any = null) => { |
||||
|
Object.assign(formData, initialFormData) |
||||
|
loading.value = true |
||||
|
if(row){ |
||||
|
const data = await (await getAssignmentInfo(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,8 @@ |
|||||
|
# 默认忽略的文件 |
||||
|
/shelf/ |
||||
|
/workspace.xml |
||||
|
# 基于编辑器的 HTTP 客户端请求 |
||||
|
/httpRequests/ |
||||
|
# Datasource local storage ignored files |
||||
|
/dataSources/ |
||||
|
/dataSources.local.xml |
||||
@ -0,0 +1,8 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<module type="WEB_MODULE" version="4"> |
||||
|
<component name="NewModuleRootManager"> |
||||
|
<content url="file://$MODULE_DIR$" /> |
||||
|
<orderEntry type="inheritedJdk" /> |
||||
|
<orderEntry type="sourceFolder" forTests="false" /> |
||||
|
</component> |
||||
|
</module> |
||||
@ -0,0 +1,8 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<project version="4"> |
||||
|
<component name="ProjectModuleManager"> |
||||
|
<modules> |
||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/app.iml" filepath="$PROJECT_DIR$/.idea/app.iml" /> |
||||
|
</modules> |
||||
|
</component> |
||||
|
</project> |
||||
@ -0,0 +1,22 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<project version="4"> |
||||
|
<component name="MessDetectorOptionsConfiguration"> |
||||
|
<option name="transferred" value="true" /> |
||||
|
</component> |
||||
|
<component name="PHPCSFixerOptionsConfiguration"> |
||||
|
<option name="transferred" value="true" /> |
||||
|
</component> |
||||
|
<component name="PHPCodeSnifferOptionsConfiguration"> |
||||
|
<option name="highlightLevel" value="WARNING" /> |
||||
|
<option name="transferred" value="true" /> |
||||
|
</component> |
||||
|
<component name="PhpProjectSharedConfiguration" php_language_level="8.0"> |
||||
|
<option name="suggestChangeDefaultLanguageLevel" value="false" /> |
||||
|
</component> |
||||
|
<component name="PhpStanOptionsConfiguration"> |
||||
|
<option name="transferred" value="true" /> |
||||
|
</component> |
||||
|
<component name="PsalmOptionsConfiguration"> |
||||
|
<option name="transferred" value="true" /> |
||||
|
</component> |
||||
|
</project> |
||||
@ -0,0 +1,6 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<project version="4"> |
||||
|
<component name="VcsDirectoryMappings"> |
||||
|
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" /> |
||||
|
</component> |
||||
|
</project> |
||||
@ -0,0 +1,119 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\adminapi\controller\assignment; |
||||
|
|
||||
|
use core\base\BaseAdminController; |
||||
|
use app\service\admin\assignment\AssignmentService; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 作业管理控制器 |
||||
|
* Class Assignment |
||||
|
* @package app\adminapi\controller\assignment |
||||
|
*/ |
||||
|
class Assignment extends BaseAdminController |
||||
|
{ |
||||
|
/** |
||||
|
* 获取作业管理列表 |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function lists(){ |
||||
|
$data = $this->request->params([ |
||||
|
["class_id",""], |
||||
|
["course_id",""], |
||||
|
["personnel_id",""], |
||||
|
["student_id",""], |
||||
|
["status",""] |
||||
|
]); |
||||
|
return success((new AssignmentService())->getPage($data)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 作业管理详情 |
||||
|
* @param int $id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function info(int $id){ |
||||
|
return success((new AssignmentService())->getInfo($id)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 添加作业管理 |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function add(){ |
||||
|
$data = $this->request->params([ |
||||
|
["class_id",0], |
||||
|
["course_id",0], |
||||
|
["personnel_id",0], |
||||
|
["student_id",""], |
||||
|
["description",""], |
||||
|
["content_type",""], |
||||
|
["content_text",""], |
||||
|
["status",0], |
||||
|
|
||||
|
]); |
||||
|
$this->validate($data, 'app\validate\assignment\Assignment.add'); |
||||
|
$id = (new AssignmentService())->add($data); |
||||
|
return success('ADD_SUCCESS', ['id' => $id]); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 作业管理编辑 |
||||
|
* @param $id 作业管理id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function edit(int $id){ |
||||
|
$data = $this->request->params([ |
||||
|
["class_id",0], |
||||
|
["course_id",0], |
||||
|
["personnel_id",0], |
||||
|
["student_id",""], |
||||
|
["description",""], |
||||
|
["content_type",""], |
||||
|
["content_text",""], |
||||
|
["status",0], |
||||
|
|
||||
|
]); |
||||
|
$this->validate($data, 'app\validate\assignment\Assignment.edit'); |
||||
|
(new AssignmentService())->edit($id, $data); |
||||
|
return success('EDIT_SUCCESS'); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 作业管理删除 |
||||
|
* @param $id 作业管理id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function del(int $id){ |
||||
|
(new AssignmentService())->del($id); |
||||
|
return success('DELETE_SUCCESS'); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public function getClassGradeAll(){ |
||||
|
return success(( new AssignmentService())->getClassGradeAll()); |
||||
|
} |
||||
|
|
||||
|
public function getCourseAll(){ |
||||
|
return success(( new AssignmentService())->getCourseAll()); |
||||
|
} |
||||
|
|
||||
|
public function getPersonnelAll(){ |
||||
|
return success(( new AssignmentService())->getPersonnelAll()); |
||||
|
} |
||||
|
|
||||
|
public function getStudentAll(){ |
||||
|
return success(( new AssignmentService())->getStudentAll()); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,46 @@ |
|||||
|
<?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 -- assignment |
||||
|
|
||||
|
Route::group('assignment', function () { |
||||
|
|
||||
|
//作业管理列表 |
||||
|
Route::get('assignment', 'assignment.Assignment/lists'); |
||||
|
//作业管理详情 |
||||
|
Route::get('assignment/:id', 'assignment.Assignment/info'); |
||||
|
//添加作业管理 |
||||
|
Route::post('assignment', 'assignment.Assignment/add'); |
||||
|
//编辑作业管理 |
||||
|
Route::put('assignment/:id', 'assignment.Assignment/edit'); |
||||
|
//删除作业管理 |
||||
|
Route::delete('assignment/:id', 'assignment.Assignment/del'); |
||||
|
|
||||
|
Route::get('class_grade_all','assignment.Assignment/getClassGradeAll'); |
||||
|
|
||||
|
Route::get('course_all','assignment.Assignment/getCourseAll'); |
||||
|
|
||||
|
Route::get('personnel_all','assignment.Assignment/getPersonnelAll'); |
||||
|
|
||||
|
Route::get('student_all','assignment.Assignment/getStudentAll'); |
||||
|
|
||||
|
})->middleware([ |
||||
|
AdminCheckToken::class, |
||||
|
AdminCheckRole::class, |
||||
|
AdminLog::class |
||||
|
]); |
||||
|
// USER_CODE_END -- assignment |
||||
@ -0,0 +1,123 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\service\admin\assignment; |
||||
|
|
||||
|
use app\model\assignment\Assignment; |
||||
|
use app\model\class_grade\ClassGrade; |
||||
|
use app\model\course\Course; |
||||
|
use app\model\personnel\Personnel; |
||||
|
use app\model\student\Student; |
||||
|
|
||||
|
use core\base\BaseAdminService; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 作业管理服务层 |
||||
|
* Class AssignmentService |
||||
|
* @package app\service\admin\assignment |
||||
|
*/ |
||||
|
class AssignmentService extends BaseAdminService |
||||
|
{ |
||||
|
public function __construct() |
||||
|
{ |
||||
|
parent::__construct(); |
||||
|
$this->model = new Assignment(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取作业管理列表 |
||||
|
* @param array $where |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function getPage(array $where = []) |
||||
|
{ |
||||
|
$field = 'id,type,class_id,course_id,personnel_id,student_id,description,content_type,content_text,status,create_time,update_time,deleted_at'; |
||||
|
$order = 'id desc'; |
||||
|
|
||||
|
$search_model = $this->model->withSearch(["class_id","course_id","personnel_id","student_id","status"], $where)->with(['classGrade','course','personnel','student'])->field($field)->order($order); |
||||
|
$list = $this->pageQuery($search_model); |
||||
|
return $list; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取作业管理信息 |
||||
|
* @param int $id |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function getInfo(int $id) |
||||
|
{ |
||||
|
$field = 'id,type,class_id,course_id,personnel_id,student_id,description,content_type,content_text,status,create_time,update_time,deleted_at'; |
||||
|
|
||||
|
$info = $this->model->field($field)->where([['id', "=", $id]])->with(['classGrade','course','personnel','student'])->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 getClassGradeAll(){ |
||||
|
$classGradeModel = new ClassGrade(); |
||||
|
return $classGradeModel->select()->toArray(); |
||||
|
} |
||||
|
|
||||
|
public function getCourseAll(){ |
||||
|
$courseModel = new Course(); |
||||
|
return $courseModel->select()->toArray(); |
||||
|
} |
||||
|
|
||||
|
public function getPersonnelAll(){ |
||||
|
$personnelModel = new Personnel(); |
||||
|
return $personnelModel->select()->toArray(); |
||||
|
} |
||||
|
|
||||
|
public function getStudentAll(){ |
||||
|
$studentModel = new Student(); |
||||
|
return $studentModel->select()->toArray(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,43 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\validate\assignment; |
||||
|
use core\base\BaseValidate; |
||||
|
/** |
||||
|
* 作业管理验证器 |
||||
|
* Class Assignment |
||||
|
* @package addon\app\validate\assignment |
||||
|
*/ |
||||
|
class Assignment extends BaseValidate |
||||
|
{ |
||||
|
|
||||
|
protected $rule = [ |
||||
|
'class_id' => 'require', |
||||
|
'course_id' => 'require', |
||||
|
'personnel_id' => 'require', |
||||
|
'student_id' => 'require', |
||||
|
'content_type' => 'require', |
||||
|
]; |
||||
|
|
||||
|
protected $message = [ |
||||
|
'class_id.require' => ['common_validate.require', ['class_id']], |
||||
|
'course_id.require' => ['common_validate.require', ['course_id']], |
||||
|
'personnel_id.require' => ['common_validate.require', ['personnel_id']], |
||||
|
'student_id.require' => ['common_validate.require', ['student_id']], |
||||
|
'content_type.require' => ['common_validate.require', ['content_type']], |
||||
|
]; |
||||
|
|
||||
|
protected $scene = [ |
||||
|
"add" => ['class_id', 'course_id', 'personnel_id', 'student_id', 'description', 'content_type', 'content_text', 'status'], |
||||
|
"edit" => ['class_id', 'course_id', 'personnel_id', 'student_id', 'description', 'content_type', 'content_text', 'status'] |
||||
|
]; |
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue