myAnli.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <div class="center_content">
  3. <div class="myAnliBox" v-if="anliBox.length > 0">
  4. <div class="anLi" v-for="(an, anIndex) in anliBox" :key="anIndex">
  5. <div class="anliTop">
  6. <div class="anliTopLeft">
  7. <div>比赛名称:广东省PBL案例征集</div>
  8. <div>比赛类别:{{ an.typename ? an.typename : "暂无分类" }}</div>
  9. </div>
  10. <div class="anliTopRight">创建人:{{ an.username }}</div>
  11. </div>
  12. <div class="anliMiddle">
  13. <div class="anliBox">
  14. <div class="anliImg">
  15. <img
  16. :src="
  17. JSON.parse(an.info).cover && JSON.parse(an.info).cover.length
  18. ? JSON.parse(an.info).cover[0].url
  19. : noBanner
  20. "
  21. alt=""
  22. />
  23. </div>
  24. <div class="anliNav">
  25. <div>项目名称:{{ JSON.parse(an.info).title }}</div>
  26. <div>单位:{{ an.schoolName }}</div>
  27. <div>
  28. {{ JSON.parse(an.info).courseText }}
  29. </div>
  30. <div class="people">
  31. <div class="man">
  32. <img src="../../../../assets/people.png" alt />
  33. </div>
  34. <div class="person">
  35. {{ an.info ? JSON.parse(an.info).tableData.length : 0 }}人
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="anliBottom">
  42. <div class="bottomLeft">
  43. 当前状态:{{ an.state == 0 ? "未提交" : "已提交" }}
  44. </div>
  45. <div class="bottomRight">
  46. <div class="rightButton" @click="updateState(an.id)">提交</div>
  47. <div class="rightButton" @click="exportAnli(an)">导出</div>
  48. <div class="rightButton">开始教学</div>
  49. <div class="rightButton" @click="goTo('/addRace?aid=' + an.id)">
  50. 编辑
  51. </div>
  52. <div
  53. class="rightButton"
  54. style="background: #225ac7"
  55. @click="goTo('/anliDetail?aid=' + an.id)"
  56. >
  57. 查看详情
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. <div class="noAnliBox" v-else>
  64. <img src="../../../../assets/icon/race/isNoMessage.png" alt="" />
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. export default {
  70. props: ["userid", "oid"],
  71. data() {
  72. return {
  73. anliBox: [],
  74. noBanner: require("../../../../assets/noBanner.jpg"),
  75. };
  76. },
  77. methods: {
  78. goTo(path) {
  79. this.$router.push(path);
  80. },
  81. selectAnLi() {
  82. let params = {
  83. uid: this.userid,
  84. };
  85. this.ajax
  86. .get(this.$store.state.api + "selectRaceList", params)
  87. .then((res) => {
  88. this.anliBox = res.data[0];
  89. })
  90. .catch((err) => {
  91. console.error(err);
  92. });
  93. },
  94. updateState(id) {
  95. let params = {
  96. id: id,
  97. };
  98. this.ajax
  99. .get(this.$store.state.api + "updateRaceState", params)
  100. .then((res) => {
  101. this.$message({
  102. message: "提交成功",
  103. type: "success",
  104. });
  105. this.selectAnLi();
  106. })
  107. .catch((err) => {
  108. console.error(err);
  109. });
  110. },
  111. exportAnli(res) {
  112. console.log(res);
  113. let _html = "";
  114. var _title = "<h1>项目基础信息</h1>";
  115. let info = JSON.parse(res.info);
  116. _title += `
  117. <iframe style="display: none;" name="downloadFile"></iframe>
  118. <h2>项目名称:${info.title}</h2>
  119. `;
  120. _title += `<h3>比赛类别:${res.typename}</h3>`;
  121. _title += `<h4>单位:${res.schoolName}</h4>`;
  122. _title += `<div>项目简介:${info.courseText}</div>`;
  123. _title += `<h4>文件:`;
  124. var _div = document.createElement("div");
  125. for (var i = 0; i < info.data.length; i++) {
  126. var _div2 = document.createElement("div");
  127. _div2.innerHTML = ` <a href="${info.data[i].url}" target="downloadFile">${info.data[i].name}</a>`;
  128. _div.appendChild(_div2);
  129. }
  130. _title += `<div>${_div.innerHTML}</div>`;
  131. let overview = JSON.parse(res.overview);
  132. var _overview = "<h1>项目概况</h1>";
  133. var oArray = [
  134. { j: "driQuestion", name: "驱动性问题" },
  135. { j: "tarDesign", name: "学习目标" },
  136. { j: "actiDesign", name: "评价设计" },
  137. // { j: "evaDesign", name: "评价设计" },
  138. // { j: "other", name: "其他补充" },
  139. ];
  140. for (var k = 0; k < oArray.length; k++) {
  141. _overview += `<h2>${oArray[k].name}</h2>`;
  142. // <a :href="`${完整的下载地址}`" target="downloadFile">{{文件名称}}</a>
  143. // <iframe style="display: none;" name="downloadFile"></iframe>
  144. _overview += `<div>${overview[oArray[k].j].brief}</div>`;
  145. var _div = document.createElement("div");
  146. for (var i = 0; i < overview[oArray[k].j].data.length; i++) {
  147. var _div2 = document.createElement("div");
  148. _div2.innerHTML = ` <a href="${
  149. overview[oArray[k].j].data[i].url
  150. }" target="downloadFile">${overview[oArray[k].j].data[i].name}</a>`;
  151. _div.appendChild(_div2);
  152. }
  153. _overview += `<div>${_div.innerHTML}</div>`;
  154. }
  155. let process = JSON.parse(res.process).stageBox;
  156. var _process = "<h1>项目安排</h1>";
  157. for (var pz = 0; pz < process.length; pz++) {
  158. _process += `<h2>阶段${pz + 1}:${process[pz].staTitle}</h2>`;
  159. _process += `<h2>总课时:${process[pz].allTime}</h2>`;
  160. let _act = process[pz].actBox;
  161. for (var z = 0; z < _act.length; z++) {
  162. _process += `<h2>活动${z + 1}</h2>`;
  163. _process += `<h3>活动名称:${_act[z].actName} 课时:${_act[z].actTime}</h3>`;
  164. let pAarray = [
  165. { j: "driQuestion", name: "活动目标" },
  166. { j: "tarDesign", name: "活动内容" },
  167. { j: "actiDesign", name: "预期成果" },
  168. { j: "evaDesign", name: "活动评价" },
  169. ];
  170. for (var i = 0; i < pAarray.length; i++) {
  171. _process += `<h3>${pAarray[i].name}</h3>`;
  172. _process += `<div>描述</div>`;
  173. _process += `<div>${_act[z][pAarray[i].j].brief}</div>`;
  174. _process += `<div>资料补充</div>`;
  175. var _div = document.createElement("div");
  176. for (var c = 0; c < _act[z][pAarray[i].j].data.length; c++) {
  177. var _div2 = document.createElement("div");
  178. _div2.innerHTML = ` <a href="${
  179. _act[z][pAarray[i].j].data[c].url
  180. }" target="downloadFile">${
  181. _act[z][pAarray[i].j].data[c].name
  182. }</a>`;
  183. _div.appendChild(_div2);
  184. }
  185. _process += `<div>${_div.innerHTML}</div>`;
  186. }
  187. }
  188. }
  189. let _proact = "<h1>项目活动过程</h1>";
  190. for (var pz = 0; pz < process.length; pz++) {
  191. _proact += `<h2>阶段${pz + 1}</h2>`;
  192. _proact += `<h2>描述</h2>`;
  193. _proact += `<div>${process[pz].brief}</div>`;
  194. _proact += `<h4>附件:`;
  195. var _div = document.createElement("div");
  196. for (var i = 0; i < process[pz].data.length; i++) {
  197. var _div2 = document.createElement("div");
  198. _div2.innerHTML = ` <a href="${process[pz].data[i].url}" target="downloadFile">${process[pz].data[i].name}</a>`;
  199. _div.appendChild(_div2);
  200. }
  201. _proact += `<div>${_div.innerHTML}</div>`;
  202. }
  203. let proexc = JSON.parse(res.proexc);
  204. let _proexc = "<h1>项目成果交流与评价</h1>";
  205. _proexc += `<div>描述</div>`;
  206. _proexc += `<div>${proexc.brief}</div>`;
  207. _proexc += `<div>附件</div>`;
  208. var _div = document.createElement("div");
  209. for (var i = 0; i < proexc.data.length; i++) {
  210. var _div2 = document.createElement("div");
  211. _div2.innerHTML = ` <a href="${proexc.data[i].url}" target="downloadFile">${proexc.data[i].name}</a>`;
  212. _div.appendChild(_div2);
  213. }
  214. _proexc += `<div>${_div.innerHTML}</div>`;
  215. let results = JSON.parse(res.results);
  216. let _results = "<h1>项目成效与反思</h1>";
  217. _results += `<div>描述</div>`;
  218. _results += `<div>${results.brief}</div>`;
  219. _results += `<div>附件</div>`;
  220. var _div = document.createElement("div");
  221. for (var i = 0; i < results.data.length; i++) {
  222. var _div2 = document.createElement("div");
  223. _div2.innerHTML = ` <a href="${results.data[i].url}" target="downloadFile">${results.data[i].name}</a>`;
  224. _div.appendChild(_div2);
  225. }
  226. _results += `<div>${_div.innerHTML}</div>`;
  227. // _results += `<h3>项目成效</h3>`;
  228. // _results += `<div>${results.proEffText}</div>`;
  229. // _results += `<h3>项目反思</h3>`;
  230. // _results += `<div>${results.proRefText}</div>`;
  231. _html = _title + _overview + _process + _proact + _proexc + _results;
  232. console.log("_overview", overview);
  233. console.log("_process", process);
  234. console.log("_results", results);
  235. this.generate(_html, { title: info.title, username: res.username });
  236. },
  237. async generate(a, data) {
  238. // 将html文件中需要用到的数据挂载到store上
  239. this.$store.commit("update", ["report", a]);
  240. console.log(this.$store.state.report);
  241. const content = `<!DOCTYPE html>
  242. <html lang="en">
  243. <head>
  244. <meta charset="UTF-8">
  245. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  246. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  247. <title>报告</title>
  248. </head>
  249. <body>
  250. ${this.$store.state.report}
  251. </body>
  252. </html>`;
  253. // debugger
  254. // 生成报告
  255. const link = document.createElement("a");
  256. let dname = data.title + "-" + data.username + ".html";
  257. // link.download = "报告.html"; // 文件名
  258. link.download = dname; // 文件名
  259. link.style.display = "none";
  260. // 创建文件流
  261. // 创建bolb实例时,内容一定要放在[]中
  262. const blob = new Blob([content], {
  263. type: "text/plain;charset='utf-8'",
  264. });
  265. link.href = window.URL.createObjectURL(blob);
  266. document.body.appendChild(link);
  267. link.click();
  268. document.body.removeChild(link);
  269. },
  270. },
  271. created() {
  272. this.selectAnLi();
  273. },
  274. };
  275. </script>
  276. <style scoped>
  277. @media screen and (max-width: 1280px) {
  278. .anliNav > div:nth-child(3) {
  279. width: 70% !important;
  280. }
  281. .noAnliBox{
  282. width: 300px !important;
  283. }
  284. }
  285. .myAnliBox {
  286. /* height: 500px; */
  287. overflow: auto;
  288. overflow-x: hidden;
  289. height: 100%;
  290. /* box-shadow: inset 0px 14px 7px -14px #b9b9b9; */
  291. }
  292. .center_content {
  293. width: 100%;
  294. height: 100%;
  295. }
  296. .anLi {
  297. background: #fff;
  298. width: 95%;
  299. margin: 20px auto;
  300. border-radius: 10px;
  301. }
  302. .anliTop {
  303. display: flex;
  304. flex-direction: row;
  305. flex-wrap: nowrap;
  306. align-items: center;
  307. justify-content: space-between;
  308. }
  309. .anliTopLeft {
  310. display: flex;
  311. flex-direction: row;
  312. flex-wrap: nowrap;
  313. align-items: center;
  314. color: #afafaf;
  315. padding: 20px 0 10px 30px;
  316. }
  317. .anliTopLeft > div:nth-child(2) {
  318. padding-left: 20px;
  319. }
  320. .anliTopRight {
  321. padding: 20px 30px 10px 0;
  322. }
  323. .anliMiddle {
  324. padding: 0 0 5px 30px;
  325. }
  326. .anliImg {
  327. width: 200px;
  328. height: 115px;
  329. min-width: 200px;
  330. }
  331. .anliImg > img {
  332. width: 100%;
  333. height: 100%;
  334. }
  335. .people {
  336. display: flex;
  337. }
  338. .person {
  339. margin-left: 10px;
  340. line-height: 18px;
  341. }
  342. .man {
  343. width: 16px;
  344. height: 16px;
  345. }
  346. .man > img {
  347. width: 100%;
  348. height: 100%;
  349. }
  350. .anliBox {
  351. display: flex;
  352. flex-direction: row;
  353. flex-wrap: nowrap;
  354. align-items: flex-start;
  355. }
  356. .anliNav {
  357. padding-left: 30px;
  358. width: 100%;
  359. }
  360. .anliNav > div:nth-child(1) {
  361. font-size: 24px;
  362. /* font-weight: bold; */
  363. }
  364. .anliNav > div:nth-child(2) {
  365. /* font-weight: bold; */
  366. margin: 10px 0 10px 0;
  367. }
  368. .anliNav > div:nth-child(3) {
  369. color: #aba8a8;
  370. margin-bottom: 10px;
  371. height: 40px;
  372. white-space: nowrap;
  373. overflow: hidden;
  374. text-overflow: ellipsis;
  375. width: 80%;
  376. }
  377. .anliBottom {
  378. display: flex;
  379. flex-direction: row;
  380. flex-wrap: nowrap;
  381. align-items: center;
  382. justify-content: space-between;
  383. padding: 0 10px 15px 30px;
  384. }
  385. .bottomRight {
  386. display: flex;
  387. flex-direction: row;
  388. flex-wrap: nowrap;
  389. align-items: center;
  390. }
  391. .rightButton {
  392. background: #499eef;
  393. color: #fff;
  394. /* width: 60px; */
  395. height: 30px;
  396. text-align: center;
  397. line-height: 30px;
  398. font-size: 14px;
  399. border-radius: 5px;
  400. cursor: pointer;
  401. margin-right: 20px;
  402. padding: 0 15px;
  403. }
  404. .noAnliBox {
  405. width: 500px;
  406. margin: 20px auto;
  407. }
  408. .noAnliBox > img {
  409. width: 100%;
  410. height: 100%;
  411. }
  412. </style>