newStudentProjectApply.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. <template>
  2. <!-- 测试上传组件 -->
  3. <div v-loading="loading">
  4. <div class="pAHeader">
  5. <div class="pAHeader1">创客项目申请</div>
  6. </div>
  7. <hr />
  8. <!-- 学生项目立项 -->
  9. <studentProjectWord
  10. ref="pdf"
  11. :wordData="wordData"
  12. :reversedMessage="reversedMessage"
  13. @fileOption2="fileOption2"
  14. @getFile2="getFile2"
  15. />
  16. <div style="position: fixed; bottom: 5%; right: 2%">
  17. <el-button @click="saveDraft" type="primary">保存草稿</el-button>
  18. <el-button @click="test" type="primary">保存项目</el-button>
  19. </div>
  20. <!-- 保存项目弹窗 -->
  21. <el-dialog
  22. title="提示"
  23. :visible.sync="submitHint"
  24. width="600px"
  25. class="pageSubmitData"
  26. >
  27. <div class="deleteContent">
  28. 确定保存“{{ wordData["projectName"] }}”项目吗?
  29. </div>
  30. <span slot="footer" class="dialog-footer">
  31. <el-button type="primary" @click="submitWord" class="AllDialogBtn"
  32. >确认保存</el-button
  33. >
  34. <el-button @click="submitHint = false" class="AllDialogBtn"
  35. >取消</el-button
  36. >
  37. </span>
  38. </el-dialog>
  39. <!-- 展示文件 -->
  40. <el-dialog
  41. title="展示文件"
  42. :visible.sync="showFile"
  43. top="1vh"
  44. width="80vw"
  45. append-to-body
  46. >
  47. <div class="showFileArea" style="height: 80vh">
  48. <!-- <vpdf v-if="/^\s*$/g.test(showFileUrl)&&showFileUrl.split('.')[showFileUrl.split('.').length-1]=='pdf'" :pdfUrl="showFileUrl"></vpdf> -->
  49. <div
  50. class="workd_media"
  51. style="width: 90%; height: 90%"
  52. v-if="videoDetail.sources"
  53. >
  54. <video-player
  55. class="video-player vjs-custom-skin"
  56. :playsinline="true"
  57. :options="videoDetail"
  58. @play="onPlayerPlay($event)"
  59. style="width: 90%; height: 90%; margin: 0 auto"
  60. ></video-player>
  61. </div>
  62. <vword
  63. style="width: 100%; height: 100%; overflow: auto"
  64. class="fullStyle"
  65. v-else-if="Wordss['type'] != 'pdf' && Wordss['name'] != '图片'"
  66. :pdfUrl="
  67. 'https://view.officeapps.live.com/op/view.aspx?src=' + showFileUrl
  68. "
  69. ></vword>
  70. <vpdf
  71. style="width: 100%; height: 100%; overflow: auto"
  72. class="fullStyle"
  73. :pdfUrl="showFileUrl"
  74. v-else-if="Wordss['type'] == 'pdf'"
  75. ></vpdf>
  76. <img
  77. :src="showFileUrl"
  78. alt="图片哦"
  79. v-else-if="Wordss['name'] == '图片'"
  80. style="width: auto; height: auto; max-width: 100%; max-height: 100%"
  81. />
  82. </div>
  83. <!-- <el-button type="primary" size="mini" @click="downFile(showFileUrl)">下载文件</el-button> -->
  84. </el-dialog>
  85. <!-- 修改文件名称 -->
  86. <el-dialog
  87. title="修改名称"
  88. :visible.sync="dialogVisibleUpdateFile"
  89. :append-to-body="true"
  90. width="500px"
  91. class="dialog_diy"
  92. >
  93. <div
  94. style="
  95. width: 100%;
  96. display: flex;
  97. flex-direction: row;
  98. flex-wrap: nowrap;
  99. align-items: center;
  100. justify-content: center;
  101. "
  102. >
  103. <div style="min-width: fit-content">文件名称:</div>
  104. <el-input
  105. v-model="updateFile.fileName"
  106. placeholder="请输入要修改的名称"
  107. ></el-input>
  108. </div>
  109. <span slot="footer" class="dialog-footer">
  110. <el-button @click="dialogVisibleUpdateFile = false">取 消</el-button>
  111. <el-button type="primary" @click="updateFileName">确 定</el-button>
  112. </span>
  113. </el-dialog>
  114. </div>
  115. </template>
  116. <script>
  117. // import MakerSpaceWord from '../components/MakerSpaceWord.vue'
  118. import getProjectNo from "@/components/tool/getProjectNo";
  119. import { getNowDate } from "@/components/tool/Date.js";
  120. import studentProjectWord from "./components/studentProjectWord.vue";
  121. import vpdf from "@/components/vpdf.vue";
  122. import vword from "@/components/vword.vue";
  123. // import markerFundWord from '@/components/markerFundWord.vue';
  124. // import markeractivityWord from '@/components/markeractivityWord.vue';
  125. export default {
  126. components: {
  127. studentProjectWord,
  128. vpdf,
  129. vword
  130. // markerFundWord,
  131. // markeractivityWord
  132. },
  133. data() {
  134. return {
  135. accept: "*",
  136. loading: false,
  137. submitHint: false,
  138. updatedWordDig: false, //立即修改对话框
  139. showFile:false,// 展示文件弹窗
  140. dialogVisibleUpdateFile:false,//修改文件弹窗
  141. word: [
  142. "DOC",
  143. "DOCX",
  144. "DOCM",
  145. "DOTM",
  146. "DOTX",
  147. "PPTX",
  148. "PPSX",
  149. "PPT",
  150. "PPS",
  151. "PPTM",
  152. "POTM",
  153. "PPAM",
  154. "POTX",
  155. "PPSM",
  156. "XLSX",
  157. "XLS",
  158. ],
  159. pdf: ["PDF"],
  160. image: [
  161. "BMP",
  162. "PJP",
  163. "APNG",
  164. "PNG",
  165. "JPG",
  166. "GIF",
  167. "SVG",
  168. "JPEG",
  169. "JPG",
  170. "ICO",
  171. "PGPEG",
  172. "AVIF",
  173. ],
  174. vedio: [
  175. "AVI",
  176. "NAVI",
  177. "MPEG",
  178. "ASF",
  179. "MOV",
  180. "WMV",
  181. "3GP",
  182. "RM",
  183. "RMVB",
  184. "FLV",
  185. "F4V",
  186. "H.264",
  187. "H.265",
  188. "REAL VIDEO",
  189. "MKV",
  190. "WebM",
  191. "HDDVD",
  192. "MP4",
  193. "MPG",
  194. "M4V",
  195. "MGV",
  196. "OGV",
  197. "QTM",
  198. "STR",
  199. "AMC",
  200. "DVX",
  201. "EVO",
  202. "DAT",
  203. "OGG",
  204. "OGM",
  205. ],
  206. playerOptions: {
  207. playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度
  208. autoplay: false, //如果true,浏览器准备好时开始回放。
  209. muted: false, // 默认情况下将会消除任何音频。
  210. loop: false, // 导致视频一结束就重新开始。
  211. preload: "auto", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
  212. language: "zh-CN",
  213. aspectRatio: "16:9", // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
  214. fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
  215. sources: [
  216. {
  217. type: "video/mp4", //这里的种类支持很多种:基本视频格式、直播、流媒体等,具体可以参看git网址项目 || "video/ogg"|| "video/webm"
  218. src: "", //url地址require("../../assets/media/aaa.mp4")
  219. },
  220. ],
  221. // poster: require("../../assets/tu31.png"), //你的封面地址
  222. // poster: dataRes.imgUrl, //你的封面地址
  223. notSupportedMessage: "此视频暂无法播放,请稍后再试", //允许覆盖Video.js无法播放媒体源时显示的默认信息。
  224. controlBar: {
  225. timeDivider: true, //当前时间和持续时间的分隔符
  226. durationDisplay: true, //显示持续时间
  227. remainingTimeDisplay: false, //是否显示剩余时间功能
  228. fullscreenToggle: true, //全屏按钮
  229. },
  230. },
  231. playerO: {},
  232. videoDetail: {},
  233. Wordss:{},
  234. showFileUrl:"",
  235. canonical: {
  236. Image:
  237. /^https?:\/\/(.+\/)+.+(\.(gif|png|jpg|jpeg|webp|svg|psd|bmp|tif))$/i,
  238. File: /^https?:\/\/(.+\/)+.+(\.(docx|xlsx|ppt|pdf))$/i,
  239. },
  240. updateFile:{
  241. url:"",
  242. fileName:""
  243. },
  244. wordData: {
  245. applicationDate: getNowDate(1), //申请日期
  246. projectName: "",
  247. radio: "",
  248. checkList: [],
  249. schoolRadio: [],
  250. applyParsonRadio: [],
  251. applyParsonName: "",
  252. college: "",
  253. tel: "",
  254. beginTime: "",
  255. endTime: "",
  256. studentS: [
  257. { name: "", collage: "", work: "" },
  258. { name: "", collage: "", work: "" },
  259. { name: "", collage: "", work: "" },
  260. { name: "", collage: "", work: "" },
  261. { name: "", collage: "", work: "" },
  262. { name: "", collage: "", work: "" },
  263. { name: "", collage: "", work: "" },
  264. { name: "", collage: "", work: "" },
  265. { name: "", collage: "", work: "" }
  266. ],
  267. teacherS: [
  268. { name: "", collage: "", work: "" },
  269. { name: "", collage: "", work: "" },
  270. { name: "", collage: "", work: "" },
  271. { name: "", collage: "", work: "" }
  272. ],
  273. brief: "",
  274. introduce: {
  275. back: "",
  276. innovate: "",
  277. path: "",
  278. scene: "",
  279. worth: "",
  280. team: "",
  281. cost: "",
  282. expectResults: "",
  283. expectResultsTeacher: "",
  284. expectConversion: "",
  285. plan: "",
  286. },
  287. attachment:[],
  288. total: "",
  289. fund: {
  290. device: "",
  291. Material: "",
  292. processing: "",
  293. Collaboration: "",
  294. APPRAISAL: "",
  295. entery: "",
  296. activities: "",
  297. Transaction: "",
  298. },
  299. opinion:[],
  300. },
  301. };
  302. },
  303. computed: {
  304. reversedMessage: function () {
  305. return (
  306. this.wordData.fund.device * 1 +
  307. this.wordData.fund.Material * 1 +
  308. this.wordData.fund.processing * 1 +
  309. this.wordData.fund.Collaboration * 1 +
  310. this.wordData.fund.APPRAISAL * 1 +
  311. this.wordData.fund.entery * 1 +
  312. this.wordData.fund.activities * 1 +
  313. this.wordData.fund.Transaction * 1
  314. );
  315. },
  316. },
  317. methods: {
  318. test() {
  319. //验证
  320. const cEmpty = /^\s*$/g;
  321. for (let i in this.wordData) {
  322. // console.log(this.wordData[i],i);
  323. switch (i) {
  324. case "projectName":
  325. if (cEmpty.test(this.wordData[i])) {
  326. this.$message.error("请输入项目名称");
  327. // this.$refs.projectName.style.background='rgb(236, 141, 141)'
  328. // setTimeout(() => {
  329. // this.$refs.projectName.style.background='#ffffff'
  330. // }, 2000);
  331. document
  332. .querySelector("#projectName")
  333. .scrollIntoView({ behavior: "smooth" });
  334. return false;
  335. }
  336. break;
  337. case "radio":
  338. if (cEmpty.test(this.wordData[i])) {
  339. this.$message.error("请选择项目分组");
  340. document
  341. .querySelector("#radio")
  342. .scrollIntoView({ behavior: "smooth" });
  343. return false;
  344. }
  345. break;
  346. // case "checkList":
  347. // if (this.wordData[i].length == 0) {
  348. // this.$message.error("优先支持项目");
  349. // document
  350. // .querySelector("#checkList")
  351. // .scrollIntoView({ behavior: "smooth" });
  352. // return false;
  353. // }
  354. // break;
  355. // case "schoolRadio":
  356. // if (this.wordData[i].length == 0) {
  357. // this.$message.error("请选择美丽校园改造项目");
  358. // document
  359. // .querySelector("#schoolRadio")
  360. // .scrollIntoView({ behavior: "smooth" });
  361. // return false;
  362. // }
  363. // break;
  364. // case "applyParsonRadio":
  365. // if (this.wordData[i].length == 0) {
  366. // this.$message.error("请选择项目申请人");
  367. // document
  368. // .querySelector("#applyParsonRadio")
  369. // .scrollIntoView({ behavior: "smooth" });
  370. // return false;
  371. // }
  372. // break;
  373. case "applyParsonName":
  374. if (cEmpty.test(this.wordData[i])) {
  375. this.$message.error("请填写申请人姓名");
  376. document
  377. .querySelector("#applyParsonName")
  378. .scrollIntoView({ behavior: "smooth" });
  379. return false;
  380. }
  381. break;
  382. case "college":
  383. if (cEmpty.test(this.wordData[i])) {
  384. this.$message.error("请选择所在学院");
  385. document
  386. .querySelector("#applyParsonName")
  387. .scrollIntoView({ behavior: "smooth" });
  388. return false;
  389. }
  390. break;
  391. case "tel":
  392. if (cEmpty.test(this.wordData[i])) {
  393. this.$message.error("请填写联系方式");
  394. document
  395. .querySelector("#applyParsonName")
  396. .scrollIntoView({ behavior: "smooth" });
  397. return false;
  398. }
  399. break;
  400. case "beginTime":
  401. if (cEmpty.test(this.wordData[i])) {
  402. this.$message.error("请选择项目起始时间");
  403. document
  404. .querySelector("#beginTime")
  405. .scrollIntoView({ behavior: "smooth" });
  406. return false;
  407. }
  408. break;
  409. case "endTime":
  410. if (cEmpty.test(this.wordData[i])) {
  411. this.$message.error("请选择计划完成时间");
  412. document
  413. .querySelector("#beginTime")
  414. .scrollIntoView({ behavior: "smooth" });
  415. return false;
  416. }
  417. break;
  418. // case "studentS":
  419. // let snum = 0;
  420. // this.wordData[i].forEach((item) => {
  421. // if (cEmpty.test(item["name"])) snum++;
  422. // for(let j in item){
  423. // if(cEmpty.test(item[j])){
  424. // snum++;
  425. // }
  426. // }
  427. // });
  428. // if (snum > 0) {
  429. // this.$message.error("学生姓名请不要留空");
  430. // document
  431. // .querySelector("#studentS")
  432. // .scrollIntoView({ behavior: "smooth" });
  433. // return false;
  434. // }
  435. // }
  436. // break;
  437. // case "teacherS":
  438. // let num = 0;
  439. // this.wordData[i].forEach((item) => {
  440. // if (cEmpty.test(item["name"])) num++;
  441. // for(let j in item){
  442. // if(cEmpty.test(item[j])){
  443. // num++;
  444. // }
  445. // }
  446. // });
  447. // if (num > 0) {
  448. // this.$message.error("老师姓名请不要留空");
  449. // document
  450. // .querySelector("#teacherS")
  451. // .scrollIntoView({ behavior: "smooth" });
  452. // return false;
  453. // }
  454. // break;
  455. // case "brief":
  456. // if (this.wordData[i].length > 300 || this.wordData[i].length == 0) {
  457. // this.$message.error("请填写项目简介,字数在300字以内");
  458. // document
  459. // .querySelector("#brief")
  460. // .scrollIntoView({ behavior: "smooth" });
  461. // return false;
  462. // }
  463. // break;
  464. case "fund":
  465. // device:"",
  466. // Material:"",
  467. // processing:"",
  468. // Collaboration:"",
  469. // APPRAISAL:"",
  470. // entery:"",
  471. // activities:"",
  472. // Transaction:"",
  473. // let mon=this.wordData.fund.device*1 + this.wordData.fund.Material*1+this.wordData.fund.processing*1+ this.wordData.fund.Collaboration*1+this.wordData.fund.APPRAISAL*1+ this.wordData.fund.match*1+this.wordData.fund.activity*1+this.wordData.fund.affair*1
  474. let mon = 0;
  475. for (let k in this.wordData.fund) {
  476. mon += this.wordData.fund[k] * 1;
  477. }
  478. // console.log(mon);
  479. if (mon == 0) {
  480. document
  481. .querySelector("#fund")
  482. .scrollIntoView({ behavior: "smooth" });
  483. return this.$message.error("请输入经费");
  484. }
  485. break;
  486. }
  487. }
  488. this.wordData["total"] =
  489. this.wordData.fund.device * 1 +
  490. this.wordData.fund.Material * 1 +
  491. this.wordData.fund.processing * 1 +
  492. this.wordData.fund.Collaboration * 1 +
  493. this.wordData.fund.APPRAISAL * 1 +
  494. this.wordData.fund.entery * 1 +
  495. this.wordData.fund.activities * 1 +
  496. this.wordData.fund.Transaction * 1;
  497. this.submitHint = true;
  498. },
  499. submitWord() {
  500. //提交
  501. // return console.log(this.wordData['total']);
  502. let typeList = {
  503. "4a4e2cfe-e1a1-11ee-81d4-00ff5c7a43f5":"CX",
  504. "56f0ad8d-e1a1-11ee-81d4-00ff5c7a43f5":"CY",
  505. "ed917c55-f51d-11ed-a3f6-509a4c5b67cf":"SJ",
  506. "1":"XM"
  507. }
  508. getProjectNo(typeList[this.wordData["radio"]]).then((result) => {
  509. let pram = {
  510. uid: this.$store.state.userInfo.userid, //用户ID
  511. pNo: result, //项目编号
  512. tid: "5e21b204-c206-11ed-a4cd-509a4c5b67cf", //特色创客空间建设项目分类ID
  513. tit: encodeURIComponent(this.wordData["projectName"]), //项目名称
  514. radio: this.wordData["radio"], //项目分组
  515. checkList: encodeURIComponent(JSON.stringify(this.wordData["checkList"])), //优先支持项目
  516. schoolRadio: encodeURIComponent(JSON.stringify(this.wordData["schoolRadio"])), //美丽校园改造项目
  517. applyParsonRadio: encodeURIComponent(JSON.stringify(this.wordData["applyParsonRadio"])), //项 目 申 请 人
  518. applyParsonName: encodeURIComponent(this.wordData["applyParsonName"]), //申请人姓名
  519. cid: this.wordData["college"], //学院ID,
  520. tel: this.wordData["tel"], //联系电话
  521. beh: this.wordData["beginTime"], //项目开始时间,
  522. planEnd: this.wordData["endTime"], //计划完成时间,
  523. cs: encodeURIComponent(JSON.stringify(this.wordData["studentS"])), //学生组,
  524. ct: encodeURIComponent(JSON.stringify(this.wordData["teacherS"])), //教师组,
  525. bf: encodeURIComponent(this.wordData["brief"]), //项目简介
  526. introduce: encodeURIComponent(JSON.stringify(this.wordData["introduce"])), //项目详细
  527. mon: encodeURIComponent(JSON.stringify(this.wordData["fund"])), //预算经费
  528. f: this.wordData["total"], //总经费
  529. apply: this.wordData["applicationDate"], //申请日期
  530. mem:this.wordData["studentS"].filter(i=>i.name!='').length + this.wordData["teacherS"].filter(i=>i.name!='').length, //项目组人数
  531. attachment:encodeURIComponent(JSON.stringify(this.wordData["attachment"])),//附件上传
  532. };
  533. this.ajax
  534. .post(this.$store.state.api + "/studentProjectWordApply", pram)
  535. .then(
  536. async (result) => {
  537. console.log(result);
  538. if (result["data"] == 1) {
  539. this.$message.success("项目提交成功");
  540. //提交项目成功,查看sessionStore是否有数据,有则删
  541. // localStorage.removeItem(`StudentProjectApplyData${this.$store.state.userInfo.userid}`);
  542. await this.ajax.post(this.$store.state.api+"/delDraft",{userid:this.$store.state.userInfo.userid,type:0})
  543. this.submitHint = false;
  544. this.$destroy();
  545. this.$router.push("/projectApplication");
  546. } else {
  547. this.$message.error("项目提交失败");
  548. this.submitHint = false
  549. }
  550. },
  551. (err) => {
  552. console.log(err);
  553. }
  554. )
  555. .catch((err) => {
  556. console.log(err);
  557. });
  558. });
  559. },
  560. saveData() {
  561. // localStorage.setItem(
  562. // `StudentProjectApplyData${this.$store.state.userInfo.userid}`,
  563. // JSON.stringify(this.wordData)
  564. // );
  565. },
  566. // 保存草稿
  567. saveDraft(){
  568. if(this.loading)return this.$message.info('请稍等...');
  569. this.loading = true;
  570. let params = {
  571. userid:this.$store.state.userInfo.userid,
  572. type:0,
  573. jsonData:encodeURIComponent(JSON.stringify(this.wordData))
  574. }
  575. this.ajax.post(this.$store.state.api + "/saveDraft",params).then(res=>{
  576. if(res.data==1){
  577. this.$message.success("保存成功")
  578. }else{
  579. this.$message.error("保存失败")
  580. }
  581. this.loading = false;
  582. })
  583. },
  584. //获取草稿
  585. getDraft(){
  586. if(this.loading)return this.$message.info('请稍等...');
  587. this.loading = true;
  588. let params = {
  589. userid:this.$store.state.userInfo.userid,
  590. type:0,
  591. }
  592. this.ajax.get(this.$store.state.api + "/getDraft",params).then(res=>{
  593. if(res.data[0].length){
  594. this.wordData = JSON.parse(res.data[0][0].json)
  595. // }else{
  596. // if (localStorage.getItem(`StudentProjectApplyData${this.$store.state.userInfo.userid}`)){
  597. // this.wordData = JSON.parse(
  598. // localStorage.getItem(`StudentProjectApplyData${this.$store.state.userInfo.userid}`)
  599. // );
  600. // }
  601. }
  602. this.loading = false;
  603. })
  604. },
  605. //上传附件
  606. fileOption2(file,index,opt){
  607. if(opt=='0'){
  608. this.checkFile(file.url)
  609. }else if(opt=='1'){
  610. if(index==0)return;
  611. this.wordData.attachment.splice(index-1,0,this.wordData.attachment.splice(index,1)[0]);
  612. }else if(opt=='2'){
  613. if(index==this.wordData.attachment.length-1)return;
  614. this.wordData.attachment.splice(index+1,0,this.wordData.attachment.splice(index,1)[0]);
  615. }else if(opt=='3'){
  616. this.updateFile = {...file,index:index}
  617. this.dialogVisibleUpdateFile = true;
  618. }else if(opt=='4'){
  619. this.$confirm("确定删除该文件?","提示",{
  620. type:"error",
  621. confirmButtonText:"确定删除",
  622. cancelButtonText:"取消",
  623. }).then(_=>{
  624. this.wordData.attachment.splice(index,1);
  625. })
  626. }
  627. },
  628. // 上传专家文件
  629. getFile2(file){
  630. this.wordData.attachment.push(file);
  631. },
  632. // 展示文件
  633. checkFile(url) {
  634. this.videoDetail = {};
  635. if (
  636. this.vedio.indexOf(
  637. url.split(".")[url.split(".").length - 1].toLocaleUpperCase()
  638. ) != -1
  639. ) {
  640. this.playerOptions.sources[0].src = url;
  641. this.videoDetail = this.playerOptions;
  642. this.showFile = true;
  643. } else {
  644. if (
  645. this.word.indexOf(
  646. url.split(".")[url.split(".").length - 1].toLocaleUpperCase()
  647. ) == -1 &&
  648. this.pdf.indexOf(
  649. url.split(".")[url.split(".").length - 1].toLocaleUpperCase()
  650. ) == -1 &&
  651. this.image.indexOf(
  652. url.split(".")[url.split(".").length - 1].toLocaleUpperCase()
  653. ) == -1
  654. ) {
  655. this.downFile(url);
  656. return;
  657. }
  658. this.showFileUrl = url;
  659. this.showFile = true;
  660. if (typeof url == "undefined") return { type: "", name: "" };
  661. let urlSplit = url.split(".");
  662. const type = urlSplit[urlSplit.length - 1];
  663. if (this.canonical.Image.test(url)) {
  664. this.Wordss = { type: type, name: "图片" };
  665. return console.log(this.Wordss);
  666. }
  667. if (this.canonical.File.test(url)) {
  668. this.Wordss = { type: type, name: "文档" };
  669. return console.log(this.Wordss);
  670. }
  671. if (this.canonical.vedio.test(url)) {
  672. this.Wordss = { type: type, name: "视频" };
  673. return console.log(this.Wordss);
  674. } else return (this.Wordss = { type: type, name: type });
  675. }
  676. },
  677. // 修改文件名称
  678. updateFileName(){
  679. if(!this.updateFile.fileName)return this.$message.error("请输入文件名称");
  680. this.wordData.attachment[this.updateFile.index].fileName = this.updateFile.fileName;
  681. this.dialogVisibleUpdateFile = false;
  682. },
  683. //下载文件
  684. downFile(f) {
  685. var credentials = {
  686. accessKeyId: "AKIATLPEDU37QV5CHLMH",
  687. secretAccessKey: "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",
  688. }; //秘钥形式的登录上传
  689. window.AWS.config.update(credentials);
  690. window.AWS.config.region = "cn-northwest-1"; //设置区域
  691. let url2 = f;
  692. let _url2 = "";
  693. if (
  694. url2.indexOf("https://view.officeapps.live.com/op/view.aspx?src=") != -1
  695. ) {
  696. _url2 = url2.split(
  697. "https://view.officeapps.live.com/op/view.aspx?src="
  698. )[1];
  699. } else {
  700. _url2 = url2;
  701. }
  702. var s3 = new window.AWS.S3({ params: { Bucket: "ccrb" } });
  703. let name = decodeURIComponent(
  704. _url2.split("https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/")[1]
  705. );
  706. var params = {
  707. Bucket: "ccrb",
  708. Key: name,
  709. };
  710. s3.getObject(params, function (err, data) {
  711. if (err) console.log(err, err.stack); // an error occurred
  712. else {
  713. let url = window.URL.createObjectURL(new Blob([data.Body]));
  714. let a = document.createElement("a");
  715. a.name = name;
  716. a.href = url;
  717. a.download = name;
  718. a.click();
  719. console.log(data);
  720. } // sxuccessful response
  721. });
  722. return;
  723. },
  724. },
  725. mounted() {
  726. this.getDraft();
  727. window.addEventListener("beforeunload", () => this.saveData());
  728. },
  729. beforeRouteLeave(to, from, next) {
  730. //判断,如果还没提交然后切换页面了,则把数据存到sessionStore里;
  731. if (!this.submitHint) this.saveData();
  732. next();
  733. },
  734. };
  735. </script>
  736. <style lang="less" scoped></style>