804a19878843e461f43a5d15cb8d02ae9e5984cf.svn-base 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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/nowUploadFile'
  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','type'],
  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. orgId(){
  88. return localStorage.getItem('currentOrgId') ? localStorage.getItem('currentOrgId') : ''
  89. },
  90. },
  91. mounted() {
  92. this.getPicArray();
  93. },
  94. methods: {
  95. dialogClose() {
  96. this.$emit('jqmmDialogClose');
  97. },
  98. addPic() {
  99. this.addPicPanel = !this.addPicPanel;
  100. },
  101. getPicArray() {
  102. var _this = this;
  103. request.post(`/file/findFileByBiz?bizId=${this.jqmmEngId}${this.orgId}`).then(res => {
  104. if (res.success) {
  105. this.pictureArray = [];
  106. this.videoArray = [];
  107. res.data.forEach(item => {
  108. if (
  109. item.fileExt == "jpg" ||
  110. item.fileExt == "JPG" ||
  111. item.fileExt == "png" ||
  112. item.fileExt == "PNG" ||
  113. item.fileExt == "JPEG" ||
  114. item.fileExt == "jpeg"
  115. ) {
  116. this.pictureArray.push(item);
  117. } else if (item.fileExt == "mp4" || item.fileExt == "MP4") {
  118. this.videoArray.push({
  119. height: "320",
  120. width: "500",
  121. id: item.id,
  122. bizId: item.bizId,
  123. autoplay: false,
  124. muted: true,
  125. language: "en",
  126. playbackRates: [0.7, 1.0, 1.5, 2.0],
  127. sources: [
  128. {
  129. type: "video/mp4",
  130. src: this.hostUrl + item.filePath
  131. }
  132. ]
  133. });
  134. }
  135. });
  136. _this.$nextTick(function(){
  137. var ViewerDom = document.getElementById('imgView');
  138. var viewer = new Viewer(ViewerDom, {})
  139. });
  140. this.picturetabName = "图片资料(" + this.pictureArray.length + ")";
  141. this.videotabName = "视频资料(" + this.videoArray.length + ")";
  142. }
  143. })
  144. },
  145. onSubmit() {
  146. this.submitUpload();
  147. },
  148. // 文件上传
  149. submitUpload() {
  150. if (this.$refs.uploadFile.submitUpload(this.jqmmEngId+this.orgId)) {
  151. this.removeNewSupervision();
  152. }
  153. },
  154. removeNewSupervision(arg) {
  155. if (arg) {
  156. this.$message.success('上传成功');
  157. this.addPicPanel = false;
  158. this.getPicArray();
  159. // this.$emit('jqmmDialogClose');
  160. // this.pictureArray = [];
  161. this.$refs.uploadFile.init();
  162. } else {
  163. this.$message.error('上传有误');
  164. }
  165. },
  166. // 删除多媒体文件
  167. removeFile(id, index) {
  168. this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
  169. confirmButtonText: "确定",
  170. cancelButtonText: "返回",
  171. type: "warning"
  172. }).then(
  173. res => {
  174. if (res === "confirm") {
  175. deleteFileById(id, localStorage.getItem("userid")).then(res => {
  176. if (res.success) {
  177. this.getPicArray();
  178. } else {
  179. this.$message.error(res.message);
  180. }
  181. });
  182. }
  183. }
  184. );
  185. },
  186. },
  187. }
  188. </script>
  189. <style lang="scss">
  190. .jqmm {
  191. .image-preview-action {
  192. position: absolute;
  193. top: 0;
  194. left: 0;
  195. width: 100%;
  196. height: 30px;
  197. text-align: center;
  198. opacity: 0;
  199. font-size: 20px;
  200. background-color: rgba(0, 0, 0, 0.5);
  201. transition: opacity 0.3s;
  202. cursor: pointer;
  203. line-height: 30px;
  204. }
  205. .image-preview-action .el-icon-delete {
  206. font-size: 25px;
  207. }
  208. .image-preview-action:hover {
  209. opacity: 1;
  210. }
  211. .noPic {
  212. width: 100%;
  213. height: 100%;
  214. text-align: center;
  215. line-height: 300px;
  216. font-size: 17px;
  217. font-weight: bold;
  218. }
  219. .jqmm span.el-dialog__title {
  220. font-weight: bold;
  221. }
  222. /*.el-carousel.el-carousel--horizontal {*/
  223. /*text-align: center;*/
  224. /*}*/
  225. .el-dialog__body {
  226. padding: 0 30px 20px;
  227. }
  228. }
  229. </style>