file copy.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <div id="file">
  3. <el-button type="primary" @click="handleDown">pdf</el-button>
  4. <el-row>
  5. <el-col :span="24" style="text-align:center;font-size:32px;margin-bottom:30px;">
  6. {{ getProp('basic.achieve_name') }}
  7. </el-col>
  8. </el-row>
  9. <div id="demo">
  10. <el-col :span="24" class="info">
  11. <page5></page5>
  12. <!-- <page6></page6> -->
  13. <!-- <page5></page5>
  14. <expertList :list="expertList"></expertList> -->
  15. </el-col>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. const _ = require('lodash');
  21. import page5 from '@common/template/page5.vue';
  22. import page6 from '@common/template/page6.vue';
  23. import expertList from '@common/template/expertList.vue';
  24. import htmlToPdf from '@/unit/htmlToPdf.js';
  25. import { mapState, createNamespacedHelpers } from 'vuex';
  26. const { mapActions: achieveApply } = createNamespacedHelpers('achieveApply');
  27. const { mapActions: achieveApplyExpert } = createNamespacedHelpers('achieveApplyExpert');
  28. export default {
  29. name: 'file',
  30. props: {},
  31. components: { page5 },
  32. data: function() {
  33. return {
  34. info: {},
  35. expertList: [],
  36. };
  37. },
  38. created() {
  39. this.init();
  40. },
  41. methods: {
  42. ...achieveApply(['fetch']),
  43. ...achieveApplyExpert(['query']),
  44. async init() {
  45. const apply = await this.fetch(this.id);
  46. if (this.$checkRes(apply)) {
  47. this.$set(this, `info`, apply.data);
  48. }
  49. const experts = await this.query({ apply_id: this.info.id, type: '2', expert: true });
  50. if (this.$checkRes(experts)) {
  51. this.$set(this, `expertList`, experts.data);
  52. }
  53. },
  54. // 证书下载
  55. handleDown() {
  56. htmlToPdf.downloadPDF(document.querySelector('#demo'), this.info.basic.achieve_name);
  57. },
  58. getProp(prop) {
  59. return _.get(this.info, prop);
  60. },
  61. },
  62. computed: {
  63. ...mapState(['user', 'menuParams']),
  64. pageTitle() {
  65. return `${this.$route.meta.title}`;
  66. },
  67. id() {
  68. return this.$route.query.id;
  69. },
  70. },
  71. metaInfo() {
  72. return { title: this.$route.meta.title };
  73. },
  74. };
  75. </script>
  76. <style lang="less" scoped></style>