89 changed files with 5624 additions and 1712 deletions
@ -0,0 +1,58 @@ |
|||||
|
import request from '@/utils/request' |
||||
|
|
||||
|
// USER_CODE_BEGIN -- class_resources_rel
|
||||
|
/** |
||||
|
* 获取班级和资源列表 |
||||
|
* @param params |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function getClassResourcesRelList(params: Record<string, any>) { |
||||
|
return request.get(`class_resources_rel/class_resources_rel`, {params}) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取班级和资源详情 |
||||
|
* @param id 班级和资源id |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function getClassResourcesRelInfo(id: number) { |
||||
|
return request.get(`class_resources_rel/class_resources_rel/${id}`); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 添加班级和资源 |
||||
|
* @param params |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function addClassResourcesRel(params: Record<string, any>) { |
||||
|
return request.post('class_resources_rel/class_resources_rel', params, { showErrorMessage: true, showSuccessMessage: true }) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 编辑班级和资源 |
||||
|
* @param id |
||||
|
* @param params |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function editClassResourcesRel(params: Record<string, any>) { |
||||
|
return request.put(`class_resources_rel/class_resources_rel/${params.id}`, params, { showErrorMessage: true, showSuccessMessage: true }) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除班级和资源 |
||||
|
* @param id |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function deleteClassResourcesRel(id: number) { |
||||
|
return request.delete(`class_resources_rel/class_resources_rel/${id}`, { showErrorMessage: true, showSuccessMessage: true }) |
||||
|
} |
||||
|
|
||||
|
export function getWithClassGradeList(params: Record<string,any>){ |
||||
|
return request.get('class_resources_rel/class_grade_all', {params}) |
||||
|
}export function getWithCustomerResourcesList(params: Record<string,any>){ |
||||
|
return request.get('class_resources_rel/customer_resources_all', {params}) |
||||
|
}export function getWithCampusList(params: Record<string,any>){ |
||||
|
return request.get('class_resources_rel/campus_all', {params}) |
||||
|
} |
||||
|
|
||||
|
// USER_CODE_END -- class_resources_rel
|
||||
@ -0,0 +1,17 @@ |
|||||
|
{ |
||||
|
"classId":"班级", |
||||
|
"classIdPlaceholder":"请输入班级", |
||||
|
"resourceId":"资源", |
||||
|
"resourceIdPlaceholder":"请输入资源", |
||||
|
"campusId":"校区", |
||||
|
"campusIdPlaceholder":"请输入校区", |
||||
|
"sourceType":"数据资源类型", |
||||
|
"sourceTypePlaceholder":"请输入数据资源类型", |
||||
|
"status":"状态", |
||||
|
"statusPlaceholder":"请输入状态", |
||||
|
"addClassResourcesRel":"添加班级和资源", |
||||
|
"updateClassResourcesRel":"编辑班级和资源", |
||||
|
"classResourcesRelDeleteTips":"确定要删除该数据吗?", |
||||
|
"startDate":"请选择开始时间", |
||||
|
"endDate":"请选择结束时间" |
||||
|
} |
||||
@ -1,29 +1,37 @@ |
|||||
{ |
{ |
||||
"id": "课程安排编号", |
"id": "课程安排编号", |
||||
"idPlaceholder": "请输入课程安排编号", |
"idPlaceholder": "请输入课程安排编号", |
||||
"campusId": "校区ID", |
"campusId": "校区", |
||||
"campusIdPlaceholder": "请输入校区ID", |
"campusIdPlaceholder": "请选择校区", |
||||
"venueId": "场地ID", |
"venueId": "场地", |
||||
"venueIdPlaceholder": "请输入场地ID", |
"venueIdPlaceholder": "请选择场地", |
||||
"courseDate": "上课日期", |
"courseDate": "上课日期", |
||||
"courseDatePlaceholder": "请输入上课日期", |
"courseDatePlaceholder": "请选择上课日期", |
||||
"timeSlot": "上课时段", |
"timeSlot": "上课时段", |
||||
"timeSlotPlaceholder": "请输入上课时段", |
"timeSlotPlaceholder": "请选择上课时段", |
||||
"courseId": "课程ID", |
"courseId": "课程", |
||||
"courseIdPlaceholder": "请输入课程ID", |
"courseIdPlaceholder": "请选择课程", |
||||
"coachId": "上课教练ID", |
"coachId": "上课教练", |
||||
"coachIdPlaceholder": "请输入上课教练ID", |
"coachIdPlaceholder": "请选择上课教练", |
||||
"participants": "参与人员列表", |
"participants": "参与人员", |
||||
"participantsPlaceholder": "请输入参与人员列表", |
"participantsPlaceholder": "请选择参与人员", |
||||
"studentIds": "上课学生列表", |
"studentIds": "参与学生", |
||||
"studentIdsPlaceholder": "请输入上课学生列表", |
"studentIdsPlaceholder": "请选择参与学生", |
||||
"availableCapacity": "根据场地容量判断的可安排学员位置数量", |
"availableCapacity": "根据场地容量判断的可安排学员位置数量", |
||||
"availableCapacityPlaceholder": "请输入根据场地容量判断的可安排学员位置数量", |
"availableCapacityPlaceholder": "请输入根据场地容量判断的可安排学员位置数量", |
||||
"status": "课程状态:", |
"status": "课程状态", |
||||
"statusPlaceholder": "请输入课程状态:", |
"statusPlaceholder": "请选择课程状态", |
||||
"addCourseSchedule": "添加课程安排", |
"addCourseSchedule": "添加课程安排", |
||||
"updateCourseSchedule": "编辑课程安排", |
"updateCourseSchedule": "编辑课程安排", |
||||
"courseScheduleDeleteTips": "确定要删除该数据吗?", |
"courseScheduleDeleteTips": "确定要删除该数据吗?", |
||||
"startDate": "请选择开始时间", |
"startDate": "请选择开始时间", |
||||
"endDate": "请选择结束时间" |
"endDate": "请选择结束时间", |
||||
|
"pending": "待开始", |
||||
|
"upcoming": "即将开始", |
||||
|
"ongoing": "进行中", |
||||
|
"completed": "已结束", |
||||
|
"autoSchedule": "自动排课", |
||||
|
"autoSchedulePlaceholder": "请选择是否自动排课", |
||||
|
"yes": "是", |
||||
|
"no": "否" |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,201 @@ |
|||||
|
<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('addClassResourcesRel') }} |
||||
|
</el-button> |
||||
|
</div> |
||||
|
|
||||
|
<el-card class="box-card !border-none my-[10px] table-search-wrap" shadow="never"> |
||||
|
<el-form :inline="true" :model="classResourcesRelTable.searchParam" ref="searchFormRef"> |
||||
|
|
||||
|
<el-form-item> |
||||
|
<el-button type="primary" @click="loadClassResourcesRelList()">{{ 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="classResourcesRelTable.data" size="large" v-loading="classResourcesRelTable.loading"> |
||||
|
<template #empty> |
||||
|
<span>{{ !classResourcesRelTable.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="resource_id_name" :label="t('resourceId')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column prop="campus_id_name" :label="t('campusId')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column :label="t('sourceType')" min-width="180" align="center" :show-overflow-tooltip="true"> |
||||
|
<template #default="{ row }"> |
||||
|
<div v-for="(item, index) in source_typeList"> |
||||
|
<div v-if="item.value == row.source_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="classResourcesRelTable.page" v-model:page-size="classResourcesRelTable.limit" |
||||
|
layout="total, sizes, prev, pager, next, jumper" :total="classResourcesRelTable.total" |
||||
|
@size-change="loadClassResourcesRelList()" @current-change="loadClassResourcesRelList" /> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<edit ref="editClassResourcesRelDialog" @complete="loadClassResourcesRelList" /> |
||||
|
</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 { getClassResourcesRelList, deleteClassResourcesRel, getWithClassGradeList, getWithCustomerResourcesList, getWithCampusList } from '@/app/api/class_resources_rel' |
||||
|
import { img } from '@/utils/common' |
||||
|
import { ElMessageBox,FormInstance } from 'element-plus' |
||||
|
import Edit from '@/app/views/class_resources_rel/components/class-resources-rel-edit.vue' |
||||
|
import { useRoute } from 'vue-router' |
||||
|
const route = useRoute() |
||||
|
const pageName = route.meta.title; |
||||
|
|
||||
|
let classResourcesRelTable = reactive({ |
||||
|
page: 1, |
||||
|
limit: 10, |
||||
|
total: 0, |
||||
|
loading: true, |
||||
|
data: [], |
||||
|
searchParam:{ |
||||
|
|
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
const searchFormRef = ref<FormInstance>() |
||||
|
|
||||
|
// 选中数据 |
||||
|
const selectData = ref<any[]>([]) |
||||
|
|
||||
|
// 字典数据 |
||||
|
const source_typeList = ref([] as any[]) |
||||
|
const source_typeDictList = async () => { |
||||
|
source_typeList.value = await (await useDictionary('sj_type')).data.dictionary |
||||
|
} |
||||
|
source_typeDictList(); |
||||
|
const statusList = ref([] as any[]) |
||||
|
const statusDictList = async () => { |
||||
|
statusList.value = await (await useDictionary('student_status')).data.dictionary |
||||
|
} |
||||
|
statusDictList(); |
||||
|
|
||||
|
/** |
||||
|
* 获取班级和资源列表 |
||||
|
*/ |
||||
|
const loadClassResourcesRelList = (page: number = 1) => { |
||||
|
classResourcesRelTable.loading = true |
||||
|
classResourcesRelTable.page = page |
||||
|
|
||||
|
getClassResourcesRelList({ |
||||
|
page: classResourcesRelTable.page, |
||||
|
limit: classResourcesRelTable.limit, |
||||
|
...classResourcesRelTable.searchParam |
||||
|
}).then(res => { |
||||
|
classResourcesRelTable.loading = false |
||||
|
classResourcesRelTable.data = res.data.data |
||||
|
classResourcesRelTable.total = res.data.total |
||||
|
}).catch(() => { |
||||
|
classResourcesRelTable.loading = false |
||||
|
}) |
||||
|
} |
||||
|
loadClassResourcesRelList() |
||||
|
|
||||
|
const editClassResourcesRelDialog: Record<string, any> | null = ref(null) |
||||
|
|
||||
|
/** |
||||
|
* 添加班级和资源 |
||||
|
*/ |
||||
|
const addEvent = () => { |
||||
|
editClassResourcesRelDialog.value.setFormData() |
||||
|
editClassResourcesRelDialog.value.showDialog = true |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 编辑班级和资源 |
||||
|
* @param data |
||||
|
*/ |
||||
|
const editEvent = (data: any) => { |
||||
|
editClassResourcesRelDialog.value.setFormData(data) |
||||
|
editClassResourcesRelDialog.value.showDialog = true |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除班级和资源 |
||||
|
*/ |
||||
|
const deleteEvent = (id: number) => { |
||||
|
ElMessageBox.confirm(t('classResourcesRelDeleteTips'), t('warning'), |
||||
|
{ |
||||
|
confirmButtonText: t('confirm'), |
||||
|
cancelButtonText: t('cancel'), |
||||
|
type: 'warning', |
||||
|
} |
||||
|
).then(() => { |
||||
|
deleteClassResourcesRel(id).then(() => { |
||||
|
loadClassResourcesRelList() |
||||
|
}).catch(() => { |
||||
|
}) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
const classIdList = ref([]) |
||||
|
const setClassIdList = async () => { |
||||
|
classIdList.value = await (await getWithClassGradeList({})).data |
||||
|
} |
||||
|
setClassIdList() |
||||
|
const resourceIdList = ref([]) |
||||
|
const setResourceIdList = async () => { |
||||
|
resourceIdList.value = await (await getWithCustomerResourcesList({})).data |
||||
|
} |
||||
|
setResourceIdList() |
||||
|
const campusIdList = ref([]) |
||||
|
const setCampusIdList = async () => { |
||||
|
campusIdList.value = await (await getWithCampusList({})).data |
||||
|
} |
||||
|
setCampusIdList() |
||||
|
|
||||
|
const resetForm = (formEl: FormInstance | undefined) => { |
||||
|
if (!formEl) return |
||||
|
formEl.resetFields() |
||||
|
loadClassResourcesRelList() |
||||
|
} |
||||
|
</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,251 @@ |
|||||
|
<template> |
||||
|
<el-dialog v-model="showDialog" title="班级分配" 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="资源" > |
||||
|
<el-select class="input-width" v-model="formData.resource_id" clearable :placeholder="t('resourceIdPlaceholder')"> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="(item, index) in resourceIdList" |
||||
|
:key="index" |
||||
|
:label="item['name']" |
||||
|
:value="item['id']" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> --> |
||||
|
|
||||
|
|
||||
|
|
||||
|
<el-form-item label="数据资源类型" > |
||||
|
<el-select class="input-width" v-model="formData.source_type" clearable placeholder="请选择数据资源类型"> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="(item, index) in source_typeList" |
||||
|
:key="index" |
||||
|
:label="item.name" |
||||
|
:value="item.value" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</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="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 { addClassResourcesRel, editClassResourcesRel, getClassResourcesRelInfo, getWithClassGradeList, getWithCustomerResourcesList, getWithCampusList } from '@/app/api/class_resources_rel' |
||||
|
|
||||
|
let showDialog = ref(false) |
||||
|
const loading = ref(false) |
||||
|
|
||||
|
/** |
||||
|
* 表单数据 |
||||
|
*/ |
||||
|
const initialFormData = { |
||||
|
id: '', |
||||
|
class_id: '', |
||||
|
// resource_id: '', |
||||
|
campus_id: '', |
||||
|
source_type: '', |
||||
|
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' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
resource_id: [ |
||||
|
{ required: true, message: t('resourceIdPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
campus_id: [ |
||||
|
{ required: true, message: t('campusIdPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
source_type: [ |
||||
|
{ required: true, message: t('sourceTypePlaceholder'), 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 ? editClassResourcesRel : addClassResourcesRel |
||||
|
|
||||
|
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 source_typeList = ref([]) |
||||
|
const source_typeDictList = async () => { |
||||
|
source_typeList.value = await (await useDictionary('sj_type')).data.dictionary |
||||
|
} |
||||
|
source_typeDictList(); |
||||
|
watch(() => source_typeList.value, () => { formData.source_type = source_typeList.value[0].value }) |
||||
|
let statusList = ref([]) |
||||
|
const statusDictList = async () => { |
||||
|
statusList.value = await (await useDictionary('student_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 resourceIdList = ref([] as any[]) |
||||
|
const setResourceIdList = async () => { |
||||
|
resourceIdList.value = await (await getWithCustomerResourcesList({})).data |
||||
|
} |
||||
|
setResourceIdList() |
||||
|
const campusIdList = ref([] as any[]) |
||||
|
const setCampusIdList = async () => { |
||||
|
campusIdList.value = await (await getWithCampusList({})).data |
||||
|
} |
||||
|
setCampusIdList() |
||||
|
const setFormData = async (row: any = null) => { |
||||
|
Object.assign(formData, initialFormData) |
||||
|
loading.value = true |
||||
|
if(row){ |
||||
|
const data = await (await getClassResourcesRelInfo(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,149 @@ |
|||||
|
<template> |
||||
|
<el-dialog |
||||
|
v-model="showDialog" |
||||
|
:title="formData.id ? t('updateCourse') : t('addCourse')" |
||||
|
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="合同" prop="contract_id"> |
||||
|
<el-select |
||||
|
class="input-width" |
||||
|
v-model="formData.contract_id" |
||||
|
placeholder="请选择合同" |
||||
|
> |
||||
|
<el-option |
||||
|
v-for="(item, index) in contractList" |
||||
|
:key="index" |
||||
|
:label="item.contract_name" |
||||
|
:value="item.id" |
||||
|
/> |
||||
|
</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 { addCourse, editCourse, getCourseInfo,contractAll } from '@/app/api/course' |
||||
|
|
||||
|
let showDialog = ref(false) |
||||
|
const loading = ref(false) |
||||
|
|
||||
|
|
||||
|
const contractList : any = ref(null) |
||||
|
// 获取全部标签 |
||||
|
const getContractAll = async () => { |
||||
|
contractList.value = await (await contractAll()).data |
||||
|
} |
||||
|
getContractAll() |
||||
|
|
||||
|
/** |
||||
|
* 表单数据 |
||||
|
*/ |
||||
|
const initialFormData = { |
||||
|
id: '', |
||||
|
course_name: '', |
||||
|
course_type: '', |
||||
|
duration: '', |
||||
|
session_count: '', |
||||
|
single_session_count: '', |
||||
|
price: '', |
||||
|
internal_reminder: '', |
||||
|
customer_reminder: '', |
||||
|
remarks: '', |
||||
|
contract_id: '', |
||||
|
} |
||||
|
const formData: Record<string, any> = reactive({ ...initialFormData }) |
||||
|
|
||||
|
const formRef = ref<FormInstance>() |
||||
|
|
||||
|
// 表单验证规则 |
||||
|
const formRules = computed(() => { |
||||
|
return { |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
|
||||
|
const emit = defineEmits(['complete']) |
||||
|
|
||||
|
/** |
||||
|
* 确认 |
||||
|
* @param formEl |
||||
|
*/ |
||||
|
const confirm = async (formEl: FormInstance | undefined) => { |
||||
|
if (loading.value || !formEl) return |
||||
|
let save = formData.id ? editCourse : addCourse |
||||
|
|
||||
|
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 |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
// 获取字典数据 |
||||
|
|
||||
|
const setFormData = async (row: any = null) => { |
||||
|
Object.assign(formData, initialFormData) |
||||
|
loading.value = true |
||||
|
if (row) { |
||||
|
const data = await (await getCourseInfo(row.id)).data |
||||
|
if (data) |
||||
|
Object.keys(formData).forEach((key: string) => { |
||||
|
if (data[key] != undefined) formData[key] = data[key] |
||||
|
}) |
||||
|
} |
||||
|
loading.value = false |
||||
|
} |
||||
|
|
||||
|
|
||||
|
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,228 @@ |
|||||
|
<template> |
||||
|
<div class="main-container"> |
||||
|
<el-card class="box-card !border-none" shadow="never" v-loading="loading"> |
||||
|
<div class="flex justify-between items-center"> |
||||
|
<span class="text-lg">{{ pageName }}</span> |
||||
|
<el-button type="primary" @click="addStage"> 新增阶段 </el-button> |
||||
|
</div> |
||||
|
</el-card> |
||||
|
|
||||
|
<el-card class="box-card !border-none" shadow="never"> |
||||
|
<div |
||||
|
class="flex items-center justify-between p-[10px] table-item-border bg" |
||||
|
> |
||||
|
<span class="text-base w-[230px]">阶段名称</span> |
||||
|
<span class="text-base w-[110px] text-center">底薪</span> |
||||
|
</div> |
||||
|
|
||||
|
<el-collapse v-model="activeNames" accordion> |
||||
|
<el-collapse-item |
||||
|
v-for="(stage, index) in stages" |
||||
|
:key="stage.id" |
||||
|
:name="stage.id" |
||||
|
> |
||||
|
<template #title> |
||||
|
<div class="collapse-title"> |
||||
|
<span class="title-name">{{ stage.name }}</span> |
||||
|
<span class="arrow">{{ stage.price }} 元</span> |
||||
|
<!-- <span class="arrow">></span> --> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<el-form label-width="100px" style="margin-bottom: 10px"> |
||||
|
<el-form-item label="阶段名称"> |
||||
|
<el-input v-model="stage.name" placeholder="请输入阶段名称" /> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
|
||||
|
<el-form label-width="100px" style="margin-bottom: 10px"> |
||||
|
<el-form-item label="阶段底薪"> |
||||
|
<el-input v-model="stage.price" placeholder="请输入阶段底薪" /> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
|
||||
|
<el-button type="success" size="small" @click="addRule(stage)" |
||||
|
>新增规则</el-button |
||||
|
> |
||||
|
|
||||
|
<el-table :data="stage.rules" border style="margin-top: 10px"> |
||||
|
<el-table-column prop="renewal_standard_min" label="续费上限"> |
||||
|
<template #default="{ row }"> |
||||
|
<el-input |
||||
|
v-model="row.renewal_standard_min" |
||||
|
placeholder="请输入续费上限" |
||||
|
/> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
|
||||
|
<el-table-column prop="renewal_standard_max" label="续费下限"> |
||||
|
<template #default="{ row }"> |
||||
|
<el-input |
||||
|
v-model="row.renewal_standard_max" |
||||
|
placeholder="请输入续费下限" |
||||
|
/> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
|
||||
|
<el-table-column prop="renewal_commission" label="续费提成"> |
||||
|
<template #default="{ row }"> |
||||
|
<el-input v-model="row.renewal_commission" placeholder="%" /> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
|
||||
|
<el-table-column prop="new_count_min" label="新单成交数上限"> |
||||
|
<template #default="{ row }"> |
||||
|
<el-input v-model="row.new_count_min" /> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
|
||||
|
<el-table-column prop="new_count_max" label="新单成交数下限"> |
||||
|
<template #default="{ row }"> |
||||
|
<el-input v-model="row.new_count_max" /> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
|
||||
|
<el-table-column prop="new_move_5" label="新招(5+1)x3"> |
||||
|
<template #default="{ row }"> |
||||
|
<el-input v-model="row.new_move_5" /> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column prop="new_move_7" label="新招(7+1)x3"> |
||||
|
<template #default="{ row }"> |
||||
|
<el-input v-model="row.new_move_7" /> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column label="操作" width="100"> |
||||
|
<template #default="{ $index }"> |
||||
|
<el-button |
||||
|
type="danger" |
||||
|
size="small" |
||||
|
@click="removeRule(stage, $index)" |
||||
|
>删除</el-button |
||||
|
> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
</el-table> |
||||
|
|
||||
|
<el-button |
||||
|
type="danger" |
||||
|
size="small" |
||||
|
style="margin-top: 10px" |
||||
|
@click="removeStage(index)" |
||||
|
>删除该阶段</el-button |
||||
|
> |
||||
|
</el-collapse-item> |
||||
|
</el-collapse> |
||||
|
|
||||
|
<div style="text-align: right; margin-top: 20px"> |
||||
|
<el-button type="primary" @click="onSave">提交保存</el-button> |
||||
|
</div> |
||||
|
</el-card> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts" setup> |
||||
|
import { jlyjConfig, getJlyjConfig } from '@/app/api/sys' |
||||
|
import { reactive, ref } from 'vue' |
||||
|
import { ElMessage } from 'element-plus' |
||||
|
import { useRoute } from 'vue-router' |
||||
|
const route = useRoute() |
||||
|
const pageName = route.meta.title |
||||
|
|
||||
|
const loading = ref(true) |
||||
|
const stages = ref([]) |
||||
|
const activeNames = ref(null) |
||||
|
|
||||
|
function addStage() { |
||||
|
const newStage = { |
||||
|
name: '默认阶段', |
||||
|
price: 0, |
||||
|
rules: [ |
||||
|
{ |
||||
|
renewal_standard_min: '', |
||||
|
renewal_standard_max: '', |
||||
|
renewal_commission: '', |
||||
|
new_count_min: '', |
||||
|
new_count_max: '', |
||||
|
new_move_5: '', |
||||
|
new_move_7: '', |
||||
|
}, |
||||
|
], |
||||
|
} |
||||
|
stages.value.push(newStage) |
||||
|
activeNames.value = newStage.name |
||||
|
} |
||||
|
|
||||
|
function removeStage(index) { |
||||
|
stages.value.splice(index, 1) |
||||
|
} |
||||
|
|
||||
|
function addRule(stage) { |
||||
|
stage.rules.push({ |
||||
|
renewal_standard_min: '', |
||||
|
renewal_standard_max: '', |
||||
|
renewal_commission: '', |
||||
|
new_count_min: '', |
||||
|
new_count_max: '', |
||||
|
new_move_5: '', |
||||
|
new_move_7: '', |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
function removeRule(stage, ruleIndex) { |
||||
|
if (stage.rules.length === 1) { |
||||
|
ElMessage.warning('至少保留一条规则') |
||||
|
return |
||||
|
} |
||||
|
stage.rules.splice(ruleIndex, 1) |
||||
|
} |
||||
|
|
||||
|
const setFormData = async () => { |
||||
|
const data = await (await getJlyjConfig()).data |
||||
|
stages.value = data |
||||
|
loading.value = false |
||||
|
} |
||||
|
|
||||
|
setFormData() |
||||
|
|
||||
|
const onSave = async () => { |
||||
|
jlyjConfig(stages.value) |
||||
|
.then(() => { |
||||
|
loading.value = true |
||||
|
setFormData() |
||||
|
}) |
||||
|
.catch(() => { |
||||
|
loading.value = false |
||||
|
}) |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.collapse-title { |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
justify-content: space-between; |
||||
|
width: 100%; |
||||
|
font-size: 14px; |
||||
|
font-weight: 500; |
||||
|
padding-right: 10px; |
||||
|
color: #333; |
||||
|
padding: 10px; |
||||
|
} |
||||
|
|
||||
|
.title-name { |
||||
|
width: 230px; |
||||
|
} |
||||
|
|
||||
|
.title-salary { |
||||
|
width: 110px; |
||||
|
text-align: center; |
||||
|
color: #7438d5; |
||||
|
} |
||||
|
|
||||
|
.arrow { |
||||
|
margin-left: auto; |
||||
|
color: #999; |
||||
|
font-size: 14px; |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,188 @@ |
|||||
|
<template> |
||||
|
<div class="main-container"> |
||||
|
<!-- 实时概况 --> |
||||
|
<el-card shadow="never" class="!border-none"> |
||||
|
|
||||
|
<template #header> |
||||
|
<span class="text-lg font-extrabold mr-[10px]">统计概括</span> |
||||
|
<span class="text-sm text-[#a19f98]">查看校区、员工、资源和学员的实时数据</span> |
||||
|
</template> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="6"> |
||||
|
<div class="text-sm text-[#a19f98] leading-8 "> |
||||
|
<el-statistic :value="info.campus_count"> |
||||
|
<template #title> |
||||
|
<div style="display: inline-flex; align-items: center"> |
||||
|
<span class="mr-[5px]">校区数量</span> |
||||
|
</div> |
||||
|
</template> |
||||
|
</el-statistic> |
||||
|
<div class="text-sm text-[#a19f98] leading-8"> |
||||
|
|
||||
|
</div> |
||||
|
</div> |
||||
|
</el-col> |
||||
|
|
||||
|
<el-col :span="6"> |
||||
|
<div class="text-sm text-[#a19f98] leading-8 "> |
||||
|
<el-statistic :value="info.personnel_count"> |
||||
|
<template #title> |
||||
|
<div style="display: inline-flex; align-items: center"> |
||||
|
<span class="mr-[5px]">员工数量</span> |
||||
|
</div> |
||||
|
</template> |
||||
|
</el-statistic> |
||||
|
|
||||
|
<div class="text-sm text-[#a19f98] leading-8"> |
||||
|
|
||||
|
</div> |
||||
|
</div> |
||||
|
</el-col> |
||||
|
|
||||
|
<el-col :span="6"> |
||||
|
<div class="text-sm text-[#a19f98] leading-8 "> |
||||
|
<el-statistic :value="info.customerResources_count"> |
||||
|
<template #title> |
||||
|
<div style="display: inline-flex; align-items: center"> |
||||
|
<span class="mr-[5px]">资源数量</span> |
||||
|
</div> |
||||
|
</template> |
||||
|
</el-statistic> |
||||
|
|
||||
|
<div class="text-sm text-[#a19f98] leading-8"> |
||||
|
<span>昨日新增</span> |
||||
|
<span>{{info.customerResources_day_count}}</span> |
||||
|
</div> |
||||
|
</div> |
||||
|
</el-col> |
||||
|
|
||||
|
<el-col :span="6"> |
||||
|
<div class="text-sm text-[#a19f98] leading-8 "> |
||||
|
<el-statistic :value="info.student_count"> |
||||
|
<template #title> |
||||
|
<div style="display: inline-flex; align-items: center"> |
||||
|
<span class="mr-[5px]">学员数量</span> |
||||
|
</div> |
||||
|
</template> |
||||
|
</el-statistic> |
||||
|
<div class="text-sm text-[#a19f98] leading-8"> |
||||
|
<span>昨日新增</span> |
||||
|
<span>{{info.student_day_count}}</span> |
||||
|
</div> |
||||
|
</div> |
||||
|
</el-col> |
||||
|
|
||||
|
|
||||
|
</el-row> |
||||
|
|
||||
|
|
||||
|
</el-card> |
||||
|
<!-- 实时概况 end --> |
||||
|
|
||||
|
|
||||
|
<el-row :gutter="15" class="mt-[15px]"> |
||||
|
<el-col :span="24"> |
||||
|
<el-card shadow="never" class="!border-none"> |
||||
|
<template #header> |
||||
|
<span class="text-lg font-extrabold">资源增长趋势</span> |
||||
|
</template> |
||||
|
<div > |
||||
|
<el-button :type="activeRange === 'week' ? 'primary' : 'default'" size="small" |
||||
|
@click="changeRange('week')">周</el-button> |
||||
|
<el-button :type="activeRange === 'month' ? 'primary' : 'default'" size="small" |
||||
|
@click="changeRange('month')">月</el-button> |
||||
|
<el-button :type="activeRange === 'year' ? 'primary' : 'default'" size="small" |
||||
|
@click="changeRange('year')">年</el-button> |
||||
|
|
||||
|
</div> |
||||
|
|
||||
|
<div ref="visitStat" :style="{ width: '100%', height: '300px' }"> |
||||
|
|
||||
|
</div> |
||||
|
</el-card> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts" setup> |
||||
|
import { ref, reactive } from 'vue' |
||||
|
import { getHome } from '@/app/api/sys' |
||||
|
import * as echarts from 'echarts' |
||||
|
const visitStat = ref<any>(null) |
||||
|
const activeRange = ref<'week' | 'month' | 'year'>('week') |
||||
|
|
||||
|
const info = reactive({ |
||||
|
campus_count: 0, |
||||
|
personnel_count: 0, |
||||
|
customerResources_count: 0, |
||||
|
customerResources_day_count: 0, |
||||
|
student_count: 0, |
||||
|
student_day_count: 0, |
||||
|
customer: [] |
||||
|
}) |
||||
|
|
||||
|
const changeRange = (range) => { |
||||
|
activeRange.value = range |
||||
|
Init(range) // 加载新数据 |
||||
|
} |
||||
|
|
||||
|
const Init = (range) => { |
||||
|
|
||||
|
getHome({'date':range}) |
||||
|
.then((res) => { |
||||
|
info.campus_count = res.data.campus_count |
||||
|
info.personnel_count = res.data.personnel_count |
||||
|
info.customerResources_count = res.data.customerResources_count |
||||
|
info.customerResources_day_count = res.data.customerResources_day_count |
||||
|
info.student_count = res.data.student_count |
||||
|
info.student_day_count = res.data.student_day_count |
||||
|
info.customer = res.data.customer |
||||
|
drawChart(''); |
||||
|
}) |
||||
|
.catch(() => { |
||||
|
|
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
Init(); |
||||
|
|
||||
|
|
||||
|
const drawChart = (item : any) => { |
||||
|
let value = info.customer.value |
||||
|
if (item) value = item |
||||
|
if (!visitStat.value) return |
||||
|
|
||||
|
|
||||
|
const visitStatChart = echarts.init(visitStat.value) |
||||
|
const visitStatOption = ref({ |
||||
|
// title: { |
||||
|
// text: '订单量趋势' |
||||
|
// }, |
||||
|
legend: {}, |
||||
|
xAxis: { |
||||
|
data: [] |
||||
|
}, |
||||
|
yAxis: {}, |
||||
|
tooltip: { |
||||
|
trigger: 'axis' |
||||
|
}, |
||||
|
series: [ |
||||
|
{ |
||||
|
type: 'line', |
||||
|
data: [] |
||||
|
} |
||||
|
] |
||||
|
}) |
||||
|
|
||||
|
|
||||
|
visitStatOption.value.xAxis.data = info.customer.time |
||||
|
visitStatOption.value.series[0].data = value |
||||
|
|
||||
|
visitStatChart.setOption(visitStatOption.value) |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped></style> |
||||
@ -0,0 +1,113 @@ |
|||||
|
/** |
||||
|
* 根据场地信息生成可用时间段 |
||||
|
* @param venueInfo 场地信息对象 |
||||
|
* @returns 时间段数组,格式为["08:00-09:00", "09:00-10:00"] |
||||
|
*/ |
||||
|
export const generateTimeSlots = (venueInfo: any) => { |
||||
|
if (!venueInfo) return [] |
||||
|
|
||||
|
const timeSlots: string[] = [] |
||||
|
|
||||
|
// 如果场地已有预设时间段,优先使用
|
||||
|
if (venueInfo.time_slots && Array.isArray(venueInfo.time_slots)) { |
||||
|
return venueInfo.time_slots.map((slot: string) => slot.trim()); |
||||
|
} |
||||
|
|
||||
|
// 根据time_range_type生成不同的时间段
|
||||
|
switch (venueInfo.time_range_type) { |
||||
|
case 'fixed': |
||||
|
// 从fixed_time_ranges中获取固定时间段
|
||||
|
try { |
||||
|
// 确保fixed_time_ranges是数组
|
||||
|
const fixedRanges = Array.isArray(venueInfo.fixed_time_ranges) |
||||
|
? venueInfo.fixed_time_ranges |
||||
|
: (typeof venueInfo.fixed_time_ranges === 'string' |
||||
|
? JSON.parse(venueInfo.fixed_time_ranges || '[]') |
||||
|
: []); |
||||
|
|
||||
|
fixedRanges.forEach((range: any) => { |
||||
|
// 确保start_time和end_time存在
|
||||
|
if (range && range.start_time && range.end_time) { |
||||
|
timeSlots.push(`${range.start_time}-${range.end_time}`) |
||||
|
} |
||||
|
}) |
||||
|
} catch (error) { |
||||
|
console.error('解析固定时间段失败:', error) |
||||
|
} |
||||
|
break |
||||
|
|
||||
|
case 'all': |
||||
|
// 全天可用,但中午12:30-14:00不可用
|
||||
|
// 早上8点到中午12:30,步长60分钟
|
||||
|
for (let hour = 8; hour <= 12; hour++) { |
||||
|
for (let minute = 0; minute < 60; minute += 60) { |
||||
|
if (hour === 12 && minute === 30) continue // 跳过12:30
|
||||
|
|
||||
|
const startHour = hour |
||||
|
const startMinute = minute |
||||
|
const endHour = minute === 30 ? hour + 1 : hour |
||||
|
const endMinute = minute === 30 ? 0 : 30 |
||||
|
|
||||
|
const startTime = `${startHour.toString().padStart(2, '0')}:${startMinute.toString().padStart(2, '0')}` |
||||
|
const endTime = `${endHour.toString().padStart(2, '0')}:${endMinute.toString().padStart(2, '0')}` |
||||
|
|
||||
|
timeSlots.push(`${startTime}-${endTime}`) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 下午14:00到晚上22:00,步长60分钟
|
||||
|
for (let hour = 14; hour < 22; hour++) { |
||||
|
for (let minute = 0; minute < 60; minute += 60) { |
||||
|
const startHour = hour |
||||
|
const startMinute = minute |
||||
|
const endHour = minute === 30 ? hour + 1 : hour |
||||
|
const endMinute = minute === 30 ? 0 : 30 |
||||
|
|
||||
|
const startTime = `${startHour.toString().padStart(2, '0')}:${startMinute.toString().padStart(2, '0')}` |
||||
|
const endTime = `${endHour.toString().padStart(2, '0')}:${endMinute.toString().padStart(2, '0')}` |
||||
|
|
||||
|
timeSlots.push(`${startTime}-${endTime}`) |
||||
|
} |
||||
|
} |
||||
|
break |
||||
|
|
||||
|
case 'range': |
||||
|
// 使用指定的时间范围,步长60分钟
|
||||
|
if (venueInfo.time_range_start && venueInfo.time_range_end) { |
||||
|
const startTimeParts = venueInfo.time_range_start.split(':') |
||||
|
const endTimeParts = venueInfo.time_range_end.split(':') |
||||
|
|
||||
|
if (startTimeParts.length === 2 && endTimeParts.length === 2) { |
||||
|
const startHour = parseInt(startTimeParts[0]) |
||||
|
const startMinute = parseInt(startTimeParts[1]) |
||||
|
const endHour = parseInt(endTimeParts[0]) |
||||
|
const endMinute = parseInt(endTimeParts[1]) |
||||
|
|
||||
|
// 计算总分钟数
|
||||
|
const startTotalMinutes = startHour * 60 + startMinute |
||||
|
const endTotalMinutes = endHour * 60 + endMinute |
||||
|
|
||||
|
// 以60分钟为步长生成时间段
|
||||
|
for (let minutes = startTotalMinutes; minutes < endTotalMinutes; minutes += 60) { |
||||
|
const startHour = Math.floor(minutes / 60) |
||||
|
const startMinute = minutes % 60 |
||||
|
const endHour = Math.floor((minutes + 60) / 60) |
||||
|
const endMinute = (minutes + 60) % 60 |
||||
|
|
||||
|
const startTime = `${startHour.toString().padStart(2, '0')}:${startMinute.toString().padStart(2, '0')}` |
||||
|
const endTime = `${endHour.toString().padStart(2, '0')}:${endMinute.toString().padStart(2, '0')}` |
||||
|
|
||||
|
timeSlots.push(`${startTime}-${endTime}`) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
break |
||||
|
} |
||||
|
|
||||
|
// 添加现有时间段,如果有的话
|
||||
|
if (venueInfo.time_slot && !timeSlots.includes(venueInfo.time_slot)) { |
||||
|
timeSlots.push(venueInfo.time_slot); |
||||
|
} |
||||
|
|
||||
|
return timeSlots |
||||
|
} |
||||
Binary file not shown.
@ -0,0 +1,104 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\adminapi\controller\class_resources_rel; |
||||
|
|
||||
|
use core\base\BaseAdminController; |
||||
|
use app\service\admin\class_resources_rel\ClassResourcesRelService; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 班级和资源控制器 |
||||
|
* Class ClassResourcesRel |
||||
|
* @package app\adminapi\controller\class_resources_rel |
||||
|
*/ |
||||
|
class ClassResourcesRel extends BaseAdminController |
||||
|
{ |
||||
|
/** |
||||
|
* 获取班级和资源列表 |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function lists(){ |
||||
|
$data = $this->request->params([ |
||||
|
|
||||
|
]); |
||||
|
return success((new ClassResourcesRelService())->getPage($data)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 班级和资源详情 |
||||
|
* @param int $id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function info(int $id){ |
||||
|
return success((new ClassResourcesRelService())->getInfo($id)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 添加班级和资源 |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function add(){ |
||||
|
$data = $this->request->params([ |
||||
|
["class_id",0], |
||||
|
["resource_id",0], |
||||
|
["campus_id",0], |
||||
|
["source_type",""], |
||||
|
["status",0], |
||||
|
|
||||
|
]); |
||||
|
$this->validate($data, 'app\validate\class_resources_rel\ClassResourcesRel.add'); |
||||
|
$id = (new ClassResourcesRelService())->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], |
||||
|
["campus_id",0], |
||||
|
["source_type",""], |
||||
|
["status",0], |
||||
|
|
||||
|
]); |
||||
|
// $this->validate($data, 'app\validate\class_resources_rel\ClassResourcesRel.edit'); |
||||
|
(new ClassResourcesRelService())->edit($id, $data); |
||||
|
return success('EDIT_SUCCESS'); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 班级和资源删除 |
||||
|
* @param $id 班级和资源id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function del(int $id){ |
||||
|
(new ClassResourcesRelService())->del($id); |
||||
|
return success('DELETE_SUCCESS'); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public function getClassGradeAll(){ |
||||
|
return success(( new ClassResourcesRelService())->getClassGradeAll()); |
||||
|
} |
||||
|
|
||||
|
public function getCustomerResourcesAll(){ |
||||
|
return success(( new ClassResourcesRelService())->getCustomerResourcesAll()); |
||||
|
} |
||||
|
|
||||
|
public function getCampusAll(){ |
||||
|
return success(( new ClassResourcesRelService())->getCampusAll()); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,43 @@ |
|||||
|
<?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 -- class_resources_rel |
||||
|
|
||||
|
Route::group('class_resources_rel', function () { |
||||
|
|
||||
|
//班级和资源列表 |
||||
|
Route::get('class_resources_rel', 'class_resources_rel.ClassResourcesRel/lists'); |
||||
|
//班级和资源详情 |
||||
|
Route::get('class_resources_rel/:id', 'class_resources_rel.ClassResourcesRel/info'); |
||||
|
//添加班级和资源 |
||||
|
Route::post('class_resources_rel', 'class_resources_rel.ClassResourcesRel/add'); |
||||
|
//编辑班级和资源 |
||||
|
Route::put('class_resources_rel/:id', 'class_resources_rel.ClassResourcesRel/edit'); |
||||
|
//删除班级和资源 |
||||
|
Route::delete('class_resources_rel/:id', 'class_resources_rel.ClassResourcesRel/del'); |
||||
|
|
||||
|
Route::get('class_grade_all','class_resources_rel.ClassResourcesRel/getClassGradeAll'); |
||||
|
|
||||
|
Route::get('customer_resources_all','class_resources_rel.ClassResourcesRel/getCustomerResourcesAll'); |
||||
|
|
||||
|
Route::get('campus_all','class_resources_rel.ClassResourcesRel/getCampusAll'); |
||||
|
|
||||
|
})->middleware([ |
||||
|
AdminCheckToken::class, |
||||
|
AdminCheckRole::class, |
||||
|
AdminLog::class |
||||
|
]); |
||||
|
// USER_CODE_END -- class_resources_rel |
||||
@ -0,0 +1,189 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\api\controller\apiController; |
||||
|
|
||||
|
use app\Request; |
||||
|
use app\service\api\apiService\CampusService; |
||||
|
use app\service\api\apiService\ChatService; |
||||
|
use app\service\api\apiService\CommonService; |
||||
|
use core\base\BaseApiService; |
||||
|
|
||||
|
/** |
||||
|
* 聊天控制器相关接口 |
||||
|
* Class Personnel |
||||
|
* @package app\api\controller\apiController |
||||
|
*/ |
||||
|
class Chat extends BaseApiService |
||||
|
{ |
||||
|
|
||||
|
//获取好友关系列表 |
||||
|
public function getChatFriendsList(Request $request) |
||||
|
{ |
||||
|
$personnel_id = $request->param('personnel_id', '');//员工人力资源表id(两个参数2选1) |
||||
|
$customer_resources_id = $request->param('customer_resources_id', '');//学生资源表id(两个参数2选1) |
||||
|
if (empty($personnel_id) && empty($customer_resources_id)) { |
||||
|
return fail('缺少参数'); |
||||
|
} |
||||
|
|
||||
|
$where = [ |
||||
|
'personnel_id' => $personnel_id, |
||||
|
'customer_resources_id' => $customer_resources_id, |
||||
|
]; |
||||
|
|
||||
|
$res = (new ChatService())->getChatFriendsPage($where); |
||||
|
|
||||
|
return success($res); |
||||
|
} |
||||
|
|
||||
|
//获取好友关系详情 |
||||
|
public function getChatFriendsInfo(Request $request) |
||||
|
{ |
||||
|
$personnel_id = $request->param('personnel_id','');//员工人力资源表id |
||||
|
$customer_resources_id = $request->param('customer_resources_id','');//学生资源表id |
||||
|
|
||||
|
|
||||
|
if (empty($personnel_id) && empty($customer_resources_id)) { |
||||
|
return fail('缺少参数'); |
||||
|
} |
||||
|
|
||||
|
$where = [ |
||||
|
'personnel_id' => $personnel_id, |
||||
|
'customer_resources_id' => $customer_resources_id, |
||||
|
]; |
||||
|
|
||||
|
$res = (new ChatService())->getChatFriendsInfo($where); |
||||
|
|
||||
|
if(!$res['data']){ |
||||
|
//创建好友关系 |
||||
|
$add = (new ChatService())->addChatFriends($where); |
||||
|
if(!$add['code']){ |
||||
|
return fail('创建好友关系失败'); |
||||
|
}else{ |
||||
|
$res = (new ChatService())->getChatFriendsInfo($where); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if(!$res['code']){ |
||||
|
return fail($res['msg']); |
||||
|
} |
||||
|
|
||||
|
return success($res['data']); |
||||
|
} |
||||
|
|
||||
|
//创建好友关系 |
||||
|
public function addChatFriends(Request $request) |
||||
|
{ |
||||
|
$personnel_id = $request->param('personnel_id', ''); |
||||
|
$customer_resources_id = $request->param('customer_resources_id', ''); |
||||
|
if (empty($personnel_id) || empty($customer_resources_id)) { |
||||
|
return fail('缺少参数'); |
||||
|
} |
||||
|
|
||||
|
$where = [ |
||||
|
'personnel_id' => $personnel_id, |
||||
|
'customer_resources_id' => $customer_resources_id, |
||||
|
]; |
||||
|
|
||||
|
|
||||
|
//检测好友关系是否存在 |
||||
|
$getChatFriendsInfo = (new ChatService())->getChatFriendsInfo($where); |
||||
|
|
||||
|
if ($getChatFriendsInfo['data']) { |
||||
|
return fail('好友关系已存在'); |
||||
|
} |
||||
|
|
||||
|
$addChatFriends = (new ChatService())->addChatFriends($where); |
||||
|
if (!$addChatFriends['code']) { |
||||
|
return fail($addChatFriends['msg']); |
||||
|
} |
||||
|
return success($addChatFriends['data']); |
||||
|
} |
||||
|
|
||||
|
//获取聊天记录 |
||||
|
public function getChatMessagesList(Request $request) |
||||
|
{ |
||||
|
|
||||
|
$friend_id = $request->param('friend_id', '');//关联chat_friends表id |
||||
|
|
||||
|
if (empty($friend_id)) { |
||||
|
return fail('发送者类型不正确'); |
||||
|
} |
||||
|
$where = [ |
||||
|
'friend_id' => $friend_id, |
||||
|
]; |
||||
|
$res = (new ChatService())->getChatMessagesList($where); |
||||
|
return success($res); |
||||
|
} |
||||
|
|
||||
|
//发送聊天内容 |
||||
|
public function sendChatMessages(Request $request) |
||||
|
{ |
||||
|
$from_type = $request->param('from_type', '');//发送者类型|personnel=员工,customer=学生(客户) |
||||
|
|
||||
|
$from_id = $request->param('from_id', '');//发送者ID |
||||
|
|
||||
|
$to_id = $request->param('to_id', '');//接收者ID |
||||
|
|
||||
|
$friend_id = $request->param('friend_id', '');//关联chat_friends表id |
||||
|
|
||||
|
$message_type = $request->param('message_type', '');//消息类型|text=文本,img=图片 |
||||
|
|
||||
|
$content = $request->param('content', '');//文本内容(JSON 格式扩展字段),文本类型=纯文字,图片类型=绝对路径 |
||||
|
|
||||
|
if (!in_array($message_type, ['text', 'img'])) { |
||||
|
return fail('消息类型不正确'); |
||||
|
} |
||||
|
if (!in_array($from_type, ['personnel', 'customer'])) { |
||||
|
return fail('发送者类型不正确'); |
||||
|
} |
||||
|
if (empty($from_id) || empty($to_id) || empty($friend_id) || empty($content)) { |
||||
|
return fail('缺少参数'); |
||||
|
} |
||||
|
|
||||
|
$data = [ |
||||
|
'from_type' => $from_type, // 发送者类型:personnel=员工,customer=学生(客户) |
||||
|
'from_id' => $from_id, // 发送者ID(员工/学生),根据from_type判断 |
||||
|
'to_id' => $to_id, // 接收者ID(员工/学生),根据from_type判断 |
||||
|
'friend_id' => $friend_id, // 关联chat_friends表id |
||||
|
'message_type' => $message_type, // 消息类型:text=文本,img=图片 |
||||
|
'content' => $content // 文本内容(JSON格式扩展字段) |
||||
|
]; |
||||
|
|
||||
|
$res = (new ChatService())->sendChatMessages($data); |
||||
|
if(!$res['code']){ |
||||
|
return fail($res['msg']); |
||||
|
} |
||||
|
return success($res['data']); |
||||
|
} |
||||
|
|
||||
|
//修改未读消息数量 |
||||
|
public function editUnreadCount(Request $request){ |
||||
|
$from_type = $request->param('from_type', '');//发送者类型|personnel=员工,customer=学生(客户) |
||||
|
|
||||
|
$from_id = $request->param('from_id', '');//发送者ID |
||||
|
|
||||
|
$friend_id = $request->param('friend_id', '');//关联chat_friends表id |
||||
|
|
||||
|
if (!in_array($from_type, ['personnel', 'customer'])) { |
||||
|
return fail('发送者类型不正确'); |
||||
|
} |
||||
|
if (empty($from_id) || empty($friend_id)) { |
||||
|
return fail('缺少参数'); |
||||
|
} |
||||
|
|
||||
|
$res = (new ChatService())->editUnreadCount($from_type,$friend_id); |
||||
|
// if(!$res){ |
||||
|
// return fail('修改失败'); |
||||
|
// } |
||||
|
return success($res); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,91 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\model\chat_friends; |
||||
|
|
||||
|
use app\model\customer_resources\CustomerResources; |
||||
|
use core\base\BaseModel; |
||||
|
use think\model\concern\SoftDelete; |
||||
|
use app\model\personnel\Personnel; |
||||
|
|
||||
|
/** |
||||
|
* 员工与会员聊天好友关系模型 |
||||
|
* Class Attendance |
||||
|
* @package app\model\attendance |
||||
|
*/ |
||||
|
class ChatFriends extends BaseModel |
||||
|
{ |
||||
|
|
||||
|
use SoftDelete; |
||||
|
|
||||
|
/** |
||||
|
* 数据表主键 |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $pk = 'id'; |
||||
|
|
||||
|
/** |
||||
|
* 模型名称 |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $name = 'chat_friends'; |
||||
|
|
||||
|
/** |
||||
|
* 定义软删除标记字段. |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $deleteTime = 'delete_time'; |
||||
|
/** |
||||
|
* 定义软删除字段的默认值. |
||||
|
* @var int |
||||
|
*/ |
||||
|
protected $defaultSoftDelete = 0; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 搜索器:员工人力资源表id |
||||
|
* @param $value |
||||
|
* @param $data |
||||
|
*/ |
||||
|
public function searchPersonnelIdAttr($query, $value, $data) |
||||
|
{ |
||||
|
if ($value) { |
||||
|
$query->where("personnel_id", $value); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 搜索器:学生资源表id |
||||
|
* @param $value |
||||
|
* @param $data |
||||
|
*/ |
||||
|
public function searchCustomerResourcesIdAttr($query, $value, $data) |
||||
|
{ |
||||
|
if ($value) { |
||||
|
$query->where("customer_resources_id", $value); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public function campus(){ |
||||
|
return $this->hasOne(CustomerResources::class, 'id', 'customer_resources_id')->joinType('left')->withField('name,id')->bind(['customer_resources_id'=>'name']); |
||||
|
} |
||||
|
|
||||
|
public function personnel(){ |
||||
|
return $this->hasOne(Personnel::class, 'id', 'personnel_id')->joinType('left')->withField('name,id')->bind(['personnel_id_name'=>'name']); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,50 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\model\chat_messages; |
||||
|
|
||||
|
use core\base\BaseModel; |
||||
|
use think\model\concern\SoftDelete; |
||||
|
|
||||
|
/** |
||||
|
* 员工与会员聊天记录表模型 |
||||
|
* Class Attendance |
||||
|
* @package app\model\attendance |
||||
|
*/ |
||||
|
class ChatMessages extends BaseModel |
||||
|
{ |
||||
|
|
||||
|
use SoftDelete; |
||||
|
|
||||
|
/** |
||||
|
* 数据表主键 |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $pk = 'id'; |
||||
|
|
||||
|
/** |
||||
|
* 模型名称 |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $name = 'chat_messages'; |
||||
|
|
||||
|
/** |
||||
|
* 定义软删除标记字段. |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $deleteTime = 'delete_time'; |
||||
|
/** |
||||
|
* 定义软删除字段的默认值. |
||||
|
* @var int |
||||
|
*/ |
||||
|
protected $defaultSoftDelete = 0; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,68 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\model\class_resources_rel; |
||||
|
|
||||
|
use core\base\BaseModel; |
||||
|
use think\model\concern\SoftDelete; |
||||
|
use think\model\relation\HasMany; |
||||
|
use think\model\relation\HasOne; |
||||
|
|
||||
|
use app\model\class_grade\ClassGrade; |
||||
|
|
||||
|
use app\model\customer_resources\CustomerResources; |
||||
|
|
||||
|
use app\model\campus\Campus; |
||||
|
|
||||
|
/** |
||||
|
* 班级和资源模型 |
||||
|
* Class ClassResourcesRel |
||||
|
* @package app\model\class_resources_rel |
||||
|
*/ |
||||
|
class ClassResourcesRel extends BaseModel |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 数据表主键 |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $pk = 'id'; |
||||
|
|
||||
|
/** |
||||
|
* 模型名称 |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $name = 'class_resources_rel'; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
public function classGrade(){ |
||||
|
return $this->hasOne(ClassGrade::class, 'id', 'class_id')->joinType('left')->withField('class_name,id')->bind(['class_id_name'=>'class_name']); |
||||
|
} |
||||
|
|
||||
|
public function customerResources(){ |
||||
|
return $this->hasOne(CustomerResources::class, 'id', 'resource_id')->joinType('left')->withField('name,id')->bind(['resource_id_name'=>'name']); |
||||
|
} |
||||
|
|
||||
|
public function campus(){ |
||||
|
return $this->hasOne(Campus::class, 'id', 'campus_id')->joinType('left')->withField('campus_name,id')->bind(['campus_id_name'=>'campus_name']); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,117 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\service\admin\class_resources_rel; |
||||
|
|
||||
|
use app\model\class_resources_rel\ClassResourcesRel; |
||||
|
use app\model\class_grade\ClassGrade; |
||||
|
use app\model\customer_resources\CustomerResources; |
||||
|
use app\model\campus\Campus; |
||||
|
|
||||
|
use core\base\BaseAdminService; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 班级和资源服务层 |
||||
|
* Class ClassResourcesRelService |
||||
|
* @package app\service\admin\class_resources_rel |
||||
|
*/ |
||||
|
class ClassResourcesRelService extends BaseAdminService |
||||
|
{ |
||||
|
public function __construct() |
||||
|
{ |
||||
|
parent::__construct(); |
||||
|
$this->model = new ClassResourcesRel(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取班级和资源列表 |
||||
|
* @param array $where |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function getPage(array $where = []) |
||||
|
{ |
||||
|
$field = 'id,class_id,resource_id,campus_id,source_id,source_type,join_time,out_time,status,create_time,update_time'; |
||||
|
$order = 'id desc'; |
||||
|
|
||||
|
$search_model = $this->model->withSearch([], $where)->with(['classGrade','customerResources','campus'])->field($field)->order($order); |
||||
|
$list = $this->pageQuery($search_model); |
||||
|
return $list; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取班级和资源信息 |
||||
|
* @param int $id |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function getInfo(int $id) |
||||
|
{ |
||||
|
$field = 'id,class_id,resource_id,campus_id,source_id,source_type,join_time,out_time,status,create_time,update_time'; |
||||
|
|
||||
|
$info = $this->model->field($field)->where([['id', "=", $id]])->with(['classGrade','customerResources','campus'])->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 getCustomerResourcesAll(){ |
||||
|
$customerResourcesModel = new CustomerResources(); |
||||
|
return $customerResourcesModel->select()->toArray(); |
||||
|
} |
||||
|
|
||||
|
public function getCampusAll(){ |
||||
|
$campusModel = new Campus(); |
||||
|
return $campusModel->select()->toArray(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,216 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\service\api\apiService; |
||||
|
|
||||
|
use app\model\campus\Campus; |
||||
|
use app\model\campus_person_role\CampusPersonRole; |
||||
|
use app\model\chat_friends\ChatFriends; |
||||
|
use app\model\chat_messages\ChatMessages; |
||||
|
use app\model\dict\Dict; |
||||
|
use core\base\BaseApiService; |
||||
|
use think\facade\Db; |
||||
|
|
||||
|
/** |
||||
|
* 校区服务层 |
||||
|
* Class MemberService |
||||
|
* @package app\service\api\member |
||||
|
*/ |
||||
|
class ChatService extends BaseApiService |
||||
|
{ |
||||
|
public function __construct() |
||||
|
{ |
||||
|
parent::__construct(); |
||||
|
} |
||||
|
|
||||
|
//查询好友关系列表 |
||||
|
public function getChatFriendsPage(array $where) |
||||
|
{ |
||||
|
$page_params = $this->getPageParam();//获取请求参数中的页码+分页数 |
||||
|
$page = $page_params['page']; |
||||
|
$limit = $page_params['limit']; |
||||
|
|
||||
|
$model = new ChatFriends(); |
||||
|
//判断用没有员工id |
||||
|
if (!empty($where['personnel_id'])) { |
||||
|
$model = $model->where('personnel_id', $where['personnel_id']); |
||||
|
} |
||||
|
|
||||
|
if (!empty($where['customer_resources_id'])) { |
||||
|
$model = $model->where('customer_resources_id', $where['customer_resources_id']); |
||||
|
} |
||||
|
|
||||
|
$data = $model->paginate([ |
||||
|
'list_rows' => $limit, |
||||
|
'page' => $page, |
||||
|
])->toArray(); |
||||
|
|
||||
|
return $data; |
||||
|
} |
||||
|
|
||||
|
//查询好友关系详情 |
||||
|
public function getChatFriendsInfo(array $where) |
||||
|
{ |
||||
|
$model = new ChatFriends(); |
||||
|
//判断用没有员工id |
||||
|
if (!empty($where['personnel_id'])) { |
||||
|
$model = $model->where('personnel_id', $where['personnel_id']); |
||||
|
} |
||||
|
if (!empty($where['customer_resources_id'])) { |
||||
|
$model = $model->where('customer_resources_id', $where['customer_resources_id']); |
||||
|
} |
||||
|
$data = $model->find(); |
||||
|
|
||||
|
|
||||
|
if ($data) { |
||||
|
$data = $data->toArray(); |
||||
|
$res = [ |
||||
|
'code' => 1, |
||||
|
'msg' => '操作成功', |
||||
|
'data' => $data |
||||
|
]; |
||||
|
return $res; |
||||
|
} else { |
||||
|
$res = [ |
||||
|
'code' => 0, |
||||
|
'msg' => '暂无数据', |
||||
|
'data' => [] |
||||
|
]; |
||||
|
return $res; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//创建好友关系 |
||||
|
public function addChatFriends(array $data) |
||||
|
{ |
||||
|
$data = ChatFriends::create($data); |
||||
|
if($data){ |
||||
|
$res = [ |
||||
|
'code' => 1, |
||||
|
'msg' => '操作成功', |
||||
|
'data' => $data |
||||
|
]; |
||||
|
return $res; |
||||
|
}else{ |
||||
|
$res = [ |
||||
|
'code' => 0, |
||||
|
'msg' => '操作失败', |
||||
|
'data' => [] |
||||
|
]; |
||||
|
return $res; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//发送聊天信息 |
||||
|
public function sendChatMessages(array $data){ |
||||
|
//开启事物操作 |
||||
|
Db::startTrans(); |
||||
|
try { |
||||
|
$add = ChatMessages::create($data); |
||||
|
|
||||
|
if(!empty($data['from_type']) && !empty($data['from_id']) && !empty($data['friend_id'])){ |
||||
|
$to_type = 'personnel'; |
||||
|
if($data['from_type'] == 'personnel'){ |
||||
|
$to_type = 'customer'; |
||||
|
} |
||||
|
$this->addUnreadCount($to_type,$data['friend_id']); |
||||
|
|
||||
|
$this->editUnreadCount($data['from_type'],$data['friend_id']); |
||||
|
} |
||||
|
|
||||
|
if($add){ |
||||
|
Db::commit(); |
||||
|
$res = [ |
||||
|
'code' => 1, |
||||
|
'msg' => '操作成功', |
||||
|
'data' => $add->toArray() |
||||
|
]; |
||||
|
return $res; |
||||
|
}else{ |
||||
|
Db::rollback(); |
||||
|
$res = [ |
||||
|
'code' => 0, |
||||
|
'msg' => '操作失败', |
||||
|
'data' => [] |
||||
|
]; |
||||
|
return $res; |
||||
|
} |
||||
|
}catch (\Exception $exception){ |
||||
|
Db::rollback(); |
||||
|
$res = [ |
||||
|
'code' => 0, |
||||
|
'msg' => '操作失败', |
||||
|
'data' => [] |
||||
|
]; |
||||
|
return $res; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//获取聊天记录 |
||||
|
public function getChatMessagesList(array $where){ |
||||
|
$page_params = $this->getPageParam();//获取请求参数中的页码+分页数 |
||||
|
$page = $page_params['page']; |
||||
|
$limit = $page_params['limit']; |
||||
|
|
||||
|
$model = new ChatMessages(); |
||||
|
$model = $model->where('friend_id',$where['friend_id']); |
||||
|
|
||||
|
// 按id倒序排列 |
||||
|
$data = $model->order('id', 'desc')->paginate([ |
||||
|
'list_rows' => $limit, |
||||
|
'page' => $page, |
||||
|
])->toArray(); |
||||
|
|
||||
|
return $data; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改未读消息数量 |
||||
|
* @param $from_type 发送者类型|personnel=员工,customer=学生(客户) |
||||
|
* @param $from_id 发送者ID(员工/学生) |
||||
|
* @param $friend_id 关联chat_friends表id |
||||
|
*/ |
||||
|
public function editUnreadCount($from_type ,$friend_id){ |
||||
|
$where = []; |
||||
|
if($from_type == 'personnel'){ |
||||
|
//员工发送的消息->把员工的未读消息数量清空 |
||||
|
$data['unread_count_personnel'] = 0; |
||||
|
}else{ |
||||
|
//学生发送的消息->把学生的未读消息数量清空 |
||||
|
$data['unread_count_customer_resources'] = 0; |
||||
|
} |
||||
|
$model = ChatFriends::where('id',$friend_id); |
||||
|
|
||||
|
$data['updated_at'] = date('Y-m-d H:i:s'); |
||||
|
$model = $model->update($data); |
||||
|
return $model; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 追加接收消息的人未读消息数量+1 |
||||
|
* @param $to_type 接收者类型|personnel=员工,customer=学生(客户) |
||||
|
* @param $to_id 接收者ID(员工/学生) |
||||
|
* @param $friend_id 关联chat_friends表id |
||||
|
*/ |
||||
|
public function addUnreadCount($to_type, $friend_id) |
||||
|
{ |
||||
|
$model = ChatFriends::where('id', $friend_id); |
||||
|
|
||||
|
if ($to_type == 'personnel') { |
||||
|
// 员工接收的消息 -> 员工的未读消息数量+1 |
||||
|
return $model->inc('unread_count_personnel')->update(); |
||||
|
} else { |
||||
|
// 学生接收的消息 -> 学生的未读消息数量+1 |
||||
|
return $model->inc('unread_count_customer_resources')->update(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,35 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\validate\class_resources_rel; |
||||
|
use core\base\BaseValidate; |
||||
|
/** |
||||
|
* 班级和资源验证器 |
||||
|
* Class ClassResourcesRel |
||||
|
* @package addon\app\validate\class_resources_rel |
||||
|
*/ |
||||
|
class ClassResourcesRel extends BaseValidate |
||||
|
{ |
||||
|
|
||||
|
protected $rule = [ |
||||
|
'class_id' => 'require', |
||||
|
]; |
||||
|
|
||||
|
protected $message = [ |
||||
|
'class_id.require' => ['common_validate.require', ['class_id']], |
||||
|
]; |
||||
|
|
||||
|
protected $scene = [ |
||||
|
"add" => ['class_id', 'resource_id', 'campus_id', 'source_type', 'status'], |
||||
|
"edit" => ['class_id', 'resource_id', 'campus_id', 'source_type', 'status'] |
||||
|
]; |
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue