536a8b308fb69c30c9dafebf5acc708f4f37f2b8.svn-base 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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"
  8. >{{!addPicPanel?"添加材料":"取消"}}</el-button>
  9. </el-row>
  10. <el-row v-if="addPicPanel" style="text-align:center;">
  11. <upload ref="uploadFile" :url="`/pdcApi/file/insert?bizId=`" @uploadOver="removeNewSupervision" :accept="accept"></upload>
  12. </el-row>
  13. <el-row v-else>
  14. <viewer :images="pictureArray">
  15. <div v-for="(item,index) in pictureArray" :key="index" style="overflow:hidden">
  16. <div class="img_wrapper">
  17. <img style="width: 100%;height:100%;" v-if="namePic.indexOf(item.fileExt)>-1" :src="`${hostUrl}/${item.filePath}`">
  18. <a style="width: 100%;height:100%;" target="_blank" v-if="namePic.indexOf(item.fileExt)<0" :href="`${hostUrl}/${item.filePath}`">{{item.fileName}}</a>
  19. <div class="image-action">
  20. <i @click="removeFile(item.id)" class="el-icon-delete"></i>
  21. </div>
  22. </div>
  23. <span>描述信息:{{item.keyWord}}</span>
  24. </div>
  25. </viewer>
  26. <p v-if="pictureArray.length==0" class="noPic">暂无材料信息</p>
  27. </el-row>
  28. <div slot="footer" class="dialog-footer">
  29. <el-button @click="dialogFormVisible = false">取 消</el-button>
  30. <el-button type="primary" @click="onSubmit">保 存</el-button>
  31. </div>
  32. </el-dialog>
  33. </div>
  34. </template>
  35. <script>
  36. import request from '@util/gw_ajax_request'
  37. import upload from './uploadFileWithDesc'
  38. import { deleteFileById } from "@api/duChaAPI.js";
  39. import { hostUrl } from "@util/global_variable.js";
  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. namePic:['png','PNG','jpg','JPG','jpeg','JPEG','gif','GIF']
  52. }
  53. },
  54. computed:{
  55. hostUrl(){
  56. return hostUrl
  57. },
  58. organCode() {
  59. return localStorage.getItem('currentRlcode') ? localStorage.getItem('currentRlcode') : ''
  60. },
  61. accept(){
  62. return '.pdf,.doc,.docx,.png,.jpg,.jpeg,.xls,.xlsx,.ppt,.pptx,.mp4,.m3u8,.mov,.avi,.flv,.wmv';
  63. // if(this.organCode.substring(0,2).indexOf('63')>-1 || this.organCode.substring(0,2).indexOf('37')>-1){
  64. // return '.*'
  65. // }else{
  66. // return '.pdf,.PDF';
  67. // }
  68. }
  69. },
  70. mounted(){
  71. this.getPicArray();
  72. },
  73. methods:{
  74. dialogClose(){
  75. this.$emit('jqmmDialogClose');
  76. },
  77. addPic() {
  78. this.addPicPanel = !this.addPicPanel;
  79. },
  80. getPicArray(){
  81. let params = {
  82. bizId: this.jqmmEngId,
  83. bizType: this.type
  84. }
  85. request.post(`/file/findPageInfo`,params).then(res =>{
  86. if(res.success) {
  87. this.pictureArray = res.data.list;
  88. }
  89. })
  90. },
  91. onSubmit(){
  92. this.submitUpload();
  93. },
  94. // 文件上传
  95. submitUpload() {
  96. if (this.$refs.uploadFile.submitUpload(this.jqmmEngId,this.type)) {
  97. this.removeNewSupervision();
  98. }
  99. },
  100. removeNewSupervision(arg){
  101. if (arg) {
  102. this.$message.success('上传成功');
  103. this.getPicArray();
  104. this.$emit('jqmmDialogClose');
  105. // this.pictureArray = [];
  106. this.$refs.uploadFile.init();
  107. this.addPicPanel = !this.addPicPanel;
  108. } else{
  109. this.$message.error('上传有误');
  110. }
  111. },
  112. // 删除图片文件
  113. removeFile(id, index) {
  114. this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
  115. confirmButtonText: "确定",
  116. cancelButtonText: "返回",
  117. type: "warning"
  118. }).then(
  119. res => {
  120. if (res === "confirm") {
  121. deleteFileById(id, localStorage.getItem("userid")).then(res => {
  122. if (res.success) {
  123. this.getPicArray();
  124. } else {
  125. this.$message.error(res.message);
  126. }
  127. });
  128. }
  129. }
  130. );
  131. },
  132. },
  133. }
  134. </script>
  135. <style lang="scss">
  136. .img_wrapper{
  137. width: 120px;
  138. min-height: 120px;
  139. max-height: 200px;
  140. position: relative;
  141. float: left;
  142. &:hover{
  143. .image-action{
  144. opacity: 1;
  145. }
  146. }
  147. +span{
  148. margin-left: 20px;
  149. }
  150. }
  151. .image-action{
  152. position: absolute;
  153. bottom: 0;
  154. left: 0;
  155. width: 100%;
  156. height: 40px;
  157. text-align: center;
  158. opacity: 0;
  159. font-size: 16px;
  160. background-color: rgba(0, 0, 0, 0.5);
  161. transition: opacity 0.3s;
  162. cursor: pointer;
  163. line-height: 40px;
  164. }
  165. .image-action .el-icon-delete {
  166. font-size: 20px;
  167. color: #fff;
  168. }
  169. .noPic{
  170. width: 100%;
  171. height: 100%;
  172. text-align: center;
  173. line-height: 300px;
  174. font-size: 17px;
  175. font-weight: bold;
  176. }
  177. .jqmm span.el-dialog__title {
  178. font-weight: bold;
  179. }
  180. .viewer-container{
  181. z-index: 9999 !important;
  182. }
  183. </style>