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