89eb4e19a540f63a0553d5ce8be83a28c96368a2.svn-base 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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="type" :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 { hostUrl } from "@util/global_variable.js";
  38. import Viewer from 'viewerjs';
  39. import 'viewerjs/dist/viewer.css';
  40. export default {
  41. name: "theRecentAppearance",
  42. props: ['jqmmShow','jqmmEngId','dialogTitle','currentObjectName','type'],
  43. components: {
  44. upload
  45. },
  46. data (){
  47. return {
  48. dialogFormVisible:true,
  49. addPicPanel:false,
  50. pictureArray: [],
  51. }
  52. },
  53. computed:{
  54. hostUrl(){
  55. return hostUrl
  56. }
  57. },
  58. mounted(){
  59. this.getPicArray();
  60. },
  61. methods:{
  62. dialogClose(){
  63. this.$emit('jqmmDialogClose');
  64. },
  65. addPic() {
  66. this.addPicPanel = !this.addPicPanel;
  67. },
  68. getPicArray(){
  69. let params = {
  70. bizId: this.jqmmEngId,
  71. bizType: this.type
  72. }
  73. var _this = this;
  74. request.post(`/file/findPageInfo`,params).then(res =>{
  75. if(res.success) {
  76. this.pictureArray = res.data.list;
  77. _this.$nextTick(function(){
  78. var ViewerDom = document.getElementById('imgView');
  79. var viewer = new Viewer(ViewerDom, {})
  80. });
  81. }
  82. })
  83. },
  84. onSubmit(){
  85. this.submitUpload();
  86. },
  87. // 文件上传
  88. submitUpload() {
  89. if (this.$refs.uploadFile.submitUpload(this.jqmmEngId,this.type)) {
  90. this.removeNewSupervision();
  91. }
  92. },
  93. removeNewSupervision(arg){
  94. if (arg) {
  95. this.$message.success('上传成功');
  96. this.getPicArray();
  97. // this.$emit('jqmmDialogClose');
  98. // this.pictureArray = [];
  99. this.$refs.uploadFile.init();
  100. } else{
  101. this.$message.error('上传有误');
  102. }
  103. },
  104. // 删除图片文件
  105. removeFile(id, index) {
  106. this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
  107. confirmButtonText: "确定",
  108. cancelButtonText: "返回",
  109. type: "warning"
  110. }).then(
  111. res => {
  112. if (res === "confirm") {
  113. deleteFileById(id, localStorage.getItem("userid")).then(res => {
  114. if (res.success) {
  115. this.getPicArray();
  116. } else {
  117. this.$message.error(res.message);
  118. }
  119. });
  120. }
  121. }
  122. );
  123. },
  124. },
  125. }
  126. </script>
  127. <style>
  128. .image-preview-action{
  129. position: absolute;
  130. top: 0;
  131. left: 0;
  132. width: 100%;
  133. height: 30px;
  134. text-align: center;
  135. opacity: 0;
  136. font-size: 20px;
  137. background-color: rgba(0, 0, 0, 0.5);
  138. transition: opacity 0.3s;
  139. cursor: pointer;
  140. line-height: 30px;
  141. }
  142. .image-preview-action .el-icon-delete {
  143. font-size: 25px;
  144. }
  145. .image-preview-action:hover{
  146. opacity: 1;
  147. }
  148. .noPic{
  149. width: 100%;
  150. height: 100%;
  151. text-align: center;
  152. line-height: 300px;
  153. font-size: 17px;
  154. font-weight: bold;
  155. }
  156. .jqmm span.el-dialog__title {
  157. font-weight: bold;
  158. }
  159. </style>