Guest User

Untitled

a guest
Nov 15th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. <template>
  2. <div style="display: flex;flex-direction: column; width: 100%;">
  3. <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
  4. <el-menu-item v-for="(item) in memos"
  5. :key="item.key"
  6. :index="item.key">
  7. <el-popover
  8. class="popOver"
  9. placement="top-start"
  10. width="240"
  11. trigger="click">
  12. <div class="el-popover__content">
  13. <span>Title:</span><input type="text" v-model="item.title" @blur="editMemo('')">
  14. </div>
  15. <span slot="reference">{{item.title}}</span>
  16. </el-popover>
  17. <span class="menu-text">{{item.title}}</span>
  18. <i class="el-icon-close" @click="dialogVisible = true"></i>
  19. </el-menu-item>
  20. </el-menu>
  21. <Edit :viewMode="viewMode" :editText="memoContent" @editMemo="editMemo" v-if="Object.keys(memos).length"/>
  22. <el-dialog
  23. title="削除"
  24. :visible.sync="dialogVisible"
  25. width="30%">
  26. <span>本当に削除しますか?</span>
  27. <span slot="footer" class="dialog-footer">
  28. <el-button @click="dialogVisible = false">キャンセル</el-button>
  29. <el-button type="primary" @click="deleteMemo(false)">削除</el-button>
  30. </span>
  31. </el-dialog>
  32. <el-dialog title="ログイン(まだ未実装)" :visible.sync="dialogFormVisible" @close="$emit('formVisible',false)">
  33. <el-form :model="form">
  34. <el-form-item label="E-mail" :label-width="formLabelWidth">
  35. <el-input v-model="form.email" autocomplete="off"></el-input>
  36. </el-form-item>
  37. <el-form-item label="Password" :label-width="formLabelWidth">
  38. <el-input type="password" v-model="form.passward" autocomplete="off"></el-input>
  39. </el-form-item>
  40. </el-form>
  41. <span slot="footer" class="dialog-footer">
  42. <el-button @click="$emit('formVisible',false)">キャンセル</el-button>
  43. <el-button type="primary" @click="$emit('formVisible',false)">送信</el-button>
  44. </span>
  45. </el-dialog>
  46. </div>
  47. </template>
  48.  
  49. <script>
  50. import Edit from '@/components/edit'
  51.  
  52. export default {
  53. components : {
  54. Edit
  55. },
  56. props:['viewMode','dialogFormVisible'],
  57. data() {
  58. return {
  59. activeIndex: '',
  60. memoIndex: '',
  61. dialogVisible: false,
  62. popVisible: false,
  63. formLabelWidth: '120px',
  64. form: {
  65. email: '',
  66. password: '',
  67. },
  68. user: ""
  69. };
  70. },
  71. computed: {
  72. //Vuexからメモ情報をゲッターで取得
  73. memos: function () {
  74. return this.$store.getters.memos
  75. },
  76. //本文をedit.vueに渡すために抽出
  77. memoContent: function () {
  78. if(this.memos[this.memoIndex]){
  79. return this.memos[this.memoIndex].content
  80. }
  81. }
  82.  
  83. },
  84. methods: {
  85. //メモの選択した時
  86. handleSelect(key, keyPath) {
  87. this.activeIndex = key;
  88. this.memoIndex = this.memos.findIndex(
  89. memo => memo.key === this.activeIndex
  90. );
  91. },
  92. //タイトルを変更するためのツールチップを表示
  93. popOver(key){
  94. if(key == this.activeIndex){
  95. this.popVisible = true;
  96. }
  97. },
  98. //メモを編集した時
  99. editMemo(memo){
  100. if(memo){ //本文修正の時だけ代入
  101. this.memos[this.memoIndex].content = memo
  102. }
  103. this.$store.dispatch('editMemo',this.memos[this.memoIndex]);
  104. },
  105. //メモを削除した時
  106. deleteMemo(display){
  107. this.dialogVisible = display;
  108. this.$store.dispatch('deleteMemo',{ key: this.activeIndex, index: this.memoIndex });
  109. this.activeIndex = "";
  110. },
  111.  
  112. },
  113. created: function(){
  114. this.user = this.$store.getters.user;
  115.  
  116. }
  117. }
  118.  
  119. </script>
  120.  
  121. <style scoped>
  122.  
  123. .el-menu--horizontal>.el-menu-item {
  124. height: 48px;
  125. line-height: 48px;
  126. transition: color .3s cubic-bezier(.645,.045,.355,1),padding .3s cubic-bezier(.645,.045,.355,1);
  127. }
  128. .el-menu--horizontal>.el-menu-item * {
  129. vertical-align: initial;
  130. }
  131. .el-menu-item .popOver {
  132. display: none;
  133. }
  134. .el-menu-item .popOver span{
  135. line-height: 48px;
  136. display: inline-block;
  137. }
  138. .el-menu-item.is-active .popOver {
  139. display: inline-block;
  140. }
  141. .el-menu-item.is-active .menu-text {
  142. display: none;
  143. }
  144. .el-menu-item [class^=el-icon-].el-icon-close {
  145. font-size: 12px;
  146. width: 0;
  147. overflow: hidden;
  148. border-radius: 50%;
  149. text-align: center;
  150. transition: all .3s cubic-bezier(.645,.045,.355,1);
  151. position: relative;
  152. top: 2px;
  153. }
  154. .el-menu-item.is-active:hover {
  155. padding: 0 10px;
  156. }
  157. .el-menu-item.is-active:hover [class^=el-icon-].el-icon-close {
  158. width: 12px;
  159. margin-left: 8px;
  160. }
  161. [class^=el-icon-].el-icon-close:hover {
  162. color: #409EFF;
  163. }
  164.  
  165. .el-popover__content {
  166. display: flex;
  167. }
  168. .el-popover__content input {
  169. flex-grow: 1;
  170. padding: 2px;
  171. }
  172.  
  173. </style>
Add Comment
Please, Sign In to add comment