Browse Source

12.12

master
lichong 1 week ago
parent
commit
7a1e1ec1b1
  1. 3
      src/main/index.js
  2. 2
      src/renderer/index.html
  3. 4
      src/renderer/src/App.vue
  4. 16
      src/renderer/src/assets/css/base.css
  5. 69
      src/renderer/src/assets/json/file.json
  6. 22
      src/renderer/src/components/tablecomponent.vue
  7. 22
      src/renderer/src/components/treecomponent.vue
  8. 2
      src/renderer/src/main.js
  9. 190
      src/renderer/src/views/dangan.vue

3
src/main/index.js

@ -186,9 +186,6 @@ app.whenReady().then(() => {
let sourceFilePath = element.prePath; let sourceFilePath = element.prePath;
destinationFilePath = Buffer.from(destinationFilePath, 'utf8').toString('utf8'); destinationFilePath = Buffer.from(destinationFilePath, 'utf8').toString('utf8');
sourceFilePath = Buffer.from(sourceFilePath, 'utf8').toString('utf8'); sourceFilePath = Buffer.from(sourceFilePath, 'utf8').toString('utf8');
// 读取文件大小
let fileSize = fs.statSync(sourceFilePath).size;
element.size = fileSize
try { try {
fs.copyFileSync(sourceFilePath, destinationFilePath); fs.copyFileSync(sourceFilePath, destinationFilePath);
successFileList.push(element) successFileList.push(element)

2
src/renderer/index.html

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<title>档案管理</title> <title>海丰县不可移动文物四有资料管理系统</title>
<!-- <link rel="icon" href="/icon/icon.jpg" /> --> <!-- <link rel="icon" href="/icon/icon.jpg" /> -->
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP --> <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" <meta http-equiv="Content-Security-Policy"

4
src/renderer/src/App.vue

@ -27,7 +27,7 @@ export default {
computed: {}, computed: {},
methods: {}, methods: {},
async mounted() { async mounted() {
let fiveDay = dayjs('2024-12-14T00:00:00').valueOf() let fiveDay = dayjs('2024-12-18T00:00:00').valueOf()
if (!this.isVip) { if (!this.isVip) {
if (dayjs().valueOf() > fiveDay) { if (dayjs().valueOf() > fiveDay) {
this.isVip = false this.isVip = false
@ -42,7 +42,7 @@ export default {
</script> </script>
<style scoped> <style scoped>
.appClass { .appClass {
width: calc(100vw - 10px); width: calc(100vw - 27px);
height: calc(100vh - 40px); height: calc(100vh - 40px);
position: relative; position: relative;
} }

16
src/renderer/src/assets/css/base.css

@ -4,20 +4,6 @@ body {
padding: 0; padding: 0;
} }
.allClass.is-active .el-radio-button__inner { .el-form-item {
background-color: #409eff !important;
border: 1px solid #409eff !important;
}
.normalClass.is-active .el-radio-button__inner {
background-color: #67c23a !important;
border: 1px solid #67c23a !important;
}
.unregisterClass.is-active .el-radio-button__inner {
background-color: #f56c6c !important;
border: 1px solid #f56c6c !important;
}
.el-form-item{
margin-bottom: 0 !important; margin-bottom: 0 !important;
} }

69
src/renderer/src/assets/json/file.json

@ -1,17 +1,4 @@
[ [
{
"label": "项目名",
"prop": "xiangmuName",
"type": "text",
"tableShow": true,
"export": true
},
{
"label": "卷名",
"prop": "juanName",
"type": "text",
"export": true
},
{ {
"label": "文件名", "label": "文件名",
"prop": "fileName", "prop": "fileName",
@ -22,23 +9,7 @@
"export": true "export": true
}, },
{ {
"label": "文件", "label": "类型",
"prop": "file",
"type": "file",
"tableShow": false,
"formShow": true,
"export": false
},
{
"label": "文件大小",
"prop": "size",
"type": "size",
"tableShow": true,
"formShow": false,
"export": false
},
{
"label": "文件类型",
"prop": "fileType", "prop": "fileType",
"type": "select", "type": "select",
"tooltip": "如果不填写则默认使用上传文件的文件类型,如果填写请正确填写", "tooltip": "如果不填写则默认使用上传文件的文件类型,如果填写请正确填写",
@ -88,6 +59,14 @@
"formShow": true, "formShow": true,
"export": true "export": true
}, },
{
"label": "存储位置",
"prop": "path",
"type": "text",
"tableShow": true,
"formShow": false,
"export": true
},
{ {
"label": "状态", "label": "状态",
"prop": "status", "prop": "status",
@ -111,13 +90,35 @@
"export": true "export": true
}, },
{ {
"label": "存储位置", "label": "项目名",
"prop": "path", "prop": "xiangmuName",
"type": "text", "type": "text",
"tableShow": true, "tableShow": false,
"formShow": false, "export": true
},
{
"label": "卷名",
"prop": "juanName",
"type": "text",
"tableShow": false,
"export": true "export": true
}, },
{
"label": "文件",
"prop": "file",
"type": "file",
"tableShow": false,
"formShow": true,
"export": false
},
{
"label": "文件大小",
"prop": "size",
"type": "size",
"tableShow": false,
"formShow": false,
"export": false
},
{ {
"label": "备注", "label": "备注",
"prop": "note", "prop": "note",

22
src/renderer/src/components/tablecomponent.vue

@ -26,31 +26,31 @@
</template> </template>
</vxe-column> </vxe-column>
</template> </template>
<vxe-column fixed="right" title="操作" width="200"> <vxe-column fixed="right" title="操作" width="260">
<template #default="{ row }"> <template #default="{ row }">
<el-button type="primary" text @click="optClick(row, 'view')" size="small" style="padding: 5px;"> <el-button type="primary" text @click="optClick(row, 'view')" size="small" style="padding: 5px;">
<!-- <el-icon> <el-icon>
<View /> <View />
</el-icon> --> </el-icon>
<span>预览</span> <span>预览</span>
</el-button> </el-button>
<el-button type="primary" text @click="optClick(row, 'edit')" size="small" style="padding: 5px;"> <el-button type="primary" text @click="optClick(row, 'edit')" size="small" style="padding: 5px;">
<!-- <el-icon> <el-icon>
<EditPen /> <EditPen />
</el-icon> --> </el-icon>
<span>修改</span> <span>修改</span>
</el-button> </el-button>
<el-button :type="row.status === '正常' ? 'primary' : 'success'" text @click="optClick(row, 'unregister')" <el-button :type="row.status === '正常' ? 'primary' : 'success'" text @click="optClick(row, 'unregister')"
size="small" style="padding: 5px;"> size="small" style="padding: 5px;color:#ff0000">
<!-- <el-icon> <el-icon>
<Delete /> <Delete />
</el-icon> --> </el-icon>
<span>{{ row.status === "正常" ? "注销" : "正常" }}</span> <span>{{ row.status === "正常" ? "注销" : "正常" }}</span>
</el-button> </el-button>
<el-button type="primary" text @click="optClick(row, 'download')" size="small" style="padding: 5px;"> <el-button type="primary" text @click="optClick(row, 'download')" size="small" style="padding: 5px;">
<!-- <el-icon> <el-icon>
<Download /> <Download />
</el-icon> --> </el-icon>
<span>下载</span> <span>下载</span>
</el-button> </el-button>
</template> </template>
@ -121,7 +121,7 @@ export default {
</script> </script>
<style scoped> <style scoped>
.tableClass { .tableClass {
height: calc(100vh - 152px); height: calc(100vh - 220px);
text-align: center; text-align: center;
text-align-last: center; text-align-last: center;
} }

22
src/renderer/src/components/treecomponent.vue

@ -1,22 +1,21 @@
<template> <template>
<div class="treeClass bgColor"> <div class="treeClass bgColor">
<el-auto-resizer style="height: calc(100vh - 70px);"> <el-auto-resizer style="height: calc(100vh - 160px);">
<template #default="{ height, width }"> <template #default="{ height, width }">
<el-tree-v2 :data="treeData" :props="treeProps" class="bgColor" @node-click="nodeClick" ref="treeRef" <el-tree-v2 :data="treeData" :props="treeProps" class="bgColor" @node-click="nodeClick" ref="treeRef"
:height="height" :expand-on-click-node="true"> :height="height" :expand-on-click-node="true">
<template #default="{ node }"> <template #default="{ node }">
<div style="width: 100%;text-align-last:left;" :class="node.data.id === nodeClickId ? 'selectedNode' : ''"> <div style="width: 100%;text-align-last:left;">
<el-tooltip effect="dark" :content="node.label" placement="right" v-if="node.label.length > textLength"> <el-tooltip effect="dark" :content="node.label" placement="right" v-if="node.label.length > textLength">
<span>{{ node.label.slice(0, textLength) }}...</span> <span>{{ node.label.slice(0, textLength) }}...</span>
</el-tooltip> </el-tooltip>
<span v-else>{{ node.label }}</span> <span v-else>{{ node.label }}</span>
<!-- <span>{{ node.label }}</span> --> <!-- <span>{{ node.label }}</span> -->
<span style="position: absolute;right: 8px;" v-if="node.level === 1"> <span v-if="node.level === 1">
<el-button :type="node.data.id === nodeClickId ? 'success' : 'primary'" link <el-button link style="color:#56abfa" @click="e => editxiangmu(e, node)">
@click="e => editxiangmu(e, node)"> 修改
编辑
</el-button> </el-button>
<el-button type="danger" link @click="e => delxiangmu(e, node)"> <el-button style="color:#ff0000" link @click="e => delxiangmu(e, node)">
删除 删除
</el-button> </el-button>
</span> </span>
@ -100,7 +99,6 @@ export default {
} }
}, },
async mounted() { async mounted() {
console.log(103, window.innerHeight);
window.onresize = () => { window.onresize = () => {
let width = document.getElementsByClassName("treeClass")[0].clientWidth let width = document.getElementsByClassName("treeClass")[0].clientWidth
this.textLength = Math.floor((width - 310) / 15) + 14 this.textLength = Math.floor((width - 310) / 15) + 14
@ -112,7 +110,7 @@ export default {
</script> </script>
<style scoped> <style scoped>
.treeClass { .treeClass {
height: calc(100vh - 70px); height: calc(100vh - 137px);
margin-left: 8px; margin-left: 8px;
text-align: center; text-align: center;
text-align-last: center; text-align-last: center;
@ -122,10 +120,4 @@ export default {
background-color: #ccc; background-color: #ccc;
border-radius: 8px; border-radius: 8px;
} }
.selectedNode {
background-color: #409eff;
color: #fff;
border-radius: 8px;
}
</style> </style>

2
src/renderer/src/main.js

@ -22,7 +22,7 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
} }
app.use(ElementPlus, { app.use(ElementPlus, {
locale: zhCn, locale: zhCn,
size:"large" size:"default"
}) })
app.use(screenShort, { enableWebRtc: false, level: 300001, hiddenScrollBar: true }).use(VxeUI).use(VxeUITable) app.use(screenShort, { enableWebRtc: false, level: 300001, hiddenScrollBar: true }).use(VxeUI).use(VxeUITable)
app.mount('#app') app.mount('#app')

190
src/renderer/src/views/dangan.vue

@ -1,11 +1,12 @@
<template> <template>
<div class="rightClass"> <div class="rightClass">
<h1 style="text-align: center;font-weight: 500;">海丰县不可移动文物四有资料管理系统</h1>
<div style="margin: 0 0 8px 8px;"> <div style="margin: 0 0 8px 8px;">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col> <el-col>
<div style="width: calc(100vw - 400px);display: inline-block;margin-right: 12px;"> <div style="width: calc(100vw - 400px);display: inline-block;margin-right: 12px;">
<el-input v-model="xiangmuObj.xianmguName" placeholder="请输入项目名" clearable> <el-input v-model="xiangmuObj.xianmguName" placeholder="请输入" clearable>
<template #prepend>项目名</template> <template #prepend>项目名</template>
</el-input> </el-input>
</div> </div>
<el-button type="primary" @click="clearAndSearchTree"> <el-button type="primary" @click="clearAndSearchTree">
@ -49,7 +50,7 @@
<el-form-item label="状态:"> <el-form-item label="状态:">
<el-radio-group v-model="wenjianObj.status" style="display: inline-block;"> <el-radio-group v-model="wenjianObj.status" style="display: inline-block;">
<el-radio-button :label="statusItem.label" :value="statusItem.value" <el-radio-button :label="statusItem.label" :value="statusItem.value"
v-for="(statusItem, statusIndex) in statusList" :key="statusIndex" :class="`${statusItem.class}`"> v-for="(statusItem, statusIndex) in statusList" :key="statusIndex">
</el-radio-button> </el-radio-button>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
@ -59,7 +60,7 @@
</div> </div>
<div style="margin-bottom: 8px;"> <div style="margin-bottom: 8px;">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="4"> <el-col :span="3">
<!-- <el-button type="primary" plain @click="addFile" :disabled="_.get(treeNode, 'level') !== 3"> --> <!-- <el-button type="primary" plain @click="addFile" :disabled="_.get(treeNode, 'level') !== 3"> -->
<el-button type="primary" plain @click="addFile" :disabled="[1].includes(_.get(treeNode, 'level', 1))"> <el-button type="primary" plain @click="addFile" :disabled="[1].includes(_.get(treeNode, 'level', 1))">
<el-icon> <el-icon>
@ -73,7 +74,7 @@
<template #prepend>文件名</template> <template #prepend>文件名</template>
</el-input> </el-input>
</el-col> </el-col>
<el-col :span="9" style="position: relative;top:-3px;"> <el-col :span="10" style="position: relative;top:-3px;">
<el-button type="primary" @click="searchTable"> <el-button type="primary" @click="searchTable">
<el-icon> <el-icon>
<Search /> <Search />
@ -86,6 +87,12 @@
</el-icon> </el-icon>
<span>重置</span> <span>重置</span>
</el-button> </el-button>
<el-button @click="clearAll" type="danger">
<el-icon>
<Delete />
</el-icon>
<span>清空</span>
</el-button>
<div class="inputClass uploadClass"> <div class="inputClass uploadClass">
<el-upload :show-file-list="false" v-model="fileOriData" :before-upload="beforeAvatarUpload" <el-upload :show-file-list="false" v-model="fileOriData" :before-upload="beforeAvatarUpload"
:http-request="successSubmit" accept=".xls,.xlsx,.csv"> :http-request="successSubmit" accept=".xls,.xlsx,.csv">
@ -93,7 +100,7 @@
<el-icon> <el-icon>
<Upload /> <Upload />
</el-icon> </el-icon>
<span>导入历史数据</span> <span>导入数据</span>
</el-button> </el-button>
</el-upload> </el-upload>
</div> </div>
@ -170,7 +177,7 @@ export default {
wenjianObj: { wenjianObj: {
wenjianName: "", wenjianName: "",
fileType: "", fileType: "",
status: "", status: "正常",
}, },
fileList: [ fileList: [
{ {
@ -214,19 +221,16 @@ export default {
{ {
label: "全部", label: "全部",
color: "#409eff", color: "#409eff",
class: "allClass",
value: "", value: "",
}, },
{ {
label: "正常", label: "正常",
color: "#67c23a", color: "#67c23a",
class: "normalClass",
value: "正常" value: "正常"
}, },
{ {
label: "已注销", label: "已注销",
color: "#f56c6c", color: "#f56c6c",
class: "unregisterClass",
value: "已注销" value: "已注销"
}, },
], ],
@ -300,16 +304,15 @@ export default {
let workbook = XLSX.read(data, { type: 'binary' }) let workbook = XLSX.read(data, { type: 'binary' })
let sheetName = workbook.SheetNames[0] let sheetName = workbook.SheetNames[0]
let sheetData = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]) let sheetData = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName])
let xiangmuObj = _.groupBy(sheetData, "项目名") let xiangmuObj = _.groupBy(_.cloneDeep(sheetData), "项目名")
let excludeList = ["123123", "test2222", "主卷"]
let xiangmuList = [] let xiangmuList = []
for (let key in xiangmuObj) { for (let key in xiangmuObj) {
if (key && !excludeList.includes(key)) { if (key) {
xiangmuList.push(key) xiangmuList.push(key)
} }
} }
let { pathList, treeList } = that.bulkAddXiangmu(xiangmuList) let { pathList, treeList } = that.bulkAddXiangmu(xiangmuList)
let { tableList, successList } = that.bulkAddFile(treeList, sheetData) let { tableList } = that.bulkAddFile(treeList, sheetData)
that.inputTreeList = _.cloneDeep(treeList) that.inputTreeList = _.cloneDeep(treeList)
that.inputTableList = _.cloneDeep(tableList) that.inputTableList = _.cloneDeep(tableList)
that.inputPathList = _.cloneDeep(pathList) that.inputPathList = _.cloneDeep(pathList)
@ -380,8 +383,8 @@ export default {
// //
bulkAddFile(treeList, tableDataList) { bulkAddFile(treeList, tableDataList) {
console.log(386, tableDataList);
let tableList = [] let tableList = []
let successList = []
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 juanNameLIst = _.split(fileItem["文件名"], "·")
@ -391,11 +394,12 @@ export default {
let chineseCharsOnly = pdfText.match(/[\u4e00-\u9fa5]+/g); let chineseCharsOnly = pdfText.match(/[\u4e00-\u9fa5]+/g);
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 treeItem2 = _.find(treeList, o => _.startsWith(o.path, `${fileItem["项目名"]}}`) && juanName.includes(o.label))
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/")
if (treeItem) { if (treeItem) {
successList.push(i)
tableList.push({ tableList.push({
treeId: treeItem.currentId, treeId: treeItem.currentId,
pretreeId: treeItem.preId, pretreeId: treeItem.preId,
@ -407,8 +411,44 @@ export default {
uploadTime: fileItem["上传时间"], uploadTime: fileItem["上传时间"],
status: fileItem["状态"], status: fileItem["状态"],
size: "", size: "",
path: `D:\\test\\${fileItem["项目名"]}\\${fileItem["卷名"]}\\${juanName}\\${path[1]}`, path: `D: \\test\\${fileItem["项目名"]}\\${fileItem["卷名"]}\\${juanName}\\${path[1]}`,
prePath: `D:\\uploadPath\\${prepath[1].replaceAll("/", "\\")}`, 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["备注"], 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'),
@ -416,7 +456,7 @@ export default {
} }
} }
} }
return { tableList, successList } return { tableList }
}, },
// inputData // inputData
async inputData(treeList, pathList, tableList) { async inputData(treeList, pathList, tableList) {
@ -483,7 +523,8 @@ export default {
check: false, check: false,
}) })
} }
this.treeData = treeList
this.treeData = _.sortBy(treeList, "label")
await this.searchTable() await this.searchTable()
}, },
//() //()
@ -577,7 +618,7 @@ export default {
//() //()
async delxiangmu(node) { async delxiangmu(node) {
ElMessageBox.confirm( ElMessageBox.confirm(
`是否删除(${node.label})项目?同时删除项目时将删除下面的文件夹及文件?`, `是否删除(${node.label})项目?同时删除项目时将删除下面的文件夹及文件 ? `,
'danger', 'danger',
{ {
confirmButtonText: '确认', confirmButtonText: '确认',
@ -629,7 +670,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,
@ -663,18 +704,18 @@ export default {
} }
let bytes = Number(num); let bytes = Number(num);
if (bytes >= 1024 ** 4) { if (bytes >= 1024 ** 4) {
return `${(bytes / 1024 ** 4).toFixed(2)}TB`; return `${(bytes / 1024 ** 4).toFixed(2)} TB`;
} }
if (bytes >= 1024 ** 3) { if (bytes >= 1024 ** 3) {
return `${(bytes / 1024 ** 3).toFixed(2)}GB`; return `${(bytes / 1024 ** 3).toFixed(2)} GB`;
} }
if (bytes >= 1024 ** 2) { if (bytes >= 1024 ** 2) {
return `${(bytes / 1024 ** 2).toFixed(2)}MB`; return `${(bytes / 1024 ** 2).toFixed(2)} MB`;
} }
if (bytes >= 1024) { if (bytes >= 1024) {
return `${(bytes / 1024).toFixed(2)}KB`; return `${(bytes / 1024).toFixed(2)} KB`;
} }
return `${bytes}B`; return `${bytes} B`;
}, },
// //
async addFile() { async addFile() {
@ -687,13 +728,13 @@ export default {
let pathList = _.compact(_.split(this.treeNode.path, '\\')) let pathList = _.compact(_.split(this.treeNode.path, '\\'))
this.addFileForm = { this.addFileForm = {
visible: true, visible: true,
title: `文件路径:D:\\${_.get(this.treeNode, 'path')}`, title: `文件路径:D: \\${_.get(this.treeNode, 'path')} `,
disabled: false, disabled: false,
type: "add", type: "add",
formHeader: this.formHeader, formHeader: this.formHeader,
formData: { formData: {
xiangmuName: `${_.trim(pathList[0])}`, xiangmuName: `${_.trim(pathList[0])} `,
juanName: `${_.trim(pathList[1])}`, juanName: `${_.trim(pathList[1])} `,
fileName: "", fileName: "",
fileLimit: 10000, fileLimit: 10000,
file: [], file: [],
@ -713,6 +754,41 @@ export default {
this.treeNode = {} this.treeNode = {}
await this.searchTable() 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) { async viewFile(row) {
// //
@ -722,7 +798,7 @@ export default {
async editFile(row) { async editFile(row) {
this.addFileForm = { this.addFileForm = {
visible: true, 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, disabled: false,
type: "put", type: "put",
formHeader: this.formHeader, formHeader: this.formHeader,
@ -740,8 +816,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,
@ -797,16 +873,16 @@ export default {
let firstId = v5(xianmguName, this.uuidNameSpace) let firstId = v5(xianmguName, this.uuidNameSpace)
for (let i = 0; i < this.level2.length; i++) { for (let i = 0; i < this.level2.length; i++) {
let level2Item = this.level2[i]; let level2Item = this.level2[i];
let level2Str = `${xianmguName}${level2Item}` let level2Str = `${xianmguName}${level2Item} `
let level2uuid = v5(level2Str, this.uuidNameSpace) let level2uuid = v5(level2Str, this.uuidNameSpace)
for (let j = 0; j < this.level3[level2Item].length; j++) { for (let j = 0; j < this.level3[level2Item].length; j++) {
let level3Item = this.level3[level2Item][j]; let level3Item = this.level3[level2Item][j];
let level3Str = `${xianmguName}${level2Item}${level3Item}` let level3Str = `${xianmguName}${level2Item}${level3Item} `
let level3uuid = v5(level3Str, this.uuidNameSpace) let level3uuid = v5(level3Str, this.uuidNameSpace)
treeList.push({ treeList.push({
label: level3Item, label: level3Item,
currentId: level3uuid, currentId: level3uuid,
path: `${xianmguName}\\${level2Item}\\${level3Item}`, path: `${xianmguName} \\${level2Item} \\${level3Item} `,
delete: false, delete: false,
preId: level2uuid, preId: level2uuid,
prepreId: firstId, prepreId: firstId,
@ -814,12 +890,12 @@ export default {
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'),
}) })
pathList.push(`${xianmguName}\\${level2Item}\\${level3Item}`) pathList.push(`${xianmguName} \\${level2Item} \\${level3Item} `)
} }
treeList.push({ treeList.push({
label: level2Item, label: level2Item,
currentId: level2uuid, currentId: level2uuid,
path: `${xianmguName}\\${level2Item}`, path: `${xianmguName} \\${level2Item} `,
delete: false, delete: false,
preId: firstId, preId: firstId,
prepreId: "", prepreId: "",
@ -831,7 +907,7 @@ export default {
treeList.push({ treeList.push({
label: xianmguName, label: xianmguName,
currentId: firstId, currentId: firstId,
path: `${xianmguName}`, path: `${xianmguName} `,
delete: false, delete: false,
preId: "", preId: "",
prepreId: "", prepreId: "",
@ -849,7 +925,7 @@ export default {
await this.searchTree() await this.searchTree()
} catch (error) { } catch (error) {
ElMessage({ ElMessage({
message: `${error}`, message: `${error} `,
type: 'error', type: 'error',
}) })
} }
@ -865,7 +941,7 @@ export default {
id: level3Item.id, id: level3Item.id,
label: level3Item.label, label: level3Item.label,
currentId: level3Item.currentId, currentId: level3Item.currentId,
path: `${xianmguName}\\${level2Item.label}\\${level3Item.label}`, path: `${xianmguName} \\${level2Item.label} \\${level3Item.label} `,
delete: false, delete: false,
preId: level3Item.preId, preId: level3Item.preId,
prepreId: level3Item.prepreId, prepreId: level3Item.prepreId,
@ -879,7 +955,7 @@ export default {
id: level2Item.id, id: level2Item.id,
label: level2Item.label, label: level2Item.label,
currentId: level2Item.currentId, currentId: level2Item.currentId,
path: `${xianmguName}\\${level2Item.label}`, path: `${xianmguName} \\${level2Item.label} `,
delete: false, delete: false,
preId: level2Item.preId, preId: level2Item.preId,
prepreId: "", prepreId: "",
@ -893,7 +969,7 @@ export default {
id: preNodeTemp.id, id: preNodeTemp.id,
label: xianmguName, label: xianmguName,
currentId: preNodeTemp.currentId, currentId: preNodeTemp.currentId,
path: `${xianmguName}`, path: `${xianmguName} `,
delete: false, delete: false,
preId: "", preId: "",
prepreId: "", prepreId: "",
@ -916,7 +992,7 @@ export default {
await this.searchTree() await this.searchTree()
} catch (error) { } catch (error) {
ElMessage({ ElMessage({
message: `${error}`, message: `${error} `,
type: 'error', type: 'error',
}) })
} }
@ -948,13 +1024,13 @@ export default {
pretreeId: this.treeNode.preId, pretreeId: this.treeNode.preId,
prepretreeId: this.treeNode.prepreId, prepretreeId: this.treeNode.prepreId,
xiangmuName: filePathList[0], xiangmuName: filePathList[0],
juanName: `${filePathList[1]}${filePathList[2] ? "_" + filePathList[2] : ""}`, juanName: `${filePathList[1]}${filePathList[2] ? "_" + filePathList[2] : ""} `,
fileName: fileItem.raw.name, fileName: fileItem.raw.name,
fileType: fileItem.raw.type, fileType: fileItem.raw.type,
uploadTime: dayjs().format('YYYY-MM-DD HH:mm:ss'), uploadTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
status: "正常", status: "正常",
size: fileItem.raw.size, size: fileItem.raw.size,
path: `${this.treeNode.path}\\${fileItem.raw.name}`, path: `${this.treeNode.path} \\${fileItem.raw.name} `,
prePath: fileItem.raw.path, prePath: fileItem.raw.path,
note: this.addFileForm.formData.note, note: this.addFileForm.formData.note,
create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'),
@ -978,7 +1054,7 @@ export default {
uploadTime: formData.uploadTime, uploadTime: formData.uploadTime,
status: formData.status, status: formData.status,
size: _.get(formData.file, [0, "raw", "size"], _.get(formData.file, [0, "size"], "")), 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"], "")), prePath: _.get(formData.file, [0, "raw", "path"], _.get(formData.file, [0, "path"], "")),
note: formData.note, note: formData.note,
create_at: formData.create_at, create_at: formData.create_at,
@ -998,7 +1074,7 @@ export default {
let resObj = JSON.parse(res) let resObj = JSON.parse(res)
if (resObj.errorList.length) { if (resObj.errorList.length) {
ElMessage({ ElMessage({
message: `文件夹${resObj.errorList.join(",")}创建失败`, message: `文件夹${resObj.errorList.join(",")} 创建失败`,
type: 'error', type: 'error',
}) })
} else { } else {
@ -1027,7 +1103,7 @@ export default {
id: level3Item.id, id: level3Item.id,
label: level3Item.label, label: level3Item.label,
currentId: level3Item.currentId, currentId: level3Item.currentId,
path: `${resObj.errorList[0].oldPath}\\${level2Item}\\${level3Item}`, path: `${resObj.errorList[0].oldPath} \\${level2Item} \\${level3Item} `,
delete: false, delete: false,
preId: level3Item.preId, preId: level3Item.preId,
prepreId: level3Item.prepreId, prepreId: level3Item.prepreId,
@ -1041,7 +1117,7 @@ export default {
id: level2Item.id, id: level2Item.id,
label: level2Item.label, label: level2Item.label,
currentId: level2Item.currentId, currentId: level2Item.currentId,
path: `${resObj.errorList[0].oldPath}\\${level2Item.label}`, path: `${resObj.errorList[0].oldPath} \\${level2Item.label} `,
delete: false, delete: false,
preId: level2Item.preId, preId: level2Item.preId,
prepreId: "", prepreId: "",
@ -1055,7 +1131,7 @@ export default {
id: preNodeTemp.id, id: preNodeTemp.id,
label: resObj.errorList[0].oldPath, label: resObj.errorList[0].oldPath,
currentId: preNodeTemp.currentId, currentId: preNodeTemp.currentId,
path: `${resObj.errorList[0].oldPath}`, path: `${resObj.errorList[0].oldPath} `,
delete: false, delete: false,
preId: "", preId: "",
prepreId: "", prepreId: "",
@ -1073,7 +1149,7 @@ export default {
that.searchTree() that.searchTree()
// //
let collection = myDatabase.fileList 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() let fileList = await collection.toArray()
for (let index = 0; index < fileList.length; index++) { for (let index = 0; index < fileList.length; index++) {
let fileItem = fileList[index]; let fileItem = fileList[index];
@ -1092,12 +1168,12 @@ export default {
let resObj = JSON.parse(res) let resObj = JSON.parse(res)
if (resObj.errorList.length) { if (resObj.errorList.length) {
ElMessage({ ElMessage({
message: `文件夹${resObj.errorList[0].name}删除失败`, message: `文件夹${resObj.errorList[0].name} 删除失败`,
type: 'error', type: 'error',
}) })
} else { } else {
ElMessage({ ElMessage({
message: `文件夹${resObj.successList[0].name}删除成功`, message: `文件夹${resObj.successList[0].name} 删除成功`,
type: 'success', type: 'success',
}) })
await myDatabase.treeList.bulkDelete(that.deleteXiangmuIdList) await myDatabase.treeList.bulkDelete(that.deleteXiangmuIdList)
@ -1125,7 +1201,7 @@ export default {
errorList.push(element.fileName) errorList.push(element.fileName)
} }
ElMessage({ 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', type: 'error',
}) })
} else { } else {
@ -1135,7 +1211,7 @@ export default {
successList.push(element.fileName) successList.push(element.fileName)
} }
ElMessage({ 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', type: 'success',
}) })
that.searchTable() that.searchTable()
@ -1145,7 +1221,7 @@ export default {
window.electron.ipcRenderer.on('downloadFileResult', async (eve, result) => { window.electron.ipcRenderer.on('downloadFileResult', async (eve, result) => {
if (!result.success) { if (!result.success) {
ElMessage({ ElMessage({
message: `文件下载失败${result.error}`, message: `文件下载失败${result.error} `,
type: 'error', type: 'error',
}); });
return; return;

Loading…
Cancel
Save