Merge branch 'developer' of ssh://code.cyweb.top:30033/scj/zhxy/v3/cloud-ui into developer
This commit is contained in:
@@ -26,20 +26,12 @@
|
||||
</div>
|
||||
</el-form-item>
|
||||
<slot :visible="true" :expanded="isExpanded"></slot>
|
||||
<!-- 收起时:查询/重置在首行 -->
|
||||
<div v-show="!isExpanded" class="actions-outside">
|
||||
<slot name="actions"></slot>
|
||||
<!-- 折叠区:收起时隐藏,display:contents 不破坏表单行内流 -->
|
||||
<div v-if="hasCollapsibleItems" v-show="isExpanded" class="collapse-visibility">
|
||||
<slot :visible="false" :expanded="isExpanded" @has-content="hasCollapsibleContent = true"></slot>
|
||||
</div>
|
||||
<!-- 折叠区:展开时内部再放一份查询/重置,位置在更多筛选项之后 -->
|
||||
<div v-if="hasCollapsibleItems" class="collapse-grid" :class="{ 'is-expanded': isExpanded }">
|
||||
<div class="collapse-grid-inner">
|
||||
<div class="collapse-grid-cell">
|
||||
<slot :visible="false" :expanded="isExpanded" @has-content="hasCollapsibleContent = true"></slot>
|
||||
<div v-show="isExpanded" class="actions-inside">
|
||||
<slot name="actions"></slot>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-form__actions">
|
||||
<slot name="actions" :expanded="isExpanded"></slot>
|
||||
</div>
|
||||
<div v-show="false" ref="detectionWrapperRef" class="detection-wrapper">
|
||||
<slot :visible="false" :expanded="true"></slot>
|
||||
@@ -218,7 +210,6 @@ defineExpose({
|
||||
:deep(.el-form-item__content) {
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
margin-right: 16px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
@@ -280,40 +271,21 @@ defineExpose({
|
||||
}
|
||||
|
||||
:deep(.el-form-item:not(:has(.el-button))) {
|
||||
margin-right: 16px;
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
/* grid 0fr→1fr 高度过渡,ease-out 收尾不弹跳 */
|
||||
.collapse-grid {
|
||||
display: grid;
|
||||
grid-template-rows: 0fr;
|
||||
transition: grid-template-rows 0.26s cubic-bezier(0.33, 1, 0.68, 1);
|
||||
contain: layout;
|
||||
&.is-expanded {
|
||||
grid-template-rows: 1fr;
|
||||
}
|
||||
}
|
||||
.collapse-grid-inner {
|
||||
overflow: hidden;
|
||||
min-height: 0;
|
||||
backface-visibility: hidden;
|
||||
}
|
||||
.collapse-grid-cell {
|
||||
overflow: hidden;
|
||||
min-height: 0;
|
||||
opacity: 0;
|
||||
/* 收起时立即隐藏,不出现输入框慢慢消失 */
|
||||
transition: opacity 0s;
|
||||
}
|
||||
.collapse-grid.is-expanded .collapse-grid-cell {
|
||||
opacity: 1;
|
||||
/* 仅展开时淡入 */
|
||||
transition: opacity 0.12s ease-out;
|
||||
}
|
||||
.actions-outside,
|
||||
.actions-inside {
|
||||
/* 折叠区收起时隐藏,展开时 display:contents 不破坏表单行内流 */
|
||||
.collapse-visibility {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
/* 查询/重置按钮区:表单项 margin-right 为 0 */
|
||||
.search-form__actions {
|
||||
display: contents;
|
||||
:deep(.el-form-item) {
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
321
src/components/SearchForm/index2.vue
Normal file
321
src/components/SearchForm/index2.vue
Normal file
@@ -0,0 +1,321 @@
|
||||
<template>
|
||||
<div class="search-form__wrap" :class="{ 'search-form__wrap--with-title': filterTitle }">
|
||||
<div class="search-form__bar">
|
||||
<div class="search-form-container">
|
||||
<el-form :model="formModel" ref="formRef" :inline="true" @keyup.enter="handleKeyupEnter" :label-width="labelWidth">
|
||||
<!-- 筛选 + 展开更多 放在同一表单项内,保证垂直对齐 -->
|
||||
<el-form-item v-if="filterTitle || hasCollapsibleItems" class="search-form__left-group">
|
||||
<div class="search-form__left-inner">
|
||||
<span v-if="filterTitle" class="search-form__title">
|
||||
<el-icon class="search-form__title-icon"><Search /></el-icon>
|
||||
{{ filterTitle }}
|
||||
</span>
|
||||
<el-button
|
||||
v-if="hasCollapsibleItems"
|
||||
link
|
||||
type="primary"
|
||||
class="toggle-btn"
|
||||
@click="toggleExpand"
|
||||
>
|
||||
<el-icon style="margin-right: 4px">
|
||||
<ArrowUp v-if="isExpanded" />
|
||||
<ArrowDown v-else />
|
||||
</el-icon>
|
||||
{{ isExpanded ? '收起' : '展开更多' }}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<slot :visible="true" :expanded="isExpanded"></slot>
|
||||
<!-- 收起时:查询/重置在首行 -->
|
||||
<div v-show="!isExpanded" class="actions-outside">
|
||||
<slot name="actions"></slot>
|
||||
</div>
|
||||
<!-- 折叠区:展开时内部再放一份查询/重置,位置在更多筛选项之后 -->
|
||||
<div v-if="hasCollapsibleItems" class="collapse-grid" :class="{ 'is-expanded': isExpanded }">
|
||||
<div class="collapse-grid-inner">
|
||||
<div class="collapse-grid-cell">
|
||||
<slot :visible="false" :expanded="isExpanded" @has-content="hasCollapsibleContent = true"></slot>
|
||||
<div v-show="isExpanded" class="actions-inside">
|
||||
<slot name="actions"></slot>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-show="false" ref="detectionWrapperRef" class="detection-wrapper">
|
||||
<slot :visible="false" :expanded="true"></slot>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="search-form">
|
||||
import { ref, watch, computed, onMounted, nextTick } from 'vue';
|
||||
import { ArrowUp, ArrowDown, Search } from '@element-plus/icons-vue';
|
||||
|
||||
const props = defineProps({
|
||||
/**
|
||||
* 筛选标题(如「筛选」),传入时在表单左侧显示标题+竖线,与表单项同一行
|
||||
*/
|
||||
filterTitle: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
/**
|
||||
* 表单数据模型
|
||||
*/
|
||||
model: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
/**
|
||||
* 是否默认展开折叠区域
|
||||
*/
|
||||
defaultExpanded: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
/**
|
||||
* 是否显示展开/折叠按钮
|
||||
* 如果不设置,将自动检测是否有可折叠内容(visible=false 的插槽)
|
||||
*/
|
||||
showCollapse: {
|
||||
type: Boolean,
|
||||
default: undefined,
|
||||
},
|
||||
/**
|
||||
* 表单项标签宽度
|
||||
*/
|
||||
labelWidth: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['expand-change', 'keyup-enter']);
|
||||
|
||||
const formModel = props.model;
|
||||
const { filterTitle } = props;
|
||||
const formRef = ref();
|
||||
const isExpanded = ref(props.defaultExpanded);
|
||||
const hasCollapsibleContent = ref(false);
|
||||
const detectionWrapperRef = ref<HTMLElement | null>(null);
|
||||
|
||||
// 检测是否有可折叠内容
|
||||
const checkCollapsibleContent = () => {
|
||||
// 如果 showCollapse 明确指定,则使用指定值
|
||||
if (props.showCollapse !== undefined) {
|
||||
hasCollapsibleContent.value = props.showCollapse
|
||||
return
|
||||
}
|
||||
|
||||
// 否则,通过检查隐藏的检测元素是否有内容来判断
|
||||
// 需要等待 DOM 渲染完成,可能需要多次尝试以确保数据加载完成
|
||||
let retryCount = 0
|
||||
const maxRetries = 5
|
||||
|
||||
const check = () => {
|
||||
nextTick(() => {
|
||||
setTimeout(() => {
|
||||
if (detectionWrapperRef.value) {
|
||||
// 检查检测元素是否有子元素(排除文本节点)
|
||||
// 检查是否有 el-form-item 元素(因为表单项会被渲染为 el-form-item)
|
||||
const hasContent = detectionWrapperRef.value.children.length > 0 ||
|
||||
detectionWrapperRef.value.querySelector('.el-form-item') !== null ||
|
||||
(!!detectionWrapperRef.value.textContent && detectionWrapperRef.value.textContent.trim() !== '')
|
||||
|
||||
if (hasContent || retryCount >= maxRetries) {
|
||||
hasCollapsibleContent.value = hasContent
|
||||
} else {
|
||||
// 如果还没检测到内容且未达到最大重试次数,继续重试
|
||||
retryCount++
|
||||
setTimeout(check, 100)
|
||||
}
|
||||
} else {
|
||||
if (retryCount < maxRetries) {
|
||||
retryCount++
|
||||
setTimeout(check, 100)
|
||||
} else {
|
||||
hasCollapsibleContent.value = false
|
||||
}
|
||||
}
|
||||
}, 50)
|
||||
})
|
||||
}
|
||||
|
||||
check()
|
||||
}
|
||||
|
||||
// 是否有需要折叠的项
|
||||
const hasCollapsibleItems = computed(() => {
|
||||
if (props.showCollapse !== undefined) {
|
||||
return props.showCollapse
|
||||
}
|
||||
return hasCollapsibleContent.value
|
||||
});
|
||||
|
||||
// 处理回车键
|
||||
const handleKeyupEnter = () => {
|
||||
emit('keyup-enter');
|
||||
};
|
||||
|
||||
// 切换展开/收起状态
|
||||
const toggleExpand = () => {
|
||||
isExpanded.value = !isExpanded.value;
|
||||
emit('expand-change', isExpanded.value);
|
||||
};
|
||||
|
||||
// 监听 defaultExpanded 变化
|
||||
watch(
|
||||
() => props.defaultExpanded,
|
||||
(newVal) => {
|
||||
isExpanded.value = newVal;
|
||||
}
|
||||
);
|
||||
|
||||
// 监听 showCollapse 变化
|
||||
watch(
|
||||
() => props.showCollapse,
|
||||
() => {
|
||||
checkCollapsibleContent()
|
||||
}
|
||||
);
|
||||
|
||||
// 初始化时检测
|
||||
onMounted(() => {
|
||||
checkCollapsibleContent()
|
||||
});
|
||||
|
||||
// 暴露方法供外部调用
|
||||
defineExpose({
|
||||
formRef,
|
||||
toggleExpand,
|
||||
expand: () => {
|
||||
isExpanded.value = true;
|
||||
emit('expand-change', true);
|
||||
},
|
||||
collapse: () => {
|
||||
isExpanded.value = false;
|
||||
emit('expand-change', false);
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.search-form__bar {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 0;
|
||||
min-height: 32px;
|
||||
}
|
||||
|
||||
.search-form__left-group {
|
||||
:deep(.el-form-item__label) {
|
||||
display: none;
|
||||
}
|
||||
:deep(.el-form-item__content) {
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.search-form__left-inner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.search-form__title {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex-shrink: 0;
|
||||
padding-right: 12px;
|
||||
margin-right: 12px;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: var(--el-text-color-secondary);
|
||||
cursor: default;
|
||||
user-select: none;
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 1px;
|
||||
height: 14px;
|
||||
background: var(--el-border-color);
|
||||
}
|
||||
}
|
||||
|
||||
.search-form__title-icon {
|
||||
font-size: 15px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.search-form-container {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
:deep(.el-form--inline) {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.search-form__left-inner :deep(.toggle-btn) {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
height: 32px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
:deep(.el-form-item:not(:has(.el-button))) {
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
/* grid 0fr→1fr 高度过渡,ease-out 收尾不弹跳 */
|
||||
.collapse-grid {
|
||||
display: grid;
|
||||
grid-template-rows: 0fr;
|
||||
transition: grid-template-rows 0.26s cubic-bezier(0.33, 1, 0.68, 1);
|
||||
contain: layout;
|
||||
&.is-expanded {
|
||||
grid-template-rows: 1fr;
|
||||
}
|
||||
}
|
||||
.collapse-grid-inner {
|
||||
overflow: hidden;
|
||||
min-height: 0;
|
||||
backface-visibility: hidden;
|
||||
}
|
||||
.collapse-grid-cell {
|
||||
overflow: hidden;
|
||||
min-height: 0;
|
||||
opacity: 0;
|
||||
/* 收起时立即隐藏,不出现输入框慢慢消失 */
|
||||
transition: opacity 0s;
|
||||
}
|
||||
.collapse-grid.is-expanded .collapse-grid-cell {
|
||||
opacity: 1;
|
||||
/* 仅展开时淡入 */
|
||||
transition: opacity 0.12s ease-out;
|
||||
}
|
||||
.actions-outside,
|
||||
.actions-inside {
|
||||
display: contents;
|
||||
:deep(.el-form-item) {
|
||||
margin-right: 0!important;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -161,6 +161,7 @@ interface FileItem {
|
||||
name?: string;
|
||||
url?: string;
|
||||
uid?: number;
|
||||
id?: string; // 文件ID
|
||||
}
|
||||
|
||||
interface UploadFileItem {
|
||||
@@ -170,6 +171,7 @@ interface UploadFileItem {
|
||||
fileSize: number;
|
||||
fileName: string;
|
||||
fileType: string;
|
||||
id?: string; // 文件ID
|
||||
}
|
||||
|
||||
const props = defineProps({
|
||||
@@ -270,14 +272,74 @@ const handleBeforeUpload = (file: File) => {
|
||||
// 上传成功回调
|
||||
function handleUploadSuccess(res: any, file: any) {
|
||||
if (res.code === 0) {
|
||||
// 调试:打印完整的响应数据
|
||||
console.log('上传成功响应数据:', res);
|
||||
console.log('res.data:', res.data);
|
||||
|
||||
// 获取文件ID - 尝试多种可能的字段名
|
||||
let fileId = res.data?.id || res.data?.fileId || res.data?.file_id || null;
|
||||
let fileUrl = res.data?.url || res.data?.fileUrl || '';
|
||||
|
||||
// 如果fileId不存在,尝试从fileName中提取(fileName可能是ID)
|
||||
if (!fileId && res.data?.fileName) {
|
||||
const fileName = res.data.fileName;
|
||||
// 检查fileName是否是32位十六进制字符串(文件ID格式)
|
||||
if (/^[a-f0-9]{32}$/i.test(fileName)) {
|
||||
fileId = fileName;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果fileId仍然不存在,尝试从URL中提取
|
||||
if (!fileId && fileUrl) {
|
||||
try {
|
||||
const urlObj = new URL(fileUrl, window.location.origin);
|
||||
fileId = urlObj.searchParams.get('id');
|
||||
// 如果URL参数中没有id,检查路径中是否有32位十六进制字符串
|
||||
if (!fileId) {
|
||||
const pathParts = urlObj.pathname.split('/').filter(p => p);
|
||||
const lastPart = pathParts[pathParts.length - 1];
|
||||
if (lastPart && /^[a-f0-9]{32}$/i.test(lastPart)) {
|
||||
fileId = lastPart;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// URL解析失败,忽略
|
||||
}
|
||||
}
|
||||
|
||||
// 如果仍然没有fileId,尝试从整个res.data中查找可能的ID字段
|
||||
if (!fileId && res.data) {
|
||||
// 遍历res.data的所有属性,查找32位十六进制字符串
|
||||
for (const key in res.data) {
|
||||
const value = res.data[key];
|
||||
if (typeof value === 'string' && /^[a-f0-9]{32}$/i.test(value)) {
|
||||
fileId = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('提取的文件ID:', fileId);
|
||||
|
||||
// 构建URL,如果存在id则添加到URL参数中(用于兼容性)
|
||||
if (fileId && fileUrl) {
|
||||
// 如果URL中已经有参数,使用&,否则使用?
|
||||
fileUrl = fileUrl.includes('?') ? `${fileUrl}&id=${fileId}` : `${fileUrl}?id=${fileId}`;
|
||||
}
|
||||
fileUrl = `${fileUrl}&originalFileName=${file.name}`;
|
||||
|
||||
uploadList.value.push({
|
||||
name: file.name,
|
||||
url: `${res.data?.url}&originalFileName=${file.name}`,
|
||||
url: fileUrl,
|
||||
fileUrl: res.data?.fileName,
|
||||
fileSize: file.size,
|
||||
fileName: file.name,
|
||||
fileType: file.raw.type,
|
||||
id: fileId, // 保存文件ID(优先使用)
|
||||
});
|
||||
|
||||
console.log('保存的文件对象:', uploadList.value[uploadList.value.length - 1]);
|
||||
|
||||
uploadedSuccessfully();
|
||||
} else {
|
||||
number.value--;
|
||||
@@ -298,10 +360,12 @@ const uploadedSuccessfully = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleRemove = (file: { name: string }) => {
|
||||
fileList.value = fileList.value.filter((f) => f.name !== file.name);
|
||||
emit('update:modelValue', listToString(fileList.value));
|
||||
emit('change', listToString(fileList.value), fileList.value);
|
||||
const handleRemove = (file: { name?: string }) => {
|
||||
if (file.name) {
|
||||
fileList.value = fileList.value.filter((f) => f.name !== file.name);
|
||||
emit('update:modelValue', listToString(fileList.value));
|
||||
emit('change', listToString(fileList.value), fileList.value);
|
||||
}
|
||||
};
|
||||
|
||||
const handlePreview = (file: any) => {
|
||||
@@ -319,12 +383,21 @@ const handleExceed = () => {
|
||||
* @param separator 分隔符,默认为逗号。
|
||||
* @returns {string} 返回转换后的字符串。
|
||||
*/
|
||||
/**
|
||||
* 将对象数组转为字符串,以逗号分隔。
|
||||
* 如果文件有id,优先使用id,否则使用url。
|
||||
* @param list 待转换的对象数组。
|
||||
* @param separator 分隔符,默认为逗号。
|
||||
* @returns {string} 返回转换后的字符串(ID或URL,用逗号分隔)。
|
||||
*/
|
||||
const listToString = (list: FileItem[], separator = ','): string => {
|
||||
let strs = '';
|
||||
separator = separator || ',';
|
||||
for (let i in list) {
|
||||
if (list[i].url) {
|
||||
strs += list[i].url + separator;
|
||||
// 优先使用id,如果没有id则使用url
|
||||
const value = list[i].id || list[i].url;
|
||||
if (value) {
|
||||
strs += value + separator;
|
||||
}
|
||||
}
|
||||
return strs !== '' ? strs.substr(0, strs.length - 1) : '';
|
||||
@@ -347,7 +420,28 @@ watch(
|
||||
// 然后将数组转为对象数组
|
||||
fileList.value = list.map((item: any) => {
|
||||
if (typeof item === 'string') {
|
||||
item = { name: other.getQueryString(item, 'originalFileName') || other.getQueryString(item, 'fileName'), url: item };
|
||||
// 检查是否是32位十六进制字符串(文件ID格式)
|
||||
const isId = /^[a-f0-9]{32}$/i.test(item.trim());
|
||||
if (isId) {
|
||||
// 如果是ID格式,直接使用
|
||||
item = { id: item.trim(), name: '', url: '' };
|
||||
} else {
|
||||
// 如果是URL,尝试从URL中提取id
|
||||
try {
|
||||
const urlObj = new URL(item, window.location.origin);
|
||||
const id = urlObj.searchParams.get('id');
|
||||
item = {
|
||||
name: other.getQueryString(item, 'originalFileName') || other.getQueryString(item, 'fileName'),
|
||||
url: item,
|
||||
id: id || undefined
|
||||
};
|
||||
} catch {
|
||||
item = {
|
||||
name: other.getQueryString(item, 'originalFileName') || other.getQueryString(item, 'fileName'),
|
||||
url: item
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
item.uid = item.uid || new Date().getTime() + temp++;
|
||||
return item as FileItem;
|
||||
|
||||
@@ -211,10 +211,33 @@
|
||||
upload-file-url="/purchase/purchasingfiles/upload" />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 询价 -->
|
||||
<el-form-item
|
||||
v-if="isInquiryPurchaseType"
|
||||
label="询价模板"
|
||||
prop="inquiryTemplate"
|
||||
class="mb20">
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
icon="Download"
|
||||
@click="downloadTemplate('inquiry')"
|
||||
class="mb10">
|
||||
下载《部门采购询价模版》模版
|
||||
</el-button>
|
||||
<upload-file
|
||||
v-model="dataForm.inquiryTemplate"
|
||||
:limit="5"
|
||||
:file-type="['doc', 'docx', 'pdf']"
|
||||
:data="{ fileType: FILE_TYPE_MAP.inquiryTemplate }"
|
||||
upload-file-url="/purchase/purchasingfiles/upload" />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 委托采购中心 -->
|
||||
<template v-if="isPurchaseType(PURCHASE_TYPE_IDS.ENTRUST_CENTER)">
|
||||
<el-form-item label="委托采购中心方式" prop="entrustCenterType" class="mb20">
|
||||
<el-radio-group v-model="dataForm.entrustCenterType">
|
||||
<!-- 由系统根据品目末级节点标记自动判断,不允许用户手动选择 -->
|
||||
<el-radio-group v-model="dataForm.entrustCenterType" disabled>
|
||||
<el-radio label="service_online">服务类网上商城</el-radio>
|
||||
<el-radio label="other">其他方式</el-radio>
|
||||
</el-radio-group>
|
||||
@@ -224,12 +247,12 @@
|
||||
<template v-if="dataForm.entrustCenterType === 'service_online' && categoryCodePath && categoryCodePath.length > 0 && categoryCodePath[0] === 'C'">
|
||||
<el-form-item label="是否有供应商" prop="hasSupplier" class="mb20">
|
||||
<el-radio-group v-model="dataForm.hasSupplier">
|
||||
<el-radio label="yes">有</el-radio>
|
||||
<el-radio label="no">无</el-radio>
|
||||
<el-radio label="1">有</el-radio>
|
||||
<el-radio label="0">无</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<!-- 有供应商:显示供应商名称输入框 -->
|
||||
<template v-if="dataForm.hasSupplier === 'yes'">
|
||||
<template v-if="dataForm.hasSupplier === '1'">
|
||||
<el-form-item
|
||||
label="供应商名称"
|
||||
prop="suppliers"
|
||||
@@ -776,6 +799,7 @@ const dataForm = reactive({
|
||||
businessNegotiationTable: '',
|
||||
marketPurchaseMinutes: '',
|
||||
onlineMallMaterials: '',
|
||||
inquiryTemplate: '', // 询价模板
|
||||
entrustCenterType: '',
|
||||
hasSupplier: '',
|
||||
suppliers: '', // 供应商名称(逗号或分号分隔)
|
||||
@@ -831,10 +855,11 @@ const PURCHASE_TYPE_IDS = {
|
||||
};
|
||||
|
||||
// 文件类型映射(对应数据库 file_type 字段)
|
||||
// 10:商务洽谈纪要 20:市场采购纪要 30:网上商城采购相关材料 40:可行性论证报告 50:会议记录 60:其他材料 70:单一来源专家论证表 80:进口产品申请表 90:进口产品专家论证表 100:政府采购意向表 110:履约验收单
|
||||
// 10:商务洽谈纪要 20:市场采购纪要 30:网上商城采购相关材料 40:可行性论证报告 50:会议记录 60:其他材料 70:单一来源专家论证表 80:进口产品申请表 90:进口产品专家论证表 100:政府采购意向表 110:履约验收单 120:采购需求表 130:采购文件
|
||||
const FILE_TYPE_MAP: Record<string, string> = {
|
||||
businessNegotiationTable: '10', // 商务洽谈纪要
|
||||
marketPurchaseMinutes: '20', // 市场采购纪要
|
||||
inquiryTemplate: '20', // 询价模板(归类到市场采购纪要)
|
||||
onlineMallMaterials: '30', // 网上商城采购相关材料
|
||||
feasibilityReport: '40', // 可行性论证报告
|
||||
meetingMinutes: '50', // 会议记录
|
||||
@@ -845,16 +870,16 @@ const FILE_TYPE_MAP: Record<string, string> = {
|
||||
singleSourceProof: '70', // 单一来源专家论证表
|
||||
importApplication: '80', // 进口产品申请表
|
||||
governmentPurchaseIntent: '100', // 政府采购意向表
|
||||
// 需求文件相关(暂时使用默认值,可根据实际需求调整)
|
||||
serviceDirectSelect: '30', // 服务商城项目需求模板(直选)- 归类到网上商城采购相关材料
|
||||
serviceInviteSelect: '30', // 服务商城项目需求模板(邀请比选)
|
||||
servicePublicSelect: '30', // 服务商城项目需求模板(公开比选)
|
||||
servicePublicSelectAuto: '30', // 服务商城项目需求模板(公开比选-自动)
|
||||
purchaseRequirementTemplate: '30', // 采购需求填报模板
|
||||
purchaseRequirement: '30', // 采购需求填报模板
|
||||
serviceInviteSelectSchool: '30', // 服务商城项目需求模板(邀请比选-学校)
|
||||
servicePublicSelectSchoolAuto: '30', // 服务商城项目需求模板(公开比选-学校-自动)
|
||||
servicePublicSelectSchool: '30', // 服务商城项目需求模板(公开比选-学校)
|
||||
// 需求文件相关 - 所有需求模板都应该是120(采购需求表)
|
||||
serviceDirectSelect: '120', // 服务商城项目需求模板(直选)- 采购需求表
|
||||
serviceInviteSelect: '120', // 服务商城项目需求模板(邀请比选)- 采购需求表
|
||||
servicePublicSelect: '120', // 服务商城项目需求模板(公开比选)- 采购需求表
|
||||
servicePublicSelectAuto: '120', // 服务商城项目需求模板(公开比选-自动)- 采购需求表
|
||||
purchaseRequirementTemplate: '120', // 采购需求填报模板 - 采购需求表
|
||||
purchaseRequirement: '120', // 采购需求填报模板 - 采购需求表
|
||||
serviceInviteSelectSchool: '120', // 服务商城项目需求模板(邀请比选-学校)- 采购需求表
|
||||
servicePublicSelectSchoolAuto: '120', // 服务商城项目需求模板(公开比选-学校-自动)- 采购需求表
|
||||
servicePublicSelectSchool: '120', // 服务商城项目需求模板(公开比选-学校)- 采购需求表
|
||||
};
|
||||
|
||||
// 辅助函数:判断当前采购方式是否为指定类型(通过 id 或 value 匹配)
|
||||
@@ -871,6 +896,17 @@ const isPurchaseType = (purchaseTypeId: string) => {
|
||||
return dataForm.purchaseType === purchaseTypeId;
|
||||
};
|
||||
|
||||
// 辅助函数:判断当前采购方式是否为"询价"(通过 label 匹配)
|
||||
const isInquiryPurchaseType = computed(() => {
|
||||
if (!dataForm.purchaseType) return false;
|
||||
const item = purchaseTypeDeptList.value.find(item => item.value === dataForm.purchaseType);
|
||||
if (item) {
|
||||
const label = item.label || item.dictLabel || item.name || '';
|
||||
return label.includes('询价');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// 辅助函数:判断特殊情况是否为指定类型(通过 id 或 value 匹配)
|
||||
const isSpecialType = (specialIdOrValue: string) => {
|
||||
if (!dataForm.isSpecial) return false;
|
||||
@@ -998,6 +1034,53 @@ const isSpecialServiceCategory = computed(() => {
|
||||
return Number(category.isMallService) === 1 || Number(category.isProjectService) === 1;
|
||||
});
|
||||
|
||||
// 委托采购中心方式自动判断:
|
||||
// - 服务类:若末级节点 isMallService=0 且 isMallProject=0,则选“其他方式”,否则选“服务类网上商城”
|
||||
// - 非服务类:默认选“其他方式”
|
||||
const calcEntrustCenterType = (): 'service_online' | 'other' | '' => {
|
||||
if (!isPurchaseType(PURCHASE_TYPE_IDS.ENTRUST_CENTER)) return '';
|
||||
if (!dataForm.categoryCode) return '';
|
||||
|
||||
const category = getCategoryInfo();
|
||||
if (!category) return '';
|
||||
|
||||
// 兼容字段:接口可能为 isMallProject,也可能历史字段为 isProjectService
|
||||
const mallService = Number(category.isMallService ?? 0);
|
||||
const mallProject = Number(category.isMallProject ?? category.isProjectService ?? 0);
|
||||
|
||||
if (isServiceCategory.value) {
|
||||
return mallService === 0 && mallProject === 0 ? 'other' : 'service_online';
|
||||
}
|
||||
return 'other';
|
||||
};
|
||||
|
||||
// 监听品目/采购方式变化,自动设置委托采购中心方式,并清理无关字段
|
||||
watch(
|
||||
[() => dataForm.purchaseType, () => dataForm.categoryCode, () => categoryTreeData.value],
|
||||
() => {
|
||||
const nextType = calcEntrustCenterType();
|
||||
if (!nextType) return;
|
||||
|
||||
const prevType = dataForm.entrustCenterType as any;
|
||||
if (prevType === nextType) return;
|
||||
|
||||
dataForm.entrustCenterType = nextType;
|
||||
|
||||
// 切换时清理不相关字段,避免脏数据
|
||||
if (nextType === 'other') {
|
||||
dataForm.hasSupplier = '';
|
||||
dataForm.suppliers = '';
|
||||
dataForm.serviceDirectSelect = '';
|
||||
dataForm.serviceInviteSelect = '';
|
||||
dataForm.servicePublicSelect = '';
|
||||
dataForm.servicePublicSelectAuto = '';
|
||||
} else if (nextType === 'service_online') {
|
||||
dataForm.purchaseRequirementTemplate = '';
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
// 判断是否自动选择网上商城采购方式(5万<=金额<40万,服务类目,特殊服务类目)
|
||||
const isAutoSelectPurchaseType = computed(() => {
|
||||
if (!dataForm.budget) return false;
|
||||
@@ -1085,6 +1168,7 @@ const downloadTemplate = async (type: string) => {
|
||||
const templateMap: Record<string, { fileName: string, displayName: string }> = {
|
||||
'business_negotiation': { fileName: '商务洽谈表.xlsx', displayName: '商务洽谈表.xlsx' },
|
||||
'market_purchase_minutes': { fileName: '市场采购纪要.xlsx', displayName: '市场采购纪要.xlsx' },
|
||||
'inquiry': { fileName: '部门采购询价模版.docx', displayName: '部门采购询价模版.docx' },
|
||||
'direct_select': { fileName: '服务商城项目需求模板(直选).doc', displayName: '服务商城项目需求模板(直选).doc' },
|
||||
'public_select': { fileName: '服务商城项目需求模板(公开比选).doc', displayName: '服务商城项目需求模板(公开比选).doc' },
|
||||
'invite_select': { fileName: '服务商城项目需求模板(邀请比选).doc', displayName: '服务商城项目需求模板(邀请比选).doc' },
|
||||
@@ -1437,50 +1521,52 @@ const handleSchoolLeaderChange = (value: string) => {
|
||||
};
|
||||
|
||||
// 处理文件ID字符串转数组
|
||||
// 从上传返回的URL中提取文件ID,拼成数组格式:["id1", "id2"]
|
||||
// 从上传返回的URL或ID中提取文件ID,拼成数组格式:["id1", "id2"]
|
||||
// 上传接口返回的id会保存在URL的id参数中,或者直接是32位十六进制字符串
|
||||
const getFileIdsArray = (fileIds: string | string[]): string[] => {
|
||||
if (!fileIds) return [];
|
||||
if (Array.isArray(fileIds)) return fileIds;
|
||||
|
||||
const urls = fileIds.split(',').filter(url => url.trim());
|
||||
const items = fileIds.split(',').filter(item => item.trim());
|
||||
const ids: string[] = [];
|
||||
|
||||
urls.forEach(url => {
|
||||
items.forEach(item => {
|
||||
const trimmed = item.trim();
|
||||
// 首先检查是否是直接的ID格式(32位十六进制字符串)
|
||||
if (/^[a-f0-9]{32}$/i.test(trimmed)) {
|
||||
ids.push(trimmed);
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果不是ID格式,尝试从URL中提取id参数
|
||||
try {
|
||||
// 尝试解析为URL
|
||||
const urlObj = new URL(url, window.location.origin);
|
||||
const urlObj = new URL(trimmed, window.location.origin);
|
||||
// 优先从URL参数中获取id
|
||||
let id = urlObj.searchParams.get('id');
|
||||
|
||||
// 如果没有id参数,尝试从路径中提取(可能是直接的文件ID)
|
||||
if (!id) {
|
||||
const pathParts = urlObj.pathname.split('/').filter(p => p);
|
||||
// 检查最后一个路径段是否是32位十六进制字符串(文件ID格式)
|
||||
const lastPart = pathParts[pathParts.length - 1];
|
||||
if (lastPart && /^[a-f0-9]{32}$/i.test(lastPart)) {
|
||||
id = lastPart;
|
||||
} else if (lastPart) {
|
||||
id = lastPart;
|
||||
}
|
||||
}
|
||||
|
||||
if (id) {
|
||||
ids.push(id);
|
||||
} else {
|
||||
// 如果URL解析失败,检查原始字符串是否是ID格式
|
||||
if (/^[a-f0-9]{32}$/i.test(url.trim())) {
|
||||
ids.push(url.trim());
|
||||
} else {
|
||||
ids.push(url);
|
||||
}
|
||||
// 如果无法提取ID,使用原始字符串(可能是URL)
|
||||
// 但这种情况不应该发生,因为上传接口应该返回id
|
||||
console.warn('无法从URL中提取文件ID:', trimmed);
|
||||
ids.push(trimmed);
|
||||
}
|
||||
} catch {
|
||||
// URL解析失败,检查是否是直接的ID格式(32位十六进制)
|
||||
if (/^[a-f0-9]{32}$/i.test(url.trim())) {
|
||||
ids.push(url.trim());
|
||||
// URL解析失败,如果原始字符串是ID格式则使用,否则忽略
|
||||
if (/^[a-f0-9]{32}$/i.test(trimmed)) {
|
||||
ids.push(trimmed);
|
||||
} else {
|
||||
// 否则直接使用原始字符串
|
||||
ids.push(url);
|
||||
console.warn('无法解析文件标识:', trimmed);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1504,9 +1590,9 @@ const handleSubmit = async () => {
|
||||
...dataForm,
|
||||
};
|
||||
|
||||
// 处理所有文件字段
|
||||
// 处理所有文件字段 - 收集所有文件ID到fileIds数组中
|
||||
const fileFields = [
|
||||
'businessNegotiationTable', 'marketPurchaseMinutes', 'onlineMallMaterials',
|
||||
'businessNegotiationTable', 'marketPurchaseMinutes', 'onlineMallMaterials', 'inquiryTemplate',
|
||||
'serviceDirectSelect', 'servicePublicSelect', 'purchaseRequirementTemplate',
|
||||
'serviceInviteSelect', 'servicePublicSelectAuto', 'purchaseRequirement',
|
||||
'meetingMinutes', 'feasibilityReport', 'meetingMinutesUrgent',
|
||||
@@ -1515,11 +1601,27 @@ const handleSubmit = async () => {
|
||||
'servicePublicSelectSchoolAuto', 'otherMaterials'
|
||||
];
|
||||
|
||||
// 收集所有文件ID到一个数组中
|
||||
const allFileIds: string[] = [];
|
||||
|
||||
fileFields.forEach(field => {
|
||||
if (submitData[field]) {
|
||||
submitData[field] = getFileIdsArray(submitData[field]);
|
||||
const ids = getFileIdsArray(submitData[field]);
|
||||
console.log(`字段 ${field} 的文件ID:`, ids);
|
||||
// 收集到总数组中
|
||||
allFileIds.push(...ids);
|
||||
// 清空原字段,不再单独传递
|
||||
delete submitData[field];
|
||||
}
|
||||
});
|
||||
|
||||
// 将所有文件ID统一放到fileIds字段中
|
||||
if (allFileIds.length > 0) {
|
||||
submitData.fileIds = allFileIds;
|
||||
console.log('所有文件ID (fileIds):', allFileIds);
|
||||
}
|
||||
|
||||
console.log('提交数据:', submitData);
|
||||
|
||||
await addObj(submitData);
|
||||
useMessage().success('提交成功');
|
||||
@@ -1555,8 +1657,9 @@ const handleTempStore = async () => {
|
||||
...dataForm,
|
||||
};
|
||||
|
||||
// 处理所有文件字段 - 收集所有文件ID到fileIds数组中
|
||||
const fileFields = [
|
||||
'businessNegotiationTable', 'marketPurchaseMinutes', 'onlineMallMaterials',
|
||||
'businessNegotiationTable', 'marketPurchaseMinutes', 'onlineMallMaterials', 'inquiryTemplate',
|
||||
'serviceDirectSelect', 'servicePublicSelect', 'purchaseRequirementTemplate',
|
||||
'serviceInviteSelect', 'servicePublicSelectAuto', 'purchaseRequirement',
|
||||
'meetingMinutes', 'feasibilityReport', 'meetingMinutesUrgent',
|
||||
@@ -1565,11 +1668,23 @@ const handleTempStore = async () => {
|
||||
'servicePublicSelectSchoolAuto', 'otherMaterials'
|
||||
];
|
||||
|
||||
// 收集所有文件ID到一个数组中
|
||||
const allFileIds: string[] = [];
|
||||
|
||||
fileFields.forEach(field => {
|
||||
if (submitData[field]) {
|
||||
submitData[field] = getFileIdsArray(submitData[field]);
|
||||
const ids = getFileIdsArray(submitData[field]);
|
||||
// 收集到总数组中
|
||||
allFileIds.push(...ids);
|
||||
// 清空原字段,不再单独传递
|
||||
delete submitData[field];
|
||||
}
|
||||
});
|
||||
|
||||
// 将所有文件ID统一放到fileIds字段中
|
||||
if (allFileIds.length > 0) {
|
||||
submitData.fileIds = allFileIds;
|
||||
}
|
||||
|
||||
await tempStore(submitData);
|
||||
useMessage().success('暂存成功');
|
||||
|
||||
Reference in New Issue
Block a user