edb5eaa4da18ad3fee535dafb22b1bbe1dc6b0c7.svn-base 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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-row>
  15. <el-row>
  16. <el-tabs style="overflow-y: auto;margin:5px;" :style="{'max-height':testHeight-40+'px',}">
  17. <el-tab-pane :label="picturetabName" style="height: 350px;">
  18. <el-carousel :interval="4000" height="350px" id="imgView">
  19. <el-carousel-item v-for="(item,index) in pictureArray" :key="index">
  20. <a :href="`${item.filePath}`" target="_blank" v-if="item.filePath.indexOf('http')>-1">
  21. <img style="height:100%;" :src="`${item.filePath}`">
  22. </a>
  23. <a :href="`${hostUrl}/${item.filePath}`" target="_blank" v-if="item.filePath.indexOf('http')<0">
  24. <img style="height:100%;" :src="`${hostUrl}/${item.filePath}`">
  25. </a>
  26. <div class="image-preview-action">
  27. <i @click="removeFile(item.id)" class="el-icon-delete"></i>
  28. </div>
  29. </el-carousel-item>
  30. <p v-if="pictureArray.length==0" class="noPic">暂无图片信息</p>
  31. </el-carousel>
  32. </el-tab-pane>
  33. <el-tab-pane :label="videotabName">
  34. <el-carousel :interval="4000" height="350px">
  35. <el-carousel-item v-for="(item,index) in videoArray" :key="index">
  36. <video-player
  37. class="vjs-custom-skin"
  38. ref="videoPlayer"
  39. :options="item"
  40. :playsinline="true"
  41. ></video-player>
  42. <div>
  43. <el-button @click="removeFile(item.id)" type="danger" icon="el-icon-delete" circle></el-button>
  44. </div>
  45. </el-carousel-item>
  46. <el-carousel-item v-if="videoArray.length==0">
  47. <p class="noPic">暂无视频信息</p>
  48. </el-carousel-item>
  49. </el-carousel>
  50. </el-tab-pane>
  51. </el-tabs>
  52. </el-row>
  53. <div slot="footer" class="dialog-footer">
  54. <el-button @click="dialogFormVisible = false">取 消</el-button>
  55. <el-button type="primary" @click="onSubmit" v-if="openType==true || openType==undefined || openType==null">保 存</el-button>
  56. </div>
  57. </el-dialog>
  58. </div>
  59. </template>
  60. <script>
  61. import request from '../../utils/gw_ajax_request'
  62. import upload from '../../widgets/uploadFile'
  63. import {deleteFileById} from "../../api/duChaAPI.js";
  64. import {hostUrl} from "@util/global_variable.js";
  65. import Viewer from 'viewerjs';
  66. import 'viewerjs/dist/viewer.css';
  67. export default {
  68. name: "theRecentAppearance",
  69. props: ['jqmmShow', 'jqmmEngId', 'dialogTitle', 'currentObjectName','openType'],
  70. components: {
  71. upload
  72. },
  73. data() {
  74. return {
  75. dialogFormVisible: true,
  76. addPicPanel: false,
  77. pictureArray: [],
  78. videoArray: [],
  79. picturetabName: [],
  80. videotabName: []
  81. }
  82. },
  83. computed: {
  84. hostUrl() {
  85. return hostUrl
  86. }
  87. },
  88. mounted() {
  89. this.getPicArray();
  90. },
  91. methods: {
  92. dialogClose() {
  93. this.$emit('jqmmDialogClose');
  94. },
  95. addPic() {
  96. this.addPicPanel = !this.addPicPanel;
  97. },
  98. getPicArray() {
  99. var _this = this;
  100. request.post(`/file/findFileByBiz?bizId=${this.jqmmEngId}`).then(res => {
  101. if (res.success) {
  102. this.pictureArray = [];
  103. this.videoArray = [];
  104. res.data.forEach(item => {
  105. if (
  106. item.fileExt == "jpg" ||
  107. item.fileExt == "JPG" ||
  108. item.fileExt == "png" ||
  109. item.fileExt == "PNG" ||
  110. item.fileExt == "JPEG" ||
  111. item.fileExt == "jpeg"
  112. ) {
  113. this.pictureArray.push(item);
  114. } else if (item.fileExt == "mp4" || item.fileExt == "MP4") {
  115. this.videoArray.push({
  116. height: "320",
  117. width: "500",
  118. id: item.id,
  119. bizId: item.bizId,
  120. autoplay: false,
  121. muted: true,
  122. language: "en",
  123. playbackRates: [0.7, 1.0, 1.5, 2.0],
  124. sources: [
  125. {
  126. type: "video/mp4",
  127. src: this.hostUrl + item.filePath
  128. }
  129. ]
  130. });
  131. }
  132. });
  133. _this.$nextTick(function(){
  134. var ViewerDom = document.getElementById('imgView');
  135. var viewer = new Viewer(ViewerDom, {})
  136. });
  137. this.picturetabName = "图片资料(" + this.pictureArray.length + ")";
  138. this.videotabName = "视频资料(" + this.videoArray.length + ")";
  139. }
  140. })
  141. },
  142. onSubmit() {
  143. this.submitUpload();
  144. },
  145. // 文件上传
  146. submitUpload() {
  147. if (this.$refs.uploadFile.submitUpload(this.jqmmEngId)) {
  148. this.removeNewSupervision();
  149. }
  150. },
  151. removeNewSupervision(arg) {
  152. if (arg) {
  153. this.$message.success('上传成功');
  154. this.addPicPanel = false;
  155. this.getPicArray();
  156. // this.$emit('jqmmDialogClose');
  157. // this.pictureArray = [];
  158. this.$refs.uploadFile.init();
  159. } else {
  160. this.$message.error('上传有误');
  161. }
  162. },
  163. // 删除多媒体文件
  164. removeFile(id, index) {
  165. this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
  166. confirmButtonText: "确定",
  167. cancelButtonText: "返回",
  168. type: "warning"
  169. }).then(
  170. res => {
  171. if (res === "confirm") {
  172. deleteFileById(id, localStorage.getItem("userid")).then(res => {
  173. if (res.success) {
  174. this.getPicArray();
  175. } else {
  176. this.$message.error(res.message);
  177. }
  178. });
  179. }
  180. }
  181. );
  182. },
  183. },
  184. }
  185. </script>
  186. <style lang="scss">
  187. .jqmm {
  188. .image-preview-action {
  189. position: absolute;
  190. top: 0;
  191. left: 0;
  192. width: 100%;
  193. height: 30px;
  194. text-align: center;
  195. opacity: 0;
  196. font-size: 20px;
  197. background-color: rgba(0, 0, 0, 0.5);
  198. transition: opacity 0.3s;
  199. cursor: pointer;
  200. line-height: 30px;
  201. }
  202. .image-preview-action .el-icon-delete {
  203. font-size: 25px;
  204. }
  205. .image-preview-action:hover {
  206. opacity: 1;
  207. }
  208. .noPic {
  209. width: 100%;
  210. height: 100%;
  211. text-align: center;
  212. line-height: 300px;
  213. font-size: 17px;
  214. font-weight: bold;
  215. }
  216. .jqmm span.el-dialog__title {
  217. font-weight: bold;
  218. }
  219. /*.el-carousel.el-carousel--horizontal {*/
  220. /*text-align: center;*/
  221. /*}*/
  222. .el-dialog__body {
  223. padding: 0 30px 20px;
  224. }
  225. }
  226. </style>