瀏覽代碼

新增驾考题目管理模块

wyling007 3 年之前
父節點
當前提交
9b2fa548ed
共有 3 個文件被更改,包括 323 次插入73 次删除
  1. 32 0
      src/api/subject.js
  2. 223 0
      src/views/subject/index.vue
  3. 68 73
      vue.config.js

+ 32 - 0
src/api/subject.js

@@ -0,0 +1,32 @@
+import request from "@/utils/request";
+
+class SubjectApi {
+  /**查询题目列表 */
+  getList(query) {
+    return request({
+      url: "pc/question/info/list",
+      method: "get",
+      params: query,
+    });
+  }
+
+  /**根据专题类型获取具体分类 */
+  getIssueType(query) {
+    return request({
+      url: "pc/question/info/issueType",
+      method: "get",
+      params: query,
+    });
+  }
+
+  /**修改题目顺序 */
+  setSubjectSort(data) {
+    return request({
+      url: "pc/question/info",
+      method: "put",
+      data,
+    });
+  }
+}
+
+export default new SubjectApi();

+ 223 - 0
src/views/subject/index.vue

@@ -0,0 +1,223 @@
+<template>
+  <div class="app-container">
+    <!--搜索模块-->
+    <el-form :model="queryParams" ref="queryForm" :inline="true">
+      <el-form-item label="科目" prop="subject">
+        <el-select v-model="queryParams.subject" placeholder="请选择科目">
+          <el-option label="科目一" :value="1" />
+          <el-option label="科目四" :value="4" />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="类型参数" prop="issueTypeValue">
+        <el-select
+          v-model="queryParams.issueTypeValue"
+          placeholder="请选择类型"
+        >
+          <el-option label="分类专题" :value="1" />
+          <el-option label="精选专题" :value="2" />
+          <el-option label="地方专题" :value="3" />
+          <el-option label="顺序练习" :value="4" />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="分类id值" prop="issueValue">
+        <el-select v-model="queryParams.issueValue" placeholder="请选择分类">
+          <el-option
+            v-for="item in issueTypeList"
+            :label="item.title"
+            :value="item.typeId"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item>
+        <el-button
+          type="cyan"
+          icon="el-icon-search"
+          size="mini"
+          @click="handleQuery"
+          >搜索</el-button
+        >
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
+          >重置</el-button
+        >
+      </el-form-item>
+    </el-form>
+
+    <!--列表数据模块-->
+    <div class="table-box">
+      <el-table v-loading="loading" :data="list" height="100%">
+        <el-table-column label="ID" align="center" prop="id" />
+        <el-table-column
+          label="题目"
+          width="300px"
+          align="center"
+          prop="issue"
+        />
+        <el-table-column label="指定顺序" align="center" width="130px">
+          <template slot-scope="scope">
+            <el-card :body-style="{ padding: '5px' }">
+              <div class="sort-card">
+                <el-input
+                  v-model="scope.row.sort"
+                  placeholder="题目顺序"
+                  type="number"
+                  size="small"
+                />
+                <el-button
+                  type="primary"
+                  size="mini"
+                  @click="setSort(scope.row)"
+                  >修改顺序</el-button
+                >
+              </div>
+            </el-card>
+          </template>
+        </el-table-column>
+        <el-table-column
+          label="分类模块名称"
+          align="center"
+          prop="classIssueName"
+        />
+        <el-table-column
+          label="精选模块名称"
+          align="center"
+          prop="excellIssueName"
+        />
+        <el-table-column
+          label="顺序模块名称"
+          align="center"
+          prop="sequeIssueName"
+        />
+      </el-table>
+    </div>
+
+    <pagination
+      v-show="total > 0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+  </div>
+</template>
+
+<script>
+import subjectApi from "@/api/subject";
+
+export default {
+  name: "Subject",
+  data() {
+    return {
+      //表格加载状态
+      loading: false,
+      //表格数据
+      list: null,
+      // 总条数
+      total: 0,
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        issueTypeValue: 1,
+        issueValue: "1",
+        subject: 1,
+      },
+      //具体分类列表
+      issueTypeList: null,
+    };
+  },
+  created() {
+    this.getList();
+    this.getIssueTypeList();
+  },
+  watch: {
+    "queryParams.subject": {
+      handler() {
+        this.getIssueTypeList();
+      },
+    },
+    "queryParams.issueTypeValue": {
+      handler() {
+        this.getIssueTypeList();
+      },
+    },
+  },
+  methods: {
+    /**查询用户列表 */
+    async getList() {
+      this.loading = true;
+      const res = await subjectApi.getList(this.queryParams);
+      this.list = res.rows;
+      this.total = res.total;
+      this.loading = false;
+    },
+    /**获取具体分类列表 */
+    async getIssueTypeList() {
+      const res = await subjectApi.getIssueType({
+        issueTypeValue: this.queryParams.issueTypeValue,
+        subject: this.queryParams.subject,
+      });
+      this.issueTypeList = res.data;
+      this.$set(this.queryParams, "issueValue", this.issueTypeList[0].typeId);
+    },
+    /**修改题目顺序 */
+    async setSort(row) {
+      try {
+        await this.$confirm(
+          `确认修改题目ID为${row.id}的顺序为${row.sort}吗?`,
+          "修改题目顺序",
+          {
+            distinguishCancelAndClose: true,
+            confirmButtonText: "保存",
+            cancelButtonText: "放弃修改",
+          }
+        );
+        await subjectApi.setSubjectSort({
+          id: row.id,
+          sort: row.sort,
+          issueTypeValue: this.queryParams.issueTypeValue,
+        });
+        this.$message({
+          type: "info",
+          message: "保存修改",
+        });
+        this.getList();
+      } catch (error) {
+        this.$message({
+          type: "info",
+          message: "放弃修改",
+        });
+      }
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.page = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.app-container {
+  display: flex;
+  flex-direction: column;
+  height: calc(100vh - 150px);
+  padding: 20px;
+  .table-box {
+    flex-grow: 1;
+  }
+}
+
+.sort-card {
+  display: flex;
+  flex-direction: column;
+  justify-content: space-around;
+  align-items: center;
+  height: 70px;
+}
+</style>

+ 68 - 73
vue.config.js

@@ -1,14 +1,14 @@
-'use strict'
-const path = require('path')
-const defaultSettings = require('./src/settings.js')
+"use strict";
+const path = require("path");
+const defaultSettings = require("./src/settings.js");
 
 function resolve(dir) {
-  return path.join(__dirname, dir)
+  return path.join(__dirname, dir);
 }
 
-const name = defaultSettings.title || '若依管理系统' // 标题
+const name = defaultSettings.title || "若依管理系统"; // 标题
 
-const port = process.env.port || process.env.npm_config_port || 80 // 端口
+const port = process.env.port || process.env.npm_config_port || 80; // 端口
 
 // vue.config.js 配置说明
 //官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions
@@ -19,100 +19,95 @@ module.exports = {
   // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
   publicPath: process.env.NODE_ENV === "production" ? "/" : "/",
   // 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist)
-  outputDir: 'dist',
+  outputDir: "dist",
   // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
-  assetsDir: 'static',
+  assetsDir: "static",
   // 是否开启eslint保存检测,有效值:ture | false | 'error'
-  lintOnSave: process.env.NODE_ENV === 'development',
+  lintOnSave: process.env.NODE_ENV === "development",
   // 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
   productionSourceMap: false,
   // webpack-dev-server 相关配置
   devServer: {
-    host: '0.0.0.0',
+    host: "0.0.0.0",
     port: port,
     open: true,
     proxy: {
       // detail: https://cli.vuejs.org/config/#devserver-proxy
       [process.env.VUE_APP_BASE_API]: {
-        target: `http://localhost:8080`,
+        target: "http://218.85.55.253:65535/twzd-admin",
         changeOrigin: true,
         pathRewrite: {
-          ['^' + process.env.VUE_APP_BASE_API]: ''
-        }
-      }
+          ["^" + process.env.VUE_APP_BASE_API]: "",
+        },
+      },
     },
-    disableHostCheck: true
+    disableHostCheck: true,
   },
   configureWebpack: {
     name: name,
     resolve: {
       alias: {
-        '@': resolve('src')
-      }
-    }
+        "@": resolve("src"),
+      },
+    },
   },
   chainWebpack(config) {
-    config.plugins.delete('preload') // TODO: need test
-    config.plugins.delete('prefetch') // TODO: need test
+    config.plugins.delete("preload"); // TODO: need test
+    config.plugins.delete("prefetch"); // TODO: need test
 
     // set svg-sprite-loader
+    config.module.rule("svg").exclude.add(resolve("src/assets/icons")).end();
     config.module
-      .rule('svg')
-      .exclude.add(resolve('src/assets/icons'))
-      .end()
-    config.module
-      .rule('icons')
+      .rule("icons")
       .test(/\.svg$/)
-      .include.add(resolve('src/assets/icons'))
+      .include.add(resolve("src/assets/icons"))
       .end()
-      .use('svg-sprite-loader')
-      .loader('svg-sprite-loader')
+      .use("svg-sprite-loader")
+      .loader("svg-sprite-loader")
       .options({
-        symbolId: 'icon-[name]'
+        symbolId: "icon-[name]",
       })
-      .end()
+      .end();
 
-    config
-      .when(process.env.NODE_ENV !== 'development',
-        config => {
-          config
-            .plugin('ScriptExtHtmlWebpackPlugin')
-            .after('html')
-            .use('script-ext-html-webpack-plugin', [{
-            // `runtime` must same as runtimeChunk name. default is `runtime`
-              inline: /runtime\..*\.js$/
-            }])
-            .end()
-          config
-            .optimization.splitChunks({
-              chunks: 'all',
-              cacheGroups: {
-                libs: {
-                  name: 'chunk-libs',
-                  test: /[\\/]node_modules[\\/]/,
-                  priority: 10,
-                  chunks: 'initial' // only package third parties that are initially dependent
-                },
-                elementUI: {
-                  name: 'chunk-elementUI', // split elementUI into a single package
-                  priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
-                  test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
-                },
-                commons: {
-                  name: 'chunk-commons',
-                  test: resolve('src/components'), // can customize your rules
-                  minChunks: 3, //  minimum common number
-                  priority: 5,
-                  reuseExistingChunk: true
-                }
-              }
-            })
-          config.optimization.runtimeChunk('single'),
+    config.when(process.env.NODE_ENV !== "development", (config) => {
+      config
+        .plugin("ScriptExtHtmlWebpackPlugin")
+        .after("html")
+        .use("script-ext-html-webpack-plugin", [
           {
-             from: path.resolve(__dirname, './public/robots.txt'),//防爬虫文件
-             to:'./',//到根目录下
-          }
-        }
-      )
-  }
-}
+            // `runtime` must same as runtimeChunk name. default is `runtime`
+            inline: /runtime\..*\.js$/,
+          },
+        ])
+        .end();
+      config.optimization.splitChunks({
+        chunks: "all",
+        cacheGroups: {
+          libs: {
+            name: "chunk-libs",
+            test: /[\\/]node_modules[\\/]/,
+            priority: 10,
+            chunks: "initial", // only package third parties that are initially dependent
+          },
+          elementUI: {
+            name: "chunk-elementUI", // split elementUI into a single package
+            priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
+            test: /[\\/]node_modules[\\/]_?element-ui(.*)/, // in order to adapt to cnpm
+          },
+          commons: {
+            name: "chunk-commons",
+            test: resolve("src/components"), // can customize your rules
+            minChunks: 3, //  minimum common number
+            priority: 5,
+            reuseExistingChunk: true,
+          },
+        },
+      });
+      config.optimization.runtimeChunk("single"),
+        {
+          from: path.resolve(__dirname, "./public/robots.txt"), //防爬虫文件
+          to: "./", //到根目录下
+        };
+    });
+  },
+};