This commit is contained in:
parent
7c05e80d62
commit
e70b93ea57
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "ag-element-ui",
|
"name": "ag-element-ui",
|
||||||
"version": "0.1.24",
|
"version": "0.1.25",
|
||||||
"main": "packages/index.js",
|
"main": "packages/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vue-cli-service serve",
|
"dev": "vue-cli-service serve",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(item, index) in options"
|
v-for="(item, index) in options"
|
||||||
:key="index"
|
:key="index"
|
||||||
|
:disabled="item.disabled"
|
||||||
:label="item.label"
|
:label="item.label"
|
||||||
:value="item.value"
|
:value="item.value"
|
||||||
></el-option>
|
></el-option>
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
@dragenter="onDragenter"
|
@dragenter="onDragenter"
|
||||||
@dragover="onDragover"
|
@dragover="onDragover"
|
||||||
@dragend="onDragend"
|
@dragend="onDragend"
|
||||||
@dragleave="onMouseup"
|
|
||||||
>
|
>
|
||||||
<slot name="file" :file="img">
|
<slot name="file" :file="img">
|
||||||
<img
|
<img
|
||||||
|
@ -31,6 +30,7 @@
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
v-if="
|
v-if="
|
||||||
|
index == 0 &&
|
||||||
$attrs.masktext &&
|
$attrs.masktext &&
|
||||||
$attrs.masktext.ai == false &&
|
$attrs.masktext.ai == false &&
|
||||||
$attrs.masktext.data[index]
|
$attrs.masktext.data[index]
|
||||||
|
@ -293,6 +293,8 @@ export default {
|
||||||
selectTop: false,
|
selectTop: false,
|
||||||
drag: false,
|
drag: false,
|
||||||
dragmoveclass: "imghover",
|
dragmoveclass: "imghover",
|
||||||
|
moveIndexs: [],
|
||||||
|
startIndex: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -304,6 +306,7 @@ export default {
|
||||||
return inkey !== index;
|
return inkey !== index;
|
||||||
});
|
});
|
||||||
this.$emit("onRemove", file, this.imageList);
|
this.$emit("onRemove", file, this.imageList);
|
||||||
|
this.$emit("onUpload", this.fileList, this.imageList, "remove");
|
||||||
},
|
},
|
||||||
handlePictureCardPreview(file) {
|
handlePictureCardPreview(file) {
|
||||||
if (file.type.indexOf("image/") > -1) {
|
if (file.type.indexOf("image/") > -1) {
|
||||||
|
@ -321,8 +324,6 @@ export default {
|
||||||
let that = this;
|
let that = this;
|
||||||
try {
|
try {
|
||||||
let uplist = [];
|
let uplist = [];
|
||||||
console.log(this.limit, " this.limit", this.limit - this.imageList.length);
|
|
||||||
|
|
||||||
let files = [...e.target.files].slice(0, this.limit - this.imageList.length);
|
let files = [...e.target.files].slice(0, this.limit - this.imageList.length);
|
||||||
const find = files.find((f, i) => {
|
const find = files.find((f, i) => {
|
||||||
if (this.$attrs.accept) {
|
if (this.$attrs.accept) {
|
||||||
|
@ -400,7 +401,7 @@ export default {
|
||||||
if (files.length == uplist.length) {
|
if (files.length == uplist.length) {
|
||||||
this.$refs.fileinputref.value = "";
|
this.$refs.fileinputref.value = "";
|
||||||
if (this.$listeners.onUpload) {
|
if (this.$listeners.onUpload) {
|
||||||
this.$emit("onUpload", this.fileList, uplist);
|
this.$emit("onUpload", this.fileList, uplist, "upload");
|
||||||
} else {
|
} else {
|
||||||
this.imageList.push(...uplist);
|
this.imageList.push(...uplist);
|
||||||
}
|
}
|
||||||
|
@ -465,6 +466,9 @@ export default {
|
||||||
e.target.classList.add("moving");
|
e.target.classList.add("moving");
|
||||||
}, 1);
|
}, 1);
|
||||||
},
|
},
|
||||||
|
onDragover(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
},
|
||||||
onDragenter(e) {
|
onDragenter(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this.disabled) {
|
if (this.disabled) {
|
||||||
|
@ -486,19 +490,13 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
const sourceIndex = childrens.indexOf(this.sourceNode);
|
const sourceIndex = childrens.indexOf(this.sourceNode);
|
||||||
|
if (!this.startIndex) {
|
||||||
|
this.startIndex = sourceIndex;
|
||||||
|
}
|
||||||
const targetIndex = childrens.indexOf(thistarget);
|
const targetIndex = childrens.indexOf(thistarget);
|
||||||
if (sourceIndex < targetIndex) {
|
this.moveIndexs = [sourceIndex, targetIndex];
|
||||||
this.partNode.insertBefore(this.sourceNode, thistarget.nextElementSibling);
|
|
||||||
} else {
|
|
||||||
this.partNode.insertBefore(this.sourceNode, thistarget);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onDragover(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
if (this.disabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onMouseup(e) {
|
onMouseup(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!this.dragmove) {
|
if (!this.dragmove) {
|
||||||
|
@ -523,16 +521,15 @@ export default {
|
||||||
e.target.classList.remove("moving");
|
e.target.classList.remove("moving");
|
||||||
e.target.classList.remove("tabsbg");
|
e.target.classList.remove("tabsbg");
|
||||||
this.sourceNode.classList.remove("moving");
|
this.sourceNode.classList.remove("moving");
|
||||||
if (this.partNode === e.target || e.target === this.sourceNode) {
|
const [sourceIndex, targetIndex] = this.moveIndexs;
|
||||||
return;
|
let newimage = Object.assign([], this.imageList);
|
||||||
}
|
let temp = Object.assign({}, newimage[sourceIndex]);
|
||||||
const childrens = [...this.partNode.children];
|
newimage[sourceIndex] = newimage[targetIndex];
|
||||||
|
newimage[targetIndex] = temp;
|
||||||
const sourceIndex = childrens.indexOf(this.sourceNode);
|
this.imageList = newimage;
|
||||||
const item = this.imageList.splice(sourceIndex, 1)[0];
|
|
||||||
this.imageList.splice(sourceIndex, 0, item);
|
|
||||||
this.sourceNode = null;
|
|
||||||
this.partNode = null;
|
this.partNode = null;
|
||||||
|
this.sourceNode = null;
|
||||||
|
this.moveIndexs = [];
|
||||||
},
|
},
|
||||||
onUploadDrap(e) {
|
onUploadDrap(e) {
|
||||||
e.preventDefault(); // 阻止默认行为(打开文件)
|
e.preventDefault(); // 阻止默认行为(打开文件)
|
||||||
|
|
Loading…
Reference in New Issue