dataInfo.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <div id="dataInfo">
  3. <el-row>
  4. <el-col :span="24" class="main">
  5. <el-col :span="24" class="top">
  6. <el-button type="primary" size="mini" @click="download">PDF下载</el-button>
  7. <el-button type="primary" size="mini" @click="back">返回</el-button>
  8. </el-col>
  9. <el-col :span="24" class="down">
  10. <div id="demo">
  11. <el-col :span="24" class="common one">
  12. <one :form="form"></one>
  13. </el-col>
  14. <el-col :span="24" class="common two">
  15. <two :form="form"></two>
  16. </el-col>
  17. <el-col :span="24" class="common thr">
  18. <thr :form="form"></thr>
  19. </el-col>
  20. <el-col :span="24" class="common four">
  21. <four :form="form"></four>
  22. </el-col>
  23. <el-col :span="24" class="common five">
  24. <five :form="form"></five>
  25. </el-col>
  26. <el-col :span="24" class="common six">
  27. <six :form="form"></six>
  28. </el-col>
  29. <el-col :span="24" class="common seven">
  30. <seven :form="form"></seven>
  31. </el-col>
  32. <el-col :span="24" class="common eight">
  33. <eight :form="form"></eight>
  34. </el-col>
  35. </div>
  36. </el-col>
  37. </el-col>
  38. </el-row>
  39. </div>
  40. </template>
  41. <script>
  42. import one from './infoParts/one.vue';
  43. import two from './infoParts/two.vue';
  44. import thr from './infoParts/thr.vue';
  45. import four from './infoParts/four.vue';
  46. import five from './infoParts/five.vue';
  47. import six from './infoParts/six.vue';
  48. import seven from './infoParts/seven.vue';
  49. import eight from './infoParts/eight.vue';
  50. import htmlToPdf from '@/unit/htmlToPdf.js';
  51. import { mapState, createNamespacedHelpers } from 'vuex';
  52. const { mapActions: achieveApply } = createNamespacedHelpers('achieveApply');
  53. export default {
  54. name: 'dataInfo',
  55. props: {},
  56. // components: { one, two, thr, four, five, six, seven, eight },
  57. components: { one, two, thr, four, five, six, seven, eight },
  58. data: function() {
  59. return {
  60. form: {
  61. // 基本信息
  62. basic: {},
  63. // 信息简介
  64. brief: {},
  65. // 参加人员
  66. research: [],
  67. // 图片
  68. file: {},
  69. },
  70. };
  71. },
  72. async created() {
  73. await this.search();
  74. },
  75. methods: {
  76. ...achieveApply(['fetch', 'update']),
  77. async search() {
  78. if (this.id) {
  79. let res = await this.fetch(this.id);
  80. if (this.$checkRes(res)) {
  81. console.log(res.data);
  82. this.$set(this, 'form', res.data);
  83. }
  84. }
  85. },
  86. // PDF下载
  87. download() {
  88. htmlToPdf.downloadPDF(document.querySelector('#demo'), '测试');
  89. },
  90. // 返回
  91. back() {
  92. this.$router.push({ path: '/adminCate' });
  93. },
  94. },
  95. computed: {
  96. ...mapState(['user']),
  97. id() {
  98. return this.$route.query.id;
  99. },
  100. },
  101. metaInfo() {
  102. return { title: this.$route.meta.title };
  103. },
  104. watch: {
  105. test: {
  106. deep: true,
  107. immediate: true,
  108. handler(val) {},
  109. },
  110. },
  111. };
  112. </script>
  113. <style lang="less" scoped>
  114. .main {
  115. .top {
  116. text-align: center;
  117. margin: 0 0 15px 0;
  118. }
  119. .down {
  120. padding: 0 20%;
  121. #demo {
  122. width: 100%;
  123. height: 11108px;
  124. border: 1px solid #ff0000;
  125. .one {
  126. padding: 0;
  127. }
  128. .two {
  129. height: 1389px;
  130. padding: 60px 30px;
  131. }
  132. .thr {
  133. height: 1390px;
  134. padding: 60px 30px;
  135. }
  136. .four {
  137. height: 1389px;
  138. }
  139. }
  140. }
  141. }
  142. .common {
  143. width: 100%;
  144. height: 1388px;
  145. border-bottom: 1px solid #666666;
  146. padding: 40px 20px;
  147. }
  148. </style>