Browse Source

新增页面,优化菜单栏逻辑

yellowtaotao 4 years ago
parent
commit
1a094e89ab

+ 4 - 0
src/api/index.js

@@ -26,6 +26,10 @@ const subList = [
   {
     name: "API_LIST_ARTICLE",
     url: "VUE_APP_BASE_API"
+  },
+  {
+    name: "API_LIST_ANSWER_MANAGEMENT",
+    url: "VUE_APP_BASE_API"
   }
 ];
 

+ 5 - 0
src/api/modules/answerManagement.js

@@ -0,0 +1,5 @@
+/* JTXT系统相关api */
+export default {
+  API_LIST_ANSWER_MANAGEMENT: {
+  }
+};

+ 10 - 8
src/components/layout/components/Sider.vue

@@ -8,7 +8,7 @@
       class="ant-menu-ul"
       mode="inline"
       theme="dark"
-      :defaultSelectedKeys="[activeMenu]"
+      :selectedKeys.sync="activeMenu"
       :openKeys.sync="defaultOpenKeys"
     >
       <template v-for="item in routes">
@@ -83,7 +83,7 @@ export default {
   },
   created() {},
   mounted() {
-    this.defaultOpenKeys = this.initDataFun(); //初始化数据
+    this.defaultOpenKeys = this.initDataFun(this); //初始化数据
   },
   beforeDestroy() {},
   watch: {},
@@ -91,23 +91,25 @@ export default {
     ...mapGetters(['routes', 'sidebar']),
     // 菜单选择变化时,需要刷新值
     activeMenu() {
-      const route = this.$route;
+      let that = this;
+      const route = that.$route;
       const { meta, path } = route;
       // if set path, the sidebar will highlight the path you set
       if (meta.activeMenu) {
         return meta.activeMenu;
       }
       // console.log(meta, path);
-      return path;
+      that.defaultOpenKeys = that.initDataFun(that);
+      return [path];
     },
   },
   methods: {
     // 初始化菜单展开状态
-    initDataFun() {
+    initDataFun(that) {
       let defaultPath = [];
-      let routeInfo = optionalCopy(this.$route, 'matched');
-      for (let i = 0; i < this.routes.length; i++) {
-        let item = this.routes[i];
+      let routeInfo = optionalCopy(that.$route, 'matched');
+      for (let i = 0; i < that.routes.length; i++) {
+        let item = that.routes[i];
         if (item.path === routeInfo.path) {
           // console.log('1111');
           break;

+ 22 - 0
src/router/menu.js

@@ -65,6 +65,28 @@ export default [
           },
         ],
       },
+      {
+        path: '/examQuestionManagement/batchImport',
+        meta: { title: '批量导入' },
+      },
+    ],
+  },
+  {
+    meta: { title: '答题管理', icon: 'ali-icon-bianji' },
+    path: '/answerManagement',
+    children: [
+      {
+        path: '/answerManagement/day',
+        meta: { title: '每日答题管理' },
+      },
+      {
+        path: '/answerManagement/week',
+        meta: { title: '每周答题管理' },
+      },
+      {
+        meta: { title: '专项答题管理' },
+        path: '/answerManagement/special',
+      },
     ],
   },
   {

+ 30 - 0
src/router/modules/answerManagement.js

@@ -0,0 +1,30 @@
+import layout from '@/components/layout';
+export default {
+  path: '/answerManagement',
+  meta: { title: '答题管理' },
+  redirect: '/answerManagement/day',
+  component: layout,
+  children: [
+    {
+      path: 'day',
+      name: 'answerManagement-day',
+      meta: { title: '每日答题管理' },
+      component: () =>
+        import('@/views/answerManagement/answerManagementDay'),
+    },
+    {
+      path: 'week',
+      name: 'answerManagement-week',
+      meta: { title: '每周答题管理' },
+      component: () =>
+        import('@/views/answerManagement/answerManagementWeek'),
+    },
+    {
+      path: 'special',
+      name: 'answerManagement-special',
+      meta: { title: '专项答题管理' },
+      component: () =>
+        import('@/views/answerManagement/answerManagementSpecial'),
+    }
+  ],
+};

+ 7 - 0
src/router/modules/examQuestionManagement.js

@@ -47,5 +47,12 @@ export default {
       component: () =>
         import('@/views/examQuestionManagement/examQusetionCreateGapFilling'),
     },
+    {
+      path: 'batchImport',
+      name: 'examQuestion-batchImport',
+      meta: { title: '批量导入题目' },
+      component: () =>
+        import('@/views/examQuestionManagement/examQuestionBatchImport'),
+    },
   ],
 };

+ 37 - 0
src/views/answerManagement/answerManagementDay.vue

@@ -0,0 +1,37 @@
+<template>
+  <div class="app-container">
+    <a-spin :spinning="loading">
+      <div class="common-card">这里是每日答题</div>
+    </a-spin>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'answerManagementDay',
+  props: {},
+  components: {},
+  data() {
+    return {
+      loading: false, // 是否显示加载动画
+    };
+  },
+  created() {
+    this.initDataFun(); //初始化数据
+  },
+  mounted() {},
+  beforeDestroy() {},
+  watch: {},
+  computed: {},
+  methods: {
+    //初始化数据
+    initDataFun() {},
+  },
+};
+</script>
+
+<style lang="less"></style>
+
+<style lang="less" scoped>
+@import '~@/styles/common/variable.less';
+</style>

+ 37 - 0
src/views/answerManagement/answerManagementSpecial.vue

@@ -0,0 +1,37 @@
+<template>
+  <div class="app-container">
+    <a-spin :spinning="loading">
+      <div class="common-card">这里是专项答题</div>
+    </a-spin>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'answerManagementSpecial',
+  props: {},
+  components: {},
+  data() {
+    return {
+      loading: false, // 是否显示加载动画
+    };
+  },
+  created() {
+    this.initDataFun(); //初始化数据
+  },
+  mounted() {},
+  beforeDestroy() {},
+  watch: {},
+  computed: {},
+  methods: {
+    //初始化数据
+    initDataFun() {},
+  },
+};
+</script>
+
+<style lang="less"></style>
+
+<style lang="less" scoped>
+@import '~@/styles/common/variable.less';
+</style>

+ 37 - 0
src/views/answerManagement/answerManagementWeek.vue

@@ -0,0 +1,37 @@
+<template>
+  <div class="app-container">
+    <a-spin :spinning="loading">
+      <div class="common-card">这里是每周答题</div>
+    </a-spin>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'answerManagementWeek',
+  props: {},
+  components: {},
+  data() {
+    return {
+      loading: false, // 是否显示加载动画
+    };
+  },
+  created() {
+    this.initDataFun(); //初始化数据
+  },
+  mounted() {},
+  beforeDestroy() {},
+  watch: {},
+  computed: {},
+  methods: {
+    //初始化数据
+    initDataFun() {},
+  },
+};
+</script>
+
+<style lang="less"></style>
+
+<style lang="less" scoped>
+@import '~@/styles/common/variable.less';
+</style>

+ 37 - 0
src/views/examQuestionManagement/examQuestionBatchImport.vue

@@ -0,0 +1,37 @@
+<template>
+  <div class="app-container">
+    <a-spin :spinning="loading">
+      <div class="common-card">这里是批量导入</div>
+    </a-spin>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'examQuestionBatchImport',
+  props: {},
+  components: {},
+  data() {
+    return {
+      loading: false, // 是否显示加载动画
+    };
+  },
+  created() {
+    this.initDataFun(); //初始化数据
+  },
+  mounted() {},
+  beforeDestroy() {},
+  watch: {},
+  computed: {},
+  methods: {
+    //初始化数据
+    initDataFun() {},
+  },
+};
+</script>
+
+<style lang="less"></style>
+
+<style lang="less" scoped>
+@import '~@/styles/common/variable.less';
+</style>

+ 1 - 1
src/views/login/index.vue

@@ -86,7 +86,7 @@ export default {
         if (!err) {
           console.log(values);
           let params = {
-            userName: values.loginUerName,
+            userName: values.loginUserName,
             password: values.loginPassword,
             token: AUTH_TOKEN_FRONT,
           };

+ 45 - 3
src/views/user/userManagementList.vue

@@ -104,7 +104,9 @@
           :row-key="(record) => record.registerTime"
           :pagination="false"
         >
-          <!-- <template slot="action" slot-scope="text, record"></template> -->
+          <template slot="action" slot-scope="text, record">
+            <a @click="userDelete(record)">删除</a>
+          </template>
         </a-table>
         <!-- 分页 -->
         <div class="a-pagination-display">
@@ -172,6 +174,12 @@ export default {
           key: 'password',
           scopedSlots: { customRender: 'password' },
         },
+        {
+          title: '操作',
+          dataIndex: 'action',
+          key: 'action',
+          scopedSlots: { customRender: 'action' },
+        },
       ];
       this.getAdminListFun(); // 查询:已有账号列表
     },
@@ -221,15 +229,49 @@ export default {
       this.loading = true;
       this.$_http
         .post(this.$_API.INTERFACE_POST_USER_ADMIN, params)
-        .then((res) => {
-          console.log(res);
+        .then(() => {
           this.$message.success('新建账号成功');
+          // 清空表单值
+          this.addAdminForm.setFieldsValue({
+            userName: '',
+            password: '',
+            passwordSecond: '',
+            nickName: '',
+          });
           this.loading = false;
+          this.getAdminListFun(); // 查询:已有账号列表
         })
         .catch(() => {
           this.loading = false;
         });
     },
+    // 操作:删除用户
+    userDelete(record) {
+      let that = this;
+      that.$confirm({
+        title: '删除',
+        content: `确认删除 ${record.userName} 吗?`,
+        okText: '确认',
+        cancelText: '取消',
+        onOk() {
+          that.loading = true;
+          let params = {
+            userName: record.userName,
+          };
+          that.$_http
+            .delete(that.$_API.INTERFACE_DELETE_USER_ADMIN, { data: params })
+            .then(() => {
+              that.loading = false;
+              that.$message.success('删除用户成功');
+              this.getAdminListFun(); // 查询:已有账号列表
+            })
+            .catch(() => {
+              that.loading = false;
+            });
+        },
+        onCancel() {},
+      });
+    },
   },
 };
 </script>