index.vue 9.7 KB

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