lrf402788946 5 yıl önce
ebeveyn
işleme
fea6fe410b

+ 4 - 0
.env

@@ -0,0 +1,4 @@
+VUE_APP_AXIOS_BASE_URL = ''
+VUE_APP_ROOT_URL=/admin/
+VUE_APP_MODULE='school'
+VUE_APP_LIMIT = 10

+ 33 - 0
.eslintrc.js

@@ -0,0 +1,33 @@
+// https://eslint.org/docs/user-guide/configuring
+
+module.exports = {
+  root: true,
+  env: {
+    node: true,
+  },
+  extends: ['plugin:vue/essential', '@vue/prettier'],
+  plugins: ['vue'],
+  rules: {
+    'max-len': [
+      'warn',
+      {
+        code: 250,
+      },
+    ],
+    'no-unused-vars': 'off',
+    'no-console': 'off',
+    'prettier/prettier': [
+      'warn',
+      {
+        singleQuote: true,
+        trailingComma: 'es5',
+        bracketSpacing: true,
+        jsxBracketSameLine: true,
+        printWidth: 160,
+      },
+    ],
+  },
+  parserOptions: {
+    parser: 'babel-eslint',
+  },
+};

+ 1 - 1
.gitignore

@@ -1,7 +1,7 @@
 .DS_Store
 node_modules
 /dist
-
+package-lock.json
 # local env files
 .env.local
 .env.*.local

+ 154 - 4
package-lock.json

@@ -940,6 +940,37 @@
         "to-fast-properties": "^2.0.0"
       }
     },
+    "@fullcalendar/core": {
+      "version": "4.4.0",
+      "resolved": "https://registry.npm.taobao.org/@fullcalendar/core/download/@fullcalendar/core-4.4.0.tgz",
+      "integrity": "sha1-edvAzKg2zmKKB+c5pFbaEf8UE3M="
+    },
+    "@fullcalendar/daygrid": {
+      "version": "4.4.0",
+      "resolved": "https://registry.npm.taobao.org/@fullcalendar/daygrid/download/@fullcalendar/daygrid-4.4.0.tgz",
+      "integrity": "sha1-Jfyucia2Joi04IamEVguciU7Uik="
+    },
+    "@fullcalendar/interaction": {
+      "version": "4.4.0",
+      "resolved": "https://registry.npm.taobao.org/@fullcalendar/interaction/download/@fullcalendar/interaction-4.4.0.tgz",
+      "integrity": "sha1-/I+LqvXLNTPWzgpoTW+ZUqRDBoU="
+    },
+    "@fullcalendar/vue": {
+      "version": "4.4.0",
+      "resolved": "https://registry.npm.taobao.org/@fullcalendar/vue/download/@fullcalendar/vue-4.4.0.tgz",
+      "integrity": "sha1-18cCUhfQlAeTnWutaHYp0hdQGyc=",
+      "requires": {
+        "@fullcalendar/core": "~4.4.0",
+        "fast-deep-equal": "^2.0.1"
+      },
+      "dependencies": {
+        "fast-deep-equal": {
+          "version": "2.0.1",
+          "resolved": "https://registry.npm.taobao.org/fast-deep-equal/download/fast-deep-equal-2.0.1.tgz",
+          "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk="
+        }
+      }
+    },
     "@hapi/address": {
       "version": "2.1.4",
       "resolved": "https://registry.npm.taobao.org/@hapi/address/download/@hapi/address-2.1.4.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40hapi%2Faddress%2Fdownload%2F%40hapi%2Faddress-2.1.4.tgz",
@@ -2046,6 +2077,14 @@
       "integrity": "sha1-3TeelPDbgxCwgpH51kwyCXZmF/0=",
       "dev": true
     },
+    "async-validator": {
+      "version": "1.8.5",
+      "resolved": "https://registry.npm.taobao.org/async-validator/download/async-validator-1.8.5.tgz?cache=0&sync_timestamp=1575620599372&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fasync-validator%2Fdownload%2Fasync-validator-1.8.5.tgz",
+      "integrity": "sha1-3D4I7B/Q3dtn5ghC8CwM0c7G1/A=",
+      "requires": {
+        "babel-runtime": "6.x"
+      }
+    },
     "asynckit": {
       "version": "0.4.0",
       "resolved": "https://registry.npm.taobao.org/asynckit/download/asynckit-0.4.0.tgz",
@@ -2093,6 +2132,37 @@
       "integrity": "sha1-fjPY99RJs/ZzzXLeuavcVS2+Uo4=",
       "dev": true
     },
+    "axios": {
+      "version": "0.19.2",
+      "resolved": "https://registry.npm.taobao.org/axios/download/axios-0.19.2.tgz",
+      "integrity": "sha1-PqNsXYgY0NX4qKl6bTa4bNwAyyc=",
+      "requires": {
+        "follow-redirects": "1.5.10"
+      },
+      "dependencies": {
+        "debug": {
+          "version": "3.1.0",
+          "resolved": "https://registry.npm.taobao.org/debug/download/debug-3.1.0.tgz",
+          "integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=",
+          "requires": {
+            "ms": "2.0.0"
+          }
+        },
+        "follow-redirects": {
+          "version": "1.5.10",
+          "resolved": "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.5.10.tgz",
+          "integrity": "sha1-e3qfmuov3/NnhqlP9kPtB/T/Xio=",
+          "requires": {
+            "debug": "=3.1.0"
+          }
+        },
+        "ms": {
+          "version": "2.0.0",
+          "resolved": "https://registry.npm.taobao.org/ms/download/ms-2.0.0.tgz",
+          "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
+        }
+      }
+    },
     "babel-eslint": {
       "version": "10.0.3",
       "resolved": "https://registry.npm.taobao.org/babel-eslint/download/babel-eslint-10.0.3.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbabel-eslint%2Fdownload%2Fbabel-eslint-10.0.3.tgz",
@@ -2107,6 +2177,11 @@
         "resolve": "^1.12.0"
       }
     },
+    "babel-helper-vue-jsx-merge-props": {
+      "version": "2.0.3",
+      "resolved": "https://registry.npm.taobao.org/babel-helper-vue-jsx-merge-props/download/babel-helper-vue-jsx-merge-props-2.0.3.tgz",
+      "integrity": "sha1-Iq69OzOQIyjlEyk6jkmSs4T58bY="
+    },
     "babel-loader": {
       "version": "8.0.6",
       "resolved": "https://registry.npm.taobao.org/babel-loader/download/babel-loader-8.0.6.tgz",
@@ -2128,6 +2203,27 @@
         "object.assign": "^4.1.0"
       }
     },
+    "babel-runtime": {
+      "version": "6.26.0",
+      "resolved": "https://registry.npm.taobao.org/babel-runtime/download/babel-runtime-6.26.0.tgz",
+      "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=",
+      "requires": {
+        "core-js": "^2.4.0",
+        "regenerator-runtime": "^0.11.0"
+      },
+      "dependencies": {
+        "core-js": {
+          "version": "2.6.11",
+          "resolved": "https://registry.npm.taobao.org/core-js/download/core-js-2.6.11.tgz?cache=0&sync_timestamp=1578957006406&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcore-js%2Fdownload%2Fcore-js-2.6.11.tgz",
+          "integrity": "sha1-OIMUafmSK97Y7iHJ3EaYXgOZMIw="
+        },
+        "regenerator-runtime": {
+          "version": "0.11.1",
+          "resolved": "https://registry.npm.taobao.org/regenerator-runtime/download/regenerator-runtime-0.11.1.tgz",
+          "integrity": "sha1-vgWtf5v30i4Fb5cmzuUBf78Z4uk="
+        }
+      }
+    },
     "balanced-match": {
       "version": "1.0.0",
       "resolved": "https://registry.npm.taobao.org/balanced-match/download/balanced-match-1.0.0.tgz",
@@ -3647,8 +3743,7 @@
     "deepmerge": {
       "version": "1.5.2",
       "resolved": "https://registry.npm.taobao.org/deepmerge/download/deepmerge-1.5.2.tgz?cache=0&sync_timestamp=1572279812893&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdeepmerge%2Fdownload%2Fdeepmerge-1.5.2.tgz",
-      "integrity": "sha1-EEmdhohEza1P7ghC34x/bwyVp1M=",
-      "dev": true
+      "integrity": "sha1-EEmdhohEza1P7ghC34x/bwyVp1M="
     },
     "default-gateway": {
       "version": "5.0.5",
@@ -4087,6 +4182,19 @@
       "integrity": "sha1-xvE/J9UhJkOXmGekAMGl6KTvBCo=",
       "dev": true
     },
+    "element-ui": {
+      "version": "2.13.0",
+      "resolved": "https://registry.npm.taobao.org/element-ui/download/element-ui-2.13.0.tgz",
+      "integrity": "sha1-9rsE5bCnbqX2JGYES3dEB7pOvS0=",
+      "requires": {
+        "async-validator": "~1.8.1",
+        "babel-helper-vue-jsx-merge-props": "^2.0.0",
+        "deepmerge": "^1.2.0",
+        "normalize-wheel": "^1.0.1",
+        "resize-observer-polyfill": "^1.5.0",
+        "throttle-debounce": "^1.0.1"
+      }
+    },
     "elliptic": {
       "version": "6.5.2",
       "resolved": "https://registry.npm.taobao.org/elliptic/download/elliptic-6.5.2.tgz",
@@ -7141,8 +7249,7 @@
     "lodash": {
       "version": "4.17.15",
       "resolved": "https://registry.npm.taobao.org/lodash/download/lodash-4.17.15.tgz?cache=0&sync_timestamp=1563508077056&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.15.tgz",
-      "integrity": "sha1-tEf2ZwoEVbv+7dETku/zMOoJdUg=",
-      "dev": true
+      "integrity": "sha1-tEf2ZwoEVbv+7dETku/zMOoJdUg="
     },
     "lodash.defaultsdeep": {
       "version": "4.6.1",
@@ -7627,6 +7734,14 @@
         "thenify-all": "^1.0.0"
       }
     },
+    "naf-core": {
+      "version": "0.1.2",
+      "resolved": "https://registry.npm.taobao.org/naf-core/download/naf-core-0.1.2.tgz",
+      "integrity": "sha1-0UetT3+BTsnSvYGPWCOVHgWAsJU=",
+      "requires": {
+        "lodash": "^4.17.11"
+      }
+    },
     "nan": {
       "version": "2.14.0",
       "resolved": "https://registry.npm.taobao.org/nan/download/nan-2.14.0.tgz",
@@ -7789,6 +7904,11 @@
       "integrity": "sha1-suHE3E98bVd0PfczpPWXjRhlBVk=",
       "dev": true
     },
+    "normalize-wheel": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npm.taobao.org/normalize-wheel/download/normalize-wheel-1.0.1.tgz",
+      "integrity": "sha1-rsiGr/2wRQcNhWRH32Ls+GFG7EU="
+    },
     "npm-run-path": {
       "version": "2.0.2",
       "resolved": "https://registry.npm.taobao.org/npm-run-path/download/npm-run-path-2.0.2.tgz",
@@ -9386,6 +9506,11 @@
       "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=",
       "dev": true
     },
+    "resize-observer-polyfill": {
+      "version": "1.5.1",
+      "resolved": "https://registry.npm.taobao.org/resize-observer-polyfill/download/resize-observer-polyfill-1.5.1.tgz",
+      "integrity": "sha1-DpAg3T0hAkRY1OvSfiPkAmmBBGQ="
+    },
     "resolve": {
       "version": "1.15.1",
       "resolved": "https://registry.npm.taobao.org/resolve/download/resolve-1.15.1.tgz?cache=0&sync_timestamp=1580943346382&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fresolve%2Fdownload%2Fresolve-1.15.1.tgz",
@@ -10512,6 +10637,11 @@
         "neo-async": "^2.6.0"
       }
     },
+    "throttle-debounce": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npm.taobao.org/throttle-debounce/download/throttle-debounce-1.1.0.tgz",
+      "integrity": "sha1-UYU9o3vmihVctugns1FKPEIuic0="
+    },
     "through": {
       "version": "2.3.8",
       "resolved": "https://registry.npm.taobao.org/through/download/through-2.3.8.tgz",
@@ -11084,6 +11214,21 @@
         }
       }
     },
+    "vue-meta": {
+      "version": "2.3.2",
+      "resolved": "https://registry.npm.taobao.org/vue-meta/download/vue-meta-2.3.2.tgz",
+      "integrity": "sha1-2HpFZYLaBA/3vJMEcBzKR6w27h4=",
+      "requires": {
+        "deepmerge": "^4.2.2"
+      },
+      "dependencies": {
+        "deepmerge": {
+          "version": "4.2.2",
+          "resolved": "https://registry.npm.taobao.org/deepmerge/download/deepmerge-4.2.2.tgz?cache=0&sync_timestamp=1572279812893&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdeepmerge%2Fdownload%2Fdeepmerge-4.2.2.tgz",
+          "integrity": "sha1-RNLqNnm49NT/ujPwPYZfwee/SVU="
+        }
+      }
+    },
     "vue-router": {
       "version": "3.1.5",
       "resolved": "https://registry.npm.taobao.org/vue-router/download/vue-router-3.1.5.tgz",
@@ -11128,6 +11273,11 @@
       "resolved": "https://registry.npm.taobao.org/vuex/download/vuex-3.1.2.tgz",
       "integrity": "sha1-ooY/QAWqc/JYflXD+t8/AfacfU0="
     },
+    "wangeditor": {
+      "version": "3.1.1",
+      "resolved": "https://registry.npm.taobao.org/wangeditor/download/wangeditor-3.1.1.tgz",
+      "integrity": "sha1-+9PB1JdpI8nt67hbKdMLNVEq0Dk="
+    },
     "watchpack": {
       "version": "1.6.0",
       "resolved": "https://registry.npm.taobao.org/watchpack/download/watchpack-1.6.0.tgz?cache=0&sync_timestamp=1579095944058&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fwatchpack%2Fdownload%2Fwatchpack-1.6.0.tgz",

+ 11 - 1
package.json

@@ -8,10 +8,20 @@
     "lint": "vue-cli-service lint"
   },
   "dependencies": {
+    "@fullcalendar/core": "^4.4.0",
+    "@fullcalendar/daygrid": "^4.4.0",
+    "@fullcalendar/interaction": "^4.4.0",
+    "@fullcalendar/vue": "^4.4.0",
+    "axios": "^0.19.2",
     "core-js": "^3.6.4",
+    "element-ui": "^2.13.0",
+    "lodash": "^4.17.15",
+    "naf-core": "^0.1.2",
     "vue": "^2.6.11",
+    "vue-meta": "^2.3.2",
     "vue-router": "^3.1.5",
-    "vuex": "^3.1.2"
+    "vuex": "^3.1.2",
+    "wangeditor": "^3.1.1"
   },
   "devDependencies": {
     "@vue/cli-plugin-babel": "^4.2.0",

+ 17 - 22
src/App.vue

@@ -1,32 +1,27 @@
 <template>
   <div id="app">
-    <div id="nav">
-      <router-link to="/">Home</router-link> |
-      <router-link to="/about">About</router-link>
-    </div>
     <router-view />
   </div>
 </template>
+<script>
+export default {
+  name: 'App',
+  components: {},
+};
+</script>
 
 <style lang="less">
-#app {
-  font-family: Avenir, Helvetica, Arial, sans-serif;
-  -webkit-font-smoothing: antialiased;
-  -moz-osx-font-smoothing: grayscale;
-  text-align: center;
-  color: #2c3e50;
-}
-
-#nav {
-  padding: 30px;
-
-  a {
-    font-weight: bold;
-    color: #2c3e50;
-
-    &.router-link-exact-active {
-      color: #42b983;
-    }
+html {
+  overflow: hidden;
+  body {
+    margin: 0;
+    padding: 0;
+  }
+  margin: 0;
+  padding: 0;
+  p {
+    margin: 0;
+    padding: 0;
   }
 }
 </style>

+ 10 - 7
src/main.js

@@ -1,12 +1,15 @@
-import Vue from "vue";
-import App from "./App.vue";
-import router from "./router";
-import store from "./store";
-
+import Vue from 'vue';
+import App from './App.vue';
+import router from './router';
+import store from './store';
+import '@/plugins/meta';
+import '@/plugins/axios';
+import '@/plugins/check-res';
+import '@/plugins/element';
 Vue.config.productionTip = false;
 
 new Vue({
   router,
   store,
-  render: h => h(App)
-}).$mount("#app");
+  render: h => h(App),
+}).$mount('#app');

+ 1 - 0
src/plugins/README.md

@@ -0,0 +1 @@
+### 框架使用的 vue plugin

+ 24 - 0
src/plugins/axios.js

@@ -0,0 +1,24 @@
+/* eslint-disable no-console */
+/* eslint-disable no-param-reassign */
+
+import Vue from 'vue';
+import AxiosWrapper from '@frame/utils/axios-wrapper';
+
+const Plugin = {
+  install(vue, options) {
+    // 3. 注入组件
+    vue.mixin({
+      created() {
+        if (this.$store && !this.$store.$axios) {
+          this.$store.$axios = this.$axios;
+          this.$store.$limit = process.env.VUE_APP_LIMIT;
+        }
+      },
+    });
+    // 4. 添加实例方法
+    vue.prototype.$axios = new AxiosWrapper(options);
+    vue.prototype.$limit = process.env.VUE_APP_LIMIT;
+  },
+};
+
+Vue.use(Plugin, { baseUrl: process.env.VUE_APP_AXIOS_BASE_URL, unwrap: true });

+ 40 - 0
src/plugins/check-res.js

@@ -0,0 +1,40 @@
+/* eslint-disable no-underscore-dangle */
+/* eslint-disable no-param-reassign */
+/* eslint-disable no-unused-vars */
+/* eslint-disable no-shadow */
+import Vue from 'vue';
+import _ from 'lodash';
+import { Message } from 'element-ui';
+
+const vm = new Vue({});
+const Plugin = {
+  install(Vue, options) {
+    // 4. 添加实例方法
+    Vue.prototype.$checkRes = (res, okText, errText) => {
+      let _okText = okText;
+      let _errText = errText;
+      if (!_.isFunction(okText) && _.isObject(okText) && okText != null) {
+        ({ okText: _okText, errText: _errText } = okText);
+      }
+      const { errcode = 0, errmsg } = res || {};
+      if (errcode === 0) {
+        if (_.isFunction(_okText)) {
+          return _okText();
+        }
+        if (_okText) {
+          Message.success(_okText);
+          // Message({ message: _okText, type: 'success', duration: 60000 });
+        }
+        return true;
+      }
+      if (_.isFunction(_errText)) {
+        return _errText();
+      }
+      Message.error(_errText || errmsg);
+      // Message({ message: _errText || errmsg, duration: 60000 });
+      return false;
+    };
+  },
+};
+
+Vue.use(Plugin);

+ 5 - 0
src/plugins/element.js

@@ -0,0 +1,5 @@
+import Vue from 'vue';
+import Element from 'element-ui';
+import 'element-ui/lib/theme-chalk/index.css';
+// 注册element-ui组件
+Vue.use(Element);

+ 4 - 0
src/plugins/meta.js

@@ -0,0 +1,4 @@
+import Vue from 'vue';
+import Meta from 'vue-meta';
+
+Vue.use(Meta);

+ 26 - 0
src/plugins/naf-dict.js

@@ -0,0 +1,26 @@
+/**
+ * 字典数据处理插件
+ */
+
+import Vue from 'vue';
+import _ from 'lodash';
+import assert from 'assert';
+
+const Plugin = {
+  install(vue, options) {
+    // 4. 添加实例方法
+    vue.prototype.$dict = function(codeType, code) {
+      assert(_.isString(codeType));
+      const state = this.$store.state.naf.dict;
+      if (!state) {
+        throw new Error("can't find store for naf dict");
+      }
+      if (_.isString(code)) {
+        return (state.codes[codeType] && state.codes[codeType][code]) || code;
+      } else {
+        return state.items[codeType];
+      }
+    };
+  },
+};
+Vue.use(Plugin);

+ 6 - 0
src/plugins/nut-ui.js

@@ -0,0 +1,6 @@
+import Vue from 'vue';
+import { Toast } from '@nutui/nutui';
+// import '@nutui/nutui/dist/nutui.css';
+
+// 注册nut-ui组件
+Toast.install(Vue); // 按需加载

+ 65 - 0
src/plugins/stomp.js

@@ -0,0 +1,65 @@
+/**
+ * 基于WebStomp的消息处理插件
+ */
+
+import Vue from 'vue';
+import _ from 'lodash';
+import assert from 'assert';
+import { Client } from '@stomp/stompjs/esm5/client';
+
+const Plugin = {
+  install(Vue, options) {
+    assert(_.isObject(options));
+    if (options.debug && !_.isFunction(options.debug)) {
+      options.debug = str => {
+        console.log(str);
+      };
+    }
+    assert(_.isString(options.brokerURL));
+    if (!options.brokerURL.startsWith('ws://')) {
+      options.brokerURL = `ws://${location.host}${options.brokerURL}`;
+    }
+
+    // 3. 注入组件
+    Vue.mixin({
+      beforeDestroy: function() {
+        if (this.$stompClient) {
+          this.$stompClient.deactivate();
+          delete this.$stompClient;
+        }
+      },
+    });
+
+    // 4. 添加实例方法
+    Vue.prototype.$stomp = function(subscribes = {}) {
+      // connect to mq
+      const client = new Client(options);
+      client.onConnect = frame => {
+        // Do something, all subscribes must be done is this callback
+        // This is needed because this will be executed after a (re)connect
+        console.log('[stomp] connected');
+        Object.keys(subscribes)
+          .filter(p => _.isFunction(subscribes[p]))
+          .forEach(key => {
+            client.subscribe(key, subscribes[key]);
+          });
+      };
+
+      client.onStompError = frame => {
+        // Will be invoked in case of error encountered at Broker
+        // Bad login/passcode typically will cause an error
+        // Complaint brokers will set `message` header with a brief message. Body may contain details.
+        // Compliant brokers will terminate the connection after any error
+        console.log('Broker reported error: ' + frame.headers['message']);
+        console.log('Additional details: ' + frame.body);
+      };
+
+      client.activate();
+
+      this.$stompClient = client;
+    };
+  },
+};
+export default () => {
+  Vue.use(Plugin, Vue.config.stomp);
+};

+ 22 - 16
src/router/index.js

@@ -1,28 +1,34 @@
-import Vue from "vue";
-import VueRouter from "vue-router";
-import Home from "../views/Home.vue";
+import Vue from 'vue';
+import VueRouter from 'vue-router';
 
 Vue.use(VueRouter);
 
 const routes = [
   {
-    path: "/",
-    name: "Home",
-    component: Home
+    path: '/',
+    name: 'frame',
+    component: () => import('@/views/index.vue'),
+    children: [
+      {
+        path: '/plan/index',
+        name: 'plan_list',
+        meta: { title: '计划', sub: '列表' },
+        component: () => import('@/views/plan/index.vue'),
+      },
+      {
+        path: '/plan/detail',
+        name: 'plan_detail',
+        meta: { title: '计划', sub: '详情' },
+        component: () => import('@/views/plan/detail.vue'),
+      },
+    ],
   },
-  {
-    path: "/about",
-    name: "About",
-    // route level code-splitting
-    // this generates a separate chunk (about.[hash].js) for this route
-    // which is lazy-loaded when the route is visited.
-    component: () =>
-      import(/* webpackChunkName: "about" */ "../views/About.vue")
-  }
 ];
 
 const router = new VueRouter({
-  routes
+  mode: 'history',
+  base: process.env.NODE_ENV === 'development' ? '' : process.env.VUE_APP_ROOT_URL + 'teacher',
+  routes,
 });
 
 export default router;

+ 5 - 3
src/store/index.js

@@ -1,5 +1,7 @@
-import Vue from "vue";
-import Vuex from "vuex";
+import Vue from 'vue';
+import Vuex from 'vuex';
+import trainplan from '@center/src/store/trainplan';
+import teaPlan from './tea-plan';
 
 Vue.use(Vuex);
 
@@ -7,5 +9,5 @@ export default new Vuex.Store({
   state: {},
   mutations: {},
   actions: {},
-  modules: {}
+  modules: { trainplan, teaPlan },
 });

+ 38 - 0
src/store/tea-plan.js

@@ -0,0 +1,38 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  interface: `/api/train/apply`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.interface}`, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.interface}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.interface}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.interface}/update/${id}`, data);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.interface}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 0 - 5
src/views/About.vue

@@ -1,5 +0,0 @@
-<template>
-  <div class="about">
-    <h1>This is an about page</h1>
-  </div>
-</template>

+ 0 - 18
src/views/Home.vue

@@ -1,18 +0,0 @@
-<template>
-  <div class="home">
-    <img alt="Vue logo" src="../assets/logo.png" />
-    <HelloWorld msg="Welcome to Your Vue.js App" />
-  </div>
-</template>
-
-<script>
-// @ is an alias to /src
-import HelloWorld from "@/components/HelloWorld.vue";
-
-export default {
-  name: "Home",
-  components: {
-    HelloWorld
-  }
-};
-</script>

+ 60 - 0
src/views/index.vue

@@ -0,0 +1,60 @@
+<template>
+  <div id="admin-index">
+    <div class="app-wrapper">
+      <admin-menu class="sidebar-container"></admin-menu>
+      <div class="main-container">
+        <admin-bar></admin-bar>
+        <fw-admin class="display"></fw-admin>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+import adminMenu from '@frame/layout/admin/admin-menu.vue';
+import adminBar from '@frame/layout/admin/navBar.vue';
+import fwAdmin from '@frame/layout/admin/fw-admin.vue';
+import { devMenu } from '@frame/config/menu-config';
+export default {
+  name: 'admin-index',
+  metaInfo: { title: ' 双困生培训系统' },
+  props: {},
+  components: {
+    fwAdmin,
+    adminMenu,
+    adminBar,
+    // breadcrumb,
+  },
+  data: () => ({
+    devMenu,
+  }),
+  created() {},
+  computed: {},
+  methods: {},
+};
+</script>
+
+<style lang="less" scoped>
+.display {
+  height: ~'calc(100% - 30px)';
+  padding: 0.3rem;
+}
+
+.app-wrapper {
+  position: relative;
+  height: 100%;
+  width: 100%;
+  &:after {
+    content: '';
+    display: table;
+    clear: both;
+  }
+}
+
+.main-container {
+  min-height: 100vh;
+  transition: margin-left 0.28s;
+  margin-left: 12rem;
+  background-color: #f0f2f5;
+}
+</style>

+ 252 - 0
src/views/plan/detail.vue

@@ -0,0 +1,252 @@
+<template>
+  <div id="detail">
+    <detail-frame :title="mainTitle" returns="/plan/index">
+      <el-row :gutter="10" type="flex">
+        <el-col :span="12">
+          <el-card header="全年计划信息">
+            <el-form :model="info" label-width="60px" size="small" @submit.native.prevent>
+              <el-form-item label="年份">
+                {{ info.year }}
+              </el-form-item>
+              <el-form-item label="标题" prop="title">
+                {{ info.title }}
+              </el-form-item>
+              <!-- <el-form-item label="备注" prop="remark">
+                <el-input v-model="info.remark" type="textarea" :autosize="{ minRows: 3, maxRows: 5 }"></el-input>
+              </el-form-item> -->
+
+              <el-collapse v-model="collapse" accordion>
+                <el-collapse-item title="上报可行时间列表" name="1">
+                  <data-table :fields="fields" :data="selected" :opera="opera" @delete="toDelete" :height="heights"></data-table>
+                </el-collapse-item>
+              </el-collapse>
+              <el-form-item>
+                <el-row type="flex" align="middle" justify="space-around" style="margin-top:20px">
+                  <el-col :span="6">
+                    <el-button type="primary" @click="savePlan">上报选择时间</el-button>
+                  </el-col>
+                </el-row>
+              </el-form-item>
+            </el-form>
+          </el-card>
+        </el-col>
+        <el-col :span="16" :style="`width:${widths}px`">
+          <el-card ref="card" v-if="info.year">
+            <calendar :year="info.year" :useDraft="false" @eventClick="eventClick" :events="events"></calendar>
+          </el-card>
+        </el-col>
+      </el-row>
+    </detail-frame>
+  </div>
+</template>
+
+<script>
+import detailFrame from '@frame/layout/admin/detail-frame';
+import calendar from '@frame/components/calendar';
+import dataTable from '@frame/components/data-table';
+import _ from 'lodash';
+import { createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('trainplan');
+const { mapActions: teaPlan } = createNamespacedHelpers('teaPlan');
+export default {
+  metaInfo: { title: '计划详情' },
+  name: 'detail',
+  props: {},
+  components: { detailFrame, calendar, dataTable },
+  data: () => ({
+    info: {},
+    form: {},
+    events: [],
+    collapse: '1',
+    fields: [
+      // { label: '期数', prop: 'termnum' },
+      { label: '名称', prop: 'name' },
+    ],
+    opera: [
+      {
+        label: '删除',
+        icon: 'el-icon-delete',
+        method: 'delete',
+        confirm: true,
+      },
+    ],
+    heights: 250,
+    selected: [],
+  }),
+  created() {
+    this.search();
+  },
+  mounted() {},
+  methods: {
+    ...mapActions(['fetch', 'create', 'update']),
+    ...teaPlan({
+      teaPlanQuery: 'query',
+      teaPlanCreate: 'create',
+      teaPlanDelete: 'delete',
+    }),
+    async searchTea() {
+      let res = await this.teaPlanQuery({ planid: this.id, teacherid: '5e4e260da4b2e15998bfb349' });
+      if (this.$checkRes(res)) {
+        let data = JSON.parse(JSON.stringify(res.data));
+        let arr = data.map(i => {
+          let event = this.events.find(f => f.termid === i.termid);
+          let object = {};
+          if (event) {
+            let { term } = event;
+            object = { termid: i.termid, name: `第${term}期`, id: i.id };
+          }
+          return object;
+        });
+        this.$set(this, `selected`, arr);
+      }
+    },
+    //查询计划
+    async search() {
+      const res = await this.fetch(this.id);
+      if (this.$checkRes(res)) this.$set(this, `info`, res.data);
+      let midArr = JSON.parse(JSON.stringify(res.data));
+      let events = [];
+      events = _.flatten(
+        midArr.termnum.map(item => {
+          item.batchnum.map(i => {
+            i.term = item.term;
+            i.termid = item._id; //需要使用期id
+            i.id = i._id;
+            i.start = JSON.parse(JSON.stringify(i.startdate));
+            i.end = JSON.parse(JSON.stringify(i.enddate));
+            i.title = JSON.parse(JSON.stringify(i.name));
+            delete i.startdate, delete i.enddate, delete i.name;
+            return i;
+          });
+          return item.batchnum;
+        })
+      );
+      let vac = midArr.festivals.map(i => {
+        let object = {};
+        object.id = i._id;
+        object.start = i.begindate;
+        object.end = i.finishdate;
+        object.rendering = 'background';
+        object.color = 'red';
+        object.editable = false;
+        return object;
+      });
+      this.$set(this, `events`, events.concat(vac));
+      this.searchTea();
+    },
+    //日历事件点击事件
+    eventClick({ event }) {
+      let arr = this.events.filter(fil => fil.id == event.id);
+      let object = {};
+      if (arr.length > 0) {
+        object = arr[0];
+        if (!_.get(object, 'editable', true)) {
+          this.$message.warning('不能上报假期的时间');
+          return;
+        }
+      } else {
+        console.warn(`无对应id事件`);
+        return;
+      }
+
+      let { termid } = object;
+      //查重,查看期数是否存在
+      let re = () => {
+        this.$notify({
+          title: '重复添加该期',
+          type: 'error',
+          duration: 2000,
+        });
+      };
+      let push = data => {
+        let res = this.savePlan(data);
+        if (res) {
+          this.$notify({
+            title: '已添加',
+            type: 'success',
+            duration: 2000,
+          });
+          this.searchTea();
+        } else {
+          this.$notify({
+            title: '添加失败',
+            type: 'error',
+            duration: 2000,
+          });
+        }
+      };
+      // 需要判断期id和期类型
+      let isSelected = this.selected.filter(i => i.termid === termid);
+      //不需要考虑特殊班
+      if (isSelected.length > 0) re();
+      else push(this.setTeacherDate(object));
+    },
+    //列表删除事件
+    async toDelete({ data, index }) {
+      //接口对接删除
+      let res = await this.teaPlanDelete(data.id);
+      if (this.$checkRes(res)) {
+        this.$notify({
+          title: '已删除',
+          type: 'success',
+          duration: 2000,
+        });
+        this.searchTea();
+      } else {
+        this.$notify({
+          title: '删除失败',
+          type: 'error',
+          duration: 2000,
+        });
+      }
+    },
+    //保存计划事件
+    async savePlan(data) {
+      // 因为数据形式不一样,教师上报时间是直接对接接口.
+      let subid = '5e4369a4275c2f5514ec2593';
+      let teacherid = '5e4e260da4b2e15998bfb349';
+      let { termid } = data;
+      let object = { termid, subid, teacherid };
+      let res = await this.teaPlanCreate(object);
+    },
+    setHeight() {
+      let heights = this.$refs.card.$el.clientHeight * 0.63;
+      this.$set(this, `heights`, heights);
+    },
+    //添加上报时间
+    setTeacherDate(object) {
+      let data = JSON.parse(JSON.stringify(object));
+      let res = {};
+      res.termid = JSON.parse(JSON.stringify(data.termid));
+      res.name = `第${data.term}期`;
+      return res;
+    },
+  },
+  computed: {
+    widths() {
+      let width = (document.body.clientWidth - 200) * 0.5;
+      return width > 400 ? width : 400;
+    },
+    id() {
+      return this.$route.query.id;
+    },
+    mainTitle() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      let sub = meta.sub || '';
+      return `${main}${sub}`;
+    },
+    keyWord() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      return main;
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+/deep/.el-divider--horizontal {
+  margin: 5px 0;
+}
+</style>

+ 69 - 0
src/views/plan/index.vue

@@ -0,0 +1,69 @@
+<template>
+  <div id="index">
+    <list-frame :title="mainTitle" @query="search" :total="total" :needFilter="false" :needAdd="false">
+      <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit"></data-table>
+    </list-frame>
+  </div>
+</template>
+
+<script>
+import listFrame from '@frame/layout/admin/list-frame';
+import dataTable from '@frame/components/data-table';
+import { createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('trainplan');
+
+export default {
+  metaInfo: { title: '计划一览' },
+  name: 'index',
+  props: {},
+  components: { listFrame, dataTable },
+  data: () => ({
+    opera: [
+      {
+        label: '查看全年计划',
+        icon: 'el-icon-date',
+        method: 'edit',
+      },
+    ],
+    fields: [
+      { label: '计划标题', prop: 'title' },
+      { label: '年度', prop: 'year' },
+    ],
+    list: [],
+    total: 0,
+  }),
+  created() {
+    this.search();
+  },
+  computed: {
+    mainTitle() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      let sub = meta.sub || '';
+      let title = main + sub;
+      return title;
+    },
+    keyWord() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      return main;
+    },
+  },
+  methods: {
+    ...mapActions(['query', 'delete']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    toEdit({ data }) {
+      //TODO 该把详情做成什么样的比较好,是和大日历在一起选择还是其他形式
+      this.$router.push({ path: '/plan/detail', query: { id: data.id } });
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 60 - 1
vue.config.js

@@ -1,3 +1,62 @@
+const path = require('path');
+const frame = path.resolve(__dirname, '../frame');
+const center = path.resolve(__dirname, '../train-center');
 module.exports = {
-  lintOnSave: false
+  publicPath: process.env.NODE_ENV === 'development' ? '/' : process.env.VUE_APP_ROOT_URL + 'teacher',
+  configureWebpack: {
+    // externals: {
+    //   'element-ui': 'Element',
+    //   vue: 'Vue',
+    // },
+    // 开发生产共同配置
+    resolve: {
+      alias: {
+        '@': path.resolve(__dirname, './src'),
+        '@c': path.resolve(__dirname, './src/components'),
+        '@a': path.resolve(__dirname, './src/assets'),
+        '@frame': frame,
+        '@center': center,
+      },
+    },
+  },
+  devServer: {
+    port: '8003',
+    //api地址前缀
+    proxy: {
+      '/api': {
+        target: 'http://free.liaoningdoupo.com',
+        changeOrigin: true,
+        ws: true,
+      },
+      '/files': {
+        target: 'http://smart.cc-lotus.info',
+        changeOrigin: true,
+        ws: true,
+      },
+      '/ws': {
+        target: 'http://smart.cc-lotus.info',
+        ws: true,
+      },
+      '/weixin': {
+        target: 'http://smart.cc-lotus.info',
+        changeOrigin: true,
+        ws: true,
+      },
+      '/admin/center': {
+        target: 'http://localhost:8001',
+      },
+      '/admin/director': {
+        target: 'http://localhost:8002',
+      },
+      '/admin/teacher': {
+        target: 'http://localhost:8003',
+      },
+      '/admin/student': {
+        target: 'http://localhost:8004',
+      },
+      '/admin/school': {
+        target: 'http://localhost:8005',
+      },
+    },
+  },
 };