Skip to content

Commit

Permalink
feat(frontend): 单据管理迭代_5 TencentBlueKing#7190
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 25085
  • Loading branch information
hLinx committed Nov 27, 2024
1 parent 83ab77b commit ba98fb3
Show file tree
Hide file tree
Showing 26 changed files with 208 additions and 152 deletions.
18 changes: 9 additions & 9 deletions dbm-ui/frontend/src/hooks/useTicketCount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ import { getTicketCount } from '@services/source/ticketFlow';
import { useEventBus } from '@hooks';

const run = () => {
const isLoading = ref(true);
const data = ref<ServiceReturnType<typeof getTicketCount>>({
MY_APPROVE: 0,
APPROVE: 0,
TODO: 0,
RUNNING: 0,
RESOURCE_REPLENISH: 0,
FAILED: 0,
DONE: 0,
FAILED: 0,
INNER_TODO: 0,
MY_APPROVE: 0,
RESOURCE_REPLENISH: 0,
SELF_MANAGE: 0,
TODO: 0,
});

const { loading, run } = useRequest(getTicketCount, {
cacheKey: 'ticketCount',
cacheTime: 10000,
const { run } = useRequest(getTicketCount, {
onSuccess(result) {
data.value = result;
isLoading.value = false;
},
});

Expand All @@ -34,7 +34,7 @@ const run = () => {
});

return {
loading,
loading: isLoading,
data,
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
ticketCount.value.APPROVE +
ticketCount.value.FAILED +
ticketCount.value.RESOURCE_REPLENISH +
ticketCount.value.RUNNING +
ticketCount.value.INNER_TODO +
ticketCount.value.TODO
);
});
Expand Down
5 changes: 5 additions & 0 deletions dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -3746,5 +3746,10 @@
"强制实例下架:": "强制实例下架:",
"Excel文件:": "Excel文件:",
"单据t不在n单据中": "单据 {t} 不在“{n}”单据中",
"单据重试确认": "单据重试确认",
"重试后,单据将再次尝试继续执行": "重试后,单据将再次尝试继续执行",
"批量处理": "批量处理",
"新窗口打开": "新窗口打开",
"重试后,单据将再次尝试申请资源": "重试后,单据将再次尝试申请资源",
"这行勿动!新增翻译请在上一行添加!": ""
}
10 changes: 5 additions & 5 deletions dbm-ui/frontend/src/services/source/ticketFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ export function processTodo(params: { id: number; todo_id: number; action: strin
// 获取单据数量
export function getTicketCount() {
return http.get<{
MY_APPROVE: number;
APPROVE: number;
TODO: number;
RUNNING: number;
RESOURCE_REPLENISH: number;
FAILED: number;
DONE: number;
FAILED: number;
INNER_TODO: number;
MY_APPROVE: number;
RESOURCE_REPLENISH: number;
SELF_MANAGE: number;
TODO: number;
}>(`${path}/get_tickets_count/`);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
:label="t('操作')"
width="160">
<template #default="{ data }: { data: IRowData }">
<TicketDetailLink
<TicketClone
v-if="data"
:data="data" />
<TicketClone
<TicketDetailLink
v-if="data"
class="ml-8"
:data="data" />
Expand Down
13 changes: 8 additions & 5 deletions dbm-ui/frontend/src/views/ticket-center/common/CardModeList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
import TicketModel from '@services/model/ticket/ticket';
import { getTickets } from '@services/source/ticket';
import { useStretchLayout, useUrlSearch } from '@hooks';
import { useEventBus, useStretchLayout, useUrlSearch } from '@hooks';
import EmptyStatus from '@components/empty-status/EmptyStatus.vue';
import RenderRow from '@components/render-row/index.vue';
Expand All @@ -96,6 +96,7 @@
const router = useRouter();
const { t } = useI18n();
const { getSearchParams } = useUrlSearch();
const eventBus = useEventBus();
const { splitScreen: stretchLayoutSplitScreen } = useStretchLayout();
const { formatValue: formatDateValue } = useDatePicker();
Expand Down Expand Up @@ -186,12 +187,14 @@
});
};
onDeactivated(() => {
pauseFetchData();
});
onActivated(() => {
currentTicketScrollToTop();
eventBus.on('refreshTicketStatus', fetchData);
});
onDeactivated(() => {
pauseFetchData();
eventBus.off('refreshTicketStatus', fetchData);
});
onMounted(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
import { getTickets } from '@services/source/ticket';
import {getInnerFlowInfo} from '@services/source/ticketFlow'
import { useStretchLayout } from '@hooks';
import { useEventBus, useStretchLayout } from '@hooks';
import EmptyStatus from '@components/empty-status/EmptyStatus.vue';
import TicketStatusTag from '@components/ticket-status-tag/Index.vue';
Expand Down Expand Up @@ -218,6 +218,7 @@
}>()
const { t } = useI18n();
const eventBus = useEventBus();
const { isSplited: isStretchLayoutOpen } = useStretchLayout();
let isInited = false;
Expand Down Expand Up @@ -301,8 +302,6 @@
pagination.current = 1;
}
console.log('from watch fetchdata = ', window.location.href)
fetchData();
});
Expand Down Expand Up @@ -390,17 +389,21 @@
}
const fetchRefresh = () => {
rowSelectMemo.value = {}
triggerSelection();
fetchData();
}
onActivated(() => {
resumeFetchData();
resumeFetchInnerFlowInfo();
eventBus.on('refreshTicketStatus', fetchRefresh);
})
onDeactivated(() => {
pauseFetchData();
pauseFetchInnerFlowInfo();
eventBus.off('refreshTicketStatus', fetchRefresh);
})
onMounted(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

import { ClusterTypes, TicketTypes } from '@common/const';

import { getBusinessHref } from '@utils';

interface Props {
data: TicketModel<unknown>;
}
Expand Down Expand Up @@ -178,7 +180,7 @@
ticketType: props.data.ticket_type,
},
});
window.open(href, '_blank');
window.open(getBusinessHref(href, props.data.bk_biz_id), '_blank');
}
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ticketId: data.id,
},
}">
{{ t('查看详情') }}
{{ t('新窗口打开') }}
</RouterLink>
</template>
<script setup lang="ts">
Expand Down
44 changes: 44 additions & 0 deletions dbm-ui/frontend/src/views/ticket-center/common/TicketRevoke.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<DbPopconfirm
v-if="isCan"
:confirm-handler="handleRevoke"
:content="t('撤销后,单据将作废处理')"
:title="t('确定撤销单据')">
<BkButton theme="danger">
{{ t('撤销单据') }}
</BkButton>
</DbPopconfirm>
</template>
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import TicketModel from '@services/model/ticket/ticket';
import { revokeTicket } from '@services/source/ticketFlow';
import { useEventBus } from '@hooks';
import { useUserProfile } from '@stores';
interface Props {
data: TicketModel<unknown>;
}
const props = defineProps<Props>();
const { username } = useUserProfile();
const { t } = useI18n();
const eventBus = useEventBus();
const isCan = computed(
() => props.data.status === TicketModel.STATUS_APPROVE && props.data.todo_operators.includes(username),
);
const handleRevoke = () =>
revokeTicket({
ticket_ids: [props.data.id],
}).then(() => {
eventBus.emit('refreshTicketStatus');
});
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<template>
<DbPopconfirm
:confirm-handler="handleApproval"
placement="bottom"
:title="t('单据重试确认')"
trigger="click"
:width="350">
<slot />
<template #content>
<div>
{{ t('操作:') }}
<BkTag
class="mr-4"
theme="success"
type="stroke">
{{ t('确认执行') }}
</BkTag>
<span>{{ t('重试后,单据将再次尝试申请资源') }}</span>
</div>
</template>
</DbPopconfirm>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import FlowMode from '@services/model/ticket/flow';
import TicketModel from '@services/model/ticket/ticket';
import { batchProcessTicket, batchProcessTodo } from '@services/source/ticketFlow';
import { useEventBus } from '@hooks';
import { messageSuccess } from '@utils';
interface Props {
data?: TicketModel;
todoData?: FlowMode['todos'][number];
}
const props = defineProps<Props>();
const { t } = useI18n();
const eventBus = useEventBus();
const isSubmitting = ref(false);
const handleApproval = () => {
isSubmitting.value = true;
return Promise.resolve()
.then(() => {
if (props.data) {
return batchProcessTicket({
action: 'APPROVE',
ticket_ids: [props.data.id],
});
}
if (props.todoData) {
return batchProcessTodo({
action: 'APPROVE',
operations: [
{
todo_id: props.todoData.id,
},
],
});
}
return Promise.reject();
})
.then(() => {
messageSuccess(t('操作成功'));
eventBus.emit('refreshTicketStatus');
})
.finally(() => {
isSubmitting.value = false;
});
};
</script>
Loading

0 comments on commit ba98fb3

Please sign in to comment.