addPPt.vue 12 KB

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