Skip to content

Commit 4d906dd

Browse files
committed
feat(frontend): sqlserver添加统一设置和单据备注 #9684
1 parent 158f65f commit 4d906dd

File tree

34 files changed

+4828
-82
lines changed

34 files changed

+4828
-82
lines changed

dbm-ui/frontend/src/components/editable-table/Column.vue

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@
111111
width?: number;
112112
}
113113
114+
export type Emits = (e: 'validate', result: boolean, message: string) => boolean;
115+
114116
interface Slots {
115117
default: () => VNode;
116118
error?: (params: { message: string }) => VNode;
@@ -162,6 +164,7 @@
162164
rules: undefined,
163165
width: undefined,
164166
});
167+
const emits = defineEmits<Emits>();
165168
const slots = defineSlots<Slots>();
166169
167170
const tableContext = inject(tableInjectKey);
@@ -173,7 +176,7 @@
173176
interface IFinalRule {
174177
message: string | (() => string);
175178
trigger: string;
176-
validator: (value: any, rowData?: Record<string, any>) => Promise<boolean | string> | boolean | string;
179+
validator: (value: any, rowDataValue?: Record<string, any>) => Promise<boolean | string> | boolean | string;
177180
}
178181
179182
let loadingValidatorTimer: ReturnType<typeof setTimeout>;
@@ -423,10 +426,19 @@
423426
424427
const doValidate = (() => {
425428
let stepIndex = -1;
426-
return (finalRuleList: IFinalRule[], value: any, rowDataValue: Record<string, any>): Promise<boolean> => {
429+
return (
430+
finalRuleList: IFinalRule[],
431+
value: any,
432+
rowDataValue: {
433+
columnIndex: number;
434+
rowData: Record<string, any>;
435+
rowIndex: number;
436+
},
437+
): Promise<boolean> => {
427438
stepIndex = stepIndex + 1;
428439
// 验证通过
429440
if (stepIndex >= finalRuleList.length) {
441+
emits('validate', true, '');
430442
tableContext.emits('validate', props.field || '', true, '');
431443
return Promise.resolve(true);
432444
}
@@ -454,6 +466,7 @@
454466
(errorMessage: string) => {
455467
validateState.isError = true;
456468
validateState.errorMessage = errorMessage;
469+
emits('validate', false, errorMessage);
457470
tableContext.emits('validate', props.field || '', false, errorMessage);
458471
return Promise.reject(validateState.errorMessage);
459472
},
@@ -504,8 +517,14 @@
504517
validateState.errorMessage = '';
505518
}
506519
507-
const rowDataValue = tableContext.props.model[rowContext!.getRowIndex()];
508-
const value = _.get(rowDataValue, props.field || '_');
520+
const rowIndex = rowContext!.getRowIndex();
521+
const columnIndex = tableContext!.getColumnRelateRowIndexByInstance(currentInstance);
522+
const rowDataValue = {
523+
columnIndex,
524+
rowData: tableContext.props.model[rowIndex],
525+
rowIndex,
526+
};
527+
const value = _.get(rowDataValue.rowData, props.field || '_');
509528
510529
doValidate(finalRuleList, value, rowDataValue).then(
511530
() => {

dbm-ui/frontend/src/components/editable-table/Index.vue

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
<slot />
1515
</tbody>
1616
</table>
17+
<div
18+
v-if="slots.empty"
19+
class="bk-editable-table-empty">
20+
<slot name="empty" />
21+
</div>
1722
</div>
1823
<div class="bk-editable-table-fixed-wrapper">
1924
<div
@@ -87,6 +92,7 @@
8792
8893
export interface Slots {
8994
default: () => VNode;
95+
empty?(): VNode;
9096
}
9197
9298
export interface Expose {
@@ -114,15 +120,15 @@
114120
export { Block, Column, DatePicker, Input, Row, Select, TagInput, Textarea, TimePicker, useColumn, useTable };
115121
</script>
116122
<script setup lang="ts">
123+
defineOptions({
124+
name: 'EditableTable',
125+
});
126+
117127
const props = defineProps<Props>();
118128
119129
const emits = defineEmits<Emits>();
120130
121-
defineSlots<Slots>();
122-
123-
defineOptions({
124-
name: 'EditableTable',
125-
});
131+
const slots = defineSlots<Slots>();
126132
127133
const tableRef = ref<HTMLElement>();
128134
const scrollXRef = ref<HTMLElement>();
@@ -280,6 +286,12 @@
280286
width: 0;
281287
height: 0;
282288
}
289+
290+
.bk-editable-table-empty {
291+
display: flex;
292+
justify-content: center;
293+
align-items: center;
294+
}
283295
}
284296
285297
table {

dbm-ui/frontend/src/components/editable-table/edit/TagInput.vue

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
clearable
1010
has-delete-icon
1111
@blur="handleBlur"
12+
@change="handleChange"
1213
@focus="handleFocus" />
1314
</template>
1415
<script setup lang="ts" generic="T extends string[] | number[] | string | number">
16+
import _ from 'lodash';
1517
import { watch } from 'vue';
1618
1719
import useColumn from '../useColumn';
@@ -30,14 +32,17 @@
3032
const props = defineProps<Props>();
3133
const emits = defineEmits<Emits<T>>();
3234
35+
const modelValue = defineModel<T>();
36+
3337
const attrs = useAttrs();
3438
3539
const columnContext = useColumn();
3640
37-
const modelValue = defineModel<T>();
38-
39-
watch(modelValue, () => {
40-
columnContext?.validate('change');
41+
watch(modelValue, (newValue, oldValue) => {
42+
// 对于引用类型,实际值变化才校验
43+
if (!_.isEqual(newValue, oldValue)) {
44+
columnContext?.validate('change');
45+
}
4146
});
4247
4348
const handleBlur = () => {
@@ -50,6 +55,10 @@
5055
columnContext?.focus();
5156
emits('focus');
5257
};
58+
59+
const handleChange = () => {
60+
emits('change', modelValue.value as T);
61+
};
5362
</script>
5463
<style lang="less">
5564
.bk-editable-tag-input {

dbm-ui/frontend/src/components/editable-table/types.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,12 @@ export interface IRule {
77
pattern?: RegExp;
88
required?: boolean;
99
trigger: string;
10-
validator?: (value: any, rowData?: Record<string, any>) => Promise<boolean | string> | boolean | string;
10+
validator?: (
11+
value: any,
12+
rowDataValue: {
13+
columnIndex: number;
14+
rowData: Record<string, any>;
15+
rowIndex: number;
16+
},
17+
) => Promise<boolean | string> | boolean | string;
1118
}

dbm-ui/frontend/src/locales/zh-cn.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4069,6 +4069,7 @@
40694069
"近1小时": "近1小时",
40704070
"近1天": "近1天",
40714071
"近1个月": "近1个月",
4072+
"数据库备份任务提交成功": "数据库备份任务提交成功",
40724073
"跳转监控": "跳转监控",
40734074
"批量设置告警组": "批量设置告警组",
40744075
"已选n个策略": "已选 {n} 个策略",
@@ -4342,5 +4343,15 @@
43424343
"每个 Shard 节点数不能为空": "每个 Shard 节点数不能为空",
43434344
"集群 Shared 数不能为空": "集群 Shared 数不能为空",
43444345
"机器组数不能为空": "机器组数不能为空",
4346+
"预览 DB 结果列表": "预览 DB 结果列表",
4347+
"新建一个单节点实例,通过全备 +binlog 的方式,将数据库恢复到过去的某一时间点或者某个指定备份文件的状态。": "新建一个单节点实例,通过全备 +binlog 的方式,将数据库恢复到过去的某一时间点或者某个指定备份文件的状态。",
4348+
"已更新": "已更新",
4349+
"目标集群n输入格式有误": "目标集群 {n} 输入格式有误",
4350+
"目标集群n不存在": "目标集群 {n} 不存在",
4351+
"起止时间:": "起止时间:",
4352+
"完整": "完整",
4353+
"DB 列表": "DB 列表",
4354+
"请先设置集群、构造 DB、回档信息": "请先设置集群、构造 DB、回档信息",
4355+
"请先设置集群、目标集群、构造 DB、回档信息": "请先设置集群、目标集群、构造 DB、回档信息",
43454356
"这行勿动!新增翻译请在上一行添加!": ""
43464357
}

dbm-ui/frontend/src/views/db-manage/common/batch-edit-column/Index.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
allow-create
5353
:disabled="disabled"
5454
has-delete-icon
55+
:max-data="single ? 1 : -1"
5556
:model-value="localValue"
5657
:paste-fn="tagInputPasteFn"
5758
@change="handleChange" />
@@ -61,6 +62,7 @@
6162
:disabled="disabled"
6263
:disabled-date="disableFn"
6364
:model-value="localValue"
65+
style="width: 100%"
6466
type="datetime"
6567
@change="handleChange">
6668
</BkDatePicker>
@@ -84,6 +86,7 @@
8486
}[];
8587
disableFn?: (date?: Date | number) => boolean;
8688
placeholder?: string;
89+
single?: boolean;
8790
title: string;
8891
titlePrefixType?: 'edit' | 'entry';
8992
type?: 'select' | 'textarea' | 'input' | 'taginput' | 'datetime' | 'number-input';
@@ -95,6 +98,7 @@
9598
dataList: () => [],
9699
disableFn: () => false,
97100
placeholder: '',
101+
single: false,
98102
titlePrefixType: 'edit',
99103
type: 'select',
100104
});

0 commit comments

Comments
 (0)