|
@ -1,6 +1,14 @@ |
|
|
<!-- 导入组件 --> |
|
|
<!-- 导入组件 --> |
|
|
<template> |
|
|
<template> |
|
|
<Dialog v-model="dialogVisible" :title="t('ts.导入')" width="600" :close-on-click-modal="false"> |
|
|
<Dialog v-model="dialogVisible" :title="t('ts.导入')" width="600" :close-on-click-modal="false"> |
|
|
|
|
|
<Form |
|
|
|
|
|
ref="formRef" |
|
|
|
|
|
:rules="rules" |
|
|
|
|
|
:schema="formSchema" |
|
|
|
|
|
:is-col="true" |
|
|
|
|
|
@opensearchTable="opensearchTable" |
|
|
|
|
|
style="margin-top:20px" |
|
|
|
|
|
/> |
|
|
<el-upload |
|
|
<el-upload |
|
|
ref="uploadRef" |
|
|
ref="uploadRef" |
|
|
v-model:file-list="fileList" |
|
|
v-model:file-list="fileList" |
|
@ -16,7 +24,8 @@ |
|
|
outFile + |
|
|
outFile + |
|
|
'&extend=' + extend + |
|
|
'&extend=' + extend + |
|
|
'&fromInventoryStatus=' + fromInventoryStatus + |
|
|
'&fromInventoryStatus=' + fromInventoryStatus + |
|
|
'&toInventoryStatus=' + toInventoryStatus |
|
|
'&toInventoryStatus=' + toInventoryStatus + |
|
|
|
|
|
(formRef?.formModel ? Object.entries(formRef.formModel).map(([key, value]) => `&${key}=${value}`).join('') : '') |
|
|
" |
|
|
" |
|
|
:auto-upload="false" |
|
|
:auto-upload="false" |
|
|
:disabled="formLoading" |
|
|
:disabled="formLoading" |
|
@ -99,6 +108,17 @@ |
|
|
<el-button @click="dialogVisible = false">{{ t('ts.取 消') }}</el-button> |
|
|
<el-button @click="dialogVisible = false">{{ t('ts.取 消') }}</el-button> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
<SearchTable |
|
|
|
|
|
ref="searchTableRef" |
|
|
|
|
|
:showSearchTableQueryFields="showSearchTableQueryFields" |
|
|
|
|
|
:hiddenFilterBtnFields="hiddenFilterBtnFields" |
|
|
|
|
|
:isCheckStrictly="isCheckStrictly" |
|
|
|
|
|
@searchTableSuccess="searchTableSuccess" |
|
|
|
|
|
> |
|
|
|
|
|
<template v-for="name in Object.keys($slots)" :key="name" #[name]="{ selections }"> |
|
|
|
|
|
<slot :name="name" :selections="selections"></slot> |
|
|
|
|
|
</template> |
|
|
|
|
|
</SearchTable> |
|
|
</Dialog> |
|
|
</Dialog> |
|
|
</template> |
|
|
</template> |
|
|
<script lang="ts" setup> |
|
|
<script lang="ts" setup> |
|
@ -198,6 +218,47 @@ const props = defineProps({ |
|
|
required: false, |
|
|
required: false, |
|
|
default: false |
|
|
default: false |
|
|
}, |
|
|
}, |
|
|
|
|
|
// 表单,列表 相关信息 |
|
|
|
|
|
formSchema: { |
|
|
|
|
|
type: Array, |
|
|
|
|
|
required: false, |
|
|
|
|
|
default: () => [] |
|
|
|
|
|
}, |
|
|
|
|
|
// 成功入库接口 |
|
|
|
|
|
confirmFormSuccess: { |
|
|
|
|
|
type: Function, |
|
|
|
|
|
required: false, |
|
|
|
|
|
}, |
|
|
|
|
|
detailData:{ |
|
|
|
|
|
type:Object, |
|
|
|
|
|
required: false, |
|
|
|
|
|
default: () => ({}) |
|
|
|
|
|
}, |
|
|
|
|
|
isSearch:{ |
|
|
|
|
|
type:Boolean, |
|
|
|
|
|
default:false |
|
|
|
|
|
}, |
|
|
|
|
|
showSearchTableQueryFields: { |
|
|
|
|
|
type: Array, |
|
|
|
|
|
required: false, |
|
|
|
|
|
default: [] |
|
|
|
|
|
}, |
|
|
|
|
|
hiddenFilterBtnFields:{ |
|
|
|
|
|
type: Array, |
|
|
|
|
|
required: false, |
|
|
|
|
|
default: [] |
|
|
|
|
|
}, |
|
|
|
|
|
// 失去焦点之后是否进行校验, |
|
|
|
|
|
isJiaoyan: { |
|
|
|
|
|
type: Boolean, |
|
|
|
|
|
required: false, |
|
|
|
|
|
default: false |
|
|
|
|
|
}, |
|
|
|
|
|
// true 取消父子关联; false 关联 |
|
|
|
|
|
isCheckStrictly:{ |
|
|
|
|
|
type:Boolean, |
|
|
|
|
|
default:false |
|
|
|
|
|
}, |
|
|
}) |
|
|
}) |
|
|
const importTemplateData = ref(props.importTemplateData) |
|
|
const importTemplateData = ref(props.importTemplateData) |
|
|
const accept = ref(props.accept) |
|
|
const accept = ref(props.accept) |
|
@ -207,7 +268,7 @@ const appendIsDisable = ref(props.appendIsDisable) //追加是否禁用,默认 |
|
|
const coverIsDisable = ref(props.coverIsDisable) //覆盖是否禁用,默认值不禁用 |
|
|
const coverIsDisable = ref(props.coverIsDisable) //覆盖是否禁用,默认值不禁用 |
|
|
const updatePart = ref(props.updatePart) //是否部门保存 |
|
|
const updatePart = ref(props.updatePart) //是否部门保存 |
|
|
const outFile = ref(props.outFile) //是否引入外部资源 |
|
|
const outFile = ref(props.outFile) //是否引入外部资源 |
|
|
|
|
|
const formRef = ref() //表单 |
|
|
const importUrl = getBaseUrl() + import.meta.env.VITE_API_URL + props.url |
|
|
const importUrl = getBaseUrl() + import.meta.env.VITE_API_URL + props.url |
|
|
|
|
|
|
|
|
/** 打开弹窗 */ |
|
|
/** 打开弹窗 */ |
|
@ -217,25 +278,65 @@ const open = () => { |
|
|
} |
|
|
} |
|
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗 |
|
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 传递给父类 |
|
|
|
|
|
const emits = defineEmits([ |
|
|
|
|
|
'success', |
|
|
|
|
|
'tableSelectionChange', |
|
|
|
|
|
'tableSelectionDelete', |
|
|
|
|
|
'tableFormSelectOnBlur', |
|
|
|
|
|
'extendedButtonsClick', |
|
|
|
|
|
'formSelectChange', |
|
|
|
|
|
'formSelectvVisibleChange', |
|
|
|
|
|
'tableSortChange', |
|
|
|
|
|
'selectCallback', |
|
|
|
|
|
'handleTableSelect', |
|
|
|
|
|
'handleDeleteTable', |
|
|
|
|
|
'handleAddTable', |
|
|
|
|
|
'inpuFocus', |
|
|
|
|
|
'searchTableSuccess', |
|
|
|
|
|
'opensearchTable', |
|
|
|
|
|
'submitForm', |
|
|
|
|
|
'selectChange', |
|
|
|
|
|
'selectChangeDetail', |
|
|
|
|
|
'tableFormChange', |
|
|
|
|
|
'buttonOperationClick', |
|
|
|
|
|
'inputStringBlur', |
|
|
|
|
|
'onChange', |
|
|
|
|
|
'onBlur', |
|
|
|
|
|
'onEnter', |
|
|
|
|
|
'inputNumberChange', |
|
|
|
|
|
'formFormDateChange', |
|
|
|
|
|
'footButtonClick', |
|
|
|
|
|
'clearSearchInput', |
|
|
|
|
|
'clearInput', |
|
|
|
|
|
'sumFormDataHandle', |
|
|
|
|
|
'visibleChange' |
|
|
|
|
|
]) |
|
|
/** 提交表单 */ |
|
|
/** 提交表单 */ |
|
|
const submitForm = async () => { |
|
|
const submitForm = async () => { |
|
|
|
|
|
// 表单校验部分 - 仅修改这部分 |
|
|
|
|
|
const elForm = unref(formRef)?.getElFormRef() |
|
|
|
|
|
if (!elForm) return |
|
|
|
|
|
const valid = await elForm.validate() |
|
|
|
|
|
if (!valid) return |
|
|
|
|
|
|
|
|
if (fileList.value.length == 0) { |
|
|
if (fileList.value.length == 0) { |
|
|
message.error('请上传文件') |
|
|
message.error('请上传文件') |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 以下都保持原样不变 |
|
|
// 校验文件类型 |
|
|
// 校验文件类型 |
|
|
const fileName = fileList.value[0].name |
|
|
const fileName = fileList.value[0].name |
|
|
const fileExtension = fileName.substring(fileName.lastIndexOf('.')).toLowerCase() |
|
|
const fileExtension = fileName.substring(fileName.lastIndexOf('.')).toLowerCase() |
|
|
const acceptedTypes = accept.value.split(',').map(type => type.toLowerCase()) |
|
|
const acceptedTypes = accept.value.split(',').map(type => type.toLowerCase()) |
|
|
|
|
|
|
|
|
// 检查文件扩展名是否在允许的类型列表中 |
|
|
// 检查文件扩展名是否在允许的类型列表中 |
|
|
if (!acceptedTypes.some(type => type === fileExtension || type === `.*${fileExtension}`)) { |
|
|
if (!acceptedTypes.some(type => type === fileExtension || type === `.*${fileExtension}`)) { |
|
|
message.error(`只能上传 ${accept.value} 格式的文件`) |
|
|
message.error(`只能上传 ${accept.value} 格式的文件`) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
file.value = fileName |
|
|
file.value = fileName |
|
|
|
|
|
|
|
|
// 提交请求 |
|
|
// 提交请求 |
|
|
uploadHeaders.value = { |
|
|
uploadHeaders.value = { |
|
|
Authorization: 'Bearer ' + getAccessToken(), |
|
|
Authorization: 'Bearer ' + getAccessToken(), |
|
@ -245,8 +346,149 @@ const submitForm = async () => { |
|
|
uploadRef.value!.submit() |
|
|
uploadRef.value!.submit() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** 文件上传成功 */ |
|
|
|
|
|
const emits = defineEmits(['success']) |
|
|
const searchTableRef = ref() |
|
|
|
|
|
const opensearchTable = ( |
|
|
|
|
|
formField, |
|
|
|
|
|
searchField, |
|
|
|
|
|
searchTitle, |
|
|
|
|
|
searchAllSchemas, |
|
|
|
|
|
searchPage, |
|
|
|
|
|
searchCondition, |
|
|
|
|
|
multiple, |
|
|
|
|
|
type, |
|
|
|
|
|
row, |
|
|
|
|
|
isConcatDetailSchemas = false, |
|
|
|
|
|
searchDetailSchemas: any |
|
|
|
|
|
) => { |
|
|
|
|
|
const _searchCondition = {} |
|
|
|
|
|
// 判断查询条件中,是否存在指向主表的数据 |
|
|
|
|
|
if (searchCondition && searchCondition.length > 0) { |
|
|
|
|
|
// 转换筛选条件所需 |
|
|
|
|
|
let filters: any[] = [] |
|
|
|
|
|
for (var i = 0; i < searchCondition.length; i++) { |
|
|
|
|
|
// searchCondition.forEach((item) => { |
|
|
|
|
|
// 查询条件为主表某字段,需要赋值主表数据,数据来源是详情的,赋值需要从row中获取 |
|
|
|
|
|
if (searchCondition[i].isMainValue) { |
|
|
|
|
|
if (searchCondition[i].isFilterValue) { |
|
|
|
|
|
//后端接口需要拼入到filters中 |
|
|
|
|
|
filters.push({ |
|
|
|
|
|
action: searchCondition[i].action, |
|
|
|
|
|
column: searchCondition[i].key, |
|
|
|
|
|
value: formRef.value.formModel[searchCondition[i].value] |
|
|
|
|
|
? formRef.value.formModel[searchCondition[i].value] |
|
|
|
|
|
: props.detailData |
|
|
|
|
|
? props.detailData[searchCondition[i].value] |
|
|
|
|
|
: row |
|
|
|
|
|
? row[searchCondition[i].value] |
|
|
|
|
|
: '' |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
_searchCondition[searchCondition[i].key] = formRef.value.formModel[ |
|
|
|
|
|
searchCondition[i].value |
|
|
|
|
|
] |
|
|
|
|
|
? formRef.value.formModel[searchCondition[i].value] |
|
|
|
|
|
: props.detailData |
|
|
|
|
|
? props.detailData[searchCondition[i].value] |
|
|
|
|
|
: row |
|
|
|
|
|
? row[searchCondition[i].value] |
|
|
|
|
|
: '' |
|
|
|
|
|
// 是否含有空参数情况 |
|
|
|
|
|
let isNull = false |
|
|
|
|
|
if ( |
|
|
|
|
|
_searchCondition[searchCondition[i].key] == '' || |
|
|
|
|
|
_searchCondition[searchCondition[i].key] == undefined |
|
|
|
|
|
) { |
|
|
|
|
|
if(!searchCondition[i].isOptional){ // 添加参数可选可空的判断 |
|
|
|
|
|
isNull = true |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (isNull) { |
|
|
|
|
|
message.warning( |
|
|
|
|
|
searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!' |
|
|
|
|
|
) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if(searchCondition[i].isRemoveParams){ |
|
|
|
|
|
//有校验,但是不传参 |
|
|
|
|
|
_searchCondition[searchCondition[i].key] = '' |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} else if (searchCondition[i].isTableRowValue) { |
|
|
|
|
|
if (searchCondition[i].required) { |
|
|
|
|
|
if (row[searchCondition[i].value] == '' || row[searchCondition[i].value] == undefined) { |
|
|
|
|
|
message.warning( |
|
|
|
|
|
searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!' |
|
|
|
|
|
) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
row[searchCondition[i].value] |
|
|
|
|
|
//查询当前table表数据的值 |
|
|
|
|
|
_searchCondition[searchCondition[i].key] = row[searchCondition[i].value] |
|
|
|
|
|
} else { |
|
|
|
|
|
// 扩展 转换为筛选条件进行查询 |
|
|
|
|
|
if (searchCondition[i].isSearch) { |
|
|
|
|
|
if (searchCondition[i].isFormModel) { |
|
|
|
|
|
//用formModel中的值 |
|
|
|
|
|
if (searchCondition[i].required) { |
|
|
|
|
|
if ( |
|
|
|
|
|
formRef.value.formModel[searchCondition[i].value] == '' || |
|
|
|
|
|
formRef.value.formModel[searchCondition[i].value] == undefined |
|
|
|
|
|
) { |
|
|
|
|
|
if(!searchCondition[i].isOptional){ // 添加参数可选可空的判断 |
|
|
|
|
|
message.warning( |
|
|
|
|
|
searchCondition[i].message ? searchCondition[i].message : '前置条件未选择!' |
|
|
|
|
|
) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if(formRef.value.formModel[searchCondition[i].value]){ |
|
|
|
|
|
filters.push({ |
|
|
|
|
|
action: searchCondition[i].action, |
|
|
|
|
|
column: searchCondition[i].key, |
|
|
|
|
|
value: formRef.value.formModel[searchCondition[i].value] |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
filters.push({ |
|
|
|
|
|
action: searchCondition[i].action, |
|
|
|
|
|
column: searchCondition[i].key, |
|
|
|
|
|
value: searchCondition[i].value |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
_searchCondition[searchCondition[i].key] = searchCondition[i].value |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (filters.length > 0) { |
|
|
|
|
|
_searchCondition.isSearch = true |
|
|
|
|
|
_searchCondition.filters = filters |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
const _searchTableTitle = searchTitle |
|
|
|
|
|
const _searchTableAllSchemas = searchAllSchemas |
|
|
|
|
|
const _searchTablePage = searchPage |
|
|
|
|
|
searchTableRef.value.open( |
|
|
|
|
|
_searchTableTitle, |
|
|
|
|
|
_searchTableAllSchemas, |
|
|
|
|
|
_searchTablePage, |
|
|
|
|
|
formField, |
|
|
|
|
|
searchField, |
|
|
|
|
|
multiple, |
|
|
|
|
|
type, |
|
|
|
|
|
row, |
|
|
|
|
|
_searchCondition, |
|
|
|
|
|
undefined, |
|
|
|
|
|
isConcatDetailSchemas, |
|
|
|
|
|
searchDetailSchemas |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const submitFormSuccess = (response: any) => { |
|
|
const submitFormSuccess = (response: any) => { |
|
|
formLoading.value = true |
|
|
formLoading.value = true |
|
|
console.log(response) |
|
|
console.log(response) |
|
@ -333,6 +575,10 @@ const handleExceed = (): void => { |
|
|
message.error('最多只能上传一个文件!') |
|
|
message.error('最多只能上传一个文件!') |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const searchTableSuccess = (formField, searchField, val, type, row) => { |
|
|
|
|
|
emits('searchTableSuccess', formField, searchField, val, formRef.value, type, row) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** 下载模板操作 */ |
|
|
/** 下载模板操作 */ |
|
|
const importTemplate = () => { |
|
|
const importTemplate = () => { |
|
|
const res = importTemplateData.value.templateUrl |
|
|
const res = importTemplateData.value.templateUrl |
|
|