Browse Source

12.12

master
lichong 1 week ago
parent
commit
3802b656ab
  1. 8
      src/main/index.js
  2. 78
      src/renderer/src/views/dangan.vue

8
src/main/index.js

@ -142,6 +142,12 @@ app.whenReady().then(() => {
let paramsObj = JSON.parse(paramsStr) let paramsObj = JSON.parse(paramsStr)
mainWindow.webContents.send(`delFileResult`, paramsObj) mainWindow.webContents.send(`delFileResult`, paramsObj)
}) })
// 删除所有文件
ipcMain.on('deleteFolder', (e, paramsStr) => {
try {
fs.rmdirSync(paramsStr, { recursive: true })
} catch (e) { }
})
// 打开文件 // 打开文件
ipcMain.on('openFile', (e, pathStr) => { ipcMain.on('openFile', (e, pathStr) => {
let filePath = path.join("D:\\test\\", pathStr.replace("D:\\test\\", "")); let filePath = path.join("D:\\test\\", pathStr.replace("D:\\test\\", ""));
@ -168,7 +174,7 @@ app.whenReady().then(() => {
let errorFolderList = [] let errorFolderList = []
for (let index = 0; index < pathList.length; index++) { for (let index = 0; index < pathList.length; index++) {
let element = pathList[index]; let element = pathList[index];
let folderPath = path.join("D:\\test\\", element); let folderPath = path.join("D:\\test\\", element.replace("D:\\test\\", ""));
folderPath = Buffer.from(folderPath, 'utf8').toString('utf8'); folderPath = Buffer.from(folderPath, 'utf8').toString('utf8');
try { try {
fs.mkdirSync(`${folderPath}\\`, { recursive: true }); fs.mkdirSync(`${folderPath}\\`, { recursive: true });

78
src/renderer/src/views/dangan.vue

@ -311,6 +311,7 @@ export default {
xiangmuList.push(key) xiangmuList.push(key)
} }
} }
xiangmuList = _.sortBy(xiangmuList)
let { pathList, treeList } = that.bulkAddXiangmu(xiangmuList) let { pathList, treeList } = that.bulkAddXiangmu(xiangmuList)
let { tableList } = that.bulkAddFile(treeList, sheetData) let { tableList } = that.bulkAddFile(treeList, sheetData)
that.inputTreeList = _.cloneDeep(treeList) that.inputTreeList = _.cloneDeep(treeList)
@ -383,11 +384,13 @@ export default {
// //
bulkAddFile(treeList, tableDataList) { bulkAddFile(treeList, tableDataList) {
console.log(386, tableDataList);
let tableList = [] let tableList = []
for (let i = 0; i < tableDataList.length; i++) { for (let i = 0; i < tableDataList.length; i++) {
let fileItem = tableDataList[i]; let fileItem = tableDataList[i];
let juanNameLIst = _.split(fileItem["文件名"], "·") let fileNameTemp = fileItem["文件名"].replaceAll(" ", "")
let juanNameLIst = _.split(fileNameTemp, "·")
let juanNameLIstTemp = _.cloneDeep(juanNameLIst)
juanNameLIstTemp.splice(juanNameLIstTemp.length - 1, 0, i)
if (juanNameLIst) { if (juanNameLIst) {
let pdfText = juanNameLIst[juanNameLIst.length - 1]; let pdfText = juanNameLIst[juanNameLIst.length - 1];
// 使 // 使
@ -395,7 +398,13 @@ export default {
let juanName = chineseCharsOnly ? chineseCharsOnly.join('') : ''; let juanName = chineseCharsOnly ? chineseCharsOnly.join('') : '';
let treeItem = _.find(treeList, o => o.path === `${fileItem["项目名"]}\\${fileItem["卷名"]}\\${juanName}`) let treeItem = _.find(treeList, o => o.path === `${fileItem["项目名"]}\\${fileItem["卷名"]}\\${juanName}`)
let treeItem1 = _.find(treeList, o => _.startsWith(o.path, `${fileItem["项目名"]}\\${fileItem["卷名"]}`) && juanName.includes(o.label)) let treeItem1 = _.find(treeList, o => _.startsWith(o.path, `${fileItem["项目名"]}\\${fileItem["卷名"]}`) && juanName.includes(o.label))
if (!treeItem1) {
treeItem1 = _.find(treeList, o => _.startsWith(o.path, `${fileItem["项目名"]}\\${fileItem["卷名"]}`))
}
let treeItem2 = _.find(treeList, o => _.startsWith(o.path, `${fileItem["项目名"]}}`) && juanName.includes(o.label)) let treeItem2 = _.find(treeList, o => _.startsWith(o.path, `${fileItem["项目名"]}}`) && juanName.includes(o.label))
if (!treeItem2) {
treeItem2 = _.find(treeList, o => _.startsWith(o.path, `${fileItem["项目名"]}}`))
}
let path = _.split(fileItem["储存位置"], "_") let path = _.split(fileItem["储存位置"], "_")
let fileType = _.find(this.fileList, o => o.label === path[1].split(".")[1]) let fileType = _.find(this.fileList, o => o.label === path[1].split(".")[1])
let prepath = _.split(fileItem["储存位置"], "uploadPath/") let prepath = _.split(fileItem["储存位置"], "uploadPath/")
@ -406,13 +415,13 @@ export default {
prepretreeId: treeItem.prepreId, prepretreeId: treeItem.prepreId,
xiangmuName: fileItem["项目名"], xiangmuName: fileItem["项目名"],
juanName: `${fileItem["卷名"]}_${juanName}`, juanName: `${fileItem["卷名"]}_${juanName}`,
fileName: path[1], fileName: fileNameTemp,
fileType: (fileType || {}).value, fileType: (fileType || {}).value,
uploadTime: fileItem["上传时间"], uploadTime: fileItem["上传时间"],
status: fileItem["状态"], status: fileItem["状态"],
size: "", size: "",
path: `D: \\test\\${fileItem["项目名"]}\\${fileItem["卷名"]}\\${juanName}\\${path[1]}`, path: `D:\\test\\${fileItem["项目名"]}\\${fileItem["卷名"]}\\${juanName}\\${_.join(juanNameLIstTemp, ".")}`,
prePath: `D: \\uploadPath\\${prepath[1].replaceAll("/", "\\")}`, prePath: `D:\\uploadPath\\${prepath[1].replaceAll("/", "\\")}`,
note: fileItem["备注"], note: fileItem["备注"],
create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
@ -424,13 +433,13 @@ export default {
prepretreeId: treeItem1.prepreId, prepretreeId: treeItem1.prepreId,
xiangmuName: fileItem["项目名"], xiangmuName: fileItem["项目名"],
juanName: `${fileItem["卷名"]}`, juanName: `${fileItem["卷名"]}`,
fileName: path[1], fileName: fileNameTemp,
fileType: (fileType || {}).value, fileType: (fileType || {}).value,
uploadTime: fileItem["上传时间"], uploadTime: fileItem["上传时间"],
status: fileItem["状态"], status: fileItem["状态"],
size: "", size: "",
path: `D: \\test\\${fileItem["项目名"]}\\${fileItem["卷名"]}\\${path[1]}`, path: `D:\\test\\${fileItem["项目名"]}\\${fileItem["卷名"]}\\${_.join(juanNameLIstTemp, ".")}`,
prePath: `D: \\uploadPath\\${prepath[1].replaceAll("/", "\\")}`, prePath: `D:\\uploadPath\\${prepath[1].replaceAll("/", "\\")}`,
note: fileItem["备注"], note: fileItem["备注"],
create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
@ -442,13 +451,13 @@ export default {
prepretreeId: treeItem2.prepreId, prepretreeId: treeItem2.prepreId,
xiangmuName: fileItem["项目名"], xiangmuName: fileItem["项目名"],
juanName: `${fileItem["卷名"]}_${juanName}`, juanName: `${fileItem["卷名"]}_${juanName}`,
fileName: path[1], fileName: fileNameTemp,
fileType: (fileType || {}).value, fileType: (fileType || {}).value,
uploadTime: fileItem["上传时间"], uploadTime: fileItem["上传时间"],
status: fileItem["状态"], status: fileItem["状态"],
size: "", size: "",
path: `D: \\test\\${fileItem["项目名"]}\\${path[1]}`, path: `D:\\test\\${fileItem["项目名"]}\\${_.join(juanNameLIstTemp, ".")}`,
prePath: `D: \\uploadPath\\${prepath[1].replaceAll("/", "\\")}`, prePath: `D:\\uploadPath\\${prepath[1].replaceAll("/", "\\")}`,
note: fileItem["备注"], note: fileItem["备注"],
create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
@ -670,7 +679,7 @@ export default {
"一级卷名": _.split(listItem.juanName, "_")[0], "一级卷名": _.split(listItem.juanName, "_")[0],
"二级卷名": _.split(listItem.juanName, "_")[1], "二级卷名": _.split(listItem.juanName, "_")[1],
"文件名": listItem.fileName, "文件名": listItem.fileName,
"文件路径": `D: \\test\\${listItem.path.replace("D:\\test\\", "")}`, "文件路径": `D:\\test\\${listItem.path.replace("D:\\test\\", "")}`,
"文件类型": _.find(this.fileList, { value: listItem.fileType }).label, "文件类型": _.find(this.fileList, { value: listItem.fileType }).label,
"文件大小": this.genSize(listItem.size), "文件大小": this.genSize(listItem.size),
"文件状态": listItem.status, "文件状态": listItem.status,
@ -764,29 +773,28 @@ export default {
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'error', type: 'error',
} }
) ).then(async () => {
.then(async () => { //
// let db = await myDatabase.open();
let db = await myDatabase.open(); //
// let tableNames = db._storeNames
let tableNames = db._storeNames //
// for (let index = 0; index < tableNames.length; index++) {
for (let index = 0; index < tableNames.length; index++) { let tableName = tableNames[index];
let tableName = tableNames[index]; await myDatabase[tableName].clear();
await myDatabase[tableName].clear(); }
} window.electron.ipcRenderer.send('deleteFolder', "D:\\test")
await this.searchTree() await this.searchTree()
ElMessage({ ElMessage({
type: 'error', type: 'error',
message: '您已经删除数据库,数据全部清空了!!!', message: '您已经删除数据库,数据全部清空了!!!',
})
}) })
.catch(() => { }).catch(() => {
ElMessage({ ElMessage({
type: 'success', type: 'success',
message: '您取消删除数据库,数据仍然存在', message: '您取消删除数据库,数据仍然存在',
})
}) })
})
}, },
// //
@ -816,8 +824,8 @@ export default {
name: row.fileName, name: row.fileName,
type: row.fileType, type: row.fileType,
size: row.size, size: row.size,
path: `D: \\test\\${row.xiangmuName} \\${_.join(_.split(row.juanName, "_"), "\\")} \\${row.fileName} `, path: `D:\\test\\${row.xiangmuName} \\${_.join(_.split(row.juanName, "_"), "\\")} \\${row.fileName} `,
url: `D: \\test\\${row.xiangmuName} \\${_.join(_.split(row.juanName, "_"), "\\")} \\${row.fileName} `, url: `D:\\test\\${row.xiangmuName} \\${_.join(_.split(row.juanName, "_"), "\\")} \\${row.fileName} `,
} }
], ],
fileType: row.fileType, fileType: row.fileType,

Loading…
Cancel
Save