shareLink.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <!--
  2. * @Descripttion:
  3. * @Author: qianlishi
  4. * @Date: 2021-12-13 11:04:24
  5. * @Last Modified by: qianming
  6. * @Last Modified time: 2021-3-13 11:04:24
  7. !-->
  8. <template>
  9. <div>
  10. <el-dialog
  11. title="请输入分享码"
  12. :visible.sync="dialogVisible"
  13. width="30%"
  14. :close-on-click-modal="false"
  15. :before-close="handleClose"
  16. >
  17. <el-input v-model="password" placeholder="请输入分享码"></el-input>
  18. <span slot="footer" class="dialog-footer">
  19. <el-button @click="dialogVisible = false">取 消</el-button>
  20. <el-button type="primary" @click="checkPassword()">确 定</el-button>
  21. </span>
  22. </el-dialog>
  23. </div>
  24. </template>
  25. <script>
  26. import { reportShareDetailByCode } from "@/api/reportShare";
  27. import { setShareToken } from "@/utils/auth";
  28. export default {
  29. name: "Excel",
  30. components: {},
  31. data() {
  32. return {
  33. password: "",
  34. sharePassword: "",
  35. dialogVisible: false,
  36. reportCode: "",
  37. shareToken: ""
  38. };
  39. },
  40. created() {
  41. this.handleOpen();
  42. },
  43. methods: {
  44. async handleOpen() {
  45. const url = window.location.href;
  46. const shareCode = url.substring(url.lastIndexOf("/") + 1);
  47. const { code, data } = await reportShareDetailByCode(shareCode);
  48. if (code != "200") return;
  49. this.reportCode = data.reportCode;
  50. this.sharePassword = data.sharePassword;
  51. this.shareToken = data.shareToken;
  52. if (this.sharePassword) {
  53. this.dialogVisible = true;
  54. } else {
  55. this.pushEl();
  56. }
  57. },
  58. checkPassword() {
  59. const md5 = require("js-md5");
  60. const inputPassword = md5(this.password);
  61. if (inputPassword == this.sharePassword) {
  62. this.pushEl();
  63. } else {
  64. this.$message.error("分享码输入不正确");
  65. }
  66. },
  67. pushEl() {
  68. setShareToken(this.shareToken);
  69. this.$router.push({
  70. path: "/excelreport/viewer",
  71. query: {
  72. reportCode: this.reportCode
  73. }
  74. });
  75. },
  76. handleClose(done) {
  77. this.$confirm("确认关闭?")
  78. .then(_ => {
  79. done();
  80. })
  81. .catch(_ => {});
  82. }
  83. }
  84. };
  85. </script>