Add, props add-index, method replace. Modify method add(files, index)

master
git 8 years ago
parent 9493161003
commit 17369cd847

@ -545,6 +545,25 @@ Whether to open the drag directory
### add-index
* **Type:** `Boolean, Number`
* **Default:** `undefined`
* **Version:** : `>=2.6.1`
* **Details:**
The default value of the `index` parameter for the [`add()`](#instance-methods-add) method
* **Usage:**
```html
<file-upload :add-index="true"></file-upload>
```
## Options / Events
@ -866,7 +885,7 @@ Add one or more files
* **Arguments:**
* `files: Array<File | window.File | Object> | File | window.File | Object` If it is an array of responses will be an array
* `start: Boolean` Whether it is inserted from the start position
* `index: Number | Boolean` = [`props.add-index`](#options-props-add-index) `true = ` Start, `false = ` End, `Number = ` Index
* **Result:** `Object | Array<File | Object> | Boolean` The incoming array is returned to the array otherwise the object or `false`
@ -1013,6 +1032,17 @@ Remove a file object
</script>
```
### replace()
Replace the location of the two files
* **Arguments:**
* `id1: File | Object | String`
* `id2: File | Object | String`
* **Result:** `Boolean`
### clear()

@ -540,6 +540,23 @@ input标签的 `name` 属性
```
### add-index
* **类型:** `Boolean, Number`
* **默认值:** `undefined`
* **详细:**
* **版本:** `>= 2.6.1`
[`add()`](#实例-方法-add) 方法 `index` 参数的默认值
* **示例:**
```html
<file-upload :add-index="true"></file-upload>
```
## 选项 / 事件
@ -860,7 +877,7 @@ Add, update, remove pre-filter
* **参数:**
* `files: Array<File | window.File | Object> | File | window.File | Object` 如果它是一个数组的响应将是一个数组
* `start: Boolean` 是否从开始位置插入
* `index: Number | Boolean` = [`props.add-index`](#选项-属性-add-index) `true = ` 开始位置, `false = ` 结束位置, `Number = ` 下标位置
* **结果:** `Object | Array<File | Object> | Boolean` 传入的是数组返回数组否则对象或`false`
@ -1008,6 +1025,19 @@ Add, update, remove pre-filter
```
### replace()
替换两个文件的位置
* **参数:**
* `id1: File | Object | String`
* `id2: File | Object | String`
* **结果:** `Boolean`
### clear()
清空文件列表

@ -97,6 +97,7 @@
:data="data"
:drop="drop"
:drop-directory="dropDirectory"
:add-index="addIndex"
v-model="files"
@input-filter="inputFilter"
@input-file="inputFile"
@ -163,6 +164,14 @@
<label for="minSize">Min size:</label>
<input type="number" min="0" id="minSize" class="form-control" v-model.number="minSize">
</div>
<div class="form-group">
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" id="add-index" class="form-check-input" v-model="addIndex"> Start position to add
</label>
</div>
<small class="form-text text-muted">Add a file list to start the location to add</small>
</div>
<div class="form-group">
<div class="form-check">
<label class="form-check-label">
@ -384,6 +393,7 @@ export default {
directory: false,
drop: true,
dropDirectory: true,
addIndex: false,
thread: 3,
name: 'file',
postAction: '/upload/post',

@ -1,7 +1,7 @@
{
"name": "vue-upload-component",
"description": "Vue.js file upload component, Multi-file upload, Upload directory, Drag upload, Drag the directory, Upload multiple files at the same time, html4 (IE 9), `PUT` method, Customize the filter",
"version": "2.6.0-beta.3",
"version": "2.6.1",
"author": "LianYue",
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server",

@ -56,6 +56,10 @@ export default {
type: Boolean,
},
addIndex: {
type: [Boolean, Number],
},
directory: {
type: Boolean,
},
@ -189,17 +193,7 @@ export default {
* uploading 正在上传的线程
* @return {[type]} [description]
*/
/*
uploading() {
let uploading = 0
for (var i = 0; i < this.files.length; i++) {
if (this.files[i].active) {
uploading++
}
}
return uploading
},
*/
/**
* uploaded 文件列表是否全部已上传
* @return {[type]} [description]
@ -309,7 +303,7 @@ export default {
},
//
add(_files, start) {
add(_files, index = this.addIndex) {
let files = _files
let isArray = files instanceof Array
@ -403,8 +397,11 @@ export default {
// files
let newFiles
if (start) {
if (index === true || index === 0) {
newFiles = addFiles.concat(this.files)
} else if (index) {
newFiles = addFiles.concat([])
newFiles.splice(index, 0, addFiles)
} else {
newFiles = this.files.concat(addFiles)
}
@ -536,6 +533,25 @@ export default {
},
replace(id1, id2) {
let file1 = this.get(id1)
let file2 = this.get(id2)
if (!file1 || !file2 || file1 === file2) {
return false
}
let files = this.files.concat([])
let index1 = files.indexOf(file1)
let index2 = files.indexOf(file2)
if (index1 === -1 || index2 === -1) {
return false
}
files[index1] = file2
files[index2] = file1
this.files = files
this.emitInput()
return true
},
//
remove(id) {
let file = this.get(id)
@ -601,6 +617,7 @@ export default {
},
//
emitFilter(newFile, oldFile) {
let isPrevent = false

Loading…
Cancel
Save