dda3de1d83e24754dba108df22e45c879beeeee4.svn-base 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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"></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%;" :src="`${hostUrl}/${item.filePath}`">
  18. <div class="image-action">
  19. <i @click="removeFile(item.id)" class="el-icon-delete"></i>
  20. </div>
  21. </div>
  22. <span>描述信息:{{item.keyWord}}</span>
  23. </div>
  24. </viewer>
  25. <p v-if="pictureArray.length==0" class="noPic">暂无图片信息</p>
  26. </el-row>
  27. <div slot="footer" class="dialog-footer">
  28. <el-button @click="dialogFormVisible = false">取 消</el-button>
  29. <el-button type="primary" @click="onSubmit">保 存</el-button>
  30. </div>
  31. </el-dialog>
  32. </div>
  33. </template>
  34. <script>
  35. import request from '@util/gw_ajax_request'
  36. import upload from '@widget/uploadPicWithDesc'
  37. import { deleteFileById } from "@api/duChaAPI.js";
  38. import { hostUrl } from "@util/global_variable.js";
  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 hostUrl
  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: this.type
  71. }
  72. request.post(`/file/findPageInfo`,params).then(res =>{
  73. if(res.success) {
  74. this.pictureArray = res.data.list;
  75. }
  76. })
  77. },
  78. onSubmit(){
  79. this.submitUpload();
  80. },
  81. // 文件上传
  82. submitUpload() {
  83. if (this.$refs.uploadFile.submitUpload(this.jqmmEngId,this.type)) {
  84. this.removeNewSupervision();
  85. }
  86. },
  87. removeNewSupervision(arg){
  88. if (arg) {
  89. this.$message.success('上传成功');
  90. this.getPicArray();
  91. this.$emit('jqmmDialogClose');
  92. // this.pictureArray = [];
  93. this.$refs.uploadFile.init();
  94. this.addPicPanel = !this.addPicPanel;
  95. } else{
  96. this.$message.error('上传有误');
  97. }
  98. },
  99. // 删除图片文件
  100. removeFile(id, index) {
  101. this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
  102. confirmButtonText: "确定",
  103. cancelButtonText: "返回",
  104. type: "warning"
  105. }).then(
  106. res => {
  107. if (res === "confirm") {
  108. deleteFileById(id, localStorage.getItem("userid")).then(res => {
  109. if (res.success) {
  110. this.getPicArray();
  111. } else {
  112. this.$message.error(res.message);
  113. }
  114. });
  115. }
  116. }
  117. );
  118. },
  119. },
  120. }
  121. </script>
  122. <style lang="scss">
  123. .img_wrapper{
  124. width: 120px;
  125. min-height: 120px;
  126. max-height: 200px;
  127. position: relative;
  128. float: left;
  129. &:hover{
  130. .image-action{
  131. opacity: 1;
  132. }
  133. }
  134. +span{
  135. margin-left: 20px;
  136. }
  137. }
  138. .image-action{
  139. position: absolute;
  140. bottom: 0;
  141. left: 0;
  142. width: 100%;
  143. height: 40px;
  144. text-align: center;
  145. opacity: 0;
  146. font-size: 16px;
  147. background-color: rgba(0, 0, 0, 0.5);
  148. transition: opacity 0.3s;
  149. cursor: pointer;
  150. line-height: 40px;
  151. }
  152. .image-action .el-icon-delete {
  153. font-size: 20px;
  154. color: #fff;
  155. }
  156. .noPic{
  157. width: 100%;
  158. height: 100%;
  159. text-align: center;
  160. line-height: 300px;
  161. font-size: 17px;
  162. font-weight: bold;
  163. }
  164. .jqmm span.el-dialog__title {
  165. font-weight: bold;
  166. }
  167. .viewer-container{
  168. z-index: 9999 !important;
  169. }
  170. </style>