Selaa lähdekoodia

添加答题管理(查看用户及分数)

asd123a20 3 vuotta sitten
vanhempi
commit
6d3b6b58a5

+ 6 - 0
admin-frame/lib/apps.js

@@ -134,5 +134,11 @@ export default [
     entry: config.dev ? '//localhost:3021/admin-problem/' : 'admin-problem',
     container: config.tabs ? '#problem' : '#content',
     activeRule: '/admin/problem'
+  },
+  {
+    name: 'admin-paper',
+    entry: config.dev ? '//localhost:3022/admin-paper/' : 'admin-paper',
+    container: config.tabs ? '#paper' : '#content',
+    activeRule: '/admin/paper'
   }
 ];

+ 3 - 0
admin-paper/.browserslistrc

@@ -0,0 +1,3 @@
+> 1%
+last 2 versions
+not dead

+ 5 - 0
admin-paper/.editorconfig

@@ -0,0 +1,5 @@
+[*.{js,jsx,ts,tsx,vue}]
+indent_style = space
+indent_size = 2
+trim_trailing_whitespace = true
+insert_final_newline = true

+ 2 - 0
admin-paper/.env

@@ -0,0 +1,2 @@
+# 窗口使用弹出还是抽屉 (dialog And drawer)
+VUE_APP_WINDOW=dialog

+ 1 - 0
admin-paper/.eslintignore

@@ -0,0 +1 @@
+public-path.js

+ 23 - 0
admin-paper/.eslintrc.js

@@ -0,0 +1,23 @@
+module.exports = {
+  root: true,
+  env: {
+    node: true
+  },
+  extends: [
+    'plugin:vue/essential',
+    '@vue/standard'
+  ],
+  parserOptions: {
+    parser: 'babel-eslint'
+  },
+  rules: {
+    'no-console': 0,
+    'no-debugger': 0,
+    'comma-dangle': [2, 'never'],
+    'no-extra-parens': 2,
+    'no-extra-semi': 2,
+    semi: [2, 'always'],
+    'space-before-function-paren': [0, 'always'],
+    eqeqeq: 0
+  }
+};

+ 23 - 0
admin-paper/.gitignore

@@ -0,0 +1,23 @@
+.DS_Store
+node_modules
+/dist
+
+
+# local env files
+.env.local
+.env.*.local
+
+# Log files
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+
+# Editor directories and files
+.idea
+.vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?

+ 24 - 0
admin-paper/README.md

@@ -0,0 +1,24 @@
+# admin-gaf
+
+## Project setup
+```
+npm install
+```
+
+### Compiles and hot-reloads for development
+```
+npm run serve
+```
+
+### Compiles and minifies for production
+```
+npm run build
+```
+
+### Lints and fixes files
+```
+npm run lint
+```
+
+### Customize configuration
+See [Configuration Reference](https://cli.vuejs.org/config/).

+ 5 - 0
admin-paper/babel.config.js

@@ -0,0 +1,5 @@
+module.exports = {
+  presets: [
+    '@vue/cli-plugin-babel/preset'
+  ]
+};

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 12565 - 0
admin-paper/package-lock.json


+ 35 - 0
admin-paper/package.json

@@ -0,0 +1,35 @@
+{
+  "name": "admin-paper",
+  "version": "0.1.0",
+  "private": true,
+  "scripts": {
+    "serve": "vue-cli-service serve",
+    "build": "vue-cli-service build",
+    "lint": "vue-cli-service lint"
+  },
+  "dependencies": {
+    "core-js": "^3.6.5",
+    "element-ui": "^2.15.6",
+    "sass": "^1.48.0",
+    "sass-loader": "^10.0.0",
+    "vue": "^2.6.11",
+    "vue-router": "^3.2.0",
+    "vuex": "^3.4.0"
+  },
+  "devDependencies": {
+    "@vue/cli-plugin-babel": "~4.5.0",
+    "@vue/cli-plugin-eslint": "~4.5.0",
+    "@vue/cli-plugin-router": "~4.5.0",
+    "@vue/cli-plugin-vuex": "~4.5.0",
+    "@vue/cli-service": "~4.5.0",
+    "@vue/eslint-config-standard": "^5.1.2",
+    "babel-eslint": "^10.1.0",
+    "eslint": "^6.7.2",
+    "eslint-plugin-import": "^2.20.2",
+    "eslint-plugin-node": "^11.1.0",
+    "eslint-plugin-promise": "^4.2.1",
+    "eslint-plugin-standard": "^4.0.0",
+    "eslint-plugin-vue": "^6.2.2",
+    "vue-template-compiler": "^2.6.11"
+  }
+}

BIN
admin-paper/public/favicon.ico


+ 17 - 0
admin-paper/public/index.html

@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="">
+  <head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width,initial-scale=1.0">
+    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
+    <title><%= htmlWebpackPlugin.options.title %></title>
+  </head>
+  <body>
+    <noscript>
+      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
+    </noscript>
+    <div id="app"></div>
+    <!-- built files will be auto injected -->
+  </body>
+</html>

+ 24 - 0
admin-paper/src/App.vue

@@ -0,0 +1,24 @@
+<template>
+  <div id="app">
+    <router-view></router-view>
+  </div>
+</template>
+
+<script>
+export default {
+  components: {},
+  computed: {},
+  data() {
+    return {};
+  },
+  mounted() {},
+  methods: {}
+};
+</script>
+
+<style lang="scss" scoped>
+#app {
+  width: 100%;
+  height: 100%;
+}
+</style>

BIN
admin-paper/src/assets/logo.png


+ 49 - 0
admin-paper/src/main.js

@@ -0,0 +1,49 @@
+import Vue from 'vue';
+import App from './App.vue';
+import VueRouter from 'vue-router';
+import routes from './router';
+import store from './store';
+import ElementUI from 'element-ui';
+import 'element-ui/lib/theme-chalk/index.css';
+import './public-path.js';
+import dict from '@lib/dict.js';
+import tree from '@lib/tree.js';
+import resChange from '@lib/resChange.js';
+Vue.config.productionTip = false;
+Vue.use(VueRouter);
+Vue.use(ElementUI);
+Vue.use(dict);
+Vue.use(tree);
+Vue.use(resChange);
+let router = null;
+let instance = null;
+function render (props = {}) {
+  const { container } = props;
+  router = new VueRouter({
+    base: window.__POWERED_BY_QIANKUN__ ? '/admin/paper/' : '/',
+    mode: 'history',
+    routes
+  });
+  instance = new Vue({
+    router,
+    store,
+    render: (h) => h(App)
+  }).$mount(container ? container.querySelector('#app') : '#app');
+}
+
+// 独立运行时
+if (!window.__POWERED_BY_QIANKUN__) {
+  render();
+}
+
+export async function bootstrap () {}
+export async function mount (props) {
+  console.log(123);
+  render(props);
+}
+export async function unmount () {
+  instance.$destroy();
+  instance.$el.innerHTML = '';
+  instance = null;
+  router = null;
+}

+ 3 - 0
admin-paper/src/public-path.js

@@ -0,0 +1,3 @@
+if (window.__POWERED_BY_QIANKUN__) {
+  __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
+}

+ 10 - 0
admin-paper/src/router/index.js

@@ -0,0 +1,10 @@
+import home from '../views/home.vue';
+const routes = [
+  {
+    path: '/home',
+    name: 'home',
+    component: home
+  }
+];
+
+export default routes;

+ 56 - 0
admin-paper/src/store/index.js

@@ -0,0 +1,56 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import $axios from '@lib/axios.js';
+const api = {
+  paperCreate: '/api/question/paper/create',
+  paperUpdate: '/api/question/paper/update',
+  paperDelete: '/api/question/paper/delete',
+  paperQuery: '/api/question/paper/query'
+};
+Vue.use(Vuex);
+const state = () => ({
+  Total: 0,
+  paperList: [],
+  bindList: [],
+  roleList: []
+});
+
+const actions = {
+  async paperCreate ({ commit }, payload) {
+    const res = await $axios.post(api.paperCreate, payload);
+    return res;
+  },
+  async paperUpdate ({ commit }, payload) {
+    const res = await $axios.post(api.paperUpdate, { ...payload, id: payload._id });
+    return res;
+  },
+  async paperDelete ({ commit }, { id }) {
+    const res = await $axios.delete(`${api.paperDelete}/${id}`);
+    return res;
+  },
+  async paperQuery ({ commit }, { filter, paging } = {}) {
+    const res = await $axios.get(api.paperQuery, { ...filter, skip: paging.page, limit: paging.size });
+    commit('paperQuery', res);
+    return res;
+  }
+};
+
+const mutations = {
+  paperQuery(state, payload) {
+    state.paperList = payload.data;
+    state.Total = payload.total;
+  },
+  queryBind(state, payload) {
+    state.bindList = payload.data;
+  },
+  roleQuery(state, payload) {
+    state.roleList = payload.data;
+  }
+};
+
+export default new Vuex.Store({
+  state,
+  actions,
+  mutations,
+  modules: {}
+});

+ 125 - 0
admin-paper/src/views/home.vue

@@ -0,0 +1,125 @@
+<template>
+  <div class="box">
+    <el-card class="box-card">
+      <div slot="header" class="clearfix">
+        <span>答题管理</span>
+        <!-- <el-button style="float: right; padding: 3px 0" type="text" @click="addpaper">添加答题</el-button> -->
+      </div>
+      <div class="main">
+        <filterList ref="filterList" :tableData="paperList" :filed="filed" @edit="filtereEdit" @delete="filterDelete" @query="filterQuery" :total="Total"></filterList>
+      </div>
+    </el-card>
+    <dialogAndDrawer :width="'35%'" :title="title" :visibleSync="visibleSync" v-if="visibleSync" @close="visibleSync = false">
+      <template v-slot:windowMain>
+        <formData :filed="formfiled" :data="formdata" :rules="formrules" @save="formSave"></formData>
+      </template>
+    </dialogAndDrawer>
+  </div>
+</template>
+<script>
+import filterList from '@components/filterList/index.vue';
+import dialogAndDrawer from '@components/dialogAndDrawer.vue';
+import formData from '@components/formData/index.vue';
+import { mapState, mapActions } from 'vuex';
+export default {
+  components: {
+    filterList,
+    dialogAndDrawer,
+    formData
+  },
+  data() {
+    return {
+      title: '',
+      visibleSync: false,
+      filed: [
+        { name: 'userName', label: '姓名', filter: true },
+        { name: 'fraction', label: '分数' }
+      ],
+      formdata: {},
+      formfiled: [
+        { name: 'userName', label: '姓名' },
+        { name: 'fraction', label: '分数' }
+      ],
+      formrules: {
+        title: [
+          { required: true, message: '请输入答题', trigger: 'blur' }
+        ],
+        answer: [
+          { required: true, message: '请输入答案', trigger: 'blur' }
+        ],
+        fraction: [
+          { required: true, message: '请输入分数', trigger: 'blur' }
+        ]
+      }
+    };
+  },
+  computed: {
+    ...mapState(['paperList', 'Total'])
+  },
+  async mounted() {
+    await this.filterQuery();
+  },
+  methods: {
+    ...mapActions(['paperQuery', 'paperCreate', 'paperUpdate', 'paperDelete']),
+    // 添加
+    addpaper () {
+      this.formdata = {};
+      this.title = '添加答题';
+      this.visibleSync = true;
+    },
+    // 修改
+    filtereEdit (e) {
+      this.formdata = e;
+      this.title = '修改答题';
+      this.visibleSync = true;
+      this.bind = false;
+    },
+    // 删除
+    async filterDelete (e) {
+      const res = await this.paperDelete({ id: e?._id });
+      this.$resChange(res, '删除成功');
+      this.filterQuery();
+    },
+    // 查询
+    async filterQuery ({ filter = {}, paging = { page: 0, size: 10 } } = {}) {
+      await this.paperQuery({ filter, paging });
+    },
+    // 表单保存
+    async formSave (e) {
+      if (e.isRevise && e?.isRevise == false) {
+        this.$message.warning('未作修改');
+        return;
+      }
+      this.$delete(e, 'isRevise');
+      let res, msg;
+      e.options = this.options;
+      // 修改
+      if (e._id) {
+        res = await this.paperUpdate(e);
+        msg = '答题修改成功';
+      } else {
+        res = await this.paperCreate(e);
+        msg = '答题添加成功';
+      }
+      this.$resChange(res, msg);
+      this.filterQuery();
+      this.visibleSync = false;
+    }
+  }
+};
+</script>
+<style lang="scss" scoped>
+.box {
+  width: 100%;
+  height: 100%;
+  .box-card {
+    height: 100%;
+    .el-card__body {
+      height: 100%;
+    }
+  }
+  .item > .el-form-item__content{
+    display: flex;
+  }
+}
+</style>

+ 33 - 0
admin-paper/vue.config.js

@@ -0,0 +1,33 @@
+const path = require('path');
+const frameSrc = path.resolve(__dirname, '../admin-frame');
+const packageName = require('./package.json').name;
+module.exports = {
+  publicPath: `/${packageName}/`,
+  outputDir: path.join(frameSrc, `../../admin-web/${packageName}/`),
+  devServer: {
+    port: 3022,
+    headers: {
+      'Access-Control-Allow-Origin': '*'
+    },
+    proxy: {
+      '/api/': {
+        // target: 'http://192.168.0.45:18090'
+        target: 'http://192.168.3.45:18090'
+      }
+    }
+  },
+  configureWebpack: {
+    output: {
+      library: `${packageName}-[name]`,
+      libraryTarget: 'umd',
+      jsonpFunction: `webpackJsonp_${packageName}`
+    },
+    resolve: {
+      alias: {
+        '@components': path.join(frameSrc, '/src/components'),
+        '@style': path.join(frameSrc, '/style'),
+        '@lib': path.join(frameSrc, '/lib')
+      }
+    }
+  }
+};

+ 3 - 0
xms.code-workspace

@@ -63,6 +63,9 @@
 		{
 			"path": "admin-problem"
 		},
+		{
+			"path": "admin-paper"
+		},
 	],
 	"settings": {}
 }