|
@@ -28,7 +28,7 @@
|
|
class="part-action"
|
|
class="part-action"
|
|
:size="6"
|
|
:size="6"
|
|
>
|
|
>
|
|
- <a-button type="text" @click="newCourse">
|
|
|
|
|
|
+ <a-button type="text" @click="toAdd">
|
|
<template #icon>
|
|
<template #icon>
|
|
<svg-icon name="add"></svg-icon>
|
|
<svg-icon name="add"></svg-icon>
|
|
</template>
|
|
</template>
|
|
@@ -111,7 +111,7 @@
|
|
v-if="store.isGreaterThanEqualRootOrgAdmin"
|
|
v-if="store.isGreaterThanEqualRootOrgAdmin"
|
|
class="action-cell"
|
|
class="action-cell"
|
|
>
|
|
>
|
|
- <a-button type="text" @click="showModal(record)">编辑</a-button>
|
|
|
|
|
|
+ <a-button type="text" @click="toEdit(record)">编辑</a-button>
|
|
<a-button
|
|
<a-button
|
|
type="text"
|
|
type="text"
|
|
:danger="record.enable"
|
|
:danger="record.enable"
|
|
@@ -125,42 +125,6 @@
|
|
</a-table>
|
|
</a-table>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- <a-modal
|
|
|
|
- v-model:open="visible"
|
|
|
|
- title="科目信息页"
|
|
|
|
- okText="确定"
|
|
|
|
- cancelText="取消"
|
|
|
|
- :width="438"
|
|
|
|
- @ok="handleOk"
|
|
|
|
- >
|
|
|
|
- <a-form :labelCol="{ span: 4 }">
|
|
|
|
- <a-form-item v-show="store.isSuperAdmin" label="学校">
|
|
|
|
- <RootOrgSelect
|
|
|
|
- v-model:value="courseObj.rootOrgId"
|
|
|
|
- :disabled="!!courseObj.id"
|
|
|
|
- />
|
|
|
|
- </a-form-item>
|
|
|
|
- <a-form-item label="科目代码">
|
|
|
|
- <a-input
|
|
|
|
- v-model:value="courseObj.code"
|
|
|
|
- :disabled="!!courseObj.id"
|
|
|
|
- ></a-input>
|
|
|
|
- </a-form-item>
|
|
|
|
- <a-form-item label="科目名称">
|
|
|
|
- <a-input v-model:value="courseObj.name"></a-input>
|
|
|
|
- </a-form-item>
|
|
|
|
- <a-form-item label="科目类型">
|
|
|
|
- <CourseTypeSelect v-model:value="courseObj.type" />
|
|
|
|
- </a-form-item>
|
|
|
|
- <a-form-item label="状态">
|
|
|
|
- <a-radio-group v-model:value="courseObj.enable">
|
|
|
|
- <a-radio :value="true">启用</a-radio>
|
|
|
|
- <a-radio :value="false">禁用</a-radio>
|
|
|
|
- </a-radio-group>
|
|
|
|
- </a-form-item>
|
|
|
|
- </a-form>
|
|
|
|
- </a-modal>
|
|
|
|
-
|
|
|
|
<a-modal
|
|
<a-modal
|
|
v-model:open="importModalVisible"
|
|
v-model:open="importModalVisible"
|
|
title="批量科目导入"
|
|
title="批量科目导入"
|
|
@@ -169,20 +133,39 @@
|
|
:width="438"
|
|
:width="438"
|
|
@ok="handleImport"
|
|
@ok="handleImport"
|
|
>
|
|
>
|
|
- <a-form>
|
|
|
|
|
|
+ <a-form :labelCol="{ style: { width: '72px' } }">
|
|
<a-form-item v-if="store.isSuperAdmin" label="学校">
|
|
<a-form-item v-if="store.isSuperAdmin" label="学校">
|
|
- <RootOrgSelect v-model:value="courseObj.rootOrgId" />
|
|
|
|
|
|
+ <RootOrgSelect v-model:value="rootOrgId" />
|
|
</a-form-item>
|
|
</a-form-item>
|
|
<a-form-item label="文件地址">
|
|
<a-form-item label="文件地址">
|
|
- <input id="file-input" :multiple="false" type="file" />
|
|
|
|
|
|
+ <a-upload
|
|
|
|
+ accept=".xls,.xlsx"
|
|
|
|
+ :before-upload="beforeUpload"
|
|
|
|
+ :disabled="importLoading"
|
|
|
|
+ :maxCount="1"
|
|
|
|
+ @remove="handleRemove"
|
|
|
|
+ >
|
|
|
|
+ <a-button>
|
|
|
|
+ <template #icon>
|
|
|
|
+ <svg-icon name="file"></svg-icon>
|
|
|
|
+ </template>
|
|
|
|
+ 选择文件
|
|
|
|
+ </a-button>
|
|
|
|
+ </a-upload>
|
|
</a-form-item>
|
|
</a-form-item>
|
|
<a-form-item label="下载模板">
|
|
<a-form-item label="下载模板">
|
|
- <a-button class="download-tpl-btn" @click="downloadTpl"
|
|
|
|
- >下载模板</a-button
|
|
|
|
- >
|
|
|
|
|
|
+ <a-button @click="downloadTpl">
|
|
|
|
+ <template #icon>
|
|
|
|
+ <svg-icon name="download"></svg-icon>
|
|
|
|
+ </template>
|
|
|
|
+ 下载模板
|
|
|
|
+ </a-button>
|
|
</a-form-item>
|
|
</a-form-item>
|
|
</a-form>
|
|
</a-form>
|
|
</a-modal>
|
|
</a-modal>
|
|
|
|
+
|
|
|
|
+ <!-- ModifyCourse -->
|
|
|
|
+ <ModifyCourse ref="modifyCourseRef" :row-data="curRow" @modified="search" />
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
@@ -199,6 +182,9 @@ import { Course, Course_Type } from "@/types";
|
|
import { downloadFileURL } from "@/utils/utils";
|
|
import { downloadFileURL } from "@/utils/utils";
|
|
import { message } from "ant-design-vue";
|
|
import { message } from "ant-design-vue";
|
|
import { watch, onMounted, ref, reactive, toRaw, h } from "vue";
|
|
import { watch, onMounted, ref, reactive, toRaw, h } from "vue";
|
|
|
|
+import type { UploadProps } from "ant-design-vue";
|
|
|
|
+import useLoading from "@/hooks/loading";
|
|
|
|
+import ModifyCourse from "./ModifyCourse.vue";
|
|
|
|
|
|
const store = useMainStore();
|
|
const store = useMainStore();
|
|
store.currentLocation = "";
|
|
store.currentLocation = "";
|
|
@@ -302,34 +288,16 @@ onMounted(async () => {
|
|
await search();
|
|
await search();
|
|
});
|
|
});
|
|
|
|
|
|
-const visible = ref<boolean>(false);
|
|
|
|
-
|
|
|
|
-const showModal = (record: Course) => {
|
|
|
|
- Object.assign(courseObj, record);
|
|
|
|
- visible.value = true;
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-const handleOk = async () => {
|
|
|
|
- await updateCourse(toRaw(courseObj));
|
|
|
|
- visible.value = false;
|
|
|
|
- await search();
|
|
|
|
- void message.success({ content: "操作成功" });
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-const initCourse = <Course>(<unknown>{
|
|
|
|
- id: undefined,
|
|
|
|
- code: "",
|
|
|
|
- name: "",
|
|
|
|
- enable: true,
|
|
|
|
- type: undefined,
|
|
|
|
- rootOrgId: store.userInfo.rootOrgId,
|
|
|
|
-});
|
|
|
|
-const courseObj = reactive({ ...initCourse });
|
|
|
|
-
|
|
|
|
-const newCourse = () => {
|
|
|
|
- Object.assign(courseObj, initCourse);
|
|
|
|
- showModal(courseObj);
|
|
|
|
-};
|
|
|
|
|
|
+const modifyCourseRef = ref();
|
|
|
|
+const curRow = ref<Course>({} as Course);
|
|
|
|
+function toAdd() {
|
|
|
|
+ curRow.value = {} as Course;
|
|
|
|
+ modifyCourseRef.value?.open();
|
|
|
|
+}
|
|
|
|
+function toEdit(row: Course) {
|
|
|
|
+ curRow.value = row;
|
|
|
|
+ modifyCourseRef.value?.open();
|
|
|
|
+}
|
|
|
|
|
|
function checkEmpty(selectIds: number[]): boolean {
|
|
function checkEmpty(selectIds: number[]): boolean {
|
|
if (selectIds && selectIds.length > 0) {
|
|
if (selectIds && selectIds.length > 0) {
|
|
@@ -347,17 +315,34 @@ async function handleToggleCourses(enable: boolean, ids: number[]) {
|
|
}
|
|
}
|
|
|
|
|
|
/** <handleImport> */
|
|
/** <handleImport> */
|
|
|
|
+let fileList = $ref<UploadProps["fileList"]>([]);
|
|
|
|
+const beforeUpload: UploadProps["beforeUpload"] = (file) => {
|
|
|
|
+ fileList = [file];
|
|
|
|
+ return false;
|
|
|
|
+};
|
|
|
|
+const handleRemove = () => {
|
|
|
|
+ fileList = [];
|
|
|
|
+};
|
|
|
|
+const { loading: importLoading, setLoading: setImportLoading } = useLoading();
|
|
let importModalVisible = $ref<boolean>(false);
|
|
let importModalVisible = $ref<boolean>(false);
|
|
async function handleImport() {
|
|
async function handleImport() {
|
|
- const files = (document.querySelector("#file-input") as HTMLInputElement)
|
|
|
|
- .files;
|
|
|
|
- const fileToImport = files && files[0];
|
|
|
|
- if (!fileToImport) {
|
|
|
|
|
|
+ if (!rootOrgId) {
|
|
|
|
+ void message.error("请先选择结构");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (!fileList?.length) {
|
|
void message.warn({ content: "请选择文件" });
|
|
void message.warn({ content: "请选择文件" });
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- (document.querySelector("#file-input") as HTMLInputElement).value = "";
|
|
|
|
- const res = await importCourses(rootOrgId, fileToImport);
|
|
|
|
|
|
+ setImportLoading(true);
|
|
|
|
+
|
|
|
|
+ const res = await importCourses(rootOrgId, fileList[0] as any).catch(
|
|
|
|
+ () => {}
|
|
|
|
+ );
|
|
|
|
+ if (!res) return;
|
|
|
|
+
|
|
|
|
+ setImportLoading(false);
|
|
|
|
+
|
|
if (!res.data.hasError) {
|
|
if (!res.data.hasError) {
|
|
importModalVisible = false;
|
|
importModalVisible = false;
|
|
void message.success({ content: "导入成功" });
|
|
void message.success({ content: "导入成功" });
|