detail.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <div id="detail">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
  5. <el-col :span="24" class="one">
  6. <cSearch :is_title="false" :is_search="true" :fields="fields" @search="toSearch"> </cSearch>
  7. </el-col>
  8. <el-col :span="24" class="thr">
  9. <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @view="toView"> </cTable>
  10. </el-col>
  11. </el-col>
  12. </el-row>
  13. <cDialog :dialog="dialog" @toClose="toClose">
  14. <template v-slot:info>
  15. <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
  16. <el-col :span="24" class="list" v-for="(i, index) in info.answer" :key="index">
  17. <el-col :span="24" class="list_1">
  18. <span>{{ index + 1 }}.</span>
  19. <span>{{ i.label }}</span>
  20. </el-col>
  21. <el-col :span="24" class="list_2">{{ getDict(i.value) }}</el-col>
  22. </el-col>
  23. </el-col>
  24. </template>
  25. </cDialog>
  26. </div>
  27. </template>
  28. <script setup lang="ts">
  29. // 基础
  30. import _ from 'lodash';
  31. import type { Ref } from 'vue';
  32. import { onMounted, ref, getCurrentInstance } from 'vue';
  33. import { useRoute } from 'vue-router';
  34. // 接口
  35. import { AnswerStore } from '@common/src/stores/question/answer';
  36. import type { IQueryResult } from '@/util/types.util';
  37. const answertAxios = AnswerStore();
  38. const { proxy } = getCurrentInstance() as any;
  39. // 路由
  40. const route = useRoute();
  41. // 加载中
  42. const loading: Ref<any> = ref(false);
  43. const list: Ref<any> = ref([]);
  44. const total: Ref<any> = ref(0);
  45. const skip = 0;
  46. const limit = proxy.limit;
  47. const fields: Ref<any[]> = ref([
  48. { label: '用户姓名', model: 'user_name', isSearch: true },
  49. { label: '手机号', model: 'phone', isSearch: true },
  50. { label: '答题时间', model: 'answer_date' }
  51. ]);
  52. const opera: Ref<any[]> = ref([{ label: '查看答案', method: 'view' }]);
  53. // 查询
  54. const searchInfo: Ref<any> = ref({});
  55. // 弹框
  56. const dialog: Ref<any> = ref({ title: '答题信息', show: false, type: '1' });
  57. const info: Ref<any> = ref({ answer: [] });
  58. // 请求
  59. onMounted(async () => {
  60. loading.value = true;
  61. await search({ skip, limit });
  62. loading.value = false;
  63. });
  64. const search = async (e: { skip: number; limit: number }) => {
  65. let id = route.query.id;
  66. const info = { skip: e.skip, limit: e.limit, ...searchInfo.value, questionnaire_id: id };
  67. const res: IQueryResult = await answertAxios.query(info);
  68. if (res.errcode == '0') {
  69. list.value = res.data;
  70. total.value = res.total;
  71. }
  72. };
  73. const toSearch = (query) => {
  74. searchInfo.value = query;
  75. search({ skip, limit });
  76. };
  77. const toView = (data) => {
  78. info.value = data;
  79. dialog.value = { title: '答题信息', show: true, type: '1' };
  80. };
  81. const getDict = (data) => {
  82. if (_.isArray(data)) {
  83. return data.join(',');
  84. } else {
  85. return data;
  86. }
  87. };
  88. // 关闭弹框
  89. const toClose = () => {
  90. info.value = {};
  91. search({ skip, limit });
  92. dialog.value = { title: '答题信息', show: false, type: '1' };
  93. };
  94. </script>
  95. <style scoped lang="scss">
  96. .dialog_one {
  97. .list {
  98. margin: 0 0 10px 0;
  99. .list_1 {
  100. margin: 0 0 10px 0;
  101. span {
  102. margin: 0 0 10px 0;
  103. font-weight: bold;
  104. font-size: 16px;
  105. font-family: monospace;
  106. }
  107. }
  108. .list_2 {
  109. color: #ff0000;
  110. }
  111. }
  112. }
  113. </style>