diff --git a/dist.zip b/dist.zip deleted file mode 100644 index 62483ad..0000000 Binary files a/dist.zip and /dev/null differ diff --git a/src/api/oa/oaCompany/model/index.ts b/src/api/oa/oaCompany/model/index.ts index 9224fe1..613ba58 100644 --- a/src/api/oa/oaCompany/model/index.ts +++ b/src/api/oa/oaCompany/model/index.ts @@ -108,6 +108,8 @@ export interface OaCompany { updateTime?: string; // 知识库id kbId?: string; + // 资料库库IDs + libraryIds?: string; } /** diff --git a/src/views/oa/oaCompany/components/oaCompanyEdit.vue b/src/views/oa/oaCompany/components/oaCompanyEdit.vue index a22455d..0c4da3a 100644 --- a/src/views/oa/oaCompany/components/oaCompanyEdit.vue +++ b/src/views/oa/oaCompany/components/oaCompanyEdit.vue @@ -49,6 +49,34 @@ v-model:value="form.companyCode" /> + + + + + + + + + + + + + + + + + + + + @@ -184,6 +242,8 @@ import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types'; import { FormInstance } from 'ant-design-vue/es/form'; import { FileRecord } from '@/api/system/file/model'; + import {listPwlProjectLibrary} from '@/api/pwl/pwlProjectLibrary'; + import DictSelect from "@/components/DictSelect/index.vue"; // 是否是修改 const isUpdate = ref(false); @@ -191,6 +251,11 @@ // 是否开启响应式布局 const themeStore = useThemeStore(); const { styleResponsive } = storeToRefs(themeStore); + // 资料库响应式数据 + const bizLibList = ref([]); + const pubLibList = ref([]); + // 存储完整的资料库数据,用于查找名称 + const allLibraries = ref([]); const props = defineProps<{ // 弹窗是否打开 @@ -271,6 +336,7 @@ comments: '', sortNumber: 100, kbId: undefined, + libraryIds: undefined, }); /* 更新visible */ @@ -304,6 +370,31 @@ form.companyLogo = ''; }; + // 获取资料库列表 + const fetchLibraries = () => { + return listPwlProjectLibrary().then(res => { + allLibraries.value = res; + + // 过滤行业库 (type='biz') + bizLibList.value = res + .filter(item => item.type === 'biz') + .map(item => ({ + label: item.name, + value: String(item.id) // 将 ID 转换为字符串 + })); + + // 过滤公共库 (type='pub') + pubLibList.value = res + .filter(item => item.type === 'pub') + .map(item => ({ + label: item.name, + value: String(item.id) // 将 ID 转换为字符串 + })); + + return res; + }); + }; + const { resetFields } = useForm(form, rules); /* 保存编辑 */ @@ -315,8 +406,16 @@ .validate() .then(() => { loading.value = true; + + // 合并行业库和公共库的ID到libraryIds + const allLibraryIds = [ + ...(form.bizLibIds || []), + ...(form.pubLibIds || []) + ] + const formData = { - ...form + ...form, + libraryIds: allLibraryIds.join(','), // 保存为逗号分隔的字符串 }; const saveOrUpdate = isUpdate.value ? updateOaCompany : addOaCompany; saveOrUpdate(formData) @@ -334,10 +433,62 @@ .catch(() => {}); }; + // 设置资料库回显 + const setLibraryEcho = () => { + if (props.data?.libraryIds) { + // 如果是字符串,按逗号分割成数组 + if (typeof props.data.libraryIds === 'string') { + const libraryIdsArray = props.data.libraryIds.split(',').filter(id => id.trim() !== ''); + + // 清空当前的选择 + form.bizLibIds = []; + form.pubLibIds = []; + + // 根据资料库类型分别设置回显 + libraryIdsArray.forEach(id => { + // 检查是否在行业库列表中 + const isBizLib = bizLibList.value.some(lib => lib.value === String(id)); // 转换为字符串比较 + // 检查是否在公共库列表中 + const isPubLib = pubLibList.value.some(lib => lib.value === String(id)); // 转换为字符串比较 + + if (isBizLib) { + form.bizLibIds.push(String(id)); // 确保存储为字符串 + } + if (isPubLib) { + form.pubLibIds.push(String(id)); // 确保存储为字符串 + } + }); + } else { + // 如果是数组,直接使用相同的逻辑 + form.bizLibIds = []; + form.pubLibIds = []; + + props.data.libraryIds.forEach(id => { + const isBizLib = bizLibList.value.some(lib => lib.value === String(id)); + const isPubLib = pubLibList.value.some(lib => lib.value === String(id)); + + if (isBizLib) { + form.bizLibIds.push(String(id)); + } + if (isPubLib) { + form.pubLibIds.push(String(id)); + } + }); + } + } else { + form.bizLibIds = []; + form.pubLibIds = []; + } + }; + watch( () => props.visible, - (visible) => { + async (visible) => { if (visible) { + + // 等待资料库列表加载完成后再设置回显 + await fetchLibraries(); + images.value = []; if (props.data) { assignObject(form, props.data); @@ -348,6 +499,10 @@ status: 'done' }) } + + // 设置资料库回显 + setLibraryEcho(); + isUpdate.value = true; } else { isUpdate.value = false; diff --git a/src/views/oa/oaCompany/index.vue b/src/views/oa/oaCompany/index.vue index ac90b19..b5b27dd 100644 --- a/src/views/oa/oaCompany/index.vue +++ b/src/views/oa/oaCompany/index.vue @@ -340,7 +340,7 @@ const openImport = () => { /* 删除单个 */ const remove = (row: OaCompany) => { const hide = message.loading('请求中..', 0); - removeOaCompany(row.oaCompanyId) + removeOaCompany(row.companyId) .then((msg) => { hide(); message.success(msg); diff --git a/src/views/pwl/pwlProject/components/pwlProjectEdit.vue b/src/views/pwl/pwlProject/components/pwlProjectEdit.vue index 63cbc7c..e663b2d 100644 --- a/src/views/pwl/pwlProject/components/pwlProjectEdit.vue +++ b/src/views/pwl/pwlProject/components/pwlProjectEdit.vue @@ -500,6 +500,11 @@ const onCompany = (item: OaCompany) => { console.log('选择的公司:', item); form.name = item.companyName; form.kbId = item.kbId; + form.libraryIds = item.libraryIds; + // 需要等待资料库列表加载完成后再设置回显 + fetchLibraries().then(() => { + setLibraryEcho(); + }); console.log('设置后的form.name:', form.name); }; @@ -645,10 +650,13 @@ const save = () => { // 设置资料库回显 const setLibraryEcho = () => { - if (props.data?.libraryIds) { + // 优先使用form中的libraryIds,回退到props.data.libraryIds + const libraryIdsSource = form.libraryIds || props.data?.libraryIds; + + if (libraryIdsSource) { // 如果是字符串,按逗号分割成数组 - if (typeof props.data.libraryIds === 'string') { - const libraryIdsArray = props.data.libraryIds.split(',').filter(id => id.trim() !== ''); + if (typeof libraryIdsSource === 'string') { + const libraryIdsArray = libraryIdsSource.split(',').filter(id => id.trim() !== ''); // 清空当前的选择 form.bizLibIds = []; @@ -673,7 +681,7 @@ const setLibraryEcho = () => { form.bizLibIds = []; form.pubLibIds = []; - props.data.libraryIds.forEach(id => { + libraryIdsSource.forEach(id => { const isBizLib = bizLibList.value.some(lib => lib.value === String(id)); const isPubLib = pubLibList.value.some(lib => lib.value === String(id));