|
@@ -0,0 +1,163 @@
|
|
|
+<template>
|
|
|
+ <popup>
|
|
|
+ <div class="ui-message ui-message-confirm" style="width: 400px">
|
|
|
+ <div class="ui-message-header">
|
|
|
+ <span>{{$i18n.t(`gather.rename`)}}</span>
|
|
|
+ <span @click="$emit('close')">
|
|
|
+ <i class="iconfont icon_close"></i>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <div class="input-wrap">
|
|
|
+ <input
|
|
|
+ class="ui-input"
|
|
|
+ :class="{
|
|
|
+ invalid: !validateRes.isValid,
|
|
|
+ }"
|
|
|
+ type="text"
|
|
|
+ maxlength="15"
|
|
|
+ ref="input"
|
|
|
+ :placeholder="$i18n.t(`gather.rename_folder_placeholder`)"
|
|
|
+ @input="emojistr" v-model="key"
|
|
|
+ />
|
|
|
+ <div v-if="!validateRes.isValid" class="invalid-tip">
|
|
|
+ {{validateRes.tip}}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="ui-message-footer">
|
|
|
+ <div class="btn">
|
|
|
+ <button @click="$emit('close')" class="ui-button ui-button-rect cancel">
|
|
|
+ {{$i18n.t(`gather.cancel`)}}
|
|
|
+ </button>
|
|
|
+ <button
|
|
|
+ @click="onClickConfirm"
|
|
|
+ class="ui-button ui-button-rect submit"
|
|
|
+ :class="{disable: !key || !validateRes.isValid}"
|
|
|
+ >
|
|
|
+ {{$i18n.t(`gather.comfirm`)}}
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </popup>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import Popup from "@/components/shared/popup";
|
|
|
+
|
|
|
+export default {
|
|
|
+ components: {
|
|
|
+ Popup
|
|
|
+ },
|
|
|
+ props: {
|
|
|
+ validate: {
|
|
|
+ type: Function,
|
|
|
+ default: function() {
|
|
|
+ return {
|
|
|
+ isValid: true,
|
|
|
+ tip: '',
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ oldName: {
|
|
|
+ type: String,
|
|
|
+ default: '',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ key: this.oldName,
|
|
|
+ validateRes: {
|
|
|
+ isValid: true,
|
|
|
+ tip: '',
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ key: {
|
|
|
+ handler(v) {
|
|
|
+ this.validateRes = this.validate(this.oldName, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.$refs.input.focus()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ emojistr() {
|
|
|
+ this.key = this.key.replace(/(\ud83c[\udf00-\udfff])|(\ud83d[\udc00-\ude4f])|(\ud83d[\ude80-\udeff])/g, function (char) {
|
|
|
+ if (char.length === 2) {
|
|
|
+ return ""
|
|
|
+ } else {
|
|
|
+ return char;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onClickConfirm() {
|
|
|
+ if (!this.key.trim()) {
|
|
|
+ return this.$alert({ content: "请输入名字" });
|
|
|
+ }
|
|
|
+ this.$emit('submit', this.key)
|
|
|
+ },
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+
|
|
|
+
|
|
|
+.ui-message-confirm {
|
|
|
+ width: 400px;
|
|
|
+ height: 230px;
|
|
|
+
|
|
|
+ .ui-message-header {
|
|
|
+ .icon_close {
|
|
|
+ color: #969799;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ > .input-wrap {
|
|
|
+ margin: 40px 0;
|
|
|
+ position: relative;
|
|
|
+ > input.ui-input {
|
|
|
+ height: 36px;
|
|
|
+ color: #323233;
|
|
|
+ font-size: 14px;
|
|
|
+ border-radius: 4px;
|
|
|
+ border: 1px solid #EBEDF0;
|
|
|
+ &:focus {
|
|
|
+ border: 1px solid @color;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ > input::placeholder {
|
|
|
+ font-size: 14px;
|
|
|
+ color: #969799 !important;
|
|
|
+ }
|
|
|
+ > input.ui-input.invalid {
|
|
|
+ border: 1px solid red;
|
|
|
+ }
|
|
|
+ > .invalid-tip {
|
|
|
+ position: absolute;
|
|
|
+ top: calc(100% + 0.5em);
|
|
|
+ left: 0.5em;
|
|
|
+ font-size: 14px;
|
|
|
+ color: red;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .ui-message-footer {
|
|
|
+ width: 100%;
|
|
|
+
|
|
|
+ .btn {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+
|
|
|
+ .ui-button {
|
|
|
+ max-width: 104px
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+@import '../style.less';
|
|
|
+</style>
|