rename.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <popup>
  3. <div class="ui-message ui-message-confirm" style="width: 400px">
  4. <div class="ui-message-header">
  5. <span>{{$i18n.t(`material.components.rename_material`)}}</span>
  6. <span @click="$emit('close')">
  7. <i class="iconfont icon_close"></i>
  8. </span>
  9. </div>
  10. <input class="ui-input" type="text" maxlength="50" :placeholder="$i18n.t(`edit_settings.please_input`)" @input="emojistr" v-model="key" />
  11. <div class="ui-message-footer">
  12. <div class="btn">
  13. <button @click="$emit('close')" class="ui-button ui-button-rect cancel">
  14. {{$i18n.t(`gather.cancel`)}}
  15. </button>
  16. <button @click="emitname" class="ui-button ui-button-rect submit" :class="{disable:!key}">
  17. {{$i18n.t(`gather.comfirm`)}}
  18. </button>
  19. </div>
  20. </div>
  21. </div>
  22. </popup>
  23. </template>
  24. <script>
  25. import Popup from "@/components/shared/popup";
  26. export default {
  27. props: ['item'],
  28. components: {
  29. Popup
  30. },
  31. watch: {
  32. show() {
  33. this.key = this.item.name
  34. }
  35. },
  36. data() {
  37. return {
  38. key: this.item.name
  39. }
  40. },
  41. methods: {
  42. emojistr() {
  43. this.key = this.key.replace(/(\ud83c[\udf00-\udfff])|(\ud83d[\udc00-\ude4f])|(\ud83d[\ude80-\udeff])/g, function (char) {
  44. if (char.length === 2) {
  45. return ""
  46. } else {
  47. return char;
  48. }
  49. });
  50. },
  51. emitname() {
  52. if (!this.key.trim()) {
  53. return this.$alert({ content: "请输入名字" });
  54. }
  55. this.$emit('rename', this.key)
  56. }
  57. }
  58. }
  59. </script>
  60. <style lang="less" scoped>
  61. .ui-message-confirm {
  62. width: 400px;
  63. height: 230px;
  64. .ui-message-header {
  65. .icon_close {
  66. color: #969799;
  67. }
  68. }
  69. .ui-input {
  70. margin: 40px 0;
  71. height: 36px;
  72. color: #323233;
  73. font-size: 14px;
  74. border-radius: 4px;
  75. border: 1px solid #EBEDF0;
  76. &:focus {
  77. border: 1px solid @color;
  78. }
  79. }
  80. .ui-message-footer {
  81. width: 100%;
  82. .btn {
  83. display: flex;
  84. justify-content: flex-end;
  85. .ui-button {
  86. max-width: 104px
  87. }
  88. }
  89. }
  90. }
  91. </style>
  92. <style lang="less" scoped>
  93. @import '../style.less';
  94. </style>