|
@@ -7,19 +7,31 @@
|
|
|
<i class="iconfont icon_close"></i>
|
|
|
</span>
|
|
|
</div>
|
|
|
- <input
|
|
|
- class="ui-input"
|
|
|
- type="text"
|
|
|
- maxlength="15"
|
|
|
- :placeholder="$i18n.t(`material.components.new_folder_placeholder`)"
|
|
|
- @input="emojistr" v-model="key"
|
|
|
- />
|
|
|
+ <div class="input-wrap">
|
|
|
+ <input
|
|
|
+ class="ui-input"
|
|
|
+ :class="{
|
|
|
+ invalid: !validateRes.isValid,
|
|
|
+ }"
|
|
|
+ type="text"
|
|
|
+ maxlength="15"
|
|
|
+ :placeholder="$i18n.t(`material.components.new_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="emitname" class="ui-button ui-button-rect submit" :class="{disable:!key}">
|
|
|
+ <button
|
|
|
+ @click="onClickConfirm"
|
|
|
+ class="ui-button ui-button-rect submit"
|
|
|
+ :class="{disable: !key || !validateRes.isValid}"
|
|
|
+ >
|
|
|
{{$i18n.t(`gather.comfirm`)}}
|
|
|
</button>
|
|
|
</div>
|
|
@@ -35,9 +47,31 @@ export default {
|
|
|
components: {
|
|
|
Popup
|
|
|
},
|
|
|
+ props: {
|
|
|
+ validate: {
|
|
|
+ type: Function,
|
|
|
+ default: function() {
|
|
|
+ return {
|
|
|
+ isValid: true,
|
|
|
+ tip: '',
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
key: '',
|
|
|
+ validateRes: {
|
|
|
+ isValid: true,
|
|
|
+ tip: '',
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ key: {
|
|
|
+ handler(v) {
|
|
|
+ this.validateRes = this.validate(v)
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
@@ -50,12 +84,12 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- emitname() {
|
|
|
+ onClickConfirm() {
|
|
|
if (!this.key.trim()) {
|
|
|
return this.$alert({ content: "请输入名字" });
|
|
|
}
|
|
|
this.$emit('submit', this.key)
|
|
|
- }
|
|
|
+ },
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
@@ -72,21 +106,33 @@ export default {
|
|
|
color: #969799;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- .ui-input {
|
|
|
+ > .input-wrap {
|
|
|
margin: 40px 0;
|
|
|
- height: 36px;
|
|
|
- color: #323233;
|
|
|
- font-size: 14px;
|
|
|
- border-radius: 4px;
|
|
|
- border: 1px solid #EBEDF0;
|
|
|
- &:focus {
|
|
|
- border: 1px solid @color;
|
|
|
+ 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;
|
|
|
}
|
|
|
- }
|
|
|
- input::placeholder {
|
|
|
- font-size: 14px;
|
|
|
- color: #969799 !important;
|
|
|
}
|
|
|
.ui-message-footer {
|
|
|
width: 100%;
|