myAnli.vue 15 KB

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