c5b0a78e0dcddc48cd7e3314ae4b3f885efd6288.svn-base 10 KB

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