nihao 5 éve
szülő
commit
f5bb7f39ff
3 módosított fájl, 109 hozzáadás és 13 törlés
  1. 2 0
      src/store/index.js
  2. 38 0
      src/store/questionnaire.js
  3. 69 13
      src/views/question/index.vue

+ 2 - 0
src/store/index.js

@@ -2,12 +2,14 @@ import Vue from 'vue';
 import Vuex from 'vuex';
 import leave from './leave';
 import attendance from './attendance';
+import questionnaire from './questionnaire';
 Vue.use(Vuex);
 
 export default new Vuex.Store({
   modules: {
     leave,
     attendance,
+    questionnaire,
   },
   state: {}, //变量
   mutations: {}, //同步方法

+ 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 = {
+  questionInfo: `/api/train/questionnaire`,
+};
+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,
+};

+ 69 - 13
src/views/question/index.vue

@@ -1,26 +1,82 @@
 <template>
   <div id="index">
-    <van-tabbar v-model="active">
-      <van-tabbar-item info="3">
-        <span>自定义</span>
-        <img slot="icon" slot-scope="props" :src="props.active ? icon.active : icon.inactive" />
-      </van-tabbar-item>
-      <van-tabbar-item icon="search">标签</van-tabbar-item>
-      <van-tabbar-item icon="setting-o">标签</van-tabbar-item>
-    </van-tabbar>
+    <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>
+    <footInfo></footInfo>
   </div>
 </template>
 
 <script>
+import footInfo from '@/layout/index/footInfo.vue';
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: mapQuestion } = createNamespacedHelpers('questionnaire');
 export default {
   name: 'index',
   props: {},
-  components: {},
-  data: () => ({}),
-  created() {},
+  components: {
+    footInfo,
+  },
+  data: () => ({
+    info: {
+      name: '2020年疫情发展问卷调查',
+      num: '1',
+      question: [],
+    },
+  }),
+  created() {
+    this.searchInfo();
+  },
   computed: {},
-  methods: {},
+  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></style>
+<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>