to-download.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <div id="to-download">
  3. <el-row type="flex" align="middle" justify="center" style="margin-bottom:20px">
  4. <el-col :span="2">
  5. <el-button size="mini" type="primary" plain icon="el-icon-download" @click="downLoad"></el-button>
  6. </el-col>
  7. </el-row>
  8. </div>
  9. </template>
  10. <script>
  11. import _ from 'lodash';
  12. import { mapState, createNamespacedHelpers } from 'vuex';
  13. export default {
  14. name: 'to-download',
  15. props: {
  16. canvas: { type: null },
  17. gid: { type: String, default: `${new Date().getTime()}` },
  18. },
  19. components: {},
  20. data: function() {
  21. return {};
  22. },
  23. created() {},
  24. methods: {
  25. downLoad() {
  26. let e = this.canvas;
  27. let img = e.toDataURL('image/png', 1);
  28. let a = document.createElement('a');
  29. a.href = img;
  30. a.download = this.gid;
  31. a.click();
  32. },
  33. },
  34. computed: {
  35. ...mapState(['user']),
  36. pageTitle() {
  37. return `${this.$route.meta.title}`;
  38. },
  39. },
  40. metaInfo() {
  41. return { title: this.$route.meta.title };
  42. },
  43. };
  44. </script>
  45. <style lang="less" scoped></style>