imageTextList.vue 8.9 KB

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