Browse Source

对接用户管理接口

yellowtaotao 3 years ago
parent
commit
d7a197e155

+ 1 - 1
src/api/modules/exam.js

@@ -4,7 +4,7 @@ export default {
     // 查询考试列表信息
     INTERFACE_GET_EXAMS: "exams",
     // 删除某个考试
-    INTERFACE_DELETE_EXAM: "/exams/{examId}",
+    INTERFACE_DELETE_EXAM: "exams/{examId}",
     // 批量删除考试
     INTERFACE_DELETE_EXAMS: "admin/someexams",
     // 查询某场考试的详细信息

+ 3 - 3
src/api/modules/examQuestion.js

@@ -15,10 +15,10 @@ export default {
     // 新建试题
     INTERFACE_POST_EXAMS_QUESTION_ADD: "questions",
     // 删除某一个试题
-    INTERFACE_DELETE_EXAMS_QUESTION_DELETE: "/questions/{questionId}",
+    INTERFACE_DELETE_EXAMS_QUESTION_DELETE: "questions/{questionId}",
     // 批量删除试题
-    INTERFACE_DELETE_EXAMS_QUESTION_DELETE_LIST: "/admin/somequestions",
+    INTERFACE_DELETE_EXAMS_QUESTION_DELETE_LIST: "admin/somequestions",
     // 查询某个试题的详情
-    INTERFACE_GET_EXAMS_QUESTION_DETAIL: "/question/{questionId}"
+    INTERFACE_GET_EXAMS_QUESTION_DETAIL: "question/{questionId}"
   }
 };

+ 7 - 3
src/api/modules/user.js

@@ -2,8 +2,12 @@
 export default {
   API_LIST_USER: {
     // 登录
-    INTERFACE_POST_USER_LOGIN: '',
-    //  admin获取所有用户
-    INTERFACE_GET_USER_ADMIN_USERS: "admin/users",
+    INTERFACE_GET_USER_LOGIN: 'user/login',
+    // 查询管理员列表
+    INTERFACE_GET_USER_LIST: 'admin/users',
+    // 新增管理员
+    INTERFACE_POST_USER_ADMIN: "admin/register",
+    // 删除管理员
+    INTERFACE_DELETE_USER_ADMIN: "admin/users",
   }
 };

+ 0 - 15
src/common/Constant.js

@@ -57,18 +57,3 @@ export const EXAM_STATUS_TYPE = {
 // 考试状态对应的文本
 export const EXAM_STATUS_TYPE_TXT = ['未开始', '正在考试', '已结束'];
 
-// 接口请求的了---------------------------------------
-// 工种类型
-export const ENGINEERING_WORK_LIST = [
-  { id: 1, name: '桥隧工', code: 'QiaoSuiGong' },
-  // { id: 2, name: "测量工", code: "CeLiangGong" },
-  { id: 3, name: '线路工', code: 'XianLuGong' },
-];
-// 试题类型
-export const EXAM_QUESTION_TYPE_CONDITION = [
-  { id: 1, name: '类型1', code: 'LeiBie1' },
-  { id: 2, name: '类型2', code: 'LeiBie2' },
-  { id: 3, name: '类型3', code: 'LeiBie3' },
-  { id: 4, name: '类型4', code: 'LeiBie4' },
-];
-// 接口请求的了---------------------------------------

+ 1 - 10
src/filters/index.js

@@ -193,16 +193,7 @@ export function formatePathParams(path, formatePathParams) {
 export function formateUrlParams(path, urlParams) {
   let paramsNum = 0;
   for (let key in urlParams) {
-    // // 如果urlParams不为空,并且是第一个不为空的参数时,直接进行拼接,不用加&
-    // if (path === 'aaa/bbb?' && urlParams[key]) {
-    //   path = path + key + '=' + urlParams[key];
-    //   // 如果该项的obj不为空(等于0也可以),但不是第一个不为空的参数时,加&进行拼接
-    // } else if (
-    //   (path !== 'aaa/bbb?' && urlParams[key]) ||
-    //   (path !== 'aaa/bbb?' && urlParams[key] === 0)
-    // ) {
-    //   path = path + '&' + key + '=' + urlParams[key];
-    // }
+    // 如果urlParams不为空,并且是第一个不为空的参数时,直接进行拼接,不用加&
     paramsNum++;
     if (paramsNum === 1) {
       path = path + '?' + key + '=' + urlParams[key];

+ 11 - 8
src/views/examManagement/examManualVolumeFormation.vue

@@ -159,7 +159,6 @@
               id="examManualVolumeFormationSubmit"
               type="primary"
               html-type="submit"
-              ref="submitBtn"
               >提交</a-button
             >
           </a-form-item>
@@ -664,7 +663,6 @@ export default {
           { params }
         )
         .then((res) => {
-          console.log('已有题目', res);
           let resData = res.data.content;
           resData.forEach((item) => {
             // 试题类别
@@ -1101,12 +1099,12 @@ export default {
               values.examTimeLong.hours,
               values.examTimeLong.minutes
             ), // 考试持续时间
-            startTime: this.examDateTime, // 开始日期
+            startTime: this.examDateTime.replace(' ', 'T'), // 开始日期
             deadline: formateDateTimeToAfter(
               this.examDateTime,
               values.examTimeLong.hours,
               values.examTimeLong.minutes
-            ), // 结束日期
+            ).replace(' ', 'T'), // 结束日期
             tages: [],
             engineerTypes: [engineerTypeInfo], // 信息集合:工种
             type: this.examTypeChooseValue, // 考试类别
@@ -1137,8 +1135,10 @@ export default {
           params
         )
         .then((res) => {
-          console.log(res);
           this.loading = false;
+          if (res.data.id) {
+            this.httpQuestAddQuestionsFun(res.data.id); // 表单提交请求:题目
+          }
         })
         .catch(() => {
           this.loading = false;
@@ -1146,6 +1146,9 @@ export default {
     },
     // 表单提交请求:题目
     httpQuestAddQuestionsFun(examId) {
+      if (!examId) {
+        return;
+      }
       this.loading = true;
       let dataArr = [];
       this.disabledIdArr.forEach((item) => {
@@ -1160,10 +1163,10 @@ export default {
           formatePathParams(this.$_API.INTERFACE_POST_EXAM_ADD_QUESTIONS, {
             examId,
           }),
-          { data: dataArr }
+          dataArr
         )
-        .then((res) => {
-          console.log(res);
+        .then(() => {
+          this.$message.success('添加考试成功');
           this.loading = false;
         })
         .catch(() => {

+ 11 - 3
src/views/examQuestionManagement/examQuestionList.vue

@@ -402,10 +402,18 @@ export default {
         cancelText: '取消',
         onOk() {
           that.loading = true;
+          // let arr = [];
+          // that.selectedRowKeys.forEach((item) => {
+          //   let obj = {
+          //     questionid: item,
+          //   };
+          //   arr.push(obj);
+          // });
           that.$_http
-            .delete(that.$_API.INTERFACE_DELETE_EXAMS_QUESTION_DELETE_LIST, {
-              data: that.selectedRowKeys,
-            })
+            .delete(
+              that.$_API.INTERFACE_DELETE_EXAMS_QUESTION_DELETE_LIST,
+              that.selectedRowKeys
+            )
             .then(() => {
               that.selectedRowKeys = [];
               that.loading = false;

+ 7 - 10
src/views/login/index.vue

@@ -14,11 +14,9 @@
           placeholder="账户"
           :maxLength="10"
           v-decorator="[
-            'userName',
+            'loginUserName',
             {
-              rules: [
-                { required: true, message: 'Please input your userName!' },
-              ],
+              rules: [{ required: true, message: '请输入您的账户!' }],
             },
           ]"
         >
@@ -34,11 +32,9 @@
           placeholder="密码"
           :maxLength="10"
           v-decorator="[
-            'password',
+            'loginPassword',
             {
-              rules: [
-                { required: true, message: 'Please input your password!' },
-              ],
+              rules: [{ required: true, message: '请输入您的密码!' }],
             },
           ]"
         >
@@ -90,7 +86,8 @@ export default {
         if (!err) {
           console.log(values);
           let params = {
-            ...values,
+            userName: values.loginUerName,
+            password: values.loginPassword,
             token: AUTH_TOKEN_FRONT,
           };
           this.httpLoginFun(params);
@@ -99,7 +96,7 @@ export default {
     },
     httpLoginFun(params) {
       // this.$_http
-      //   .get(this.$_API.INTERFACE_GET_USER_ADMIN_USERS)
+      //   .get(this.$_API.INTERFACE_GET_USER_LOGIN)
       //   .then((res) => {
       //     // 自己的操作
       //     console.log(res);

+ 225 - 4
src/views/user/userManagementList.vue

@@ -1,7 +1,124 @@
 <template>
   <div class="app-container">
-    <div class="common-card"></div>
-    <div class="common-card a-card-margin-top"></div>
+    <a-spin :spinning="loading">
+      <div class="common-card basic-information-box">
+        <div class="basic-information-title">新建账号</div>
+        <div class="user-form-div">
+          <a-form
+            :form="addAdminForm"
+            autocomplete="off"
+            style="width: 400px;"
+            @submit="handleSubmitForm"
+          >
+            <a-form-item
+              label="账号"
+              :label-col="labelCol"
+              :wrapper-col="wrapperCol"
+            >
+              <a-input
+                placeholder="输入账号"
+                :maxLength="10"
+                autocomplete="off"
+                allow-clear
+                v-decorator="[
+                  'userName',
+                  {
+                    rules: [{ required: true, message: '请输入账号!' }],
+                    initialValue: '',
+                  },
+                ]"
+              />
+            </a-form-item>
+            <a-form-item
+              label="密码"
+              :label-col="labelCol"
+              :wrapper-col="wrapperCol"
+            >
+              <a-input
+                placeholder="输入密码"
+                :maxLength="10"
+                autocomplete="off"
+                allow-clear
+                v-decorator="[
+                  'password',
+                  {
+                    rules: [{ required: true, message: '请输入密码!' }],
+                    initialValue: '',
+                  },
+                ]"
+              />
+            </a-form-item>
+            <a-form-item
+              label="确认密码"
+              :label-col="labelCol"
+              :wrapper-col="wrapperCol"
+            >
+              <a-input
+                placeholder="确认密码"
+                :maxLength="10"
+                autocomplete="off"
+                allow-clear
+                v-decorator="[
+                  'passwordSecond',
+                  {
+                    rules: [{ required: true, message: '请输入相同的密码!' }],
+                    initialValue: '',
+                  },
+                ]"
+              />
+            </a-form-item>
+            <a-form-item
+              label="用户名"
+              :label-col="labelCol"
+              :wrapper-col="wrapperCol"
+            >
+              <a-input
+                placeholder="请输入用户名"
+                :maxLength="10"
+                autocomplete="off"
+                allow-clear
+                v-decorator="[
+                  'nickName',
+                  {
+                    rules: [{ required: true, message: '请输入用户名' }],
+                    initialValue: '',
+                  },
+                ]"
+              />
+            </a-form-item>
+            <a-form-item
+              :wrapper-col="{
+                sm: { span: 12, offset: 12 },
+              }"
+            >
+              <a-button type="primary" html-type="submit">提交</a-button>
+            </a-form-item>
+          </a-form>
+        </div>
+      </div>
+      <div class="common-card a-card-margin-top">
+        <!-- 表单 -->
+        <a-table
+          :columns="columns"
+          :data-source="tableData"
+          :row-key="(record) => record.registerTime"
+          :pagination="false"
+        >
+          <!-- <template slot="action" slot-scope="text, record"></template> -->
+        </a-table>
+        <!-- 分页 -->
+        <div class="a-pagination-display">
+          <a-pagination
+            v-model="pagination.current"
+            :pageSize="pagination.pageSize"
+            :total.sync="pagination.total"
+            show-less-items
+            show-quick-jumper
+            @change="getAdminListFun"
+          />
+        </div>
+      </div>
+    </a-spin>
   </div>
 </template>
 
@@ -11,7 +128,21 @@ export default {
   props: {},
   components: {},
   data() {
-    return {};
+    return {
+      loading: false, // 是否显示加载动画
+      // 基础信息的表单
+      labelCol: { span: 6 }, // 表单行中label的占位
+      wrapperCol: { span: 18 }, // 表单行中内容的占位
+      addAdminForm: this.$form.createForm(this, { name: 'addAdminForm' }), // 表单
+      // table
+      columns: {}, // 表格列配置
+      tableData: [], // 表格数据
+      pagination: {
+        pageSize: 10,
+        current: 1,
+        total: 0,
+      }, // 分页参数
+    };
   },
   created() {
     this.initDataFun(); //初始化数据
@@ -22,7 +153,83 @@ export default {
   computed: {},
   methods: {
     //初始化数据
-    initDataFun() {},
+    initDataFun() {
+      // 表单的列的配置参数
+      this.columns = [
+        {
+          title: '账号',
+          dataIndex: 'userName',
+          key: 'userName',
+        },
+        {
+          title: '用户名',
+          dataIndex: 'nickName',
+          key: 'nickName',
+        },
+        {
+          title: '密码',
+          dataIndex: 'password',
+          key: 'password',
+          scopedSlots: { customRender: 'password' },
+        },
+      ];
+      this.getAdminListFun(); // 查询:已有账号列表
+    },
+    // 查询:已有账号列表
+    getAdminListFun() {
+      this.loading = true;
+      // let params = {
+      //   page: this.pagination.current,
+      //   size: this.pagination.pageSize,
+      // };
+      this.$_http
+        .get(this.$_API.INTERFACE_GET_USER_LIST)
+        .then((res) => {
+          this.tableData = res.data.content;
+          this.pagination.total = res.data.totalElements; // 总条数
+          this.loading = false;
+        })
+        .catch(() => {
+          this.loading = false;
+        });
+    },
+    // 操作:新建
+    handleSubmitForm(e) {
+      e.preventDefault();
+      this.addAdminForm.validateFields((err, values) => {
+        if (!err) {
+          if (values.password !== values.passwordSecond) {
+            this.addAdminForm.setFields({
+              password: {
+                value: values.password,
+                errors: [new Error('密码输入不一致')],
+              },
+              passwordSecond: {
+                value: values.passwordSecond,
+                errors: [new Error('密码输入不一致')],
+              },
+            });
+            return;
+          } else {
+            this.httpLoginFun(values); // 表单提交请求:新建管理员
+          }
+        }
+      });
+    },
+    // 表单提交请求:新建管理员
+    httpLoginFun(params) {
+      this.loading = true;
+      this.$_http
+        .post(this.$_API.INTERFACE_POST_USER_ADMIN, params)
+        .then((res) => {
+          console.log(res);
+          this.$message.success('新建账号成功');
+          this.loading = false;
+        })
+        .catch(() => {
+          this.loading = false;
+        });
+    },
   },
 };
 </script>
@@ -31,4 +238,18 @@ export default {
 
 <style lang="less" scoped>
 @import '~@/styles/common/variable.less';
+.app-container {
+  overflow-y: auto;
+  .basic-information-title {
+    font-size: 18px;
+    font-weight: bold;
+    color: @mainColorBlack85;
+    margin-bottom: @paddingMarginVal;
+  }
+  .user-form-div {
+    width: 100%;
+    display: flex;
+    justify-content: center;
+  }
+}
 </style>