qiushang 8 сар өмнө
parent
commit
6395e8d4c2

+ 47 - 14
src/renderer/components/home.vue

@@ -373,23 +373,20 @@
 							<div v-show="menuIndex == '8'">
 								<div class="handle-item" >
 									<label class="handle-label">操作类型:</label>
-									<el-select v-model="foundData.foundType" style="width:150px;" size="small" @change="refreshList('change')">
-										<el-option value="folder" label="合并"></el-option>
-										<el-option value="docx" label="提取"></el-option>
+									<el-select v-model="mergeData.type" style="width:150px;" size="small" @change="refreshList('change')">
+										<el-option value="merge" label="合并目录"></el-option>
+										<el-option value="extract" label="提取文件"></el-option>
 									</el-select>
 								</div>
 								
-								<template v-if="foundData.foundType != 'folder'">
-									<div class="handle-item">
-										<label class="handle-label">上传模板:</label>
-										<el-input :title="foundData.sourceFileName" ref="upload-example" @focus="importExample" placeholder="选择文件" size="small" v-model="foundData.sourceFileName" readonly style="width:150px;" prefix-icon="el-icon-folder"></el-input>
-									</div>
-									
-									<div class="eq-tips">不上传模板,默认创建文件内容为空</div>
-								</template>
+								<div class="handle-item">
+									<label class="handle-label">保存位置:</label>
+									<el-input :title="mergeData.newPath" ref="upload-merge" size="mini" @focus="pickPath('mergeData', 'upload-merge')" placeholder="请选择保存位置" v-model="mergeData.newPath" readonly style="width:150px;" prefix-icon="el-icon-folder"></el-input>
+								</div>
+								
 								
 								<el-divider content-position="left">
-									<i class="el-icon-s-tools" style="margin-right: 3px;"></i>文件名设置
+									<i class="el-icon-s-tools" style="margin-right: 3px;"></i>参数设置
 								</el-divider>
 								<el-popover placement="left" popper-class="popper-open" trigger="manual" v-model="visible5" content='文件名不能包含下列任何字符: \ / : * ? " < > |'>
 									<i slot="reference"></i>
@@ -941,6 +938,11 @@ export default {
 				exportSuffix: "xlsx",
 			},
 			
+			mergeData: { // 合并设置参数
+				type: 'merge', // 1合并 2提取
+				newPath: '',
+			},
+			
 	        dowloadModel: false,
 	        finishModel: false,
 			loading: false,
@@ -1055,7 +1057,7 @@ export default {
 					this[str].newPath = path;
 					if(str == 'foundData'){
 						this.downloadFoundDir = path;
-					}else{
+					}else if(str == 'extractData'){
 						this.downloadDir = path;
 					}
 					
@@ -1840,7 +1842,7 @@ export default {
 	    // 导出
 	    exportFile(flag) {
 			let authority = this.$refs.headerRef.authority;
-	        if ((['1','3','5'].indexOf(this.menuIndex) > -1 && this.fileList.length > 0) || (['2','4','6'].indexOf(this.menuIndex) > -1 && this.dirList.length > 0) || (this.menuIndex == '7' && this.foundList2.length > 0)) {
+	        if ((['1','3','5'].indexOf(this.menuIndex) > -1 && this.fileList.length > 0) || (['2','4','6','8'].indexOf(this.menuIndex) > -1 && this.dirList.length > 0) || (this.menuIndex == '7' && this.foundList2.length > 0)) {
 	            if (!authority.isAuthority && !flag) { // 非会员点击转换弹出提示框
 					if(this.menuIndex == '3' || this.menuIndex == '4'){
 						this.$refs.headerRef.tipsModal = true;
@@ -1874,9 +1876,40 @@ export default {
 					case '7':
 						this.foundFile(authority.isAuthority, size);
 						break;
+					case '8':
+						this.mergeFile(authority.isAuthority, size);
+						break;
 				}
 			}
 	    },
+		// 合并提取文件夹
+		mergeFile(authority, size){
+			if(!this.mergeData.newPath){ // 请选择保存位置
+				this.$notify({title: '提示', message: "请选择保存位置", type: 'warning'});
+				return false;
+			}
+			
+			for(let i=0;i < this.dirList.length; i++){
+				let item = this.dirList[i];
+				
+				fs.mkdir(this.mergeData.newPath + separator + item.name, (err) => {
+					if(err){
+						this.dirList[i].status = '5';
+						if(err.toString().indexOf('EBUSY') > -1){
+							this.$notify({title: '提示', message: "文件被占用,请关闭后重试!", type: 'warning'});
+							thisdirList[i].status = '3';
+						}else if(err.toString().indexOf('EXIST') > -1){
+							this.dirList[i].status = '2';
+						}
+					}else{
+						this.dirList[i].status = '2';
+					}
+				});
+			}
+			
+			
+		},
+		
 		// 提取文件、文件夹名称
 		extratFile(authority, size){
 			let nameCont = [];