|
|
@ -8,7 +8,7 @@ |
|
|
|
<template #prepend>项目名:</template> |
|
|
|
</el-input> |
|
|
|
</div> |
|
|
|
<el-button type="primary" @click="searchTree"> |
|
|
|
<el-button type="primary" @click="clearAndSearchTree"> |
|
|
|
<el-icon> |
|
|
|
<Search /> |
|
|
|
</el-icon> |
|
|
@ -60,7 +60,7 @@ |
|
|
|
<div style="margin-bottom: 8px;"> |
|
|
|
<el-row :gutter="20"> |
|
|
|
<el-col :span="4"> |
|
|
|
<el-button type="primary" plain @click="addFile"> |
|
|
|
<el-button type="primary" plain @click="addFile" :disabled="_.get(treeNode, 'level') !== 3"> |
|
|
|
<el-icon> |
|
|
|
<Plus /> |
|
|
|
</el-icon> |
|
|
@ -68,12 +68,12 @@ |
|
|
|
</el-button> |
|
|
|
</el-col> |
|
|
|
<el-col :span="10"> |
|
|
|
<el-input v-model="xiangmuObj.xianmguName" style="width: 100%;" placeholder="请输入文件名" clearable> |
|
|
|
<el-input v-model="wenjianObj.wenjianName" style="width: 100%;" placeholder="请输入文件名" clearable> |
|
|
|
<template #prepend>文件名:</template> |
|
|
|
</el-input> |
|
|
|
</el-col> |
|
|
|
<el-col :span="8"> |
|
|
|
<el-button type="primary" @click="searchFile"> |
|
|
|
<el-button type="primary" @click="searchTable"> |
|
|
|
<el-icon> |
|
|
|
<Search /> |
|
|
|
</el-icon> |
|
|
@ -122,7 +122,6 @@ |
|
|
|
|
|
|
|
<script> |
|
|
|
import _ from 'lodash' |
|
|
|
import * as XLSX from 'xlsx'; |
|
|
|
import { v5 } from "uuid"; |
|
|
|
import tableHeaderLocal from '../assets/json/file.json' |
|
|
|
import { myDatabase } from '../assets/js/db.js' |
|
|
@ -132,11 +131,21 @@ import treecomponent from "../components/treecomponent.vue" |
|
|
|
import formcomponent from "../components/formcomponent.vue" |
|
|
|
import viewcomponent from "../components/viewcomponent.vue" |
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus' |
|
|
|
import { refresh } from 'less'; |
|
|
|
export default { |
|
|
|
name: 'dangan', |
|
|
|
components: { tablecomponent, formcomponent, treecomponent, viewcomponent }, |
|
|
|
watch: {}, |
|
|
|
watch: { |
|
|
|
"wenjianObj.fileType": { |
|
|
|
handler(newValue, oldValue) { |
|
|
|
this.searchTable() |
|
|
|
} |
|
|
|
}, |
|
|
|
"wenjianObj.status": { |
|
|
|
handler(newValue, oldValue) { |
|
|
|
this.searchTable() |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: {}, |
|
|
|
data() { |
|
|
|
return { |
|
|
@ -149,7 +158,6 @@ export default { |
|
|
|
wenjianName: "", |
|
|
|
fileType: "", |
|
|
|
status: "", |
|
|
|
parentId: "", |
|
|
|
}, |
|
|
|
fileList: [ |
|
|
|
{ |
|
|
@ -158,35 +166,35 @@ export default { |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: "doc", |
|
|
|
value: "doc" |
|
|
|
value: "application/msword" |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: "docx", |
|
|
|
value: "docx" |
|
|
|
value: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: "jpg", |
|
|
|
value: "jpg" |
|
|
|
value: "image/jpeg" |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: "mp4", |
|
|
|
value: "mp4" |
|
|
|
value: "video/mp4" |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: "pdf", |
|
|
|
value: "pdf" |
|
|
|
value: "application/pdf" |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: "png", |
|
|
|
value: "png" |
|
|
|
value: "image/png" |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: "xls", |
|
|
|
value: "xls" |
|
|
|
value: "application/vnd.ms-excel" |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: "xlsx", |
|
|
|
value: "xlsx" |
|
|
|
value: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" |
|
|
|
}, |
|
|
|
], |
|
|
|
statusList: [ |
|
|
@ -200,13 +208,13 @@ export default { |
|
|
|
label: "正常", |
|
|
|
color: "#67c23a", |
|
|
|
class: "normalClass", |
|
|
|
value: "normal" |
|
|
|
value: "正常" |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: "注销", |
|
|
|
color: "#f56c6c", |
|
|
|
class: "unregisterClass", |
|
|
|
value: "unregister" |
|
|
|
value: "注销" |
|
|
|
}, |
|
|
|
], |
|
|
|
level1: [], |
|
|
@ -237,26 +245,37 @@ export default { |
|
|
|
formHeader: [], |
|
|
|
formData: {} |
|
|
|
}, |
|
|
|
treeNode: {}, |
|
|
|
preNode: {}, |
|
|
|
preFile: {}, |
|
|
|
uuidNameSpace: "8268af6b-7ef5-5d6d-a489-2d641dfb53bb", |
|
|
|
preNodeTemp: {}, |
|
|
|
treeLoading: false, |
|
|
|
tableLoading: false, |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 清空左侧并搜索 |
|
|
|
clearAndSearchTree() { |
|
|
|
this.treeNode = {} |
|
|
|
this.$refs.treeComponentRef.nodeClickId = "" |
|
|
|
this.searchTree() |
|
|
|
}, |
|
|
|
//搜索数据(树状) |
|
|
|
async searchTree() { |
|
|
|
this.treeLoading = true |
|
|
|
let collection = myDatabase.treeList |
|
|
|
let xianmguName = _.trim(this.xiangmuObj.xianmguName) |
|
|
|
collection = collection.filter((equip) => equip.delete === false) |
|
|
|
if (xianmguName) { |
|
|
|
let reg = new RegExp(xianmguName, "i") |
|
|
|
collection = collection.filter((equip) => reg.test(equip.label)) |
|
|
|
} |
|
|
|
// 处理 jujinnianxian |
|
|
|
let res = await collection.toArray(); |
|
|
|
let level1List = _.filter(res, { level: 1, prepreId: "", preId: "", }) |
|
|
|
let level2List = _.filter(res, { level: 2, prepreId: "", }) |
|
|
|
let level3List = _.filter(res, { level: 3 }) |
|
|
|
let level1List = _.filter(res, { level: 1, prepreId: "", preId: "", delete: false, }) |
|
|
|
let level2List = _.filter(res, { level: 2, prepreId: "", delete: false, }) |
|
|
|
let level3List = _.filter(res, { level: 3, delete: false, }) |
|
|
|
this.treeLoading = false |
|
|
|
let treeList = [] |
|
|
|
for (let i = 0; i < level1List.length; i++) { |
|
|
@ -271,22 +290,60 @@ export default { |
|
|
|
let level3Item = level3ListTemp[l]; |
|
|
|
level2Children.push({ |
|
|
|
...level3Item, |
|
|
|
id: level3Item.currentId, |
|
|
|
check: false, |
|
|
|
}) |
|
|
|
} |
|
|
|
level1Children.push({ |
|
|
|
...level2Item, |
|
|
|
id: level2Item.currentId, |
|
|
|
children: level2Children |
|
|
|
children: level2Children, |
|
|
|
check: false, |
|
|
|
}) |
|
|
|
} |
|
|
|
treeList.push({ |
|
|
|
...level1Item, |
|
|
|
id: level1Item.currentId, |
|
|
|
children: level1Children |
|
|
|
children: level1Children, |
|
|
|
check: false, |
|
|
|
}) |
|
|
|
} |
|
|
|
this.treeData = treeList |
|
|
|
await this.searchTable() |
|
|
|
}, |
|
|
|
//搜索数据(表格) |
|
|
|
async searchTable() { |
|
|
|
this.tableLoading = true |
|
|
|
let collection = myDatabase.fileList |
|
|
|
if (!_.isEmpty(this.treeNode)) { |
|
|
|
if (this.treeNode.level === 1) { |
|
|
|
collection = collection.filter((equip) => equip.prepretreeId === this.treeNode.currentId) |
|
|
|
} else if (this.treeNode.level === 2) { |
|
|
|
collection = collection.filter((equip) => equip.pretreeId === this.treeNode.currentId) |
|
|
|
} else if (this.treeNode.level === 3) { |
|
|
|
collection = collection.filter((equip) => equip.treeId === this.treeNode.currentId) |
|
|
|
} |
|
|
|
} else { |
|
|
|
let fileCurrentIdList = [] |
|
|
|
for (let i = 0; i < this.treeData.length; i++) { |
|
|
|
let treeItem = this.treeData[i]; |
|
|
|
fileCurrentIdList.push(treeItem.currentId) |
|
|
|
} |
|
|
|
collection = collection.filter((equip) => fileCurrentIdList.includes(equip.prepretreeId)) |
|
|
|
} |
|
|
|
if (!_.isEmpty(this.wenjianObj)) { |
|
|
|
let wenjianName = _.trim(this.wenjianObj.wenjianName) |
|
|
|
if (wenjianName) { |
|
|
|
collection = collection.filter((equip) => equip.fileName.includes(wenjianName)) |
|
|
|
} |
|
|
|
if (this.wenjianObj.fileType) { |
|
|
|
collection = collection.filter((equip) => equip.fileType === this.wenjianObj.fileType) |
|
|
|
} |
|
|
|
if (this.wenjianObj.status) { |
|
|
|
collection = collection.filter((equip) => equip.status === this.wenjianObj.status) |
|
|
|
} |
|
|
|
} |
|
|
|
// 处理 jujinnianxian |
|
|
|
let res = await collection.toArray(); |
|
|
|
this.tableLoading = false |
|
|
|
this.tableData = res |
|
|
|
}, |
|
|
|
//增加项目(树状) |
|
|
|
async addxiangmu() { |
|
|
@ -314,27 +371,12 @@ export default { |
|
|
|
}, |
|
|
|
//编辑项目(树状) |
|
|
|
async editxiangmu(node) { |
|
|
|
console.log(265, node); |
|
|
|
}, |
|
|
|
//删除项目(树状) |
|
|
|
async delxiangmu(node) { |
|
|
|
console.log(269, node); |
|
|
|
}, |
|
|
|
// 选中树的节点 |
|
|
|
async nodeClick(node) { |
|
|
|
console.log(273, node); |
|
|
|
}, |
|
|
|
//导出(树状) |
|
|
|
async exportData(params = {}, isAll = false) { |
|
|
|
|
|
|
|
}, |
|
|
|
//新增文件 |
|
|
|
async addFile() { |
|
|
|
this.addFileForm = { |
|
|
|
this.preNode = _.cloneDeep(node) |
|
|
|
this.adddanganForm = { |
|
|
|
visible: true, |
|
|
|
title: "新增文件", |
|
|
|
title: `编辑${node.label}`, |
|
|
|
disabled: false, |
|
|
|
type: "add", |
|
|
|
type: "put", |
|
|
|
formHeader: [ |
|
|
|
{ |
|
|
|
label: "项目名称", |
|
|
@ -348,33 +390,152 @@ export default { |
|
|
|
} |
|
|
|
], |
|
|
|
formData: { |
|
|
|
xianmguName: "" |
|
|
|
xianmguName: node.label |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
//搜索文件 |
|
|
|
async searchFile(params = {}, isAll = false) { |
|
|
|
//删除项目(树状) |
|
|
|
async delxiangmu(node) { |
|
|
|
ElMessageBox.confirm( |
|
|
|
`是否删除(${node.label})项目?同时删除项目时将删除下面的文件夹及文件?`, |
|
|
|
'danger', |
|
|
|
{ |
|
|
|
confirmButtonText: '确认', |
|
|
|
cancelButtonText: '取消', |
|
|
|
type: 'danger', |
|
|
|
} |
|
|
|
) |
|
|
|
.then(async () => { |
|
|
|
let idList = [] |
|
|
|
// 删除项目并且,将下面的文件夹和文件全部删除 |
|
|
|
idList.push(node.data.id) |
|
|
|
let fileIdList = [] |
|
|
|
for (let i = 0; i < node.data.children.length; i++) { |
|
|
|
let level2Item = node.data.children[i]; |
|
|
|
idList.push(level2Item.id) |
|
|
|
for (let j = 0; j < level2Item.children.length; j++) { |
|
|
|
let level3Item = level2Item.children[j]; |
|
|
|
fileIdList.push(level3Item.currentId) |
|
|
|
idList.push(level3Item.id) |
|
|
|
} |
|
|
|
} |
|
|
|
// 删除项目 |
|
|
|
await myDatabase.treeList.bulkDelete(idList) |
|
|
|
window.electron.ipcRenderer.send('delFloder', JSON.stringify({ name: node.label })) |
|
|
|
// 查找要删除的文件列表id并删除 |
|
|
|
let delfiltIdList = [] |
|
|
|
let fileCollection = myDatabase.fileList |
|
|
|
fileCollection = fileCollection.filter((equip) => fileIdList.includes(equip.treeId)) |
|
|
|
let delfiltList = await collection.toArray(); |
|
|
|
for (let i = 0; i < delfiltList.length; i++) { |
|
|
|
let fileItem = delfiltList[i]; |
|
|
|
delfiltIdList.push(fileItem.id) |
|
|
|
} |
|
|
|
await myDatabase.fileList.bulkDelete(delfiltIdList) |
|
|
|
await this.searchTree() |
|
|
|
await this.searchTable() |
|
|
|
}) |
|
|
|
.catch((e) => { |
|
|
|
ElMessage({ |
|
|
|
type: 'info', |
|
|
|
message: `取消删除(${node.label})项目`, |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 选中树的节点 |
|
|
|
async nodeClick(node) { |
|
|
|
this.treeNode = _.cloneDeep(node) |
|
|
|
this.searchTable() |
|
|
|
}, |
|
|
|
//导出(树状) |
|
|
|
async exportData(params = {}, isAll = false) { |
|
|
|
|
|
|
|
}, |
|
|
|
//新增文件 |
|
|
|
async addFile() { |
|
|
|
if (_.get(this.treeNode, 'level') !== 3) { |
|
|
|
ElMessage({ |
|
|
|
message: '请选择项目', |
|
|
|
type: 'warning' |
|
|
|
}) |
|
|
|
} else { |
|
|
|
let pathList = _.compact(_.split(this.treeNode.path, '\\')) |
|
|
|
this.addFileForm = { |
|
|
|
visible: true, |
|
|
|
title: `文件路径:E:\\${_.get(this.treeNode, 'path')}`, |
|
|
|
disabled: false, |
|
|
|
type: "add", |
|
|
|
formHeader: this.formHeader, |
|
|
|
formData: { |
|
|
|
xiangmuName: `${_.trim(pathList[0])}`, |
|
|
|
juanName: `${_.trim(pathList[1])}`, |
|
|
|
fileName: "", |
|
|
|
fileLimit: 10000, |
|
|
|
file: [], |
|
|
|
fileType: "", |
|
|
|
uploadTime: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
status: "正常", |
|
|
|
path: "", |
|
|
|
note: "", |
|
|
|
create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
//重置 |
|
|
|
async refresh(params = {}, isAll = false) { |
|
|
|
|
|
|
|
async refresh() { |
|
|
|
this.treeNode = {} |
|
|
|
await this.searchTable() |
|
|
|
}, |
|
|
|
//预览 |
|
|
|
async viewFile(params = {}, isAll = false) { |
|
|
|
|
|
|
|
async viewFile(row) { |
|
|
|
// 根据路径打开文件 |
|
|
|
window.electron.ipcRenderer.send('openFile', row.path) |
|
|
|
}, |
|
|
|
//修改 |
|
|
|
async editFile(params = {}, isAll = false) { |
|
|
|
|
|
|
|
async editFile(row) { |
|
|
|
this.addFileForm = { |
|
|
|
visible: true, |
|
|
|
title: `编辑文件:E:\\test\\${row.xiangmuName}\\${_.join(_.split(row.juanName, "_"), "\\")}\\${row.fileName}`, |
|
|
|
disabled: false, |
|
|
|
type: "put", |
|
|
|
formHeader: this.formHeader, |
|
|
|
formData: { |
|
|
|
id: row.id, |
|
|
|
treeId: row.treeId, |
|
|
|
pretreeId: row.pretreeId, |
|
|
|
prepretreeId: row.prepretreeId, |
|
|
|
xiangmuName: row.xiangmuName, |
|
|
|
juanName: row.juanName, |
|
|
|
fileName: row.fileName, |
|
|
|
fileLimit: 1, |
|
|
|
file: [ |
|
|
|
{ |
|
|
|
name: row.fileName, |
|
|
|
url: `E:\\test\\${row.xiangmuName}\\${_.join(_.split(row.juanName, "_"), "\\")}\\${row.fileName}`, |
|
|
|
} |
|
|
|
], |
|
|
|
fileType: row.fileType, |
|
|
|
uploadTime: row.uploadTime, |
|
|
|
status: row.status, |
|
|
|
path: row.path, |
|
|
|
note: row.note, |
|
|
|
create_at: row.create_at, |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
//注销 |
|
|
|
async unregisterFile(params = {}, isAll = false) { |
|
|
|
|
|
|
|
async unregisterFile(row) { |
|
|
|
let org = row.status |
|
|
|
row.status = org === "注销" ? "正常" : "注销" |
|
|
|
await myDatabase.fileList.put({ ...row }) |
|
|
|
await this.searchTable() |
|
|
|
}, |
|
|
|
//下载文件 |
|
|
|
async downloadFile(params = {}, isAll = false) { |
|
|
|
|
|
|
|
async downloadFile(row) { |
|
|
|
// 按照本地路径下载文件 |
|
|
|
window.electron.ipcRenderer.send('downloadFile', row.path) |
|
|
|
}, |
|
|
|
//关闭项目模态框 |
|
|
|
canceldanganDialog() { |
|
|
@ -387,62 +548,154 @@ export default { |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
//确认项目模态框 |
|
|
|
//新增确认项目模态框 |
|
|
|
async submitdanganDialog() { |
|
|
|
let treeList = [] |
|
|
|
let xianmguName = _.trim(this.adddanganForm.formData.xianmguName) |
|
|
|
if (xianmguName) { |
|
|
|
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 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 level3uuid = v5(level3Str, this.uuidNameSpace) |
|
|
|
// ++id, label, currentId, preId, prepreId, level, note, create_at, update_at |
|
|
|
let collection = myDatabase.treeList |
|
|
|
collection = collection.filter((equip) => equip.level === 1 && equip.label === xianmguName) |
|
|
|
// 处理 jujinnianxian |
|
|
|
let ishasXiangmu = await collection.toArray(); |
|
|
|
if (ishasXiangmu.length > 0) { |
|
|
|
ElMessage({ |
|
|
|
message: '项目已存在,请输入不同的项目名', |
|
|
|
type: 'warning' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.adddanganForm.type === "add") { |
|
|
|
let treeList = [] |
|
|
|
let pathList = [] |
|
|
|
if (xianmguName) { |
|
|
|
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 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 level3uuid = v5(level3Str, this.uuidNameSpace) |
|
|
|
treeList.push({ |
|
|
|
label: level3Item, |
|
|
|
currentId: level3uuid, |
|
|
|
path: `${xianmguName}\\${level2Item}\\${level3Item}`, |
|
|
|
delete: false, |
|
|
|
preId: level2uuid, |
|
|
|
prepreId: firstId, |
|
|
|
level: 3, |
|
|
|
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}`) |
|
|
|
} |
|
|
|
treeList.push({ |
|
|
|
label: level3Item, |
|
|
|
currentId: level3uuid, |
|
|
|
preId: level2uuid, |
|
|
|
prepreId: firstId, |
|
|
|
level: 3, |
|
|
|
label: level2Item, |
|
|
|
currentId: level2uuid, |
|
|
|
path: `${xianmguName}\\${level2Item}`, |
|
|
|
delete: false, |
|
|
|
preId: firstId, |
|
|
|
prepreId: "", |
|
|
|
level: 2, |
|
|
|
create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
}) |
|
|
|
} |
|
|
|
treeList.push({ |
|
|
|
label: level2Item, |
|
|
|
currentId: level2uuid, |
|
|
|
preId: firstId, |
|
|
|
label: xianmguName, |
|
|
|
currentId: firstId, |
|
|
|
path: `${xianmguName}`, |
|
|
|
delete: false, |
|
|
|
preId: "", |
|
|
|
prepreId: "", |
|
|
|
level: 2, |
|
|
|
level: 1, |
|
|
|
create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
}) |
|
|
|
} |
|
|
|
treeList.push({ |
|
|
|
label: xianmguName, |
|
|
|
currentId: firstId, |
|
|
|
preId: "", |
|
|
|
prepreId: "", |
|
|
|
level: 1, |
|
|
|
create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
}) |
|
|
|
} |
|
|
|
try { |
|
|
|
await myDatabase.treeList.bulkAdd(treeList) |
|
|
|
try { |
|
|
|
await myDatabase.treeList.bulkAdd(treeList) |
|
|
|
this.canceldanganDialog() |
|
|
|
pathList = _.uniq(pathList) |
|
|
|
console.log(619, pathList, JSON.stringify(pathList)); |
|
|
|
// 在d盘中新建文件夹 |
|
|
|
window.electron.ipcRenderer.send('createFloder', JSON.stringify(pathList)) |
|
|
|
await this.searchTree() |
|
|
|
} catch (error) { |
|
|
|
ElMessage({ |
|
|
|
message: `${error}`, |
|
|
|
type: 'error', |
|
|
|
}) |
|
|
|
} |
|
|
|
} else if (this.adddanganForm.type === "put") { |
|
|
|
let preNodeTemp = _.cloneDeep(this.preNode.data) |
|
|
|
this.preNodeTemp = _.cloneDeep(this.preNode.data) |
|
|
|
if (xianmguName) { |
|
|
|
for (let i = 0; i < preNodeTemp.children.length; i++) { |
|
|
|
let level2Item = preNodeTemp.children[i]; |
|
|
|
console.log(635, level2Item); |
|
|
|
for (let j = 0; j < level2Item.children.length; j++) { |
|
|
|
let level3Item = level2Item.children[j]; |
|
|
|
let level3ItemTemp = { |
|
|
|
id: level3Item.id, |
|
|
|
label: level3Item.label, |
|
|
|
currentId: level3Item.currentId, |
|
|
|
path: `${xianmguName}\\${level2Item.label}\\${level3Item.label}`, |
|
|
|
delete: false, |
|
|
|
preId: level3Item.preId, |
|
|
|
prepreId: level3Item.prepreId, |
|
|
|
level: 3, |
|
|
|
create_at: level3Item.create_at, |
|
|
|
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
} |
|
|
|
await myDatabase.treeList.put({ ...level3ItemTemp }) |
|
|
|
} |
|
|
|
let level2ItemTemp = { |
|
|
|
id: level2Item.id, |
|
|
|
label: level2Item.label, |
|
|
|
currentId: level2Item.currentId, |
|
|
|
path: `${xianmguName}\\${level2Item.label}`, |
|
|
|
delete: false, |
|
|
|
preId: level2Item.preId, |
|
|
|
prepreId: "", |
|
|
|
level: 2, |
|
|
|
create_at: level2Item.create_at, |
|
|
|
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
} |
|
|
|
await myDatabase.treeList.put({ ...level2ItemTemp }) |
|
|
|
} |
|
|
|
let level1ItemTemp = { |
|
|
|
id: preNodeTemp.id, |
|
|
|
label: xianmguName, |
|
|
|
currentId: preNodeTemp.currentId, |
|
|
|
path: `${xianmguName}`, |
|
|
|
delete: false, |
|
|
|
preId: "", |
|
|
|
prepreId: "", |
|
|
|
level: 1, |
|
|
|
create_at: preNodeTemp.create_at, |
|
|
|
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
} |
|
|
|
await myDatabase.treeList.put({ ...level1ItemTemp }) |
|
|
|
} else { |
|
|
|
ElMessage({ |
|
|
|
message: '请输入新的项目名称', |
|
|
|
type: 'warning' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
try { |
|
|
|
// 在E盘中更新文件夹 |
|
|
|
let params = { oldPath: preNodeTemp.label, newPath: xianmguName } |
|
|
|
console.log(688, params); |
|
|
|
window.electron.ipcRenderer.send('putFloder', JSON.stringify(params)) |
|
|
|
await this.searchTree() |
|
|
|
} catch (error) { |
|
|
|
ElMessage({ |
|
|
|
message: `${error}`, |
|
|
|
type: 'error', |
|
|
|
}) |
|
|
|
} |
|
|
|
this.canceldanganDialog() |
|
|
|
// 在d盘中新建文件夹 |
|
|
|
|
|
|
|
await this.searchTree() |
|
|
|
} catch (error) { |
|
|
|
ElMessage({ |
|
|
|
message: `${error}`, |
|
|
|
type: 'error', |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
//关闭文件模态框 |
|
|
@ -459,35 +712,220 @@ export default { |
|
|
|
|
|
|
|
//确认文件模态框 |
|
|
|
async submitFileDialog() { |
|
|
|
if (this.addFileForm.type === "add") { |
|
|
|
let fileList = _.cloneDeep(this.addFileForm.formData.file) |
|
|
|
let tableList = [] |
|
|
|
let filePathList = _.split(this.treeNode.path, "\\") |
|
|
|
for (let i = 0; i < fileList.length; i++) { |
|
|
|
let fileItem = fileList[i]; |
|
|
|
tableList.push({ |
|
|
|
treeId: this.treeNode.currentId, |
|
|
|
pretreeId: this.treeNode.preId, |
|
|
|
prepretreeId: this.treeNode.prepreId, |
|
|
|
xiangmuName: filePathList[0], |
|
|
|
juanName: `${filePathList[1]}_${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}`, |
|
|
|
prePath: fileItem.raw.path, |
|
|
|
note: this.addFileForm.formData.note, |
|
|
|
create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
}) |
|
|
|
} |
|
|
|
await myDatabase.fileList.bulkAdd(tableList) |
|
|
|
window.electron.ipcRenderer.send('createFile', JSON.stringify(tableList)) |
|
|
|
} else if (this.addFileForm.type === "put") { |
|
|
|
let formData = _.cloneDeep(this.addFileForm.formData) |
|
|
|
let pathArr = _.split(formData.path, "\\") |
|
|
|
console.log(744, pathArr); |
|
|
|
let fileItem = { |
|
|
|
id: formData.id, |
|
|
|
treeId: formData.treeId, |
|
|
|
pretreeId: formData.pretreeId, |
|
|
|
prepretreeId: formData.prepretreeId, |
|
|
|
xiangmuName: formData.xiangmuName, |
|
|
|
juanName: formData.juanName, |
|
|
|
fileName: formData.file[0].raw.name, |
|
|
|
fileType: formData.file[0].raw.type, |
|
|
|
uploadTime: formData.uploadTime, |
|
|
|
status: formData.status, |
|
|
|
size: formData.file[0].raw.size, |
|
|
|
path: `${_.join(pathArr.splice(0, pathArr.length - 1), "\\")}\\${formData.file[0].name}`, |
|
|
|
prePath: formData.file[0].raw.path, |
|
|
|
note: formData.note, |
|
|
|
create_at: formData.create_at, |
|
|
|
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
} |
|
|
|
await myDatabase.fileList.put({ ...fileItem }) |
|
|
|
} |
|
|
|
await this.searchTable() |
|
|
|
this.cancelFileDialog() |
|
|
|
}, |
|
|
|
//初始化数据 |
|
|
|
watchApi() { |
|
|
|
let that = this |
|
|
|
// 监听新增文件夹 |
|
|
|
window.electron.ipcRenderer.on('createFloderResult', (eve, res) => { |
|
|
|
let resObj = JSON.parse(res) |
|
|
|
if (resObj.errorList.length) { |
|
|
|
ElMessage({ |
|
|
|
message: `文件夹${resObj.errorList.join(",")}创建失败`, |
|
|
|
type: 'error', |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// resObj.successList[0].split("\\")[0] |
|
|
|
ElMessage({ |
|
|
|
message: `项目(${_.split(resObj.successList[0], "\\")[0]})新增成功`, |
|
|
|
type: 'success', |
|
|
|
}) |
|
|
|
that.searchTree() |
|
|
|
} |
|
|
|
}) |
|
|
|
// 监听更新文件夹 |
|
|
|
window.electron.ipcRenderer.on('putFloderResult', async (eve, res) => { |
|
|
|
let resObj = JSON.parse(res) |
|
|
|
let preNodeTemp = _.cloneDeep(that.preNodeTemp) |
|
|
|
console.log(788, resObj, preNodeTemp); |
|
|
|
if (resObj.errorList.length) { |
|
|
|
ElMessage({ |
|
|
|
message: `文件夹${resObj.errorList[0].oldPath}修改为${resObj.errorList[0].newPath},修改失败`, |
|
|
|
type: 'error', |
|
|
|
}) |
|
|
|
for (let i = 0; i < preNodeTemp.children.length; i++) { |
|
|
|
let level2Item = preNodeTemp.children[i]; |
|
|
|
for (let j = 0; j < level2Item.children.length; j++) { |
|
|
|
let level3Item = level2Item.children[j]; |
|
|
|
let level3ItemTemp = { |
|
|
|
id: level3Item.id, |
|
|
|
label: level3Item.label, |
|
|
|
currentId: level3Item.currentId, |
|
|
|
path: `${resObj.errorList[0].oldPath}\\${level2Item}\\${level3Item}`, |
|
|
|
delete: false, |
|
|
|
preId: level3Item.preId, |
|
|
|
prepreId: level3Item.prepreId, |
|
|
|
level: 3, |
|
|
|
create_at: level3Item.create_at, |
|
|
|
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
} |
|
|
|
await myDatabase.treeList.put({ ...level3ItemTemp }) |
|
|
|
} |
|
|
|
let level2ItemTemp = { |
|
|
|
id: level2Item.id, |
|
|
|
label: level2Item.label, |
|
|
|
currentId: level2Item.currentId, |
|
|
|
path: `${resObj.errorList[0].oldPath}\\${level2Item.label}`, |
|
|
|
delete: false, |
|
|
|
preId: level2Item.preId, |
|
|
|
prepreId: "", |
|
|
|
level: 2, |
|
|
|
create_at: level2Item.create_at, |
|
|
|
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
} |
|
|
|
await myDatabase.treeList.put({ ...level2ItemTemp }) |
|
|
|
} |
|
|
|
let level1ItemTemp = { |
|
|
|
id: preNodeTemp.id, |
|
|
|
label: resObj.errorList[0].oldPath, |
|
|
|
currentId: preNodeTemp.currentId, |
|
|
|
path: `${resObj.errorList[0].oldPath}`, |
|
|
|
delete: false, |
|
|
|
preId: "", |
|
|
|
prepreId: "", |
|
|
|
level: 1, |
|
|
|
create_at: preNodeTemp.create_at, |
|
|
|
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
} |
|
|
|
await myDatabase.treeList.put({ ...level1ItemTemp }) |
|
|
|
} else { |
|
|
|
// resObj.successList[0].split("\\")[0] |
|
|
|
ElMessage({ |
|
|
|
message: `文件夹${resObj.successList[0].oldPath}修改为${resObj.successList[0].newPath},修改成功`, |
|
|
|
type: 'success', |
|
|
|
}) |
|
|
|
that.searchTree() |
|
|
|
// 成功以后更新文件的路径 |
|
|
|
let collection = myDatabase.fileList |
|
|
|
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]; |
|
|
|
let fileParmas = { |
|
|
|
...fileItem, |
|
|
|
path: fileItem.path.replace(preNodeTemp.label, resObj.successList[0].newPath), |
|
|
|
update_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), |
|
|
|
} |
|
|
|
await myDatabase.fileList.put({ ...fileParmas }) |
|
|
|
} |
|
|
|
} |
|
|
|
await that.searchTree() |
|
|
|
}) |
|
|
|
// 监听删除文件夹 |
|
|
|
window.electron.ipcRenderer.on('delFloderResult', (eve, res) => { |
|
|
|
let resObj = JSON.parse(res) |
|
|
|
if (resObj.errorList.length) { |
|
|
|
ElMessage({ |
|
|
|
message: `文件夹${resObj.errorList[0].name}删除失败`, |
|
|
|
type: 'error', |
|
|
|
}) |
|
|
|
} else { |
|
|
|
ElMessage({ |
|
|
|
message: `文件夹${resObj.successList[0].name}删除成功`, |
|
|
|
type: 'success', |
|
|
|
}) |
|
|
|
that.searchTree() |
|
|
|
} |
|
|
|
}) |
|
|
|
// 监听创建文件 |
|
|
|
window.electron.ipcRenderer.on('createFileResult', (eve, res) => { |
|
|
|
let resObj = JSON.parse(res) |
|
|
|
if (resObj.errorList.length) { |
|
|
|
let errorList = [] |
|
|
|
for (let i = 0; i < resObj.errorList.length; i++) { |
|
|
|
let element = resObj.errorList[i]; |
|
|
|
errorList.push(element.fileName) |
|
|
|
} |
|
|
|
ElMessage({ |
|
|
|
message: `${resObj.errorList[0].xiangmuName}项目下${resObj.errorList[0].juanName}卷下新增文件${_.join(errorList, ",")}失败`, |
|
|
|
type: 'error', |
|
|
|
}) |
|
|
|
} else { |
|
|
|
let successList = [] |
|
|
|
for (let i = 0; i < resObj.successList.length; i++) { |
|
|
|
let element = resObj.successList[i]; |
|
|
|
successList.push(element.fileName) |
|
|
|
} |
|
|
|
ElMessage({ |
|
|
|
message: `${resObj.successList[0].xiangmuName}项目下${resObj.successList[0].juanName}卷下新增文件${_.join(successList, ",")}成功`, |
|
|
|
type: 'success', |
|
|
|
}) |
|
|
|
that.searchTable() |
|
|
|
} |
|
|
|
}) |
|
|
|
// 监听下载文件 |
|
|
|
window.electron.ipcRenderer.on('downloadFileResult', async (eve, result) => { |
|
|
|
if (!result.success) { |
|
|
|
ElMessage({ |
|
|
|
message: `文件下载失败${result.error}`, |
|
|
|
type: 'error', |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
let data = result.data; |
|
|
|
let blob = new Blob([data], { type: 'application/octet-stream' }); |
|
|
|
let url = window.URL.createObjectURL(blob); |
|
|
|
let a = document.createElement('a'); |
|
|
|
a.href = url; |
|
|
|
a.download = result.path.split('\\').pop(); // 使用文件名作为下载名称 |
|
|
|
document.body.appendChild(a); |
|
|
|
a.click(); |
|
|
|
a.remove(); |
|
|
|
window.URL.revokeObjectURL(url); |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
//确认模态框 |
|
|
|
// async submitDialog() { |
|
|
|
// for (let i = 0; i < this.formHeader.length; i++) { |
|
|
|
// let headItem = this.formHeader[i]; |
|
|
|
// if (headItem.type === "date") { |
|
|
|
// this.adddanganForm.formData[headItem.prop] = dayjs(this.adddanganForm.formData[headItem.prop]).format("YYYY-MM-DD") |
|
|
|
// } |
|
|
|
// } |
|
|
|
// let params = { |
|
|
|
// ...this.adddanganForm.formData, ...this.dealRow(this.adddanganForm.formData), create_at: dayjs().format('YYYY-MM-DD HH:mm:ss'), update_at: dayjs().format('YYYY-MM-DD HH:mm:ss') |
|
|
|
// } |
|
|
|
// if (this.adddanganForm.type === "put") { |
|
|
|
// delete params.create_at |
|
|
|
// } |
|
|
|
// try { |
|
|
|
// await myDatabase.student[this.adddanganForm.type]({ ...params, update_at: dayjs().format('YYYY-MM-DD HH:mm:ss') }) |
|
|
|
// await this.searchData() |
|
|
|
// this.cancelDialog() |
|
|
|
// } catch (e) { |
|
|
|
// ElMessage( |
|
|
|
// { |
|
|
|
// type: "error", |
|
|
|
// message: "时间不允许重复,请重新设置时间" |
|
|
|
// } |
|
|
|
// ) |
|
|
|
// } |
|
|
|
// }, |
|
|
|
|
|
|
|
}, |
|
|
|
async mounted() { |
|
|
@ -495,6 +933,8 @@ export default { |
|
|
|
this.formHeader = _.filter(tableHeaderLocal, o => o.formShow) |
|
|
|
this.exportHeader = _.filter(tableHeaderLocal, o => o.export) |
|
|
|
this.searchTree() |
|
|
|
this.searchTable() |
|
|
|
this.watchApi() |
|
|
|
}, |
|
|
|
} |
|
|
|
</script> |
|
|
|