fix: 修复缺陷管理&用例管理文件转存bug

This commit is contained in:
xinxin.wu 2024-04-15 17:37:47 +08:00 committed by Craftsman
parent 0b85f941ec
commit b1ea71ecfa
4 changed files with 74 additions and 41 deletions

View File

@ -212,7 +212,6 @@
watch( watch(
() => props.fileList, () => props.fileList,
(val) => { (val) => {
console.log(props.initFileSaveTips);
innerFileList.value = val.sort((a, b) => { innerFileList.value = val.sort((a, b) => {
if (a.status === UploadStatus.init && b.status !== UploadStatus.init) { if (a.status === UploadStatus.init && b.status !== UploadStatus.init) {
return -1; // "init" return -1; // "init"

View File

@ -105,21 +105,10 @@
type="button" type="button"
status="primary" status="primary"
class="!mr-[4px]" class="!mr-[4px]"
@click="transferVisible = true" @click="transferHandler(item)"
> >
{{ t('caseManagement.featureCase.storage') }} {{ t('caseManagement.featureCase.storage') }}
</MsButton> </MsButton>
<TransferModal
v-model:visible="transferVisible"
:request-fun="transferFileRequest"
:params="{
projectId: currentProjectId,
bugId: bugId,
fileId: item.uid,
local: true,
}"
@success="emit('updateSuccess')"
/>
<MsButton <MsButton
v-if="item.status === 'done'" v-if="item.status === 'done'"
type="button" type="button"
@ -197,6 +186,12 @@
@save="saveSelectAssociatedFile" @save="saveSelectAssociatedFile"
/> />
<a-image-preview v-model:visible="previewVisible" :src="imageUrl" /> <a-image-preview v-model:visible="previewVisible" :src="imageUrl" />
<TransferModal
v-model:visible="transferVisible"
:request-fun="transferFileRequest"
:params="activeTransferFileParams"
@success="emit('updateSuccess')"
/>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -235,6 +230,7 @@
import { findParents, Option } from '@/utils/recursion'; import { findParents, Option } from '@/utils/recursion';
import { BugEditCustomField, BugEditCustomFieldItem, BugEditFormObject } from '@/models/bug-management'; import { BugEditCustomField, BugEditCustomFieldItem, BugEditFormObject } from '@/models/bug-management';
import type { OperationFile } from '@/models/caseManagement/featureCase';
import { AssociatedList, AttachFileInfo } from '@/models/caseManagement/featureCase'; import { AssociatedList, AttachFileInfo } from '@/models/caseManagement/featureCase';
import { TableQueryParams } from '@/models/common'; import { TableQueryParams } from '@/models/common';
@ -540,6 +536,22 @@
await handleFileFunc(attachments); await handleFileFunc(attachments);
Message.success(t('common.linkSuccess')); Message.success(t('common.linkSuccess'));
} }
const activeTransferFileParams = ref<OperationFile>({
projectId: '',
bugId: '',
fileId: '',
local: true,
});
function transferHandler(item: MsFileItem) {
activeTransferFileParams.value = {
projectId: currentProjectId.value,
fileId: item.uid,
bugId: props.detailInfo.id,
local: true,
};
transferVisible.value = true;
}
watchEffect(() => { watchEffect(() => {
initCurrentDetail(props.detailInfo); initCurrentDetail(props.detailInfo);

View File

@ -108,21 +108,10 @@
type="button" type="button"
status="primary" status="primary"
class="!mr-[4px]" class="!mr-[4px]"
@click="transferFile" @click="transferFile(item)"
> >
{{ t('caseManagement.featureCase.storage') }} {{ t('caseManagement.featureCase.storage') }}
</MsButton> </MsButton>
<TransferModal
v-model:visible="transferVisible"
:request-fun="transferFileRequest"
:params="{
projectId: currentProjectId,
caseId: props.caseId,
fileId: item.uid,
local: true,
}"
@success="getCaseInfo()"
/>
<MsButton <MsButton
v-if="item.status !== 'init'" v-if="item.status !== 'init'"
type="button" type="button"
@ -250,6 +239,12 @@
@save="saveSelectAssociatedFile" @save="saveSelectAssociatedFile"
/> />
<a-image-preview v-model:visible="previewVisible" :src="imageUrl" /> <a-image-preview v-model:visible="previewVisible" :src="imageUrl" />
<TransferModal
v-model:visible="transferVisible"
:request-fun="transferFileRequest"
:params="activeTransferFileParams"
@success="getCaseInfo()"
/>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -296,6 +291,7 @@
CreateOrUpdateCase, CreateOrUpdateCase,
CustomAttributes, CustomAttributes,
DetailCase, DetailCase,
OperationFile,
OptionsFieldId, OptionsFieldId,
StepList, StepList,
} from '@/models/caseManagement/featureCase'; } from '@/models/caseManagement/featureCase';
@ -695,10 +691,25 @@
}); });
const transferVisible = ref<boolean>(false); const transferVisible = ref<boolean>(false);
const activeTransferFileParams = ref<OperationFile>({
projectId: '',
caseId: '',
fileId: '',
local: true,
});
// //
function transferFile() { function transferFile(item: MsFileItem) {
activeTransferFileParams.value = {
projectId: currentProjectId.value,
caseId: form.value.id,
fileId: item.uid,
local: true,
};
transferVisible.value = true; transferVisible.value = true;
} }
// //
async function downloadFile(item: MsFileItem) { async function downloadFile(item: MsFileItem) {
try { try {

View File

@ -182,20 +182,9 @@
> >
{{ t('ms.upload.preview') }} {{ t('ms.upload.preview') }}
</MsButton> </MsButton>
<MsButton type="button" status="primary" class="!mr-[4px]" @click="transferVisible = true"> <MsButton type="button" status="primary" class="!mr-[4px]" @click="transferFileHandler(item)">
{{ t('caseManagement.featureCase.storage') }} {{ t('caseManagement.featureCase.storage') }}
</MsButton> </MsButton>
<TransferModal
v-model:visible="transferVisible"
:request-fun="transferFileRequest"
:params="{
projectId: currentProjectId,
caseId: detailForm.id,
fileId: item.uid,
local: true,
}"
@success="emit('updateSuccess')"
/>
<MsButton <MsButton
v-if="item.status === 'done'" v-if="item.status === 'done'"
type="button" type="button"
@ -270,6 +259,12 @@
/> />
</div> </div>
<a-image-preview v-model:visible="previewVisible" :src="imageUrl" /> <a-image-preview v-model:visible="previewVisible" :src="imageUrl" />
<TransferModal
v-model:visible="transferVisible"
:request-fun="transferFileRequest"
:params="activeTransferFileParams"
@success="emit('updateSuccess')"
/>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -308,7 +303,7 @@
import { downloadByteFile, getGenerateId, sleep } from '@/utils'; import { downloadByteFile, getGenerateId, sleep } from '@/utils';
import { scrollIntoView } from '@/utils/dom'; import { scrollIntoView } from '@/utils/dom';
import type { AssociatedList, DetailCase, StepList } from '@/models/caseManagement/featureCase'; import type { AssociatedList, DetailCase, OperationFile, StepList } from '@/models/caseManagement/featureCase';
import type { TableQueryParams } from '@/models/common'; import type { TableQueryParams } from '@/models/common';
import { convertToFile } from '../utils'; import { convertToFile } from '../utils';
@ -674,6 +669,22 @@
fileListRef.value?.startUpload(); fileListRef.value?.startUpload();
} }
const activeTransferFileParams = ref<OperationFile>({
projectId: '',
caseId: '',
fileId: '',
local: true,
});
function transferFileHandler(item: MsFileItem) {
activeTransferFileParams.value = {
projectId: currentProjectId.value,
caseId: props.form.id,
fileId: item.uid,
local: true,
};
transferVisible.value = true;
}
watch( watch(
() => props.form, () => props.form,
(val) => { (val) => {