e15bd9d5eea12e497cb63a2b283350022c466174.svn-base 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <div>
  3. <el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" @close="dialogClose" :append-to-body="true"
  4. class="jqmm">
  5. <el-row style="text-align:right;">
  6. <el-button :type="!addPicPanel ? 'primary' : 'danger'"
  7. :icon="!addPicPanel ? 'el-icon-circle-plus-outline':'el-icon-circle-close-outline'"
  8. @click="addPic" v-if="openType==undefined || openType"
  9. >{{ !addPicPanel ? "添加" : "取消" }}
  10. </el-button>
  11. </el-row>
  12. <el-row v-if="addPicPanel" style="text-align:center;">
  13. <upload ref="uploadFile" :url="`/pdcApi/file/insert?bizId=`" @uploadOver="removeNewSupervision"></upload>
  14. <el-button type="primary" @click="onSubmit">保 存</el-button>
  15. </el-row>
  16. <el-row>
  17. <el-tabs style="overflow-y: auto;margin:5px;">
  18. <el-tab-pane :label="picturetabName" style="height: 350px;">
  19. <el-carousel :interval="4000" height="350px" id="imgView">
  20. <el-carousel-item v-for="(item,index) in pictureArray" :key="index">
  21. <a :href="`${item.filePath}`" target="_blank" v-if="item.filePath.indexOf('http')>-1">
  22. <img style="height:100%;" :src="`${item.filePath}`">
  23. </a>
  24. <a :href="`${hostUrl}/${item.filePath}`" target="_blank" v-if="item.filePath.indexOf('http')<0">
  25. <img style="height:100%;width: 100%;" :src="`${hostUrl}/${item.filePath}`">
  26. </a>
  27. <div class="image-preview-action">
  28. <i @click="removeFile(item.id)" class="el-icon-delete"></i>
  29. </div>
  30. </el-carousel-item>
  31. <p v-if="pictureArray.length==0" class="noPic">暂无图片信息</p>
  32. </el-carousel>
  33. </el-tab-pane>
  34. <el-tab-pane :label="videotabName">
  35. <el-carousel :interval="4000" height="350px">
  36. <el-carousel-item v-for="(item,index) in videoArray" :key="index">
  37. <video-player
  38. class="vjs-custom-skin"
  39. ref="videoPlayer"
  40. :options="item"
  41. :playsinline="true"
  42. ></video-player>
  43. <div class="image-preview-action">
  44. <i @click="removeFile(item.id)" class="el-icon-delete"></i>
  45. </div>
  46. </el-carousel-item>
  47. <el-carousel-item v-if="videoArray.length==0">
  48. <p class="noPic">暂无视频信息</p>
  49. </el-carousel-item>
  50. </el-carousel>
  51. </el-tab-pane>
  52. <el-tab-pane :label="audiotabName">
  53. <el-table border :data="audioArray" style="width: 100%;margin: 0 auto;" :height="testHeight">
  54. <el-table-column header-align="center" align="center" label="音频">
  55. <template slot-scope="scope">
  56. <elaudio
  57. style="margin-left:15%;width:100px;height:30px;"
  58. :theUrl="`${hostUrl}/${scope.row.filePath}`"
  59. ></elaudio>
  60. <!-- <span>{{scope.row.fileTitle}}</span> -->
  61. </template>
  62. </el-table-column>
  63. <el-table-column header-align="center" align="center" label="操作">
  64. <template slot-scope="scope">
  65. <el-button
  66. size="mini"
  67. @click="removeFile(scope.row.id,scope.$index)"
  68. type="danger"
  69. >删除
  70. </el-button>
  71. </template>
  72. </el-table-column>
  73. </el-table>
  74. </el-tab-pane>
  75. <el-tab-pane :label="filetabName">
  76. <el-table border :data="fileArray" style="width: 100%;margin: 0 auto;" :height="testHeight">
  77. <el-table-column header-align="center" align="center" label="文档">
  78. <template slot-scope="scope">
  79. <p>
  80. <a :href="`${hostUrl}/${scope.row.filePath}`" target="_blank"
  81. rel="noopener noreferrer">
  82. {{scope.row.fileName}}
  83. </a>
  84. </p>
  85. </template>
  86. </el-table-column>
  87. <el-table-column header-align="center" align="center" label="操作">
  88. <template slot-scope="scope">
  89. <el-button
  90. size="mini"
  91. @click="removeFile(scope.row.id,scope.$index)"
  92. type="danger"
  93. >删除
  94. </el-button>
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. </el-tab-pane>
  99. </el-tabs>
  100. </el-row>
  101. </el-dialog>
  102. </div>
  103. </template>
  104. <script>
  105. import request from '../../utils/gw_ajax_request'
  106. import upload from '../../widgets/uploadFilePblmConfirm'
  107. import {deleteFileById} from "../../api/duChaAPI.js";
  108. import {hostUrl} from "@util/global_variable.js";
  109. import elaudio from "../../widgets/elAudioShort.vue";
  110. import Viewer from 'viewerjs';
  111. import 'viewerjs/dist/viewer.css';
  112. export default {
  113. name: "theRecentAppearance",
  114. props: ['jqmmShow', 'currentObjectId', 'dialogTitle', 'currentObjectName','openType'],
  115. components: {
  116. upload,
  117. elaudio
  118. },
  119. data() {
  120. return {
  121. bizType:"confirm_media",
  122. testHeight:350,
  123. dialogFormVisible: true,
  124. addPicPanel: false,
  125. pictureArray: [],
  126. videoArray: [],
  127. videoArray: [],
  128. audioArray: [],
  129. fileArray:[],
  130. picturetabName: "",
  131. videotabName: "",
  132. audiotabName: "",
  133. filetabName: "",
  134. }
  135. },
  136. computed: {
  137. hostUrl() {
  138. return hostUrl
  139. }
  140. },
  141. mounted() {
  142. this.getPicArray();
  143. },
  144. methods: {
  145. dialogClose() {
  146. this.$emit('jqmmDialogClose');
  147. },
  148. addPic() {
  149. this.addPicPanel = !this.addPicPanel;
  150. },
  151. getPicArray() {
  152. var params = {
  153. bizId:this.currentObjectId,
  154. bizType:this.bizType
  155. }
  156. var _this = this;
  157. request.post(`/file/findAllFile`,params).then(res => {
  158. if (res.success) {
  159. this.pictureArray = [];
  160. this.videoArray = [];
  161. this.audioArray = [];
  162. this.fileArray = [];
  163. res.data.forEach(item => {
  164. if (
  165. item.fileExt == "jpg" ||
  166. item.fileExt == "JPG" ||
  167. item.fileExt == "png" ||
  168. item.fileExt == "PNG" ||
  169. item.fileExt == "JPEG" ||
  170. item.fileExt == "jpeg"
  171. ) {
  172. this.pictureArray.push(item);
  173. } else if (item.fileExt == "mp4" || item.fileExt == "MP4") {
  174. this.videoArray.push({
  175. height: "320",
  176. width: "500",
  177. id: item.id,
  178. bizId: item.bizId,
  179. autoplay: false,
  180. muted: true,
  181. language: "en",
  182. playbackRates: [0.7, 1.0, 1.5, 2.0],
  183. sources: [
  184. {
  185. type: "video/mp4",
  186. src: this.hostUrl + item.filePath
  187. }
  188. ]
  189. });
  190. }else if (
  191. item.fileExt == "mp3" ||
  192. item.fileExt == "MP3" ||
  193. item.fileExt == "m4a"
  194. ) {
  195. this.audioArray.push(item);
  196. }else{
  197. this.fileArray.push(item);
  198. }
  199. });
  200. _this.$nextTick(function(){
  201. var ViewerDom = document.getElementById('imgView');
  202. var viewer = new Viewer(ViewerDom, {})
  203. });
  204. this.picturetabName = "图片资料(" + this.pictureArray.length + ")";
  205. this.videotabName = "视频资料(" + this.videoArray.length + ")";
  206. this.audiotabName = "音频资料(" + this.audioArray.length + ")";
  207. this.filetabName = "其他资料(" + this.fileArray.length + ")";
  208. }
  209. })
  210. },
  211. onSubmit() {
  212. this.submitUpload();
  213. },
  214. // 文件上传
  215. submitUpload() {
  216. if (this.$refs.uploadFile.submitUpload(this.currentObjectId,this.bizType)) {
  217. this.removeNewSupervision();
  218. }
  219. },
  220. removeNewSupervision(arg) {
  221. if (arg) {
  222. this.$message.success('上传成功');
  223. this.addPicPanel = false;
  224. this.getPicArray();
  225. // this.$emit('jqmmDialogClose');
  226. // this.pictureArray = [];
  227. this.$refs.uploadFile.init();
  228. } else {
  229. this.$message.error('上传有误');
  230. }
  231. },
  232. // 删除多媒体文件
  233. removeFile(id, index) {
  234. this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
  235. confirmButtonText: "确定",
  236. cancelButtonText: "返回",
  237. type: "warning"
  238. }).then(
  239. res => {
  240. if (res === "confirm") {
  241. deleteFileById(id, localStorage.getItem("userid")).then(res => {
  242. if (res.success) {
  243. this.getPicArray();
  244. } else {
  245. this.$message.error(res.message);
  246. }
  247. });
  248. }
  249. }
  250. );
  251. },
  252. },
  253. }
  254. </script>
  255. <style lang="scss">
  256. .noPic{
  257. text-align: center;
  258. }
  259. .image-preview-action {
  260. position: absolute;
  261. top: 0;
  262. left: 0;
  263. width: 100%;
  264. height: 30px;
  265. text-align: center;
  266. opacity: 0;
  267. font-size: 20px;
  268. background-color: rgba(0, 0, 0, 0.5);
  269. transition: opacity 0.3s;
  270. cursor: pointer;
  271. line-height: 30px;
  272. }
  273. .image-preview-action .el-icon-delete {
  274. font-size: 25px;
  275. }
  276. .image-preview-action:hover {
  277. opacity: 1;
  278. }
  279. .jqmm {
  280. .image-preview-action:hover {
  281. opacity: 1;
  282. }
  283. .noPic {
  284. width: 100%;
  285. height: 100%;
  286. text-align: center;
  287. line-height: 300px;
  288. font-size: 17px;
  289. font-weight: bold;
  290. }
  291. .jqmm span.el-dialog__title {
  292. font-weight: bold;
  293. }
  294. /*.el-carousel.el-carousel--horizontal {*/
  295. /*text-align: center;*/
  296. /*}*/
  297. .el-dialog__body {
  298. padding: 0 30px 20px;
  299. }
  300. }
  301. </style>