Skip to content

Commit

Permalink
feat: 策略编辑 --story=120594134
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasikeai committed Jan 15, 2025
1 parent 4a6fa3b commit 0a24075
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 37 deletions.
24 changes: 24 additions & 0 deletions src/frontend/src/domain/model/strategy/strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
to the current version of the project delivered to anyone in the future.
*/

import DatabaseTableFieldModel from '@model/strategy/database-table-field';

import StrategyFieldEvent from '../strategy/strategy-field-event';

export default class Strategy {
Expand All @@ -34,6 +36,12 @@ export default class Strategy {
data_source?: {
source_type: string;
result_table_id?: string;
rt_id: string;
link_table: {
uid: string,
version: number,
},
system_ids: Array<string>,
filter_config: Array<{
connector: string;
key: string;
Expand All @@ -54,6 +62,22 @@ export default class Strategy {
}>
}
};
select: Array<DatabaseTableFieldModel>,
where: {
operator: 'and' | 'or' ;
conditions: Array<{
operator: 'and' | 'or';
conditions: Array<{
field: DatabaseTableFieldModel | '';
filter: string;
filters: string[];
}>
}>;
},
schedule_config: {
count_freq: string,
schedule_period: string,
},
[key: string]: any
};
status: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@

interface Expose {
resetFormData: () => void,
setConfigs: (config: Array<DatabaseTableFieldModel>) => void;
}
interface Emits {
(e: 'updateExpectedResult', value: Array<DatabaseTableFieldModel>): void;
Expand Down Expand Up @@ -112,6 +113,9 @@
resetFormData: () => {
expectedResultList.value = [];
},
setConfigs(configs: Array<DatabaseTableFieldModel>) {
expectedResultList.value = configs;
},
});
</script>
<style scoped lang="postcss">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@
<div
v-if="needCondition"
class="condition"
@click="handleChangeOperator">
{{ conditions.operator }}
@click="handleChangeConnector">
{{ conditions.connector }}
</div>
</template>
<script setup lang="ts">
Expand All @@ -143,12 +143,12 @@
interface Emits {
(e: 'updateFieldItemList', value: string, conditionsIndex: number): void;
(e: 'updateFieldItem', value: DatabaseTableFieldModel, conditionsIndex: number, childConditionsIndex: number): void;
(e: 'updateOperator', value: 'and' | 'or', conditionsIndex: number): void;
(e: 'updateConnector', value: 'and' | 'or', conditionsIndex: number): void;
}
interface Props {
tableFields: Array<DatabaseTableFieldModel>
conditions: {
operator: 'and' | 'or';
connector: 'and' | 'or';
conditions: Array<{
field: DatabaseTableFieldModel;
filter: string;
Expand Down Expand Up @@ -209,8 +209,8 @@
emits('updateFieldItem', value, props.conditionsIndex, index);
};

const handleChangeOperator = () => {
emits('updateOperator', props.conditions.operator === 'and' ? 'or' : 'and', props.conditionsIndex);
const handleChangeConnector = () => {
emits('updateConnector', props.conditions.connector === 'and' ? 'or' : 'and', props.conditionsIndex);
};
</script>
<style scoped lang="postcss">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
:conditions="conditions"
:conditions-index="index"
:table-fields="tableFields"
@update-connector="handleUpdateConnector"
@update-field-item="handleUpdateFieldItem"
@update-field-item-list="handleUpdateFieldItemList"
@update-operator="handleUpdateOperator" />
@update-field-item-list="handleUpdateFieldItemList" />
<audit-icon
v-if="index !== 0"
class="delete-conditions"
Expand All @@ -54,8 +54,8 @@
<div
v-if="needCondition"
class="condition"
@click="() => where.operator = where.operator === 'and' ? 'or' : 'and'">
{{ where.operator }}
@click="() => where.connector = where.connector === 'and' ? 'or' : 'and'">
{{ where.connector }}
</div>
</div>
<div
Expand All @@ -78,11 +78,12 @@

interface Expose {
resetFormData: () => void,
setConfigs: (config: Where) => void;
}
interface Where {
operator: 'and' | 'or';
connector: 'and' | 'or';
conditions: Array<{
operator: 'and' | 'or';
connector: 'and' | 'or';
conditions: Array<{
field: DatabaseTableFieldModel;
filter: string;
Expand All @@ -102,9 +103,9 @@
const { t } = useI18n();

const where = ref<Where>({
operator: 'and',
connector: 'and',
conditions: [{
operator: 'and',
connector: 'and',
conditions: [{
field: new DatabaseTableFieldModel(),
filter: '',
Expand All @@ -120,7 +121,7 @@

const handleAddRuleItem = () => {
where.value.conditions.push({
operator: 'and',
connector: 'and',
conditions: [{
field: new DatabaseTableFieldModel(),
filter: '',
Expand All @@ -146,8 +147,8 @@
where.value.conditions[conditionsIndex].conditions[childConditionsIndex].field = value;
};

const handleUpdateOperator = (value: 'and' | 'or', conditionsIndex: number) => {
where.value.conditions[conditionsIndex].operator = value;
const handleUpdateConnector = (value: 'and' | 'or', conditionsIndex: number) => {
where.value.conditions[conditionsIndex].connector = value;
};

watch(() => where.value, (data) => {
Expand All @@ -159,9 +160,9 @@
defineExpose<Expose>({
resetFormData: () => {
where.value = {
operator: 'and',
connector: 'and',
conditions: [{
operator: 'and',
connector: 'and',
conditions: [{
field: new DatabaseTableFieldModel(),
filter: '',
Expand All @@ -170,6 +171,9 @@
}],
};
},
setConfigs(configs: Where) {
where.value = configs;
},
});
</script>
<style scoped lang="postcss">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@

interface Expose {
resetFormData: () => void,
setConfigs: (config: IFormData['configs']) => void;
}

interface Emits {
Expand Down Expand Up @@ -154,11 +155,14 @@
immediate: true,
});


defineExpose<Expose>({
resetFormData: () => {
formData.value.configs.data_source.system_ids = [];
},
setConfigs(configs: IFormData['configs']) {
formData.value.configs.data_source.system_ids = configs.data_source.system_ids;
emits('updateDataSource', formData.value.configs.data_source);
},
});
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
interface Expose {
refreshLinkData: () => void,
resetFormData: () => void,
setConfigs: (config: IFormData['configs']) => void;
}
interface Emits {
(e: 'updateDataSource', value: IFormData['configs']['data_source']): void,
Expand Down Expand Up @@ -131,5 +132,11 @@
version: 0,
};
},
setConfigs(configs: IFormData['configs']) {
if (!configs.data_source.link_table) {
return;
}
formData.value.configs.data_source.link_table = configs.data_source.link_table;
},
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

interface Expose {
resetFormData: () => void,
setConfigs: (config: IFormData['configs']) => void;
}

interface Emits {
Expand Down Expand Up @@ -100,5 +101,9 @@
resetFormData: () => {
formData.value.configs.data_source.rt_id = '';
},
setConfigs(configs: IFormData['configs']) {
formData.value.configs.data_source.rt_id = configs.data_source.rt_id;
emits('updateDataSource', formData.value.configs.data_source);
},
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

interface Expose {
resetFormData: () => void,
setConfigs: (config: FormData) => void;
}
interface Props {
tableData: Array<{
Expand Down Expand Up @@ -124,6 +125,20 @@
resetFormData: () => {
formData.value.configs.data_source.rt_id = [];
},
setConfigs(config: Record<string, any>) {
// 对tableid转换
props.tableData.forEach((item) => {
if (item.children && item.children.length) {
item.children.forEach((cItem) => {
if (cItem.value === config.data_source.rt_id) {
formData.value.configs.data_source.rt_id = [item.value, config.data_source.rt_id];
}
});
}
});
formData.value.configs.data_source.rt_id = config.data_source.rt_id;
handleUpdateDataSource();
},
});
</script>

Expand Down
Loading

0 comments on commit 0a24075

Please sign in to comment.