zhangjie 2 жил өмнө
parent
commit
4562051bc9

+ 14 - 0
src/assets/styles/pages.scss

@@ -1137,3 +1137,17 @@
     font-size: 40px;
   }
 }
+
+// modify-school
+.modify-school{
+  .logo-image{
+    background-color: $--color-background;
+    padding: 10px;
+    border-radius: 5px;
+    text-align: center;
+  }
+  .logo-view{
+    max-width: 160px;
+    max-height: 40px;
+  }
+}

+ 1 - 1
src/components/base/SchoolSelect.vue

@@ -19,7 +19,7 @@
 </template>
 
 <script>
-import { schoolList } from "../../modules/login/api";
+import { schoolList } from "../../modules/admin/api";
 
 export default {
   name: "school-select",

+ 9 - 3
src/constants/adminNavs.js

@@ -8,23 +8,29 @@ const navs = [
   {
     id: "2",
     parentId: "1",
+    name: "学校管理",
+    url: "SchoolManage"
+  },
+  {
+    id: "3",
+    parentId: "1",
     name: "用户管理",
     url: "AdminUserManage"
   },
   {
-    id: "3",
+    id: "4",
     parentId: "1",
     name: "系统角色管理",
     url: "SystemRoleManage"
   },
   {
-    id: "4",
+    id: "5",
     parentId: "1",
     name: "菜单管理",
     url: "SchoolMenuManage"
   },
   {
-    id: "5",
+    id: "6",
     parentId: "1",
     name: "授权配置",
     url: "AuthSet"

+ 10 - 0
src/modules/admin/api.js

@@ -57,3 +57,13 @@ export const exportDeviceInfo = () => {
     }
   );
 };
+// school-manage
+export const schoolList = () => {
+  return $postParam("/api/admin/common/school/list", {});
+};
+export const schoolSync = () => {
+  return $postParam("/api/admin/common/school/sync", {});
+};
+export const updateSchool = datas => {
+  return $post("/api/admin/menu/custom/save", datas);
+};

+ 175 - 0
src/modules/admin/components/ModifySchool.vue

@@ -0,0 +1,175 @@
+<template>
+  <el-dialog
+    class="modify-school"
+    :visible.sync="modalIsShow"
+    :title="title"
+    top="10vh"
+    width="600px"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    @opened="visibleChange"
+  >
+    <el-form
+      ref="modalFormComp"
+      :model="modalForm"
+      :rules="rules"
+      :key="modalForm.id"
+      label-width="100px"
+    >
+      <el-form-item prop="code" label="学校代码:">
+        {{ modalForm.code }}
+      </el-form-item>
+      <el-form-item prop="name" label="学校名称:">
+        <el-input
+          v-model.trim="modalForm.name"
+          placeholder="请输入名称"
+          clearable
+        ></el-input>
+      </el-form-item>
+      <!-- <el-form-item prop="code" label="学校域名">
+        <el-input
+          v-model.trim="modalForm.code"
+          placeholder="请输入编码"
+          clearable
+        ></el-input>
+      </el-form-item> -->
+      <el-form-item label="学校logo:">
+        <UploadFetchFile
+          ref="UploadFetchFile"
+          input-width="340px"
+          :disabled="isSubmit"
+          @file-change="logoChange"
+        />
+        <div>
+          <p class="tips-info">logo会展示在登录页及内页;</p>
+          <p class="tips-info">
+            文件必须是 jpg 或 png 格式的图片,不超过 2M 尺寸:160*40px。
+          </p>
+        </div>
+        <div class="logo-image" v-if="imgSrc">
+          <img class="logo-view" :src="imgSrc" alt="logo" />
+        </div>
+      </el-form-item>
+    </el-form>
+    <div slot="footer">
+      <el-button type="danger" @click="cancel" plain>取消</el-button>
+      <el-button type="primary" :disabled="isSubmit" @click="submit"
+        >确认</el-button
+      >
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+import { updateSchool } from "../api";
+import UploadFetchFile from "../../../components/UploadFetchFile.vue";
+
+const initModalForm = {
+  id: "",
+  name: "",
+  code: "",
+  logo: "",
+  logoMd5: ""
+};
+
+export default {
+  name: "modify-school",
+  components: { UploadFetchFile },
+  props: {
+    instance: {
+      type: Object,
+      default() {
+        return {};
+      }
+    }
+  },
+  computed: {
+    isEdit() {
+      return !!this.instance.id;
+    },
+    title() {
+      return (this.isEdit ? "编辑" : "新增") + "学校";
+    }
+  },
+  data() {
+    return {
+      modalIsShow: false,
+      isSubmit: false,
+      modalForm: { ...initModalForm },
+      imgSrc: "",
+      rules: {
+        name: [
+          {
+            required: true,
+            message: "请输入学校名称",
+            trigger: "change"
+          }
+        ],
+        code: [
+          {
+            required: true,
+            message: "请输入学校代码",
+            trigger: "change"
+          }
+        ],
+        logo: [
+          {
+            required: true,
+            message: "请选择logo",
+            trigger: "change"
+          }
+        ]
+      }
+    };
+  },
+  methods: {
+    initData(val) {
+      if (val.id) {
+        this.modalForm = this.$objAssign(initModalForm, val);
+        this.imgSrc = val.logo || "";
+      } else {
+        this.imgSrc = "";
+        this.modalForm = { ...initModalForm };
+      }
+      this.$refs.modalFormComp.clearValidate();
+      this.$nextTick(() => {
+        this.$refs.UploadFetchFile.setAttachmentName(this.imgSrc);
+      });
+    },
+    visibleChange() {
+      this.initData(this.instance);
+    },
+    cancel() {
+      this.modalIsShow = false;
+    },
+    open() {
+      this.modalIsShow = true;
+    },
+    logoChange({ file, md5 }) {
+      let uRl = window.URL || window.webkitURL;
+      this.imgSrc = uRl.createObjectURL(file);
+      this.modalForm.logo = file;
+      this.modalForm.logoMd5 = md5;
+    },
+    async submit() {
+      const valid = await this.$refs.modalFormComp.validate();
+      if (!valid) return;
+
+      if (this.isSubmit) return;
+      this.isSubmit = true;
+      let datas = { ...this.modalForm };
+      const data = await updateSchool(datas).catch(() => {
+        this.isSubmit = false;
+      });
+
+      if (!data) return;
+
+      this.isSubmit = false;
+      this.$message.success(this.title + "成功!");
+      this.$emit("modified");
+      this.cancel();
+    }
+  }
+};
+</script>

+ 6 - 0
src/modules/admin/router.js

@@ -2,6 +2,7 @@ import AdminUserManage from "./views/AdminUserManage.vue";
 import PrivilegeManage from "./views/PrivilegeManage.vue";
 import SystemRoleManage from "./views/SystemRoleManage.vue";
 import SchoolMenuManage from "./views/SchoolMenuManage.vue";
+import SchoolManage from "./views/SchoolManage.vue";
 import AuthSet from "./views/AuthSet.vue";
 import Admin from "./views/Admin.vue";
 
@@ -30,6 +31,11 @@ export default {
       name: "SchoolMenuManage",
       component: SchoolMenuManage
     },
+    {
+      path: "school-manage",
+      name: "SchoolManage",
+      component: SchoolManage
+    },
     {
       path: "auth-set",
       name: "AuthSet",

+ 136 - 0
src/modules/admin/views/SchoolManage.vue

@@ -0,0 +1,136 @@
+<template>
+  <div class="school-manage">
+    <div class="part-box part-box-filter part-box-flex">
+      <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
+        <el-form-item label="启用/禁用:" label-width="90px">
+          <el-select
+            v-model="filter.schoolId"
+            placeholder="选择学校"
+            filterable
+            clearable
+          >
+            <el-option
+              v-for="item in schools"
+              :key="item.id"
+              :value="item.id"
+              :label="item.name"
+            ></el-option>
+          </el-select>
+        </el-form-item>
+
+        <el-form-item label-width="0px">
+          <el-button type="primary" @click="filterSchool">查询</el-button>
+        </el-form-item>
+      </el-form>
+      <div class="part-box-action">
+        <el-button
+          type="primary"
+          icon="el-icon-refresh"
+          :loading="loading"
+          @click="toSyncSchool"
+          >机构同步</el-button
+        >
+      </div>
+    </div>
+
+    <div class="part-box part-box-pad">
+      <el-table ref="TableList" :data="dataList">
+        <el-table-column type="index" label="序号" width="70"></el-table-column>
+        <el-table-column
+          prop="name"
+          label="学校名称"
+          min-width="200"
+        ></el-table-column>
+        <el-table-column
+          prop="code"
+          label="学校代码"
+          min-width="100"
+        ></el-table-column>
+        <el-table-column
+          prop="code"
+          label="学校域名"
+          min-width="100"
+        ></el-table-column>
+        <el-table-column class-name="action-column" label="操作" width="120">
+          <template slot-scope="scope">
+            <el-button
+              class="btn-primary"
+              type="text"
+              @click="toEdit(scope.row)"
+              >编辑</el-button
+            >
+            <el-button class="btn-primary" type="text" @click="toSet(scope.row)"
+              >设置</el-button
+            >
+          </template>
+        </el-table-column>
+      </el-table>
+    </div>
+
+    <!-- ModifySchool -->
+    <modify-school
+      ref="ModifySchool"
+      :instance="curSchool"
+      @modified="getSchools"
+    ></modify-school>
+  </div>
+</template>
+
+<script>
+import { schoolList, schoolSync } from "../api";
+import ModifySchool from "../components/ModifySchool.vue";
+
+export default {
+  name: "school-manage",
+  components: { ModifySchool },
+  data() {
+    return {
+      schools: [],
+      dataList: [],
+      filter: {
+        schoolId: null
+      },
+      curSchool: {},
+      loading: false
+    };
+  },
+  mounted() {
+    this.getSchools();
+  },
+  methods: {
+    async getSchools() {
+      const data = await schoolList();
+      this.schools = data || [];
+      this.dataList = this.schools;
+    },
+    filterSchool() {
+      if (!this.filter.schoolId) {
+        this.dataList = this.schools;
+        return;
+      }
+
+      this.dataList = this.schools.filter(
+        item => item.id === this.filter.schoolId
+      );
+    },
+    async toSyncSchool() {
+      if (this.loading) return;
+      this.loading = true;
+
+      const res = await schoolSync().catch(() => {});
+      this.loading = false;
+
+      if (!res) return;
+
+      this.$message.success("操作成功");
+      this.filter.schoolId = null;
+      this.getSchools();
+    },
+    toEdit(row) {
+      this.curSchool = row;
+      this.$refs.ModifySchool.open();
+    },
+    toSet() {}
+  }
+};
+</script>

+ 0 - 3
src/modules/login/api.js

@@ -30,9 +30,6 @@ export const attachmentDownload = ({ id, type }) => {
 export const getEnums = type => {
   return $postParam("/api/admin/common/get_enums", { type });
 };
-export const schoolList = () => {
-  return $postParam("/api/admin/common/school/list", {});
-};
 export const getSchoolInfo = code => {
   return $postParam("/api/admin/common/school/query_by_school_code", { code });
 };