asd123a20 3 rokov pred
rodič
commit
963c45a690

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

@@ -128,5 +128,11 @@ export default [
     entry: config.dev ? '//localhost:3020/admin-client-vip/' : 'admin-client-vip',
     container: config.tabs ? '#clientVip' : '#content',
     activeRule: '/admin/clientVip'
+  },
+  {
+    name: 'admin-problem',
+    entry: config.dev ? '//localhost:3021/admin-problem/' : 'admin-problem',
+    container: config.tabs ? '#problem' : '#content',
+    activeRule: '/admin/problem'
   }
 ];

+ 3 - 0
admin-problem/.browserslistrc

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

+ 5 - 0
admin-problem/.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-problem/.env

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

+ 1 - 0
admin-problem/.eslintignore

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

+ 23 - 0
admin-problem/.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-problem/.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-problem/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-problem/babel.config.js

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

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 12565 - 0
admin-problem/package-lock.json


+ 35 - 0
admin-problem/package.json

@@ -0,0 +1,35 @@
+{
+  "name": "admin-problem",
+  "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-problem/public/favicon.ico


+ 17 - 0
admin-problem/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-problem/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-problem/src/assets/logo.png


+ 49 - 0
admin-problem/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/problem/' : '/',
+    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-problem/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-problem/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-problem/src/store/index.js

@@ -0,0 +1,56 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import $axios from '@lib/axios.js';
+const api = {
+  problemCreate: '/api/question/bank/create',
+  problemUpdate: '/api/question/bank/update',
+  problemDelete: '/api/question/bank/delete',
+  problemQuery: '/api/question/bank/query'
+};
+Vue.use(Vuex);
+const state = () => ({
+  Total: 0,
+  problemList: [],
+  bindList: [],
+  roleList: []
+});
+
+const actions = {
+  async problemCreate ({ commit }, payload) {
+    const res = await $axios.post(api.problemCreate, payload);
+    return res;
+  },
+  async problemUpdate ({ commit }, payload) {
+    const res = await $axios.post(api.problemUpdate, { ...payload, id: payload._id });
+    return res;
+  },
+  async problemDelete ({ commit }, { id }) {
+    const res = await $axios.delete(`${api.problemDelete}/${id}`);
+    return res;
+  },
+  async problemQuery ({ commit }, { filter, paging } = {}) {
+    const res = await $axios.get(api.problemQuery, { ...filter, skip: paging.page, limit: paging.size });
+    commit('problemQuery', res);
+    return res;
+  }
+};
+
+const mutations = {
+  problemQuery(state, payload) {
+    state.problemList = 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: {}
+});

+ 160 - 0
admin-problem/src/views/home.vue

@@ -0,0 +1,160 @@
+<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="addproblem">添加问题</el-button>
+      </div>
+      <div class="main">
+        <filterList ref="filterList" :tableData="problemList" :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">
+          <template v-slot:ext="{ }">
+            <el-form-item
+              v-for="(domain, index) in options"
+              :label="'选项' +(index + 1)"
+              :key="domain.key"
+              class="item"
+            >
+              <el-input v-model="domain.value"></el-input>
+              <el-button v-if="index == options.length - 1" type="primary" icon="el-icon-plus" @click="addDomain"></el-button>
+              <el-button type="primary" icon="el-icon-minus" @click.prevent="removeDomain(domain)"></el-button>
+            </el-form-item>
+          </template>
+        </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 {
+      options: [{ value: '' }],
+      title: '',
+      visibleSync: false,
+      bind: false,
+      filed: [
+        { name: 'title', label: '问题', filter: true },
+        { name: 'answer', label: '答案' },
+        { name: 'fraction', label: '分数' }
+      ],
+      formdata: {},
+      formfiled: [
+        { name: 'title', label: '问题' },
+        { name: 'answer', label: '答案' },
+        { name: 'fraction', label: '分数' }
+        // { name: 'options', label: '选项', formater: 'slot' }
+      ],
+      formrules: {
+        title: [
+          { required: true, message: '请输入问题', trigger: 'blur' }
+        ],
+        answer: [
+          { required: true, message: '请输入答案', trigger: 'blur' }
+        ],
+        fraction: [
+          { required: true, message: '请输入分数', trigger: 'blur' }
+        ]
+      },
+      problemInfo: {},
+      values: []
+    };
+  },
+  computed: {
+    ...mapState(['problemList', 'Total'])
+  },
+  async mounted() {
+    await this.filterQuery();
+  },
+  methods: {
+    ...mapActions(['problemQuery', 'problemCreate', 'problemUpdate', 'problemDelete']),
+    // 删除选项
+    removeDomain(item) {
+      var index = this.options.indexOf(item);
+      if (index !== -1) {
+        this.options.splice(index, 1);
+      }
+    },
+    // 增加选项
+    addDomain() {
+      this.options.push({
+        value: ''
+      });
+    },
+    // 添加
+    addproblem () {
+      this.formdata = {};
+      this.title = '添加问题';
+      this.visibleSync = true;
+      this.options = [{ value: '' }];
+    },
+    // 修改
+    filtereEdit (e) {
+      this.formdata = e;
+      this.options = e.options;
+      this.title = '修改问题';
+      this.visibleSync = true;
+      this.bind = false;
+    },
+    // 删除
+    async filterDelete (e) {
+      const res = await this.problemDelete({ id: e?._id });
+      this.$resChange(res, '删除成功');
+      this.filterQuery();
+    },
+    // 查询
+    async filterQuery ({ filter = {}, paging = { page: 0, size: 10 } } = {}) {
+      await this.problemQuery({ 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.problemUpdate(e);
+        msg = '问题修改成功';
+      } else {
+        res = await this.problemCreate(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-problem/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: 3021,
+    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

@@ -60,6 +60,9 @@
 		{
 			"path": "admin-client-vip"
 		},
+		{
+			"path": "admin-problem"
+		},
 	],
 	"settings": {}
 }