<!--
*Author:jxx
*Contact:283591387@qq.com
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*业务请在@/extension/system/dynamic_general_ledger/dynamic_general_ledger.jsx此处编写
-->
<template>
<view-grid ref="grid"
:columns="columns"
:detail="detail"
:editFormFields="editFormFields"
:editFormOptions="editFormOptions"
:searchFormFields="searchFormFields"
:searchFormOptions="searchFormOptions"
:table="table"
:extend="extend">
</view-grid>
<el-dialog
v-model="isDialogVisible"
title="文档权限信息"
width="90%"
:before-close="handleClose"
style="max-width: 1400px"
>
<div class="dialog-content">
<!-- 文档基本信息 -->
<!-- <el-descriptions title="文档基本信息" :column="2" border style="margin-bottom: 20px">
<el-descriptions-item label="文档编码">{{ currentDocument.code }}</el-descriptions-item>
<el-descriptions-item label="文档名称">{{ currentDocument.name }}</el-descriptions-item>
<el-descriptions-item label="文档所属工厂">{{
currentDocument.creatorFactory
}}</el-descriptions-item>
<el-descriptions-item label="文档安全等级">{{
currentDocument.level
}}</el-descriptions-item>
<el-descriptions-item label="文档状态">{{ currentDocument.state }}</el-descriptions-item>
<el-descriptions-item label="文档类型">{{ currentDocument.type }}</el-descriptions-item>
<el-descriptions-item label="项目编码">{{
currentDocument.projectCode
}}</el-descriptions-item>
<el-descriptions-item label="项目名称">{{
currentDocument.projectName
}}</el-descriptions-item>
<el-descriptions-item label="项目涉及工厂">{{
currentDocument.projectFactories
}}</el-descriptions-item>
<el-descriptions-item label="项目类型">{{
currentDocument.projectCgr
}}</el-descriptions-item>
</el-descriptions>
<el-divider /> -->
<h3>文档授权信息</h3>
</div>
<el-tabs v-model="activeAccessTab" class="demo-tabs" type="card">
<el-tab-pane label="用户" name="user">
<div class="user-controls" :style="{ marginBottom: '15px', marginLeft: '5px' }">
<div>
<span><strong>搜索权限用户:</strong></span>
<el-input
v-model="searchUserInput"
placeholder="请输入工号/姓名"
style="width: 200px; margin-right: 10px"
/>
<el-button type="primary" @click="handleSearchAccessUser">搜索</el-button>
</div>
<div style="display: flex; justify-content: flex-end; margin-left: auto">
<!-- <el-button @click="clearUserFilters">重置筛选条件</el-button> -->
<!-- <el-button type="primary" @click="addUser" style="margin-left: 10px">
新增权限
</el-button> -->
</div>
</div>
<el-table
ref="accessUserTableRef"
:data="userList"
row-key="id"
border
height="500"
stripe
:header-cell-style="{ background: '#F8F8F9', color: '#333', textAlign: 'center' }"
:cell-style="{ textAlign: 'center' }"
default-expand-all
:scrollbar-always-on="true"
class="content-right-table"
>
<el-table-column label="操作" width="100">
<template #default="scope">
<el-button
type="text"
:style="{ color: scope.row.accessType === '特殊' ? '#409EFF' : '#909399' }"
@click="deleteUser(scope.row)"
>删除</el-button
>
<el-button
type="text"
:style="{ color: scope.row.accessType === '特殊' ? '#409EFF' : '#909399' }"
@click="updateUser(scope.row)"
>修改</el-button
>
</template>
</el-table-column>
<el-table-column label="查看权限" width="120">
<template #default="scope">
<el-checkbox
:model-value="scope.row.checkAccess === 0"
:style="{ color: scope.row.accessType === '特殊' ? '#409EFF' : '#909399' }"
:disabled="true"
/>
</template>
</el-table-column>
<el-table-column prop="userName" label="工号" width="120" />
<el-table-column prop="userTrueName" label="姓名" width="120" />
<el-table-column prop="organization" label="事业部" width="150">
<template #default="scope">{{ scope.row.organization }}</template>
</el-table-column>
<el-table-column prop="department" label="工厂/部门" width="150">
<template #default="scope">{{ scope.row.department }}</template>
</el-table-column>
<el-table-column prop="position" label="职位" width="120">
<template #default="scope">{{ scope.row.position || '无' }}</template>
</el-table-column>
<el-table-column prop="projectRole" label="项目角色" width="120">
<template #default="scope">{{ scope.row.projectRole }}</template>
</el-table-column>
<el-table-column prop="systemRole" label="系统角色" width="120">
<template #default="scope">{{ scope.row.systemRole }}</template>
</el-table-column>
<el-table-column prop="accessType" label="权限类型" width="120">
<template #default="scope">
<el-tag :type="getTagType(scope.row.accessType)">{{ scope.row.accessType }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="modifyDate" label="授权日期" width="150">
<template #default="scope">{{ scope.row.modifyDate || '无' }}</template>
</el-table-column>
<el-table-column prop="modifierName" label="授权人工号" width="120">
<template #default="scope">{{ scope.row.modifierName || '无' }}</template>
</el-table-column>
<el-table-column prop="modifierTrueName" label="授权人姓名" width="120">
<template #default="scope">{{ scope.row.modifierTrueName || '无' }}</template>
</el-table-column>
</el-table>
<el-pagination
class="mt-3"
style="display: flex; justify-content: flex-end; margin-top: 10px"
background
layout="total, sizes, prev, pager, next, jumper"
:total="accessUsersTotal"
:page-sizes="[10, 20, 30, 50]"
:page-size="accessUsersPageSize"
:current-page="accessUsersCurrentPage"
@size-change="handleAccessUsersSizeChange"
@current-change="handleAccessUsersCurrentChange"
/>
</el-tab-pane>
<el-tab-pane label="角色" name="roles">
<div class="user-controls" :style="{ marginBottom: '15px', marginLeft: '5px' }">
<div>
<span><strong>搜索权限角色:</strong></span>
<el-input
v-model="searchRoleInput"
placeholder="请输入角色ID/名称"
style="width: 200px; margin-right: 10px"
/>
<el-button type="primary" @click="handleSearchAccessRole">搜索</el-button>
</div>
<!-- <div style="display: flex; justify-content: flex-end; margin-left: auto">
<el-button type="primary" @click="addUser" style="margin-left: 10px">
新增权限
</el-button>
</div> -->
</div>
<el-table
ref="accessRoleTableRef"
:data="accessRolesList"
row-key="id"
border
height="500"
style="width: 100%"
fit
:header-cell-style="{ background: '#F8F8F9', color: '#333', textAlign: 'center' }"
:cell-style="{ textAlign: 'center' }"
default-expand-all
:scrollbar-always-on="true"
class="content-right-table"
>
<el-table-column label="操作">
<template #default="scope">
<el-button type="text" :style="{ color: '#409EFF' }" @click="deleteRole(scope.row)"
>删除</el-button
>
<el-button type="text" :style="{ color: '#409EFF' }" @click="updateRole(scope.row)"
>修改</el-button
>
</template>
</el-table-column>
<el-table-column label="查看权限">
<template #default="scope">
<el-checkbox :model-value="scope.row.check_access === 0" :disabled="true" />
</template>
</el-table-column>
<el-table-column prop="role_id" label="角色ID" />
<el-table-column prop="role_name" label="角色名称" />
<el-table-column prop="access_type" label="权限类型">
<template #default="scope">
<el-tag :type="getTagType(scope.row.access_type)">{{ scope.row.access_type }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="modify_date" label="授权日期">
<template #default="scope">{{ scope.row.modify_date || '无' }}</template>
</el-table-column>
<el-table-column prop="modifier_name" label="授权人工号">
<template #default="scope">{{ scope.row.modifier_name || '无' }}</template>
</el-table-column>
<el-table-column prop="modifier_truename" label="授权人姓名">
<template #default="scope">{{ scope.row.modifier_truename || '无' }}</template>
</el-table-column>
</el-table>
<el-pagination
class="mt-3"
style="display: flex; justify-content: flex-end; margin-top: 10px"
background
layout="total, sizes, prev, pager, next, jumper"
:total="accessRolesTotal"
:page-sizes="[10, 20, 30, 50]"
:page-size="accessRolesPageSize"
:current-page="accessRolesCurrentPage"
@size-change="handleAccessRolesSizeChange"
@current-change="handleAccessRolesCurrentChange"
/>
</el-tab-pane>
</el-tabs>
</el-dialog>
</template>
<script>
import extend from "@/extension/system/dynamic_general_ledger/dynamic_general_ledger.jsx";
import { ref, defineComponent,h } from "vue";
import axios from 'axios'
import { ElDialog, ElRow, ElCol, ElButton, ElLink, ElMessage,ElIcon} from 'element-plus'
import { useRouter } from 'vue-router'
import Message from '@/views/index/Message.vue'
import { View } from '@element-plus/icons-vue';
const isDialogVisible = ref(false)
const dialogContent = ref('')
const accessUsersCurrentPage = ref(1)
const accessUsersPageSize = ref(10)
const accessRolesCurrentPage = ref(1)
const accessRolesPageSize = ref(10)
const activeAccessTab = ref('user')
const userList = ref([])
const accessUsersTotal = ref(0)
const searchUserInput = ref('')
const accessRolesList = ref([])
const searchRoleInput = ref('')
const accessRolesTotal = ref(0)
var document = {
id: '',
dr: '',
code: '',
name: '',
area: '',
typeCode: '',
type: '',
level: '',
state: '',
projectName: '',
projectCgr: '',
projectCode: '',
projectFactories: '',
creatorId: '',
creatorName: '',
creatorFactoryId: '',
creatorFactory: ''
}
const { proxy } = getCurrentInstance()
const openDialog = (params.row) => {
debugger
userList.value = []
accessRolesList.value = []
searchUserInput.value = ''
searchRoleInput.value = ''
activeAccessTab.value = 'user'
isDialogVisible.value = true
//重置分页
accessUsersCurrentPage.value = 1
accessUsersPageSize.value = 10
accessRolesCurrentPage.value = 1
accessRolesPageSize.value = 10
userListUpdate(document, '')
roleListUpdate(document, '')
}
// 搜索按钮点击事件
const handleSearchAccessUser = () => {
accessUsersCurrentPage.value = 1
userListUpdate(document, searchUserInput.value)
}
const handleAccessUsersCurrentChange = (page) => {
userList.value = []
accessUsersCurrentPage.value = page
userListUpdate(document, searchUserInput.value)
}
const handleAccessUsersSizeChange = (size) => {
accessUsersPageSize.value = size
accessUsersCurrentPage.value = 1
userListUpdate(document, searchUserInput.value)
}
const getDocument = async (params) => {
console.log(params)
debugger
try {
const document1 = {
code: params.row.file_code
}
const response1 = await axios.post('/api/Sys_File_Info/getDocumentrefer', document1)
console.log('===response1.data.value==:', response1.data)
console.log('===response1.data.value==:', response1.data.id)
document.id = response1.data.id
document.dr = response1.data.dr
document.code = response1.data.code
document.name = response1.data.name
document.area = response1.data.area
document.type = response1.data.type
document.level = response1.data.level
document.state = response1.data.state
document.projectName = response1.data.projectName
document.projectCgr = response1.data.projectCgr
document.projectCode = response1.data.projectCode
document.projectFactories = response1.data.projectFactories
document.creatorId = response1.data.creatorId
document.creatorName = response1.data.creatorName
document.creatorFactoryId = response1.data.creatorFactoryId
document.creatorFactory = response1.data.creatorFactory
console.log('========document:======', document)
} catch (error) {
// proxy.$message.error(`获取文件信息失败:${error.message}`)
}
}
const userListUpdate = async (document, searchQuery) => {
try {
const params = {
page: accessUsersCurrentPage.value,
pageSize: accessUsersPageSize.value,
file: document,
searchQuery: searchQuery || '' // 传递搜索词
}
const response = await axios.post('/api/Access_File/getAccessUsersByFileWithPaging', params)
userList.value = response.data.items.map((user) => ({
...user,
projectRole: user.projectRole ? user.projectRole : '无'
}))
accessUsersTotal.value = response.data.total
console.log('userList.value:', userList.value)
} catch (error) {
proxy.$message.error(`获取权限用户失败:${error.message}`)
}
}
const roleListUpdate = async (document, searchQuery) => {
try {
// const response1 = await axios.post('/api/Sys_File_Info/getDocument', {
// file: document
// })
const params = {
page: accessRolesCurrentPage.value,
pageSize: accessRolesPageSize.value,
file: document,
searchQuery: searchQuery || '' // 传递搜索词
}
const response = await axios.post(
'/api/Access_File_Role/getAccessRolesByFileWithPaging',
params
)
accessRolesList.value = response.data.items.map((role) => ({
...role,
access_type: '角色'
}))
accessRolesTotal.value = response.data.total
} catch (error) {
proxy.$message.error(`获取角色权限失败:${error.message}`)
console.log(`获取角色权限失败:${error.message}`)
}
}
export default defineComponent({
setup() {
const table = ref({
key: 'id',
footer: "Foots",
cnName: '动态一本账',
name: 'dynamic_general_ledger/dynamic_general_ledger',
url: "/dynamic_general_ledger/",
sortName: "id"
});
const editFormFields = ref({});
const editFormOptions = ref([]);
const searchFormFields = ref({});
const searchFormOptions = ref([]);
const columns = ref([{field:'id',title:'序号',type:'long',width:120,require:true,align:'left',sort:true},
{field:'file_id',title:'文档ID',type:'string',width:110,align:'left'},
{field:'file_type',title:'文档类型',type:'string',width:110,align:'left'},
{field:'business_scenario',title:'所属业务场景',type:'string',width:110,align:'left'},
{field:'belong_stage',title:'所属阶段',type:'string',width:110,align:'left'},
{field:'model_project',title:'所属车型项目',type:'string',width:110,align:'left'},
{field:'project_type',title:'项目类型',type:'string',width:110,align:'left'},
{field:'product_model_number',title:'所属产品型号',type:'string',width:110,align:'left'},
{field:'file_security_level',title:'文档安全等级',type:'string',width:110,align:'left'},
{field:'file_code',title:'文件编号',type:'string',width:110,align:'left'},
{field:'file_version',title:'文件版本',type:'string',width:110,align:'left'},
{field:'file_state',title:'文件状态',type:'string',width:110,align:'left'},
{field:'development_tool',title:'编制工具',type:'string',width:110,align:'left'},
{field:'tool_code',title:'编制工具代码',type:'string',width:110,align:'left'},
{field:'method',title:'编制方式',type:'string',width:110,align:'left'},
{field:'collaboration_information',title:'协作信息',type:'string',width:110,align:'left'},
{field:'review_tool_platform',title:'评审工具/平台',type:'string',width:110,align:'left'},
{field:'review_method',title:'评审方式',type:'string',width:110,align:'left'},
{field:'review_scope',title:'评审范围',type:'string',width:110,align:'left'},
//评审角色需做对比
{field:'review_role',title:'评审角色',type:'string',width:110,align:'left'},
/*{
field: 'review_role',
title: '评审角色',
type: 'string',
width: 110,
align: 'left',
render: async (value, params) => {
console.log(value)
debugger
// 构造请求参数
const param = {
FileType: params.row.file_type,
};
try {
const response = await axios.post('/api/Review_Info/IsRole', param, {
headers: { 'Content-Type': 'application/json' }
});
const backendRoles = response.data.review_role.split(',').map(r => r.trim()).sort();
const frontendRoles = value.split(',').map(r => r.trim()).sort();
// 判断是否完全一致
if (JSON.stringify(frontendRoles) === JSON.stringify(backendRoles)) {
return value; // 一致,直接返回原值
}
// 不一致,高亮多余部分
const backendSet = new Set(backendRoles);
const highlightRoles = frontendRoles.map(role => {
return backendSet.has(role) ? role : `<span style="color: red;">${role}</span>`;
});
return highlightRoles.join(', ');
} catch (error) {
console.error('接口调用失败', error);
return value; // 出错返回原始值
}
}
},*/
{field:'transfer_tool',title:'传输工具',type:'string',width:110,align:'left'},
{field:'transfer_method',title:'传输方式',type:'string',width:110,align:'left'},
{field:'transfer_scope',title:'传输范围',type:'string',width:110,align:'left'},
{field:'transfer_format',title:'传输格式',type:'string',width:110,align:'left'},
{field:'publishing_platform',title:'发布平台',type:'string',width:110,align:'left'},
{field:'sharing_platform',title:'共享平台',type:'string',width:110,align:'left'},
{field:'sharing_method',title:'共享方式',type:'string',width:110,align:'left'},
{field:'sharing_scope',title:'共享范围',type:'string',width:110,align:'left'},
{
title: '操作',
width: 100,
align: 'center',
fixed: 'right', // 固定在表格最右侧
render: (h, params) => {
return [
h('i', {
class: 'el-icon-view preview-icon', // 使用 Element Plus 图标
style: 'cursor: pointer; margin-right: 10px;', // 添加样式
onClick: () => openDialog(params.row || '') // 点击事件处理函数
}),
]
}
},
{field:'integration_platform',title:'集成平台',type:'string',width:110,align:'left'},
{field:'storage_platform',title:'存储平台',type:'string',width:110,align:'left'},
{field:'retention_period',title:'保管期限',type:'string',width:110,align:'left'},
{field:'storage_strategy',title:'存储策略',type:'string',width:110,align:'left'},
{field:'backup_requirements',title:'备份要求',type:'string',width:110,align:'left'}]);
const detail = ref({
cnName: "#detailCnName",
table: "#detailTable",
columns: [],
sortName: "",
key: ""
});
return {
table,
extend,
editFormFields,
editFormOptions,
searchFormFields,
searchFormOptions,
columns,
detail,
};
},
});
</script>
我现在想点击这里后{
title: '操作',
width: 100,
align: 'center',
fixed: 'right', // 固定在表格最右侧
render: (h, params) => {
return [
h('i', {
class: 'el-icon-view preview-icon', // 使用 Element Plus 图标
style: 'cursor: pointer; margin-right: 10px;', // 添加样式
onClick: () => openDialog(params.row || '') // 点击事件处理函数
}),
]
}
},弹出弹窗,调用getDocument方法获得document数据,然后接着调用这两个方法 const userListUpdate = async (document, searchQuery) => {
try {
const params = {
page: accessUsersCurrentPage.value,
pageSize: accessUsersPageSize.value,
file: document,
searchQuery: searchQuery || '' // 传递搜索词
}
const response = await axios.post('/api/Access_File/getAccessUsersByFileWithPaging', params)
userList.value = response.data.items.map((user) => ({
...user,
projectRole: user.projectRole ? user.projectRole : '无'
}))
accessUsersTotal.value = response.data.total
console.log('userList.value:', userList.value)
} catch (error) {
proxy.$message.error(`获取权限用户失败:${error.message}`)
}
}
const roleListUpdate = async (document, searchQuery) => {
try {
// const response1 = await axios.post('/api/Sys_File_Info/getDocument', {
// file: document
// })
const params = {
page: accessRolesCurrentPage.value,
pageSize: accessRolesPageSize.value,
file: document,
searchQuery: searchQuery || '' // 传递搜索词
}
const response = await axios.post(
'/api/Access_File_Role/getAccessRolesByFileWithPaging',
params
)
accessRolesList.value = response.data.items.map((role) => ({
...role,
access_type: '角色'
}))
accessRolesTotal.value = response.data.total
} catch (error) {
proxy.$message.error(`获取角色权限失败:${error.message}`)
console.log(`获取角色权限失败:${error.message}`)
}
}获得弹窗中需要的数据,然后弹窗中的信息根据这些方法返回的数据赋值,我现在代码有啥问题吗,因为有一部分是我直接复制粘贴的