feat(pwl):添加报告关联企业资料库,企业信息添加资料库库IDs字段
This commit is contained in:
@@ -108,6 +108,8 @@ export interface OaCompany {
|
|||||||
updateTime?: string;
|
updateTime?: string;
|
||||||
// 知识库id
|
// 知识库id
|
||||||
kbId?: string;
|
kbId?: string;
|
||||||
|
// 资料库库IDs
|
||||||
|
libraryIds?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -49,6 +49,34 @@
|
|||||||
v-model:value="form.companyCode"
|
v-model:value="form.companyCode"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="企业性质" name="companyType">
|
||||||
|
<DictSelect
|
||||||
|
dict-code="CompanyType"
|
||||||
|
:width="200"
|
||||||
|
:show-search="true"
|
||||||
|
placeholder="企业性质"
|
||||||
|
v-model:value="form.companyType"
|
||||||
|
:field-names="{
|
||||||
|
label: 'dictDataName',
|
||||||
|
value: 'dictDataCode'
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="所属行业" name="industryParent">
|
||||||
|
<DictSelect
|
||||||
|
dict-code="Industry"
|
||||||
|
:width="200"
|
||||||
|
:show-search="true"
|
||||||
|
placeholder="所属行业"
|
||||||
|
v-model:value="form.industryParent"
|
||||||
|
:field-names="{
|
||||||
|
label: 'dictDataName',
|
||||||
|
value: 'dictDataCode'
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
<a-form-item label="知识库ID" name="kbId">
|
<a-form-item label="知识库ID" name="kbId">
|
||||||
<a-input
|
<a-input
|
||||||
:class="{ 'disabled-text': !form.kbId }"
|
:class="{ 'disabled-text': !form.kbId }"
|
||||||
@@ -58,6 +86,36 @@
|
|||||||
readonly
|
readonly
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
|
<!-- 行业库 -->
|
||||||
|
<a-form-item label="行业库" name="bizLibIds">
|
||||||
|
<a-select
|
||||||
|
show-search
|
||||||
|
:allow-clear="true"
|
||||||
|
optionFilterProp="label"
|
||||||
|
v-model:value="form.bizLibIds"
|
||||||
|
mode="multiple"
|
||||||
|
style="width: 100%"
|
||||||
|
placeholder="选择行业库"
|
||||||
|
:options="bizLibList"
|
||||||
|
></a-select>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<!-- 公共库 -->
|
||||||
|
<a-form-item label="公共库" name="pubLibIds">
|
||||||
|
<a-select
|
||||||
|
show-search
|
||||||
|
:allow-clear="true"
|
||||||
|
optionFilterProp="label"
|
||||||
|
v-model:value="form.pubLibIds"
|
||||||
|
mode="multiple"
|
||||||
|
style="width: 100%"
|
||||||
|
placeholder="选择公共库"
|
||||||
|
:options="pubLibList"
|
||||||
|
></a-select>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
|
||||||
<!-- <a-form-item label="类型" name="companyType">-->
|
<!-- <a-form-item label="类型" name="companyType">-->
|
||||||
<!-- <a-radio-group v-model:value="form.companyType">-->
|
<!-- <a-radio-group v-model:value="form.companyType">-->
|
||||||
<!-- <a-radio :value="10">企业</a-radio>-->
|
<!-- <a-radio :value="10">企业</a-radio>-->
|
||||||
@@ -184,6 +242,8 @@
|
|||||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||||
import { FormInstance } from 'ant-design-vue/es/form';
|
import { FormInstance } from 'ant-design-vue/es/form';
|
||||||
import { FileRecord } from '@/api/system/file/model';
|
import { FileRecord } from '@/api/system/file/model';
|
||||||
|
import {listPwlProjectLibrary} from '@/api/pwl/pwlProjectLibrary';
|
||||||
|
import DictSelect from "@/components/DictSelect/index.vue";
|
||||||
|
|
||||||
// 是否是修改
|
// 是否是修改
|
||||||
const isUpdate = ref(false);
|
const isUpdate = ref(false);
|
||||||
@@ -191,6 +251,11 @@
|
|||||||
// 是否开启响应式布局
|
// 是否开启响应式布局
|
||||||
const themeStore = useThemeStore();
|
const themeStore = useThemeStore();
|
||||||
const { styleResponsive } = storeToRefs(themeStore);
|
const { styleResponsive } = storeToRefs(themeStore);
|
||||||
|
// 资料库响应式数据
|
||||||
|
const bizLibList = ref<any[]>([]);
|
||||||
|
const pubLibList = ref<any[]>([]);
|
||||||
|
// 存储完整的资料库数据,用于查找名称
|
||||||
|
const allLibraries = ref<any[]>([]);
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
// 弹窗是否打开
|
// 弹窗是否打开
|
||||||
@@ -271,6 +336,7 @@
|
|||||||
comments: '',
|
comments: '',
|
||||||
sortNumber: 100,
|
sortNumber: 100,
|
||||||
kbId: undefined,
|
kbId: undefined,
|
||||||
|
libraryIds: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
/* 更新visible */
|
/* 更新visible */
|
||||||
@@ -304,6 +370,31 @@
|
|||||||
form.companyLogo = '';
|
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);
|
const { resetFields } = useForm(form, rules);
|
||||||
|
|
||||||
/* 保存编辑 */
|
/* 保存编辑 */
|
||||||
@@ -315,8 +406,16 @@
|
|||||||
.validate()
|
.validate()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
|
||||||
|
// 合并行业库和公共库的ID到libraryIds
|
||||||
|
const allLibraryIds = [
|
||||||
|
...(form.bizLibIds || []),
|
||||||
|
...(form.pubLibIds || [])
|
||||||
|
]
|
||||||
|
|
||||||
const formData = {
|
const formData = {
|
||||||
...form
|
...form,
|
||||||
|
libraryIds: allLibraryIds.join(','), // 保存为逗号分隔的字符串
|
||||||
};
|
};
|
||||||
const saveOrUpdate = isUpdate.value ? updateOaCompany : addOaCompany;
|
const saveOrUpdate = isUpdate.value ? updateOaCompany : addOaCompany;
|
||||||
saveOrUpdate(formData)
|
saveOrUpdate(formData)
|
||||||
@@ -334,10 +433,62 @@
|
|||||||
.catch(() => {});
|
.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(
|
watch(
|
||||||
() => props.visible,
|
() => props.visible,
|
||||||
(visible) => {
|
async (visible) => {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
|
|
||||||
|
// 等待资料库列表加载完成后再设置回显
|
||||||
|
await fetchLibraries();
|
||||||
|
|
||||||
images.value = [];
|
images.value = [];
|
||||||
if (props.data) {
|
if (props.data) {
|
||||||
assignObject(form, props.data);
|
assignObject(form, props.data);
|
||||||
@@ -348,6 +499,10 @@
|
|||||||
status: 'done'
|
status: 'done'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置资料库回显
|
||||||
|
setLibraryEcho();
|
||||||
|
|
||||||
isUpdate.value = true;
|
isUpdate.value = true;
|
||||||
} else {
|
} else {
|
||||||
isUpdate.value = false;
|
isUpdate.value = false;
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ const openImport = () => {
|
|||||||
/* 删除单个 */
|
/* 删除单个 */
|
||||||
const remove = (row: OaCompany) => {
|
const remove = (row: OaCompany) => {
|
||||||
const hide = message.loading('请求中..', 0);
|
const hide = message.loading('请求中..', 0);
|
||||||
removeOaCompany(row.oaCompanyId)
|
removeOaCompany(row.companyId)
|
||||||
.then((msg) => {
|
.then((msg) => {
|
||||||
hide();
|
hide();
|
||||||
message.success(msg);
|
message.success(msg);
|
||||||
|
|||||||
@@ -500,6 +500,11 @@ const onCompany = (item: OaCompany) => {
|
|||||||
console.log('选择的公司:', item);
|
console.log('选择的公司:', item);
|
||||||
form.name = item.companyName;
|
form.name = item.companyName;
|
||||||
form.kbId = item.kbId;
|
form.kbId = item.kbId;
|
||||||
|
form.libraryIds = item.libraryIds;
|
||||||
|
// 需要等待资料库列表加载完成后再设置回显
|
||||||
|
fetchLibraries().then(() => {
|
||||||
|
setLibraryEcho();
|
||||||
|
});
|
||||||
console.log('设置后的form.name:', form.name);
|
console.log('设置后的form.name:', form.name);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -645,10 +650,13 @@ const save = () => {
|
|||||||
|
|
||||||
// 设置资料库回显
|
// 设置资料库回显
|
||||||
const setLibraryEcho = () => {
|
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') {
|
if (typeof libraryIdsSource === 'string') {
|
||||||
const libraryIdsArray = props.data.libraryIds.split(',').filter(id => id.trim() !== '');
|
const libraryIdsArray = libraryIdsSource.split(',').filter(id => id.trim() !== '');
|
||||||
|
|
||||||
// 清空当前的选择
|
// 清空当前的选择
|
||||||
form.bizLibIds = [];
|
form.bizLibIds = [];
|
||||||
@@ -673,7 +681,7 @@ const setLibraryEcho = () => {
|
|||||||
form.bizLibIds = [];
|
form.bizLibIds = [];
|
||||||
form.pubLibIds = [];
|
form.pubLibIds = [];
|
||||||
|
|
||||||
props.data.libraryIds.forEach(id => {
|
libraryIdsSource.forEach(id => {
|
||||||
const isBizLib = bizLibList.value.some(lib => lib.value === String(id));
|
const isBizLib = bizLibList.value.some(lib => lib.value === String(id));
|
||||||
const isPubLib = pubLibList.value.some(lib => lib.value === String(id));
|
const isPubLib = pubLibList.value.some(lib => lib.value === String(id));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user