Authored by TaoHuang

fix upload

... ... @@ -7,7 +7,7 @@
</div>
<slot>
<input ref="input" :type="type" class="wrapper-input" :placeholder="placeHolder" :value="inputValue"
@input="onInputChange" @blur="validate"/>
@input="onInputChange" @blur="validate" :maxlength="maxLength"/>
</slot>
</div>
</template>
... ... @@ -53,6 +53,12 @@ export default {
default() {
return false;
}
},
maxLength: {
type: Number,
default() {
return 100;
}
}
},
data() {
... ... @@ -70,6 +76,10 @@ export default {
},
methods: {
onInputChange() {
if (this.$refs.input.value.length > this.maxLength) {
this.$refs.input.value = this.$refs.input.value.slice(0, this.maxLength);
}
this.inputValue = this.$refs.input.value;
this.$emit('input', this.$refs.input.value);
},
... ...
... ... @@ -9,7 +9,6 @@
:simultaneous-uploads="1"
:value="file"
@files-added="filesAdded"
@file-submitted="fileSubmit"
@file-error="fileError"
@file-success="fileSuccess"
@file-removed="fileRemove"
... ... @@ -62,23 +61,23 @@ export default {
}
},
data() {
let vm = this;
return {
multiple: false,
action: {
target: 'http://upload.qiniup.com/',
data: {
token: '',
key: ''
data(file) {
return {
token: vm.token,
key: 'license/' + Date.now() + '/' + file.name
};
}
},
file: this.value
};
},
methods: {
fileSubmit(file) {
this.action.data.token = this.token;
this.action.data.key = 'license/' + Date.now() + '/' + file.name;
},
filesAdded(files) {
let hasIgnore = false;
const maxSize = 10 * 1024 * 1024; // 10M
... ... @@ -126,10 +125,10 @@ export default {
},
fileSuccess(file) {
file.name = file.response.key;
this.$emit('file-change');
this.$emit('file-change', file);
},
fileRemove(file) {
this.$emit('file-change');
this.$emit('file-change', file);
}
},
computed: {
... ...
... ... @@ -5,15 +5,15 @@
<Form ref="form">
<FormItem>
<CInput label="品牌" :show-required="true" :required="true" place-holder="请输入品牌名" v-model="form.brand"></CInput>
<CInput label="品牌" :max-length="50" :show-required="true" :required="true" place-holder="请输入品牌名" v-model="form.brand"></CInput>
</FormItem>
<FormItem>
<CInput label="名称" :show-required="true" :required="true" place-holder="请输入产品名" v-model="form.product_name"></CInput>
<CInput label="名称" :max-length="50" :show-required="true" :required="true" place-holder="请输入产品名" v-model="form.product_name"></CInput>
</FormItem>
<FormItem>
<CInput label="发售价" type="number" :show-required="true" :required="false" place-holder="请输入发售价" v-model="form.price"></CInput>
<CInput label="发售价" :max-length="9" type="number" :show-required="true" :required="false" place-holder="请输入发售价" v-model="form.price"></CInput>
</FormItem>
<FormItem>
... ... @@ -21,7 +21,7 @@
</FormItem>
<FormItem>
<CInput label="货号" :show-required="true" :required="true" place-holder="请输入货号" v-model="form.product_code"></CInput>
<CInput :max-length="50" label="货号" :show-required="true" :required="true" place-holder="请输入货号" v-model="form.product_code"></CInput>
</FormItem>
<FormItem>
... ...