event-edit.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 v-model="defaultCollapse">
  20. <el-collapse-item v-for="(item, index) in activeElement.events" :name="index" :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. defaultCollapse: 0,
  63. eventTypeList: [{
  64. label: '链接跳转',
  65. value: 'link',
  66. disabled: false
  67. }, {
  68. label: '分享',
  69. value: 'share',
  70. disabled: true
  71. }, {
  72. label: '表单提交',
  73. value: 'submitForm',
  74. disabled: true
  75. }]
  76. }
  77. },
  78. computed: {
  79. ...mapState({
  80. projectData: state => state.editor.projectData,
  81. activePageUUID: state => state.editor.activePageUUID,
  82. activeElementUUID: state => state.editor.activeElementUUID
  83. }),
  84. ...mapGetters([
  85. 'currentPageIndex',
  86. 'activeElementIndex',
  87. 'activeElement',
  88. 'activePage'
  89. ])
  90. },
  91. methods: {
  92. /**
  93. * 添加事件
  94. * @param type 事件名称
  95. */
  96. addEvent(type) {
  97. this.$store.dispatch('addElementEvent', type)
  98. },
  99. /**
  100. * 删除事件
  101. * @param index
  102. */
  103. deleteEvent(index) {
  104. this.$store.dispatch('deleteElementEvent', index)
  105. },
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .components-attr-edit {
  111. height: 100%;
  112. }
  113. .components-attr-animate-edit {
  114. position: relative;
  115. }
  116. .attr-title {
  117. font-weight: bold;
  118. }
  119. .attr-item-edit-wrapper {
  120. padding-left: 4px;
  121. display: flex;
  122. width: 100%;
  123. text-align: center;
  124. padding-bottom: 10px;
  125. .attr-item-title {
  126. text-align: left;
  127. width: 80px;
  128. font-size: 12px;
  129. line-height: 28px;
  130. }
  131. .attr-item-edit-input {
  132. text-align: left;
  133. flex: 1;
  134. }
  135. }
  136. .el-animate-list-wrapper {
  137. .el-animate-title-name {
  138. display: inline-block;
  139. vertical-align: middle;
  140. font-size: 14px;
  141. font-weight: bold;
  142. width: 55px;
  143. }
  144. .el-animate-title-type-wrapper {
  145. display: inline-block;
  146. width: 190px;
  147. }
  148. .el-animate-title-type {
  149. display: inline-block;
  150. vertical-align: middle;
  151. max-width: 140px;
  152. height: 24px;
  153. color: #333;
  154. overflow: hidden;
  155. text-overflow: ellipsis;
  156. white-space: nowrap;
  157. background: #fafafa;
  158. border-radius: 60px;
  159. padding: 4px 20px;
  160. border: none;
  161. cursor: pointer;
  162. margin: 0 20px 0 10px;
  163. line-height: 14px;
  164. }
  165. .el-animate-title-btn {
  166. display: inline-block;
  167. vertical-align: middle;
  168. text-align: center;
  169. line-height: 24px;
  170. font-size: 14px;
  171. color: #666;
  172. width: 24px;
  173. height: 24px;
  174. cursor: pointer;
  175. border-radius: 4px;
  176. background: rgba(37, 165, 137, 0.08);
  177. margin-left: 6px;
  178. &:hover {
  179. color: white;
  180. background: $primary;
  181. }
  182. }
  183. }
  184. </style>