提交 a733f056 编写于 作者: lijinyang's avatar lijinyang

文件上传本地文件更新

上级 db794f2f
...@@ -100,6 +100,22 @@ export default class AppFileUpload extends Vue { ...@@ -100,6 +100,22 @@ export default class AppFileUpload extends Vue {
*/ */
@Prop() public data!: string; @Prop() public data!: string;
/**
* 视图参数
*
* @type {*}
* @memberof AppFormDRUIPart
*/
@Prop() public viewparams!: any;
/**
* 视图上下文
*
* @type {*}
* @memberof AppAutocomplete
*/
@Prop() public context!: any;
/** /**
* 初始化值 * 初始化值
* *
...@@ -146,7 +162,7 @@ export default class AppFileUpload extends Vue { ...@@ -146,7 +162,7 @@ export default class AppFileUpload extends Vue {
* @type {string} * @type {string}
* @memberof AppFileUpload * @memberof AppFileUpload
*/ */
@Prop() public uploadparams?: string; @Prop() public uploadparams?: any;
/** /**
* 下载参数 * 下载参数
...@@ -154,15 +170,7 @@ export default class AppFileUpload extends Vue { ...@@ -154,15 +170,7 @@ export default class AppFileUpload extends Vue {
* @type {string} * @type {string}
* @memberof AppFileUpload * @memberof AppFileUpload
*/ */
@Prop() public exportparams?: string; @Prop() public exportparams?: any;
/**
* 自定义参数
*
* @type {*}
* @memberof AppFileUpload
*/
@Prop() public customparams?: any;
/** /**
* 上传文件路径 * 上传文件路径
...@@ -186,20 +194,20 @@ export default class AppFileUpload extends Vue { ...@@ -186,20 +194,20 @@ export default class AppFileUpload extends Vue {
public files = []; public files = [];
/** /**
* 上传keys * 上传params
* *
* @type {Array<any>} * @type {Array<any>}
* @memberof AppFileUpload * @memberof AppFileUpload
*/ */
public upload_keys: Array<any> = []; public upload_params: Array<any> = [];
/** /**
* 导出keys * 导出params
* *
* @type {Array<any>} * @type {Array<any>}
* @memberof AppFileUpload * @memberof AppFileUpload
*/ */
public export_keys: Array<any> = []; public export_params: Array<any> = [];
/** /**
* 自定义数组 * 自定义数组
...@@ -239,31 +247,37 @@ export default class AppFileUpload extends Vue { ...@@ -239,31 +247,37 @@ export default class AppFileUpload extends Vue {
* @memberof AppFileUpload * @memberof AppFileUpload
*/ */
private dataProcess(): void { private dataProcess(): void {
let upload_arr: Array<string> = [];
let export_arr: Array<string> = [];
const _data: any = JSON.parse(this.data);
this.upload_keys.forEach((key: string) => {
upload_arr.push(`${key}=${_data[key]}`);
});
this.export_keys.forEach((key: string) => {
export_arr.push(`${key}=${_data[key]}`);
});
let _url = `${Environment.BaseUrl}${Environment.UploadFile}`; let _url = `${Environment.BaseUrl}${Environment.UploadFile}`;
if (upload_arr.length > 0 || this.custom_arr.length > 0) { if (this.upload_params.length > 0 ) {
_url = `${_url}?${upload_arr.join('&')}${upload_arr.length > 0 ? '&' : ''}${this.custom_arr.join('&')}`; _url +='?';
this.upload_params.forEach((item:any,i:any)=>{
_url += `${Object.keys(item)[0]}=${Object.values(item)[0]}`;
if(i<this.upload_params.length-1){
_url += '&';
}
})
} }
this.uploadUrl = _url; this.uploadUrl = _url;
this.files.forEach((file: any) => { this.files.forEach((file: any) => {
let url = `${this.downloadUrl}/${file.id}`; let url = `${this.downloadUrl}/${file.id}`;
if (upload_arr.length > 0 || this.custom_arr.length > 0) { if (this.export_params.length > 0) {
url = `${url}?${upload_arr.join('&')}${upload_arr.length > 0 ? '&' : ''}${this.custom_arr.join('&')}`; url +='?';
this.export_params.forEach((item:any,i:any)=>{
url += `${Object.keys(item)[0]}=${Object.values(item)[0]}`;
if(i<this.export_params.length-1){
url += '&';
}
})
} }
file.url = url; file.url = url;
}); });
} }
/** /**
* vue 生命周期 * vue 生命周期
* *
...@@ -290,28 +304,36 @@ export default class AppFileUpload extends Vue { ...@@ -290,28 +304,36 @@ export default class AppFileUpload extends Vue {
public mounted() { public mounted() {
this.appData = this.$store.getters.getAppData(); this.appData = this.$store.getters.getAppData();
let uploadparams: string = ''; let uploadparams: any = {};
let exportparams: string = ''; let exportparams: any = {};
let upload_keys: Array<string> = []; let upload_params: Array<string> = [];
let export_keys: Array<string> = []; let export_params: Array<string> = [];
let custom_arr: Array<string> = []; let custom_arr: Array<string> = [];
let param:any = this.viewparams;
let context:any = this.context;
if (this.uploadparams && !Object.is(this.uploadparams, '')) { if (this.uploadparams && !Object.is(this.uploadparams, '')) {
uploadparams = this.uploadparams; uploadparams = this.uploadparams;
upload_keys = uploadparams.split(';'); upload_params = this.$util.computedNavData(this.data,param,context,uploadparams);
} }
if (this.exportparams && !Object.is(this.exportparams, '')) { if (this.exportparams && !Object.is(this.exportparams, '')) {
exportparams = this.exportparams; exportparams = this.exportparams;
export_keys = exportparams.split(';'); export_params = this.$util.computedNavData(this.data,param,context,exportparams);
} }
if (this.customparams && !Object.is(this.customparams, '')) {
Object.keys(this.customparams).forEach((name: string) => { for (const item in upload_params) {
custom_arr.push(`${name}=${this.customparams[name]}`); this.upload_params.push({
}); [item]:upload_params[item]
})
}
for (const item in export_params) {
this.export_params.push({
[item]:export_params[item]
})
} }
this.upload_keys = upload_keys;
this.export_keys = export_keys;
this.custom_arr = custom_arr;
this.setFiles(this.value); this.setFiles(this.value);
this.dataProcess(); this.dataProcess();
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册