From 7a1e1ec1b1cc1c6d5b37b0a5b00cef09309f4098 Mon Sep 17 00:00:00 2001
From: lichong <18518571399@163.com>
Date: Thu, 12 Dec 2024 19:07:06 +0800
Subject: [PATCH] 12.12
---
src/main/index.js | 3 -
src/renderer/index.html | 2 +-
src/renderer/src/App.vue | 4 +-
src/renderer/src/assets/css/base.css | 16 +-
src/renderer/src/assets/json/file.json | 69 +++----
.../src/components/tablecomponent.vue | 22 +-
src/renderer/src/components/treecomponent.vue | 22 +-
src/renderer/src/main.js | 2 +-
src/renderer/src/views/dangan.vue | 190 ++++++++++++------
9 files changed, 191 insertions(+), 139 deletions(-)
diff --git a/src/main/index.js b/src/main/index.js
index 86ca81c..601ccbb 100644
--- a/src/main/index.js
+++ b/src/main/index.js
@@ -186,9 +186,6 @@ app.whenReady().then(() => {
let sourceFilePath = element.prePath;
destinationFilePath = Buffer.from(destinationFilePath, 'utf8').toString('utf8');
sourceFilePath = Buffer.from(sourceFilePath, 'utf8').toString('utf8');
- // 读取文件大小
- let fileSize = fs.statSync(sourceFilePath).size;
- element.size = fileSize
try {
fs.copyFileSync(sourceFilePath, destinationFilePath);
successFileList.push(element)
diff --git a/src/renderer/index.html b/src/renderer/index.html
index b2c3adb..65109b0 100644
--- a/src/renderer/index.html
+++ b/src/renderer/index.html
@@ -3,7 +3,7 @@
- 档案管理
+ 海丰县不可移动文物四有资料管理系统
fiveDay) {
this.isVip = false
@@ -42,7 +42,7 @@ export default {
diff --git a/src/renderer/src/main.js b/src/renderer/src/main.js
index 35bac26..7e9f2ab 100644
--- a/src/renderer/src/main.js
+++ b/src/renderer/src/main.js
@@ -22,7 +22,7 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
}
app.use(ElementPlus, {
locale: zhCn,
- size:"large"
+ size:"default"
})
app.use(screenShort, { enableWebRtc: false, level: 300001, hiddenScrollBar: true }).use(VxeUI).use(VxeUITable)
app.mount('#app')
diff --git a/src/renderer/src/views/dangan.vue b/src/renderer/src/views/dangan.vue
index 9841387..69ac23b 100644
--- a/src/renderer/src/views/dangan.vue
+++ b/src/renderer/src/views/dangan.vue
@@ -1,11 +1,12 @@
+
海丰县不可移动文物四有资料管理系统
-
- 项目名:
+
+ 项目名
@@ -49,7 +50,7 @@
+ v-for="(statusItem, statusIndex) in statusList" :key="statusIndex">
@@ -59,7 +60,7 @@
-
+
@@ -73,7 +74,7 @@
文件名:
-
+
@@ -86,6 +87,12 @@
重置
+
+
+
+
+ 清空
+
@@ -93,7 +100,7 @@
- 导入历史数据
+ 导入数据
@@ -170,7 +177,7 @@ export default {
wenjianObj: {
wenjianName: "",
fileType: "",
- status: "",
+ status: "正常",
},
fileList: [
{
@@ -214,19 +221,16 @@ export default {
{
label: "全部",
color: "#409eff",
- class: "allClass",
value: "",
},
{
label: "正常",
color: "#67c23a",
- class: "normalClass",
value: "正常"
},
{
label: "已注销",
color: "#f56c6c",
- class: "unregisterClass",
value: "已注销"
},
],
@@ -300,16 +304,15 @@ export default {
let workbook = XLSX.read(data, { type: 'binary' })
let sheetName = workbook.SheetNames[0]
let sheetData = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName])
- let xiangmuObj = _.groupBy(sheetData, "项目名")
- let excludeList = ["123123", "test2222", "主卷"]
+ let xiangmuObj = _.groupBy(_.cloneDeep(sheetData), "项目名")
let xiangmuList = []
for (let key in xiangmuObj) {
- if (key && !excludeList.includes(key)) {
+ if (key) {
xiangmuList.push(key)
}
}
let { pathList, treeList } = that.bulkAddXiangmu(xiangmuList)
- let { tableList, successList } = that.bulkAddFile(treeList, sheetData)
+ let { tableList } = that.bulkAddFile(treeList, sheetData)
that.inputTreeList = _.cloneDeep(treeList)
that.inputTableList = _.cloneDeep(tableList)
that.inputPathList = _.cloneDeep(pathList)
@@ -380,8 +383,8 @@ export default {
// 批量新增文件
bulkAddFile(treeList, tableDataList) {
+ console.log(386, tableDataList);
let tableList = []
- let successList = []
for (let i = 0; i < tableDataList.length; i++) {
let fileItem = tableDataList[i];
let juanNameLIst = _.split(fileItem["文件名"], "·")
@@ -391,11 +394,12 @@ export default {
let chineseCharsOnly = pdfText.match(/[\u4e00-\u9fa5]+/g);
let juanName = chineseCharsOnly ? chineseCharsOnly.join('') : '';
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 treeItem2 = _.find(treeList, o => _.startsWith(o.path, `${fileItem["项目名"]}}`) && juanName.includes(o.label))
let path = _.split(fileItem["储存位置"], "_")
let fileType = _.find(this.fileList, o => o.label === path[1].split(".")[1])
let prepath = _.split(fileItem["储存位置"], "uploadPath/")
if (treeItem) {
- successList.push(i)
tableList.push({
treeId: treeItem.currentId,
pretreeId: treeItem.preId,
@@ -407,8 +411,44 @@ export default {
uploadTime: fileItem["上传时间"],
status: fileItem["状态"],
size: "",
- path: `D:\\test\\${fileItem["项目名"]}\\${fileItem["卷名"]}\\${juanName}\\${path[1]}`,
- prePath: `D:\\uploadPath\\${prepath[1].replaceAll("/", "\\")}`,
+ path: `D: \\test\\${fileItem["项目名"]}\\${fileItem["卷名"]}\\${juanName}\\${path[1]}`,
+ prePath: `D: \\uploadPath\\${prepath[1].replaceAll("/", "\\")}`,
+ note: fileItem["备注"],
+ create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
+ update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
+ })
+ } else if (treeItem1) {
+ tableList.push({
+ treeId: treeItem1.currentId,
+ pretreeId: treeItem1.preId,
+ prepretreeId: treeItem1.prepreId,
+ xiangmuName: fileItem["项目名"],
+ juanName: `${fileItem["卷名"]}`,
+ fileName: path[1],
+ fileType: (fileType || {}).value,
+ uploadTime: fileItem["上传时间"],
+ status: fileItem["状态"],
+ size: "",
+ path: `D: \\test\\${fileItem["项目名"]}\\${fileItem["卷名"]}\\${path[1]}`,
+ prePath: `D: \\uploadPath\\${prepath[1].replaceAll("/", "\\")}`,
+ note: fileItem["备注"],
+ create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
+ update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
+ })
+ } else if (treeItem2) {
+ tableList.push({
+ treeId: treeItem2.currentId,
+ pretreeId: treeItem2.preId,
+ prepretreeId: treeItem2.prepreId,
+ xiangmuName: fileItem["项目名"],
+ juanName: `${fileItem["卷名"]}_${juanName}`,
+ fileName: path[1],
+ fileType: (fileType || {}).value,
+ uploadTime: fileItem["上传时间"],
+ status: fileItem["状态"],
+ size: "",
+ path: `D: \\test\\${fileItem["项目名"]}\\${path[1]}`,
+ prePath: `D: \\uploadPath\\${prepath[1].replaceAll("/", "\\")}`,
note: fileItem["备注"],
create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
@@ -416,7 +456,7 @@ export default {
}
}
}
- return { tableList, successList }
+ return { tableList }
},
// inputData
async inputData(treeList, pathList, tableList) {
@@ -483,7 +523,8 @@ export default {
check: false,
})
}
- this.treeData = treeList
+
+ this.treeData = _.sortBy(treeList, "label")
await this.searchTable()
},
//搜索数据(表格)
@@ -577,7 +618,7 @@ export default {
//删除项目(树状)
async delxiangmu(node) {
ElMessageBox.confirm(
- `是否删除(${node.label})项目?同时删除项目时将删除下面的文件夹及文件?`,
+ `是否删除(${node.label})项目?同时删除项目时将删除下面的文件夹及文件 ? `,
'danger',
{
confirmButtonText: '确认',
@@ -629,7 +670,7 @@ export default {
"一级卷名": _.split(listItem.juanName, "_")[0],
"二级卷名": _.split(listItem.juanName, "_")[1],
"文件名": listItem.fileName,
- "文件路径": `D:\\test\\${listItem.path.replace("D:\\test\\", "")}`,
+ "文件路径": `D: \\test\\${listItem.path.replace("D:\\test\\", "")}`,
"文件类型": _.find(this.fileList, { value: listItem.fileType }).label,
"文件大小": this.genSize(listItem.size),
"文件状态": listItem.status,
@@ -663,18 +704,18 @@ export default {
}
let bytes = Number(num);
if (bytes >= 1024 ** 4) {
- return `${(bytes / 1024 ** 4).toFixed(2)}TB`;
+ return `${(bytes / 1024 ** 4).toFixed(2)} TB`;
}
if (bytes >= 1024 ** 3) {
- return `${(bytes / 1024 ** 3).toFixed(2)}GB`;
+ return `${(bytes / 1024 ** 3).toFixed(2)} GB`;
}
if (bytes >= 1024 ** 2) {
- return `${(bytes / 1024 ** 2).toFixed(2)}MB`;
+ return `${(bytes / 1024 ** 2).toFixed(2)} MB`;
}
if (bytes >= 1024) {
- return `${(bytes / 1024).toFixed(2)}KB`;
+ return `${(bytes / 1024).toFixed(2)} KB`;
}
- return `${bytes}B`;
+ return `${bytes} B`;
},
//新增文件
async addFile() {
@@ -687,13 +728,13 @@ export default {
let pathList = _.compact(_.split(this.treeNode.path, '\\'))
this.addFileForm = {
visible: true,
- title: `文件路径:D:\\${_.get(this.treeNode, 'path')}`,
+ title: `文件路径:D: \\${_.get(this.treeNode, 'path')} `,
disabled: false,
type: "add",
formHeader: this.formHeader,
formData: {
- xiangmuName: `${_.trim(pathList[0])}`,
- juanName: `${_.trim(pathList[1])}`,
+ xiangmuName: `${_.trim(pathList[0])} `,
+ juanName: `${_.trim(pathList[1])} `,
fileName: "",
fileLimit: 10000,
file: [],
@@ -713,6 +754,41 @@ export default {
this.treeNode = {}
await this.searchTable()
},
+ //清空
+ async clearAll() {
+ ElMessageBox.confirm(
+ '是否删除所有的护具,此操作不可逆,请谨慎操作!!!',
+ '警告',
+ {
+ confirmButtonText: '确认删除',
+ cancelButtonText: '取消',
+ type: 'error',
+ }
+ )
+ .then(async () => {
+ // 清空数据库
+ let db = await myDatabase.open();
+ // 获取所有表(对象存储)名称
+ let tableNames = db._storeNames
+ // 遍历并删除每个表及其数据
+ for (let index = 0; index < tableNames.length; index++) {
+ let tableName = tableNames[index];
+ await myDatabase[tableName].clear();
+ }
+ await this.searchTree()
+ ElMessage({
+ type: 'error',
+ message: '您已经删除数据库,数据全部清空了!!!',
+ })
+ })
+ .catch(() => {
+ ElMessage({
+ type: 'success',
+ message: '您取消删除数据库,数据仍然存在',
+ })
+ })
+
+ },
//预览
async viewFile(row) {
// 根据路径打开文件
@@ -722,7 +798,7 @@ export default {
async editFile(row) {
this.addFileForm = {
visible: true,
- title: `编辑文件:D:\\test\\${row.xiangmuName}\\${_.join(_.split(row.juanName, "_"), "\\")}\\${row.fileName}`,
+ title: `编辑文件:D: \\test\\${row.xiangmuName} \\${_.join(_.split(row.juanName, "_"), "\\")} \\${row.fileName} `,
disabled: false,
type: "put",
formHeader: this.formHeader,
@@ -740,8 +816,8 @@ export default {
name: row.fileName,
type: row.fileType,
size: row.size,
- path: `D:\\test\\${row.xiangmuName}\\${_.join(_.split(row.juanName, "_"), "\\")}\\${row.fileName}`,
- url: `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} `,
}
],
fileType: row.fileType,
@@ -797,16 +873,16 @@ export default {
let firstId = v5(xianmguName, this.uuidNameSpace)
for (let i = 0; i < this.level2.length; i++) {
let level2Item = this.level2[i];
- let level2Str = `${xianmguName}${level2Item}`
+ let level2Str = `${xianmguName}${level2Item} `
let level2uuid = v5(level2Str, this.uuidNameSpace)
for (let j = 0; j < this.level3[level2Item].length; j++) {
let level3Item = this.level3[level2Item][j];
- let level3Str = `${xianmguName}${level2Item}${level3Item}`
+ let level3Str = `${xianmguName}${level2Item}${level3Item} `
let level3uuid = v5(level3Str, this.uuidNameSpace)
treeList.push({
label: level3Item,
currentId: level3uuid,
- path: `${xianmguName}\\${level2Item}\\${level3Item}`,
+ path: `${xianmguName} \\${level2Item} \\${level3Item} `,
delete: false,
preId: level2uuid,
prepreId: firstId,
@@ -814,12 +890,12 @@ export default {
create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
})
- pathList.push(`${xianmguName}\\${level2Item}\\${level3Item}`)
+ pathList.push(`${xianmguName} \\${level2Item} \\${level3Item} `)
}
treeList.push({
label: level2Item,
currentId: level2uuid,
- path: `${xianmguName}\\${level2Item}`,
+ path: `${xianmguName} \\${level2Item} `,
delete: false,
preId: firstId,
prepreId: "",
@@ -831,7 +907,7 @@ export default {
treeList.push({
label: xianmguName,
currentId: firstId,
- path: `${xianmguName}`,
+ path: `${xianmguName} `,
delete: false,
preId: "",
prepreId: "",
@@ -849,7 +925,7 @@ export default {
await this.searchTree()
} catch (error) {
ElMessage({
- message: `${error}`,
+ message: `${error} `,
type: 'error',
})
}
@@ -865,7 +941,7 @@ export default {
id: level3Item.id,
label: level3Item.label,
currentId: level3Item.currentId,
- path: `${xianmguName}\\${level2Item.label}\\${level3Item.label}`,
+ path: `${xianmguName} \\${level2Item.label} \\${level3Item.label} `,
delete: false,
preId: level3Item.preId,
prepreId: level3Item.prepreId,
@@ -879,7 +955,7 @@ export default {
id: level2Item.id,
label: level2Item.label,
currentId: level2Item.currentId,
- path: `${xianmguName}\\${level2Item.label}`,
+ path: `${xianmguName} \\${level2Item.label} `,
delete: false,
preId: level2Item.preId,
prepreId: "",
@@ -893,7 +969,7 @@ export default {
id: preNodeTemp.id,
label: xianmguName,
currentId: preNodeTemp.currentId,
- path: `${xianmguName}`,
+ path: `${xianmguName} `,
delete: false,
preId: "",
prepreId: "",
@@ -916,7 +992,7 @@ export default {
await this.searchTree()
} catch (error) {
ElMessage({
- message: `${error}`,
+ message: `${error} `,
type: 'error',
})
}
@@ -948,13 +1024,13 @@ export default {
pretreeId: this.treeNode.preId,
prepretreeId: this.treeNode.prepreId,
xiangmuName: filePathList[0],
- juanName: `${filePathList[1]}${filePathList[2] ? "_" + filePathList[2] : ""}`,
+ juanName: `${filePathList[1]}${filePathList[2] ? "_" + filePathList[2] : ""} `,
fileName: fileItem.raw.name,
fileType: fileItem.raw.type,
uploadTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
status: "正常",
size: fileItem.raw.size,
- path: `${this.treeNode.path}\\${fileItem.raw.name}`,
+ path: `${this.treeNode.path} \\${fileItem.raw.name} `,
prePath: fileItem.raw.path,
note: this.addFileForm.formData.note,
create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
@@ -978,7 +1054,7 @@ export default {
uploadTime: formData.uploadTime,
status: formData.status,
size: _.get(formData.file, [0, "raw", "size"], _.get(formData.file, [0, "size"], "")),
- path: `${_.join(pathArr.splice(0, pathArr.length - 1), "\\")}\\${_.get(formData.file, [0, "raw", "name"], _.get(formData.file, [0, "name"], ""))}`,
+ path: `${_.join(pathArr.splice(0, pathArr.length - 1), "\\")} \\${_.get(formData.file, [0, "raw", "name"], _.get(formData.file, [0, "name"], ""))} `,
prePath: _.get(formData.file, [0, "raw", "path"], _.get(formData.file, [0, "path"], "")),
note: formData.note,
create_at: formData.create_at,
@@ -998,7 +1074,7 @@ export default {
let resObj = JSON.parse(res)
if (resObj.errorList.length) {
ElMessage({
- message: `文件夹${resObj.errorList.join(",")}创建失败`,
+ message: `文件夹${resObj.errorList.join(",")} 创建失败`,
type: 'error',
})
} else {
@@ -1027,7 +1103,7 @@ export default {
id: level3Item.id,
label: level3Item.label,
currentId: level3Item.currentId,
- path: `${resObj.errorList[0].oldPath}\\${level2Item}\\${level3Item}`,
+ path: `${resObj.errorList[0].oldPath} \\${level2Item} \\${level3Item} `,
delete: false,
preId: level3Item.preId,
prepreId: level3Item.prepreId,
@@ -1041,7 +1117,7 @@ export default {
id: level2Item.id,
label: level2Item.label,
currentId: level2Item.currentId,
- path: `${resObj.errorList[0].oldPath}\\${level2Item.label}`,
+ path: `${resObj.errorList[0].oldPath} \\${level2Item.label} `,
delete: false,
preId: level2Item.preId,
prepreId: "",
@@ -1055,7 +1131,7 @@ export default {
id: preNodeTemp.id,
label: resObj.errorList[0].oldPath,
currentId: preNodeTemp.currentId,
- path: `${resObj.errorList[0].oldPath}`,
+ path: `${resObj.errorList[0].oldPath} `,
delete: false,
preId: "",
prepreId: "",
@@ -1073,7 +1149,7 @@ export default {
that.searchTree()
// 成功以后更新文件的路径
let collection = myDatabase.fileList
- collection = collection.filter((equip) => _.startsWith(equip.path, `${preNodeTemp.label}\\`))
+ collection = collection.filter((equip) => _.startsWith(equip.path, `${preNodeTemp.label} \\`))
let fileList = await collection.toArray()
for (let index = 0; index < fileList.length; index++) {
let fileItem = fileList[index];
@@ -1092,12 +1168,12 @@ export default {
let resObj = JSON.parse(res)
if (resObj.errorList.length) {
ElMessage({
- message: `文件夹${resObj.errorList[0].name}删除失败`,
+ message: `文件夹${resObj.errorList[0].name} 删除失败`,
type: 'error',
})
} else {
ElMessage({
- message: `文件夹${resObj.successList[0].name}删除成功`,
+ message: `文件夹${resObj.successList[0].name} 删除成功`,
type: 'success',
})
await myDatabase.treeList.bulkDelete(that.deleteXiangmuIdList)
@@ -1125,7 +1201,7 @@ export default {
errorList.push(element.fileName)
}
ElMessage({
- message: `${resObj.errorList[0].xiangmuName}项目下${resObj.errorList[0].juanName}卷下新增文件${_.join(errorList, ",")}失败`,
+ message: `${resObj.errorList[0].xiangmuName}项目下${resObj.errorList[0].juanName}卷下新增文件${_.join(errorList, ",")} 失败`,
type: 'error',
})
} else {
@@ -1135,7 +1211,7 @@ export default {
successList.push(element.fileName)
}
ElMessage({
- message: `${resObj.successList[0].xiangmuName}项目下${resObj.successList[0].juanName}卷下新增文件${_.join(successList, ",")}成功`,
+ message: `${resObj.successList[0].xiangmuName}项目下${resObj.successList[0].juanName}卷下新增文件${_.join(successList, ",")} 成功`,
type: 'success',
})
that.searchTable()
@@ -1145,7 +1221,7 @@ export default {
window.electron.ipcRenderer.on('downloadFileResult', async (eve, result) => {
if (!result.success) {
ElMessage({
- message: `文件下载失败${result.error}`,
+ message: `文件下载失败${result.error} `,
type: 'error',
});
return;