guhongwei 2 年之前
父節點
當前提交
02880ba315
共有 3 個文件被更改,包括 200 次插入14 次删除
  1. 5 0
      src/router/module/admin.ts
  2. 121 0
      src/views/answer/detail.vue
  3. 74 14
      src/views/answer/index.vue

+ 5 - 0
src/router/module/admin.ts

@@ -28,5 +28,10 @@ export default [
     path: '/answer',
     meta: { title: '问卷答案管理' },
     component: () => import('@/views/answer/index.vue')
+  },
+  {
+    path: '/answer/detail',
+    meta: { title: '答题情况' },
+    component: () => import('@/views/answer/detail.vue')
   }
 ];

+ 121 - 0
src/views/answer/detail.vue

@@ -0,0 +1,121 @@
+<template>
+  <div id="detail">
+    <el-row>
+      <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
+        <el-col :span="24" class="one">
+          <cSearch :is_title="false" :is_search="true" :fields="fields" @search="toSearch"> </cSearch>
+        </el-col>
+        <el-col :span="24" class="thr">
+          <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @view="toView"> </cTable>
+        </el-col>
+      </el-col>
+    </el-row>
+    <cDialog :dialog="dialog" @toClose="toClose">
+      <template v-slot:info>
+        <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
+          <el-col :span="24" class="list" v-for="(i, index) in info.answer" :key="index">
+            <el-col :span="24" class="list_1">
+              <span>{{ index + 1 }}.</span>
+              <span>{{ i.label }}</span>
+            </el-col>
+            <el-col :span="24" class="list_2">{{ getDict(i.value) }}</el-col>
+          </el-col>
+        </el-col>
+      </template>
+    </cDialog>
+  </div>
+</template>
+
+<script setup lang="ts">
+// 基础
+import _ from 'lodash';
+import type { Ref } from 'vue';
+import { onMounted, ref, getCurrentInstance } from 'vue';
+import { useRoute } from 'vue-router';
+// 接口
+import { AnswerStore } from '@common/src/stores/question/answer';
+import type { IQueryResult } from '@/util/types.util';
+const answertAxios = AnswerStore();
+
+const { proxy } = getCurrentInstance() as any;
+
+// 路由
+const route = useRoute();
+
+// 加载中
+const loading: Ref<any> = ref(false);
+const list: Ref<any> = ref([]);
+const total: Ref<any> = ref(0);
+const skip = 0;
+const limit = proxy.limit;
+const fields: Ref<any[]> = ref([
+  { label: '用户姓名', model: 'user_name', isSearch: true },
+  { label: '手机号', model: 'phone', isSearch: true },
+  { label: '答题时间', model: 'answer_date' }
+]);
+const opera: Ref<any[]> = ref([{ label: '查看答案', method: 'view' }]);
+
+// 查询
+const searchInfo: Ref<any> = ref({});
+
+// 弹框
+const dialog: Ref<any> = ref({ title: '答题信息', show: false, type: '1' });
+const info: Ref<any> = ref({ answer: [] });
+
+// 请求
+onMounted(async () => {
+  loading.value = true;
+  await search({ skip, limit });
+  loading.value = false;
+});
+const search = async (e: { skip: number; limit: number }) => {
+  let id = route.query.id;
+  const info = { skip: e.skip, limit: e.limit, ...searchInfo.value, questionnaire_id: id };
+  const res: IQueryResult = await answertAxios.query(info);
+  if (res.errcode == '0') {
+    list.value = res.data;
+    total.value = res.total;
+  }
+};
+const toSearch = (query) => {
+  searchInfo.value = query;
+  search({ skip, limit });
+};
+
+const toView = (data) => {
+  info.value = data;
+  dialog.value = { title: '答题信息', show: true, type: '1' };
+};
+const getDict = (data) => {
+  if (_.isArray(data)) {
+    return data.join(',');
+  } else {
+    return data;
+  }
+};
+// 关闭弹框
+const toClose = () => {
+  info.value = {};
+  search({ skip, limit });
+  dialog.value = { title: '答题信息', show: false, type: '1' };
+};
+</script>
+<style scoped lang="scss">
+.dialog_one {
+  .list {
+    margin: 0 0 10px 0;
+    .list_1 {
+      margin: 0 0 10px 0;
+      span {
+        margin: 0 0 10px 0;
+        font-weight: bold;
+        font-size: 16px;
+        font-family: monospace;
+      }
+    }
+    .list_2 {
+      color: #ff0000;
+    }
+  }
+}
+</style>

+ 74 - 14
src/views/answer/index.vue

@@ -2,7 +2,16 @@
   <div id="index">
     <el-row>
       <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
-        <el-col :span="24" class="one">系统首页</el-col>
+        <el-col :span="24" class="one">
+          <cSearch :is_title="false" :is_search="true" :fields="fields" @search="toSearch">
+            <template #type>
+              <el-option v-for="(i, index) in typeList" :key="index" :label="i.label" :value="i.value"></el-option>
+            </template>
+          </cSearch>
+        </el-col>
+        <el-col :span="24" class="thr">
+          <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @view="toView"> </cTable>
+        </el-col>
       </el-col>
     </el-row>
   </div>
@@ -11,28 +20,79 @@
 <script setup lang="ts">
 // 基础
 import type { Ref } from 'vue';
-// reactive,
 import { onMounted, ref, getCurrentInstance } from 'vue';
+import { useRouter } from 'vue-router';
 // 接口
-//import { TestStore } from '@common/src/stores/test';
-//import type { IQueryResult } from '@/util/types.util';
-//const testAxios = TestStore();
+import { QuestionnaireStore } from '@common/src/stores/question/questionnaire'; //
+import { DictDataStore } from '@common/src/stores/system/dictData'; // 字典表
+import type { IQueryResult } from '@/util/types.util';
+const qnaireAxios = QuestionnaireStore();
+const dictAxios = DictDataStore();
+
 const { proxy } = getCurrentInstance() as any;
+
+// 路由
+const router = useRouter();
+
 // 加载中
 const loading: Ref<any> = ref(false);
-// 分页数据
-//  const skip = 0;
-//  const limit = proxy.limit;;
+const list: Ref<any> = ref([]);
+const total: Ref<any> = ref(0);
+const skip = 0;
+const limit = proxy.limit;
+const fields: Ref<any[]> = ref([
+  { label: '类型', model: 'type', isSearch: true, format: (i) => getDict(i, 'type'), type: 'select' },
+  { label: '标题', model: 'title', isSearch: true },
+  { label: '发布时间', model: 'create_date' },
+  { label: '简介', model: 'brief' }
+]);
+const opera: Ref<any[]> = ref([{ label: '答题情况', method: 'view' }]);
+
+// 查询
+const searchInfo: Ref<any> = ref({});
+
+// 字典表
+const typeList: Ref<any> = ref([]);
+
 // 请求
 onMounted(async () => {
   loading.value = true;
-  //  await search({ skip, limit });
+  await searchOther();
+  await search({ skip, limit });
   loading.value = false;
 });
-//const search = async (e: { skip: number; limit: number }) => {
-//  const info = { skip: e.skip, limit: e.limit, ...searchInfo.value  };
-//  const res: IQueryResult = await testAxios.query(info);
-//  console.log(res);
-//};
+const search = async (e: { skip: number; limit: number }) => {
+  const info = { skip: e.skip, limit: e.limit, ...searchInfo.value };
+  const res: IQueryResult = await qnaireAxios.query(info);
+  if (res.errcode == '0') {
+    list.value = res.data;
+    total.value = res.total;
+  }
+};
+const toSearch = (query) => {
+  searchInfo.value = query;
+  search({ skip, limit });
+};
+const getDict = (e, model) => {
+  if (model == 'type') {
+    let data: any = typeList.value.find((i: any) => i.value == e);
+    if (data) return data.label;
+    else return '暂无';
+  }
+};
+
+// 答题情况
+const toView = (data) => {
+  router.push({ path: '/answer/detail', query: { id: data._id } });
+};
+
+const searchOther = async () => {
+  let res: IQueryResult;
+  // 类型
+  res = await dictAxios.query({ type: 'wenjuan-questionnaire-type' });
+  if (res.errcode == '0') {
+    typeList.value = res.data;
+  }
+};
 </script>
 <style scoped lang="scss"></style>