Browse Source

course manage add

zhangjie 5 years ago
parent
commit
7737703187

+ 2 - 1
src/constants/enumerate.js

@@ -84,5 +84,6 @@ export const MENU_ROUTER_DICT = {
   examManager: "ExamManage",
   examManager: "ExamManage",
   cardManager: "CardManage",
   cardManager: "CardManage",
   printManager: "PrintManage",
   printManager: "PrintManage",
-  cardAuditingManager: "CardAudit"
+  cardAuditingManager: "CardAudit",
+  courseManager: "CourseManage"
 };
 };

+ 4 - 0
src/constants/navs.js

@@ -106,6 +106,10 @@ const navs = [
       {
       {
         title: "规则管理",
         title: "规则管理",
         router: "RuleManage"
         router: "RuleManage"
+      },
+      {
+        title: "科目管理",
+        router: "CourseManage"
       }
       }
     ]
     ]
   }
   }

+ 15 - 0
src/modules/base/api.js

@@ -37,6 +37,21 @@ export const importExtendColums = datas => {
   return $post("/api/print/basic/cardRule/impExtendColums", datas);
   return $post("/api/print/basic/cardRule/impExtendColums", datas);
 };
 };
 
 
+// course-manage
+export const courseListPage = datas => {
+  return $get("/api/print/basic/course/list", datas);
+};
+export const deleteCourse = courseId => {
+  return $get("/api/print/basic/course/delete", { courseId });
+};
+export const updateCourse = datas => {
+  if (datas.courseId) {
+    return $post("/api/print/basic/course/update", datas);
+  } else {
+    return $post("/api/print/basic/course/add", datas);
+  }
+};
+
 // common
 // common
 export const uploadFile = datas => {
 export const uploadFile = datas => {
   return $post("/api/print/basic/sys/saveAttachment", datas);
   return $post("/api/print/basic/sys/saveAttachment", datas);

+ 125 - 0
src/modules/base/components/ModifyCourse.vue

@@ -0,0 +1,125 @@
+<template>
+  <el-dialog
+    class="modify-data"
+    :visible.sync="modalIsShow"
+    :title="title"
+    top="10vh"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    @open="visibleChange"
+  >
+    <el-form
+      ref="modalFormComp"
+      :model="modalForm"
+      :rules="rules"
+      :key="modalForm.id"
+      label-width="100px"
+    >
+      <el-form-item prop="courseName" label="科目名称:">
+        <el-input
+          v-model.trim="modalForm.courseName"
+          placeholder="请输入科目名称"
+          clearable
+        ></el-input>
+      </el-form-item>
+      <el-form-item prop="courseCode" label="科目代码:">
+        <el-input
+          v-model.trim="modalForm.courseCode"
+          placeholder="请输入科目代码"
+          clearable
+        ></el-input>
+      </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 { updateCourse } from "../api";
+import { commonCode } from "@/plugins/formRules";
+
+const initModalForm = {
+  courseId: "",
+  courseName: "",
+  courseCode: ""
+};
+
+export default {
+  name: "modify-data",
+  props: {
+    instance: {
+      type: Object,
+      default() {
+        return {};
+      }
+    }
+  },
+  computed: {
+    isEdit() {
+      return !!this.instance.id;
+    },
+    title() {
+      return (this.isEdit ? "编辑" : "新增") + "科目";
+    }
+  },
+  data() {
+    return {
+      modalIsShow: false,
+      isSubmit: false,
+      modalForm: { ...initModalForm },
+      rules: {
+        courseName: [
+          {
+            required: true,
+            message: "请输入科目名称",
+            trigger: "change"
+          }
+        ],
+        courseCode: commonCode({ prop: "科目代码" })
+      }
+    };
+  },
+  methods: {
+    initData(val) {
+      if (val.id) {
+        this.modalForm = this.$objAssign(initModalForm, val);
+        this.modalForm.courseId = val["id"] || "";
+      } else {
+        this.modalForm = { ...initModalForm };
+      }
+    },
+    visibleChange() {
+      this.initData(this.instance);
+    },
+    cancel() {
+      this.modalIsShow = false;
+    },
+    open() {
+      this.modalIsShow = true;
+    },
+    async submit() {
+      const valid = await this.$refs.modalFormComp.validate().catch(() => {});
+      if (!valid) return;
+
+      if (this.isSubmit) return;
+      this.isSubmit = true;
+      const data = await updateCourse(this.modalForm).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/base/router.js

@@ -2,6 +2,7 @@ import RuleManage from "./views/RuleManage.vue";
 import UserManage from "./views/UserManage.vue";
 import UserManage from "./views/UserManage.vue";
 import UserEdit from "./views/UserEdit.vue";
 import UserEdit from "./views/UserEdit.vue";
 import PswdManage from "./views/PswdManage.vue";
 import PswdManage from "./views/PswdManage.vue";
+import CourseManage from "./views/CourseManage.vue";
 
 
 export default [
 export default [
   {
   {
@@ -26,5 +27,10 @@ export default [
     path: "/base/rule-manage",
     path: "/base/rule-manage",
     name: "RuleManage",
     name: "RuleManage",
     component: RuleManage
     component: RuleManage
+  },
+  {
+    path: "/base/course-manage",
+    name: "CourseManage",
+    component: CourseManage
   }
   }
 ];
 ];

+ 110 - 0
src/modules/base/views/CourseManage.vue

@@ -0,0 +1,110 @@
+<template>
+  <div class="course-manage">
+    <div class="part-box">
+      <div class="part-title">
+        <div class="part-title-infos">
+          <el-button type="primary" icon="icon icon-plus" @click="toAdd"
+            >新增科目</el-button
+          >
+        </div>
+      </div>
+      <el-table ref="TableList" :data="courses" border stripe>
+        <el-table-column prop="courseName" label="科目名称"></el-table-column>
+        <el-table-column prop="courseCode" label="科目代码"></el-table-column>
+        <el-table-column label="操作" align="center" width="120px">
+          <template slot-scope="scope">
+            <el-button
+              class="btn-table-icon"
+              type="text"
+              icon="icon icon-edit"
+              @click="toEdit(scope.row)"
+              title="编辑"
+            ></el-button>
+            <el-button
+              class="btn-table-icon"
+              type="text"
+              icon="icon icon-delete"
+              @click="toDelete(scope.row)"
+              title="删除"
+            ></el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+      <div class="part-page">
+        <el-pagination
+          background
+          layout="prev, pager, next"
+          :current-page="current"
+          :total="total"
+          :page-size="size"
+          @current-change="toPage"
+        >
+        </el-pagination>
+      </div>
+    </div>
+
+    <modify-course
+      :instance="curCourse"
+      @modified="getList"
+      ref="ModifyCourse"
+    ></modify-course>
+  </div>
+</template>
+
+<script>
+import { courseListPage, deleteCourse } from "../api";
+import ModifyCourse from "../components/ModifyCourse";
+
+export default {
+  name: "course-manage",
+  components: { ModifyCourse },
+  data() {
+    return {
+      filter: {},
+      current: 1,
+      size: this.GLOBAL.pageSize,
+      total: 0,
+      courses: [],
+      curCourse: {}
+    };
+  },
+  created() {
+    this.getList();
+  },
+  methods: {
+    async getList() {
+      const datas = {
+        ...this.filter,
+        pageNumber: this.current,
+        pageSize: this.size
+      };
+      const data = await courseListPage(datas);
+      this.courses = data.records;
+      this.total = data.total;
+    },
+    toPage(page) {
+      this.current = page;
+      this.getList();
+    },
+    toAdd() {
+      this.curCourse = {};
+      this.$refs.ModifyCourse.open();
+    },
+    toEdit(row) {
+      this.curCourse = row;
+      this.$refs.ModifyCourse.open();
+    },
+    toDelete(row) {
+      this.$confirm("确定要删除当前科目吗?", "提示", {
+        cancelButtonClass: "el-button--primary",
+        confirmButtonClass: "el-button--default-act",
+        type: "warning"
+      }).then(async () => {
+        await deleteCourse(row.id);
+        this.$message.success("删除成功!");
+        this.deletePageLastItem();
+      });
+    }
+  }
+};
+</script>

+ 12 - 0
src/modules/base/views/UserManage.vue

@@ -133,6 +133,7 @@ import { ABLE_TYPE } from "@/constants/enumerate";
 import { userListPage, ableUser, updatePwd, roleList } from "../api";
 import { userListPage, ableUser, updatePwd, roleList } from "../api";
 import UploadButton from "@/components/UploadButton";
 import UploadButton from "@/components/UploadButton";
 import { AES } from "@/plugins/crypto";
 import { AES } from "@/plugins/crypto";
+import { logout } from "@/modules/login/api";
 
 
 export default {
 export default {
   name: "user-manage",
   name: "user-manage",
@@ -208,6 +209,17 @@ export default {
         newPassword: AES("123456")
         newPassword: AES("123456")
       });
       });
       this.$message.success("密码重置成功!");
       this.$message.success("密码重置成功!");
+
+      // 修改自己时,会强制重新登录
+      const userId = this.$ls.get("user", { id: "" }).id;
+      if (row.id !== userId) return;
+      this.toLogout(userId);
+    },
+    async toLogout(userId) {
+      await logout(userId);
+      this.$ls.clear();
+      this.$router.push({ name: "Login" });
+      this.$message.info("您的密码已经变更,请重新登录系统!");
     },
     },
     uplaodError(msg) {
     uplaodError(msg) {
       this.$message.error(msg);
       this.$message.error(msg);

+ 1 - 1
src/plugins/axios.js

@@ -82,7 +82,7 @@ const errorDataCallback = error => {
  */
  */
 const successCallback = data => {
 const successCallback = data => {
   if (data.code === "200") {
   if (data.code === "200") {
-    return data.data;
+    return data.data || { success: true };
   } else {
   } else {
     throw new Error(errorDataCallback(data));
     throw new Error(errorDataCallback(data));
   }
   }