# Conflicts: # niucloud/app/adminapi/controller/course/Course.php # niucloud/app/adminapi/route/course.php # niucloud/app/service/admin/course/CourseService.phpmaster
@ -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,333 @@ |
|||||
|
<template> |
||||
|
<el-dialog |
||||
|
v-model="showDialog" |
||||
|
:title="t('addBindingTestPaper')" |
||||
|
width="50%" |
||||
|
class="diy-dialog-wrap" |
||||
|
:destroy-on-close="true" |
||||
|
> |
||||
|
<el-form |
||||
|
:inline="true" |
||||
|
:model="lessonCourseTeachingTable.searchParam" |
||||
|
ref="searchFormRef" |
||||
|
> |
||||
|
<el-form-item :label="t('totalScore')" prop="title"> |
||||
|
<el-input |
||||
|
v-model="lessonCourseTeachingTable.searchParam.total_score" |
||||
|
:placeholder="t('totalScore')" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
<el-form-item :label="t('selectionMode')" prop="status"> |
||||
|
|
||||
|
<el-select class="input-width" v-model="lessonCourseTeachingTable.searchParam.selection_mode" clearable :placeholder="t('selectionMode')"> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option label="随机组题" value="random" /> |
||||
|
<el-option label="自选题目" value="manual" /> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
<el-form-item> |
||||
|
<el-button type="primary" @click="loadLessonCourseTeachingList()">{{ |
||||
|
t('search') |
||||
|
}}</el-button> |
||||
|
<el-button @click="resetForm(searchFormRef)">{{ |
||||
|
t('reset') |
||||
|
}}</el-button> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
|
||||
|
<div class="mt-[10px]"> |
||||
|
<el-table |
||||
|
:data="lessonCourseTeachingTable.data" |
||||
|
size="large" |
||||
|
v-loading="lessonCourseTeachingTable.loading" |
||||
|
@selection-change="handleSelectionChange" |
||||
|
> |
||||
|
<template #empty> |
||||
|
<span>{{ |
||||
|
!lessonCourseTeachingTable.loading ? t('emptyData') : '' |
||||
|
}}</span> |
||||
|
</template> |
||||
|
<el-table-column type="selection" width="55" /> |
||||
|
<el-table-column |
||||
|
prop="total_score" |
||||
|
min-width="80" |
||||
|
:label="t('totalScore')" |
||||
|
:show-overflow-tooltip="true" |
||||
|
/> |
||||
|
<el-table-column |
||||
|
prop="passing_score" |
||||
|
min-width="80" |
||||
|
:label="t('passingScore')" |
||||
|
:show-overflow-tooltip="true" |
||||
|
/> |
||||
|
<el-table-column |
||||
|
:label="t('selectionMode')" |
||||
|
min-width="120" |
||||
|
align="center" |
||||
|
:show-overflow-tooltip="true" |
||||
|
> |
||||
|
<template #default="{ row }"> |
||||
|
<div v-if="row.selection_mode == 'random'">随机组题</div> |
||||
|
<div v-if="row.selection_mode == 'manual'">自选题目</div> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column |
||||
|
prop="created_at" |
||||
|
:label="t('userCreateTime')" |
||||
|
min-width="150" |
||||
|
:show-overflow-tooltip="true" |
||||
|
/> |
||||
|
<!-- <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, 1)">{{--> |
||||
|
<!-- t('delete')--> |
||||
|
<!-- }}</el-button>--> |
||||
|
<!-- </template>--> |
||||
|
<!-- </el-table-column>--> |
||||
|
</el-table> |
||||
|
<div class="mt-[16px] flex justify-end"> |
||||
|
<el-pagination |
||||
|
v-model:current-page="lessonCourseTeachingTable.page" |
||||
|
v-model:page-size="lessonCourseTeachingTable.limit" |
||||
|
layout="total, sizes, prev, pager, next, jumper" |
||||
|
:total="lessonCourseTeachingTable.total" |
||||
|
@size-change="loadLessonCourseTeachingList()" |
||||
|
@current-change="loadLessonCourseTeachingList" |
||||
|
/> |
||||
|
</div> |
||||
|
</div> |
||||
|
<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 { |
||||
|
addLessonCourseTeaching, |
||||
|
editLessonCourseTeaching, |
||||
|
getLessonCourseTeachingInfo, |
||||
|
getLessonCourseTeachingList, |
||||
|
getWithPersonnelDataList, getWithTestPaperList, |
||||
|
setBindingTestPaperModule, |
||||
|
} from '@/app/api/lesson_course_teaching' |
||||
|
import { ElMessage } from 'element-plus' |
||||
|
|
||||
|
let showDialog = ref(false) |
||||
|
const loading = ref(false) |
||||
|
|
||||
|
let lessonCourseTeachingTable = reactive({ |
||||
|
page: 1, |
||||
|
limit: 10, |
||||
|
total: 0, |
||||
|
loading: true, |
||||
|
data: [], |
||||
|
searchParam: { |
||||
|
total_score: '', |
||||
|
selection_mode: '' |
||||
|
}, |
||||
|
}) |
||||
|
|
||||
|
const multipleSelection = ref<[]>([]) |
||||
|
const binding_module = ref('') |
||||
|
const handleSelectionChange = (val: []) => { |
||||
|
multipleSelection.value = val |
||||
|
} |
||||
|
|
||||
|
const loadLessonCourseTeachingList = (page: number = 1) => { |
||||
|
lessonCourseTeachingTable.loading = true |
||||
|
lessonCourseTeachingTable.page = page |
||||
|
|
||||
|
getWithTestPaperList({ |
||||
|
page: lessonCourseTeachingTable.page, |
||||
|
limit: lessonCourseTeachingTable.limit, |
||||
|
...lessonCourseTeachingTable.searchParam, |
||||
|
}) |
||||
|
.then((res) => { |
||||
|
lessonCourseTeachingTable.loading = false |
||||
|
lessonCourseTeachingTable.data = res.data.data |
||||
|
lessonCourseTeachingTable.total = res.data.total |
||||
|
}) |
||||
|
.catch(() => { |
||||
|
lessonCourseTeachingTable.loading = false |
||||
|
}) |
||||
|
} |
||||
|
loadLessonCourseTeachingList() |
||||
|
|
||||
|
const resetForm = (page: number = 1) => { |
||||
|
lessonCourseTeachingTable.searchParam.total_score = '' |
||||
|
lessonCourseTeachingTable.searchParam.selection_mode = '' |
||||
|
loadLessonCourseTeachingList() |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 表单数据 |
||||
|
*/ |
||||
|
const initialFormData = { |
||||
|
id: '', |
||||
|
title: '', |
||||
|
image: '', |
||||
|
type: '', |
||||
|
content: '', |
||||
|
status: '', |
||||
|
// user_permission: [], |
||||
|
} |
||||
|
const formData: Record<string, any> = reactive({ ...initialFormData }) |
||||
|
|
||||
|
const formRef = ref<FormInstance>() |
||||
|
|
||||
|
// 表单验证规则 |
||||
|
const formRules = computed(() => { |
||||
|
return { |
||||
|
title: [ |
||||
|
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
||||
|
], |
||||
|
image: [ |
||||
|
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
||||
|
], |
||||
|
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
||||
|
content: [ |
||||
|
{ required: true, message: t('contentPlaceholder'), trigger: 'blur' }, |
||||
|
], |
||||
|
status: [ |
||||
|
{ required: true, message: t('statusPlaceholder'), trigger: 'blur' }, |
||||
|
], |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
const emit = defineEmits(['complete']) |
||||
|
|
||||
|
/** |
||||
|
* 确认 |
||||
|
* @param formEl |
||||
|
*/ |
||||
|
const confirm = async (formEl: FormInstance | undefined) => { |
||||
|
if(multipleSelection.value.length == 0) { |
||||
|
ElMessage.error('请选择数据'); |
||||
|
return; |
||||
|
} else if (multipleSelection.value.length > 1) { |
||||
|
ElMessage.error('只能选择一条数据'); |
||||
|
return; |
||||
|
} |
||||
|
let data = { |
||||
|
id: BindingId.value, |
||||
|
exam_papers_id: multipleSelection.value |
||||
|
.map((item) => item.id) |
||||
|
.join(',') |
||||
|
} |
||||
|
setBindingTestPaperModule(data) |
||||
|
.then((res) => { |
||||
|
loading.value = false |
||||
|
showDialog.value = false |
||||
|
emit('complete') |
||||
|
}) |
||||
|
.catch((err) => { |
||||
|
loading.value = false |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
// 获取字典数据 |
||||
|
let typeList = ref([]) |
||||
|
const typeDictList = async () => { |
||||
|
typeList.value = await (await useDictionary('material_type')).data.dictionary |
||||
|
} |
||||
|
typeDictList() |
||||
|
watch( |
||||
|
() => typeList.value, |
||||
|
() => { |
||||
|
formData.type = typeList.value[0].value |
||||
|
} |
||||
|
) |
||||
|
let statusList = ref([]) |
||||
|
const statusDictList = async () => { |
||||
|
statusList.value = await ( |
||||
|
await useDictionary('course_status') |
||||
|
).data.dictionary |
||||
|
} |
||||
|
statusDictList() |
||||
|
watch( |
||||
|
() => statusList.value, |
||||
|
() => { |
||||
|
formData.status = statusList.value[0].value |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
const userPermissionList = ref([] as any[]) |
||||
|
const BindingId = ref(undefined) |
||||
|
const setUserPermissionList = async () => { |
||||
|
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
||||
|
} |
||||
|
setUserPermissionList() |
||||
|
const setFormData = async (row: any = null) => { |
||||
|
BindingId.value = row.id |
||||
|
binding_module.value = row.table_type |
||||
|
} |
||||
|
|
||||
|
// 验证手机号格式 |
||||
|
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> |
||||
@ -1,273 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id |
|
||||
? t('editBasketballTeachingLibrary') |
|
||||
: t('addBasketballTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addBasketballTeachingLibrary, |
|
||||
editBasketballTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
import { |
|
||||
addPublicLibraryList, |
|
||||
editPublicLibraryList, |
|
||||
} from '@/app/api/future_ontent' |
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
table_type: 26, |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 ? editPublicLibraryList : addPublicLibraryList |
|
||||
|
|
||||
await formEl.validate(async (valid) => { |
|
||||
if (valid) { |
|
||||
loading.value = true |
|
||||
|
|
||||
let data = formData |
|
||||
data.table_type = 26 |
|
||||
save(data) |
|
||||
.then((res) => { |
|
||||
loading.value = false |
|
||||
showDialog.value = false |
|
||||
emit('complete') |
|
||||
}) |
|
||||
.catch((err) => { |
|
||||
loading.value = false |
|
||||
}) |
|
||||
} |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
// 获取字典数据 |
|
||||
let typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,271 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id ? t('editNinjaTeachingLibrary') : t('addNinjaTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addNinjaTeachingLibrary, |
|
||||
editNinjaTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
import { |
|
||||
addPublicLibraryList, |
|
||||
editPublicLibraryList, |
|
||||
} from '@/app/api/future_ontent' |
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
table_type: 21, |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 ? editPublicLibraryList : addPublicLibraryList |
|
||||
|
|
||||
await formEl.validate(async (valid) => { |
|
||||
if (valid) { |
|
||||
loading.value = true |
|
||||
|
|
||||
let data = formData |
|
||||
data.table_type = 21 |
|
||||
save(data) |
|
||||
.then((res) => { |
|
||||
loading.value = false |
|
||||
showDialog.value = false |
|
||||
emit('complete') |
|
||||
}) |
|
||||
.catch((err) => { |
|
||||
loading.value = false |
|
||||
}) |
|
||||
} |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
// 获取字典数据 |
|
||||
let typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,271 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id |
|
||||
? t('editPhysicalTeachingLibrary') |
|
||||
: t('addPhysicalTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addPhysicalTeachingLibrary, |
|
||||
editPhysicalTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
|
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 |
|
||||
? editPhysicalTeachingLibrary |
|
||||
: addPhysicalTeachingLibrary |
|
||||
|
|
||||
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 typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,273 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id |
|
||||
? t('editSecurityTeachingLibrary') |
|
||||
: t('addSecurityTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addSecurityTeachingLibrary, |
|
||||
editSecurityTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
import { |
|
||||
addPublicLibraryList, |
|
||||
editPublicLibraryList, |
|
||||
} from '@/app/api/future_ontent' |
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
table_type: 22, |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 ? editPublicLibraryList : addPublicLibraryList |
|
||||
|
|
||||
await formEl.validate(async (valid) => { |
|
||||
if (valid) { |
|
||||
loading.value = true |
|
||||
|
|
||||
let data = formData |
|
||||
data.table_type = 22 |
|
||||
save(data) |
|
||||
.then((res) => { |
|
||||
loading.value = false |
|
||||
showDialog.value = false |
|
||||
emit('complete') |
|
||||
}) |
|
||||
.catch((err) => { |
|
||||
loading.value = false |
|
||||
}) |
|
||||
} |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
// 获取字典数据 |
|
||||
let typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,273 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id |
|
||||
? t('editStrengthenTeachingLibrary') |
|
||||
: t('addStrengthenTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addStrengTeachingLibrary, |
|
||||
editStrengTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
import { |
|
||||
addPublicLibraryList, |
|
||||
editPublicLibraryList, |
|
||||
} from '@/app/api/future_ontent' |
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
table_type: 20, |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 ? editPublicLibraryList : addPublicLibraryList |
|
||||
|
|
||||
await formEl.validate(async (valid) => { |
|
||||
if (valid) { |
|
||||
loading.value = true |
|
||||
|
|
||||
let data = formData |
|
||||
data.table_type = 20 |
|
||||
save(data) |
|
||||
.then((res) => { |
|
||||
loading.value = false |
|
||||
showDialog.value = false |
|
||||
emit('complete') |
|
||||
}) |
|
||||
.catch((err) => { |
|
||||
loading.value = false |
|
||||
}) |
|
||||
} |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
// 获取字典数据 |
|
||||
let typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,271 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id |
|
||||
? t('editBasketballTeachingLibrary') |
|
||||
: t('addBasketballTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addBasketballTeachingLibrary, |
|
||||
editBasketballTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
|
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 |
|
||||
? editBasketballTeachingLibrary |
|
||||
: addBasketballTeachingLibrary |
|
||||
|
|
||||
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 typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,267 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id ? t('editNinjaTeachingLibrary') : t('addNinjaTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addNinjaTeachingLibrary, |
|
||||
editNinjaTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
|
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 ? editNinjaTeachingLibrary : addNinjaTeachingLibrary |
|
||||
|
|
||||
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 typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,271 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id |
|
||||
? t('editPhysicalTeachingLibrary') |
|
||||
: t('addPhysicalTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addPhysicalTeachingLibrary, |
|
||||
editPhysicalTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
|
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 |
|
||||
? editPhysicalTeachingLibrary |
|
||||
: addPhysicalTeachingLibrary |
|
||||
|
|
||||
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 typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,271 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id |
|
||||
? t('editSecurityTeachingLibrary') |
|
||||
: t('addSecurityTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addSecurityTeachingLibrary, |
|
||||
editSecurityTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
|
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 |
|
||||
? editSecurityTeachingLibrary |
|
||||
: addSecurityTeachingLibrary |
|
||||
|
|
||||
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 typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,269 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id |
|
||||
? t('editStrengthenTeachingLibrary') |
|
||||
: t('addStrengthenTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addStrengTeachingLibrary, |
|
||||
editStrengTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
|
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 ? editStrengTeachingLibrary : addStrengTeachingLibrary |
|
||||
|
|
||||
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 typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,267 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id ? t('editNinjaTeachingLibrary') : t('addNinjaTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addNinjaTeachingLibrary, |
|
||||
editNinjaTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
|
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 ? editNinjaTeachingLibrary : addNinjaTeachingLibrary |
|
||||
|
|
||||
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 typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,271 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id |
|
||||
? t('editPhysicalTeachingLibrary') |
|
||||
: t('addPhysicalTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addPhysicalTeachingLibrary, |
|
||||
editPhysicalTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
|
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 |
|
||||
? editPhysicalTeachingLibrary |
|
||||
: addPhysicalTeachingLibrary |
|
||||
|
|
||||
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 typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,271 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id |
|
||||
? t('editSecurityTeachingLibrary') |
|
||||
: t('addSecurityTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addSecurityTeachingLibrary, |
|
||||
editSecurityTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
|
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 |
|
||||
? editSecurityTeachingLibrary |
|
||||
: addSecurityTeachingLibrary |
|
||||
|
|
||||
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 typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,269 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id |
|
||||
? t('editStrengthenTeachingLibrary') |
|
||||
: t('addStrengthenTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addStrengTeachingLibrary, |
|
||||
editStrengTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
|
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 ? editStrengTeachingLibrary : addStrengTeachingLibrary |
|
||||
|
|
||||
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 typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,271 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id ? t('editNinjaTeachingLibrary') : t('addNinjaTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addNinjaTeachingLibrary, |
|
||||
editNinjaTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
import { |
|
||||
addPublicLibraryList, |
|
||||
editPublicLibraryList, |
|
||||
} from '@/app/api/future_ontent' |
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
table_type: 21, |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 ? editPublicLibraryList : addPublicLibraryList |
|
||||
|
|
||||
await formEl.validate(async (valid) => { |
|
||||
if (valid) { |
|
||||
loading.value = true |
|
||||
|
|
||||
let data = formData |
|
||||
data.table_type = 21 |
|
||||
save(data) |
|
||||
.then((res) => { |
|
||||
loading.value = false |
|
||||
showDialog.value = false |
|
||||
emit('complete') |
|
||||
}) |
|
||||
.catch((err) => { |
|
||||
loading.value = false |
|
||||
}) |
|
||||
} |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
// 获取字典数据 |
|
||||
let typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,271 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id |
|
||||
? t('editPhysicalTeachingLibrary') |
|
||||
: t('addPhysicalTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addPhysicalTeachingLibrary, |
|
||||
editPhysicalTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
|
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 |
|
||||
? editPhysicalTeachingLibrary |
|
||||
: addPhysicalTeachingLibrary |
|
||||
|
|
||||
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 typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,273 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id |
|
||||
? t('editSecurityTeachingLibrary') |
|
||||
: t('addSecurityTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addSecurityTeachingLibrary, |
|
||||
editSecurityTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
import { |
|
||||
addPublicLibraryList, |
|
||||
editPublicLibraryList, |
|
||||
} from '@/app/api/future_ontent' |
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
table_type: 22, |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 ? editPublicLibraryList : addPublicLibraryList |
|
||||
|
|
||||
await formEl.validate(async (valid) => { |
|
||||
if (valid) { |
|
||||
loading.value = true |
|
||||
|
|
||||
let data = formData |
|
||||
data.table_type = 22 |
|
||||
save(data) |
|
||||
.then((res) => { |
|
||||
loading.value = false |
|
||||
showDialog.value = false |
|
||||
emit('complete') |
|
||||
}) |
|
||||
.catch((err) => { |
|
||||
loading.value = false |
|
||||
}) |
|
||||
} |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
// 获取字典数据 |
|
||||
let typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,273 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id |
|
||||
? t('editStrengthenTeachingLibrary') |
|
||||
: t('addStrengthenTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addStrengTeachingLibrary, |
|
||||
editStrengTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
import { |
|
||||
addPublicLibraryList, |
|
||||
editPublicLibraryList, |
|
||||
} from '@/app/api/future_ontent' |
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
table_type: 20, |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 ? editPublicLibraryList : addPublicLibraryList |
|
||||
|
|
||||
await formEl.validate(async (valid) => { |
|
||||
if (valid) { |
|
||||
loading.value = true |
|
||||
|
|
||||
let data = formData |
|
||||
data.table_type = 20 |
|
||||
save(data) |
|
||||
.then((res) => { |
|
||||
loading.value = false |
|
||||
showDialog.value = false |
|
||||
emit('complete') |
|
||||
}) |
|
||||
.catch((err) => { |
|
||||
loading.value = false |
|
||||
}) |
|
||||
} |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
// 获取字典数据 |
|
||||
let typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,271 +0,0 @@ |
|||||
<template> |
|
||||
<el-dialog |
|
||||
v-model="showDialog" |
|
||||
:title=" |
|
||||
formData.id |
|
||||
? t('editPhysicalTeachingLibrary') |
|
||||
: t('addPhysicalTeachingLibrary') |
|
||||
" |
|
||||
width="50%" |
|
||||
class="diy-dialog-wrap" |
|
||||
:destroy-on-close="true" |
|
||||
> |
|
||||
<el-form |
|
||||
:model="formData" |
|
||||
label-width="120px" |
|
||||
ref="formRef" |
|
||||
:rules="formRules" |
|
||||
class="page-form" |
|
||||
v-loading="loading" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="formData.title" |
|
||||
clearable |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
class="input-width" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('image')" prop="image"> |
|
||||
<upload-image v-model="formData.image" /> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('type')" prop="type"> |
|
||||
<el-select |
|
||||
class="input-width" |
|
||||
v-model="formData.type" |
|
||||
clearable |
|
||||
:placeholder="t('typePlaceholder')" |
|
||||
> |
|
||||
<el-option label="请选择" value=""></el-option> |
|
||||
<el-option |
|
||||
v-for="(item, index) in typeList" |
|
||||
:key="index" |
|
||||
:label="item.name" |
|
||||
:value="item.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('content')" prop="content"> |
|
||||
<editor v-model="formData.content" /> |
|
||||
</el-form-item> |
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-radio-group |
|
||||
v-model="formData.status" |
|
||||
:placeholder="t('statusPlaceholder')" |
|
||||
> |
|
||||
<el-radio |
|
||||
v-for="(item, index) in statusList" |
|
||||
:key="index" |
|
||||
:label="item.value" |
|
||||
> |
|
||||
{{ item.name }} |
|
||||
</el-radio> |
|
||||
</el-radio-group> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<!-- <el-form-item :label="t('userPermission')" prop="user_permission">--> |
|
||||
<!-- <el-checkbox-group v-model="formData.user_permission" :placeholder="t('userPermissionPlaceholder')">--> |
|
||||
<!-- <el-checkbox--> |
|
||||
<!-- v-for="(item, index) in userPermissionList"--> |
|
||||
<!-- :key="index"--> |
|
||||
<!-- :label="item['sys_user_id']">--> |
|
||||
<!-- {{ item['name'] }}--> |
|
||||
<!-- </el-checkbox>--> |
|
||||
<!-- </el-checkbox-group>--> |
|
||||
<!-- </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 { |
|
||||
addPhysicalTeachingLibrary, |
|
||||
editPhysicalTeachingLibrary, |
|
||||
getLessonCourseTeachingInfo, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
|
|
||||
let showDialog = ref(false) |
|
||||
const loading = ref(false) |
|
||||
|
|
||||
/** |
|
||||
* 表单数据 |
|
||||
*/ |
|
||||
const initialFormData = { |
|
||||
id: '', |
|
||||
title: '', |
|
||||
image: '', |
|
||||
type: '', |
|
||||
content: '', |
|
||||
status: '', |
|
||||
} |
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|
||||
|
|
||||
const formRef = ref<FormInstance>() |
|
||||
|
|
||||
// 表单验证规则 |
|
||||
const formRules = computed(() => { |
|
||||
return { |
|
||||
title: [ |
|
||||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
image: [ |
|
||||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|
||||
], |
|
||||
type: [{ required: true, message: t('typePlaceholder'), trigger: 'blur' }], |
|
||||
content: [ |
|
||||
{ required: true, message: t('contentPlaceholder'), 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 |
|
||||
? editPhysicalTeachingLibrary |
|
||||
: addPhysicalTeachingLibrary |
|
||||
|
|
||||
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 typeList = ref([]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
watch( |
|
||||
() => typeList.value, |
|
||||
() => { |
|
||||
formData.type = typeList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
let statusList = ref([]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
watch( |
|
||||
() => statusList.value, |
|
||||
() => { |
|
||||
formData.status = statusList.value[0].value |
|
||||
} |
|
||||
) |
|
||||
|
|
||||
const userPermissionList = ref([] as any[]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
const setFormData = async (row: any = null) => { |
|
||||
Object.assign(formData, initialFormData) |
|
||||
loading.value = true |
|
||||
if (row) { |
|
||||
const data = await (await getLessonCourseTeachingInfo(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> |
|
||||
@ -1,789 +0,0 @@ |
|||||
<template> |
|
||||
<div class="main-container"> |
|
||||
<el-card class="box-card !border-none" shadow="never"> |
|
||||
<el-tabs v-model="active"> |
|
||||
<el-tab-pane label="训练内容" name="CourseSyllabus"> |
|
||||
<div class="flex justify-between items-center"> |
|
||||
<el-button type="primary" @click="addEvent"> |
|
||||
{{ t('addLessonCourseTeaching') }} |
|
||||
</el-button> |
|
||||
</div> |
|
||||
<el-card |
|
||||
class="box-card !border-none my-[10px] table-search-wrap" |
|
||||
shadow="never" |
|
||||
> |
|
||||
<el-form |
|
||||
:inline="true" |
|
||||
:model="lessonCourseTeachingTable.searchParam" |
|
||||
ref="searchFormRef" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="lessonCourseTeachingTable.searchParam.title" |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-select |
|
||||
class="w-[280px]" |
|
||||
v-model="lessonCourseTeachingTable.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 :label="t('createTime')" prop="create_time"> |
|
||||
<el-date-picker |
|
||||
v-model="lessonCourseTeachingTable.searchParam.create_time" |
|
||||
type="datetimerange" |
|
||||
format="YYYY-MM-DD hh:mm:ss" |
|
||||
:start-placeholder="t('startDate')" |
|
||||
:end-placeholder="t('endDate')" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('updateTime')" prop="update_time"> |
|
||||
<el-date-picker |
|
||||
v-model="lessonCourseTeachingTable.searchParam.update_time" |
|
||||
type="datetimerange" |
|
||||
format="YYYY-MM-DD hh:mm:ss" |
|
||||
:start-placeholder="t('startDate')" |
|
||||
:end-placeholder="t('endDate')" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item> |
|
||||
<el-button |
|
||||
type="primary" |
|
||||
@click="loadLessonCourseTeachingList()" |
|
||||
>{{ t('search') }}</el-button |
|
||||
> |
|
||||
<el-button @click="resetForm(searchFormRef, 13)">{{ |
|
||||
t('reset') |
|
||||
}}</el-button> |
|
||||
</el-form-item> |
|
||||
</el-form> |
|
||||
</el-card> |
|
||||
|
|
||||
<div class="mt-[10px]"> |
|
||||
<el-table |
|
||||
:data="lessonCourseTeachingTable.data" |
|
||||
size="large" |
|
||||
v-loading="lessonCourseTeachingTable.loading" |
|
||||
> |
|
||||
<template #empty> |
|
||||
<span>{{ |
|
||||
!lessonCourseTeachingTable.loading ? t('emptyData') : '' |
|
||||
}}</span> |
|
||||
</template> |
|
||||
<el-table-column |
|
||||
prop="title" |
|
||||
:label="t('title')" |
|
||||
min-width="120" |
|
||||
:show-overflow-tooltip="true" |
|
||||
/> |
|
||||
|
|
||||
<el-table-column :label="t('image')" width="100" align="left"> |
|
||||
<template #default="{ row }"> |
|
||||
<el-avatar v-if="row.image" :src="img(row.image)" /> |
|
||||
<el-avatar v-else icon="UserFilled" /> |
|
||||
</template> |
|
||||
</el-table-column> |
|
||||
<el-table-column |
|
||||
:label="t('type')" |
|
||||
min-width="180" |
|
||||
align="center" |
|
||||
:show-overflow-tooltip="true" |
|
||||
> |
|
||||
<template #default="{ row }"> |
|
||||
<div v-for="(item, index) in typeList"> |
|
||||
<div v-if="item.value == row.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, 13)" |
|
||||
>{{ t('delete') }}</el-button |
|
||||
> |
|
||||
</template> |
|
||||
</el-table-column> |
|
||||
</el-table> |
|
||||
<div class="mt-[16px] flex justify-end"> |
|
||||
<el-pagination |
|
||||
v-model:current-page="lessonCourseTeachingTable.page" |
|
||||
v-model:page-size="lessonCourseTeachingTable.limit" |
|
||||
layout="total, sizes, prev, pager, next, jumper" |
|
||||
:total="lessonCourseTeachingTable.total" |
|
||||
@size-change="loadLessonCourseTeachingList()" |
|
||||
@current-change="loadLessonCourseTeachingList" |
|
||||
/> |
|
||||
</div> |
|
||||
</div> |
|
||||
|
|
||||
<edit |
|
||||
ref="editLessonCourseTeachingDialog" |
|
||||
@complete="loadLessonCourseTeachingList" |
|
||||
/> |
|
||||
</el-tab-pane> |
|
||||
<el-tab-pane label="训练视频" name="JumpLessonLibrary"> |
|
||||
<div class="flex justify-between items-center"> |
|
||||
<el-button type="primary" @click="addJumpLessonLibrary"> |
|
||||
{{ t('addJumpLessonLibrary') }} |
|
||||
</el-button> |
|
||||
</div> |
|
||||
<el-card |
|
||||
class="box-card !border-none my-[10px] table-search-wrap" |
|
||||
shadow="never" |
|
||||
> |
|
||||
<el-form |
|
||||
:inline="true" |
|
||||
:model="JumpLessonLibraryTable.searchParam" |
|
||||
ref="searchFormRef" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="JumpLessonLibraryTable.searchParam.title" |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-select |
|
||||
class="w-[280px]" |
|
||||
v-model="JumpLessonLibraryTable.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 :label="t('createTime')" prop="create_time"> |
|
||||
<el-date-picker |
|
||||
v-model="JumpLessonLibraryTable.searchParam.create_time" |
|
||||
type="datetimerange" |
|
||||
format="YYYY-MM-DD hh:mm:ss" |
|
||||
:start-placeholder="t('startDate')" |
|
||||
:end-placeholder="t('endDate')" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('updateTime')" prop="update_time"> |
|
||||
<el-date-picker |
|
||||
v-model="JumpLessonLibraryTable.searchParam.update_time" |
|
||||
type="datetimerange" |
|
||||
format="YYYY-MM-DD hh:mm:ss" |
|
||||
:start-placeholder="t('startDate')" |
|
||||
:end-placeholder="t('endDate')" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item> |
|
||||
<el-button |
|
||||
type="primary" |
|
||||
@click="loadJumpLessonLibraryList()" |
|
||||
>{{ t('search') }}</el-button |
|
||||
> |
|
||||
<el-button @click="resetForm(searchFormRef, 14)">{{ |
|
||||
t('reset') |
|
||||
}}</el-button> |
|
||||
</el-form-item> |
|
||||
</el-form> |
|
||||
</el-card> |
|
||||
|
|
||||
<div class="mt-[10px]"> |
|
||||
<el-table |
|
||||
:data="JumpLessonLibraryTable.data" |
|
||||
size="large" |
|
||||
v-loading="JumpLessonLibraryTable.loading" |
|
||||
> |
|
||||
<template #empty> |
|
||||
<span>{{ |
|
||||
!JumpLessonLibraryTable.loading ? t('emptyData') : '' |
|
||||
}}</span> |
|
||||
</template> |
|
||||
<el-table-column |
|
||||
prop="title" |
|
||||
:label="t('title')" |
|
||||
min-width="120" |
|
||||
:show-overflow-tooltip="true" |
|
||||
/> |
|
||||
|
|
||||
<el-table-column :label="t('image')" width="100" align="left"> |
|
||||
<template #default="{ row }"> |
|
||||
<el-avatar v-if="row.image" :src="img(row.image)" /> |
|
||||
<el-avatar v-else icon="UserFilled" /> |
|
||||
</template> |
|
||||
</el-table-column> |
|
||||
<el-table-column |
|
||||
:label="t('type')" |
|
||||
min-width="180" |
|
||||
align="center" |
|
||||
:show-overflow-tooltip="true" |
|
||||
> |
|
||||
<template #default="{ row }"> |
|
||||
<div v-for="(item, index) in typeList"> |
|
||||
<div v-if="item.value == row.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="editJumpLessonLibrary(row)" |
|
||||
>{{ t('edit') }}</el-button |
|
||||
> |
|
||||
<el-button |
|
||||
type="primary" |
|
||||
link |
|
||||
@click="deleteEvent(row.id, 14)" |
|
||||
>{{ t('delete') }}</el-button |
|
||||
> |
|
||||
</template> |
|
||||
</el-table-column> |
|
||||
</el-table> |
|
||||
<div class="mt-[16px] flex justify-end"> |
|
||||
<el-pagination |
|
||||
v-model:current-page="JumpLessonLibraryTable.page" |
|
||||
v-model:page-size="JumpLessonLibraryTable.limit" |
|
||||
layout="total, sizes, prev, pager, next, jumper" |
|
||||
:total="JumpLessonLibraryTable.total" |
|
||||
@size-change="loadJumpLessonLibraryList()" |
|
||||
@current-change="loadJumpLessonLibraryList" |
|
||||
/> |
|
||||
</div> |
|
||||
</div> |
|
||||
|
|
||||
<edit-jump |
|
||||
ref="editJumpLessonLibraryDialog" |
|
||||
@complete="loadJumpLessonLibraryList" |
|
||||
/> |
|
||||
</el-tab-pane> |
|
||||
<el-tab-pane label="课后作业" name="EnTeachingLibrary"> |
|
||||
<div class="flex justify-between items-center"> |
|
||||
<el-button type="primary" @click="addEnTeachingLibrary"> |
|
||||
{{ t('addEnTeachingLibrary') }} |
|
||||
</el-button> |
|
||||
</div> |
|
||||
<el-card |
|
||||
class="box-card !border-none my-[10px] table-search-wrap" |
|
||||
shadow="never" |
|
||||
> |
|
||||
<el-form |
|
||||
:inline="true" |
|
||||
:model="EnTeachingLibraryTable.searchParam" |
|
||||
ref="searchFormRef" |
|
||||
> |
|
||||
<el-form-item :label="t('title')" prop="title"> |
|
||||
<el-input |
|
||||
v-model="EnTeachingLibraryTable.searchParam.title" |
|
||||
:placeholder="t('titlePlaceholder')" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('status')" prop="status"> |
|
||||
<el-select |
|
||||
class="w-[280px]" |
|
||||
v-model="EnTeachingLibraryTable.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 :label="t('createTime')" prop="create_time"> |
|
||||
<el-date-picker |
|
||||
v-model="EnTeachingLibraryTable.searchParam.create_time" |
|
||||
type="datetimerange" |
|
||||
format="YYYY-MM-DD hh:mm:ss" |
|
||||
:start-placeholder="t('startDate')" |
|
||||
:end-placeholder="t('endDate')" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item :label="t('updateTime')" prop="update_time"> |
|
||||
<el-date-picker |
|
||||
v-model="EnTeachingLibraryTable.searchParam.update_time" |
|
||||
type="datetimerange" |
|
||||
format="YYYY-MM-DD hh:mm:ss" |
|
||||
:start-placeholder="t('startDate')" |
|
||||
:end-placeholder="t('endDate')" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
|
|
||||
<el-form-item> |
|
||||
<el-button |
|
||||
type="primary" |
|
||||
@click="loadEnTeachingLibraryList()" |
|
||||
>{{ t('search') }}</el-button |
|
||||
> |
|
||||
<el-button @click="resetForm(searchFormRef, 15)">{{ |
|
||||
t('reset') |
|
||||
}}</el-button> |
|
||||
</el-form-item> |
|
||||
</el-form> |
|
||||
</el-card> |
|
||||
|
|
||||
<div class="mt-[10px]"> |
|
||||
<el-table |
|
||||
:data="EnTeachingLibraryTable.data" |
|
||||
size="large" |
|
||||
v-loading="EnTeachingLibraryTable.loading" |
|
||||
> |
|
||||
<template #empty> |
|
||||
<span>{{ |
|
||||
!EnTeachingLibraryTable.loading ? t('emptyData') : '' |
|
||||
}}</span> |
|
||||
</template> |
|
||||
<el-table-column |
|
||||
prop="title" |
|
||||
:label="t('title')" |
|
||||
min-width="120" |
|
||||
:show-overflow-tooltip="true" |
|
||||
/> |
|
||||
|
|
||||
<el-table-column :label="t('image')" width="100" align="left"> |
|
||||
<template #default="{ row }"> |
|
||||
<el-avatar v-if="row.image" :src="img(row.image)" /> |
|
||||
<el-avatar v-else icon="UserFilled" /> |
|
||||
</template> |
|
||||
</el-table-column> |
|
||||
<el-table-column |
|
||||
:label="t('type')" |
|
||||
min-width="180" |
|
||||
align="center" |
|
||||
:show-overflow-tooltip="true" |
|
||||
> |
|
||||
<template #default="{ row }"> |
|
||||
<div v-for="(item, index) in typeList"> |
|
||||
<div v-if="item.value == row.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="editEnTeachingLibrary(row)" |
|
||||
>{{ t('edit') }}</el-button |
|
||||
> |
|
||||
<el-button |
|
||||
type="primary" |
|
||||
link |
|
||||
@click="deleteEvent(row.id, 15)" |
|
||||
>{{ t('delete') }}</el-button |
|
||||
> |
|
||||
</template> |
|
||||
</el-table-column> |
|
||||
</el-table> |
|
||||
<div class="mt-[16px] flex justify-end"> |
|
||||
<el-pagination |
|
||||
v-model:current-page="EnTeachingLibraryTable.page" |
|
||||
v-model:page-size="EnTeachingLibraryTable.limit" |
|
||||
layout="total, sizes, prev, pager, next, jumper" |
|
||||
:total="EnTeachingLibraryTable.total" |
|
||||
@size-change="loadEnTeachingLibraryList()" |
|
||||
@current-change="loadEnTeachingLibraryList" |
|
||||
/> |
|
||||
</div> |
|
||||
</div> |
|
||||
|
|
||||
<edit-en |
|
||||
ref="editEnTeachingLibraryDialog" |
|
||||
@complete="loadEnTeachingLibraryList" |
|
||||
/> |
|
||||
</el-tab-pane> |
|
||||
</el-tabs> |
|
||||
</el-card> |
|
||||
</div> |
|
||||
</template> |
|
||||
|
|
||||
addPublicLibraryList editPublicLibraryList |
|
||||
|
|
||||
<script lang="ts" setup> |
|
||||
import { reactive, ref, watch } from 'vue' |
|
||||
import { t } from '@/lang' |
|
||||
import { useDictionary } from '@/app/api/dict' |
|
||||
import { |
|
||||
getLessonCourseTeachingList, |
|
||||
deleteLessonCourseTeaching, |
|
||||
getWithPersonnelDataList, |
|
||||
} from '@/app/api/lesson_course_teaching' |
|
||||
import { getPublicLibraryList } from '@/app/api/future_ontent' |
|
||||
import { img } from '@/utils/common' |
|
||||
import { ElMessageBox, FormInstance } from 'element-plus' |
|
||||
import Edit from '@/app/views/future_ontent/components/lesson-course-teaching-edit.vue' |
|
||||
import EditJump from '@/app/views/future_ontent/components/Jump-lesson-library-edit.vue' |
|
||||
import EditEn from '@/app/views/future_ontent/components/en-course-teaching-edit.vue' |
|
||||
import { useRoute } from 'vue-router' |
|
||||
const route = useRoute() |
|
||||
const pageName = route.meta.title |
|
||||
const active = 'CourseSyllabus' |
|
||||
|
|
||||
let lessonCourseTeachingTable = reactive({ |
|
||||
page: 1, |
|
||||
limit: 10, |
|
||||
total: 0, |
|
||||
loading: true, |
|
||||
data: [], |
|
||||
searchParam: { |
|
||||
title: '', |
|
||||
status: '', |
|
||||
create_time: [], |
|
||||
update_time: [], |
|
||||
table_type: 13, |
|
||||
}, |
|
||||
}) |
|
||||
let JumpLessonLibraryTable = reactive({ |
|
||||
page: 1, |
|
||||
limit: 10, |
|
||||
total: 0, |
|
||||
loading: true, |
|
||||
data: [], |
|
||||
searchParam: { |
|
||||
title: '', |
|
||||
status: '', |
|
||||
create_time: [], |
|
||||
update_time: [], |
|
||||
table_type: 14, |
|
||||
}, |
|
||||
}) |
|
||||
let EnTeachingLibraryTable = reactive({ |
|
||||
page: 1, |
|
||||
limit: 10, |
|
||||
total: 0, |
|
||||
loading: true, |
|
||||
data: [], |
|
||||
searchParam: { |
|
||||
title: '', |
|
||||
status: '', |
|
||||
create_time: [], |
|
||||
update_time: [], |
|
||||
table_type: 15, |
|
||||
}, |
|
||||
}) |
|
||||
|
|
||||
const searchFormRef = ref<FormInstance>() |
|
||||
|
|
||||
// 选中数据 |
|
||||
const selectData = ref<any[]>([]) |
|
||||
|
|
||||
// 字典数据 |
|
||||
const typeList = ref([] as any[]) |
|
||||
const typeDictList = async () => { |
|
||||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|
||||
} |
|
||||
typeDictList() |
|
||||
const statusList = ref([] as any[]) |
|
||||
const statusDictList = async () => { |
|
||||
statusList.value = await ( |
|
||||
await useDictionary('course_status') |
|
||||
).data.dictionary |
|
||||
} |
|
||||
statusDictList() |
|
||||
|
|
||||
const editLessonCourseTeachingDialog: Record<string, any> | null = ref(null) |
|
||||
const editJumpLessonLibraryDialog: Record<string, any> | null = ref(null) |
|
||||
const editEnTeachingLibraryDialog: Record<string, any> | null = ref(null) |
|
||||
|
|
||||
/** |
|
||||
* 获取课程教学大纲列表 |
|
||||
*/ |
|
||||
const loadLessonCourseTeachingList = (page: number = 1) => { |
|
||||
lessonCourseTeachingTable.loading = true |
|
||||
lessonCourseTeachingTable.page = page |
|
||||
|
|
||||
getPublicLibraryList({ |
|
||||
page: lessonCourseTeachingTable.page, |
|
||||
limit: lessonCourseTeachingTable.limit, |
|
||||
...lessonCourseTeachingTable.searchParam, |
|
||||
}) |
|
||||
.then((res) => { |
|
||||
lessonCourseTeachingTable.loading = false |
|
||||
lessonCourseTeachingTable.data = res.data.data |
|
||||
lessonCourseTeachingTable.total = res.data.total |
|
||||
}) |
|
||||
.catch(() => { |
|
||||
lessonCourseTeachingTable.loading = false |
|
||||
}) |
|
||||
} |
|
||||
loadLessonCourseTeachingList() |
|
||||
|
|
||||
/** |
|
||||
* 添加课程教学大纲 |
|
||||
*/ |
|
||||
const addEvent = () => { |
|
||||
editLessonCourseTeachingDialog.value.setFormData() |
|
||||
editLessonCourseTeachingDialog.value.showDialog = true |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 编辑课程教学大纲 |
|
||||
* @param data |
|
||||
*/ |
|
||||
const editEvent = (data: any) => { |
|
||||
editLessonCourseTeachingDialog.value.setFormData(data) |
|
||||
editLessonCourseTeachingDialog.value.showDialog = true |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 获取跳绳教案库列表 |
|
||||
*/ |
|
||||
const loadJumpLessonLibraryList = (page: number = 1) => { |
|
||||
JumpLessonLibraryTable.loading = true |
|
||||
JumpLessonLibraryTable.page = page |
|
||||
|
|
||||
getPublicLibraryList({ |
|
||||
page: JumpLessonLibraryTable.page, |
|
||||
limit: JumpLessonLibraryTable.limit, |
|
||||
...JumpLessonLibraryTable.searchParam, |
|
||||
}) |
|
||||
.then((res) => { |
|
||||
JumpLessonLibraryTable.loading = false |
|
||||
JumpLessonLibraryTable.data = res.data.data |
|
||||
JumpLessonLibraryTable.total = res.data.total |
|
||||
}) |
|
||||
.catch(() => { |
|
||||
JumpLessonLibraryTable.loading = false |
|
||||
}) |
|
||||
} |
|
||||
loadJumpLessonLibraryList() |
|
||||
|
|
||||
/** |
|
||||
* 添加跳绳教案库 |
|
||||
*/ |
|
||||
const addJumpLessonLibrary = () => { |
|
||||
editJumpLessonLibraryDialog.value.setFormData() |
|
||||
editJumpLessonLibraryDialog.value.showDialog = true |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 编辑跳绳教案库 |
|
||||
* @param data |
|
||||
*/ |
|
||||
const editJumpLessonLibrary = (data: any) => { |
|
||||
editJumpLessonLibraryDialog.value.setFormData(data) |
|
||||
editJumpLessonLibraryDialog.value.showDialog = true |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 获取增高教案库列表 |
|
||||
*/ |
|
||||
const loadEnTeachingLibraryList = (page: number = 1) => { |
|
||||
EnTeachingLibraryTable.loading = true |
|
||||
EnTeachingLibraryTable.page = page |
|
||||
|
|
||||
getPublicLibraryList({ |
|
||||
page: EnTeachingLibraryTable.page, |
|
||||
limit: EnTeachingLibraryTable.limit, |
|
||||
...EnTeachingLibraryTable.searchParam, |
|
||||
}) |
|
||||
.then((res) => { |
|
||||
EnTeachingLibraryTable.loading = false |
|
||||
EnTeachingLibraryTable.data = res.data.data |
|
||||
EnTeachingLibraryTable.total = res.data.total |
|
||||
}) |
|
||||
.catch(() => { |
|
||||
EnTeachingLibraryTable.loading = false |
|
||||
}) |
|
||||
} |
|
||||
loadEnTeachingLibraryList() |
|
||||
|
|
||||
/** |
|
||||
* 添加增高教案库 |
|
||||
*/ |
|
||||
const addEnTeachingLibrary = () => { |
|
||||
editEnTeachingLibraryDialog.value.setFormData() |
|
||||
editEnTeachingLibraryDialog.value.showDialog = true |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 编辑增高教案库 |
|
||||
* @param data |
|
||||
*/ |
|
||||
const editEnTeachingLibrary = (data: any) => { |
|
||||
editEnTeachingLibraryDialog.value.setFormData(data) |
|
||||
editEnTeachingLibraryDialog.value.showDialog = true |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 删除教研管理 |
|
||||
*/ |
|
||||
const deleteEvent = (id: number, type: number) => { |
|
||||
ElMessageBox.confirm(t('lessonCourseTeachingDeleteTips'), t('warning'), { |
|
||||
confirmButtonText: t('confirm'), |
|
||||
cancelButtonText: t('cancel'), |
|
||||
type: 'warning', |
|
||||
}).then(() => { |
|
||||
deleteLessonCourseTeaching(id) |
|
||||
.then(() => { |
|
||||
if (type === 13) { |
|
||||
loadLessonCourseTeachingList() |
|
||||
} else if (type === 14) { |
|
||||
loadJumpLessonLibraryList() |
|
||||
} else if (type === 15) { |
|
||||
loadEnTeachingLibraryList() |
|
||||
} |
|
||||
}) |
|
||||
.catch(() => {}) |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
const userPermissionList = ref([]) |
|
||||
const setUserPermissionList = async () => { |
|
||||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|
||||
} |
|
||||
setUserPermissionList() |
|
||||
|
|
||||
const resetForm = (formEl: FormInstance | undefined, type: number) => { |
|
||||
if (!formEl) return |
|
||||
formEl.resetFields() |
|
||||
if (type === 13) { |
|
||||
lessonCourseTeachingTable = reactive({ |
|
||||
page: 1, |
|
||||
limit: 10, |
|
||||
total: 0, |
|
||||
loading: true, |
|
||||
data: [], |
|
||||
searchParam: { |
|
||||
title: '', |
|
||||
status: '', |
|
||||
create_time: [], |
|
||||
update_time: [], |
|
||||
table_type: 13, |
|
||||
}, |
|
||||
}) |
|
||||
loadLessonCourseTeachingList() |
|
||||
} else if (type === 14) { |
|
||||
JumpLessonLibraryTable = reactive({ |
|
||||
page: 1, |
|
||||
limit: 10, |
|
||||
total: 0, |
|
||||
loading: true, |
|
||||
data: [], |
|
||||
searchParam: { |
|
||||
title: '', |
|
||||
status: '', |
|
||||
create_time: [], |
|
||||
update_time: [], |
|
||||
table_type: 14, |
|
||||
}, |
|
||||
}) |
|
||||
loadJumpLessonLibraryList() |
|
||||
} else if (type === 15) { |
|
||||
EnTeachingLibraryTable = reactive({ |
|
||||
page: 1, |
|
||||
limit: 10, |
|
||||
total: 0, |
|
||||
loading: true, |
|
||||
data: [], |
|
||||
searchParam: { |
|
||||
title: '', |
|
||||
status: '', |
|
||||
create_time: [], |
|
||||
update_time: [], |
|
||||
table_type: 15, |
|
||||
}, |
|
||||
}) |
|
||||
loadEnTeachingLibraryList() |
|
||||
} |
|
||||
} |
|
||||
</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,486 @@ |
|||||
|
<template> |
||||
|
<div class="seat-selector"> |
||||
|
<div class="seats-container"> |
||||
|
<div v-if="rows.length === 0" class="no-seats-message"> |
||||
|
没有可用座位,请确认场地容量设置 |
||||
|
</div> |
||||
|
<div v-else v-for="row in rows" :key="row" class="seat-row"> |
||||
|
<div |
||||
|
v-for="col in cols" |
||||
|
:key="`${row}-${col}`" |
||||
|
class="seat-container" |
||||
|
> |
||||
|
<div |
||||
|
class="seat" |
||||
|
:class="{ |
||||
|
'seat-available': isSeatAvailable(row, col), |
||||
|
'seat-occupied': !isSeatAvailable(row, col) && isSeatValid(row, col), |
||||
|
'seat-selected': isSelected(row, col), |
||||
|
'seat-hidden': !isSeatValid(row, col) |
||||
|
}" |
||||
|
@click="toggleSeat(row, col)" |
||||
|
> |
||||
|
{{ col }} |
||||
|
</div> |
||||
|
<div v-if="isSelected(row, col)" class="seat-name"> |
||||
|
{{ getSeatObject(row, col)?.name || '' }} |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="seat-legend"> |
||||
|
<div class="legend-item"> |
||||
|
<div class="legend-box seat-available"></div> |
||||
|
<span>可选</span> |
||||
|
</div> |
||||
|
<div class="legend-item"> |
||||
|
<div class="legend-box seat-occupied"></div> |
||||
|
<span>已占</span> |
||||
|
</div> |
||||
|
<div class="legend-item"> |
||||
|
<div class="legend-box seat-selected"></div> |
||||
|
<span>已选</span> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="seat-info"> |
||||
|
<span>已选: {{ selectedSeats.length }}/{{ props.maxSelections === Infinity ? '不限' : props.maxSelections }}</span> |
||||
|
<span>剩余空位: {{ availableSeats.length }}</span> |
||||
|
</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script setup> |
||||
|
import { ref, computed, watch, onMounted } from 'vue'; |
||||
|
import { getClassroompeople } from '@/app/api/classroom'; |
||||
|
import { getAllVenueList } from '@/app/api/venue'; |
||||
|
|
||||
|
const props = defineProps({ |
||||
|
venueId: { |
||||
|
type: [Number, String], |
||||
|
default: null |
||||
|
}, |
||||
|
capacity: { |
||||
|
type: Number, |
||||
|
default: 0 |
||||
|
}, |
||||
|
occupiedSeats: { |
||||
|
type: Array, |
||||
|
default: () => [] |
||||
|
}, |
||||
|
selectedSeatIds: { |
||||
|
type: Array, |
||||
|
default: () => [] |
||||
|
}, |
||||
|
maxSelections: { |
||||
|
type: Number, |
||||
|
default: Infinity |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
const emit = defineEmits(['update:selectedSeats', 'change', 'update:selectedSeatIds']); |
||||
|
|
||||
|
// 位置布局配置 |
||||
|
const rows = ref([]); |
||||
|
const cols = ref([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // 固定每行10个座位 |
||||
|
const selectedSeats = ref([]); |
||||
|
const occupiedSeatsData = ref([]); |
||||
|
const selectedSeatObjects = ref([]); |
||||
|
const totalSeats = ref(0); |
||||
|
|
||||
|
// 调整位置行列数以匹配容量 - 不再使用该函数,因为我们在onMounted和watch中直接设置了 |
||||
|
const adjustLayout = (capacityValue) => { |
||||
|
console.log('已废弃的adjustLayout调用,使用值:', capacityValue); |
||||
|
}; |
||||
|
|
||||
|
// 加载场地信息和已占用位置数据 |
||||
|
const loadVenueInfoAndOccupiedSeats = async () => { |
||||
|
if (!props.venueId) return; |
||||
|
|
||||
|
try { |
||||
|
// 如果有传入的已占用位置,直接使用 |
||||
|
if (props.occupiedSeats && props.occupiedSeats.length) { |
||||
|
occupiedSeatsData.value = props.occupiedSeats; |
||||
|
} else { |
||||
|
// 否则尝试从API获取 |
||||
|
const response = await getClassroompeople(props.venueId); |
||||
|
if (response.data && Array.isArray(response.data)) { |
||||
|
// 假设API返回的是已占用位置的数组 |
||||
|
occupiedSeatsData.value = response.data; |
||||
|
} |
||||
|
} |
||||
|
} catch (error) { |
||||
|
console.error('获取已占用位置失败:', error); |
||||
|
// 模拟一些随机占用的位置 |
||||
|
occupiedSeatsData.value = generateRandomOccupiedSeats(); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
// 生成一些随机占用的位置(用于演示) |
||||
|
const generateRandomOccupiedSeats = () => { |
||||
|
const occupied = []; |
||||
|
const totalSeats = rows.value.length * cols.value.length; |
||||
|
const occupiedCount = Math.floor(totalSeats * 0.3); // 30%的座位被占用 |
||||
|
|
||||
|
for (let i = 0; i < occupiedCount; i++) { |
||||
|
const row = rows.value[Math.floor(Math.random() * rows.value.length)]; |
||||
|
const col = cols.value[Math.floor(Math.random() * cols.value.length)]; |
||||
|
const seat = `${row}-${col}`; |
||||
|
if (!occupied.includes(seat)) { |
||||
|
occupied.push(seat); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return occupied; |
||||
|
}; |
||||
|
|
||||
|
// 计算所有有效座位 |
||||
|
const allValidSeats = computed(() => { |
||||
|
const seats = []; |
||||
|
if (rows.value.length === 0) return seats; |
||||
|
|
||||
|
rows.value.forEach(row => { |
||||
|
cols.value.forEach(col => { |
||||
|
if (isSeatValid(row, col)) { |
||||
|
const seatId = `${row}-${col}`; |
||||
|
seats.push(seatId); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
return seats; |
||||
|
}); |
||||
|
|
||||
|
// 计算可用座位(未被占用的有效座位) |
||||
|
const availableSeats = computed(() => { |
||||
|
const seats = []; |
||||
|
|
||||
|
allValidSeats.value.forEach(seatId => { |
||||
|
if (!occupiedSeatsData.value.includes(seatId)) { |
||||
|
seats.push(seatId); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
console.log('有效座位总数:', allValidSeats.value.length); |
||||
|
console.log('已占用座位数:', occupiedSeatsData.value.length); |
||||
|
console.log('可用座位数:', seats.length); |
||||
|
console.log('已选座位数:', selectedSeats.value.length); |
||||
|
|
||||
|
return seats; |
||||
|
}); |
||||
|
|
||||
|
// 检查座位是否有效(在总座位数范围内) |
||||
|
const isSeatValid = (row, col) => { |
||||
|
const seatIndex = (row.charCodeAt(0) - 65) * 10 + (col - 1); |
||||
|
return seatIndex < totalSeats.value; |
||||
|
}; |
||||
|
|
||||
|
// 检查座位是否可用(未被占用且有效) |
||||
|
const isSeatAvailable = (row, col) => { |
||||
|
// 先检查座位是否有效 |
||||
|
if (!isSeatValid(row, col)) { |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
const seatId = `${row}-${col}`; |
||||
|
return !occupiedSeatsData.value.includes(seatId); |
||||
|
}; |
||||
|
|
||||
|
// 检查座位是否被选中 |
||||
|
const isSelected = (row, col) => { |
||||
|
const seatId = `${row}-${col}`; |
||||
|
return selectedSeats.value.includes(seatId); |
||||
|
}; |
||||
|
|
||||
|
// 获取座位对应的选中对象 |
||||
|
const getSeatObject = (row, col) => { |
||||
|
const seatId = `${row}-${col}`; |
||||
|
return selectedSeatObjects.value.find(obj => obj.id === seatId); |
||||
|
}; |
||||
|
|
||||
|
// 切换座位选择状态 |
||||
|
const toggleSeat = (row, col) => { |
||||
|
console.log('点击座位:', row, col); |
||||
|
|
||||
|
// 检查座位是否有效 |
||||
|
if (!isSeatValid(row, col)) { |
||||
|
console.log('座位无效,不能选择'); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
const seatId = `${row}-${col}`; |
||||
|
|
||||
|
// 检查座位是否可用 |
||||
|
if (!isSeatAvailable(row, col)) { |
||||
|
console.log('座位已占用,不能选择'); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
const index = selectedSeats.value.indexOf(seatId); |
||||
|
if (index === -1) { |
||||
|
// 检查是否已达到最大选择数量 |
||||
|
if (selectedSeats.value.length >= props.maxSelections) { |
||||
|
console.log('已达到最大选择数量:', props.maxSelections); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
console.log('添加座位:', seatId); |
||||
|
selectedSeats.value.push(seatId); |
||||
|
|
||||
|
// 检查是否有对应的外部选中对象,没有则创建一个新的 |
||||
|
if (!selectedSeatObjects.value.some(obj => obj.id === seatId)) { |
||||
|
selectedSeatObjects.value.push({ id: seatId, name: '' }); |
||||
|
} |
||||
|
} else { |
||||
|
console.log('移除座位:', seatId); |
||||
|
selectedSeats.value.splice(index, 1); |
||||
|
|
||||
|
// 移除对应的外部选中对象 |
||||
|
const objIndex = selectedSeatObjects.value.findIndex(obj => obj.id === seatId); |
||||
|
if (objIndex !== -1) { |
||||
|
selectedSeatObjects.value.splice(objIndex, 1); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
console.log('选中座位:', selectedSeats.value); |
||||
|
emit('update:selectedSeats', selectedSeats.value); |
||||
|
emit('update:selectedSeatIds', selectedSeatObjects.value); |
||||
|
emit('change', selectedSeats.value); |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
|
||||
|
// 添加场地列表数据 |
||||
|
const venueList = ref([]); |
||||
|
|
||||
|
// 加载场地列表 |
||||
|
const loadVenueList = async () => { |
||||
|
try { |
||||
|
const response = await getAllVenueList({}); |
||||
|
if (response.data && Array.isArray(response.data)) { |
||||
|
venueList.value = response.data; |
||||
|
} |
||||
|
} catch (error) { |
||||
|
console.error('获取场地列表失败:', error); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
// 获取当前场地信息 |
||||
|
const getCurrentVenueInfo = () => { |
||||
|
const venue = venueList.value.find(venue => venue.id === props.venueId) || null; |
||||
|
console.log('获取场地信息:', venue, '场地ID:', props.venueId, '场地列表:', venueList.value); |
||||
|
return venue; |
||||
|
}; |
||||
|
|
||||
|
// 监听属性变化 |
||||
|
watch(() => props.venueId, async () => { |
||||
|
console.log('监听venueId变化:', props.venueId); |
||||
|
selectedSeats.value = []; |
||||
|
selectedSeatObjects.value = []; |
||||
|
|
||||
|
// 重新设置座位布局 |
||||
|
if (props.capacity) { |
||||
|
console.log('使用props容量:', props.capacity); |
||||
|
totalSeats.value = props.capacity; |
||||
|
const rowCount = Math.ceil(props.capacity / 10); |
||||
|
rows.value = Array.from({ length: rowCount }, (_, i) => |
||||
|
String.fromCharCode(65 + i) |
||||
|
).slice(0, 26); |
||||
|
} else { |
||||
|
// 设置默认值 |
||||
|
totalSeats.value = 30; |
||||
|
const rowCount = 3; |
||||
|
rows.value = Array.from({ length: rowCount }, (_, i) => |
||||
|
String.fromCharCode(65 + i) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
console.log('更新布局 - 总座位数:', totalSeats.value, '行数:', rows.value.length); |
||||
|
|
||||
|
// 加载已占用座位 |
||||
|
loadVenueInfoAndOccupiedSeats(); |
||||
|
}); |
||||
|
|
||||
|
// 监听容量变化 |
||||
|
watch(() => props.capacity, (newCapacity) => { |
||||
|
console.log('监听capacity变化:', newCapacity); |
||||
|
|
||||
|
// 更新座位布局 |
||||
|
if (newCapacity || newCapacity === 0) { |
||||
|
totalSeats.value = newCapacity; |
||||
|
const rowCount = Math.ceil(newCapacity / 10); |
||||
|
rows.value = Array.from({ length: rowCount }, (_, i) => |
||||
|
String.fromCharCode(65 + i) |
||||
|
).slice(0, 26); |
||||
|
console.log('根据新容量更新布局 - 总座位数:', totalSeats.value, '行数:', rows.value.length); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
watch(() => props.occupiedSeats, () => { |
||||
|
occupiedSeatsData.value = props.occupiedSeats; |
||||
|
}); |
||||
|
|
||||
|
// 监听外部传入的selectedSeatIds变化 |
||||
|
watch(() => props.selectedSeatIds, (newValue) => { |
||||
|
if (newValue && Array.isArray(newValue)) { |
||||
|
selectedSeatObjects.value = [...newValue]; |
||||
|
selectedSeats.value = newValue.map(item => item.id); |
||||
|
} |
||||
|
}, { immediate: true }); |
||||
|
|
||||
|
// 组件挂载时初始化 |
||||
|
onMounted(async () => { |
||||
|
console.log('组件挂载 - venueId:', props.venueId, 'capacity:', props.capacity); |
||||
|
|
||||
|
// 确保有默认值 |
||||
|
if (!props.capacity && props.capacity !== 0) { |
||||
|
totalSeats.value = 30; |
||||
|
// 生成默认行数 |
||||
|
const rowCount = Math.ceil(totalSeats.value / 10); |
||||
|
rows.value = Array.from({ length: rowCount }, (_, i) => |
||||
|
String.fromCharCode(65 + i) |
||||
|
); |
||||
|
console.log('使用默认设置 - 总座位数:', totalSeats.value, '行数:', rows.value.length); |
||||
|
} else { |
||||
|
console.log('使用props容量:', props.capacity); |
||||
|
totalSeats.value = props.capacity; |
||||
|
// 计算需要的行数 |
||||
|
const rowCount = Math.ceil(props.capacity / 10); |
||||
|
// 生成行标识 |
||||
|
rows.value = Array.from({ length: rowCount }, (_, i) => |
||||
|
String.fromCharCode(65 + i) |
||||
|
).slice(0, 26); |
||||
|
console.log('根据容量设置 - 总座位数:', totalSeats.value, '行数:', rows.value.length); |
||||
|
} |
||||
|
|
||||
|
// 加载已占用座位 |
||||
|
loadVenueInfoAndOccupiedSeats(); |
||||
|
}); |
||||
|
</script> |
||||
|
|
||||
|
<style scoped> |
||||
|
.seat-selector { |
||||
|
width: 100%; |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
align-items: center; |
||||
|
padding: 20px; |
||||
|
} |
||||
|
|
||||
|
.screen { |
||||
|
width: 80%; |
||||
|
height: 30px; |
||||
|
background: linear-gradient(to bottom, #ccc, #f5f5f5); |
||||
|
margin-bottom: 30px; |
||||
|
display: flex; |
||||
|
justify-content: center; |
||||
|
align-items: center; |
||||
|
border-radius: 5px; |
||||
|
} |
||||
|
|
||||
|
.screen-text { |
||||
|
font-size: 14px; |
||||
|
color: #666; |
||||
|
} |
||||
|
|
||||
|
.seats-container { |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
gap: 10px; |
||||
|
margin-bottom: 20px; |
||||
|
} |
||||
|
|
||||
|
.seat-row { |
||||
|
display: flex; |
||||
|
align-items: flex-start; |
||||
|
gap: 10px; |
||||
|
} |
||||
|
|
||||
|
.row-label { |
||||
|
width: 20px; |
||||
|
text-align: center; |
||||
|
font-weight: bold; |
||||
|
margin-top: 10px; |
||||
|
} |
||||
|
|
||||
|
.seat-container { |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
align-items: center; |
||||
|
gap: 3px; |
||||
|
margin-bottom: 5px; |
||||
|
} |
||||
|
|
||||
|
.seat { |
||||
|
width: 30px; |
||||
|
height: 30px; |
||||
|
display: flex; |
||||
|
justify-content: center; |
||||
|
align-items: center; |
||||
|
border-radius: 5px; |
||||
|
cursor: pointer; |
||||
|
font-size: 12px; |
||||
|
transition: all 0.2s; |
||||
|
} |
||||
|
|
||||
|
.seat-name { |
||||
|
font-size: 10px; |
||||
|
max-width: 40px; |
||||
|
text-align: center; |
||||
|
word-break: break-all; |
||||
|
color: #333; |
||||
|
height: 24px; |
||||
|
overflow: hidden; |
||||
|
} |
||||
|
|
||||
|
.seat-available { |
||||
|
background-color: #67c23a; |
||||
|
color: white; |
||||
|
} |
||||
|
|
||||
|
.seat-occupied { |
||||
|
background-color: #909399; |
||||
|
color: white; |
||||
|
cursor: not-allowed; |
||||
|
} |
||||
|
|
||||
|
.seat-selected { |
||||
|
background-color: #409eff; |
||||
|
color: white; |
||||
|
} |
||||
|
|
||||
|
.seat-hidden { |
||||
|
visibility: hidden; |
||||
|
pointer-events: none; |
||||
|
} |
||||
|
|
||||
|
.seat-legend { |
||||
|
display: flex; |
||||
|
gap: 20px; |
||||
|
margin-bottom: 15px; |
||||
|
} |
||||
|
|
||||
|
.legend-item { |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
gap: 5px; |
||||
|
} |
||||
|
|
||||
|
.legend-box { |
||||
|
width: 15px; |
||||
|
height: 15px; |
||||
|
border-radius: 3px; |
||||
|
} |
||||
|
|
||||
|
.seat-info { |
||||
|
display: flex; |
||||
|
gap: 20px; |
||||
|
font-size: 14px; |
||||
|
} |
||||
|
|
||||
|
.no-seats-message { |
||||
|
font-size: 14px; |
||||
|
color: #666; |
||||
|
padding: 20px; |
||||
|
text-align: center; |
||||
|
} |
||||
|
</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 |
||||
|
} |
||||
@ -1,65 +0,0 @@ |
|||||
<?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 -- campus |
|
||||
|
|
||||
Route::group('campus', function () { |
|
||||
|
|
||||
//校区列表 |
|
||||
Route::get('campus', 'campus.Campus/lists'); |
|
||||
//校区详情 |
|
||||
Route::get('campus/:id', 'campus.Campus/info'); |
|
||||
//添加校区 |
|
||||
Route::post('campus', 'campus.Campus/add'); |
|
||||
//编辑校区 |
|
||||
Route::put('campus/:id', 'campus.Campus/edit'); |
|
||||
//删除校区 |
|
||||
Route::delete('campus/:id', 'campus.Campus/del'); |
|
||||
|
|
||||
})->middleware([ |
|
||||
AdminCheckToken::class, |
|
||||
AdminCheckRole::class, |
|
||||
AdminLog::class |
|
||||
]); |
|
||||
// USER_CODE_END -- campus |
|
||||
|
|
||||
// USER_CODE_BEGIN -- class |
|
||||
|
|
||||
Route::group('class', function () { |
|
||||
|
|
||||
//场地管理列表 |
|
||||
Route::get('class', 'class.Class/lists'); |
|
||||
//场地管理详情 |
|
||||
Route::get('class/:id', 'class.Class/info'); |
|
||||
//添加场地管理 |
|
||||
Route::post('class', 'class.Class/add'); |
|
||||
//编辑场地管理 |
|
||||
Route::put('class/:id', 'class.Class/edit'); |
|
||||
//删除场地管理 |
|
||||
Route::delete('class/:id', 'class.Class/del'); |
|
||||
|
|
||||
Route::get('campus_all','class.Class/getCampusAll'); |
|
||||
|
|
||||
Route::get('personnel_all','class.Class/getPersonnelAll'); |
|
||||
|
|
||||
})->middleware([ |
|
||||
AdminCheckToken::class, |
|
||||
AdminCheckRole::class, |
|
||||
AdminLog::class |
|
||||
]); |
|
||||
// USER_CODE_END -- class |
|
||||
@ -0,0 +1,161 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\api\controller\apiController; |
||||
|
|
||||
|
use app\Request; |
||||
|
use app\service\admin\campus\CampusService; |
||||
|
use app\service\api\apiService\AttendanceService; |
||||
|
use app\service\api\apiService\CommonService; |
||||
|
use core\base\BaseApiService; |
||||
|
|
||||
|
/** |
||||
|
* 员工考勤控制器相关接口 |
||||
|
* Class Personnel |
||||
|
* @package app\api\controller\apiController |
||||
|
*/ |
||||
|
class Attendance extends BaseApiService |
||||
|
{ |
||||
|
|
||||
|
//列表 |
||||
|
public function index(Request $request){ |
||||
|
|
||||
|
$where = [ |
||||
|
'campus_id' => $request->param('campus_id', ''),// |
||||
|
'staff_id' => $request->param('staff_id', ''),// |
||||
|
'attendance_date' => $request->param('attendance_date', ''),// |
||||
|
'status' => $request->param('status', ''),// |
||||
|
'status_arr' => $request->param('status_arr', []),// |
||||
|
]; |
||||
|
|
||||
|
$res = (new AttendanceService())->getList($where); |
||||
|
return success($res); |
||||
|
} |
||||
|
|
||||
|
//员工考勤-编辑(员工打卡/请假/签退) |
||||
|
public function edit(Request $request){ |
||||
|
$campus_id =$request->param('campus_id','');//校区ID |
||||
|
$staff_id =$this->member_id;//人员ID |
||||
|
$attendance_date =$request->param('attendance_date','');//考勤日期 |
||||
|
$remarks =$request->param('remarks','');//备注 |
||||
|
$status =$request->param('status','');//考勤状态: present-出勤, absent-缺勤, late-迟到, leave_early-早退,leave-请假,sign_out-签退 |
||||
|
$longitude = $request->param('longitude','');//经度 |
||||
|
$latitude = $request->param('latitude','');//纬度 |
||||
|
$coordinate = '';//坐标 |
||||
|
if(!empty($longitude) && !empty($latitude)){ |
||||
|
$coordinate = "{$longitude},{$latitude}"; |
||||
|
}else{ |
||||
|
return fail('缺少定位坐标'); |
||||
|
} |
||||
|
|
||||
|
if(empty($campus_id) || empty($attendance_date) || empty($status)){ |
||||
|
return fail('缺少参数'); |
||||
|
} |
||||
|
if(!in_array($status,['present','absent','late','leave_early','leave','sign_out'])){ |
||||
|
return fail('状态类型不正确'); |
||||
|
} |
||||
|
|
||||
|
//获取校区的经纬度坐标 |
||||
|
$campus_data = (new CampusService)->getInfo($campus_id);//查校区详情 |
||||
|
$campus_lng = $campus_data['campus_coordinates']['lng'];//校区经度坐标 |
||||
|
$campus_lat = $campus_data['campus_coordinates']['lat'];//校区纬度坐标 |
||||
|
$radius = 1500.0;//打卡半径(米) |
||||
|
|
||||
|
//判断签到+签退时是否超出打卡范围 |
||||
|
if(in_array($status,['present','sign_out'])){ |
||||
|
$isInCheckRange = (new CommonService())->isInCheckRange((float)$campus_lng, (float)$campus_lat, (float)$longitude, (float)$latitude, (float)$radius); |
||||
|
if(!$isInCheckRange){ |
||||
|
return fail("超出打卡范围,规定打卡范围({$radius}米)"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
//查询数据是否存在,一天一个校区同一个人只能产生一条数据 |
||||
|
$date_h = date('H:i:s'); |
||||
|
|
||||
|
$obj = (new AttendanceService()); |
||||
|
$info = $obj->info([ |
||||
|
'campus_id'=>$campus_id, |
||||
|
'staff_id'=>$staff_id, |
||||
|
'attendance_date'=>$attendance_date, |
||||
|
])['data']; |
||||
|
|
||||
|
//如果是签退的时候就是修改 |
||||
|
if($status == 'sign_out'){ |
||||
|
|
||||
|
if (($info['status'] ?? '') != 'present') { |
||||
|
return fail('未查询到今日签到信息,无法签退'); |
||||
|
} |
||||
|
|
||||
|
//签退的情况 |
||||
|
$where = [ |
||||
|
'id'=>$info['id'] |
||||
|
]; |
||||
|
$data = [ |
||||
|
'check_out_time'=>$date_h,//签退时间 |
||||
|
'coordinate'=>$coordinate,//坐标|经度,纬度 |
||||
|
]; |
||||
|
//执行修改操作 |
||||
|
$res = $obj->editData($where,$data); |
||||
|
}else{ |
||||
|
//如果是签到/请假 |
||||
|
$data = [ |
||||
|
'campus_id'=>$campus_id,//校区ID |
||||
|
'staff_id'=>$staff_id,//人员ID |
||||
|
'attendance_date'=>$attendance_date,//考勤日期 |
||||
|
'coordinate'=>$coordinate,//坐标|经度,纬度 |
||||
|
'status'=>$status,//考勤状态 |
||||
|
]; |
||||
|
//如果是签到的情况 |
||||
|
if($info){ |
||||
|
if($status == 'present' && $info['status'] == 'present'){ |
||||
|
//更新签到数据 |
||||
|
//执行修改操作 |
||||
|
$edit_data = [ |
||||
|
'check_in_time'=>$date_h,//签到时间 |
||||
|
'coordinate'=>$coordinate,//坐标|经度,纬度 |
||||
|
'status'=>$status//考勤状态 |
||||
|
]; |
||||
|
$res = $obj->editData(['id'=>$info['id']],$edit_data); |
||||
|
if(!$res['code']){ |
||||
|
return fail($res['msg']); |
||||
|
} |
||||
|
return success($res['data']); |
||||
|
} |
||||
|
$status_arr = (new \app\model\attendance\Attendance())::STATUS; |
||||
|
$status_name = $status_arr[$info['status']] ?? ''; |
||||
|
if(!$status_name){ |
||||
|
$status_name = '考勤'; |
||||
|
} |
||||
|
return fail("今日已{$status_name}重复操作"); |
||||
|
}else{ |
||||
|
$data['check_in_time'] = $date_h;//签到时间 |
||||
|
if($remarks){ |
||||
|
$data['remarks'] = $remarks; |
||||
|
} |
||||
|
//执行创建操作 |
||||
|
$res = $obj->addData($data); |
||||
|
if(!$res['code']){ |
||||
|
return fail($res['msg']); |
||||
|
} |
||||
|
return success($res['data']); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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 = 'deleted_at'; |
||||
|
/** |
||||
|
* 定义软删除字段的默认值. |
||||
|
* @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 = 'deleted_at'; |
||||
|
/** |
||||
|
* 定义软删除字段的默认值. |
||||
|
* @var int |
||||
|
*/ |
||||
|
protected $defaultSoftDelete = 0; |
||||
|
|
||||
|
} |
||||
@ -1,148 +0,0 @@ |
|||||
<?php |
|
||||
// +---------------------------------------------------------------------- |
|
||||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|
||||
// +---------------------------------------------------------------------- |
|
||||
// | 官方网址:https://www.niucloud.com |
|
||||
// +---------------------------------------------------------------------- |
|
||||
// | niucloud团队 版权所有 开源版本可自由商用 |
|
||||
// +---------------------------------------------------------------------- |
|
||||
// | Author: Niucloud Team |
|
||||
// +---------------------------------------------------------------------- |
|
||||
|
|
||||
namespace app\model\classroom; |
|
||||
|
|
||||
use core\base\BaseModel; |
|
||||
use think\model\concern\SoftDelete; |
|
||||
use think\model\relation\HasMany; |
|
||||
use think\model\relation\HasOne; |
|
||||
use app\model\campus\Campus; |
|
||||
use app\model\personnel\Personnel; |
|
||||
|
|
||||
|
|
||||
/** |
|
||||
* 场地管理模型 |
|
||||
* Class Classroom |
|
||||
* @package app\model\classroom |
|
||||
*/ |
|
||||
class Classroom extends BaseModel |
|
||||
{ |
|
||||
|
|
||||
use SoftDelete; |
|
||||
|
|
||||
/** |
|
||||
* 数据表主键 |
|
||||
* @var string |
|
||||
*/ |
|
||||
protected $pk = 'id'; |
|
||||
|
|
||||
/** |
|
||||
* 模型名称 |
|
||||
* @var string |
|
||||
*/ |
|
||||
protected $name = 'class'; |
|
||||
|
|
||||
/** |
|
||||
* 定义软删除标记字段. |
|
||||
* @var string |
|
||||
*/ |
|
||||
protected $deleteTime = 'deleted_at'; |
|
||||
|
|
||||
/** |
|
||||
* 定义软删除字段的默认值. |
|
||||
* @var int |
|
||||
*/ |
|
||||
protected $defaultSoftDelete = 0; |
|
||||
|
|
||||
/** |
|
||||
* 搜索器:场地管理所属校区 |
|
||||
* @param $value |
|
||||
* @param $data |
|
||||
*/ |
|
||||
public function searchCampusIdAttr($query, $value, $data) |
|
||||
{ |
|
||||
if ($value) { |
|
||||
$query->where("campus_id", $value); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 搜索器:场地管理班级名称 |
|
||||
* @param $value |
|
||||
* @param $data |
|
||||
*/ |
|
||||
public function searchClassNameAttr($query, $value, $data) |
|
||||
{ |
|
||||
if ($value) { |
|
||||
$query->where("class_name", $value); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 搜索器:场地管理主教练 |
|
||||
* @param $value |
|
||||
* @param $data |
|
||||
*/ |
|
||||
public function searchHeadCoachAttr($query, $value, $data) |
|
||||
{ |
|
||||
if ($value) { |
|
||||
$query->where("head_coach", $value); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 搜索器:场地管理班级类型 |
|
||||
* @param $value |
|
||||
* @param $data |
|
||||
*/ |
|
||||
public function searchClassTypeAttr($query, $value, $data) |
|
||||
{ |
|
||||
if ($value) { |
|
||||
$query->where("class_type", $value); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 搜索器:场地管理助教 |
|
||||
* @param $value |
|
||||
* @param $data |
|
||||
*/ |
|
||||
public function searchAssistantCoachAttr($query, $value, $data) |
|
||||
{ |
|
||||
if ($value) { |
|
||||
$query->where("assistant_coach", $value); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 搜索器:场地管理创建时间 |
|
||||
* @param $value |
|
||||
* @param $data |
|
||||
*/ |
|
||||
public function searchCreatedAtAttr($query, $value, $data) |
|
||||
{ |
|
||||
if ($value) { |
|
||||
$query->where("created_at", $value); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 搜索器:场地管理班级状态 |
|
||||
* @param $value |
|
||||
* @param $data |
|
||||
*/ |
|
||||
public function searchStatusAttr($query, $value, $data) |
|
||||
{ |
|
||||
if ($value) { |
|
||||
$query->where("status", $value); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public function campus(){ |
|
||||
return $this->hasOne(Campus::class, 'id', 'campus_id')->joinType('left')->withField('campus_name,id')->bind(['campus_id_name'=>'campus_name']); |
|
||||
} |
|
||||
|
|
||||
public function personnel(){ |
|
||||
return $this->hasOne(Personnel::class, 'id', 'head_coach')->joinType('left')->withField('name,id')->bind(['head_coach_name'=>'name']); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -0,0 +1,32 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace app\model\rel; |
||||
|
|
||||
|
use app\model\personnel\Personnel; |
||||
|
use app\model\student\Student; |
||||
|
use core\base\BaseModel; |
||||
|
|
||||
|
class ClassPersonnelRel extends BaseModel |
||||
|
{ |
||||
|
/** |
||||
|
* 数据表主键 |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $pk = 'id'; |
||||
|
|
||||
|
/** |
||||
|
* 模型名称 |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $name = 'class_personnel_rel'; |
||||
|
|
||||
|
public function personnel() |
||||
|
{ |
||||
|
return $this->hasOne(Personnel::class, 'id', 'personnel_id'); |
||||
|
} |
||||
|
|
||||
|
public function student() |
||||
|
{ |
||||
|
return $this->hasOne(Student::class, 'id', 'source_id'); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,156 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\service\api\apiService; |
||||
|
|
||||
|
use app\model\attendance\Attendance; |
||||
|
use core\base\BaseApiService; |
||||
|
|
||||
|
/** |
||||
|
* 考勤管理服务层 |
||||
|
* Class MemberService |
||||
|
* @package app\service\api\member |
||||
|
*/ |
||||
|
class AttendanceService extends BaseApiService |
||||
|
{ |
||||
|
public function __construct() |
||||
|
{ |
||||
|
parent::__construct(); |
||||
|
$this->model = (new Attendance()); |
||||
|
} |
||||
|
|
||||
|
//列表 |
||||
|
public function getList(array $where, string $field = '*') |
||||
|
{ |
||||
|
$page_params = $this->getPageParam();//获取请求参数中的页码+分页数 |
||||
|
$page = $page_params['page']; |
||||
|
$limit = $page_params['limit']; |
||||
|
|
||||
|
$model = $this->model; |
||||
|
|
||||
|
if (!empty($where['campus_id'])) { |
||||
|
$model = $model->where('campus_id', $where['campus_id']); |
||||
|
} |
||||
|
if (!empty($where['staff_id'])) { |
||||
|
$model = $model->where('staff_id', $where['staff_id']); |
||||
|
} |
||||
|
if (!empty($where['attendance_date'])) { |
||||
|
$model = $model->where('attendance_date', $where['attendance_date']); |
||||
|
} |
||||
|
if (!empty($where['status'])) { |
||||
|
$model = $model->where('status', $where['status']); |
||||
|
} |
||||
|
if (!empty($where['status_arr'])) { |
||||
|
$model = $model->whereIn('status', $where['status_arr']); |
||||
|
} |
||||
|
|
||||
|
$res = $model->with([ |
||||
|
'campus', |
||||
|
'personnel', |
||||
|
])->append([ |
||||
|
'status_name' |
||||
|
]) |
||||
|
->order('created_at','desc') |
||||
|
->paginate([ |
||||
|
'list_rows' => $limit, |
||||
|
'page' => $page, |
||||
|
])->toArray(); |
||||
|
return $res; |
||||
|
} |
||||
|
|
||||
|
//查询详情 |
||||
|
public function info(array $where, string $field = '*') |
||||
|
{ |
||||
|
$res = [ |
||||
|
'code' => 0, |
||||
|
'msg' => '操作失败', |
||||
|
'data' => [], |
||||
|
]; |
||||
|
if (empty($where)) { |
||||
|
$res['msg'] = '筛选条件不能唯空'; |
||||
|
return $res; |
||||
|
} |
||||
|
$model = $this->model; |
||||
|
if (!empty($where['id'])) { |
||||
|
$model = $model->where('id', $where['id']); |
||||
|
} |
||||
|
if (!empty($where['campus_id'])) { |
||||
|
$model = $model->where('campus_id', $where['campus_id']); |
||||
|
} |
||||
|
if (!empty($where['staff_id'])) { |
||||
|
$model = $model->where('staff_id', $where['staff_id']); |
||||
|
} |
||||
|
if (!empty($where['attendance_date'])) { |
||||
|
$model = $model->where('attendance_date', $where['attendance_date']); |
||||
|
} |
||||
|
$data = $model->field($field)->find(); |
||||
|
if ($data) { |
||||
|
$res = [ |
||||
|
'code' => 1, |
||||
|
'msg' => '操作成功', |
||||
|
'data' => $data->toArray(), |
||||
|
]; |
||||
|
} else { |
||||
|
$res['msg'] = '暂无数据'; |
||||
|
} |
||||
|
|
||||
|
return $res; |
||||
|
} |
||||
|
|
||||
|
//添加数据 |
||||
|
public function addData(array $data) |
||||
|
{ |
||||
|
|
||||
|
$add = $this->model->create($data); |
||||
|
if ($add) { |
||||
|
$res = [ |
||||
|
'code' => 1, |
||||
|
'msg' => '操作成功', |
||||
|
'data' => [], |
||||
|
]; |
||||
|
} else { |
||||
|
$res = [ |
||||
|
'code' => 0, |
||||
|
'msg' => '操作失败', |
||||
|
'data' => [], |
||||
|
]; |
||||
|
} |
||||
|
return $res; |
||||
|
} |
||||
|
|
||||
|
//编辑数据 |
||||
|
public function editData(array $where, array $data) |
||||
|
{ |
||||
|
|
||||
|
$data['updated_at'] = date('Y-m-d H:i:s'); |
||||
|
$model = $this->model; |
||||
|
if (!empty($where['id'])) { |
||||
|
$model = $model->where('id', $where['id']); |
||||
|
} |
||||
|
$edit = $model->update($data); |
||||
|
if ($edit) { |
||||
|
$res = [ |
||||
|
'code' => 1, |
||||
|
'msg' => '操作成功', |
||||
|
'data' => [], |
||||
|
]; |
||||
|
} else { |
||||
|
$res = [ |
||||
|
'code' => 0, |
||||
|
'msg' => '操作失败', |
||||
|
'data' => [], |
||||
|
]; |
||||
|
} |
||||
|
return $res; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -1,4 +1,8 @@ |
|||||
/.htaccess |
/.htaccess |
||||
upload |
upload |
||||
nginx.htaccess |
nginx.htaccess |
||||
.htaccess |
.htaccess |
||||
|
addon |
||||
|
admin |
||||
|
wap |
||||
|
web |
||||
|
|||||
@ -1 +0,0 @@ |
|||||
插件资源文件目录 |
|
||||
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 911 B |
|
Before Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 26 KiB |