file.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  1. <template>
  2. <div class="c_box">
  3. <!-- <div class="mask"></div> -->
  4. <!-- <div v-if="!checkJson">暂未设置题目</div> -->
  5. <!-- <div v-if="!cJson">暂未设置题目</div> -->
  6. <div class="choices" v-if="!cJson">
  7. <div class="binfo_input">
  8. <div><span>填写者上传区</span></div>
  9. </div>
  10. </div>
  11. <div v-else class="choice_box">
  12. <!-- <div class="title"><div>{{ `(${option[checkJson.type].name})` }}</div><div v-html="checkJson.title"></div></div> -->
  13. <div class="title" style="display: flex;">
  14. <!-- + `(${option[checkJson.type].name})` -->
  15. <span style="min-width: fit-content;">{{ tindex + 1 + "、" }}</span>
  16. <span>{{ checkJson.title }}</span>
  17. <span
  18. style="color: #efa030;min-width: fit-content;"
  19. v-if="checkJson.score"
  20. >({{ "分值:" + checkJson.score + "分" }})</span
  21. >
  22. <!-- </div><div v-html="checkJson.title"></div> -->
  23. </div>
  24. <div
  25. class="detail"
  26. v-if="checkJson.detail"
  27. v-html="checkJson.detail"
  28. style="color: #00000099;margin-top: 5px;"
  29. ></div>
  30. <div class="choices">
  31. <div class="uploadBtn" v-if="checktype == 1">
  32. <div class="btn" @click.stop="addImg($event)">
  33. <span>添加本地文件</span>
  34. <input
  35. type="file"
  36. accept="*"
  37. style="display: none"
  38. multiple="multiple"
  39. @change="beforeUpload($event)"
  40. />
  41. </div>
  42. <div class="btn" @click="openFileBox()">
  43. <span>从资源库添加</span>
  44. </div>
  45. <div class="switch">
  46. <el-switch active-color="#3681fc" v-model="isTong"> </el-switch>
  47. <span @click="isTong = !isTong">同步至资源库</span>
  48. </div>
  49. </div>
  50. <div class="binfo_input">
  51. <div class="fileBox" v-if="(checkJson.file && checkJson.file.length) || uploadList.length">
  52. <div class="fileC">
  53. <div
  54. class="file"
  55. v-for="(item, index) in checkJson.file"
  56. :key="index"
  57. @click.stop="checkFile(item)"
  58. >
  59. <img
  60. class="del"
  61. src="../../../../../../assets/icon/fileIcon/deleteworks.png"
  62. @click.stop="delFile(index)"
  63. />
  64. <img
  65. class="download"
  66. src="../../../../../../assets/icon/fileIcon/download.png"
  67. @click.stop="downloadFile(item)"
  68. :style="{ right: checktype != 1 ? '10px' : '45px' }"
  69. />
  70. <img class="img" :src="wordIcon" alt="" v-if="item.type == 1" />
  71. <img
  72. class="img"
  73. :src="videoIcon"
  74. alt=""
  75. v-if="item.type == 2"
  76. />
  77. <img class="img" :src="item.url" alt="" v-if="item.type == 3" />
  78. <img class="img" :src="wordIcon" alt="" v-if="item.type == 4" />
  79. <img class="img" :src="fileIcon" alt="" v-if="item.type == 5" />
  80. <div class="name">
  81. <el-tooltip
  82. :content="item.name"
  83. placement="top"
  84. effect="dark"
  85. >
  86. <span>{{ item.name }}</span>
  87. </el-tooltip>
  88. </div>
  89. </div>
  90. <div
  91. class="file"
  92. v-for="(item, index) in uploadList"
  93. :key="item.index"
  94. >
  95. <img
  96. class="del"
  97. src="../../../../../../assets/icon/fileIcon/delFile.svg"
  98. @click.stop="delUploadFile(item)"
  99. />
  100. <img class="img" :src="wordIcon" alt="" v-if="item.type == 1" />
  101. <img
  102. class="img"
  103. :src="videoIcon"
  104. alt=""
  105. v-if="item.type == 2"
  106. />
  107. <img class="img" :src="fileIcon" alt="" v-if="item.type == 3" />
  108. <img class="img" :src="wordIcon" alt="" v-if="item.type == 4" />
  109. <img class="img" :src="fileIcon" alt="" v-if="item.type == 5" />
  110. <div class="uploadProgress">
  111. <div>{{ item.progress.value }}%</div>
  112. <span>上传中...</span>
  113. </div>
  114. <div class="name">
  115. <el-tooltip
  116. :content="item.name"
  117. placement="top"
  118. effect="dark"
  119. >
  120. <span>{{ item.name }}</span>
  121. </el-tooltip>
  122. </div>
  123. <!-- {{ item }} -->
  124. </div>
  125. </div>
  126. <!-- @click.stop="addImg($event)" -->
  127. <!-- <div class="btn" @click.stop="openFileBox()">
  128. <span>点击添加文件</span>
  129. <input type="file" accept="*" style="display: none" multiple="multiple" @change="beforeUpload($event)" />
  130. </div> -->
  131. </div>
  132. <!-- @click.stop="addImg($event)" @click.stop="addImg($event)" -->
  133. <div class="uploadQ" v-else>
  134. <span>填写者上传区</span>
  135. <!-- <input type="file" accept="*" style="display: none" multiple="multiple" @change="beforeUpload($event)" /> -->
  136. </div>
  137. <div v-if="proVisible" class="mask">
  138. <div class="progressBox">
  139. <div class="lbox">
  140. <img src="../../../../../../assets/loading.gif" />上传中,请稍后
  141. </div>
  142. <!-- <div style="margin-bottom: 10px">
  143. <span>{{
  144. isFinishSize
  145. }}M</span>
  146. /
  147. <span>{{
  148. isAllSize
  149. }}M</span>
  150. </div> -->
  151. <!-- <el-progress :text-inside="true" :stroke-width="20" :percentage="progress
  152. ? progress
  153. : 0
  154. " style="width: 80%"></el-progress> -->
  155. </div>
  156. </div>
  157. </div>
  158. <!-- <textarea :readonly="checktype == 2" rows="2" v-autoHeight="68" class="binfo_input binfo_textarea" cols v-model="checkJson.answer2"
  159. placeholder=""></textarea> -->
  160. </div>
  161. </div>
  162. <wpdf :dialogVisiblePdf.sync="dialogVisiblePdf" :url="wurl"></wpdf>
  163. <wVideo :dialogVisibleVideo.sync="dialogVisibleVideo" :url="wurl"></wVideo>
  164. <wOffice
  165. :dialogVisibleOffice.sync="dialogVisibleOffice"
  166. :url="wurl"
  167. ></wOffice>
  168. <checkfile
  169. :dialogVisiblefile.sync="dialogVisiblefile"
  170. @setCheckJson="setCheckJson"
  171. ></checkfile>
  172. <uploadFile
  173. v-for="(item, index) in uploadList"
  174. :ref="`uploadFileRef${item.index}`"
  175. :key="item.index"
  176. :index="item.index"
  177. @progressUpdate="progressUpdate"
  178. @success="uploadSuccess"
  179. />
  180. </div>
  181. </template>
  182. <script>
  183. import "../../../../../../common/aws-sdk-2.235.1.min.js";
  184. import videoIcon from "../../../../../../assets/icon/fileIcon/isVideo.png";
  185. import wordIcon from "../../../../../../assets/icon/fileIcon/isWord.png";
  186. import fileIcon from "../../../../../../assets/icon/fileIcon/word2.png";
  187. import wVideo from "../../../file/wVideo.vue";
  188. import wpdf from "../../../file/wPdf2.vue";
  189. import wOffice from "../../../file/wOffice.vue";
  190. import checkfile from "../../../file/checkfile.vue";
  191. import uploadFile from "./uploadFile.vue";
  192. import { v4 as uuidv4 } from "uuid";
  193. export default {
  194. components: {
  195. wpdf,
  196. wVideo,
  197. wOffice,
  198. checkfile,
  199. uploadFile
  200. },
  201. props: {
  202. tindex: {
  203. type: Number
  204. },
  205. cJson: {
  206. type: Object
  207. },
  208. checktype: {
  209. type: Number,
  210. default: 1
  211. },
  212. see: {
  213. type: Boolean,
  214. default: false
  215. }
  216. },
  217. data() {
  218. return {
  219. option: {
  220. 1: { name: "附件" }
  221. },
  222. userid: this.$route.query.userid,
  223. checkJson: undefined,
  224. progress: 0,
  225. isFinishSize: 0,
  226. proVisible: false,
  227. isAllSize: 0,
  228. videoIcon: videoIcon,
  229. wordIcon: wordIcon,
  230. fileIcon: fileIcon,
  231. dialogVisiblePdf: false,
  232. dialogVisibleVideo: false,
  233. dialogVisibleOffice: false,
  234. dialogVisiblefile: false,
  235. wurl: "",
  236. isTong: false,
  237. uploadList:[],
  238. };
  239. },
  240. watch: {
  241. checkJson: {
  242. handler(newValue) {
  243. this.$emit("update:cJson", newValue);
  244. },
  245. deep: true
  246. }
  247. },
  248. methods: {
  249. depthCopy(s) {
  250. return JSON.parse(JSON.stringify(s));
  251. },
  252. openFileBox() {
  253. this.dialogVisiblefile = true;
  254. },
  255. addImg(e) {
  256. var el = e.currentTarget;
  257. el.getElementsByTagName("input")[0].click();
  258. e.target.value = "";
  259. },
  260. beforeUpload(event, type) {
  261. // const loading = this.openLoading();
  262. let file = "";
  263. let cfindex2 = 0;
  264. for (var cfindex = 0; cfindex < event.target.files.length; cfindex++) {
  265. file = event.target.files[cfindex];
  266. let _type = 2;
  267. var imgA = [
  268. "png",
  269. "jpg",
  270. "jpeg",
  271. "bmp",
  272. "gif",
  273. "webp",
  274. "psd",
  275. "svg",
  276. "tiff"
  277. ];
  278. var fileA = [
  279. "DOC",
  280. "DOCX",
  281. "DOCM",
  282. "DOTM",
  283. "DOTX",
  284. "PPTX",
  285. "PPSX",
  286. "PPT",
  287. "PPS",
  288. "PPTM",
  289. "POTM",
  290. "PPAM",
  291. "POTX",
  292. "PPSM",
  293. "XLSX",
  294. "XLS"
  295. ];
  296. var videoA = [
  297. "AVI",
  298. "NAVI",
  299. "MPEG",
  300. "ASF",
  301. "MOV",
  302. "WMV",
  303. "3GP",
  304. "RM",
  305. "RMVB",
  306. "FLV",
  307. "F4V",
  308. "H.264",
  309. "H.265",
  310. "REAL VIDEO",
  311. "MKV",
  312. "WebM",
  313. "HDDVD",
  314. "MP4",
  315. "MPG",
  316. "M4V",
  317. "MGV",
  318. "OGV",
  319. "QTM",
  320. "STR",
  321. "AMC",
  322. "DVX",
  323. "EVO",
  324. "DAT",
  325. "OGG",
  326. "OGM"
  327. ];
  328. if (
  329. fileA.indexOf(
  330. file.name.split(".")[
  331. file.name.split(".").length - 1
  332. ].toLocaleUpperCase()
  333. ) != -1
  334. ) {
  335. _type = 1; //word 文件
  336. } else if (
  337. videoA.indexOf(
  338. file.name.split(".")[
  339. file.name.split(".").length - 1
  340. ].toLocaleUpperCase()
  341. ) != -1
  342. ) {
  343. _type = 2; //视频
  344. } else if (
  345. imgA.indexOf(
  346. file.name.split(".")[
  347. file.name.split(".").length - 1
  348. ].toLocaleLowerCase()
  349. ) != -1
  350. ) {
  351. _type = 3; //图片
  352. } else if (
  353. "pdf".indexOf(
  354. file.name.split(".")[
  355. file.name.split(".").length - 1
  356. ].toLocaleLowerCase()
  357. ) != -1
  358. ) {
  359. _type = 4; //pdf
  360. } else {
  361. _type = 5; //文件
  362. }
  363. this.uploadList.push({
  364. index: uuidv4(),
  365. file: file,
  366. name:file.name,
  367. type:_type,
  368. progress: { status: "", value: 0,key:"",uploadid:"" }
  369. });
  370. }
  371. this.$nextTick(() => {
  372. this.uploadList.forEach(i => {
  373. this.$refs[`uploadFileRef${i.index}`][0].awsupload({ file: i.file });
  374. });
  375. });
  376. // var credentials = {
  377. // accessKeyId: "AKIATLPEDU37QV5CHLMH",
  378. // secretAccessKey: "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"
  379. // }; //秘钥形式的登录上传
  380. // window.AWS.config.update(credentials);
  381. // window.AWS.config.region = "cn-northwest-1"; //设置区域
  382. // var bucket = new window.AWS.S3({ params: { Bucket: "ccrb" } }); //选择桶
  383. // var _this = this;
  384. // // _this.progress = 0;
  385. // _this.proVisible = true;
  386. // // _this.isFinishSize = 0;
  387. // // _this.isAllSize = (file.size / 1024 / 1024).toFixed(2);
  388. // let _name = file.name;
  389. // let size = file.size;
  390. // _this.$forceUpdate();
  391. // if (file) {
  392. // var params = {
  393. // Key:
  394. // file.name.split(".")[0] +
  395. // new Date().getTime() +
  396. // "." +
  397. // file.name.split(".")[file.name.split(".").length - 1],
  398. // ContentType: file.type,
  399. // Body: file,
  400. // "Access-Control-Allow-Credentials": "*",
  401. // ACL: "public-read"
  402. // }; //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
  403. // var options = {
  404. // partSize: 2048 * 1024 * 1024,
  405. // queueSize: 2,
  406. // leavePartsOnError: true
  407. // };
  408. // bucket
  409. // .upload(params, options)
  410. // .on("httpUploadProgress", function(evt) {
  411. // //这里可以写进度条
  412. // // console.log("Uploaded : " + parseInt((evt.loaded * 80) / evt.total) + '%');
  413. // // _this.progress = parseInt((evt.loaded / evt.total) * 100);
  414. // // _this.isFinishSize = (evt.loaded / 1024 / 1024).toFixed(2);
  415. // // _this.$forceUpdate();
  416. // })
  417. // .send(function(err, data) {
  418. // cfindex2++;
  419. // // _this.progress = 100;
  420. // // _this.isFinishSize = _this.isAllSize;
  421. // // _this.$forceUpdate();
  422. // // setTimeout(() => {
  423. // // _this.proVisible = false;
  424. // // _this.$forceUpdate();
  425. // // }, 1000);
  426. // setTimeout(() => {
  427. // if (
  428. // cfindex2 == event.target.files.length ||
  429. // cfindex2 > event.target.files.length
  430. // ) {
  431. // _this.proVisible = false;
  432. // }
  433. // }, 1000);
  434. // // loading.close();
  435. // if (err) {
  436. // _this.$message.error("上传失败");
  437. // } else {
  438. // let _type = 2;
  439. // var imgA = [
  440. // "png",
  441. // "jpg",
  442. // "jpeg",
  443. // "bmp",
  444. // "gif",
  445. // "webp",
  446. // "psd",
  447. // "svg",
  448. // "tiff"
  449. // ];
  450. // var fileA = [
  451. // "DOC",
  452. // "DOCX",
  453. // "DOCM",
  454. // "DOTM",
  455. // "DOTX",
  456. // "PPTX",
  457. // "PPSX",
  458. // "PPT",
  459. // "PPS",
  460. // "PPTM",
  461. // "POTM",
  462. // "PPAM",
  463. // "POTX",
  464. // "PPSM",
  465. // "XLSX",
  466. // "XLS"
  467. // ];
  468. // var videoA = [
  469. // "AVI",
  470. // "NAVI",
  471. // "MPEG",
  472. // "ASF",
  473. // "MOV",
  474. // "WMV",
  475. // "3GP",
  476. // "RM",
  477. // "RMVB",
  478. // "FLV",
  479. // "F4V",
  480. // "H.264",
  481. // "H.265",
  482. // "REAL VIDEO",
  483. // "MKV",
  484. // "WebM",
  485. // "HDDVD",
  486. // "MP4",
  487. // "MPG",
  488. // "M4V",
  489. // "MGV",
  490. // "OGV",
  491. // "QTM",
  492. // "STR",
  493. // "AMC",
  494. // "DVX",
  495. // "EVO",
  496. // "DAT",
  497. // "OGG",
  498. // "OGM"
  499. // ];
  500. // if (
  501. // fileA.indexOf(
  502. // data.Location.split(".")[
  503. // data.Location.split(".").length - 1
  504. // ].toLocaleUpperCase()
  505. // ) != -1
  506. // ) {
  507. // _type = 1; //word 文件
  508. // } else if (
  509. // videoA.indexOf(
  510. // data.Location.split(".")[
  511. // data.Location.split(".").length - 1
  512. // ].toLocaleUpperCase()
  513. // ) != -1
  514. // ) {
  515. // _type = 2; //视频
  516. // } else if (
  517. // imgA.indexOf(
  518. // data.Location.split(".")[
  519. // data.Location.split(".").length - 1
  520. // ].toLocaleLowerCase()
  521. // ) != -1
  522. // ) {
  523. // _type = 3; //图片
  524. // } else if (
  525. // "pdf".indexOf(
  526. // data.Location.split(".")[
  527. // data.Location.split(".").length - 1
  528. // ].toLocaleLowerCase()
  529. // ) != -1
  530. // ) {
  531. // _type = 4; //pdf
  532. // } else {
  533. // _type = 5; //文件
  534. // }
  535. // if (_this.checkJson.file) {
  536. // _this.checkJson.file.push({
  537. // name: _name,
  538. // url: data.Location,
  539. // type: _type
  540. // });
  541. // } else {
  542. // _this.checkJson.file = [];
  543. // _this.checkJson.file.push({
  544. // name: _name,
  545. // url: data.Location,
  546. // type: _type
  547. // });
  548. // }
  549. // if (_this.isTong) {
  550. // let _file = {
  551. // name: _name,
  552. // url: data.Location,
  553. // type: _type,
  554. // size: _this.formatFileSize(size)
  555. // };
  556. // _this.addSource(_file);
  557. // }
  558. // _this.$forceUpdate();
  559. // console.log(_this.checkJson);
  560. // console.log(data.Location);
  561. // }
  562. // });
  563. // }
  564. // }
  565. },
  566. delUploadFile(item) {
  567. this.$refs[`uploadFileRef${item.index}`][0].stopUpload();
  568. this.$refs[`uploadFileRef${item.index}`][0].abortMultipartUpload(
  569. item.progress.key,
  570. item.progress.uploadid
  571. );
  572. this.uploadList = this.uploadList.filter(i => i.index != item.index);
  573. },
  574. // 上传文件进度条
  575. progressUpdate(res) {
  576. this.uploadList.find(i => i.index == res.index).progress.status =
  577. res.status;
  578. this.uploadList.find(i => i.index == res.index).progress.value =
  579. res.percent;
  580. this.uploadList.find(i => i.index == res.index).progress.key = res.key;
  581. this.uploadList.find(i => i.index == res.index).progress.uploadid =
  582. res.uploadid;
  583. },
  584. //上传文件成功
  585. uploadSuccess(res) {
  586. let data = res.data;
  587. let _name = this.uploadList.find(i => i.index == res.index).file.name;
  588. let size = this.uploadList.find(i => i.index == res.index).file.size;
  589. let _type = this.uploadList.find(i => i.index == res.index).type;
  590. if (this.checkJson.file) {
  591. this.checkJson.file.push({
  592. name: _name,
  593. url: data.Location,
  594. type: _type
  595. });
  596. } else {
  597. this.checkJson.file = [];
  598. this.checkJson.file.push({
  599. name: _name,
  600. url: data.Location,
  601. type: _type
  602. });
  603. }
  604. if (this.isTong) {
  605. let _file = {
  606. name: _name,
  607. url: data.Location,
  608. type: _type,
  609. size: this.formatFileSize(size)
  610. };
  611. this.addSource(_file);
  612. }
  613. this.$forceUpdate();
  614. this.$emit("update:cJson", this.checkJson);
  615. this.uploadList = this.uploadList.filter(i => i.index != res.index);
  616. console.log(this.checkJson);
  617. console.log(data.Location);
  618. },
  619. addSource(file) {
  620. let params = [
  621. {
  622. n: file.name,
  623. file: file.url,
  624. type: file.type,
  625. pid: "0",
  626. uid: this.userid,
  627. size: file.size
  628. }
  629. ];
  630. this.ajax
  631. .post(this.$store.state.api + "addSourceFile", params)
  632. .then(res => {
  633. // if (_ctype == 2) {
  634. // this.$message.success('上传成功');
  635. // }
  636. })
  637. .catch(err => {
  638. console.error(err);
  639. });
  640. },
  641. formatFileSize(bytes) {
  642. if (bytes < 1024) {
  643. return bytes + "B";
  644. } else if (bytes < 1048576) {
  645. return (bytes / 1024).toFixed(2) + "KB";
  646. } else if (bytes < 1073741824) {
  647. return (bytes / 1048576).toFixed(2) + "MB";
  648. } else {
  649. return (bytes / 1073741824).toFixed(2) + "GB";
  650. }
  651. },
  652. setCheckJson(name, url, type) {
  653. if (this.checkJson.file) {
  654. this.checkJson.file.push({
  655. name: name,
  656. url: url,
  657. type: type
  658. });
  659. } else {
  660. this.checkJson.file = [];
  661. this.checkJson.file.push({
  662. name: name,
  663. url: url,
  664. type: type
  665. });
  666. }
  667. this.$forceUpdate();
  668. },
  669. checkFile(item) {
  670. if (item.type == 3) {
  671. this.$hevueImgPreview(item.url);
  672. } else if (item.type == 5) {
  673. this.downloadFile(item);
  674. } else if (item.type == 1) {
  675. this.dialogVisibleOffice = true;
  676. this.wurl = item.url;
  677. } else if (item.type == 2) {
  678. this.dialogVisibleVideo = true;
  679. this.wurl = item.url;
  680. } else if (item.type == 4) {
  681. this.dialogVisiblePdf = true;
  682. this.wurl = item.url;
  683. }
  684. },
  685. downloadFile(f) {
  686. var credentials = {
  687. accessKeyId: "AKIATLPEDU37QV5CHLMH",
  688. secretAccessKey: "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"
  689. }; //秘钥形式的登录上传
  690. window.AWS.config.update(credentials);
  691. window.AWS.config.region = "cn-northwest-1"; //设置区域
  692. let url2 = f.url;
  693. let _url2 = "";
  694. if (
  695. url2.indexOf("https://view.officeapps.live.com/op/view.aspx?src=") != -1
  696. ) {
  697. _url2 = url2.split(
  698. "https://view.officeapps.live.com/op/view.aspx?src="
  699. )[1];
  700. } else {
  701. _url2 = url2;
  702. }
  703. let _this = this;
  704. _this.downLoading = _url2;
  705. var s3 = new window.AWS.S3({ params: { Bucket: "ccrb" } });
  706. let name = decodeURIComponent(
  707. _url2.split("https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/")[1].replace(/\+/g, ' ')
  708. );
  709. var params = {
  710. Bucket: "ccrb",
  711. Key: name
  712. };
  713. s3.getObject(params, function(err, data) {
  714. _this.downLoading = "";
  715. if (err) console.log(err, err.stack);
  716. // an error occurred
  717. else {
  718. let url = window.URL.createObjectURL(new Blob([data.Body]));
  719. let a = document.createElement("a");
  720. a.name = f.name;
  721. a.href = url;
  722. a.download = f.name;
  723. a.click();
  724. console.log(data);
  725. } // sxuccessful response
  726. });
  727. },
  728. delFile(index) {
  729. this.checkJson.file.splice(index, 1);
  730. this.$forceUpdate();
  731. }
  732. },
  733. mounted() {
  734. this.checkJson = this.cJson ? this.depthCopy(this.cJson) : undefined;
  735. }
  736. };
  737. </script>
  738. <style scoped>
  739. .c_box {
  740. width: 100%;
  741. position: relative;
  742. }
  743. /* .mask {
  744. position: absolute;
  745. height: 100%;
  746. width: 100%;
  747. z-index: 2;
  748. } */
  749. .choice_box {
  750. white-space: pre-line;
  751. }
  752. .choice_box > .title {
  753. font-weight: bold;
  754. width: 100%;
  755. word-break: break-all;
  756. }
  757. .choice_box > .choices {
  758. margin-top: 10px;
  759. }
  760. .binfo_input {
  761. width: 100%;
  762. margin: 0;
  763. padding: 10px;
  764. display: block;
  765. min-width: 0;
  766. outline: none;
  767. box-sizing: border-box;
  768. background: none;
  769. border: none;
  770. border-radius: 5px;
  771. background: #fff;
  772. font-size: 16px;
  773. resize: none;
  774. font-family: "Microsoft YaHei";
  775. min-height: 120px;
  776. /* border: 1px solid #3682fc00; */
  777. border: 1.5px solid #e0e0e0;
  778. position: relative;
  779. }
  780. .binfo_input > .uploadQ {
  781. /* border: 1.5px dashed #dfdfdf; */
  782. height: 120px;
  783. width: 100%;
  784. display: flex;
  785. align-items: center;
  786. justify-content: center;
  787. background: #f9fafb;
  788. color: rgb(124, 124, 124);
  789. border-radius: 5px;
  790. cursor: pointer;
  791. }
  792. .mask {
  793. background-color: rgb(0 0 0 / 30%);
  794. /* position: fixed; */
  795. position: absolute;
  796. top: 0;
  797. left: 0;
  798. width: 100%;
  799. height: 100%;
  800. z-index: 90;
  801. display: flex;
  802. align-items: center;
  803. justify-content: center;
  804. }
  805. .progressBox {
  806. width: 300px;
  807. height: 150px;
  808. background: #fff;
  809. border-radius: 10px;
  810. box-shadow: 0 0 6px 1px #bfbfbf;
  811. display: flex;
  812. align-items: center;
  813. justify-content: center;
  814. flex-direction: column;
  815. position: relative;
  816. color: #6c6c6c;
  817. }
  818. .progressBox >>> .el-progress-bar__outer {
  819. background-color: #d1dfff !important;
  820. }
  821. .progressBox .lbox {
  822. height: 50px;
  823. font-size: 19px;
  824. display: flex;
  825. align-items: center;
  826. color: #747474;
  827. }
  828. .progressBox .lbox img {
  829. width: 40px;
  830. margin-right: 20px;
  831. }
  832. .closeCss {
  833. position: absolute;
  834. top: 8px;
  835. right: 8px;
  836. cursor: pointer;
  837. width: 20px;
  838. height: 20px;
  839. }
  840. .closeCss > img {
  841. width: 100%;
  842. height: 100%;
  843. }
  844. .binfo_input > .fileBox {
  845. }
  846. .binfo_input > .fileBox .fileC {
  847. display: flex;
  848. flex-wrap: wrap;
  849. width: 100%;
  850. cursor: pointer;
  851. }
  852. .binfo_input > .fileBox .fileC > .file {
  853. width: 200px;
  854. height: 140px;
  855. margin: 10px 10px 10px 0px;
  856. border-radius: 15px;
  857. box-shadow: rgb(223, 218, 218) 0px 0px 6px 1px;
  858. overflow: hidden;
  859. margin-right: 15px;
  860. position: relative;
  861. display: flex;
  862. flex-direction: column;
  863. }
  864. .binfo_input > .fileBox .fileC > .file > .img {
  865. width: 100%;
  866. height: calc(100% - 35px);
  867. object-fit: cover;
  868. }
  869. .binfo_input > .fileBox .fileC > .file > .del {
  870. position: absolute;
  871. width: 25px;
  872. top: 10px;
  873. right: 10px;
  874. cursor: pointer;
  875. z-index: 10;
  876. }
  877. .binfo_input > .fileBox .fileC > .file > .download {
  878. position: absolute;
  879. width: 25px;
  880. top: 10px;
  881. right: 35px;
  882. cursor: pointer;
  883. opacity: 0.8;
  884. }
  885. .binfo_input > .fileBox .fileC > .file > .name {
  886. height: 35px;
  887. width: 100%;
  888. background: #f9f9f9;
  889. display: flex;
  890. align-items: center;
  891. padding: 0 10px;
  892. box-sizing: border-box;
  893. }
  894. .binfo_input > .fileBox .fileC > .file > .name > span {
  895. display: block;
  896. text-overflow: ellipsis;
  897. max-width: 100%;
  898. white-space: nowrap;
  899. overflow: hidden;
  900. }
  901. .binfo_input > .fileBox .btn {
  902. width: 100%;
  903. height: 40px;
  904. background: #007bff;
  905. color: #fff;
  906. border-radius: 15px;
  907. margin-top: 10px;
  908. display: flex;
  909. align-items: center;
  910. justify-content: center;
  911. cursor: pointer;
  912. }
  913. .uploadBtn {
  914. display: flex;
  915. margin-bottom: 10px;
  916. align-items: center;
  917. width: 100%;
  918. justify-content: flex-end;
  919. }
  920. .uploadBtn .btn {
  921. display: flex;
  922. cursor: pointer;
  923. align-items: center;
  924. height: 30px;
  925. padding: 0 8px;
  926. background: #fff;
  927. color: #3681fc;
  928. border: 1px solid #3681fc;
  929. box-sizing: border-box;
  930. border-radius: 4px;
  931. font-size: 14px;
  932. align-items: center;
  933. margin-right: 10px;
  934. }
  935. .uploadBtn .switch {
  936. display: flex;
  937. align-items: center;
  938. cursor: pointer;
  939. }
  940. .uploadBtn .switch > span {
  941. margin-left: 5px;
  942. }
  943. .uploadProgress{
  944. position: absolute;
  945. width: 100%;
  946. height: calc(100% - 35px);
  947. background-color: #0000008a;
  948. display: flex;
  949. top: 0;
  950. flex-direction: column;
  951. justify-content: center;
  952. align-items: center;
  953. color: #fff;
  954. }
  955. .uploadProgress>div{
  956. font-size: 20px;
  957. font-weight: bold;
  958. margin-bottom: 10px;
  959. }
  960. </style>