353a4042 by lihua

产品支持上传文件

1 parent 9b123ce8
......@@ -426,6 +426,35 @@ const baseInfoFormItems = ref([
required: true,
},
{
label: '是否文件资源',
type: 'radio-group',
placeholder: '',
field: 'isFileResource',
block: false,
disabled: false,
default: 'N',
options: [{
value: 'Y',
label: '是'
}, {
value: 'N',
label: '否'
}],
required: true,
},
{
label: '选择文件上传',
tip: '',
type: 'upload-file',
accept: '',
required: true,
default: [],
block: false,
field: 'attachments',
col: 'col2',
visible: false,
},
{
label: '资源描述',
type: 'textarea',
placeholder: '该数据资源主要包含的信息,数据更新方式等。',
......@@ -496,7 +525,16 @@ const baseInfoFormRules = ref({
domain: [required('请选择领域')],
scenario: [required('请选择应用场景')],
medDepartmentCode: [required('请选择所属科室')],
updateFrequency: [required('请选择更新频率')]
updateFrequency: [required('请选择更新频率')],
attachments: [{
validator: (rule: any, value: any, callback: any) => {
if (!value?.length) {
callback(new Error('请上传文件'))
} else {
callback();
}
}, trigger: 'change'
}]
});
const getTableFieldPromise: any = ref({});
......@@ -665,6 +703,9 @@ const setFormItems = (val) => {
item.visible = val['domain'] == '003'
} else if (item.field == 'subjectDomain') {
item.visible = val['domain'] == '004';
} else if (item.field == 'attachments') {
item.visible = val['isFileResource'] == 'Y';
item.default = val[item.field] || [];
}
});
}
......@@ -693,6 +734,12 @@ const handleBaseInfoCheckboxChange = (val, info) => {
setFormItems(info);
}
const handleBaseInfoRadioChange = (val, info, item) => {
if (item.field == 'isFileResource') {
setFormItems(info);
}
}
/** ------------------- 添加选择数据服务API表格,多选 ---------------------------- */
const productTableRef = ref();
const productData: any = ref([]);
......@@ -881,6 +928,11 @@ onBeforeMount(() => {
item.options = domainDictList.value.find(s => s.value == detailInfo.value['domain'])?.childDictList || []
} else if (item.field == 'medDepartmentCode') {
item.visible = detailInfo.value['domain'] == '003'
} else if (item.field == 'isFileResource') {
item.default = detailInfo.value.attachments?.length ? 'Y' : 'N';
} else if (item.field == 'attachments') {
item.default = detailInfo.value.attachments || [];
item.visible = item.default.length > 0;
}
if (item.field == 'isCache' || item.field == 'isEncrypField') {
item.disabled = true;
......@@ -1035,40 +1087,48 @@ const save = () => {
baseInfoFormRef.value?.ruleFormRef?.validate((valid, errorItem) => {
if (valid) {
let params = { ...baseInfoFormRef.value.formInline };
let associationApiList: string[] = [];
for (const api of productData.value) {
if (!api.apiGuid) {
proxy.$ElMessage.error('服务包信息未填写完整');
expandServiceInfo.value = true;
return;
if (params.isFileResource != 'Y') {
let associationApiList: string[] = [];
for (const api of productData.value) {
if (!api.apiGuid) {
proxy.$ElMessage.error('服务包信息未填写完整');
expandServiceInfo.value = true;
return;
}
associationApiList.push(api.apiGuid);
}
associationApiList.push(api.apiGuid);
}
params.associationApi = associationApiList;
/** 只有数据集和api类型时,目录表必填。 */
if ((params.damType == '1') && route.query.foundMode != '2') {
// if (!params.databaseType) {
// proxy.$ElMessage.error('资源类型为数据集时,数据库类型必填');
// baseInfoExpand.value = true;
// return;
// }
if (!assetDataTableInfo.value.data?.length) {
proxy.$ElMessage.error('资源类型为数据集时,必需添加资源表');
assetTableInfoExpand.value = true;
nextTick(() => {
setTimeout(() => {
handleContentWrapView('tableInfo');
}, 500)
});
return;
params.associationApi = associationApiList;
/** 只有数据集和api类型时,目录表必填。 */
if ((params.damType == '1') && route.query.foundMode != '2') {
// if (!params.databaseType) {
// proxy.$ElMessage.error('资源类型为数据集时,数据库类型必填');
// baseInfoExpand.value = true;
// return;
// }
if (!assetDataTableInfo.value.data?.length) {
proxy.$ElMessage.error('资源类型为数据集时,必需添加资源表');
assetTableInfoExpand.value = true;
nextTick(() => {
setTimeout(() => {
handleContentWrapView('tableInfo');
}, 500)
});
return;
}
}
}
if (params.damType == '2' && route.query.foundMode != '2') {
if (!associationApiList?.length) {
proxy.$ElMessage.error('资源类型为数据接口时,服务包不能为空');
return;
if (params.damType == '2' && route.query.foundMode != '2') {
if (!associationApiList?.length) {
proxy.$ElMessage.error('资源类型为数据接口时,服务包不能为空');
return;
}
}
}
params.attachments = params.attachments?.map(item => {
return {
name: item.name,
url: item.url
}
}) || [];
if (params.coverageArea == 'all') {
params.coverageArea = [['all']];
} else if (!params.coverageArea) {
......@@ -1241,9 +1301,9 @@ const handleImportSave = (val) => {
<ContentWrap id="id-baseInfo" title="资源基本信息" description="" :isExpand="baseInfoExpand" :expand-swicth="true"
class="mb16" @expand="(v) => baseInfoExpand = v">
<Form ref="baseInfoFormRef" :itemList="baseInfoFormItems" formId="base-info-form" :rules="baseInfoFormRules"
@selectChange="baseSelectChange" @checkboxChange="handleBaseInfoCheckboxChange" col="col3" />
@selectChange="baseSelectChange" @checkboxChange="handleBaseInfoCheckboxChange" @radio-group-change="handleBaseInfoRadioChange" col="col3" />
</ContentWrap>
<ContentWrap v-if="baseInfoFormRef?.formInline?.damType == '2'" id="product-info" title="服务包信息" expandSwicth
<ContentWrap v-if="baseInfoFormRef?.formInline?.damType == '2' && baseInfoFormRef?.formInline?.isFileResource != 'Y'" id="product-info" title="服务包信息" expandSwicth
style="margin-top: 15px" :isExpand="expandServiceInfo" @expand="(v) => (expandServiceInfo = v)" description=""
class="mb16">
<Table ref="productTableRef" :tableInfo="productTableInfo" class="fiveRow-table"
......@@ -1252,7 +1312,7 @@ const handleImportSave = (val) => {
<el-button :disabled="productData.length >= apiList.length" link @click="addProduct" :icon="CirclePlus" v-preReClick>添加服务</el-button>
</div>
</ContentWrap>
<ContentWrap v-if="baseInfoFormRef?.formInline?.damType != '2'" id="id-tableInfo" title="资源表" description=""
<ContentWrap v-if="baseInfoFormRef?.formInline?.damType != '2' && baseInfoFormRef?.formInline?.isFileResource != 'Y'" id="id-tableInfo" title="资源表" description=""
:expand-swicth="true" :isExpand="assetTableInfoExpand" @expand="(v) => assetTableInfoExpand = v">
<div v-show="assetDataTableInfo.data.length" class="tools_btns">
<el-button type="primary" @click="handleCreateTable" v-preReClick>添加</el-button>
......
......@@ -1444,7 +1444,7 @@ const respParamsTableInfo = ref({
</div>
</div>
</ContentWrap>
<ContentWrap v-if="productTableInfo.data?.length" id="product-info" title="服务包信息" style="margin: 16px 16px 16px">
<ContentWrap v-if="productTableInfo.data?.length && !detailInfo.attachments?.length" id="product-info" title="服务包信息" style="margin: 16px 16px 16px">
<Table ref="productTableRef" :tableInfo="productTableInfo" />
</ContentWrap>
<ContentWrap v-if="isJSZQ" id="id-paramsInfo" title="入参出参信息" description="" style="margin: 16px 16px 16px">
......@@ -1457,7 +1457,57 @@ const respParamsTableInfo = ref({
</el-tab-pane>
</el-tabs>
</ContentWrap>
<ContentWrap id="id-table" title="资源表" v-if="detailInfo.damCatalogTableInfo?.length" description=""
<ContentWrap id="id-table" title="文件资源" v-if="detailInfo.attachments?.length" description=""
style="margin: 16px 16px 16px">
<div class="list_panel">
<div class="list_item is_block">
<div class="file_item">
<span class="item_label">上传文件:</span>
<span class="item_value">
<span v-for="productDetailItem in (detailInfo.attachments || [])"
:style="{ 'padding-left': '0px', height: '32px', display: 'block' }">
<div class="file-operate">
<template
v-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'xls' || productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'xlsx' || productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'csv'">
<img class="file-img" src="../../assets/images/excel.png" />
</template>
<template
v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'doc' || productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'docx'">
<img class="file-img" src="../../assets/images/word.png" />
</template>
<template v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'zip'">
<img class="file-img" src="../../assets/images/zip.png" />
</template>
<template v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'rar'">
<img class="file-img" src="../../assets/images/RAR.png" />
</template>
<template v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'pdf'">
<img class="file-img" src="../../assets/images/PDF.png" />
</template>
<template v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'png'">
<img class="file-img" src="../../assets/images/png.png" />
</template>
<template
v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'jpg' || productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'jpeg'">
<img class="file-img" src="../../assets/images/jpg.png" />
</template>
<div class="file-name"><ellipsis-tooltip :content="productDetailItem.name ?? ''" class-name="w100f"
refName="tooltipOver"></ellipsis-tooltip></div>
<div
v-if="foundMode != 'download' && ['pdf', 'png', 'jpg', 'jpeg'].includes(productDetailItem.name?.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase())"
:style="{ right: '36px' }" class="file-preview" @click="onUploadFilePreview(productDetailItem)">
查看
</div>
<div :style="{ right: '0px' }" class="file-preview" v-if="foundMode == 'download' || foundMode == 'readAndDown' || foundMode == '1'"
@click="onUploadFileDownload(productDetailItem)">下载</div>
</div>
</span>
</span>
</div>
</div>
</div>
</ContentWrap>
<ContentWrap id="id-table" title="资源表" v-if="detailInfo.damCatalogTableInfo?.length && !detailInfo.attachments?.length" description=""
style="margin: 16px 16px 16px">
<el-table v-show="!fullscreenLoading" ref="tableRef" :data="detailInfo.damCatalogTableInfo"
:highlight-current-row="true" stripe border @expand-change="handleTableExpandChange" max-height="350"
......@@ -1595,9 +1645,9 @@ const respParamsTableInfo = ref({
<img class="file-img" src="../../assets/images/jpg.png" />
</template>
<div class="file-name">{{ item.name }}</div>
<div :style="{ right: '36px' }" v-if="foundMode != 'download' && item.name.substring(item.name.lastIndexOf('.') + 1) == 'pdf' || item.name.substring(item.name.lastIndexOf('.') + 1) == 'png' || item.name.substring(item.name.lastIndexOf('.') + 1) == 'jpg' || item.name.substring(item.name.lastIndexOf('.') + 1) == 'jpeg'"
<div :style="{ right: '36px' }" v-if="item.name.substring(item.name.lastIndexOf('.') + 1) == 'pdf' || item.name.substring(item.name.lastIndexOf('.') + 1) == 'png' || item.name.substring(item.name.lastIndexOf('.') + 1) == 'jpg' || item.name.substring(item.name.lastIndexOf('.') + 1) == 'jpeg'"
class="file-preview" @click="onUploadFilePreview(item)">查看</div>
<div v-if="foundMode == 'download' || foundMode == 'readAndDown' || foundMode == '1'" :style="{ right: '0px' }" class="file-preview" @click="onUploadFileDownload(item)">下载</div>
<div :style="{ right: '0px' }" class="file-preview" @click="onUploadFileDownload(item)">下载</div>
</div>
</span>
</div>
......@@ -2150,6 +2200,10 @@ const respParamsTableInfo = ref({
}
}
.file_item {
width: 70%;
}
.file-operate {
display: flex;
align-items: center;
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!