You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

248 lines
7.3 KiB

5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
  1. <template>
  2. <section>
  3. <div class="SpeListOverFlow">
  4. <draggable v-model="imageLists" :options="{group:'img'}" @start="drag=true" @end="drag=false">
  5. <el-col :span="8" v-for="(o, index) in imageLists" :key="index">
  6. <el-card :body-style="{ padding: '0px' }">
  7. <div class="avatar-uploader" @click="selectedImage(index)">
  8. <div style="height: 178px;width: 186px;display: flex;">
  9. <img v-if="getUrl(o)" :src="converUrl(o)" class="avatar">
  10. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  11. </div>
  12. </div>
  13. <span class="row-span" style="justify-content:center;align-items:center;display:flex;">
  14. <span>{{index+1}},&nbsp;</span>
  15. <span v-show="!!desName" style="height: 35px;">{{o[desName]}}</span>
  16. <el-popover
  17. placement="top"
  18. width="800"
  19. trigger="click">
  20. <el-row class="padding-top">
  21. 图片标题<el-input style="width:90%;" v-model="o[desName]" clearable></el-input>
  22. </el-row>
  23. <el-row class="padding-top">
  24. 跳转链接<el-input style="width:90%;" v-model="o[valueName]" clearable></el-input>
  25. </el-row>
  26. <el-row class="padding-top">
  27. 扩展信息<el-input style="width:90%;" v-model="o['ext']" clearable></el-input>
  28. </el-row>
  29. <el-button type="text" slot="reference">编辑</el-button>
  30. </el-popover>
  31. <i class="el-icon-zoom-in" @click="previewImg(index)"></i>
  32. <el-button type="text" class="button" @click="delImg(index)">删除</el-button>
  33. </span>
  34. </el-card>
  35. </el-col>
  36. </draggable>
  37. <el-col :span="8" v-if="showAdd=='true'">
  38. <el-card :body-style="{ padding: '0px' }">
  39. <div style="padding: 14px;" class="avatar-uploader" @click="addImg">
  40. <i class="el-icon-plus avatar-uploader-icon"></i>
  41. </div>
  42. </el-card>
  43. </el-col>
  44. <el-dialog title="裁剪图片" :visible.sync="shearMngVisible" top="0px" width="1100px" :lock-scroll="false" :close-on-click-modal="false" append-to-body>
  45. <shear-mng :visible="shearMngVisible" :imgWidth="imgWidth" :imgHeight="imgHeight" :image="image" :branch-id="branchId" :deptid="deptid" :category-id="image.categoryId" :remark="remark" @cancel="shearMngVisible=false" @upload-success="uploadSuccess"></shear-mng>
  46. </el-dialog>
  47. <el-dialog title="选择图片" :visible.sync="addFormVisible" width="70%" :close-on-click-modal="false" append-to-body>
  48. <upload-image :multiple="true" :branch-id="branchId" :dept-id="deptid" :visible="addFormVisible" @cancel="addFormVisible=false" @confirm="handleConfirm"></upload-image>
  49. </el-dialog>
  50. <el-dialog :visible.sync="previewVisible" append-to-body>
  51. <img width="100%" :src="imageUrl" alt>
  52. </el-dialog>
  53. </div>
  54. </section>
  55. </template>
  56. <script>
  57. import util from '@/common/js/util';//全局公共库
  58. import UploadImage from '../UploadImage';
  59. import ShearMng from '../ShearSelectUpload';
  60. import draggable from 'vuedraggable';
  61. import config from '@/common/config';//config
  62. export default {
  63. props:['branchId','categoryId','remark','showAdd','limit','urlName','desName','value','valueName','deptid','imgWidth','imgHeight'],
  64. watch: {
  65. value(val){
  66. this.imageLists=val
  67. },
  68. imageLists(val){
  69. this.$emit("input",val)
  70. }
  71. },
  72. data() {
  73. return {
  74. addFormVisible:false,
  75. shearMngVisible:false,
  76. /**begin 在下面加自定义属性,记得补上面的一个逗号**/
  77. image:{categoryId:''},
  78. imageUrl:'',
  79. previewVisible:false,
  80. imageLists:[],//存放图片信息的数组 {urlName:,desName:,opflag:add/del/edit,order:}
  81. selectedImgIndex:this.value.length,
  82. opflag:'',//add/del/edit
  83. imageEditVisible:false,
  84. /**end 在上面加自定义属性**/
  85. }//end return
  86. },//end data
  87. methods: {
  88. selectedImage(index){
  89. this.selectedImgIndex = index;//注意修改图片url后清空
  90. this.image=this.imageLists[index]
  91. this.opflag='edit';
  92. this.addFormVisible = true;
  93. },
  94. handleConfirm(imgs){
  95. this.selectedImgIndex=0
  96. this.image=imgs[0]
  97. this.imageLists=imgs.map(i=>{
  98. var img= { ...i }
  99. img[this.urlName]=i.url
  100. img[this.desName]=i.remark
  101. img[this.valueName]=i.url
  102. return img;
  103. })
  104. //this.shearMngVisible=true;
  105. },
  106. //上传64图片后,指定回调父组件的方法,一般用于保存该图片的信息到另一张表
  107. uploadSuccess(parms){
  108. },
  109. /**begin 在下面加自定义方法,记得补上面的一个逗号**/
  110. converUrl(o){
  111. if(!o[this.urlName].indexOf('http')==0 && !o[this.urlName].indexOf('www')==0){
  112. return config.getArcImagePath()+"/"+o[this.urlName];
  113. }
  114. return o[this.urlName];
  115. },
  116. getUrl(o){
  117. if(o[this.urlName]!='' && o[this.urlName]!=undefined){
  118. return true;
  119. }
  120. return false;
  121. },
  122. previewImg(index){
  123. var o=this.imageLists[index];
  124. this.imageUrl=this.converUrl(o);
  125. this.previewVisible=true;
  126. },
  127. addImg(){
  128. if(parseInt(this.limit)<=this.imageLists.length){
  129. this.$message({ message: "图片数量已经超过", type: 'error' });
  130. return;
  131. }
  132. this.addFormVisible = true;
  133. this.opflag='add';
  134. },
  135. delImg(index){
  136. this.$confirm('确认删除吗?', '提示', {}).then(() => {
  137. this.opflag='del';
  138. this.selectedImgIndex=index;
  139. let returnDate = this.imageLists[this.selectedImgIndex];
  140. this.imageLists.splice(this.selectedImgIndex,1);
  141. this.$emit('delImg',returnDate);
  142. });
  143. },
  144. showEditImage(img,index){
  145. this.image=img;
  146. this.imageEditVisible=true;
  147. }
  148. /**end 在上面加自定义方法**/
  149. },//end method
  150. components: {
  151. //在下面添加其它组件 'image-edit':ImageEdit
  152. 'upload-image':UploadImage,
  153. 'shear-mng':ShearMng,
  154. draggable
  155. },
  156. mounted() {
  157. this.imageLists = this.value;
  158. }
  159. }
  160. </script>
  161. <style scoped="scoped">
  162. /*
  163. 1imageList的url,获取list遍历装载list的url
  164. 2addImg方法
  165. */
  166. .avatar-uploader{
  167. border: 1px dashed #d9d9d9;
  168. border-radius: 6px;
  169. cursor: pointer;
  170. position: relative;
  171. overflow: hidden;
  172. width: 208px;
  173. height: 200px;
  174. padding-left: 10px;
  175. padding-right: 10px;
  176. padding-top: 10px;
  177. padding-bottom: 10px;
  178. }
  179. .avatar-uploader:hover {
  180. border-color: #409EFF;
  181. }
  182. .avatar-uploader-icon {
  183. font-size: 28px;
  184. color: #8c939d;
  185. width: 178px;
  186. height: 178px;
  187. line-height: 178px;
  188. text-align: center;
  189. }
  190. .avatar {
  191. max-height: 100%;
  192. max-width: 100%;
  193. margin: auto;
  194. display: block;
  195. }
  196. /* card图片 */
  197. .time {
  198. font-size: 13px;
  199. color: #999;
  200. }
  201. .bottom {
  202. margin-top: 13px;
  203. line-height: 12px;
  204. }
  205. .button {
  206. padding: 0;
  207. float: right;
  208. }
  209. .el-col-8 {
  210. width: 210px;
  211. margin-right: 10px;
  212. }
  213. .el-row{
  214. padding-left: 70px;
  215. }
  216. .row-span{
  217. font-size: 14px;
  218. color: #5a5e66;
  219. text-align: center;
  220. display:block;
  221. }
  222. /* .row-span:before{
  223. content: '*';
  224. color: #fa5555;
  225. margin-right: 4px;
  226. } */
  227. .el-icon-zoom-in:hover{
  228. color: #0043ff;
  229. }
  230. .avatar-uploader img{
  231. cursor: pointer;
  232. transition: all 0.6s;
  233. }
  234. .avatar-uploader img:hover{
  235. transform: scale(1.2);
  236. }
  237. .SpeListOverFlow{
  238. overflow-y: auto;
  239. max-height: 550px;
  240. }
  241. </style>