cc7a6a41f6df5cce64f6a32ea7ccb2d0e24efb5e.svn-base 11 KB

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