|
|
@@ -64,7 +64,11 @@
|
|
|
type: Boolean,
|
|
|
default: true
|
|
|
} ,
|
|
|
- fileKeyName:'file'
|
|
|
+ fileKeyName:'file',
|
|
|
+ rootCategoryLevelId: {
|
|
|
+ type: [Number, String], // 类型与主组件rootId一致
|
|
|
+ default: '' // 默认值为空,避免无值时报错
|
|
|
+ }
|
|
|
},
|
|
|
//注册组件
|
|
|
data() {
|
|
|
@@ -80,7 +84,8 @@
|
|
|
};
|
|
|
},
|
|
|
|
|
|
- created() {},
|
|
|
+ created() {
|
|
|
+ },
|
|
|
methods: {
|
|
|
open() {
|
|
|
this.attaments = [];
|
|
|
@@ -105,44 +110,46 @@
|
|
|
this.attaments.push(param.file);
|
|
|
},
|
|
|
// 文件上传
|
|
|
- async upload() {
|
|
|
- if (this.attaments.length == 0) {
|
|
|
- return this.$message.warning('文件不能为空!');
|
|
|
- }
|
|
|
- this.module = this.$props.defModule;
|
|
|
- this.isProgress = true;
|
|
|
- this.percentage = 0;
|
|
|
- await importBatch(
|
|
|
- {
|
|
|
- module: this.module,
|
|
|
- multiPartFiles: this.attaments
|
|
|
- },
|
|
|
- this.apiUrl,
|
|
|
- (data) => {
|
|
|
- console.log(data, 'data');
|
|
|
- this.percentage = parseFloat(
|
|
|
- ((data.loaded * 100) / data.total).toFixed(2)
|
|
|
- );
|
|
|
- if (this.percentage >= 100) {
|
|
|
- setTimeout(() => {
|
|
|
- this.isProgress = false;
|
|
|
- }, 500);
|
|
|
- }
|
|
|
- },
|
|
|
- this.fileKeyName
|
|
|
- )
|
|
|
- .then((res) => {
|
|
|
- this.$message.success('操作成功!');
|
|
|
- this.dialogVisible = false;
|
|
|
- this.isProgress = false;
|
|
|
- this.$emit('success');
|
|
|
- })
|
|
|
- .catch(() => {
|
|
|
- this.isProgress = false;
|
|
|
- });
|
|
|
- },
|
|
|
+async upload() {
|
|
|
+ if (this.attaments.length == 0) {
|
|
|
+ return this.$message.warning('文件不能为空!');
|
|
|
+ }
|
|
|
+ this.module = this.$props.defModule;
|
|
|
+ this.isProgress = true;
|
|
|
+ this.percentage = 0;
|
|
|
+ await importBatch(
|
|
|
+ {
|
|
|
+ module: this.module,
|
|
|
+ multiPartFiles: this.attaments,
|
|
|
+ rootCategoryLevelId: this.rootCategoryLevelId
|
|
|
+ },
|
|
|
+ this.apiUrl,
|
|
|
+ (data) => {
|
|
|
+ console.log(data, 'data');
|
|
|
+ this.percentage = parseFloat(
|
|
|
+ ((data.loaded * 100) / data.total).toFixed(2)
|
|
|
+ );
|
|
|
+ if (this.percentage >= 100) {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.isProgress = false;
|
|
|
+ }, 500);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ this.fileKeyName,
|
|
|
+ )
|
|
|
+ .then((res) => {
|
|
|
+ this.$message.success('操作成功!');
|
|
|
+ this.dialogVisible = false;
|
|
|
+ this.isProgress = false;
|
|
|
+ this.$emit('success');
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.isProgress = false;
|
|
|
+ });
|
|
|
+},
|
|
|
//下载模板
|
|
|
downLoadTemplate() {
|
|
|
+
|
|
|
if(this.isWeb){
|
|
|
download1(window.location.origin + this.fileUrl, this.fileName);
|
|
|
}else{
|