Skip to content

Commit

Permalink
feat(frontend): 业务下增加单据免审批设置 TencentBlueKing#6346
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 17882
  • Loading branch information
JustaCattt authored and iSecloud committed Sep 10, 2024
1 parent 20af3b1 commit 5d622de
Show file tree
Hide file tree
Showing 27 changed files with 2,110 additions and 538 deletions.
7 changes: 7 additions & 0 deletions dbm-ui/frontend/src/components/auth-component/use-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ const withBizActionList = [
'admin_pwd_view',
'riak_cluster_apply',
'monitor_policy_clone',
'mongodb_apply',
'mongodb_account_create',
'mongodb_account_rules_view',
'sqlserver_apply',
'sqlserver_account_create',
'sqlserver_account_rules_view',
'biz_ticket_config_set',
];

export default function (props: Props) {
Expand Down
9 changes: 9 additions & 0 deletions dbm-ui/frontend/src/components/render-row/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<div
ref="rowRef"
class="render-row">
<slot name="prepend" />
<p
ref="textRef"
class="text-overflow">
Expand All @@ -30,6 +31,7 @@
class="render-row-tag">
{{ showAll ? t('共n个', [data.length]) : `+${overflowData.length}` }}
</BkTag>
<slot name="append" />
</div>
</template>

Expand All @@ -48,6 +50,13 @@
showAll: false,
});

defineSlots<
Partial<{
prepend(): any;
append(): any;
}>
>();

const { t } = useI18n();

const rowRef = ref<HTMLDivElement>();
Expand Down
44 changes: 23 additions & 21 deletions dbm-ui/frontend/src/hooks/useBeforeClose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
* the specific language governing permissions and limitations under the License.
*/
*/

import InfoBox from 'bkui-vue/lib/info-box';

Expand All @@ -18,24 +18,26 @@ import { t } from '@locales/index';
/**
* 侧栏通用关闭前提示
*/
export const useBeforeClose = () => function sideSilderbeforeClose(flag?: boolean) {
const closable = flag ?? window.changeConfirm;
if (closable) {
return new Promise((resolve) => {
InfoBox({
title: t('确认离开当前页'),
content: t('离开将会导致未保存信息丢失'),
confirmText: t('离开'),
onConfirm: () => {
const hasFlag = typeof flag === 'boolean';
if (hasFlag === false) {
window.changeConfirm = false;
}
resolve(true);
return true;
},
export const useBeforeClose = () =>
function sideSilderbeforeClose(flag?: boolean) {
const closable = flag ?? window.changeConfirm;
if (closable) {
return new Promise((resolve) => {
InfoBox({
title: t('确认离开当前页'),
content: t('离开将会导致未保存信息丢失'),
confirmText: t('离开'),
cancelText: t('取消'),
onConfirm: () => {
const hasFlag = typeof flag === 'boolean';
if (hasFlag === false) {
window.changeConfirm = false;
}
resolve(true);
return true;
},
});
});
});
}
return true;
};
}
return true;
};
8 changes: 7 additions & 1 deletion dbm-ui/frontend/src/layout/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@
'DBPasswordTemporaryModify',
],
[menuEnum.observableManage]: ['DBHASwitchEvents', 'inspectionManage'],
[menuEnum.configManage]: ['DbConfigure', 'DBMonitorStrategy', 'DBMonitorAlarmGroup', 'StaffManage'],
[menuEnum.configManage]: [
'DbConfigure',
'DBMonitorStrategy',
'DBMonitorAlarmGroup',
'StaffManage',
'TicketFlowSetting',
],
[menuEnum.resourceManage]: ['ResourceSpec', 'resourceManage', 'resourcePoolDirtyMachines'],
[menuEnum.platformManage]: [
'PlatformVersionFiles',
Expand Down
14 changes: 14 additions & 0 deletions dbm-ui/frontend/src/layout/components/ConfigManage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@
</span>
</BkMenuItem>
</BkMenuGroup>
<BkMenuGroup :name="t('单据配置')">
<BkMenuItem
key="TicketFlowSetting"
v-db-console="'bizConfigManage.ticketFlowSetting'">
<template #icon>
<DbIcon type="db-config" />
</template>
<span
v-overflow-tips.right
class="text-overflow">
{{ t('单据免审批设置') }}
</span>
</BkMenuItem>
</BkMenuGroup>
<BkMenuGroup :name="t('设置')">
<BkMenuItem
key="StaffManage"
Expand Down
31 changes: 28 additions & 3 deletions dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -2545,9 +2545,8 @@
"请选择单据": "请选择单据",
"可增加的流程节点": "可增加的流程节点",
"流程预览": "流程预览",
"确认删除“单据审批”流程节点?": "确认删除“单据审批”流程节点?",
"确认添加“单据审批”流程节点?": "确认添加“单据审批”流程节点?",
"已选择n个单据类型": "已选择:{n} 个单据类型",
"确认xx“单据审批”流程节点?": "确认{0}“单据审批”流程节点?",
"已选择n个单据类型": "已选择:{0} 个单据类型",
"禁用任务进行中,不可禁用": "禁用任务进行中,不可禁用",
"规则下存在实例_不可删除": "规则下存在实例,不可删除",
"确认删除该规则?": "确认删除该规则?",
Expand Down Expand Up @@ -3287,6 +3286,19 @@
"克隆DB名": "克隆 DB 名",
"按Enter或失焦可完成内容输入": "按 Enter 或失焦可完成内容输入",
"粘贴多个对象可用换行,空格或;,|分隔": "粘贴多个对象可用换行,空格或;,|分隔",
"是否审批": "是否审批",
"是否人工确认": "是否人工确认",
"是否经由DBA审批后才可执行": "是否经由DBA审批后才可执行",
"是否经由提单人确认后才可执行": "是否经由提单人确认后才可执行",
"添加单据审批节点": "添加单据审批节点",
"添加人工确认节点": "添加人工确认节点",
"全局设置的作为各个业务初始化设置,更改后会自动同步至各个业务;在业务下可以根据运行情况,可调整“是否审批”,其中“是否人工确认”在业务下不可更改": "全局设置的作为各个业务初始化设置,更改后会自动同步至各个业务;在业务下可以根据运行情况,可调整“是否审批”,其中“是否人工确认”在业务下不可更改",
"单据配置": "单据配置",
"自定义": "自定义",
"必须选择业务": "必须选择业务",
"至少选择一个集群": "至少选择一个集群",
"删除后,将不可恢复,请谨慎操作!": "删除后,将不可恢复,请谨慎操作!",
"修改目标": "修改目标",
"RedisCluster集群": "RedisCluster 集群",
"% 或 ? 不允许单独使用": "% 或 ? 不允许单独使用",
"不允许为 *": "不允许为 *",
Expand Down Expand Up @@ -3383,5 +3395,18 @@
"DB 名处理:": "DB 名处理:",
"备份记录(d):预期返回 n 个 DB 的备份记录,实际返回 m 个": "备份记录({0}):预期返回 {1} 个 DB 的备份记录,实际返回 {2} 个",
"高版本不能恢复到低版本": "高版本不能恢复到低版本",
"添加免审批": "添加免审批",
"所有集群已免审批": "所有集群已免审批",
"单据免审批设置": "单据免审批设置",
"内置策略为平台预设的审批规则,不可修改。根据业务需求,您可对全部或部分集群应用免审批策略。": "内置策略为平台预设的审批规则,不可修改。根据业务需求,您可对全部或部分集群应用免审批策略。",
"已存在自定义的免审批": "已存在自定义的免审批",
"内置策略不支持编辑": "内置策略不支持编辑",
"编辑免审批": "编辑免审批",
"添加免审批后,相关单据可直接进入下一环节,无需经过审批流程。免审批可应用于业务下的全部集群或特定部分集群。": "添加免审批后,相关单据可直接进入下一环节,无需经过审批流程。免审批可应用于业务下的全部集群或特定部分集群。",
"免审批目标": "免审批目标",
"需审批": "需审批",
"需确认": "需确认",
"免确认": "免确认",
"确定删除策略?": "确定删除策略?",
"这行勿动!新增翻译请在上一行添加!": ""
}
6 changes: 4 additions & 2 deletions dbm-ui/frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ import getSqlServerRouters from '@views/sqlserver-manage/routes';
import getStaffManageRoutes from '@views/staff-manage/routes';
import getTaskHistoryRoutes from '@views/task-history/routes';
import getTemporaryPasswordModify from '@views/temporary-paassword-modify/routes';
import getTicketFlowSettingRoutes from '@views/ticket-flow-setting/routes';
import getTicketFlowSettingBizRoutes from '@views/ticket-flow-setting-biz/routes';
import getTicketFlowSettingGlobalRoutes from '@views/ticket-flow-setting-global/routes';
import getTicketManageRoutes from '@views/ticket-manage/routes';
import getTicketsRoutes from '@views/tickets/routes';
import getVersionFilesRoutes from '@views/version-files/routes';
Expand Down Expand Up @@ -147,7 +148,8 @@ export default () => {
...getTicketManageRoutes(),
...getTemporaryPasswordModify(),
...getRiakManage(bigdataController),
...getTicketFlowSettingRoutes(),
...getTicketFlowSettingBizRoutes(),
...getTicketFlowSettingGlobalRoutes(),
...getMongoRoutes(mongdbController),
...getSqlServerRouters(funControllerData),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ interface ControllerData {
'bizConfigManage.alarmGroup': ControllerItem<string>;
'bizConfigManage.dbConfigure': ControllerItem<string>;
'bizConfigManage.StaffManage': ControllerItem<string>;
'bizConfigManage.ticketFlowSetting': ControllerItem<string>;
databaseManage: ControllerItem<string>;
'databaseManage.missionManage': ControllerItem<string>;
'databaseManage.whitelistManage': ControllerItem<string>;
Expand Down Expand Up @@ -217,6 +218,7 @@ export default class FunctionController {
'bizConfigManage.alarmGroup': ControllerItem<string>;
'bizConfigManage.dbConfigure': ControllerItem<string>;
'bizConfigManage.StaffManage': ControllerItem<string>;
'bizConfigManage.ticketFlowSetting': ControllerItem<string>;
databaseManage: ControllerItem<string>;
'databaseManage.missionManage': ControllerItem<string>;
'databaseManage.whitelistManage': ControllerItem<string>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { utcDisplayTime } from '@utils';

export default class TicketFlowDescribe {
bk_biz_id: number;
cluster_ids: number[];
clusters: {
cluster_id: number;
immute_domain: string;
}[];
configs: {
need_itsm: boolean;
need_manual_confirm: boolean;
Expand All @@ -9,20 +15,26 @@ export default class TicketFlowDescribe {
editable: boolean;
flow_desc: string[];
group: string;
id: number;
permission: {
ticket_config_set: boolean;
biz_ticket_config_set: boolean;
};
ticket_type: string;
ticket_type_display: string;
update_at: string;
updater: string;

constructor(payload = {} as TicketFlowDescribe) {
this.bk_biz_id = payload.bk_biz_id;
this.cluster_ids = payload.cluster_ids || [];
this.clusters = payload.clusters || [];
this.configs = payload.configs;
this.creator = payload.creator;
this.editable = payload.editable;
this.flow_desc = payload.flow_desc || [];
this.group = payload.group;
this.id = payload.id;
this.permission = payload.permission;
this.ticket_type = payload.ticket_type;
this.ticket_type_display = payload.ticket_type_display;
Expand All @@ -33,4 +45,29 @@ export default class TicketFlowDescribe {
get updateAtDisplay() {
return utcDisplayTime(this.update_at);
}

// 是否内置目标
get isDefaultTarget() {
return this.bk_biz_id === 0;
}

// 是否自定义目标
get isCustomTarget() {
return this.bk_biz_id !== 0;
}

// 是否集群目标
get isClusterTarget() {
return this.isCustomTarget && this.cluster_ids.length > 0;
}

// 是否为业务全部目标
get isCurrentBizTarget() {
return this.isCustomTarget && !this.isClusterTarget;
}

// 集群列表
get clusterDomainList() {
return this.clusters.map((cluster) => cluster.immute_domain);
}
}
2 changes: 2 additions & 0 deletions dbm-ui/frontend/src/services/source/dbbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ export function queryAllTypeCluster(params: {
cluster_types?: string;
immute_domain?: string;
phase?: string;
limit?: number;
offset?: number;
}) {
return http.get<
{
Expand Down
50 changes: 34 additions & 16 deletions dbm-ui/frontend/src/services/source/ticket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,27 +276,36 @@ export function queryTicketFlowDescribe(params: {
offset?: number;
bk_biz_id?: number;
}) {
// 组件 db-table 传值问题,临时解决 bk_biz_id 多余传值
// eslint-disable-next-line no-param-reassign
delete params.bk_biz_id;

return http.get<ListBase<TicketFlowDescribeModel[]>>(`${path}/query_ticket_flow_describe/`, params).then((data) => ({
...data,
results: data.results.map(
(item) =>
new TicketFlowDescribeModel(
Object.assign(item, {
permission: data.permission,
}),
),
),
return http.get<TicketFlowDescribeModel[]>(`${path}/query_ticket_flow_describe/`, params).then((data) => ({
count: data.length || 0,
results: data.map((item) => new TicketFlowDescribeModel(item)) || [],
}));
}

/**
* 修改可编辑的单据流程
* 创建单据流程规则
*/
export function updateTicketFlowConfig(params: { ticket_types: string[]; configs: Record<string, boolean> }) {
export function createTicketFlowConfig(params: {
ticket_types: string[];
configs: Record<string, boolean>;
bk_biz_id: number;
cluster_ids?: number[];
}) {
return http.post<{
ticket_types: string[];
}>(`${path}/create_ticket_flow_config/`, params);
}

/**
* 修改可编辑的单据流程规则
*/
export function updateTicketFlowConfig(params: {
ticket_types: string[];
configs: Record<string, boolean>;
bk_biz_id: number;
cluster_ids?: number[];
config_ids?: number[];
}) {
return http.post<{
ticket_types: string[];
}>(`${path}/update_ticket_flow_config/`, params);
Expand All @@ -306,6 +315,15 @@ export function getTicketStatus(params: { ticket_ids: string }) {
return http.get<Record<string, string>>(`${path}/list_ticket_status/`, params);
}

/**
* 删除单据流程规则
*/
export function deleteTicketFlowConfig(params: { config_ids: number[] }) {
return http.delete<{
ticket_types: string[];
}>(`${path}/delete_ticket_flow_config/`, params);
}

/**
* 查询服务器资源的城市信息
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<template>
<DbTab v-model="activeTab" />
<List :active-db-type="activeTab" />
<List :db-type="activeTab" />
</template>
<script setup lang="ts">
import { DBTypes } from '@common/const';
Expand All @@ -24,5 +24,5 @@

const route = useRoute();

const activeTab = ref<DBTypes>((route.query.db_type as DBTypes) || 'mysql');
const activeTab = ref<DBTypes>((route.query.db_type as DBTypes) || DBTypes.MYSQL);
</script>
Loading

0 comments on commit 5d622de

Please sign in to comment.