zhangjie 1 rok pred
rodič
commit
6fcd04285b

+ 72 - 56
src/features/authManagement/AuthManagement.vue

@@ -28,56 +28,57 @@
           <a-select-option value="OFFLINE">离线激活</a-select-option>
         </a-select>
       </a-form-item>
-      <a-form-item
-        v-show="authForm.authType == 'ONLINE'"
-        label="密匙"
-        prop="accessKey"
-      >
-        <a-input
-          v-model:value="authForm.accessKey"
-          :maxlength="255"
-          allowClear
-        />
-      </a-form-item>
-      <a-form-item
-        v-show="authForm.authType == 'ONLINE'"
-        label="密钥"
-        prop="accessSecret"
-      >
-        <a-input
-          v-model:value="authForm.accessSecret"
-          :maxlength="255"
-          allowClear
-        />
-      </a-form-item>
-      <a-form-item v-show="authForm.authType == 'OFFLINE'" label="授权文件">
-        <a-upload
-          accept=".lic"
-          :before-upload="customRequest"
-          :showUploadList="false"
-          :disabled="loading"
-        >
-          <a-button>
+      <template v-if="authForm.authType == 'ONLINE'">
+        <a-form-item label="密匙" prop="accessKey">
+          <a-input
+            v-model:value="authForm.accessKey"
+            :maxlength="255"
+            allowClear
+          />
+        </a-form-item>
+        <a-form-item label="密钥" prop="accessSecret">
+          <a-input
+            v-model:value="authForm.accessSecret"
+            :maxlength="255"
+            allowClear
+          />
+        </a-form-item>
+        <a-form-item style="margin-left: 72px">
+          <a-button type="primary" :loading="confirmLoading" @click="submitForm"
+            >保存</a-button
+          >
+        </a-form-item>
+      </template>
+
+      <template v-if="authForm.authType == 'OFFLINE'">
+        <a-form-item label="授权文件">
+          <a-upload
+            accept=".lic"
+            :before-upload="beforeUpload"
+            :disabled="importLoading"
+          >
+            <a-button>
+              <template #icon>
+                <svg-icon name="file"></svg-icon>
+              </template>
+              选择文件
+            </a-button>
+          </a-upload>
+        </a-form-item>
+        <a-form-item label="硬件信息">
+          <a-button :loading="loading" @click="exportFile">
             <template #icon>
-              <svg-icon name="file"></svg-icon>
+              <svg-icon name="export"></svg-icon>
             </template>
-            选择文件
+            导出信息
           </a-button>
-        </a-upload>
-      </a-form-item>
-      <a-form-item v-if="authForm.authType == 'OFFLINE'" label="硬件信息">
-        <a-button :loading="loading" @click="exportFile">
-          <template #icon>
-            <svg-icon name="export"></svg-icon>
-          </template>
-          导出信息
-        </a-button>
-      </a-form-item>
-      <a-form-item v-else>
-        <a-button type="primary" :loading="loading" @click="submitForm"
-          >保存</a-button
-        >
-      </a-form-item>
+        </a-form-item>
+        <a-form-item style="margin-left: 72px">
+          <a-button type="primary" :loading="importLoading" @click="uploadFile"
+            >保存</a-button
+          >
+        </a-form-item>
+      </template>
     </a-form>
   </a-card>
 </template>
@@ -89,7 +90,9 @@ import {
   onlineAuth,
 } from "../../api/authManagementPage";
 import { message } from "ant-design-vue";
-import { onMounted, reactive } from "vue";
+import type { UploadProps } from "ant-design-vue";
+
+import { onMounted, reactive, ref } from "vue";
 import { downloadFileURL } from "@/utils/utils";
 import useLoading from "@/hooks/loading";
 
@@ -126,7 +129,6 @@ let authForm: AuthFormType = reactive({
 onMounted(async () => {
   await fetchData();
 });
-const { loading, setLoading } = useLoading();
 
 async function fetchData() {
   const res = await getAuthInfo();
@@ -150,25 +152,39 @@ async function fetchData() {
   }
 }
 
+const { loading: confirmLoading, setLoading: setConfirmLoading } = useLoading();
 async function submitForm() {
   if (loading.value) return;
-  setLoading(true);
+  setConfirmLoading(true);
   await onlineAuth(authForm).catch(() => {});
-  setLoading(false);
+  setConfirmLoading(false);
   void message.success("操作成功");
 }
 
 // offline-auth
-async function customRequest(data: { file: File }) {
-  setLoading(true);
+let fileList = $ref<UploadProps["fileList"]>([]);
+const beforeUpload: UploadProps["beforeUpload"] = (file) => {
+  fileList = [file];
+  return false;
+};
+const { loading: importLoading, setLoading: setImportLoading } = useLoading();
+async function uploadFile() {
+  if (!fileList?.length) return;
+  setImportLoading(true);
+
   let formData = new FormData();
-  formData.append("file", data.file);
-  await offlineAuth(formData).catch(() => {});
-  setLoading(false);
+  formData.append("file", fileList[0] as any);
+  let err = false;
+  await offlineAuth(formData).catch(() => {
+    err = true;
+  });
+  setImportLoading(false);
+  if (err) return;
   void message.success("上传成功!");
   await fetchData();
 }
 
+const { loading, setLoading } = useLoading();
 async function exportFile() {
   if (loading.value) return;
   setLoading(true);

+ 1 - 0
src/features/courseManagement/CourseManagement.vue

@@ -201,6 +201,7 @@ import { message } from "ant-design-vue";
 import { watch, onMounted, ref, reactive, toRaw, h } from "vue";
 
 const store = useMainStore();
+store.currentLocation = "";
 
 let rootOrgId = $ref(undefined as unknown as number);
 let type = $ref(undefined as unknown as Course_Type); // 科目类型

+ 1 - 0
src/features/projectManagement/ProjectManagement.vue

@@ -220,6 +220,7 @@ import { message, Modal } from "ant-design-vue";
 import { watch, onMounted, ref, reactive, toRaw } from "vue";
 
 const store = useMainStore();
+store.currentLocation = "";
 
 let rootOrgId = $ref(undefined as unknown as number);
 let name = $ref("");

+ 2 - 77
src/features/rootOrg/RootOrg.vue

@@ -20,52 +20,16 @@
         <template v-if="column.dataIndex === 'enable'">
           <status-tag :value="record.enable" type="enable"></status-tag>
         </template>
-        <template v-if="column.dataIndex === 'action'">
-          <div class="action-cell">
-            <a-button type="text" @click="showModal(record)">编辑</a-button>
-            <a-button type="text" @click="editRootOrgSettings(record.id)"
-              >特殊设置</a-button
-            >
-          </div>
-        </template>
       </template>
     </a-table>
-
-    <a-modal
-      v-model:open="visible"
-      title="学校信息页"
-      okText="确定"
-      cancelText="取消"
-      :width="438"
-      @ok="handleOk"
-    >
-      <a-form :labelCol="{ span: 5 }">
-        <a-form-item label="学校代码">
-          <a-input v-model:value="rootOrgObj.code" disabled></a-input>
-        </a-form-item>
-        <a-form-item label="学校名称">
-          <a-input v-model:value="rootOrgObj.name" disabled></a-input>
-        </a-form-item>
-        <a-form-item label="状态">
-          <a-radio-group v-model:value="rootOrgObj.enable" disabled>
-            <a-radio :value="true">启用</a-radio>
-            <a-radio :value="false">禁用</a-radio>
-          </a-radio-group>
-        </a-form-item>
-        <a-form-item label="学校域名">
-          <a-input v-model:value="rootOrgObj.domainName"></a-input>
-        </a-form-item>
-      </a-form>
-    </a-modal>
   </div>
 </template>
 
 <script setup lang="ts">
-import { getRootOrgList, syncRootOrg, updateRootOrg } from "@/api/rootOrgPage";
-import router from "@/router";
+import { getRootOrgList, syncRootOrg } from "@/api/rootOrgPage";
 import { RootOrg } from "@/types";
 import { message } from "ant-design-vue";
-import { ref, onMounted, reactive } from "vue";
+import { onMounted } from "vue";
 
 let code = $ref("");
 let name = $ref("");
@@ -74,7 +38,6 @@ let enable = $ref(undefined as undefined | boolean);
 let data = $ref<RootOrg[]>([]);
 let pageSize = $ref(10);
 let pageNo = $ref(1);
-let totalElements = $ref(0);
 
 async function search() {
   const res = await getRootOrgList({ code, name, enable, pageSize, pageNo });
@@ -82,12 +45,6 @@ async function search() {
   data = res.data.content;
   pageNo = res.data.pageNo;
   pageSize = res.data.pageSize;
-  totalElements = res.data.totalElements;
-}
-
-async function clickSearch() {
-  pageNo = 1;
-  await search();
 }
 
 const columns = [
@@ -116,44 +73,12 @@ const columns = [
     dataIndex: "enable",
     width: 120,
   },
-  {
-    title: "操作",
-    dataIndex: "action",
-    fixed: "right",
-    width: 140,
-  },
 ];
 
 onMounted(async () => {
   await search();
 });
 
-const visible = ref<boolean>(false);
-
-const showModal = (record: RootOrg) => {
-  Object.assign(rootOrgObj, record);
-  visible.value = true;
-};
-
-const editRootOrgSettings = (orgId: number) => {
-  void router.push("/basic/rootOrg/edit/" + orgId);
-};
-
-const handleOk = async () => {
-  await updateRootOrg({ domainName: rootOrgObj.domainName, id: rootOrgObj.id });
-  visible.value = false;
-  await search();
-  void message.success({ content: "操作成功" });
-};
-
-const rootOrgObj = reactive({
-  id: 0,
-  code: "",
-  name: "",
-  enable: true,
-  domainName: "",
-});
-
 async function handleRootOrgSync() {
   await syncRootOrg();
   void message.success("操作成功");

+ 2 - 15
src/features/userManagement/UserManagement.vue

@@ -66,7 +66,6 @@
         class="page-table"
         rowKey="id"
         :columns="columns"
-        :scroll="{ x: 1200 }"
         :data-source="data"
         size="middle"
         :rowSelection="{
@@ -113,13 +112,6 @@
               <a-button type="text" @click="handleResetUsers([record.id])">
                 重置密码
               </a-button>
-              <a-button
-                v-if="store.isGreaterThanEqualRootOrgAdmin"
-                type="text"
-                @click="handleUserPrivilege(record.id)"
-              >
-                权限设置
-              </a-button>
             </div>
           </template>
         </template>
@@ -163,12 +155,6 @@
             :rootOrgId="userObj.rootOrgId"
           />
         </a-form-item>
-        <!-- <a-form-item v-if="curRoleCode === 'COURSE_ADMIN'" label="负责科目">
-          <a-input
-            v-model:value="userObj.course"
-            placeholder="多个科目用中文逗号隔开"
-          ></a-input>
-        </a-form-item> -->
         <a-form-item label="状态">
           <a-radio-group v-model:value="userObj.enable">
             <a-radio :value="true">启用</a-radio>
@@ -222,6 +208,7 @@ import { message, Modal } from "ant-design-vue";
 import { watch, onMounted, ref, reactive, toRaw, h } from "vue";
 
 const store = useMainStore();
+store.currentLocation = "";
 
 let rootOrgId = $ref<null | number>(null);
 let role = $ref(undefined as unknown as string);
@@ -320,7 +307,7 @@ const columns = [
     title: "操作",
     dataIndex: "action",
     fixed: "right",
-    width: store.isGreaterThanEqualRootOrgAdmin ? 260 : 200,
+    width: 200,
   },
 ];
 

+ 2 - 1
src/utils/utils.ts

@@ -16,7 +16,7 @@ export async function downloadFileURL(
 }
 
 export async function responseToFile(response: AxiosResponse) {
-  return new Promise(() => {
+  return new Promise((resolve) => {
     const { data, headers } = response;
     const fileName = headers["content-disposition"].replace(
       /\w+;\s*filename=(.*)/,
@@ -34,6 +34,7 @@ export async function responseToFile(response: AxiosResponse) {
     dom.click();
     dom.parentNode?.removeChild(dom);
     window.URL.revokeObjectURL(url);
+    resolve(true);
   });
 }