brandList.vue 9.1 KB

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