ProjectManagementEndProjectFile.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <template>
  2. <!-- 项目管理 项目结题附件 -->
  3. <div class="ProjectManagement5" v-loading="loading">
  4. <div class="pmInp">
  5. <beUpload
  6. @getFile="getFile"
  7. v-show="state !== 4"
  8. :navName="'上传文件'"
  9. :accept="accept"
  10. :progress="progress"
  11. ></beUpload>
  12. <el-button
  13. v-show="state == 4"
  14. style="
  15. background: #ccc !important;
  16. cursor: no-drop;
  17. color: #fff !important;
  18. border: 0;
  19. font-size: 16px;
  20. "
  21. >上传文件</el-button
  22. >
  23. </div>
  24. <el-progress
  25. v-show="progress.show"
  26. :percentage="progress.value"
  27. :format="ProgressFormat"
  28. ></el-progress>
  29. <!-- 表格部分开始 -->
  30. <el-table
  31. :data="tableData"
  32. tooltip-effect="dark"
  33. stripe
  34. class="fontSize"
  35. :header-cell-style="{ background: '#f2f2f2', color: '#000' }"
  36. >
  37. <!-- <el-table-column
  38. prop="projectTitle"
  39. label="项目名称"
  40. align="center"
  41. >
  42. <template>
  43. <span>{{ title }}</span>
  44. </template>
  45. </el-table-column> -->
  46. <el-table-column prop="fileName" label="项目结题附件" align="center">
  47. </el-table-column>
  48. <el-table-column prop="size" label="大小" align="center">
  49. </el-table-column>
  50. <el-table-column prop="uploadTime" label="时间" align="center">
  51. </el-table-column>
  52. <el-table-column prop="operation" align="center" label="操作" width="200">
  53. <template #default="scope">
  54. <div class="operations">
  55. <el-button
  56. type="primary"
  57. size="mini"
  58. @click="checkFile(scope.row.url)"
  59. style="background: #477edd"
  60. >明细查看</el-button
  61. >
  62. <el-button
  63. type="primary"
  64. v-show="state != 4"
  65. size="mini"
  66. @click="DelFile(scope.$index)"
  67. style="background: #477edd"
  68. >删除</el-button
  69. >
  70. </div>
  71. </template>
  72. </el-table-column>
  73. </el-table>
  74. <!-- 展示文档开始 -->
  75. <el-dialog
  76. title="展示文件"
  77. :visible.sync="showFile"
  78. width="80vw"
  79. top="1vh"
  80. class="addDialog showDialog"
  81. >
  82. <div class="showFileArea" style="height: 80vh">
  83. <!-- <vpdf v-if="/^\s*$/g.test(showFileUrl)&&showFileUrl.split('.')[showFileUrl.split('.').length-1]=='pdf'" :pdfUrl="showFileUrl"></vpdf> -->
  84. <div
  85. class="workd_media"
  86. style="width: 90%; height: 90%"
  87. v-if="videoDetail.sources"
  88. >
  89. <video-player
  90. class="video-player vjs-custom-skin"
  91. :playsinline="true"
  92. :options="videoDetail"
  93. @play="onPlayerPlay($event)"
  94. style="width: 90%; height: 90%; margin: 0 auto"
  95. ></video-player>
  96. </div>
  97. <vword
  98. style="width: 100%; height: 100%; overflow: auto"
  99. class="fullStyle"
  100. v-else-if="Wordss['type'] != 'pdf' && Wordss['name'] != '图片'"
  101. :pdfUrl="
  102. 'https://view.officeapps.live.com/op/view.aspx?src=' + showFileUrl
  103. "
  104. ></vword>
  105. <vpdf
  106. style="width: 100%; height: 100%; overflow: auto"
  107. class="fullStyle"
  108. :pdfUrl="showFileUrl"
  109. v-else-if="Wordss['type'] == 'pdf'"
  110. ></vpdf>
  111. <img
  112. :src="showFileUrl"
  113. alt="图片哦"
  114. v-else-if="Wordss['name'] == '图片'"
  115. style="width: auto; height: auto; max-width: 100%; max-height: 100%"
  116. />
  117. </div>
  118. </el-dialog>
  119. <!-- 分页 -->
  120. <!-- <el-pagination
  121. @current-change="handleCurrentChange"
  122. :current-page="table.currentPage"
  123. :page-size="table.packageSize"
  124. layout=" prev, pager, next"
  125. background
  126. class="paginations"
  127. :total="table.total">
  128. </el-pagination> -->
  129. <!-- 分页结束 -->
  130. </div>
  131. </template>
  132. <script>
  133. import beUpload from "@/components/tool/beUpload";
  134. import vpdf from "@/components/vpdf.vue";
  135. import vword from "@/components/vword.vue";
  136. export default {
  137. components: { beUpload, vpdf, vword },
  138. data() {
  139. return {
  140. accept: "*",
  141. // table:{ // 分页数据
  142. // total:0,
  143. // packageSize:8,
  144. // currentPage:1
  145. // },
  146. loading: false,
  147. state: 0,
  148. showFile: false,
  149. showFileType: 0,
  150. showFileUrl: "",
  151. Wordss: { type: "", name: "" },
  152. canonical: {
  153. Image:
  154. /^https?:\/\/(.+\/)+.+(\.(gif|png|jpg|jpeg|webp|svg|psd|bmp|tif))$/i,
  155. File: /^https?:\/\/(.+\/)+.+(\.(docx|xlsx|ppt|pdf))$/i,
  156. },
  157. title: "",
  158. tableData: [], //附件列表
  159. file: "",
  160. progress: {
  161. value: 0,
  162. show: false,
  163. },
  164. word: [
  165. "DOC",
  166. "DOCX",
  167. "DOCM",
  168. "DOTM",
  169. "DOTX",
  170. "PPTX",
  171. "PPSX",
  172. "PPT",
  173. "PPS",
  174. "PPTM",
  175. "POTM",
  176. "PPAM",
  177. "POTX",
  178. "PPSM",
  179. "XLSX",
  180. "XLS",
  181. ],
  182. pdf: ["PDF"],
  183. image: [
  184. "BMP",
  185. "PJP",
  186. "APNG",
  187. "PNG",
  188. "JPG",
  189. "GIF",
  190. "SVG",
  191. "JPEG",
  192. "JPG",
  193. "ICO",
  194. "PGPEG",
  195. "AVIF",
  196. ],
  197. vedio: [
  198. "AVI",
  199. "NAVI",
  200. "MPEG",
  201. "ASF",
  202. "MOV",
  203. "WMV",
  204. "3GP",
  205. "RM",
  206. "RMVB",
  207. "FLV",
  208. "F4V",
  209. "H.264",
  210. "H.265",
  211. "REAL VIDEO",
  212. "MKV",
  213. "WebM",
  214. "HDDVD",
  215. "MP4",
  216. "MPG",
  217. "M4V",
  218. "MGV",
  219. "OGV",
  220. "QTM",
  221. "STR",
  222. "AMC",
  223. "DVX",
  224. "EVO",
  225. "DAT",
  226. "OGG",
  227. "OGM",
  228. ],
  229. playerOptions: {
  230. playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度
  231. autoplay: false, //如果true,浏览器准备好时开始回放。
  232. muted: false, // 默认情况下将会消除任何音频。
  233. loop: false, // 导致视频一结束就重新开始。
  234. preload: "auto", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
  235. language: "zh-CN",
  236. aspectRatio: "16:9", // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
  237. fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
  238. sources: [
  239. {
  240. type: "video/mp4", //这里的种类支持很多种:基本视频格式、直播、流媒体等,具体可以参看git网址项目 || "video/ogg"|| "video/webm"
  241. src: "", //url地址require("../../assets/media/aaa.mp4")
  242. },
  243. ],
  244. // poster: require("../../assets/tu31.png"), //你的封面地址
  245. // poster: dataRes.imgUrl, //你的封面地址
  246. notSupportedMessage: "此视频暂无法播放,请稍后再试", //允许覆盖Video.js无法播放媒体源时显示的默认信息。
  247. controlBar: {
  248. timeDivider: true, //当前时间和持续时间的分隔符
  249. durationDisplay: true, //显示持续时间
  250. remainingTimeDisplay: false, //是否显示剩余时间功能
  251. fullscreenToggle: true, //全屏按钮
  252. },
  253. },
  254. playerO: {},
  255. videoDetail: {},
  256. };
  257. },
  258. methods: {
  259. DelFile(index) {
  260. this.$confirm("你确定要删除该文件吗?", "确定文件删除")
  261. .then((res) => {
  262. this.tableData.splice(index, 1);
  263. this.ajax
  264. .post(this.$store.state.api + "/updateEndAllFile", {
  265. uid: this.$store.state.userInfo.userid,
  266. pid: this.$route.query["pid"],
  267. file: encodeURIComponent(JSON.stringify(this.tableData)),
  268. })
  269. .then((res) => {
  270. console.log(res);
  271. if (res.data == 1) {
  272. this.$message.success("删除文件成功");
  273. } else {
  274. this.$message.error("删除文件失败");
  275. }
  276. this.getData();
  277. });
  278. })
  279. .catch((err) => {
  280. console.log("取消删除文件");
  281. });
  282. },
  283. ProgressFormat(value) {
  284. //进度条
  285. return value == 100 ? "100%" : `${value}%`;
  286. },
  287. //展示文件
  288. checkFile(url) {
  289. this.videoDetail = {};
  290. if (
  291. this.vedio.indexOf(
  292. url.split(".")[url.split(".").length - 1].toLocaleUpperCase()
  293. ) != -1
  294. ) {
  295. this.playerOptions.sources[0].src = url;
  296. this.videoDetail = this.playerOptions;
  297. this.showFile = true;
  298. } else {
  299. if (
  300. this.word.indexOf(
  301. url.split(".")[url.split(".").length - 1].toLocaleUpperCase()
  302. ) == -1 &&
  303. this.pdf.indexOf(
  304. url.split(".")[url.split(".").length - 1].toLocaleUpperCase()
  305. ) == -1 &&
  306. this.image.indexOf(
  307. url.split(".")[url.split(".").length - 1].toLocaleUpperCase()
  308. ) == -1
  309. ) {
  310. this.downFile(url);
  311. return;
  312. }
  313. this.showFileUrl = url;
  314. this.showFile = true;
  315. if (typeof url == "undefined") return { type: "", name: "" };
  316. let urlSplit = url.split(".");
  317. const type = urlSplit[urlSplit.length - 1];
  318. if (this.canonical.Image.test(url)) {
  319. this.Wordss = { type: type, name: "图片" };
  320. return console.log(this.Wordss);
  321. }
  322. if (this.canonical.File.test(url)) {
  323. this.Wordss = { type: type, name: "文档" };
  324. return console.log(this.Wordss);
  325. } else return (this.Wordss = { type: type, name: type });
  326. }
  327. },
  328. //下载文件
  329. downFile(f) {
  330. var credentials = {
  331. accessKeyId: "AKIATLPEDU37QV5CHLMH",
  332. secretAccessKey: "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",
  333. }; //秘钥形式的登录上传
  334. window.AWS.config.update(credentials);
  335. window.AWS.config.region = "cn-northwest-1"; //设置区域
  336. let url2 = f;
  337. let _url2 = "";
  338. if (
  339. url2.indexOf("https://view.officeapps.live.com/op/view.aspx?src=") != -1
  340. ) {
  341. _url2 = url2.split(
  342. "https://view.officeapps.live.com/op/view.aspx?src="
  343. )[1];
  344. } else {
  345. _url2 = url2;
  346. }
  347. var s3 = new window.AWS.S3({ params: { Bucket: "ccrb" } });
  348. let name = decodeURIComponent(
  349. _url2.split("https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/")[1]
  350. );
  351. var params = {
  352. Bucket: "ccrb",
  353. Key: name,
  354. };
  355. s3.getObject(params, function (err, data) {
  356. if (err) console.log(err, err.stack); // an error occurred
  357. else {
  358. let url = window.URL.createObjectURL(new Blob([data.Body]));
  359. let a = document.createElement("a");
  360. a.name = name;
  361. a.href = url;
  362. a.download = name;
  363. a.click();
  364. console.log(data);
  365. } // sxuccessful response
  366. });
  367. return;
  368. },
  369. getFile(val) {
  370. //上传文件
  371. this.file = val;
  372. let oldData = [];
  373. if (this.tableData != null) {
  374. this.tableData.forEach((item) => oldData.push(item));
  375. oldData.push(val);
  376. } else {
  377. oldData.push(val);
  378. }
  379. let param = {
  380. uid: this.$store.state.userInfo.userid,
  381. cid: this.$route.query["pid"],
  382. projectFile: encodeURIComponent(JSON.stringify(oldData)),
  383. };
  384. this.ajax
  385. .post(this.$store.state.api + "/AddProjectManageFile", param)
  386. .then(
  387. (res) => {
  388. if (res.data == 1) {
  389. this.getData();
  390. this.$message.success("上传成功");
  391. this.progress.show = false;
  392. } else {
  393. this.$message.error("上传失败");
  394. }
  395. },
  396. (err) => {
  397. console.log(err);
  398. }
  399. );
  400. },
  401. // handleCurrentChange(val) { //当页数发生改变的时候调用获取列表数据请求
  402. // // console.log(`当前页: ${val}`);
  403. // this.table.currentPage=val
  404. // this.getData()
  405. // },
  406. getData() {
  407. //获取基础信息
  408. if(this.loading)return;
  409. this.loading = true;
  410. let param = {
  411. uid: this.$store.state.userInfo.userid,
  412. pid: this.$route.query["pid"],
  413. };
  414. // console.log(param);
  415. this.ajax
  416. .get(this.$store.state.api + "/SelectProjectManageFile", param)
  417. .then(
  418. (res) => {
  419. let data = res.data[0][0];
  420. console.log(data);
  421. let file = "";
  422. this.state = data.isupload;
  423. if (data["endFile"] != null && data["endFile"] != "") {
  424. console.log(111);
  425. file = JSON.parse(data["endFile"]);
  426. this.tableData = file;
  427. }
  428. this.loading = false;
  429. },
  430. (err) => {
  431. console.log(err);
  432. }
  433. );
  434. },
  435. // content(){
  436. // this.$router.push('/ProjectManagement1')
  437. // },
  438. // remark(){
  439. // this.$router.push('/ProjectManagement2')
  440. // },
  441. // remark2(){
  442. // this.$router.push('/ProjectManagement3')
  443. // },
  444. // remark4(){
  445. // this.$router.push('/ProjectManagement4')
  446. // },
  447. // remark5(){
  448. // this.$router.push('/ProjectManagement5')
  449. // },
  450. // backBtn2(){
  451. // this.$router.push('/ProjectManagement1')
  452. // },
  453. // detail(){
  454. // },
  455. back() {
  456. this.$router.push("/ProjectManagement");
  457. },
  458. onPlayerPlay() {},
  459. },
  460. mounted(){
  461. this.getData();
  462. }
  463. };
  464. </script>
  465. <style lang="less">
  466. .ProjectManagement5 {
  467. .pagination {
  468. float: right;
  469. margin: 20px 55px 10px;
  470. }
  471. .addDialog {
  472. font-size: 18px;
  473. .el-dialog {
  474. border-radius: 5px;
  475. overflow: hidden;
  476. }
  477. .deleteContent {
  478. width: 100%;
  479. margin: 30px 0;
  480. font-size: 22px;
  481. color: #000;
  482. }
  483. .addDialogLogo {
  484. width: 60px;
  485. height: 30px;
  486. display: flex;
  487. justify-content: center;
  488. line-height: 30px;
  489. border-radius: 5px;
  490. background: #f2f2f2;
  491. position: absolute;
  492. left: 20px;
  493. top: 15px;
  494. }
  495. .el-dialog__header {
  496. display: flex;
  497. justify-content: center;
  498. background: #32455b;
  499. }
  500. .el-dialog__title {
  501. color: #fff;
  502. display: flex;
  503. justify-content: center;
  504. font-size: 18px;
  505. position: relative;
  506. top: -2px;
  507. }
  508. .addDialogMid {
  509. box-sizing: border-box;
  510. padding: 0 60px 0 10px;
  511. .addDialogTit {
  512. display: flex;
  513. span {
  514. width: 80px;
  515. font-size: 16px;
  516. line-height: 40px;
  517. text-align: left;
  518. }
  519. }
  520. .addDialogTit1 {
  521. display: flex;
  522. justify-content: space-between;
  523. margin-bottom: 15px;
  524. }
  525. .addDialogTit2 {
  526. margin-top: 10px;
  527. font-size: 16px;
  528. color: #000;
  529. text-indent: 2em;
  530. }
  531. .addDialogCon {
  532. margin-top: 20px;
  533. }
  534. }
  535. .dialog-footer {
  536. display: flex;
  537. justify-content: center;
  538. box-sizing: border-box;
  539. // .btn5 {
  540. // font-size: 16px;
  541. // }
  542. }
  543. }
  544. .pm5footer {
  545. float: right;
  546. margin-top: 30px;
  547. .backBtn {
  548. background: #169bd5;
  549. float: right;
  550. width: 100px;
  551. }
  552. }
  553. .pm1Tit {
  554. display: flex;
  555. margin-left: 20px;
  556. div {
  557. width: 130px;
  558. cursor: pointer;
  559. font-weight: 550;
  560. }
  561. .pr1TitBass {
  562. height: 2px;
  563. width: 100%;
  564. background: #3d67bc;
  565. }
  566. }
  567. .pmInp {
  568. width: 100%;
  569. margin: 10px 0 10px 0;
  570. display: flex;
  571. justify-content: flex-end;
  572. // .btn{
  573. // width: 120px;
  574. // font-size: 16px;
  575. // border: none;
  576. // // margin-left: 10px;
  577. // }
  578. }
  579. }
  580. </style>