|
@@ -51,7 +51,7 @@
|
|
|
<div class="table-scroll">
|
|
|
<vxe-table ref="xTable"
|
|
|
show-overflow class="img-table" max-height="100%" empty-text="没有更多数据了!" :loading="tabLoading"
|
|
|
- :loading-config="{icon: 'vxe-icon-indicator roll', text: '文件加载中...'}" :row-config="{isHover: true}"
|
|
|
+ :loading-config="{icon: 'vxe-icon-indicator roll', text: '任务处理中...'}" :row-config="{isHover: true}"
|
|
|
:edit-config="{trigger: 'click', mode: 'cell'}" :data="fileList" :scroll-y="{enabled: true}">
|
|
|
<vxe-column type="seq" width="60" title="编号"></vxe-column>
|
|
|
<vxe-column field="match" title="匹配词" width="150"></vxe-column>
|
|
@@ -124,8 +124,6 @@
|
|
|
<el-button type="danger" style="position: absolute; top: 40px; right: 10px;" @click="exportFile()" :loading="exportLoading">开始处理</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
-
|
|
|
-
|
|
|
</div>
|
|
|
|
|
|
</el-main>
|
|
@@ -166,7 +164,6 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- test: 0,
|
|
|
imgUrl: this.$api.imgUrl,
|
|
|
menuIndex: '1', // 重命名类型 1 or 2
|
|
|
fileList: [], // 文件列表
|
|
@@ -186,6 +183,7 @@ export default {
|
|
|
|
|
|
dowloadModel: false,
|
|
|
finishModel: false,
|
|
|
+ loadingModal: false,
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
@@ -208,6 +206,8 @@ export default {
|
|
|
shell.openExternal(url);
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ this.loadingModal = true;
|
|
|
},
|
|
|
methods: {
|
|
|
// 选择导出目录
|
|
@@ -345,7 +345,7 @@ export default {
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
- console.log('----验证规则----', ruleStr);
|
|
|
+ //console.log('----验证规则----', ruleStr);
|
|
|
try{
|
|
|
const files = await fg(ruleStr, { dot: true });
|
|
|
let regExp = new RegExp(paramArr.join('|'));
|
|
@@ -397,7 +397,7 @@ export default {
|
|
|
|
|
|
let size = 999999999;
|
|
|
if(!authority.isAuthority){
|
|
|
- size = 999999;
|
|
|
+ size = 99999;
|
|
|
}
|
|
|
|
|
|
if(!fs.existsSync(this.downloadDir + separator + pjson.softInfo.softName)){
|
|
@@ -405,42 +405,57 @@ export default {
|
|
|
}
|
|
|
let newPath = this.downloadDir + separator + pjson.softInfo.softName;
|
|
|
|
|
|
+ if(this.handleData.type == '4' && !this.coverFile){
|
|
|
+ this.$notify.error({
|
|
|
+ title: '提示',
|
|
|
+ message: '请选择覆盖文件后再操作'
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.tabLoading = true;
|
|
|
+
|
|
|
setTimeout(() => {
|
|
|
for(let i = 0; i < this.fileList.length; i++){
|
|
|
if(i < size){
|
|
|
let item = this.fileList[i];
|
|
|
let newFilePath = newPath + separator + item.name;
|
|
|
- console.log(i, new Date().getTime());
|
|
|
- // if(fse.existsSync(newFilePath)){
|
|
|
- // newFilePath = newPath + separator + item.title + '重复' + new Date().getTime() + i + item.suffix;
|
|
|
- // }
|
|
|
try {
|
|
|
if(this.handleData.type == '1'){ // 复制
|
|
|
- //fse.copySync(item.path, newFilePath);
|
|
|
- //item.status = '2';
|
|
|
- fse.copy(item.path, newFilePath, {overwrite: false, errorOnExist: true}).then(() => {
|
|
|
- console.log('复制成功!')
|
|
|
+ try{
|
|
|
+ fse.copySync(item.path, newFilePath, { overwrite: false, errorOnExist: true });
|
|
|
item.status = '2';
|
|
|
- }).catch(err => {
|
|
|
- let str = err.toString();
|
|
|
- console.error('复制失败', err.toString(), item.path)
|
|
|
+ }catch(e){
|
|
|
+ let str = e.toString();
|
|
|
if(str.indexOf('already exists') > -1 && str.indexOf(item.name) > -1){
|
|
|
- console.log('重新复制')
|
|
|
- // newFilePath = newPath + separator + item.title + '重复' + uuidv4() + i.toString() + item.suffix;
|
|
|
+ newFilePath = newPath + separator + item.title + '重复文件' + uuidv4().substr(0, 18) + i.toString() + item.suffix;
|
|
|
+ fse.copy(item.path, newFilePath).then(() => {
|
|
|
+ item.status = '2';
|
|
|
+ }).catch(err => {
|
|
|
+ item.status = '6';
|
|
|
+ })
|
|
|
}
|
|
|
- item.status = '6';
|
|
|
- })
|
|
|
-
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if(this.handleData.type == '2'){ // 剪切
|
|
|
- fse.moveSync(item.path, newFilePath);
|
|
|
- item.status = '3'
|
|
|
+ try{
|
|
|
+ fse.moveSync(item.path, newFilePath);
|
|
|
+ item.status = '3'
|
|
|
+ }catch(e){
|
|
|
+ let str = e.toString();
|
|
|
+ if(str.indexOf('already exists') > -1){
|
|
|
+ newFilePath = newPath + separator + item.title + '重复文件' + uuidv4().substr(0, 18) + i.toString() + item.suffix;
|
|
|
+ fse.move(item.path, newFilePath).then(() => {
|
|
|
+ item.status = '3';
|
|
|
+ }).catch(err => {
|
|
|
+ item.status = '6';
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if(this.handleData.type == '3'){ // 删除
|
|
|
- // fse.removeSync(item.path);
|
|
|
- // item.status = '4'
|
|
|
//异步
|
|
|
fse.remove(item.path).then(() => {
|
|
|
item.status = '4';
|
|
@@ -450,6 +465,16 @@ export default {
|
|
|
}
|
|
|
|
|
|
if(this.handleData.type == '4'){ // 覆盖
|
|
|
+ let filename = this.coverFile.substr(this.coverFile.lastIndexOf('\\')+1);
|
|
|
+ if(filename == item.name){
|
|
|
+ fse.copy(this.coverFile, item.path).then(() => {
|
|
|
+ item.status = '2';
|
|
|
+ }).catch(err => {
|
|
|
+ item.status = '6';
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ item.status = '6';
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -457,11 +482,19 @@ export default {
|
|
|
console.error(err);
|
|
|
item.status = '6';
|
|
|
}
|
|
|
+
|
|
|
+ this.nums++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- console.log('end', new Date().getTime());
|
|
|
}, 100);
|
|
|
+
|
|
|
+ // let delay = 500;
|
|
|
+ // this.fileList.length / 500
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ this.tabLoading = false;
|
|
|
+ }, 5000)
|
|
|
|
|
|
}
|
|
|
},
|