warnDialog.vue 10 KB

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