Skip to content

Commit

Permalink
fix:修复上线版本对比问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuikill committed Oct 27, 2023
1 parent 3d977c4 commit acba7d6
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
</select-group>
<template #footer>
<section class="actions-wrapper">
<bk-button class="publish-btn" theme="primary" @click="isDiffSliderShow = true">对比并上线</bk-button>
<bk-button class="publish-btn" theme="primary" @click="handleDiffOrPublish">{{
versionList.length ? '对比并上线' : '上线版本'
}}</bk-button>
<bk-button @click="handlePanelClose">取消</bk-button>
</section>
</template>
Expand All @@ -54,6 +56,7 @@
:base-version-id="baseVersionId"
:show-publish-btn="true"
@publish="handleOpenPublishDialog"
:version-diff-list="versionList"
/>
</section>
</template>
Expand All @@ -71,6 +74,9 @@ import VersionLayout from '../config/components/version-layout.vue';
import ConfirmDialog from './publish-version/confirm-dialog.vue';
import SelectGroup from './publish-version/select-group/index.vue';
import VersionDiff from '../config/components/version-diff/index.vue';
import { useRoute } from 'vue-router';
import { getConfigVersionList } from '../../../../../api/config';
import { IConfigVersion } from '../../../../../../types/config';
const { permissionQuery, showApplyPermDialog } = storeToRefs(useGlobalStore());
const serviceStore = useServiceStore();
Expand All @@ -87,6 +93,10 @@ const props = defineProps<{
const emit = defineEmits(['confirm']);
const route = useRoute();
const bkBizId = String(route.params.spaceId);
const appId = Number(route.params.appId);
const versionList = ref<IConfigVersion[]>([]);
const isSelectGroupPanelOpen = ref(false);
const isDiffSliderShow = ref(false);
const isConfirmDialogShow = ref(false);
Expand All @@ -107,7 +117,27 @@ const permissionQueryResource = computed(() => [
},
]);
// 判断是否需要对比上线版本
const handleDiffOrPublish = () => {
if (versionList.value.length) {
isDiffSliderShow.value = true;
return;
}
handleOpenPublishDialog();
};
// 获取所有对比基准版本
const getVersionList = async () => {
try {
const res = await getConfigVersionList(bkBizId, appId, { start: 0, all: true });
versionList.value = res.data.details.filter((item: IConfigVersion) => item.id !== versionData.value.id && item.status.publish_status === 'partial_released');
} catch (e) {
console.error(e);
}
};
const handleBtnClick = () => {
getVersionList();
if (props.hasPerm) {
openSelectGroupPanel();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
/>
<template #footer>
<section class="actions-wrapper">
<bk-button class="publish-btn" theme="primary" @click="isDiffSliderShow = true">对比并上线</bk-button>
<bk-button class="publish-btn" theme="primary" @click="handleDiffOrPublish">{{
versionList.length ? '对比并上线' : '上线版本'
}}</bk-button>
<bk-button @click="handlePanelClose">取消</bk-button>
</section>
</template>
Expand All @@ -52,6 +54,7 @@
:base-version-id="baseVersionId"
:show-publish-btn="true"
@publish="handleOpenPublishDialog"
:version-diff-list="versionList"
/>
</section>
</template>
Expand All @@ -70,6 +73,9 @@ import VersionLayout from '../../config/components/version-layout.vue';
import ConfirmDialog from './confirm-dialog.vue';
import SelectGroup from './select-group/index.vue';
import VersionDiff from '../../config/components/version-diff/index.vue';
import { useRoute } from 'vue-router';
import { getConfigVersionList } from '../../../../../../api/config';
import { IConfigVersion } from '../../../../../../../types/config';
const { permissionQuery, showApplyPermDialog } = storeToRefs(useGlobalStore());
const serviceStore = useServiceStore();
Expand All @@ -86,6 +92,10 @@ const props = defineProps<{
const emit = defineEmits(['confirm']);
const route = useRoute();
const bkBizId = String(route.params.spaceId);
const appId = Number(route.params.appId);
const versionList = ref<IConfigVersion[]>([]);
const isSelectGroupPanelOpen = ref(false);
const isDiffSliderShow = ref(false);
const isConfirmDialogShow = ref(false);
Expand All @@ -104,7 +114,27 @@ const permissionQueryResource = computed(() => [
},
]);
// 判断是否需要对比上线版本
const handleDiffOrPublish = () => {
if (versionList.value.length) {
isDiffSliderShow.value = true;
return;
}
handleOpenPublishDialog();
};
// 获取所有对比基准版本
const getVersionList = async () => {
try {
const res = await getConfigVersionList(bkBizId, appId, { start: 0, all: true });
versionList.value = res.data.details.filter((item: IConfigVersion) => item.id !== versionData.value.id && item.status.publish_status === 'partial_released');
} catch (e) {
console.error(e);
}
};
const handleBtnClick = () => {
getVersionList();
if (props.hasPerm) {
isSelectGroupPanelOpen.value = true;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const props = defineProps<{
unNamedVersionVariables?: IVariableEditParams[];
baseVersionId?: number; // 默认选中的基准版本id
selectedConfig?: IConfigDiffSelected; // 默认选中的配置文件id
versionDiffList?: IConfigVersion[];
}>();
const emits = defineEmits(['update:show', 'publish']);
Expand Down Expand Up @@ -112,7 +113,7 @@ watch(
if (val) {
getVersionList();
}
}
},
);
watch(
Expand All @@ -122,13 +123,17 @@ watch(
selectedBaseVersion.value = val;
}
},
{ immediate: true }
{ immediate: true },
);
// 获取所有对比基准版本
const getVersionList = async () => {
try {
versionListLoading.value = true;
if (props.versionDiffList) {
versionList.value = props.versionDiffList;
return;
}
const res = await getConfigVersionList(bkBizId, appId, { start: 0, all: true });
versionList.value = res.data.details.filter((item: IConfigVersion) => item.id !== props.currentVersion.id);
} catch (e) {
Expand Down

0 comments on commit acba7d6

Please sign in to comment.