event-edit.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div class="components-attr-edit">
  3. <el-scrollbar class="components-attr-edit">
  4. <div class="attr-edit-inner" v-if="activeElementUUID">
  5. <div class="animate-edit-btn-wrapper">
  6. <el-dropdown>
  7. <el-button type="primary" size="small">
  8. 添加事件<i class="el-icon-arrow-down el-icon--right"></i>
  9. </el-button>
  10. <el-dropdown-menu slot="dropdown">
  11. <el-dropdown-item v-for="(item, index) in eventTypeList" :disabled="item.disabled" :key="index">
  12. <div @click="addEvent(item.value)">{{item.label}}</div>
  13. </el-dropdown-item>
  14. </el-dropdown-menu>
  15. </el-dropdown>
  16. <p class="gray inline-block fontsize-12 marginL10">事件在编辑模式下无效果</p>
  17. </div>
  18. <div class="el-animate-list-wrapper paddingT20" v-show="activeElement.events.length">
  19. <el-collapse accordion>
  20. <el-collapse-item v-for="(item, index) in activeElement.events" :key="index">
  21. <template slot="title">
  22. <span class="el-animate-title-name">事件 {{index + 1}}</span>
  23. <div class="el-animate-title-type-wrapper">
  24. <span class="el-animate-title-type">{{item.type | getLabelText(eventTypeList)}}</span>
  25. </div>
  26. <span class="el-animate-title-btn" @click.stop.prevent="deleteEvent(index)"><i
  27. class="el-icon-delete"></i></span>
  28. </template>
  29. <div class="el-animate-item">
  30. <div class="attr-item-edit-wrapper" v-show="item.type !== 'share'">
  31. <p>打开方式:</p>
  32. <div class="col-1">
  33. <el-radio-group v-model="item.target" size="small">
  34. <el-radio-button label="_blank">新窗口</el-radio-button>
  35. <el-radio-button label="_self">当前窗口</el-radio-button>
  36. </el-radio-group>
  37. </div>
  38. </div>
  39. <div class="attr-item-edit-wrapper" v-show="item.type !== 'share'">
  40. <p class="attr-item-title">链接/接口url:</p>
  41. <div class="col-1 attr-item-edit-input">
  42. <el-input type="textarea" :rows="3" placeholder="请输入url" v-model="item.url" />
  43. </div>
  44. </div>
  45. </div>
  46. </el-collapse-item>
  47. </el-collapse>
  48. </div>
  49. </div>
  50. <div v-else>
  51. <p class="gray paddingT30 text-center">请在画板上选择需要编辑得元素</p>
  52. </div>
  53. </el-scrollbar>
  54. </div>
  55. </template>
  56. <script>
  57. import {mapState, mapGetters} from 'vuex'
  58. export default {
  59. name: "event-edit",
  60. data(){
  61. return {
  62. eventTypeList: [{
  63. label: '链接跳转',
  64. value: 'link',
  65. disabled: false
  66. }, {
  67. label: '分享',
  68. value: 'share',
  69. disabled: true
  70. }, {
  71. label: '表单提交',
  72. value: 'submitForm',
  73. disabled: true
  74. }]
  75. }
  76. },
  77. computed: {
  78. ...mapState({
  79. projectData: state => state.editor.projectData,
  80. activePageUUID: state => state.editor.activePageUUID,
  81. activeElementUUID: state => state.editor.activeElementUUID
  82. }),
  83. ...mapGetters([
  84. 'currentPageIndex',
  85. 'activeElementIndex',
  86. 'activeElement',
  87. 'activePage'
  88. ])
  89. },
  90. methods: {
  91. /**
  92. * 添加事件
  93. * @param type 事件名称
  94. */
  95. addEvent(type) {
  96. this.$store.dispatch('addElementEvent', type)
  97. },
  98. /**
  99. * 删除事件
  100. * @param index
  101. */
  102. deleteEvent(index) {
  103. this.$store.dispatch('deleteElementEvent', index)
  104. },
  105. }
  106. }
  107. </script>
  108. <style lang="scss" scoped>
  109. .components-attr-edit {
  110. height: 100%;
  111. }
  112. .components-attr-animate-edit {
  113. position: relative;
  114. }
  115. .attr-title {
  116. font-weight: bold;
  117. }
  118. .attr-item-edit-wrapper {
  119. padding-left: 4px;
  120. display: flex;
  121. width: 100%;
  122. text-align: center;
  123. padding-bottom: 10px;
  124. .attr-item-title {
  125. text-align: left;
  126. width: 80px;
  127. font-size: 12px;
  128. line-height: 28px;
  129. }
  130. .attr-item-edit-input {
  131. text-align: left;
  132. flex: 1;
  133. }
  134. }
  135. .el-animate-list-wrapper {
  136. .el-animate-title-name {
  137. display: inline-block;
  138. vertical-align: middle;
  139. font-size: 14px;
  140. font-weight: bold;
  141. width: 55px;
  142. }
  143. .el-animate-title-type-wrapper {
  144. display: inline-block;
  145. width: 190px;
  146. }
  147. .el-animate-title-type {
  148. display: inline-block;
  149. vertical-align: middle;
  150. max-width: 140px;
  151. height: 24px;
  152. color: #333;
  153. overflow: hidden;
  154. text-overflow: ellipsis;
  155. white-space: nowrap;
  156. background: #fafafa;
  157. border-radius: 60px;
  158. padding: 4px 20px;
  159. border: none;
  160. cursor: pointer;
  161. margin: 0 20px 0 10px;
  162. line-height: 14px;
  163. }
  164. .el-animate-title-btn {
  165. display: inline-block;
  166. vertical-align: middle;
  167. text-align: center;
  168. line-height: 24px;
  169. font-size: 14px;
  170. color: #666;
  171. width: 24px;
  172. height: 24px;
  173. cursor: pointer;
  174. border-radius: 4px;
  175. background: rgba(37, 165, 137, 0.08);
  176. margin-left: 6px;
  177. &:hover {
  178. color: white;
  179. background: $primary;
  180. }
  181. }
  182. }
  183. </style>