feat(sj_map_reduce): 任务表单新增reduce 分片数字段

This commit is contained in:
xlsea 2024-06-25 14:15:09 +08:00
parent 629204f270
commit e07b2039c9
6 changed files with 34 additions and 21 deletions

View File

@ -14,18 +14,12 @@ interface Props {
const props = defineProps<Props>(); const props = defineProps<Props>();
interface Emits { const modelValue = defineModel<Api.Common.RouteKey>('value', {
(e: 'update:value', value: Api.Common.RouteKey): void; default: 4
} });
const emit = defineEmits<Emits>();
const modelValue = defineModel<Api.Common.RouteKey>('value');
/** select 下拉选项 */ /** select 下拉选项 */
const selectOptions = computed(() => { const selectOptions = computed(() => {
//
emit('update:value', 4);
// 2:广, 3: ==> `` // 2:广, 3: ==> ``
if (props.taskType === 2 || props.taskType === 3) { if (props.taskType === 2 || props.taskType === 3) {
return translateOptions(routeKeyRecordOptions.filter(o => o.value === 4)); return translateOptions(routeKeyRecordOptions.filter(o => o.value === 4));

View File

@ -751,6 +751,7 @@ const local: App.I18n.Schema = {
groupName: 'Group name', groupName: 'Group name',
jobName: 'Mission name', jobName: 'Mission name',
argsStr: 'Method parameters', argsStr: 'Method parameters',
shardNum: 'Reduce shard num',
argsType: 'Parameter Type', argsType: 'Parameter Type',
nextTriggerAt: 'Next trigger time', nextTriggerAt: 'Next trigger time',
jobStatus: 'State', jobStatus: 'State',
@ -786,6 +787,7 @@ const local: App.I18n.Schema = {
blockStrategy: 'Please enter Blocking strategy', blockStrategy: 'Please enter Blocking strategy',
argsType: 'Please enter Parameter Type', argsType: 'Please enter Parameter Type',
argsStr: 'Please enter executor arguments', argsStr: 'Please enter executor arguments',
shardNum: 'Please enter reduce shard num',
groupName: 'Please enter Group name', groupName: 'Please enter Group name',
retryInterval: 'Please enter retry interval' retryInterval: 'Please enter retry interval'
}, },

View File

@ -759,6 +759,7 @@ const local: App.I18n.Schema = {
groupName: '组名称', groupName: '组名称',
jobName: '任务名称', jobName: '任务名称',
argsStr: '方法参数', argsStr: '方法参数',
shardNum: 'reduce 分片数',
argsType: '参数类型', argsType: '参数类型',
nextTriggerAt: '触发时间', nextTriggerAt: '触发时间',
jobStatus: '状态', jobStatus: '状态',
@ -794,6 +795,7 @@ const local: App.I18n.Schema = {
blockStrategy: '请输入阻塞策略', blockStrategy: '请输入阻塞策略',
argsType: '请输入参数类型', argsType: '请输入参数类型',
argsStr: '请输入方法参数', argsStr: '请输入方法参数',
shardNum: '请输入 reduce 分片数',
groupName: '请输入组名称', groupName: '请输入组名称',
retryInterval: '请输入重试间隔' retryInterval: '请输入重试间隔'
}, },

View File

@ -932,6 +932,7 @@ declare namespace App {
groupName: string; groupName: string;
jobName: string; jobName: string;
argsStr: string; argsStr: string;
shardNum: string;
argsType: string; argsType: string;
nextTriggerAt: string; nextTriggerAt: string;
jobStatus: string; jobStatus: string;
@ -967,6 +968,7 @@ declare namespace App {
blockStrategy: string; blockStrategy: string;
argsType: string; argsType: string;
argsStr: string; argsStr: string;
shardNum: string;
groupName: string; groupName: string;
retryInterval: string; retryInterval: string;
}; };

View File

@ -6,13 +6,11 @@ import { localStg } from '@/utils/storage';
const store = useLogStore(); const store = useLogStore();
const data = ref(); const data = ref(localStg.get('log'));
const { routerPushByKey } = useRouterPush(); const { routerPushByKey } = useRouterPush();
function init() { function init() {
const logData = localStg.get('log'); if (!data.value) {
if (!logData?.data) {
data.value = logData;
routerPushByKey('404'); routerPushByKey('404');
} }
} }

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, reactive, watch } from 'vue'; import { computed, reactive, ref, watch } from 'vue';
import { useFormRules, useNaiveForm } from '@/hooks/common/form'; import { useFormRules, useNaiveForm } from '@/hooks/common/form';
import OperateDrawer from '@/components/common/operate-drawer.vue'; import OperateDrawer from '@/components/common/operate-drawer.vue';
import { $t } from '@/locales'; import { $t } from '@/locales';
@ -37,6 +37,7 @@ const visible = defineModel<boolean>('visible', {
const dynamicForm = reactive({ const dynamicForm = reactive({
args: [{ arg: '' }] args: [{ arg: '' }]
}); });
const shardNum = ref(0);
const { formRef, validate, restoreValidation } = useNaiveForm(); const { formRef, validate, restoreValidation } = useNaiveForm();
const { defaultRequiredRule } = useFormRules(); const { defaultRequiredRule } = useFormRules();
@ -80,7 +81,7 @@ function createDefaultModel(): Model {
argsStr: '', argsStr: '',
argsType: 1, argsType: 1,
jobStatus: 1, jobStatus: 1,
routeKey: 1, routeKey: 4,
executorType: 1, executorType: 1,
triggerType: 2, triggerType: 2,
executorInfo: '', executorInfo: '',
@ -147,6 +148,12 @@ function handleUpdateModelWhenEdit() {
}) })
}); });
} }
if (model.taskType === 5 && model.argsStr) {
const argsJson = JSON.parse(model.argsStr);
shardNum.value = argsJson.shardNum;
model.argsStr = argsJson.argsStr;
}
} }
} }
@ -180,7 +187,7 @@ async function handleSubmit() {
const { error } = await fetchAddJob({ const { error } = await fetchAddJob({
groupName, groupName,
jobName, jobName,
argsStr, argsStr: taskType === 5 ? JSON.stringify({ shardNum: shardNum.value, argsStr }) : argsStr,
argsType, argsType,
jobStatus, jobStatus,
routeKey, routeKey,
@ -225,7 +232,7 @@ async function handleSubmit() {
id, id,
groupName, groupName,
jobName, jobName,
argsStr, argsStr: taskType === 5 ? JSON.stringify({ shardNum: shardNum.value, argsStr }) : argsStr,
argsType, argsType,
jobStatus, jobStatus,
routeKey, routeKey,
@ -283,11 +290,16 @@ watch(dynamicForm, () => {
watch( watch(
() => model.taskType, () => model.taskType,
taskType => { taskType => {
if (visible.value) { if (props.operateType === 'add') {
if (taskType !== 3) { if (visible.value) {
dynamicForm.args = []; if (taskType !== 3) {
dynamicForm.args = [];
}
if (taskType !== 5) {
shardNum.value = 0;
}
model.argsStr = '';
} }
model.argsStr = '';
} }
} }
); );
@ -328,6 +340,9 @@ watch(
<NFormItem :label="$t('page.jobTask.taskType')" path="taskType"> <NFormItem :label="$t('page.jobTask.taskType')" path="taskType">
<TaskType v-model:value="model.taskType" :placeholder="$t('page.jobTask.form.taskType')" /> <TaskType v-model:value="model.taskType" :placeholder="$t('page.jobTask.form.taskType')" />
</NFormItem> </NFormItem>
<NFormItem v-if="model.taskType === 5" :label="$t('page.jobTask.shardNum')">
<NInputNumber v-model:value="shardNum" :min="0" :placeholder="$t('page.jobTask.form.shardNum')" />
</NFormItem>
<NFormItem <NFormItem
:label="$t('page.jobTask.argsStr')" :label="$t('page.jobTask.argsStr')"
path="argsStr" path="argsStr"