shareConfig.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <!--
  2. * @Descripttion:
  3. * @Author: Devli
  4. * @Date: 2021-7-18 18:23:24
  5. * @Last Modified by: qianlishi
  6. * @Last Modified time: 2022-8-5 12:04:24
  7. !-->
  8. <template>
  9. <el-dialog
  10. class="tree_dialog"
  11. :title="titleBuild()"
  12. width="30%"
  13. :close-on-click-modal="false"
  14. center
  15. :visible.sync="visib"
  16. :before-close="closeDialog"
  17. >
  18. <div v-if="shareLinkFlag1">
  19. <el-form
  20. ref="userForm"
  21. :model="dialogForm"
  22. :rules="rules"
  23. size="small"
  24. label-width="100px"
  25. >
  26. <el-form-item label="有效期" prop="shareValidType">
  27. <el-select
  28. v-model.trim="dialogForm.shareValidType"
  29. placeholder="请选择"
  30. clearable
  31. @change="selectChange"
  32. >
  33. <el-option
  34. v-for="item in shareValidTypeOptions"
  35. :key="item.id"
  36. :label="item.text"
  37. :value="item.id"
  38. />
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item label="分享码" prop="sharePasswordFlag">
  42. <el-switch v-model="dialogForm.sharePasswordFlag"> </el-switch>
  43. </el-form-item>
  44. </el-form>
  45. <el-button
  46. type="primary"
  47. plain
  48. @click="createShare"
  49. style="margin-left:45px"
  50. >创建链接</el-button
  51. >
  52. </div>
  53. <div v-else>
  54. <el-form
  55. ref="userForm"
  56. :model="dialogForm"
  57. :rules="rules"
  58. size="small"
  59. label-width="100px"
  60. >
  61. <el-form-item label="链接" prop="reportShareUrl">
  62. <el-input v-model="reportShareUrl" :disabled="true" />
  63. </el-form-item>
  64. <el-form-item
  65. v-if="dialogForm.sharePasswordFlag"
  66. label="分享码"
  67. prop="sharePassword"
  68. >
  69. <el-input v-model="dialogForm.sharePassword" :disabled="true" />
  70. </el-form-item>
  71. <el-row :gutter="10">
  72. <el-button
  73. v-if="dialogForm.sharePassword == ''"
  74. type="primary"
  75. plain
  76. @click="copyShare"
  77. style="margin-left:45px"
  78. >复制链接</el-button
  79. >
  80. <el-button
  81. v-if="dialogForm.sharePassword != ''"
  82. type="primary"
  83. plain
  84. @click="copyShare"
  85. style="margin-left:45px"
  86. >复制链接和分享码</el-button
  87. >
  88. </el-row>
  89. </el-form>
  90. </div>
  91. <div slot="footer" style="text-align: center">
  92. <!-- <el-button type="primary" plain @click="saveReportShare">保存</el-button>-->
  93. <el-button type="danger" plain @click="closeDialog">取消</el-button>
  94. </div>
  95. </el-dialog>
  96. </template>
  97. <script>
  98. import { excelShareAdd } from "@/api/reportShare";
  99. import { getDictList } from "@/api/dict-data"; // 获取数据字典
  100. import Dictionary from "@/components/Dictionary/index";
  101. export default {
  102. components: { Dictionary },
  103. props: {
  104. visib: {
  105. required: true,
  106. type: Boolean,
  107. default: false
  108. },
  109. reportCode: {
  110. required: true,
  111. type: String,
  112. default: () => {
  113. return "";
  114. }
  115. },
  116. reportName: {
  117. required: true,
  118. type: String,
  119. default: () => {
  120. return "";
  121. }
  122. },
  123. reportType: {
  124. required : true,
  125. type: String,
  126. default: () =>{
  127. return "";
  128. }
  129. }
  130. },
  131. data() {
  132. return {
  133. title: "报表分享",
  134. reportShareUrl: "",
  135. shareValidTypeOptions: [], // 有效期类型
  136. dialogForm: {
  137. shareValidType: 0,
  138. reportCode: "",
  139. reportType: "",
  140. shareUrl: "",
  141. shareCode: "",
  142. sharePassword: "",
  143. sharePasswordFlag: false
  144. },
  145. shareLinkFlag1: true,
  146. rules: {
  147. shareValidType: [
  148. { required: true, message: "有效期必选", trigger: "change" }
  149. ]
  150. }
  151. };
  152. },
  153. watch: {
  154. visib(val) {
  155. if (val) {
  156. // 弹窗弹出时需要执行的逻辑
  157. this.getSystem();
  158. }
  159. }
  160. },
  161. created() {},
  162. methods: {
  163. titleBuild() {
  164. return "【" + this.reportName + "】" + "报表分享";
  165. },
  166. selectChange(val) {
  167. this.dialogForm.shareValidType = val;
  168. },
  169. // 获取数据字典
  170. async getSystem() {
  171. this.shareLinkFlag1 = true;
  172. const { code, data } = await getDictList("SHARE_VAILD");
  173. if (code != "200") return;
  174. this.shareValidTypeOptions = data;
  175. this.dialogForm.shareValidType = this.shareValidTypeOptions[0].id;
  176. this.dialogForm.sharePasswordFlag = false;
  177. this.dialogForm.sharePassword = "";
  178. },
  179. async createShare() {
  180. this.dialogForm.reportType = this.reportType;
  181. this.dialogForm.reportCode = this.reportCode;
  182. this.dialogForm.shareUrl = window.location.href;
  183. const { code, data } = await excelShareAdd(this.dialogForm);
  184. if (code != "200") return;
  185. this.shareLinkFlag1 = false;
  186. this.$message({
  187. message: "创建链接成功!",
  188. type: "success"
  189. });
  190. this.reportShareUrl = data.shareUrl;
  191. this.dialogForm.sharePassword = data.sharePassword;
  192. },
  193. copyShare() {
  194. let content = "";
  195. if (this.dialogForm.sharePassword == "") {
  196. content = "AJ-Report分享链接:" + this.reportShareUrl;
  197. } else {
  198. content =
  199. "AJ-Report分享链接:" +
  200. this.reportShareUrl +
  201. " 分享码:" +
  202. this.dialogForm.sharePassword;
  203. }
  204. this.copyToClip(content);
  205. this.$message({
  206. message: "复制链接成功!",
  207. type: "success"
  208. });
  209. },
  210. copyToClip(content, message) {
  211. let aux = document.createElement("input");
  212. aux.setAttribute("value", content);
  213. document.body.appendChild(aux);
  214. aux.select();
  215. document.execCommand("copy");
  216. document.body.removeChild(aux);
  217. },
  218. async saveReportShare() {
  219. let params = {};
  220. //const { code } = await saveAuthorityTree(params)
  221. //if (code != '200') return
  222. this.closeDialog();
  223. },
  224. // 弹窗关闭之前需要执行的逻辑
  225. closeDialog() {
  226. this.$emit("handleClose");
  227. }
  228. }
  229. };
  230. </script>