nihao hace 5 años
padre
commit
f58a5afeb5
Se han modificado 5 ficheros con 161 adiciones y 27 borrados
  1. 1 26
      src/App.vue
  2. 6 1
      src/store/index.js
  3. 38 0
      src/store/question.js
  4. 38 0
      src/store/questionnaire.js
  5. 78 0
      src/views/index.vue

+ 1 - 26
src/App.vue

@@ -1,32 +1,7 @@
 <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>
 
-<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;
-    }
-  }
-}
-</style>
+<style lang="less"></style>

+ 6 - 1
src/store/index.js

@@ -1,9 +1,14 @@
 import Vue from 'vue';
 import Vuex from 'vuex';
-
+import questionnaire from './questionnaire';
+import question from './question';
 Vue.use(Vuex);
 
 export default new Vuex.Store({
+  modules: {
+    questionnaire,
+    question,
+  },
   state: {},
   mutations: {},
   actions: {},

+ 38 - 0
src/store/question.js

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

+ 38 - 0
src/store/questionnaire.js

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

+ 78 - 0
src/views/index.vue

@@ -0,0 +1,78 @@
+<template>
+  <div id="index">
+    <el-form :label-position="labelPosition" label-width="80px" :model="formLabelAlign">
+      <el-row>
+        <el-col :span="24" class="text_auto">{{ info.name }}</el-col>
+      </el-row>
+      <el-row>
+        <el-col :span="24" class="text_left" v-for="(item, index) in info.question" :key="index">
+          {{ item.type }}
+        </el-col>
+        <el-col :span="24" class="text_center">456</el-col>
+      </el-row>
+    </el-form>
+  </div>
+</template>
+
+<script>
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: mapQuestion } = createNamespacedHelpers('questionnaire');
+export default {
+  name: 'index',
+  props: {},
+  components: {},
+  data: () => ({
+    info: {
+      name: '2020年疫情发展问卷调查',
+      num: '1',
+      question: [],
+    },
+  }),
+  created() {
+    this.searchInfo();
+  },
+  computed: {},
+  methods: {
+    ...mapQuestion(['query', 'fetch']),
+    async searchInfo({ ...info } = {}) {
+      const res = await this.query({ ...info });
+      console.log(res.data);
+      // this.$set(this, `leaveList`, res.data);
+    },
+    // let result;
+    // for (const val of result.data) {
+    //   console.log(val);
+    //   for (const res of val.question) {
+    //     console.log(id);
+    //     this.$set(this, `question`, res.data);
+    //   }
+    // }
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.text_auto {
+  width: 100%;
+  // height: 50px;
+  line-height: 50px;
+  position: relative;
+  text-align: center;
+  border-bottom: 1px dashed #333;
+}
+
+.text_left {
+  width: 100%;
+  // height: 50px;
+  line-height: 50px;
+  position: relative;
+  padding-left: 25px;
+  color: blue;
+}
+.text_center {
+  width: 100%;
+  line-height: 10px;
+  position: relative;
+  padding-left: 50px;
+}
+</style>