popbox.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. <template>
  2. <div>
  3. <div class="cellBlock">
  4. <div class="username">姓名</div>
  5. <div class="cellInp">
  6. <el-input
  7. v-model="recordData.studentName"
  8. disabled
  9. placeholder="请输入内容"
  10. ></el-input>
  11. </div>
  12. </div>
  13. <div class="cellBlock">
  14. <div class="username">班级</div>
  15. <div>
  16. <el-tooltip placement="top">
  17. <div slot="content">{{ recordData.className }}</div>
  18. <el-input
  19. v-model="recordData.className"
  20. disabled
  21. placeholder="请输入内容"
  22. ></el-input>
  23. </el-tooltip>
  24. </div>
  25. </div>
  26. <div class="cellBlock">
  27. <div class="username">关联</div>
  28. <div>
  29. <el-select
  30. multiple
  31. collapse-tags
  32. v-model="recordData.contact"
  33. placeholder="请选择关联同学"
  34. >
  35. <el-option
  36. v-for="(item, index) in studentList"
  37. :key="index"
  38. :label="item.name"
  39. :value="item.id"
  40. ></el-option>
  41. </el-select>
  42. </div>
  43. </div>
  44. <div class="cellBlock">
  45. <div class="username">学期</div>
  46. <div>
  47. <el-select v-model="recordData.term" placeholder="请选择">
  48. <el-option
  49. v-for="item in termList"
  50. :key="item.id"
  51. :label="item.name"
  52. :value="item.id"
  53. >
  54. </el-option>
  55. </el-select>
  56. <!-- <el-input
  57. v-model="recordData.semName"
  58. placeholder="请输入内容"
  59. ></el-input> -->
  60. </div>
  61. </div>
  62. <div class="cellBlock">
  63. <div class="username">维度</div>
  64. <div>
  65. <el-select
  66. multiple
  67. collapse-tags
  68. v-model="recordData.type"
  69. placeholder="请选择教研室"
  70. >
  71. <el-option
  72. v-for="(item, index) in weiList"
  73. :key="index"
  74. :label="item.name"
  75. :value="item.id"
  76. ></el-option>
  77. </el-select>
  78. </div>
  79. </div>
  80. <div class="cellBlock">
  81. <div class="username">时间</div>
  82. <div>
  83. <el-date-picker
  84. v-model="recordData.recordDate"
  85. type="datetime"
  86. value-format="yyyy-MM-dd HH:mm"
  87. placeholder="选择日期时间"
  88. style="width: 400px;"
  89. >
  90. </el-date-picker>
  91. </div>
  92. </div>
  93. <div class="cellBlock">
  94. <div class="username">地点</div>
  95. <div>
  96. <el-input
  97. v-model="recordData.place"
  98. placeholder="请输入内容"
  99. ></el-input>
  100. </div>
  101. </div>
  102. <div class="cellBlock">
  103. <div class="username">观察内容</div>
  104. <div>
  105. <el-input
  106. v-model="recordData.recordTit"
  107. placeholder="请输入内容"
  108. ></el-input>
  109. </div>
  110. </div>
  111. <div style="margin: 15px 0;width: 70px;font-size: 16px;text-align: right;">
  112. 观察记录
  113. </div>
  114. <div style="width: 500px;">
  115. <el-input
  116. type="textarea"
  117. placeholder="请输入内容"
  118. resize="none"
  119. rows="6"
  120. v-model="recordData.recordContent"
  121. >
  122. </el-input>
  123. </div>
  124. <div style="margin: 15px 0;width: 70px;font-size: 16px;">
  125. 图片
  126. </div>
  127. <div class="imgBlock">
  128. <div
  129. class="imgCell"
  130. v-if="judgeNum"
  131. @click.stop="addImg($event)"
  132. style="cursor: pointer;"
  133. >
  134. +
  135. <input
  136. type="file"
  137. accept="image/*"
  138. style="display: none"
  139. @change="beforeUpload($event)"
  140. />
  141. </div>
  142. <div
  143. class="imgCell"
  144. v-for="(i, index) in recordData.recordImg"
  145. :key="index"
  146. @click.stop="previewImg(i)"
  147. >
  148. <img class="imgCellCon" :src="i" alt="" />
  149. <div v-if="judgeNum" class="imgDelBtn" @click.stop="delImg(i)">
  150. ×
  151. </div>
  152. </div>
  153. </div>
  154. <div
  155. style="width: 500px;display: flex;justify-content: flex-end;"
  156. v-if="judgeNum"
  157. >
  158. <div class="updateCordSty" @click="open">修改</div>
  159. </div>
  160. <div v-if="proVisible" class="mask">
  161. <div class="progressBox">
  162. <div class="lbox">
  163. <img src="@/assets/loading.gif" />上传中,请稍后
  164. </div>
  165. <div style="margin-bottom: 10px">
  166. <span>{{ isFinishSize }}M</span>
  167. /
  168. <span>{{ isAllSize }}M</span>
  169. </div>
  170. <el-progress
  171. :text-inside="true"
  172. :stroke-width="20"
  173. :percentage="progress ? progress : 0"
  174. style="width: 80%"
  175. ></el-progress>
  176. </div>
  177. </div>
  178. </div>
  179. </template>
  180. <script>
  181. export default {
  182. props: {
  183. judgeNum: {
  184. type: Number,
  185. default: 0
  186. },
  187. recordDataCopy: {
  188. type: Object,
  189. default: () => {
  190. return {};
  191. }
  192. },
  193. termList: {
  194. type: Array,
  195. default: () => {
  196. return [];
  197. }
  198. },
  199. weiList: {
  200. type: Array,
  201. default: () => {
  202. return [];
  203. }
  204. },
  205. studentList: {
  206. type: Array,
  207. default: () => {
  208. return [];
  209. }
  210. }
  211. },
  212. data() {
  213. return {
  214. recordData: {},
  215. imgList: [],
  216. uploadProgress: 0,
  217. // Progress: false,
  218. proVisible: false,
  219. progress: 0,
  220. inputShow: false,
  221. isFinishSize: 0,
  222. isAllSize: 0
  223. };
  224. },
  225. methods: {
  226. previewImg(url) {
  227. this.$hevueImgPreview(url);
  228. },
  229. // 确认修改记录提示?
  230. open() {
  231. // console.log(this.recordData);
  232. if (!this.recordData.type.length) {
  233. this.$message({
  234. type: "success",
  235. message: "请选择纬度",
  236. type: "warning"
  237. });
  238. return;
  239. }
  240. // return
  241. this.$confirm("是否修改?", "提示", {
  242. confirmButtonText: "确定",
  243. cancelButtonText: "取消"
  244. })
  245. .then(() => {
  246. this.updateCord();
  247. this.$message({
  248. type: "success",
  249. message: "已修改"
  250. });
  251. })
  252. .catch(() => {
  253. this.$message({
  254. type: "info",
  255. message: "已取消修改"
  256. });
  257. });
  258. },
  259. // 修改记录
  260. updateCord() {
  261. let params = [
  262. {
  263. rid: this.recordData.rid,
  264. tid: this.$route.query.userid,
  265. contact: this.recordData.contact.join(","),
  266. type: this.recordData.type.join(","),
  267. timing: this.recordData.recordDate,
  268. place: this.recordData.place,
  269. observeCon: this.recordData.recordTit,
  270. recordCon: this.recordData.recordContent,
  271. imgList: this.recordData.recordImg.join(","),
  272. term: this.recordData.term
  273. }
  274. ];
  275. // return console.log("修改记录", params);
  276. this.ajax
  277. .post(this.$store.state.api + "updateRecordData", params)
  278. .then(res => {
  279. console.log(res);
  280. this.$emit("closePop");
  281. this.$emit("getData");
  282. });
  283. // updateRecordData
  284. },
  285. // 删除图片
  286. delImg(e) {
  287. console.log("删除图片", e);
  288. const iii = this.recordData.recordImg.indexOf(e);
  289. this.recordData.recordImg.splice(iii, 1);
  290. // this.recordData.recordImg = this.recordData.recordImg.
  291. },
  292. addImg(e) {
  293. var el = e.currentTarget;
  294. el.getElementsByTagName("input")[0].click();
  295. e.target.value = "";
  296. },
  297. beforeUpload(event, type) {
  298. // const loading = this.openLoading();
  299. var file = event.target.files[0];
  300. var credentials = {
  301. accessKeyId: "AKIATLPEDU37QV5CHLMH",
  302. secretAccessKey: "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"
  303. }; //秘钥形式的登录上传
  304. window.AWS.config.update(credentials);
  305. window.AWS.config.region = "cn-northwest-1"; //设置区域
  306. var bucket = new window.AWS.S3({ params: { Bucket: "ccrb" } }); //选择桶
  307. var imgA = [
  308. "png",
  309. "jpg",
  310. "jpeg",
  311. "bmp",
  312. "gif",
  313. "webp",
  314. "psd",
  315. "svg",
  316. "tiff"
  317. ];
  318. if (
  319. imgA.indexOf(file.name.split(".")[file.name.split(".").length - 1]) ==
  320. -1
  321. ) {
  322. this.$message.error("图片格式错误");
  323. return;
  324. }
  325. this.imgLoading = true;
  326. var _this = this;
  327. this.inputShow = false;
  328. this.progress = 0;
  329. this.proVisible = true;
  330. this.isFinishSize = 0;
  331. this.isAllSize = (file.size / 1024 / 1024).toFixed(2);
  332. _this.$forceUpdate();
  333. if (file) {
  334. var params = {
  335. Key:
  336. file.name.split(".")[0] +
  337. new Date().getTime() +
  338. "." +
  339. file.name.split(".")[file.name.split(".").length - 1],
  340. ContentType: file.type,
  341. Body: file,
  342. "Access-Control-Allow-Credentials": "*",
  343. ACL: "public-read"
  344. }; //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
  345. var options = {
  346. partSize: 2048 * 1024 * 1024,
  347. queueSize: 2,
  348. leavePartsOnError: true
  349. };
  350. bucket
  351. .upload(params, options)
  352. .on("httpUploadProgress", function(evt) {
  353. //这里可以写进度条
  354. _this.progress = parseInt((evt.loaded / evt.total) * 100);
  355. _this.isFinishSize = (evt.loaded / 1024 / 1024).toFixed(2);
  356. _this.$forceUpdate();
  357. })
  358. .send(function(err, data) {
  359. _this.imgLoading = false;
  360. // loading.close();
  361. _this.progress = 100;
  362. _this.isFinishSize = _this.isAllSize;
  363. _this.$forceUpdate();
  364. setTimeout(() => {
  365. _this.proVisible = false;
  366. _this.$forceUpdate();
  367. }, 1000);
  368. _this.inputShow = true;
  369. if (err) {
  370. _this.$message.error("上传失败");
  371. } else {
  372. _this.recordData.recordImg.push(data.Location);
  373. _this.$forceUpdate();
  374. console.log(_this.checkJson);
  375. console.log(data.Location);
  376. }
  377. });
  378. }
  379. }
  380. },
  381. watch: {
  382. recordDataCopy: {
  383. handler: function(newVal, oldVal) {
  384. this.recordData = JSON.parse(JSON.stringify(this.recordDataCopy));
  385. },
  386. deep: true
  387. }
  388. },
  389. mounted() {
  390. this.recordData = JSON.parse(JSON.stringify(this.recordDataCopy));
  391. // console.log("??????????????????????????????????", this.recordData);
  392. }
  393. };
  394. </script>
  395. <style scoped>
  396. .popbox {
  397. padding: 10px;
  398. border-radius: 10px;
  399. box-shadow: 0 0 10px #ccc;
  400. }
  401. .mask {
  402. background-color: rgb(0 0 0 / 30%);
  403. /* position: fixed; */
  404. position: absolute;
  405. top: 0;
  406. left: 0;
  407. width: 100%;
  408. height: 100%;
  409. z-index: 90;
  410. display: flex;
  411. align-items: center;
  412. justify-content: center;
  413. }
  414. .progressBox {
  415. width: 300px;
  416. height: 150px;
  417. background: #fff;
  418. border-radius: 10px;
  419. box-shadow: 0 0 6px 1px #bfbfbf;
  420. display: flex;
  421. align-items: center;
  422. justify-content: center;
  423. flex-direction: column;
  424. position: relative;
  425. color: #6c6c6c;
  426. }
  427. .progressBox >>> .el-progress-bar__outer {
  428. background-color: #d1dfff !important;
  429. }
  430. .progressBox .lbox {
  431. height: 50px;
  432. font-size: 19px;
  433. display: flex;
  434. align-items: center;
  435. color: #747474;
  436. }
  437. .progressBox .lbox img {
  438. width: 40px;
  439. margin-right: 20px;
  440. }
  441. .tit {
  442. width: 100%;
  443. text-align: center;
  444. margin-bottom: 10px;
  445. }
  446. .cellBlock {
  447. width: 500px;
  448. box-sizing: border-box;
  449. padding: 10px 0;
  450. display: flex;
  451. /* justify-content: center; */
  452. align-items: center;
  453. }
  454. .cellBlock > .username {
  455. width: 70px;
  456. flex-shrink: 0;
  457. font-size: 16px;
  458. text-align: right;
  459. margin-right: 10px;
  460. display: flex;
  461. justify-content: flex-end;
  462. /* justify-content: space-between; */
  463. }
  464. /deep/ .el-input__inner {
  465. width: 400px;
  466. }
  467. .imgBlock {
  468. width: 500px;
  469. display: flex;
  470. justify-content: flex-start;
  471. flex-wrap: wrap;
  472. }
  473. .imgCell {
  474. position: relative;
  475. width: 100px;
  476. height: 100px;
  477. margin-right: 10px;
  478. margin-bottom: 10px;
  479. display: flex;
  480. justify-content: center;
  481. align-items: center;
  482. border: #ccc 1px solid;
  483. }
  484. .imgCell > .imgDelBtn {
  485. position: absolute;
  486. right: 5px;
  487. top: 5px;
  488. width: 15px;
  489. height: 15px;
  490. border-radius: 50%;
  491. background-color: #fff;
  492. cursor: pointer;
  493. display: flex;
  494. justify-content: center;
  495. align-items: center;
  496. }
  497. .imgCellCon {
  498. width: 100%;
  499. height: 100%;
  500. display: block;
  501. }
  502. .updateCordSty {
  503. cursor: pointer;
  504. padding: 10px 0;
  505. width: 120px;
  506. transform: translate(50%, 0%);
  507. /* float: right; */
  508. background-color: rgba(17, 61, 221, 0.5);
  509. border-radius: 5px;
  510. color: #fff;
  511. display: flex;
  512. justify-content: center;
  513. align-items: center;
  514. }
  515. /* .shadow {
  516. position: absolute;
  517. left: 0;
  518. top: 0;
  519. width: 100%;
  520. height: 100%;
  521. } */
  522. /* ::v-deep .el-input__inner {
  523. width: 200px;
  524. }
  525. ::v-deep .el-select {
  526. width: 200px !important;
  527. } */
  528. /* .conCant {
  529. position: relative;
  530. border: 1px solid #ccc;
  531. width: 200px;
  532. min-height: 40px;
  533. display: flex;
  534. align-items: center;
  535. position: relative;
  536. box-sizing: border-box;
  537. padding: 0 10px;
  538. } */
  539. /* .conCantTxt {
  540. display: flex;
  541. justify-content: flex-start;
  542. margin-right: 5px;
  543. flex-wrap: wrap;
  544. position: relative;
  545. } */
  546. /* .tactList {
  547. position: absolute;
  548. left: 0;
  549. top: 110%;
  550. width: 200px;
  551. height: 200px;
  552. overflow-y: scroll;
  553. background-color: #fff;
  554. border: 1px solid #ccc;
  555. z-index: 10;
  556. box-sizing: border-box;
  557. padding: 10px;
  558. display: flex;
  559. flex-direction: column;
  560. } */
  561. /* .tactListCell {
  562. display: flex;
  563. justify-content: flex-start;
  564. align-items: center;
  565. box-sizing: border-box;
  566. padding: 2px 5px;
  567. background-color: #ccc;
  568. } */
  569. /* .iSty {
  570. position: absolute;
  571. right: 10px;
  572. top: 50%;
  573. transform: translate(0, -50%);
  574. } */
  575. </style>