e6ef6b5717dc7f45dd5c1a746dc8847bd0edca4e.svn-base 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <div>
  3. <el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" @close="dialogClose" :append-to-body="true" 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"
  8. >{{!addPicPanel?"添加照片":"取消"}}</el-button>
  9. </el-row>
  10. <el-row v-if="addPicPanel" style="text-align:center;">
  11. <upload ref="uploadFile" type="recentPic" :url="`/pdcApi/file/insert?bizId=`" @uploadOver="removeNewSupervision"></upload>
  12. </el-row>
  13. <el-row>
  14. <el-carousel :interval="4000" height="350px" id="imgView">
  15. <el-carousel-item v-for="(item,index) in pictureArray" :key="index">
  16. <a :href="`${hostUrl}/${item.filePath}`" target="_blank">
  17. <img style="height:100%;" :src="`${hostUrl}/${item.filePath}`">
  18. </a>
  19. <div class="image-preview-action">
  20. <i @click="removeFile(item.id)" class="el-icon-delete"></i>
  21. </div>
  22. </el-carousel-item>
  23. <p v-if="pictureArray.length==0" class="noPic">暂无图片信息</p>
  24. </el-carousel>
  25. </el-row>
  26. <div slot="footer" class="dialog-footer">
  27. <el-button @click="dialogFormVisible = false">取 消</el-button>
  28. <el-button type="primary" @click="onSubmit">保 存</el-button>
  29. </div>
  30. </el-dialog>
  31. </div>
  32. </template>
  33. <script>
  34. import request from '@util/gw_ajax_request'
  35. import upload from '@widget/uploadFileWithType'
  36. import { deleteFileById } from "@api/duChaAPI.js";
  37. import Viewer from 'viewerjs';
  38. import 'viewerjs/dist/viewer.css';
  39. export default {
  40. name: "theRecentAppearance",
  41. props: ['jqmmShow','jqmmEngId','dialogTitle','currentObjectName','type'],
  42. components: {
  43. upload
  44. },
  45. data (){
  46. return {
  47. dialogFormVisible:true,
  48. addPicPanel:false,
  49. pictureArray: [],
  50. }
  51. },
  52. computed:{
  53. hostUrl(){
  54. return window.location.href.indexOf('localhost') > -1 || window.location.href.indexOf('10.1.102.136') > -1 ? 'http://10.1.102.136:8100' : `${window.location.protocol}//${window.location.hostname}`
  55. }
  56. },
  57. mounted(){
  58. this.getPicArray();
  59. },
  60. methods:{
  61. dialogClose(){
  62. this.$emit('jqmmDialogClose');
  63. },
  64. addPic() {
  65. this.addPicPanel = !this.addPicPanel;
  66. },
  67. getPicArray(){
  68. let params = {
  69. bizId: this.jqmmEngId,
  70. bizType: "recentPic"
  71. }
  72. var _this = this;
  73. request.post(`/file/findPageInfo`,params).then(res =>{
  74. if(res.success) {
  75. this.pictureArray = res.data.list;
  76. _this.$nextTick(function(){
  77. var ViewerDom = document.getElementById('imgView');
  78. var viewer = new Viewer(ViewerDom, {})
  79. });
  80. }
  81. })
  82. },
  83. onSubmit(){
  84. this.submitUpload();
  85. },
  86. // 文件上传
  87. submitUpload() {
  88. if (this.$refs.uploadFile.submitUpload(this.jqmmEngId,this.type)) {
  89. this.removeNewSupervision();
  90. }
  91. },
  92. removeNewSupervision(arg){
  93. if (arg) {
  94. this.$message.success('上传成功');
  95. this.getPicArray();
  96. // this.$emit('jqmmDialogClose');
  97. // this.pictureArray = [];
  98. this.$refs.uploadFile.init();
  99. } else{
  100. this.$message.error('上传有误');
  101. }
  102. },
  103. // 删除图片文件
  104. removeFile(id, index) {
  105. this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
  106. confirmButtonText: "确定",
  107. cancelButtonText: "返回",
  108. type: "warning"
  109. }).then(
  110. res => {
  111. if (res === "confirm") {
  112. deleteFileById(id, localStorage.getItem("userid")).then(res => {
  113. if (res.success) {
  114. this.getPicArray();
  115. } else {
  116. this.$message.error(res.message);
  117. }
  118. });
  119. }
  120. }
  121. );
  122. },
  123. },
  124. }
  125. </script>
  126. <style>
  127. .image-preview-action{
  128. position: absolute;
  129. top: 0;
  130. left: 0;
  131. width: 100%;
  132. height: 30px;
  133. text-align: center;
  134. opacity: 0;
  135. font-size: 20px;
  136. background-color: rgba(0, 0, 0, 0.5);
  137. transition: opacity 0.3s;
  138. cursor: pointer;
  139. line-height: 30px;
  140. }
  141. .image-preview-action .el-icon-delete {
  142. font-size: 25px;
  143. }
  144. .image-preview-action:hover{
  145. opacity: 1;
  146. }
  147. .noPic{
  148. width: 100%;
  149. height: 100%;
  150. text-align: center;
  151. line-height: 300px;
  152. font-size: 17px;
  153. font-weight: bold;
  154. }
  155. .jqmm span.el-dialog__title {
  156. font-weight: bold;
  157. }
  158. </style>