稽查文档管理
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
fa71af24ad
commit
b76d157fca
|
@ -4050,4 +4050,20 @@ export function setCurrentVersion(data) {
|
|||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
// 工作台-稽查文档移动
|
||||
export function movieFileOrFolder(data) {
|
||||
return request({
|
||||
url: `/AuditDocument/movieFileOrFolder`,
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
// 工作台-稽查文档复制
|
||||
export function copyFileOrFolder(data) {
|
||||
return request({
|
||||
url: `/AuditDocument/copyFileOrFolder`,
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
|
@ -7,7 +7,7 @@
|
|||
<i class="icon el-icon-right icon_open" />
|
||||
<span>{{ $t('trials:trials-workbench:auditDocument:menu:open') }}</span>
|
||||
</div>
|
||||
<div class="contextmenu__item" @click="handleMenu('download')">
|
||||
<div class="contextmenu__item" @click="handleMenu('downLoad')">
|
||||
<i class="icon icon_download" />
|
||||
<span>{{ $t('trials:trials-workbench:auditDocument:menu:download') }}</span>
|
||||
</div>
|
||||
|
@ -21,11 +21,15 @@
|
|||
<i class="icon icon_shear" />
|
||||
<span>{{ $t('trials:trials-workbench:auditDocument:menu:shear') }}</span>
|
||||
</div>
|
||||
<div class="contextmenu__item" @click="handleMenu('stickup')" v-if="checkList.length <= 1 && isCopy">
|
||||
<i class="icon icon_stickup" />
|
||||
<span>{{ $t('trials:trials-workbench:auditDocument:menu:stickup') }}</span>
|
||||
</div>
|
||||
<div class="contextmenu__item" @click="handleMenu('rename')" v-show="checkList.length <= 1">
|
||||
<i class="icon icon_rename" />
|
||||
<span>{{ $t('trials:trials-workbench:auditDocument:menu:rename') }}</span>
|
||||
</div>
|
||||
<div class="contextmenu__item" @click="handleMenu('del')">
|
||||
<div class="contextmenu__item" @click="getDataPath('del')">
|
||||
<i class="icon icon_del" />
|
||||
<span>{{ $t('trials:trials-workbench:auditDocument:menu:del') }}</span>
|
||||
</div>
|
||||
|
@ -65,6 +69,10 @@ export default {
|
|||
return []
|
||||
}
|
||||
},
|
||||
isCopy: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -245,4 +253,16 @@ export default {
|
|||
.icon_Stats {
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
/*粘贴*/
|
||||
.icon_stickup {
|
||||
color: #1890ff;
|
||||
display: inline-block;
|
||||
background-image: url(@/assets/stickup.png);
|
||||
background-position: 0 0;
|
||||
background-size: 16px 16px;
|
||||
background-repeat: no-repeat;
|
||||
height: 16px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
</style>
|
|
@ -36,10 +36,10 @@
|
|||
<el-button type="primary" @click.stop="openFile(true)">
|
||||
{{ $t('trials:trials-workbench:auditDocument:button:uploadFolder') }}
|
||||
</el-button>
|
||||
<el-button type="primary">
|
||||
<el-button type="primary" :disabled="checkList.length <= 0" @click.stop="downLoad(checkList)">
|
||||
{{ $t('trials:trials-workbench:auditDocument:button:download') }}
|
||||
</el-button>
|
||||
<el-button type="primary">
|
||||
<el-button type="primary" :disabled="checkList.length <= 0" @click.stop="delData(checkList)">
|
||||
{{ $t('trials:trials-workbench:auditDocument:button:del') }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
|
@ -54,10 +54,10 @@
|
|||
</el-breadcrumb-item>
|
||||
</el-breadcrumb>
|
||||
</div>
|
||||
<el-table :data="tableData" style="width: 99%" row-key="Id" :loading="loading" :row-style="setRowStyle"
|
||||
v-adaptive="{ bottomOffset: 75 }" height="100" :border="true" :expand-row-keys="expandedRows"
|
||||
:tree-props="{ children: 'Children', hasChildren: 'hasChildren' }" @expand-change="handleExpandChange"
|
||||
@row-click="handleRowClick" @cell-mouse-enter="handleCellMouseEnter"
|
||||
<el-table id="auditDocumentTable" :data="tableData" style="width: 99%" row-key="Id" :loading="loading"
|
||||
:row-style="setRowStyle" v-adaptive="{ bottomOffset: 75 }" height="100" :border="true"
|
||||
:expand-row-keys="expandedRows" :tree-props="{ children: 'Children', hasChildren: 'hasChildren' }"
|
||||
@expand-change="handleExpandChange" @row-click="handleRowClick" @cell-mouse-enter="handleCellMouseEnter"
|
||||
@cell-mouse-leave="handleCellMouseLeave" @row-contextmenu="handleRowContextmenu"
|
||||
@row-dblclick="handleRowDblclick">
|
||||
<el-table-column prop="date" :label="$t('trials:trials-workbench:auditDocument:table:name')" sortable
|
||||
|
@ -97,7 +97,7 @@
|
|||
<el-table-column prop="CreateTime" :label="$t('trials:trials-workbench:auditDocument:table:createTime')">
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<contextmenu ref="contextmenu" :checkList="checkList" @handleMenu="handleMenu" />
|
||||
<contextmenu ref="contextmenu" :isCopy="isCopy" :checkList="checkList" @handleMenu="handleMenu" />
|
||||
<upload-files :config="config" :faccept="faccept" :uploadPath="uploadPath" :limitLength="limitLength"
|
||||
v-if="config.visible" @close="close" @uplaodFile="uplaodFile" />
|
||||
<detail ref="versionDetail" v-if="visible" :visible.sync="visible" :rowData="rowData"
|
||||
|
@ -105,11 +105,12 @@
|
|||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { getAuditDocumentData, addAuditDocument, getBreadcrumbData, updateAuditDocument, deleteAuditDocument, setCurrentVersion } from '@/api/trials'
|
||||
import { getAuditDocumentData, addAuditDocument, getBreadcrumbData, updateAuditDocument, deleteAuditDocument, setCurrentVersion, movieFileOrFolder, copyFileOrFolder } from '@/api/trials'
|
||||
import Pagination from '@/components/Pagination'
|
||||
import contextmenu from './contextmenu.vue'
|
||||
import uploadFiles from '@/views/trials/trials-panel/trial-summary/trial-document/components/uploadFiles.vue'
|
||||
import detail from './detail.vue'
|
||||
import { downLoadFile } from '@/utils/stream.js'
|
||||
const searchDataDefault = () => {
|
||||
return {
|
||||
Name: null,
|
||||
|
@ -128,6 +129,11 @@ export default {
|
|||
default: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isCopy() {
|
||||
return (this.copyList && this.copyList.length > 0) || this.shearList && this.shearList.length > 0
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
searchData: searchDataDefault(),
|
||||
|
@ -198,19 +204,168 @@ export default {
|
|||
console.log(err)
|
||||
}
|
||||
},
|
||||
getData(list, Id) {
|
||||
let data = {}
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
let item = list[i]
|
||||
if (item.Id === Id) {
|
||||
data = item
|
||||
// 下载
|
||||
async downLoad(list) {
|
||||
try {
|
||||
let arr = this.filterExternalIds(this.tableData, list)
|
||||
if (arr && arr.length === 1) {
|
||||
let data = this.getData(this.tableData, arr[0])
|
||||
if (data.AuditDocumentTypeEnum) {
|
||||
return await downLoadFile(
|
||||
this.OSSclientConfig.basePath + data.FilePath,
|
||||
data.Name
|
||||
)
|
||||
} else {
|
||||
let dataArray = this.getDataPath([data])
|
||||
let files = this.formatDownloadFile(dataArray)
|
||||
console.log(files, 'files')
|
||||
let name = `${data.Name}_${new Date().getTime()}.zip`
|
||||
return await downLoadFile(files, name, 'zip')
|
||||
}
|
||||
} else {
|
||||
let name = null
|
||||
let id = this.findDeepestCommonParent(this.tableData, arr)
|
||||
if (id) {
|
||||
let d = this.getData(this.tableData, id)
|
||||
name = `${d.Name}_${new Date().getTime()}.zip`
|
||||
} else {
|
||||
name = `AuditDocument_${new Date().getTime()}.zip`
|
||||
}
|
||||
let data = arr.map(id => this.getData(this.tableData, id))
|
||||
let dataArray = this.getDataPath(data)
|
||||
let files = this.formatDownloadFile(dataArray)
|
||||
return await downLoadFile(files, name, 'zip')
|
||||
}
|
||||
if (item.Children && item.Children.length > 0) {
|
||||
data = this.getData(item.Children, Id)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
},
|
||||
formatDownloadFile(list) {
|
||||
let files = []
|
||||
for (const item of list) {
|
||||
let obj = {
|
||||
name: item.Name.split('.')[1] ? item.Path : `${item.Path}.${item.FileFormat}`,
|
||||
url: this.OSSclientConfig.basePath + item.FilePath
|
||||
}
|
||||
files.push(obj)
|
||||
}
|
||||
return files
|
||||
},
|
||||
findDeepestCommonParent(rootNodes, ids) {
|
||||
// 构建节点ID到节点的映射
|
||||
const nodeMap = new Map();
|
||||
function buildMap(nodes) {
|
||||
for (const node of nodes) {
|
||||
nodeMap.set(node.Id, node);
|
||||
if (node.Children && node.Children.length > 0) {
|
||||
buildMap(node.Children);
|
||||
}
|
||||
}
|
||||
}
|
||||
buildMap(rootNodes);
|
||||
|
||||
// 生成每个ID的路径数组(从根到当前节点)
|
||||
const paths = [];
|
||||
for (const id of ids) {
|
||||
const path = [];
|
||||
let currentNode = nodeMap.get(id);
|
||||
if (!currentNode) continue; // 忽略无效ID
|
||||
|
||||
// 向上遍历直到根节点
|
||||
while (currentNode) {
|
||||
path.unshift(currentNode.Id); // 插入到前面以形成根到当前路径
|
||||
const parentId = currentNode.ParentId;
|
||||
if (parentId === null) break; // 根节点无父节点
|
||||
currentNode = nodeMap.get(parentId);
|
||||
}
|
||||
paths.push(path);
|
||||
}
|
||||
|
||||
if (paths.length === 0) return null; // 无有效ID
|
||||
|
||||
// 寻找最长公共前缀
|
||||
const findLongestCommonPrefix = (paths) => {
|
||||
if (paths.length === 0) return [];
|
||||
let common = paths[0];
|
||||
for (let i = 1; i < paths.length; i++) {
|
||||
const currentPath = paths[i];
|
||||
let j = 0;
|
||||
while (j < common.length && j < currentPath.length && common[j] === currentPath[j]) {
|
||||
j++;
|
||||
}
|
||||
common = common.slice(0, j);
|
||||
if (common.length === 0) break;
|
||||
}
|
||||
return common;
|
||||
};
|
||||
|
||||
const lcp = findLongestCommonPrefix(paths);
|
||||
return lcp.length > 0 ? lcp[lcp.length - 1] : null;
|
||||
},
|
||||
getDataPath(list, str = '', ARRAY = []) {
|
||||
for (const item of list) {
|
||||
console.log(item.AuditDocumentTypeEnum, str)
|
||||
if (!str) {
|
||||
item.Path = item.Name
|
||||
} else {
|
||||
item.Path = str + '/' + item.Name
|
||||
}
|
||||
if (item.AuditDocumentTypeEnum) {
|
||||
ARRAY.push(item)
|
||||
continue
|
||||
} else {
|
||||
if (item.Children && item.Children.length > 0) {
|
||||
this.getDataPath(item.Children, item.Path, ARRAY)
|
||||
}
|
||||
}
|
||||
}
|
||||
return ARRAY
|
||||
},
|
||||
getData(list, Id, data = {}) {
|
||||
for (const item of list) {
|
||||
if (item.Id === Id) {
|
||||
data = item
|
||||
break
|
||||
} else {
|
||||
if (item.Children && item.Children.length > 0) {
|
||||
data = this.getData(item.Children, Id, data)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return data
|
||||
},
|
||||
filterExternalIds(tree, ids) {
|
||||
if (!tree || tree.length === 0 || !ids || ids.length === 0) return [];
|
||||
const parentMap = this.buildParentMap(tree);
|
||||
const idSet = new Set(ids);
|
||||
const externalIds = new Set();
|
||||
|
||||
for (const id of ids) {
|
||||
let currentId = parentMap.get(id);
|
||||
while (currentId !== null) {
|
||||
if (idSet.has(currentId)) {
|
||||
externalIds.add(currentId);
|
||||
}
|
||||
currentId = parentMap.get(currentId);
|
||||
}
|
||||
}
|
||||
|
||||
return ids.filter(id => !externalIds.has(id));
|
||||
},
|
||||
buildParentMap(tree) {
|
||||
const parentMap = new Map();
|
||||
const traverse = (node, parentId) => {
|
||||
parentMap.set(node.Id, parentId);
|
||||
for (const child of node.Children) {
|
||||
traverse(child, node.Id);
|
||||
}
|
||||
};
|
||||
for (const root of tree) {
|
||||
traverse(root, null);
|
||||
}
|
||||
return parentMap;
|
||||
},
|
||||
handleSearch() {
|
||||
this.getList()
|
||||
},
|
||||
|
@ -219,7 +374,13 @@ export default {
|
|||
this.getList()
|
||||
},
|
||||
addCheck(row) {
|
||||
this.checkList.push(row.Id)
|
||||
let index = this.checkList.indexOf(row.Id)
|
||||
if (!!~index) {
|
||||
this.checkList.splice(index, 1)
|
||||
} else {
|
||||
this.checkList.push(row.Id)
|
||||
}
|
||||
|
||||
},
|
||||
addRenameId(row) {
|
||||
this.renameId = row.Id
|
||||
|
@ -283,6 +444,42 @@ export default {
|
|||
console.log(err)
|
||||
}
|
||||
},
|
||||
// 复制数据
|
||||
async copyData(list) {
|
||||
try {
|
||||
let DATA = this.getData(this.tableData, this.checkList[0])
|
||||
let Ids = this.filterExternalIds(this.tableData, list)
|
||||
let data = {
|
||||
Ids: Ids,
|
||||
ParentId: DATA.AuditDocumentTypeEnum ? DATA.ParentId : DATA.Id
|
||||
}
|
||||
let res = await copyFileOrFolder(data)
|
||||
if (res.IsSuccess) {
|
||||
this.getList()
|
||||
this.copyList = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
},
|
||||
// 移动数据
|
||||
async moveData(list) {
|
||||
try {
|
||||
let DATA = this.getData(this.tableData, this.checkList[0])
|
||||
let Ids = this.filterExternalIds(this.tableData, list)
|
||||
let data = {
|
||||
Ids: Ids,
|
||||
ParentId: DATA.AuditDocumentTypeEnum ? DATA.ParentId : DATA.Id
|
||||
}
|
||||
let res = await movieFileOrFolder(data)
|
||||
if (res.IsSuccess) {
|
||||
this.getList()
|
||||
this.shearList = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
},
|
||||
// 删除数据
|
||||
async delData(Ids) {
|
||||
try {
|
||||
|
@ -498,7 +695,7 @@ export default {
|
|||
// 单行右键单击(右键菜单)
|
||||
handleRowContextmenu(row, column, e) {
|
||||
e.preventDefault();
|
||||
if (!this.checkList.includes(row.Id)) this.handleRowClick(row)
|
||||
if (!this.checkList.includes(row.Id)) this.handleRowClick(row, {}, e)
|
||||
if (this.checkList.length > 1) return this.$refs.contextmenu.init(e, row, 'files')
|
||||
if (!row.AuditDocumentTypeEnum) return this.$refs.contextmenu.init(e, row, 'folder')
|
||||
this.$refs.contextmenu.init(e, row, 'file')
|
||||
|
@ -513,14 +710,30 @@ export default {
|
|||
}
|
||||
},
|
||||
// 单行左键单击
|
||||
handleRowClick(row) {
|
||||
handleRowClick(row, column, e) {
|
||||
e.stopPropagation();
|
||||
this.rowData = row
|
||||
let index = this.checkList.indexOf(row.Id)
|
||||
if (this.ctrlKey) {
|
||||
this.checkList.push(row.Id)
|
||||
if (!!~index) {
|
||||
this.checkList.splice(index, 1)
|
||||
} else {
|
||||
this.checkList.push(row.Id)
|
||||
}
|
||||
} else {
|
||||
this.checkList = [row.Id]
|
||||
if (this.checkList.length > 1 || this.checkList.length <= 0) {
|
||||
this.checkList = [row.Id]
|
||||
} else {
|
||||
if (!!~index) {
|
||||
this.checkList.splice(index, 1)
|
||||
} else {
|
||||
this.checkList = [row.Id]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
// 单行hover移入
|
||||
handleCellMouseEnter(row) {
|
||||
|
@ -561,6 +774,18 @@ export default {
|
|||
if (key === 'setVersion') {
|
||||
this.setCurrentVersion(row.Id)
|
||||
}
|
||||
if (key === 'copy') {
|
||||
this.copy()
|
||||
}
|
||||
if (key === 'shear') {
|
||||
this.shear()
|
||||
}
|
||||
if (key === 'stickup') {
|
||||
this.stickup()
|
||||
}
|
||||
if (key === 'downLoad') {
|
||||
this.downLoad(this.checkList)
|
||||
}
|
||||
},
|
||||
setRowStyle({ row, rowIndex }) {
|
||||
if (this.checkList.includes(row.Id)) {
|
||||
|
@ -570,11 +795,26 @@ export default {
|
|||
}
|
||||
},
|
||||
// 复制
|
||||
copy() { },
|
||||
copy() {
|
||||
if (!this.checkList || this.checkList.length <= 0) return this.$message.warning(this.$t("trials:trials-workbench:auditDocument:message:nothingCopy"))
|
||||
this.copyList = [...this.checkList]
|
||||
this.shearList = []
|
||||
this.$message.success(this.$t("trials:trials-workbench:auditDocument:message:copySuccess"))
|
||||
},
|
||||
// 剪切
|
||||
shear() { },
|
||||
shear() {
|
||||
if (!this.checkList || this.checkList.length <= 0) return this.$message.warning(this.$t("trials:trials-workbench:auditDocument:message:nothingShear"))
|
||||
this.shearList = [...this.checkList]
|
||||
this.copyList = []
|
||||
this.$message.success(this.$t("trials:trials-workbench:auditDocument:message:shearSuccess"))
|
||||
},
|
||||
// 粘贴
|
||||
stickup() { },
|
||||
stickup() {
|
||||
if (this.checkList.length > 1) return this.$message.warning(this.$t("trials:trials-workbench:auditDocument:message:stickupCheckDataMore"))
|
||||
if (this.shearList && this.shearList.length > 0) return this.moveData(this.shearList)
|
||||
if (this.copyList && this.copyList.length > 0) return this.copyData(this.copyList)
|
||||
},
|
||||
|
||||
// 键盘事件(按下)
|
||||
keydown(e) {
|
||||
this.ctrlKey = e.ctrlKey
|
||||
|
@ -600,11 +840,16 @@ export default {
|
|||
// 键盘事件(松开)
|
||||
keyup(e) {
|
||||
this.ctrlKey = e.ctrlKey
|
||||
},
|
||||
docClick() {
|
||||
this.checkList = []
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
document.addEventListener('keydown', this.keydown);
|
||||
document.addEventListener('keyup', this.keyup);
|
||||
let table = document.getElementById("auditDocumentTable")
|
||||
table.addEventListener('click', this.docClick);
|
||||
this.getList()
|
||||
this.getBreadcrumbData()
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue