| | |
| | | <a-form-item label="执行日期" |
| | | v-if="planBody.task_type === TaskType.Repeat || planBody.task_type === TaskType.Continuous" |
| | | name="time_range" :labelCol="{ span: 23 }"> |
| | | <a-range-picker v-model:value="planBody.time_range" format="YYYY-MM-DD" placeholder="请选择日期"/> |
| | | <a-range-picker v-model:value="planBody.time_range" format="YYYY-MM-DD" |
| | | :placeholder="['开始时间','结束时间']"/> |
| | | </a-form-item> |
| | | |
| | | <!-- 执行时间 (重复定时)--> |
| | | <a-form-item label="执行时间" v-if="planBody.task_type === TaskType.Repeat" name="execute_time_arr" |
| | | :labelCol="{ span: 23 }"> |
| | | <div class="execute-time-arr-item" v-for="(item,index) in executeTimeRepeatArr" :key="index"> |
| | | <a-time-picker v-model:value="item.value" format="HH:mm"/> |
| | | <a-button @click="addTime" type="default" shape="circle" :size="componentOptions.size"> |
| | | <template #icon> |
| | | <PlusCircleOutlined/> |
| | | </template> |
| | | </a-button> |
| | | |
| | | <a-button @click="deleteTime(item)" type="default" shape="circle" :size="componentOptions.size"> |
| | | <template #icon> |
| | | <MinusCircleOutlined/> |
| | | </template> |
| | | </a-button> |
| | | </div> |
| | | </a-form-item> |
| | | |
| | | <!-- 执行时间 (连续执行)--> |
| | | <a-form-item label="执行时间" v-if="planBody.task_type === TaskType.Continuous" :labelCol="{ span: 23 }"> |
| | | <div class="execute-time-arr-continuous-item" v-for="(item,index) in executeTimeContinuousArr" :key="index"> |
| | | <div class="time-select"> |
| | | <div class="time-item"> |
| | | <a-time-picker style="width: 100px;" v-model:value="item.value[0]" 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]" format="HH:mm"/> |
| | | </div> |
| | | </div> |
| | | <div class="btn-group"> |
| | | <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="[{ |
| | | 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> |
| | | <PlusCircleOutlined/> |
| | |
| | | <MinusCircleOutlined/> |
| | | </template> |
| | | </a-button> |
| | | </div> |
| | | </a-form-item> |
| | | </div> |
| | | </a-form-item> |
| | | </div> |
| | | |
| | | <!-- 重复频率--> |
| | | <!-- 执行时间 (连续执行)--> |
| | | <div v-if="planBody.task_type === TaskType.Continuous"> |
| | | <a-form-item |
| | | v-for="(item, index) in planBody.executeTimeContinuousArr" |
| | | :key="item.index" |
| | | :label="index === 0 ? '执行时间' : ''" |
| | | :name="item.index+'conValue'" |
| | | :labelCol="{ span: 23 }" |
| | | :rules="{ |
| | | required: true, |
| | | trigger: ['change', 'blur'], |
| | | validator: validateContinuousExecuteTime |
| | | }" |
| | | > |
| | | |
| | | <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"/> |
| | | </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"/> |
| | | </div> |
| | | </div> |
| | | <div class="btn-group"> |
| | | <a-button @click="addTime" type="default" shape="circle" :size="componentOptions.size"> |
| | | <template #icon> |
| | | <PlusCircleOutlined/> |
| | | </template> |
| | | </a-button> |
| | | <a-button @click="deleteTime(item)" type="default" shape="circle" :size="componentOptions.size"> |
| | | <template #icon> |
| | | <MinusCircleOutlined/> |
| | | </template> |
| | | </a-button> |
| | | </div> |
| | | </div> |
| | | </a-form-item> |
| | | </div> |
| | | |
| | | <!-- 任务开始执行的电量--> |
| | | <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"/> |
| | |
| | | <!-- 重复频率--> |
| | | <a-form-item label="重复频率" |
| | | v-if="planBody.task_type === TaskType.Repeat || planBody.task_type === TaskType.Continuous" |
| | | name="rep_fre_val" |
| | | :labelCol="{ span: 23 }"> |
| | | <div class="rep-fre-item"> |
| | | <div>每</div> |
| | |
| | | </a-button> |
| | | </a-form-item> |
| | | |
| | | <!-- 重复频率--> |
| | | <!-- 重复规则--> |
| | | <a-form-item label="重复规则" |
| | | v-if="(planBody.task_type === TaskType.Repeat || planBody.task_type === TaskType.Continuous) && planBody.rep_fre_type === FrequencyType.month" |
| | | :labelCol="{ span: 23 }"> |
| | |
| | | rep_fre_val: 1, |
| | | rep_fre_type: 3, |
| | | rep_rule_type: 1, |
| | | |
| | | executeTimeContinuousArr: [{ index: 1, value: [] }], |
| | | executeTimeRepeatArr: [{ index: 1, value: '' }] |
| | | }) |
| | | |
| | | const executeTimeRepeatArr = ref([ |
| | | { index: 1, value: '' } |
| | | ]) |
| | | const executeTimeContinuousArr = ref([ |
| | | { index: 1, value: [] } |
| | | ]) |
| | | watch( |
| | | planBody.executeTimeRepeatArr, |
| | | (newVal) => { |
| | | if (newVal.length) { |
| | | newVal.forEach(item => { |
| | | planBody[`${item.index}repValue`] = item.value |
| | | }) |
| | | } |
| | | }, |
| | | { deep: true, immediate: true } |
| | | ) |
| | | |
| | | watch( |
| | | planBody.executeTimeContinuousArr, |
| | | (newVal) => { |
| | | if (newVal.length) { |
| | | newVal.forEach(item => { |
| | | planBody[`${item.index}conValue`] = item.value |
| | | }) |
| | | } |
| | | }, |
| | | { deep: true, immediate: true } |
| | | ) |
| | | |
| | | // 重复规则为按星期时 |
| | | const repeatRuleValueWeek = ref([1, 1]) |
| | | // 重复规则为按日期时 |
| | |
| | | } |
| | | ], |
| | | out_of_control_action: [{ required: true, message: '请选择航线飞行中失联' }], |
| | | rep_fre_val: [ |
| | | { |
| | | validator: async (rule: RuleObject, value: string) => { |
| | | if (!/^[0-9]{1,}$/.test(value)) { |
| | | planBody.rep_fre_val = '' |
| | | throw new Error('重复频率不能为空') |
| | | } |
| | | }, |
| | | trigger: ['blur', 'change'] |
| | | } |
| | | ] |
| | | } |
| | | |
| | | function validateContinuousExecuteTime (rule: RuleObject, value: Moment[]) { |
| | | if (!value[0]) { |
| | | return Promise.reject(new Error('请选择执行时间')) |
| | | } else if (value.length < 2) { |
| | | return Promise.reject(new Error('请选择执行结束时间')) |
| | | } else if (value[1].isBefore(value[0])) { |
| | | return Promise.reject(new Error('执行结束时间不能小于执行开始时间')) |
| | | } else { |
| | | return Promise.resolve() |
| | | } |
| | | } |
| | | |
| | | function validateRepeatExecuteTime (rule: RuleObject, value: any) { |
| | | console.log('验证值', rule) |
| | | if (!value) { |
| | | return Promise.reject(new Error('请选择执行时间')) |
| | | } |
| | | } |
| | | |
| | | 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) |
| | | } |
| | | |
| | | // 重复定时添加执行时间 |
| | | function addTime () { |
| | | if (planBody.task_type === TaskType.Repeat) { |
| | | const index = executeTimeRepeatArr.value[executeTimeRepeatArr.value.length - 1].index |
| | | executeTimeRepeatArr.value.push({ |
| | | const index = planBody.executeTimeRepeatArr[planBody.executeTimeRepeatArr.length - 1].index |
| | | planBody.executeTimeRepeatArr.push({ |
| | | index: index + 1, |
| | | value: '' |
| | | }) |
| | | } else if (planBody.task_type === TaskType.Continuous) { |
| | | const index = executeTimeContinuousArr.value[executeTimeContinuousArr.value.length - 1].index |
| | | executeTimeContinuousArr.value.push({ |
| | | const index = planBody.executeTimeContinuousArr[planBody.executeTimeContinuousArr.length - 1].index |
| | | planBody.executeTimeContinuousArr.push({ |
| | | index: index + 1, |
| | | value: [] |
| | | }) |
| | |
| | | // 删除执行时间 |
| | | function deleteTime (item: any) { |
| | | if (planBody.task_type === TaskType.Repeat) { |
| | | executeTimeRepeatArr.value = executeTimeRepeatArr.value.filter(e => e.index !== item.index) |
| | | planBody.executeTimeRepeatArr = planBody.executeTimeRepeatArr.filter(e => e.index !== item.index) |
| | | } else if (planBody.task_type === TaskType.Continuous) { |
| | | executeTimeContinuousArr.value = executeTimeContinuousArr.value.filter(e => e.index !== item.index) |
| | | planBody.executeTimeContinuousArr = planBody.executeTimeContinuousArr.filter(e => e.index !== item.index) |
| | | } |
| | | } |
| | | |
| | |
| | | createPlanBody.task_days = [moment(planBody.time_range[0]).unix(), moment(planBody.time_range[1]).unix()] |
| | | createPlanBody.task_periods = [] |
| | | // 执行时间 |
| | | executeTimeRepeatArr.value.forEach(item => { |
| | | planBody.executeTimeRepeatArr.forEach(item => { |
| | | console.log(item, '------') |
| | | |
| | | createPlanBody.task_periods.push([moment(item.value).unix()]) |
| | |
| | | |
| | | break |
| | | case TaskType.Continuous: |
| | | createPlanBody.task_type = 2 |
| | | // createPlanBody.task_type = 2 |
| | | createPlanBody.task_days = [moment(planBody.time_range[0]).unix(), moment(planBody.time_range[1]).unix()] |
| | | |
| | | if (planBody.rep_fre_type === FrequencyType.month) { |
| | |
| | | } |
| | | createPlanBody.task_periods = [] |
| | | // 执行时间 |
| | | executeTimeContinuousArr.value.forEach(item => { |
| | | planBody.executeTimeContinuousArr.forEach(item => { |
| | | createPlanBody.task_periods.push([moment(item.value[0]).unix(), moment(item.value[1]).unix()]) |
| | | }) |
| | | |
| | |
| | | } |
| | | |
| | | // getFlyTimeList(createPlanBody) |
| | | |
| | | disabled.value = false |
| | | createPlan(workspaceId, createPlanBody) |
| | | .then(res => { |
| | | disabled.value = false |