diff --git a/src/api/student.ts b/src/api/student.ts index 42b36c3..d78e012 100644 --- a/src/api/student.ts +++ b/src/api/student.ts @@ -6,13 +6,34 @@ import { Res } from "@/utils/http/types"; * @description 导入表单 * @return {object} */ -export function ImportExamInfo(id: number, file: File) { +export function ImportTeacher(file: File) { let formData = new FormData(); - formData.append("eId", id.toString()); formData.append("file", file); return http.request( "post", - `ExamClassInfo/Import`, + `Student/ImportTeacher`, + { + data: formData + }, + { + headers: { + "Content-Type": "application/x-www-form-urlencoded" + }, + responseType: "blob" + } + ); +} + +/** + * @description 导入表单 + * @return {object} + */ +export function ImportStudent(file: File) { + let formData = new FormData(); + formData.append("file", file); + return http.request( + "post", + `Student/Import`, { data: formData }, @@ -36,7 +57,7 @@ export function EditStudent(data) { } /** - * @description 修改学生拓展信息 + * @description PageList * @return {object} */ export function PageList(data) { @@ -45,7 +66,7 @@ export function PageList(data) { }); } /** - * @description 获取学生拓展信息 + * @description StudentInfo * @return {object} */ export function StudentInfo(uid) { diff --git a/src/views/class/index.vue b/src/views/class/index.vue index 6adb60e..228e376 100644 --- a/src/views/class/index.vue +++ b/src/views/class/index.vue @@ -9,7 +9,7 @@ import { ruleRequired } from "@/utils/rules"; const ControllerName = "classes"; defineOptions({ - name: ControllerName + name: ControllerName, }); const SchoolApi = new hTableAPI("usercenter/back/schools"); @@ -28,7 +28,7 @@ const tableData: TableConfig = { PageSize: 20, OrderBy: "CreateTime", // 排序 defaultConditions: [], // 默认查询条件 - Conditions: [] + Conditions: [], }, operationColumn: true, // 显示操作按钮 operationColumnData: [ @@ -36,7 +36,7 @@ const tableData: TableConfig = { // 操作按钮 topBtn: false, // 是头部按钮 label: "修改", - btnType: "edit" // 按钮类型 add edit del custom + btnType: "edit", // 按钮类型 add edit del custom }, { topBtn: true, // 头部按钮 @@ -48,16 +48,16 @@ const tableData: TableConfig = { title: "新增班级", // 弹出框title src: "class/edit", // 组件路径 width: "550px", // 弹框宽度 - height: "520px" // 弹框高度 - } + height: "520px", // 弹框高度 + }, }, { topBtn: false, // 头部按钮 show: true, label: "删除", btnType: "del", // 按钮类型 add edit del 不设置则 自定义按钮 - btnStyle: "danger" // topBtn: true才生效 success danger - } + btnStyle: "danger", // topBtn: true才生效 success danger + }, ], column: { // 行数据 @@ -66,7 +66,7 @@ const tableData: TableConfig = { search: true, add: false, // 字段允许添加 edit: false, // 字段允许修改 - width: "150px" + width: "150px", }, schoolId: { label: "学校", @@ -76,7 +76,7 @@ const tableData: TableConfig = { type: "dropdown", add: true, // 字段允许添加 edit: true, // 字段允许修改 - setting: {} + setting: {}, }, name: { label: "名称", @@ -85,43 +85,43 @@ const tableData: TableConfig = { search: true, searchType: ConditionalType.Like, // 搜索类型 add: true, // 字段允许添加 - edit: true // 字段允许修改 + edit: true, // 字段允许修改 }, Grade: { label: "年级", rules: ruleRequired, width: "180px", type: "dropdown", - custom: row => `${row.grade ?? ""}`, + custom: (row) => `${row.grade ?? ""}`, // `${row.grade ?? ""} ${row.gradeLevel + row.graduationYear}`, search: true, setting: {}, add: true, // 字段允许添加 - edit: false // 字段允许修改 - }, - GradeLevel: { - label: "年级", - search: false, - type: "dropdown", - searchType: ConditionalType.Like, - add: true, // 字段允许添加 - edit: true, // 字段允许修改 - width: "70px", - setting: { - datasource: [ - { text: "初", value: "初" }, - { text: "高", value: "高" }, - { text: "小", value: "小" } - ] - } - }, - GraduationYear: { - label: "届", - search: false, - add: true, // 字段允许添加 - edit: true, // 字段允许修改 - width: "80px" + edit: false, // 字段允许修改 }, + // GradeLevel: { + // label: "年级", + // search: false, + // type: "dropdown", + // searchType: ConditionalType.Like, + // add: true, // 字段允许添加 + // edit: true, // 字段允许修改 + // width: "70px", + // setting: { + // datasource: [ + // { text: "初", value: "初" }, + // { text: "高", value: "高" }, + // { text: "小", value: "小" } + // ] + // } + // }, + // GraduationYear: { + // label: "届", + // search: false, + // add: true, // 字段允许添加 + // edit: true, // 字段允许修改 + // width: "80px" + // }, type: { label: "类型", rules: ruleRequired, @@ -130,8 +130,8 @@ const tableData: TableConfig = { search: true, add: true, // 字段允许添加 edit: true, // 字段允许修改 - setting: {} - } + setting: {}, + }, // createTime: { // label: "创建时间", // width: "180px", @@ -151,9 +151,9 @@ const tableData: TableConfig = { }, data: [], pageData: { - total: 0 + total: 0, }, - selectRows: [] + selectRows: [], }; const showTable = ref(false); @@ -172,11 +172,9 @@ onMounted(async () => { { text: "三年级", value: "三年级" }, { text: "四年级", value: "四年级" }, { text: "五年级", value: "五年级" }, - { text: "六年级", value: "六年级" } + { text: "六年级", value: "六年级" }, ]; - tableData.column.type.setting.datasource = ( - await getenum("ClassTypeEnum") - ).data; + tableData.column.type.setting.datasource = (await getenum("ClassTypeEnum")).data; tableData.column.schoolId.setting.datasource = ( await SchoolApi.querycombo({ TextName: "Name", ValueName: "Id" }) ).data; diff --git a/src/views/student/edit.vue b/src/views/student/edit.vue index bf52070..79f662a 100644 --- a/src/views/student/edit.vue +++ b/src/views/student/edit.vue @@ -60,7 +60,7 @@ - +
@@ -184,6 +184,7 @@ 退出 + { }; const importData = () => { - // const fileE = document.createElement("input"); - // fileE.type = "file"; - // const formData = new FormData(); - // fileE.onchange = async function () { - // formData.append("File", fileE.files![0]); - // const res = await ImporExportTemplate(formData); - // if (res.type === "application/json") { - // const json = await readerBlob(res); - // if (json !== undefined && json.code !== 200) { - // return ElMessage.error(json.Message); - // } else { - // return ElMessage.success("操作成功,没有重复数据"); - // } - // } else if (res === undefined || res.size === 0) { - // ElMessage.success("操作成功,没有重复数据"); - // return; - // } - // const url = res && window.URL.createObjectURL(res); - // const link = document.createElement("a"); - // link.href = url; - // link.setAttribute("download", "未成功导入的用户.xlsx"); - // document.body.appendChild(link); - // link.click(); - // document.body.removeChild(link); - // ElMessage.success("操作成功,已导出重复数据"); - // }; - // try { - // fileE.click(); - // } catch (error) { - // console.error(error); - // } + console.log("批量导入"); + + let fileE = document.createElement("input"); + fileE.type = "file"; + var formData = new window.FormData(); + fileE.onchange = async function () { + formData.append("file", fileE.files[0]); + let res = await ImportStudent(fileE.files[0]); + if (res.code != undefined) { + if (res.code !== 200) return ElMessage.error(res.message); + else return ElMessage.success("所有数据录入成功"); + } else if (res.type === "application/json") { + let json = await res.text(); + if (json !== undefined && json.Code !== 200) { + return ElMessage.error(json.Message); + } else { + return ElMessage.success("操所有数据录入成功作成功"); + } + } else if (res === undefined || res.size === 0) + return ElMessage.success("所有数据录入成功"); + const url = res && window.URL.createObjectURL(res); + const link = document.createElement("a"); + link.href = url; + link.setAttribute("download", "未成功导入的考试信息数据" + ".xlsx"); + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + ElMessage.success("导入失败,已导出错误数据"); + }; + try { + fileE.click(); + } catch (error) {} }; const readerBlob = (data: Blob): Promise => { @@ -759,7 +761,8 @@ const readerBlob = (data: Blob): Promise => { }; const downLoadImportUsersTemplate = () => { - window.open(excelImportUsersUrl, "_blank"); + let impUrl = import.meta.env.VITE_API_BASEURL + "/Student/DwImportTemplate"; + window.open(impUrl, "_blank"); }; onMounted(async () => { diff --git a/src/views/teacher/edit.vue b/src/views/teacher/edit.vue index 7be4b65..1e20b09 100644 --- a/src/views/teacher/edit.vue +++ b/src/views/teacher/edit.vue @@ -21,120 +21,21 @@ - - - - - -
- - - - - - - - - - - - - - - -
-
-
- - - - - - {{ - item.text - }} - - - - - - - - -
    -
  • - {{ userLevel2subject(value[0]) }}: - - {{ level.text }} - -
  • -
+ + +
- - - - + 分配职位 @@ -145,29 +46,18 @@ :key="index" style="padding-left: 120px; padding-bottom: 20px" > -
- {{ "禁用" }} - {{ position.schoolName || "-" }} - {{ - position.graduationYear ? position.graduationYear + "届" : "-" - }} - {{ position.grade || "-" }} - {{ position.className || "-" }} - {{ position.subjectName || "-" }} - {{ position.name || "-" }} - {{ position.endTime }} -
-
+
+ 已禁用 {{ position.schoolName || "-" }} {{ position.graduationYear ? position.graduationYear + "届" : "-" }} - {{ position.grade || "-" }} - {{ - position.className || "-" + {{ position.grade }} + {{ + position.className }} - {{ - position.subjectName || "-" + {{ + position.subjectName }} {{ position.name || "-" }}
@@ -263,6 +153,7 @@ const subject2 = ref([ { value: 7, text: "政治" }, ]); +const emit = defineEmits(["handlePagedCallback"]); const userTypeList = ref([]); const userLevelList = ref([]); const subjectLEnum = ref>({}); @@ -335,7 +226,7 @@ const userLevel2subject = (str: string) => { }; const handlePagedCallback = () => { - // Emit event to parent if needed + emit("handlePagedCallback"); }; const userEditForm = ref(); const handleSubmitForm = () => { @@ -345,8 +236,6 @@ const handleSubmitForm = () => { const formData = { ...form.value, account: form.value.phone || "", - subjectLevels: form.value.subjectLevels || [], - subjectLevel: form.value.subjectLevel || { ...defaultSubjectLevel }, positionIds: form.value.positionIds || [], }; @@ -361,6 +250,7 @@ const handleSubmitForm = () => { }); } }); + // Form validation and submission logic }; @@ -460,7 +350,10 @@ const CheckPosition = () => { const handleCheckCallback = (checkPosition: Position[]) => { dialog.visible = false; - positionList.value = checkPosition; + positionList.value = checkPosition.map((s) => { + s.enable = true; + return s; + }); form.value.positionIds = positionList.value.map((w) => w.id); }; diff --git a/src/views/teacher/index.vue b/src/views/teacher/index.vue index 26b0f0d..bbd1e31 100644 --- a/src/views/teacher/index.vue +++ b/src/views/teacher/index.vue @@ -114,9 +114,9 @@ 下载导入用户模板 - 导出用户 + > -->
@@ -156,7 +156,9 @@ - + + +