index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <el-dialog
  3. title="提醒"
  4. :visible.sync="remDig"
  5. :append-to-body="true"
  6. width="560px"
  7. :before-close="handleClose"
  8. class="dialog_diy"
  9. >
  10. <div class="share_box">
  11. <div class="info_box" ref="info">
  12. <!-- <div class="info">
  13. <span>表单范围:</span>
  14. <span>{{ reversedMessage }}</span>
  15. </div> -->
  16. <div class="info">
  17. <span>填写范围:</span>
  18. <el-select
  19. v-model="teas"
  20. @change="getData"
  21. multiple
  22. placeholder="请选择"
  23. >
  24. <el-option
  25. v-for="item in TeaList"
  26. :key="item.id"
  27. :label="item.name"
  28. :value="item.id"
  29. >
  30. </el-option>
  31. </el-select>
  32. </div>
  33. <!-- <div class="info" v-if="testJson && testJson.overtime">
  34. <span>截止时间:</span>
  35. <span>{{ testJson.overtime }}</span>
  36. </div> -->
  37. <div class="info">
  38. <span>需提交人数:</span>
  39. <span>{{ remindNum }}</span>
  40. </div>
  41. <div class="info">
  42. <span>未完成人数:</span>
  43. <span v-html="remindList.length"></span>
  44. </div>
  45. <div class="info">
  46. <span>未完成名单:</span>
  47. <span>{{
  48. remindList.length > 20
  49. ? isSuo
  50. ? remindList.slice(0, 20).join(",") + "..."
  51. : remindList.join(",")
  52. : remindList.join(",")
  53. }}</span>
  54. <span
  55. class="more"
  56. v-if="remindList.length > 20"
  57. @click="isSuo = !isSuo"
  58. >{{ isSuo ? "查看更多" : "收起" }}</span
  59. >
  60. </div>
  61. </div>
  62. <div class="btn_box">
  63. <button class="c_pub_button_confirm tag-read2" @click="getExcelTab">
  64. 导出
  65. </button>
  66. <button
  67. class="c_pub_button_confirm tag-read2"
  68. @click="copy2"
  69. :data-clipboard-text="copyText2"
  70. >
  71. 复制信息
  72. </button>
  73. </div>
  74. </div>
  75. </el-dialog>
  76. </template>
  77. <script>
  78. import Clipboard from "clipboard";
  79. export default {
  80. props: {
  81. remDig: {
  82. type: Boolean,
  83. default: false
  84. },
  85. pType: {
  86. type: Number
  87. },
  88. TeaList: {
  89. type: Array
  90. },
  91. testJson: {
  92. type: Object
  93. },
  94. TeachingValue: {
  95. type: String
  96. },
  97. TeachName: {
  98. type: Array
  99. }
  100. },
  101. data() {
  102. return {
  103. origin: "",
  104. copyText: "",
  105. copyText2: "",
  106. noCount: 0,
  107. pname: [],
  108. isSuo: true,
  109. excelData: [],
  110. remindNum: 0,
  111. remindList: [],
  112. remindName: [],
  113. oid: this.$route.query.oid, //学校id
  114. org: this.$route.query.org, //组织id
  115. teas: []
  116. };
  117. },
  118. computed: {
  119. reversedMessage() {
  120. if (this.TeachingValue == "") {
  121. return this.testJson.juriP ? this.testJson.juriP : "所有人";
  122. } else {
  123. return this.TeachName ? this.TeachName[0].name : "所有人";
  124. }
  125. }
  126. },
  127. methods: {
  128. handleClose(done) {
  129. this.close();
  130. done();
  131. },
  132. close() {
  133. this.teas = [];
  134. this.$emit("update:remDig", false);
  135. },
  136. copy2() {
  137. this.copyText2 = `填写范围:${
  138. this.teas ? this.remindName.join(",") : "所有人"
  139. }\n${"需提交人数:" +
  140. this.remindNum +
  141. "\n"}${"未完成人数:" + this.remindList.length + "\n"}${
  142. this.remindList.length
  143. ? "未完成名单:" + this.remindList.join(",") + "\n"
  144. : ""
  145. }`;
  146. var clipboard = new Clipboard(".tag-read2");
  147. clipboard.on("success", e => {
  148. this.$message.success("复制成功");
  149. console.log("复制成功");
  150. clipboard.destroy(); // 释放内存
  151. });
  152. clipboard.on("error", e => {
  153. console.log("不支持复制,该浏览器不支持自动复制");
  154. clipboard.destroy(); // 释放内存
  155. });
  156. },
  157. getData() {
  158. this.remindList = [];
  159. this.remindName = [];
  160. this.remindNum = 0;
  161. let params = {
  162. oid: this.oid,
  163. org: this.org,
  164. tea: this.teas.join(","),
  165. ptype: this.pType
  166. };
  167. this.ajax
  168. .get(this.$store.state.api + "selectExamineTeaRemind", params)
  169. .then(res => {
  170. let data = res.data[0];
  171. this.excelData = JSON.parse(JSON.stringify(data));
  172. this.remindNum = data.length > 0 ? data[0].num : 0;
  173. data.forEach(e => {
  174. this.remindList.push(e.username);
  175. });
  176. // this.digLoading = false;
  177. if (this.teas.length > 0) {
  178. this.teas.forEach(e => {
  179. this.TeaList.forEach(k => {
  180. if (e == k.id) {
  181. this.remindName.push(k.name);
  182. }
  183. });
  184. });
  185. }
  186. console.log("selectExamineTeaRemind", this.remindName);
  187. })
  188. .catch(err => {
  189. console.error(err);
  190. });
  191. // let params = {
  192. // id: this.testJson.courseId,
  193. // tea: this.TeachingValue
  194. // };
  195. // this.ajax
  196. // .get(this.$store.state.api + "getTestWorkShareCopy", params)
  197. // .then((res) => {
  198. // console.log('res.datares.datares.datares.datares.datares.data',res.data);
  199. // let parray = res.data[0]
  200. // let is = res.data[1]
  201. // this.noCount = parray.length - is.length
  202. // let isA = []
  203. // for(var i=0;i<is.length;i++){
  204. // isA.push(is[i].userid)
  205. // }
  206. // let pname = []
  207. // for(var i=0;i<parray.length;i++){
  208. // if(isA.indexOf(parray[i].userid) == -1){
  209. // pname.push(parray[i].username)
  210. // }
  211. // }
  212. // this.pname = pname
  213. // })
  214. // .catch((err) => {
  215. // console.error(err);
  216. // });
  217. },
  218. getExcelTab() {
  219. var res = this.excelData;
  220. // console.log('导出数据',res);
  221. //如果value的json字段的key值和想要的headers值不一致时,可做如下更改
  222. //将和下面的Object.fromEntries结合,将json字段的key值改变为要求的excel的header值
  223. var array = [];
  224. for (var i = 0; i < res.length; i++) {
  225. var _json = {};
  226. _json["教师姓名"] = res[i].username;
  227. _json["教师账号"] = res[i].eName;
  228. _json["所属教研室"] = res[i].tea;
  229. array.push(_json);
  230. }
  231. var XLSX = require("xlsx");
  232. const workbook = XLSX.utils.book_new(); //创建一个新的工作簿对象
  233. let ws = XLSX.utils.json_to_sheet(array); //将json对象数组转化成工作表
  234. ws["!cols"] = [
  235. //设置每一列的宽度
  236. { wch: 30 },
  237. { wch: 30 },
  238. { wch: 30 }
  239. ];
  240. XLSX.utils.book_append_sheet(workbook, ws, "sheet1"); //把sheet添加到workbook里,第三个参数是sheet名
  241. XLSX.writeFile(workbook, "未完成名单.xlsx");
  242. // const wopts = { bookType: "xlsx", bookSST: false, type: "array" };//写入的样式bookType:输出的文件类型,type:输出的数据类型,bookSST: 是否生成Shared String Table,官方解释是,如果开启生成速度会下降,但在低版本IOS设备上有更好的兼容性
  243. // const wbout = XLSX.write(workbook, wopts);// 浏览器端和node共有的API,实际上node可以直接使用xlsx.writeFile来写入文件,但是浏览器没有该API
  244. // FileSaver.saveAs(new Blob([wbout], { type: "application/octet-stream" }), `${title} demo.xlsx`);//保存文件
  245. this.$message({
  246. message: "导出成功",
  247. type: "success"
  248. });
  249. }
  250. },
  251. watch: {
  252. remDig(newValue, oldValue) {
  253. if (newValue) {
  254. this.isSuo = true;
  255. this.getData();
  256. }
  257. }
  258. }
  259. // mounted(){
  260. // console.log(top.origin);
  261. // },
  262. };
  263. </script>
  264. <style scoped>
  265. .dialog_diy >>> .el-dialog {
  266. height: 70% !important;
  267. min-width: 650px !important;
  268. margin-top: 10% !important;
  269. /* height: 100%; */
  270. /* margin: 0 auto !important; */
  271. }
  272. /* .dialog_diy >>> .el-dialog__header {
  273. background: #454545 !important;
  274. padding: 25px 20px;
  275. } */
  276. .dialog_diy >>> .el-dialog__header {
  277. background: #fff !important;
  278. padding: 15px 20px;
  279. }
  280. .dialog_diy >>> .el-dialog__body {
  281. height: calc(100% - 124px);
  282. box-sizing: border-box;
  283. padding: 0px;
  284. }
  285. .dialog_diy >>> .el-dialog__title {
  286. color: #000;
  287. }
  288. .dialog_diy >>> .el-dialog__headerbtn {
  289. top: 19px;
  290. }
  291. .dialog_diy >>> .el-dialog__headerbtn .el-dialog__close {
  292. color: #000;
  293. }
  294. .dialog_diy >>> .el-dialog__headerbtn .el-dialog__close:hover {
  295. color: #000;
  296. }
  297. .dialog_diy >>> .el-dialog__body,
  298. .dialog_diy >>> .el-dialog__footer {
  299. background: #fff;
  300. }
  301. .share_box {
  302. width: 100%;
  303. height: 100%;
  304. padding: 20px 15px;
  305. box-sizing: border-box;
  306. }
  307. .info_box {
  308. margin: 0 0 20px;
  309. }
  310. .info_box > .info {
  311. line-height: 18px;
  312. }
  313. .info_box > .info > span:nth-child(1) {
  314. color: #00000099;
  315. }
  316. .info_box > .info > span:nth-child(2) {
  317. color: #000000;
  318. }
  319. .info_box > .info + .info {
  320. margin-top: 10px;
  321. }
  322. .url_box {
  323. margin-bottom: 20px;
  324. }
  325. .qrcode_box {
  326. margin-bottom: 20px;
  327. }
  328. .url_box > .url {
  329. width: 100%;
  330. display: flex;
  331. align-items: center;
  332. border: 1px solid #e7e7e7;
  333. border-radius: 4px;
  334. height: 35px;
  335. padding: 0 7px;
  336. box-sizing: border-box;
  337. }
  338. .url_box > .url > span {
  339. font-size: 16px;
  340. color: #000000;
  341. }
  342. .url_box > .url > span:nth-child(1) {
  343. width: 100%;
  344. white-space: nowrap;
  345. overflow: hidden;
  346. text-overflow: ellipsis;
  347. }
  348. .url_box > .url > span:nth-child(2) {
  349. margin-left: auto;
  350. border-left: 1px solid #e7e7e7;
  351. padding-left: 7px;
  352. cursor: pointer;
  353. min-width: fit-content;
  354. }
  355. .url_box > .title,
  356. .qrcode_box > .title {
  357. font-size: 16px;
  358. font-weight: 700;
  359. margin-bottom: 10px;
  360. }
  361. .qrcode_box > .qrcode {
  362. padding: 7px;
  363. border: 1px solid #e7e7e7;
  364. width: fit-content;
  365. border-radius: 4px;
  366. display: flex;
  367. align-items: flex-end;
  368. }
  369. .qrcode_box > .qrcode > span:nth-child(1) {
  370. width: 100px;
  371. display: block;
  372. height: 100px;
  373. }
  374. .qrcode_box > .qrcode > span:nth-child(2) {
  375. background: #f0f2f5;
  376. padding: 7px 15px;
  377. font-size: 16px;
  378. border-radius: 4px;
  379. cursor: pointer;
  380. color: #000;
  381. margin-left: 7px;
  382. }
  383. .btn_box {
  384. display: flex;
  385. justify-content: flex-end;
  386. }
  387. .more {
  388. cursor: pointer;
  389. color: #0061ff;
  390. }
  391. </style>