|
...
|
...
|
@@ -4,30 +4,54 @@ |
|
4
|
4
|
import { BasicForm, useForm } from '/@/components/Form';
|
|
5
|
5
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
|
6
|
6
|
import { TaskTargetEnum, TaskTypeNameEnum } from '../../config';
|
|
7
|
|
- import { FormValue, TargetType, formSchemas } from './config';
|
|
|
7
|
+ import { FormFieldsEnum, FormValue, TargetNameType, TargetType, formSchemas } from './config';
|
|
8
|
8
|
import { unref } from 'vue';
|
|
9
|
9
|
import { immediateExecute } from '/@/api/task';
|
|
10
|
10
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
11
|
11
|
const props = defineProps<{
|
|
12
|
12
|
reload: Fn;
|
|
|
13
|
+ fromOrigin?: boolean;
|
|
|
14
|
+ tbDeviceId?: string;
|
|
13
|
15
|
}>();
|
|
14
|
16
|
|
|
15
|
17
|
defineEmits(['register']);
|
|
16
|
18
|
|
|
17
|
19
|
const dataSource = ref<TaskRecordType>();
|
|
18
|
20
|
|
|
|
21
|
+ const updateExecuteTargetType = (options: Recordable[]) => {
|
|
|
22
|
+ updateSchema({
|
|
|
23
|
+ field: FormFieldsEnum.EXECUTE_TARGET_TYPE,
|
|
|
24
|
+ componentProps: {
|
|
|
25
|
+ options,
|
|
|
26
|
+ },
|
|
|
27
|
+ });
|
|
|
28
|
+ };
|
|
|
29
|
+
|
|
19
|
30
|
const [registerModal, { closeModal }] = useModalInner((record: TaskRecordType) => {
|
|
20
|
31
|
resetFields();
|
|
21
|
32
|
dataSource.value = record;
|
|
22
|
33
|
if (record) {
|
|
23
|
34
|
setFieldsValue({ taskRecord: JSON.stringify(record) } as FormValue);
|
|
|
35
|
+ // 如果是从设备详情里面的任务进来的
|
|
|
36
|
+ if (props.fromOrigin) {
|
|
|
37
|
+ setFieldsValue({ tbDeviceId: props.tbDeviceId } as FormValue);
|
|
|
38
|
+ setFieldsValue({ [FormFieldsEnum.EXECUTE_TARGET_TYPE]: TargetType.ASSIGN } as FormValue);
|
|
|
39
|
+ setFieldsValue({ [FormFieldsEnum.TARGET_IDS]: [props.tbDeviceId] } as FormValue);
|
|
|
40
|
+ updateExecuteTargetType([{ label: TargetNameType.ASSIGN, value: TargetType.ASSIGN }]);
|
|
|
41
|
+ } else {
|
|
|
42
|
+ updateExecuteTargetType([
|
|
|
43
|
+ { label: TargetNameType.ALL, value: TargetType.ALL },
|
|
|
44
|
+ { label: TargetNameType.ASSIGN, value: TargetType.ASSIGN },
|
|
|
45
|
+ ]);
|
|
|
46
|
+ }
|
|
24
|
47
|
}
|
|
25
|
48
|
});
|
|
26
|
49
|
|
|
27
|
|
- const [registerForm, { setFieldsValue, getFieldsValue, resetFields, validate }] = useForm({
|
|
28
|
|
- schemas: formSchemas,
|
|
29
|
|
- showActionButtonGroup: false,
|
|
30
|
|
- });
|
|
|
50
|
+ const [registerForm, { setFieldsValue, getFieldsValue, resetFields, validate, updateSchema }] =
|
|
|
51
|
+ useForm({
|
|
|
52
|
+ schemas: formSchemas,
|
|
|
53
|
+ showActionButtonGroup: false,
|
|
|
54
|
+ });
|
|
31
|
55
|
|
|
32
|
56
|
const composeData = (record: FormValue): ImmediateExecuteTaskType => {
|
|
33
|
57
|
const { executeTarget, targetIds } = record;
|
...
|
...
|
|