index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <el-dialog title="提醒" :visible.sync="dialogVisibleShare" :append-to-body="true" width="560px"
  3. :before-close="handleClose" class="dialog_diy">
  4. <div class="share_box">
  5. <div class="info_box">
  6. <div class="info">
  7. <span>表单名称:</span>
  8. <span>{{ testJson.title }}</span>
  9. </div>
  10. <div class="info" >
  11. <span>表单范围:</span>
  12. <span>{{ testJson.juriP ? testJson.juriP : '所有人' }}</span>
  13. </div>
  14. <!-- <div class="info" v-if="testJson.overtime">
  15. <span>截止时间:</span>
  16. <span>{{ testJson.overtime }}</span>
  17. </div>
  18. <div class="info" v-if="testJson.juriP">
  19. <span>未完成人数:</span>
  20. <span>{{ noCount }}</span>
  21. </div> -->
  22. <div class="info">
  23. <span>已完成人数:</span>
  24. <span>{{ testJson.worksPerson }}</span>
  25. </div>
  26. <div class="info" v-if="testJson.juriP && pname &&pname.length">
  27. <span>未完成名单:</span>
  28. <span>{{ pname.join(',') }}</span>
  29. </div>
  30. </div>
  31. <div class="url_box">
  32. <div class="title">
  33. 链接提醒
  34. </div>
  35. <div class="url">
  36. <span>{{ origin }}</span>
  37. <span @click="copy" :data-clipboard-text="copyText" class="tag-read">复制链接</span>
  38. </div>
  39. </div>
  40. <div class="qrcode_box">
  41. <div class="title">
  42. 二维码提醒
  43. </div>
  44. <div class="qrcode">
  45. <span class="qrcodeUrl" ref="qrCodeUrl"></span>
  46. <span @click="downQr">下载二维码</span>
  47. </div>
  48. </div>
  49. </div>
  50. <!-- <span slot="footer" class="dialog-footer">
  51. <el-button @click="close()">关 闭</el-button>
  52. </span> -->
  53. </el-dialog>
  54. </template>
  55. <script>
  56. import Clipboard from "clipboard";
  57. import QRCode from "qrcodejs2";
  58. export default {
  59. props: {
  60. dialogVisibleShare: {
  61. type: Boolean,
  62. default: false
  63. },
  64. testJson: {
  65. type: Object
  66. },
  67. },
  68. data() {
  69. return {
  70. origin: top.origin,
  71. copyText: "",
  72. noCount: 0,
  73. pname:[]
  74. };
  75. },
  76. methods: {
  77. handleClose(done) {
  78. this.close();
  79. done();
  80. },
  81. close() {
  82. this.$emit("update:dialogVisibleShare", false);
  83. },
  84. setQr() {
  85. setTimeout(() => {
  86. this.$refs.qrCodeUrl.innerHTML = "";
  87. var qrcode = new QRCode(this.$refs.qrCodeUrl, {
  88. text: "https://beta.cloud.cocorobo.cn/#/testDetail?testid=" + this.testJson.courseId, // 需要转换为二维码的内容
  89. width: 100,
  90. height: 100,
  91. colorDark: "#000000",
  92. colorLight: "#ffffff",
  93. correctLevel: QRCode.CorrectLevel.H,
  94. });
  95. }, 500);
  96. },
  97. downQr() {
  98. // 创建一个虚拟链接,并将 canvas 转换为图片文件
  99. const link = document.createElement('a');
  100. link.href = this.$refs.qrCodeUrl.querySelector('img').src;
  101. link.download = 'qrcode.png';
  102. // 模拟点击链接进行下载
  103. link.click();
  104. },
  105. copy() {
  106. this.copyText = this.origin;
  107. var clipboard = new Clipboard(".tag-read");
  108. clipboard.on("success", (e) => {
  109. this.$message.success("复制成功");
  110. console.log("复制成功");
  111. clipboard.destroy(); // 释放内存
  112. });
  113. clipboard.on("error", (e) => {
  114. console.log("不支持复制,该浏览器不支持自动复制");
  115. clipboard.destroy(); // 释放内存
  116. });
  117. },
  118. getData() {
  119. if(!this.testJson.juriP){
  120. return;
  121. }
  122. let params = {
  123. id: this.testJson.courseId,
  124. };
  125. this.ajax
  126. .get(this.$store.state.api + "getTestWorkShare", params)
  127. .then((res) => {
  128. let parray = res.data[0]
  129. let is = res.data[1]
  130. this.noCount = parray.length - is.length
  131. let isA = []
  132. for(var i=0;i<is.length;i++){
  133. isA.push(is[i].userid)
  134. }
  135. let pname = []
  136. for(var i=0;i<parray.length;i++){
  137. if(isA.indexOf(parray[i].userid) == -1){
  138. pname.push(parray[i].username)
  139. }
  140. }
  141. this.pname = pname
  142. })
  143. .catch((err) => {
  144. console.error(err);
  145. });
  146. }
  147. },
  148. watch: {
  149. dialogVisibleShare(newValue, oldValue) {
  150. if (newValue) {
  151. this.setQr()
  152. this.getData()
  153. }
  154. }
  155. },
  156. };
  157. </script>
  158. <style scoped>
  159. .dialog_diy>>>.el-dialog {
  160. /* height: 100%; */
  161. /* margin: 0 auto !important; */
  162. }
  163. .dialog_diy>>>.el-dialog__header {
  164. background: #fff !important;
  165. padding: 15px 20px;
  166. }
  167. .dialog_diy>>>.el-dialog__body {
  168. height: calc(100% - 124px);
  169. box-sizing: border-box;
  170. padding: 0px;
  171. }
  172. .dialog_diy>>>.el-dialog__title {
  173. color: #000;
  174. }
  175. .dialog_diy>>>.el-dialog__headerbtn {
  176. top: 19px;
  177. }
  178. .dialog_diy>>>.el-dialog__headerbtn .el-dialog__close {
  179. color: #000;
  180. }
  181. .dialog_diy>>>.el-dialog__headerbtn .el-dialog__close:hover {
  182. color: #000;
  183. }
  184. .dialog_diy>>>.el-dialog__body,
  185. .dialog_diy>>>.el-dialog__footer {
  186. background: #fff;
  187. }
  188. .share_box {
  189. width: 100%;
  190. height: 100%;
  191. padding: 0 20px 15px;
  192. box-sizing: border-box;
  193. }
  194. .info_box {
  195. margin-bottom: 20px;
  196. }
  197. .info_box>.info {
  198. line-height: 18px;
  199. }
  200. .info_box>.info>span:nth-child(1) {
  201. color: #00000099;
  202. }
  203. .info_box>.info>span:nth-child(2) {
  204. color: #000000;
  205. }
  206. .info_box>.info+.info {
  207. margin-top: 10px;
  208. }
  209. .url_box {
  210. margin-bottom: 20px;
  211. }
  212. .qrcode_box {
  213. margin-bottom: 20px;
  214. }
  215. .url_box>.url {
  216. width: 100%;
  217. display: flex;
  218. align-items: center;
  219. border: 1px solid #e7e7e7;
  220. border-radius: 4px;
  221. height: 35px;
  222. padding: 0 7px;
  223. box-sizing: border-box;
  224. }
  225. .url_box>.url>span {
  226. font-size: 16px;
  227. color: #000000;
  228. }
  229. .url_box>.url>span:nth-child(2) {
  230. margin-left: auto;
  231. border-left: 1px solid #e7e7e7;
  232. padding-left: 7px;
  233. cursor: pointer;
  234. }
  235. .url_box>.title,
  236. .qrcode_box>.title {
  237. font-size: 16px;
  238. font-weight: 700;
  239. margin-bottom: 10px;
  240. }
  241. .qrcode_box>.qrcode {
  242. padding: 7px;
  243. border: 1px solid #e7e7e7;
  244. width: fit-content;
  245. border-radius: 4px;
  246. display: flex;
  247. align-items: flex-end;
  248. }
  249. .qrcode_box>.qrcode>span:nth-child(1) {
  250. width: 100px;
  251. display: block;
  252. height: 100px;
  253. }
  254. .qrcode_box>.qrcode>span:nth-child(2) {
  255. background: #f0f2f5;
  256. padding: 7px 15px;
  257. font-size: 16px;
  258. border-radius: 4px;
  259. cursor: pointer;
  260. color: #000;
  261. margin-left: 7px;
  262. }
  263. </style>