| | |
| | | <!-- 执行时间 (重复定时)--> |
| | | <div v-if="planBody.task_type === TaskType.Repeat"> |
| | | <div class="execute-time-arr-item"> |
| | | <a-form-item |
| | | v-for="(item, index) in planBody.executeTimeRepeatArr" |
| | | :key="item.index" |
| | | :label="index === 0 ? '执行时间' : ''" |
| | | :name="item.index+'repValue'" |
| | | :labelCol="{ span: 23 }" |
| | | :rules="[{ |
| | | <a-form-item |
| | | v-for="(item, index) in planBody.executeTimeRepeatArr" |
| | | :key="item.index" |
| | | :label="index === 0 ? '执行时间' : ''" |
| | | :name="item.index+'repValue'" |
| | | :labelCol="{ span: 23 }" |
| | | :rules="[{ |
| | | required: true, |
| | | trigger: ['change','blur'], |
| | | validator: validateRepeatExecuteTime |
| | | }]" |
| | | > |
| | | > |
| | | <a-time-picker v-model:value="item.value" @change="onRepeatChange(item)" format="HH:mm"/> |
| | | <a-button @click="addTime" type="default" shape="circle" :size="componentOptions.size"> |
| | | <template #icon> |
| | |
| | | <MinusCircleOutlined/> |
| | | </template> |
| | | </a-button> |
| | | </a-form-item> |
| | | </a-form-item> |
| | | </div> |
| | | </div> |
| | | |
| | |
| | | <div class="execute-time-arr-continuous-item"> |
| | | <div class="time-select"> |
| | | <div class="time-item"> |
| | | <a-time-picker style="width: 100px;" v-model:value="item.value[0]" @change="onContinuousChange(item)" format="HH:mm"/> |
| | | <a-time-picker style="width: 100px;" v-model:value="item.value[0]" @change="onContinuousChange(item)" |
| | | format="HH:mm"/> |
| | | </div> |
| | | <div style="color: white">-</div> |
| | | <div class="time-item"> |
| | | <a-time-picker style="width: 100px;" v-model:value="item.value[1]" @change="onContinuousChange(item)" format="HH:mm"/> |
| | | <a-time-picker style="width: 100px;" v-model:value="item.value[1]" @change="onContinuousChange(item)" |
| | | format="HH:mm"/> |
| | | </div> |
| | | </div> |
| | | <div class="btn-group"> |
| | |
| | | |
| | | <!-- 任务开始执行的电量--> |
| | | <a-form-item label="任务开始执行的电量" v-if=" planBody.task_type === TaskType.Continuous" |
| | | name="battery_capacity" :labelCol="{ span: 23 }"> |
| | | <a-input style="background: black;" v-model:value="planBody.battery_capacity"/> |
| | | name="min_battery_capacity" :labelCol="{ span: 23 }"> |
| | | <a-input style="background: black;" v-model:value="planBody.min_battery_capacity"/> |
| | | </a-form-item> |
| | | |
| | | <!-- 重复频率--> |
| | |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | import { computed, onMounted, onUnmounted, reactive, ref, toRaw, UnwrapRef } from 'vue' |
| | | import { computed, reactive, ref } from 'vue' |
| | | import { |
| | | CloseOutlined, |
| | | RocketOutlined, |
| | | CameraFilled, |
| | | UserOutlined, |
| | | CloseOutlined, |
| | | MinusCircleOutlined, |
| | | PlusCircleOutlined, |
| | | MinusCircleOutlined |
| | | RocketOutlined, |
| | | UserOutlined |
| | | } from '@ant-design/icons-vue' |
| | | import { ELocalStorageKey, ERouterName } from '/@/types' |
| | | import { useMyStore } from '/@/store' |
| | | import { WaylineType, WaylineFile } from '/@/types/wayline' |
| | | import { WaylineFile } from '/@/types/wayline' |
| | | import { Device, EDeviceType } from '/@/types/device' |
| | | import { createPlan, CreatePlan } from '/@/api/wayline' |
| | | import { createPlan, CreatePlan, createPlanCondition } from '/@/api/wayline' |
| | | import { getRoot } from '/@/root' |
| | | import { |
| | | TaskType, |
| | | OutOfControlActionOptions, |
| | | OutOfControlAction, |
| | | TaskTypeOptions, |
| | | FrequencyTypeOptions, |
| | | FrequencyType, |
| | | RepeatRuleTypeOptions, |
| | | FrequencyTypeOptions, |
| | | OutOfControlAction, |
| | | OutOfControlActionOptions, |
| | | RepeatRuleType, |
| | | WhichWeekOptions, |
| | | WhichDayOptions |
| | | RepeatRuleTypeOptions, |
| | | TaskType, |
| | | TaskTypeOptions, |
| | | WhichDayOptions, |
| | | WhichWeekOptions |
| | | } from '/@/types/task' |
| | | import moment, { Moment } from 'moment' |
| | | import { RuleObject } from 'ant-design-vue/es/form/interface' |
| | |
| | | }, |
| | | } |
| | | ], |
| | | battery_capacity: [ |
| | | min_battery_capacity: [ |
| | | { |
| | | validator: async (rule: RuleObject, value: string) => { |
| | | if (!/^[0-9]{1,}$/.test(value)) { |
| | | planBody.battery_capacity = '' |
| | | planBody.min_battery_capacity = '' |
| | | throw new Error('最小执行电量不能为空') |
| | | } else if (value < 50) { |
| | | planBody.battery_capacity = 50 |
| | | } else if (value > 100) { |
| | | planBody.battery_capacity = 100 |
| | | planBody.min_battery_capacity = 50 |
| | | } else if (value > 90) { |
| | | planBody.min_battery_capacity = 90 |
| | | } |
| | | }, |
| | | trigger: 'blur' |
| | |
| | | } |
| | | |
| | | function validateRepeatExecuteTime (rule: RuleObject, value: any) { |
| | | console.log('验证值', rule) |
| | | if (!value) { |
| | | return Promise.reject(new Error('请选择执行时间')) |
| | | } else { |
| | | return Promise.resolve() |
| | | } |
| | | } |
| | | |
| | | function onRepeatChange (item: any) { |
| | | planBody[`${item.index}repValue`] = item.value |
| | | console.log('表单:', planBody) |
| | | } |
| | | |
| | | function onContinuousChange (item: any) { |
| | | planBody[`${item.index}conValue`] = item.value |
| | | console.log('表单:', planBody) |
| | | } |
| | | |
| | | // 重复定时添加执行时间 |
| | |
| | | createPlanBody.task_periods = [] |
| | | // 执行时间 |
| | | planBody.executeTimeRepeatArr.forEach(item => { |
| | | console.log(item, '------') |
| | | |
| | | createPlanBody.task_periods.push([moment(item.value).unix()]) |
| | | }) |
| | | |
| | |
| | | } else if (planBody.rep_fre_type === FrequencyType.week) { |
| | | createPlanBody.rep_rule_val = repeatFrequencyValueWeek.value |
| | | } |
| | | console.log(createPlanBody, '*******************') |
| | | |
| | | break |
| | | case TaskType.Continuous: |
| | |
| | | createPlanBody.wayline_type = wayline.value.template_types[0] |
| | | } |
| | | |
| | | // getFlyTimeList(createPlanBody) |
| | | disabled.value = false |
| | | createPlan(workspaceId, createPlanBody) |
| | | .then(res => { |
| | | disabled.value = false |
| | | }).finally(() => { |
| | | closePlan() |
| | | }) |
| | | createPlanBody.execute_start_time_arr = getFlyTimeList(createPlanBody) |
| | | |
| | | console.log('createPlanBody', createPlanBody) |
| | | |
| | | if (planBody.task_type === TaskType.Immediate || planBody.task_type === TaskType.Timed) { |
| | | createPlan(workspaceId, createPlanBody) |
| | | .then(res => { |
| | | disabled.value = false |
| | | }).finally(() => { |
| | | closePlan() |
| | | }) |
| | | } else { |
| | | if (planBody.task_type === TaskType.Repeat) { |
| | | createPlanBody.task_type = 1 |
| | | } else if (planBody.task_type === TaskType.Continuous) { |
| | | createPlanBody.task_type = 2 |
| | | } |
| | | |
| | | createPlanCondition(workspaceId, createPlanBody) |
| | | .then(res => { |
| | | disabled.value = false |
| | | }).finally(() => { |
| | | closePlan() |
| | | }) |
| | | } |
| | | }).catch((e: any) => { |
| | | console.log('validate err', e) |
| | | }) |