|
|
@@ -60,7 +60,7 @@
|
|
|
}
|
|
|
|
|
|
},
|
|
|
- emits: ['update:isShow','confirm','cancel'], // 显式声明事件(推荐)
|
|
|
+ emits: ['update:isShow','confirm','cancel','delete'], // 显式声明事件(推荐)
|
|
|
data() {
|
|
|
return {
|
|
|
fileList: [],
|
|
|
@@ -69,7 +69,6 @@
|
|
|
watch: {
|
|
|
'paramData.variantImages':{
|
|
|
handler(newVal, oldVal) {
|
|
|
- console.log('paramData.variantIimages -- ',newVal, oldVal);
|
|
|
if(newVal.length) {
|
|
|
this.fileList = [{
|
|
|
id: newVal[0].id,
|
|
|
@@ -102,25 +101,34 @@
|
|
|
return res;
|
|
|
},
|
|
|
removeImage(file,fileList) {
|
|
|
- console.log(file,fileList);
|
|
|
if(file.status === 'success' && file.id) {
|
|
|
-
|
|
|
+ let loading = this.$loading({
|
|
|
+ target: '.flexiblevariant-uploaddialog'
|
|
|
+ });
|
|
|
axios.delete(`/admin/flexible-variant/variants/images/${file.id}`, {
|
|
|
data:{
|
|
|
variant_ids: this.paramData.variantIds
|
|
|
}
|
|
|
}).then((result) => {
|
|
|
- console.log(result);
|
|
|
this.$message({
|
|
|
message: 'Delete Success',
|
|
|
type: 'success'
|
|
|
});
|
|
|
-
|
|
|
- })
|
|
|
+ this.$emit('delete', {
|
|
|
+ variantIds: this.paramData.variantIds,
|
|
|
+ variant_images:[]
|
|
|
+ });
|
|
|
+ loading.close();
|
|
|
+ }).catch((error) => {
|
|
|
+ this.$message({
|
|
|
+ message: error.message,
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ loading.close();
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
uploadExceed(files) {
|
|
|
- console.log('uploadExceed ---- ',files);
|
|
|
this.$refs.uploadRef.clearFiles();
|
|
|
const file = files[0];
|
|
|
file.uid = this.$genFileId();
|
|
|
@@ -130,7 +138,6 @@
|
|
|
console.log(addFile.size,addFile,fileList);
|
|
|
},
|
|
|
beforeUpload(rawFile) {
|
|
|
- console.log('beforeUpload ---- ',rawFile);
|
|
|
let res = true;
|
|
|
if(rawFile.size > 5000000) {
|
|
|
this.$message({
|
|
|
@@ -142,7 +149,6 @@
|
|
|
return res;
|
|
|
},
|
|
|
submitUpload(option) {
|
|
|
- console.log('submitUpload ---- ',option);
|
|
|
let loading = this.$loading({
|
|
|
target: '.flexiblevariant-uploaddialog'
|
|
|
});
|
|
|
@@ -154,7 +160,6 @@
|
|
|
axios.post(`/admin/flexible-variant/variants/images`, formData, {
|
|
|
headers: { 'Content-Type': 'multipart/form-data' }
|
|
|
}).then((result) => {
|
|
|
- console.log(result);
|
|
|
/**
|
|
|
* 1.更新fileList
|
|
|
* 2.触发confirm事件,把新的variant数据发给父组件
|