模板权限过滤
This commit is contained in:
@@ -69,13 +69,15 @@
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="发布范围" name="publishOrgIds" class="field-span-2">
|
||||
<a-select
|
||||
<a-tree-select
|
||||
v-model:value="formState.publishOrgIds"
|
||||
mode="multiple"
|
||||
:options="orgOptions"
|
||||
placeholder="请选择模板发布范围"
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
:tree-data="orgTreeData"
|
||||
multiple
|
||||
tree-checkable
|
||||
:show-checked-strategy="SHOW_PARENT"
|
||||
placeholder="请选择模板发布范围(选择上级则其子级均可见)"
|
||||
allow-clear
|
||||
tree-default-expand-all
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
@@ -323,7 +325,7 @@ import PizZip from 'pizzip'
|
||||
import { renderAsync } from 'docx-preview'
|
||||
import {
|
||||
downloadTemplateFile,
|
||||
queryManifestOrgOptions,
|
||||
getOrgTree,
|
||||
uploadTemplateFile,
|
||||
} from '@/api/manifest.js'
|
||||
import { contractTypeTreeOptions } from '../contractTypeOptions.js'
|
||||
@@ -367,7 +369,8 @@ const templateArrayBuffer = ref(null)
|
||||
const templateUploadList = ref([])
|
||||
const variableMappings = ref([])
|
||||
const detectedVariableKeys = ref([])
|
||||
const orgOptions = ref([])
|
||||
const orgTreeData = ref([])
|
||||
const SHOW_PARENT = 'SHOW_PARENT'
|
||||
const templateFieldList = ref([])
|
||||
|
||||
let previewTimer = null
|
||||
@@ -761,7 +764,7 @@ async function renderPreview() {
|
||||
|
||||
function buildRecord(status) {
|
||||
const now = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
const orgNameMap = new Map(orgOptions.value.map((item) => [item.value, item.label]))
|
||||
const orgNameMap = buildOrgNameMap(orgTreeData.value)
|
||||
const publishOrgNames = (formState.publishOrgIds || [])
|
||||
.map((item) => orgNameMap.get(item))
|
||||
.filter(Boolean)
|
||||
@@ -933,16 +936,43 @@ async function handleDownloadCurrentTemplate() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将后端组织树节点转为 a-tree-select 需要的格式
|
||||
*/
|
||||
function convertOrgTreeToTreeSelect(node) {
|
||||
const treeNode = {
|
||||
value: String(node.id),
|
||||
label: (node.orgName || '').trim(),
|
||||
}
|
||||
if (node.children && node.children.length > 0) {
|
||||
treeNode.children = node.children.map(convertOrgTreeToTreeSelect)
|
||||
}
|
||||
return treeNode
|
||||
}
|
||||
|
||||
/**
|
||||
* 从树数据构建 orgId → orgName 的映射(递归遍历)
|
||||
*/
|
||||
function buildOrgNameMap(treeData) {
|
||||
const map = new Map()
|
||||
function walk(list) {
|
||||
if (!list) return
|
||||
for (const item of list) {
|
||||
map.set(item.value, item.label)
|
||||
walk(item.children)
|
||||
}
|
||||
}
|
||||
walk(treeData)
|
||||
return map
|
||||
}
|
||||
|
||||
async function showModal(record = {}, mode = 'create') {
|
||||
resetState()
|
||||
modalMode.value = mode || 'create'
|
||||
await ensureTemplateFieldListLoaded()
|
||||
if (!orgOptions.value.length) {
|
||||
const orgList = await queryManifestOrgOptions()
|
||||
orgOptions.value = (orgList || []).map((item) => ({
|
||||
label: item.orgName,
|
||||
value: item.orgId,
|
||||
}))
|
||||
if (!orgTreeData.value.length) {
|
||||
const tree = await getOrgTree()
|
||||
orgTreeData.value = (tree || []).map(convertOrgTreeToTreeSelect)
|
||||
}
|
||||
|
||||
const defaultState = createDefaultFormState()
|
||||
|
||||
Reference in New Issue
Block a user