imageTextNav.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <div class="brandListTool">
  3. <h3 class="toolTit">图文导航</h3>
  4. <div class="toolBox">
  5. <div class="imgListBox">
  6. <draggable v-model="activeComponent.componentContent.imgTextData">
  7. <div v-for="(item, index) in activeComponent.componentContent.imgTextData" :key="index" class="item">
  8. <div class="listItemBox">
  9. <div class="addImgTit" @click="openAddImg(item, index)">
  10. <div class="titLeft">
  11. <span class="iconfont">&#xe703;</span>
  12. <span class="iconfont">&#xe64a;</span>
  13. <span>图片</span>
  14. </div>
  15. <div class="titRight">
  16. <span class="iconfont" @click.stop="deleteItem(item, index)">&#xe633;</span>
  17. <span v-html="imgCurrent === index ? '&#xe660;' : '&#xe695;'" class="iconfont"></span>
  18. </div>
  19. </div>
  20. <div class="addBox" v-show="imgCurrent === index">
  21. <div class="addContent">
  22. <tool-single-img :imageUrl.sync='item.img' tip="建议尺寸: 100*100px"></tool-single-img>
  23. <div class="itemImgTit itemBox">
  24. <label>标题</label>
  25. <el-input v-model="item.title" maxlength="20" placeholder="请输入内容"></el-input>
  26. </div>
  27. <tool-select-link :linkObj.sync='item.linkObj'></tool-select-link>
  28. </div>
  29. <div @click="deleteItem(item, index)" class="deleteItem"><span class="iconfont">&#xe633;</span>删除导航</div>
  30. </div>
  31. </div>
  32. </div>
  33. </draggable>
  34. </div>
  35. </div>
  36. <div class="addImgBtn" v-if="activeComponent.componentContent.imgTextData.length < 5" @click="addImgText"><span class="iconfont">&#xe64a;</span>添加导航</div>
  37. <div class="addImgBtn" v-else><span class="iconfont">&#xe608;</span>最多只能添加5个</div>
  38. </div>
  39. </template>
  40. <script>
  41. import Draggable from 'vuedraggable'
  42. import {toolMixin} from '@@/config/mixin'
  43. import ToolSingleImg from '../toolModule/tool-single-img'
  44. import ToolSelectLink from '../toolModule/tool-select-link'
  45. export default {
  46. mixins: [toolMixin],
  47. name: 'imageTextNavTool',
  48. components: {
  49. ToolSelectLink,
  50. ToolSingleImg,
  51. Draggable
  52. },
  53. data () {
  54. return {
  55. title: '', // 标题内容
  56. textInfo: '', // 文本
  57. dialogImageUrl: '',
  58. imgTextData: [
  59. {
  60. title: '',
  61. isShow: true,
  62. imgData: '',
  63. describe: '',
  64. url: ''
  65. }
  66. ],
  67. alignList: [
  68. {
  69. id: 1,
  70. label: '居左',
  71. value: 'left'
  72. },
  73. {
  74. id: 2,
  75. label: '居中',
  76. value: 'center'
  77. }
  78. ],
  79. textAlign: 'left',
  80. imgCurrent: null,
  81. }
  82. },
  83. computed: {
  84. },
  85. methods: {
  86. openAddImg (item, index) {
  87. if (this.imgCurrent === index) {
  88. this.imgCurrent = null
  89. return false
  90. }
  91. this.imgCurrent = index
  92. },
  93. // 添加图文
  94. addImgText () {
  95. this.activeComponent.componentContent.imgTextData.push({
  96. title: '',
  97. isShow: true,
  98. imgData: '',
  99. linkObj: {
  100. selsectValue: '',
  101. selectName: '',
  102. typeText: '',
  103. url: ''
  104. }
  105. })
  106. },
  107. // 删除内容
  108. deleteItem (item, index) {
  109. this.$confirm('确定删除此项?')
  110. .then(_ => {
  111. this.activeComponent.componentContent.imgTextData.splice(index, 1)
  112. })
  113. .catch(_ => {})
  114. }
  115. }
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .brandListTool {
  120. padding: 20px 20px 0px 20px;
  121. h3 {
  122. font-size: 18px;
  123. font-weight: 500;
  124. height: 35px;
  125. line-height: 35px;
  126. color: #333333;
  127. margin-bottom: 20px;
  128. }
  129. .toolBox {
  130. padding-bottom: 10px;
  131. .itemBox {
  132. label {
  133. font-size: 14px;
  134. color: #666666;
  135. height: 40px;
  136. line-height: 40px;
  137. }
  138. margin-bottom: 15px;
  139. }
  140. .imgListBox {
  141. margin-top: 30px;
  142. .item {
  143. border: 1px solid #E8EAEC;
  144. border-radius: 4px;
  145. margin-bottom: 10px;
  146. }
  147. .listItemBox {
  148. .addImgTit {
  149. padding: 10px;
  150. display: flex;
  151. justify-content: space-between;
  152. align-items: center;
  153. background: #F6F7F9;
  154. cursor: pointer;
  155. .titLeft {
  156. display: flex;
  157. align-items: center;
  158. span {
  159. color: #7D7E80;
  160. }
  161. span:nth-child(1) {
  162. font-size: 28px;
  163. }
  164. span:nth-child(2) {
  165. font-size: 25px;
  166. margin: 0 6px;
  167. }
  168. span:nth-child(3) {
  169. font-size: 14px;
  170. }
  171. }
  172. .titRight {
  173. display: flex;
  174. align-items: center;
  175. span:nth-child(1) {
  176. width: 40px;
  177. text-align: center;
  178. display: block;
  179. height: 30px;
  180. line-height: 30px;
  181. }
  182. }
  183. }
  184. .addContent {
  185. padding: 5px 13px;
  186. .imgIsShow {
  187. display: flex;
  188. justify-content: space-between;
  189. margin: 18px 0 22px 0;
  190. span {
  191. font-size: 14px;
  192. color: #666666;
  193. }
  194. }
  195. .deleteItem {
  196. border-radius: 4px;
  197. background: $mainColor;
  198. text-align: center;
  199. height: 36px;
  200. color: #ffffff;
  201. font-size: 14px;
  202. display: flex;
  203. align-items: center;
  204. justify-content: center;
  205. cursor: pointer;
  206. margin-bottom: 10px;
  207. span {
  208. font-size: 18px;
  209. color: #ffffff;
  210. margin-right: 5px;
  211. }
  212. }
  213. }
  214. .deleteItem {
  215. padding: 10px;
  216. display: flex;
  217. align-items: center;
  218. justify-content: center;
  219. background: #F6F7F9;
  220. cursor: pointer;
  221. color: $mainColor;
  222. font-size: 14px;
  223. span {
  224. font-size: 16px;
  225. margin-right: 5px;
  226. }
  227. }
  228. }
  229. }
  230. .textTit {
  231. height: 35px;
  232. line-height: 35px;
  233. font-size: 16px;
  234. color: #333333;
  235. font-weight: bold;
  236. }
  237. }
  238. ::v-deep .el-select {
  239. width: 100%;
  240. }
  241. .addImgBtn {
  242. border-radius: 4px;
  243. background: $mainColor;
  244. text-align: center;
  245. height: 36px;
  246. color: #ffffff;
  247. font-size: 14px;
  248. display: flex;
  249. align-items: center;
  250. justify-content: center;
  251. cursor: pointer;
  252. span {
  253. font-size: 20px;
  254. margin-right: 5px;
  255. }
  256. }
  257. }
  258. </style>