aae2f5ef7572fe60bc84c1938ef9d82380975953.svn-base 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <el-container style="height:520px;">
  3. <div>
  4. <el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" @close="dialogClose" :append-to-body="true" width="60%" 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"
  9. >{{!addPicPanel?"添加文件(PDF、ZIP、RAR、照片)":"取消"}}</el-button>
  10. </el-row>
  11. <el-row v-if="addPicPanel" style="text-align:center;">
  12. <upload ref="uploadFile" :url="`/pdcApi/upload/file/pdforzip?bizId=`" :is-key-wrod="true" @uploadOver="removeNewSupervision"></upload>
  13. </el-row>
  14. <el-row v-else>
  15. <el-scrollbar :native="false" wrapStyle="" wrapClass="" viewClass="" viewStyle="" noresize="false" tag="section" style="height: 520px;">
  16. <viewer :images="pictureArray" >
  17. <div v-for="(item,index) in pictureArray" :key="index" style="overflow:hidden">
  18. <div class="img_wrapper">
  19. <img style="width: 100%;height:100%;" :src="`${hostUrl}/${item.thumbnailUrl}`" @click="openPdfAndZip(`${item.fileExt}`,`${item.filePath}`,`${item.fileName}`)"/>
  20. <div class="image-action">
  21. <i @click="removeFile(item.id)" class="el-icon-delete"></i>
  22. </div>
  23. </div>
  24. <span>描述信息:{{item.keyWord}}</span>
  25. </div>
  26. <p v-if="pictureArray.length==0" class="noPic">暂无文件</p>
  27. </viewer>
  28. </el-scrollbar>
  29. </el-row>
  30. <div slot="footer" class="dialog-footer">
  31. <el-button @click="dialogFormVisible = false">取 消</el-button>
  32. <el-button type="primary" @click="onSubmit">保 存</el-button>
  33. </div>
  34. </el-dialog>
  35. </div>
  36. </el-container>
  37. </template>
  38. <script>
  39. import request from '@util/gw_ajax_request'
  40. import upload from '@widget/uploadPicWithDesc'
  41. import { deleteFileById } from "@api/duChaAPI.js";
  42. import { hostUrl } from "@util/global_variable.js";
  43. export default {
  44. name: "theRecentAppearance",
  45. props: ['jqmmShow','jqmmEngId','dialogTitle','currentObjectName','type'],
  46. components: {
  47. upload,
  48. },
  49. data (){
  50. return {
  51. dialogFormVisible:true,
  52. addPicPanel:false,
  53. pictureArray: []
  54. }
  55. },
  56. computed:{
  57. hostUrl(){
  58. return hostUrl
  59. }
  60. },
  61. mounted(){
  62. this.getPicArray();
  63. },
  64. methods:{
  65. openPdfAndZip(fileExt,pdfurl,fileName){
  66. console.log("获取到的文件的扩展名:" + fileExt);
  67. if('pdf' == fileExt.toLowerCase()){
  68. window.open("../../../static/pdf/web/viewer.html?file=" + encodeURIComponent("/pdcApi" + pdfurl));
  69. return;
  70. }else if('zip' == fileExt.toLowerCase() || 'rar' == fileExt.toLowerCase()){
  71. const link = document.createElement('a');
  72. link.download = fileName;
  73. link.style.display = 'none';
  74. link.href = hostUrl + pdfurl;
  75. document.body.appendChild(link)
  76. link.click()
  77. URL.revokeObjectURL(link.href)
  78. document.body.removeChild(link)
  79. return;
  80. }else if('png' == fileExt.toLowerCase() || 'jpg' == fileExt.toLowerCase()){
  81. return;
  82. }
  83. else{
  84. this.$message.error('该文件不是PDF或ZIP、RAR');
  85. }
  86. },
  87. openPDfWindow(){
  88. },
  89. dialogClose(){
  90. this.$emit('addPdfAndZipDialogClose');
  91. },
  92. addPic() {
  93. this.addPicPanel = !this.addPicPanel;
  94. },
  95. getPicArray(){
  96. let params = {
  97. bizId: this.jqmmEngId,
  98. bizType: this.type
  99. }
  100. request.post(`/file/findPageInfo`,params).then(res =>{
  101. if(res.success) {
  102. this.pictureArray = res.data.list;
  103. }
  104. })
  105. },
  106. onSubmit(){
  107. this.submitUpload();
  108. },
  109. // 文件上传
  110. submitUpload() {
  111. if (this.$refs.uploadFile.submitUpload(this.jqmmEngId,this.type)) {
  112. this.removeNewSupervision();
  113. }
  114. },
  115. removeNewSupervision(arg){
  116. if (arg) {
  117. this.$message.success('上传成功');
  118. this.getPicArray();
  119. // this.$emit('jqmmDialogClose');
  120. // this.pictureArray = [];
  121. this.$refs.uploadFile.init();
  122. this.addPicPanel = !this.addPicPanel;
  123. } else{
  124. this.$message.error('上传有误');
  125. }
  126. },
  127. // 删除图片文件
  128. removeFile(id, index) {
  129. this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
  130. confirmButtonText: "确定",
  131. cancelButtonText: "返回",
  132. type: "warning"
  133. }).then(
  134. res => {
  135. if (res === "confirm") {
  136. deleteFileById(id, localStorage.getItem("userid")).then(res => {
  137. if (res.success) {
  138. this.getPicArray();
  139. } else {
  140. this.$message.error(res.message);
  141. }
  142. });
  143. }
  144. }
  145. );
  146. },
  147. },
  148. }
  149. </script>
  150. <style lang="scss">
  151. .abow_dialog {
  152. display: flex;
  153. justify-content: center;
  154. align-items: Center;
  155. overflow: hidden;
  156. .el-dialog {
  157. margin: 0 auto !important;
  158. height: 90%;
  159. overflow: hidden;
  160. .el-dialog__body {
  161. position: absolute;
  162. left: 0;
  163. top: 54px;
  164. bottom: 0;
  165. right: 0;
  166. padding: 0;
  167. z-index: 1;
  168. overflow: hidden;
  169. overflow-y: auto;
  170. }
  171. }
  172. }
  173. .img_wrapper{
  174. width: 120px;
  175. min-height: 120px;
  176. max-height: 200px;
  177. position: relative;
  178. float: left;
  179. &:hover{
  180. .image-action{
  181. opacity: 1;
  182. }
  183. }
  184. +span{
  185. margin-left: 20px;
  186. }
  187. }
  188. .image-action{
  189. position: absolute;
  190. bottom: 0;
  191. left: 0;
  192. width: 100%;
  193. height: 40px;
  194. text-align: center;
  195. opacity: 0;
  196. font-size: 16px;
  197. background-color: rgba(0, 0, 0, 0.5);
  198. transition: opacity 0.3s;
  199. cursor: pointer;
  200. line-height: 40px;
  201. }
  202. .image-action .el-icon-delete {
  203. font-size: 20px;
  204. color: #fff;
  205. }
  206. .noPic{
  207. width: 100%;
  208. height: 100%;
  209. text-align: center;
  210. line-height: 300px;
  211. font-size: 17px;
  212. font-weight: bold;
  213. }
  214. .jqmm span.el-dialog__title {
  215. font-weight: bold;
  216. }
  217. .viewer-container{
  218. z-index: 9999 !important;
  219. }
  220. </style>