myAnli.vue 14 KB

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