labelManage.vue 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <div class="cx-labelManage">
  3. <movable-area class="moveMenuBox">
  4. <movable-view class="moveMenuCont" :x="tran" :y="vert" direction="all" damping="30" friction="5" @change="handleChange">
  5. <img class="moveMenuPic" src="/static/images/buoy.png" @click="newLabel()">
  6. </movable-view>
  7. <div class="labelBox" v-for="(item, index) in labelData" :key="index">
  8. <p class="text">{{item.text}}({{item.num}})</p>
  9. <div class="optionsSet">
  10. <a class="delete text">删除</a>
  11. <div class="separate">|</div>
  12. <a class="update text">编辑</a>
  13. <div class="separate">|</div>
  14. <a class="moveDown text" @click="moveUps(index)" v-if="index == labelData.length - 1">上移</a>
  15. <a class="moveDown text" @click="moveDowns(index)" v-else>下移</a>
  16. </div>
  17. <div class="empty">&nbsp; </div>
  18. </div>
  19. </movable-area>
  20. <!--新建标签-->
  21. <div class="newLabelDiv" v-if="newLabelDivFlag">
  22. <div class="newLabelBox">
  23. <p class="title">新建标签</p>
  24. <input class="newLabelName" v-text="inputText" type="text" placeholder="请输入分组名称,不超过10个字">
  25. <div class="confirmBox">
  26. <button class="cancel" @click="newLabelCancel()">取消</button>
  27. <button class="save" @click="newLabelSave()">保存</button>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. data () {
  36. return {
  37. tran: 350, //横轴
  38. vert: 500, //纵轴
  39. inputText: '', //输入框
  40. newLabelDivFlag: false, //控制新建标签框展示与隐藏
  41. labelData: [
  42. {text: '重要 ', num: 8},
  43. {text: '朋友 ', num: 19},
  44. {text: '家人 ', num: 8},
  45. {text: '同事 ', num: 40}
  46. ]
  47. }
  48. },
  49. onLoad () {
  50. },
  51. methods: {
  52. handleChange(e) {
  53. // console.log(e);
  54. this.tran = e.detail.x;
  55. this.vert = e.detail.y;
  56. if (this.tran <= 188) {
  57. console.log('超过中间线了');
  58. this.tran = 0;
  59. } else {
  60. this.tran = 350;
  61. }
  62. },
  63. moveUps(index) {
  64. this.labelData[index] = this.labelData.splice(index - 1, 1, this.labelData[index])[0];
  65. },
  66. moveDowns(index) {
  67. this.labelData[index] = this.labelData.splice(index + 1, 1, this.labelData[index])[0];
  68. },
  69. newLabel() {
  70. this.newLabelDivFlag = true;
  71. },
  72. newLabelCancel() {
  73. this.inputText = '';
  74. this.newLabelDivFlag = false;
  75. },
  76. newLabelSave() {
  77. this.labelData.push({text: this.inputText, num: 5});
  78. this.newLabelDivFlag = false;
  79. this.inputText = '';
  80. console.log(this.labelData);
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="less">
  86. </style>