addPPt.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <div class="pb_content" style="background: #e6eaf0; margin: 0">
  3. <div class="bread">
  4. <el-breadcrumb
  5. separator-class="el-icon-arrow-right"
  6. style="margin-top: 15px"
  7. >
  8. <el-breadcrumb-item
  9. :to="{ path: '/classRoom?userid=' + userid + '&oid=' + oid }"
  10. >课堂备课</el-breadcrumb-item
  11. >
  12. <el-breadcrumb-item>创建课堂</el-breadcrumb-item>
  13. </el-breadcrumb>
  14. </div>
  15. <div class="pb_content_body" style="height: 100%">
  16. <div class="pptBody">
  17. <div class="pptLeft">
  18. <div>课堂备课</div>
  19. </div>
  20. <div class="pptRight">
  21. <div v-if="steps == 0">
  22. <div style="background: #fff">
  23. <div class="pptName">课堂名称</div>
  24. <div class="pptInput">
  25. <span style="color: red; margin-right: 10px">*</span>
  26. <el-input
  27. type="text"
  28. placeholder="请输入名称"
  29. v-model="upPPT[0].pName"
  30. maxlength="50"
  31. show-word-limit
  32. >
  33. </el-input>
  34. </div>
  35. </div>
  36. <div style="background: #fff; margin-top: 10px">
  37. <div class="pptName">上传课堂封面</div>
  38. <div class="pptInput" @click="addImg($event)">
  39. <span style="color: red; margin-right: 10px">*</span>
  40. <div class="uploadImg" v-if="upPPT[0].pImg.length == 0">
  41. <div class="upImg">
  42. <img src="../../assets/icon/upImg.png" alt="" />
  43. </div>
  44. <div style="color: #bfc3c7">支持jpg/png格式</div>
  45. <input
  46. type="file"
  47. accept="image/png,image/jpg"
  48. style="display: none"
  49. @change="beforeUpload1($event, 1)"
  50. />
  51. </div>
  52. <div v-else>
  53. <div class="isUpImg">
  54. <img :src="upPPT[0].pImg[0].url" alt="" />
  55. </div>
  56. <div
  57. style="
  58. width: 300px;
  59. white-space: nowrap;
  60. overflow: hidden;
  61. text-overflow: ellipsis;
  62. margin: 10px 0;
  63. text-align: center;
  64. "
  65. >
  66. {{ upPPT[0].pImg[0].name }}
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. <div style="background: #fff; margin-top: 10px">
  72. <div class="pptName">上传备课PPT</div>
  73. <div class="pptInput" @click="addImg($event)">
  74. <span style="color: red; margin-right: 10px">*</span>
  75. <div
  76. class="uploadImg"
  77. style="width: 320px; height: 200px"
  78. v-if="upPPT[0].pPPt.length == 0"
  79. >
  80. <div class="upImg">
  81. <img src="../../assets/icon/upPpt.png" alt="" />
  82. </div>
  83. <div style="color: #bfc3c7">上传文件</div>
  84. <input
  85. type="file"
  86. accept="application/.ppt, .pptx"
  87. style="display: none"
  88. @change="beforeUpload1($event, 2)"
  89. />
  90. </div>
  91. <div v-else>
  92. <div class="isUpImg"><img :src="mr" alt="" /></div>
  93. <div
  94. style="
  95. width: 300px;
  96. white-space: nowrap;
  97. overflow: hidden;
  98. text-overflow: ellipsis;
  99. margin: 10px 0;
  100. text-align: center;
  101. "
  102. >
  103. {{ upPPT[0].pPPt[0].name }}
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. <div class="rightButton" @click="steps = 1">下一步</div>
  109. </div>
  110. <div v-if="steps == 1">
  111. <div style="background: #fff; margin-top: 10px">
  112. <div class="pptName">上传备课PPT</div>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. <div v-if="proVisible" class="mask">
  119. <div class="progressBox">
  120. <div class="lbox">
  121. <img src="../../assets/loading.gif" />上传中,请稍后
  122. </div>
  123. <el-progress
  124. :text-inside="true"
  125. :stroke-width="20"
  126. :percentage="progress"
  127. style="width: 80%"
  128. ></el-progress>
  129. </div>
  130. </div>
  131. </div>
  132. </template>
  133. <script>
  134. export default {
  135. data() {
  136. return {
  137. dataVisible: false,
  138. isLoading: false,
  139. formLabelWidth: "100px",
  140. userid: this.$route.query.userid,
  141. oid: this.$route.query.oid,
  142. total: 0,
  143. tableData: [],
  144. upPPT: [
  145. {
  146. pName: "",
  147. pImg: [],
  148. pPPt: [],
  149. },
  150. ],
  151. now: "",
  152. mr: require("../../assets/icon/pptImg.png"),
  153. noneBtnImg: false,
  154. proVisible: false,
  155. progress: 0,
  156. steps: 0,
  157. };
  158. },
  159. methods: {
  160. change(val) {
  161. console.log(val);
  162. },
  163. goTo(path) {
  164. this.$router.push(path);
  165. },
  166. tableRowClassName({ row, rowIndex }) {
  167. if ((rowIndex + 1) % 2 === 0) {
  168. return "even_row";
  169. } else {
  170. return "";
  171. }
  172. },
  173. jump(cid) {
  174. window.parent.postMessage({ cid: cid, type: "1" }, "*");
  175. },
  176. init() {},
  177. handleClose(done) {
  178. done();
  179. },
  180. handleRemove(file, fileList) {
  181. console.log(file, fileList);
  182. },
  183. onExceed() {
  184. this.$message.error("课程海报仅支持上传一张,请删除后再进行上传");
  185. },
  186. //uuid生成
  187. guid() {
  188. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
  189. /[xy]/g,
  190. function (c) {
  191. var r = (Math.random() * 16) | 0,
  192. v = c == "x" ? r : (r & 0x3) | 0x8;
  193. return v.toString(16);
  194. }
  195. );
  196. },
  197. time() {
  198. if (!this.now) {
  199. this.now = new Date().getTime();
  200. return true;
  201. } else {
  202. let time = new Date().getTime();
  203. if (time - this.now > 3000) {
  204. this.now = time;
  205. return true;
  206. } else {
  207. return false;
  208. }
  209. }
  210. },
  211. addImg(e) {
  212. var el = e.currentTarget;
  213. el.getElementsByTagName("input")[0].click();
  214. },
  215. imgChange(file, fileList, type) {
  216. if (type == 1) {
  217. var _tmp = this.upPPT[0].pImg;
  218. } else if (type == 2) {
  219. var _tmp = this.upPPT[0].pPPt;
  220. }
  221. this.noneBtnImg = _tmp.length >= 1;
  222. },
  223. beforeUpload1(event, type) {
  224. var file = event.target.files[0];
  225. var credentials = {
  226. accessKeyId: "AKIATLPEDU37QV5CHLMH",
  227. secretAccessKey: "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",
  228. }; //秘钥形式的登录上传
  229. window.AWS.config.update(credentials);
  230. window.AWS.config.region = "cn-northwest-1"; //设置区域
  231. var bucket = new window.AWS.S3({ params: { Bucket: "ccrb" } }); //选择桶
  232. var _this = this;
  233. _this.progress = 0;
  234. _this.proVisible = true;
  235. if (file) {
  236. var params = {
  237. Key:
  238. file.name.split(".")[0] +
  239. new Date().getTime() +
  240. "." +
  241. file.name.split(".")[1],
  242. ContentType: file.type,
  243. Body: file,
  244. "Access-Control-Allow-Credentials": "*",
  245. ACL: "public-read",
  246. }; //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
  247. var options = {
  248. partSize: 2048 * 1024 * 1024,
  249. queueSize: 2,
  250. leavePartsOnError: true,
  251. };
  252. bucket
  253. .upload(params, options)
  254. .on("httpUploadProgress", function (evt) {
  255. //这里可以写进度条
  256. // console.log("Uploaded : " + parseInt((evt.loaded * 80) / evt.total) + '%');
  257. _this.progress = parseInt((evt.loaded * 80) / evt.total);
  258. })
  259. .send(function (err, data) {
  260. _this.progress = 100;
  261. setTimeout(() => {
  262. _this.proVisible = false;
  263. }, 1000);
  264. if (err) {
  265. var a = _this.$refs.upload1.uploadFiles;
  266. a.splice(a.length - 1, a.length);
  267. _this.$message.error("上传失败");
  268. } else {
  269. if (type == 1) {
  270. _this.upPPT[0].pImg.push({
  271. name: file.name,
  272. url: data.Location,
  273. uid: file.uid,
  274. });
  275. _this.imgChange(null, null, type);
  276. } else {
  277. _this.upPPT[0].pPPt.push({
  278. name: file.name,
  279. url: data.Location,
  280. uid: file.uid,
  281. });
  282. _this.imgChange(null, null, type);
  283. }
  284. console.log(data.Location);
  285. }
  286. });
  287. }
  288. },
  289. checkData() {
  290. this.dataVisible = true;
  291. },
  292. },
  293. created() {},
  294. };
  295. </script>
  296. <style scoped>
  297. .upImg > img,
  298. .isUpImg > img {
  299. width: 100%;
  300. height: 100%;
  301. }
  302. .xls_button {
  303. font-size: 14px;
  304. cursor: pointer;
  305. text-decoration: underline;
  306. color: rgb(34, 104, 188);
  307. }
  308. .student_search {
  309. display: flex;
  310. align-items: center;
  311. width: calc(100% / 3);
  312. }
  313. .student_search span {
  314. margin: 0 10px 0 0;
  315. width: 65px;
  316. }
  317. .el_cards >>> .el-card__body {
  318. height: 100%;
  319. }
  320. .student_input >>> .el-input__inner {
  321. height: 40px;
  322. width: 190px;
  323. font-size: 13px;
  324. padding: 0 10px;
  325. }
  326. .dialog_diy >>> .el-dialog__header {
  327. padding: 9px 20px 10px;
  328. background: #32455b !important;
  329. }
  330. .dialog_diy >>> .el-dialog__title {
  331. color: #fff;
  332. font-size: 15px;
  333. }
  334. .dialog_diy >>> .el-dialog__headerbtn {
  335. top: 14px;
  336. }
  337. .dialog_diy >>> .el-dialog__headerbtn .el-dialog__close {
  338. color: #fff;
  339. }
  340. .dialog_diy >>> .el-dialog__headerbtn .el-dialog__close:hover {
  341. color: #fff;
  342. }
  343. .dialog_diy >>> .el-dialog__body,
  344. .dialog_diy >>> .el-dialog__footer {
  345. background: #f3f3f3;
  346. }
  347. .bread {
  348. display: flex;
  349. flex-direction: row;
  350. flex-wrap: nowrap;
  351. justify-content: flex-end;
  352. align-items: center;
  353. }
  354. .pptBody {
  355. display: flex;
  356. width: 100%;
  357. height: 100%;
  358. flex-direction: row;
  359. align-items: flex-start;
  360. flex-wrap: nowrap;
  361. align-content: flex-start;
  362. }
  363. .pptLeft {
  364. background: #fff;
  365. width: 20%;
  366. height: 55px;
  367. border-radius: 5px;
  368. line-height: 55px;
  369. display: flex;
  370. align-items: center;
  371. }
  372. .pptLeft > div {
  373. border-left: 5px solid #418ae4;
  374. height: 35px;
  375. line-height: 35px;
  376. padding-left: 20px;
  377. }
  378. .pptRight {
  379. width: 80%;
  380. margin-left: 25px;
  381. background: #e6e9f0;
  382. position: relative;
  383. min-height: 100%;
  384. }
  385. .pptName {
  386. height: 40px;
  387. padding: 15px 0 0 20px;
  388. border-bottom: 1px solid #f9f9f9;
  389. }
  390. .pptInput {
  391. display: flex;
  392. margin-top: 15px;
  393. padding: 10px 0 20px 25px;
  394. flex-direction: row;
  395. align-items: center;
  396. }
  397. .pptInput >>> .el-input {
  398. width: 80%;
  399. }
  400. .pptInput >>> .el-input__inner,
  401. .pptInput >>> .el-input__count-inner {
  402. background: #f4f4f4 !important;
  403. }
  404. .uploadImg {
  405. background: #f2f2f2;
  406. width: 300px;
  407. height: 150px;
  408. display: flex;
  409. flex-direction: column;
  410. flex-wrap: nowrap;
  411. align-items: center;
  412. justify-content: center;
  413. cursor: pointer;
  414. }
  415. .upImg {
  416. width: 60px;
  417. }
  418. .mask {
  419. background-color: rgba(0, 0, 0, 0);
  420. position: fixed;
  421. top: 0;
  422. left: 0;
  423. width: 100%;
  424. height: 100%;
  425. z-index: 20000;
  426. display: flex;
  427. align-items: center;
  428. justify-content: center;
  429. }
  430. .progressBox {
  431. width: 500px;
  432. height: 180px;
  433. background: #fff;
  434. border-radius: 10px;
  435. box-shadow: 0 0 6px 1px #bfbfbf;
  436. display: flex;
  437. align-items: center;
  438. justify-content: center;
  439. flex-direction: column;
  440. }
  441. .progressBox .lbox {
  442. height: 100px;
  443. font-size: 19px;
  444. display: flex;
  445. align-items: center;
  446. }
  447. .progressBox .lbox img {
  448. width: 40px;
  449. margin-right: 20px;
  450. }
  451. .progressBox >>> .el-progress-bar__outer {
  452. background-color: #d1dfff !important;
  453. }
  454. .progressBox .lbox {
  455. height: 100px;
  456. font-size: 19px;
  457. display: flex;
  458. align-items: center;
  459. }
  460. .progressBox .lbox img {
  461. width: 40px;
  462. margin-right: 20px;
  463. }
  464. .isUpImg {
  465. width: 300px;
  466. height: 150px;
  467. }
  468. .rightButton {
  469. background: #30adff;
  470. width: 160px;
  471. height: 40px;
  472. text-align: center;
  473. line-height: 40px;
  474. color: #fff;
  475. border-radius: 5px;
  476. font-size: 12px;
  477. position: absolute;
  478. right: 0;
  479. bottom: 17%;
  480. cursor: pointer;
  481. }
  482. </style>