|
@@ -1,14 +1,191 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
- 课程管理
|
|
|
- </div>
|
|
|
+
|
|
|
+<!-- 上层状态 -->
|
|
|
+
|
|
|
+ <!-- 模态框 -->
|
|
|
+ <n-modal v-model:show="showModal" block-scroll close-on-esc trap-focus>
|
|
|
+ <n-card style="width: 600px" title="添加班级" :bordered="false" size="huge" role="dialog" aria-modal="true">
|
|
|
+ <n-form ref="formRef" :model="model" :rules="rules">
|
|
|
+ <n-form-item path="name" label="班级名称">
|
|
|
+ <n-input v-model:value="model.name" @keydown.enter.prevent />
|
|
|
+ </n-form-item>
|
|
|
+ <n-row :gutter="[0, 24]">
|
|
|
+ <n-col :span="24">
|
|
|
+ <div style="display: flex; justify-content: flex-end">
|
|
|
+ <n-button :disabled="model.name === null" round type="primary" @click="handleValidateButtonClick">
|
|
|
+ 提交
|
|
|
+ </n-button>
|
|
|
+ </div>
|
|
|
+ </n-col>
|
|
|
+ </n-row>
|
|
|
+ </n-form>
|
|
|
+ </n-card>
|
|
|
+ </n-modal>
|
|
|
+
|
|
|
+ <n-grid x-gap="300" :cols="2">
|
|
|
+ <n-gi>
|
|
|
+ <n-input placeholder="搜索">
|
|
|
+ <template #prefix>
|
|
|
+ <n-icon :component="FlashOutline" />
|
|
|
+ </template>
|
|
|
+ </n-input>
|
|
|
+ </n-gi>
|
|
|
+ <n-gi>
|
|
|
+ <n-button type="primary" @click="showModal = true">
|
|
|
+ 添加
|
|
|
+ </n-button>
|
|
|
+ </n-gi>
|
|
|
+ </n-grid>
|
|
|
+
|
|
|
+ <!-- 表格 -->
|
|
|
+ <div>
|
|
|
+ <n-data-table :bordered="false" :single-line="false" :columns="columns" :data="data" :pagination="pagination" />
|
|
|
+ </div>
|
|
|
</template>
|
|
|
+<script lang="ts">
|
|
|
+import {
|
|
|
+ FormInst,
|
|
|
+ FormItemInst,
|
|
|
+ FormItemRule,
|
|
|
+ FormRules
|
|
|
+} from 'naive-ui'
|
|
|
+import { FlashOutline } from '@vicons/ionicons5'
|
|
|
+import { h, defineComponent } from 'vue'
|
|
|
+import { useMessage } from 'naive-ui'
|
|
|
+import { NButton } from 'naive-ui'
|
|
|
+import type { DataTableColumns } from 'naive-ui'
|
|
|
+import { selectTotal, addClass } from '~/src/service/api/lesson'
|
|
|
+import { ref } from 'vue'
|
|
|
+//获取所有班级类
|
|
|
+type RowData = {
|
|
|
+ id: number
|
|
|
+ name: string
|
|
|
+ manageId?: number
|
|
|
+ assistantId?: number
|
|
|
+ createTime: string
|
|
|
+ createUid?: number
|
|
|
+ modifyTime: string
|
|
|
+ disabled?: string
|
|
|
+}
|
|
|
+const tableData = ref([]);
|
|
|
+function getTableData() {
|
|
|
+ selectTotal().then(r => {
|
|
|
+ tableData.value = r.data;
|
|
|
+ })
|
|
|
+}
|
|
|
+getTableData();
|
|
|
|
|
|
-<script setup lang="ts">
|
|
|
+const createColumns = ({
|
|
|
+ sendMail
|
|
|
+}: {
|
|
|
+ sendMail: (rowData: RowData) => void
|
|
|
+}): DataTableColumns<RowData> => {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ title: '序号',
|
|
|
+ key: 'id'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '班级名称',
|
|
|
+ key: 'name'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '创建时间',
|
|
|
+ key: 'createTime'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '更改时间',
|
|
|
+ key: 'modifyTime'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ key: 'actions',
|
|
|
+ render(row) {
|
|
|
+ return h(
|
|
|
+ NButton,
|
|
|
+ {
|
|
|
+ size: 'small',
|
|
|
+ onClick: () => sendMail(row)
|
|
|
+ },
|
|
|
+ { default: () => '删除' }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+}
|
|
|
+//---|
|
|
|
|
|
|
-</script>
|
|
|
|
|
|
-<style scoped>
|
|
|
+//增加班级类
|
|
|
+type easEduClass={
|
|
|
+ id:number,
|
|
|
+ name:string,
|
|
|
+ manageId:number,
|
|
|
+ assistantId:number,
|
|
|
+ createTime:string,
|
|
|
+ modifyTime:string,
|
|
|
+ createUid:string,
|
|
|
+ disabled:string
|
|
|
+}
|
|
|
+addClass().then(r=>{
|
|
|
+ console.log(r);
|
|
|
+
|
|
|
+})
|
|
|
+export default defineComponent({
|
|
|
|
|
|
-</style>
|
|
|
+ setup() {
|
|
|
+ const showModal = ref(false);
|
|
|
+ const formRef = ref<FormInst | null>(null)
|
|
|
+ const rPasswordFormItemRef = ref<FormItemInst | null>(null)
|
|
|
+ const message = useMessage()
|
|
|
+ const modelRef = ref({
|
|
|
+ name: null,
|
|
|
+ })
|
|
|
+ const rules: FormRules = {
|
|
|
+ name: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ validator(rule: FormItemRule, value: string) {
|
|
|
+ if (!value) {
|
|
|
+ return new Error('需要班级名称')
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ },
|
|
|
+ trigger: ['input', 'blur']
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ formRef,
|
|
|
+ rPasswordFormItemRef,
|
|
|
+ model: modelRef,
|
|
|
+ rules,
|
|
|
+ handleValidateButtonClick() {
|
|
|
+ //点击添加
|
|
|
+ showModal.value = false;
|
|
|
+ message.success("添加成功");
|
|
|
+ modelRef.value.name = null;//清空表单值
|
|
|
|
|
|
+ },
|
|
|
+ showModal,
|
|
|
+ FlashOutline,
|
|
|
+ data: tableData,
|
|
|
+ columns: createColumns({
|
|
|
+ sendMail(rowData) {
|
|
|
+ message.info('send mail to ' + rowData.name)
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ pagination: {
|
|
|
+ pageSize: 10
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|
|
|
+</script>
|
|
|
+<style scoped>
|
|
|
+.n-grid{
|
|
|
+ /* display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center; */
|
|
|
+}
|
|
|
+</style>
|