多租户商城-商户端
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.

309 lines
8.8 KiB

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