修改任务

This commit is contained in:
lq
2025-09-04 20:29:31 +08:00
parent 70cb9f86f9
commit 4864652d10
3 changed files with 35 additions and 53 deletions

View File

@ -12,9 +12,9 @@ export const delTaskSchedules = (id: string) => {
};
// 任务管理-修改
export const editTaskSchedules = (id: string) => {
export const editTaskSchedules = (id: string, params = {}) => {
console.log('id', id);
return Http.put(`/v1/task-schedules/${id}`);
return Http.put(`/v1/task-schedules/${id}`,params);
};
// 任务管理-详情

View File

@ -1,36 +1,28 @@
<template>
<div class="flex flex-col items-start cell-detail" @click="gotoDetail">
<div class="flex items-center">
<div class="flex flex-col items-start cell-detail">
<div class="flex items-center" @click="gotoDetail">
<img
:src="getPlatformIcon(record.platform)"
style="border-radius: 8px; width: 16px; height: 16px; margin-right: 8px; font-size: 14px"
/>
{{ record.name || '-' }}
</div>
<div class="size-12px color-#939499 mt-2px">
<div class="size-12px color-#939499 mt-2px" @click="gotoDetail">
{{ timestampToTime1(task.execution_time) }}
</div>
<div class="size-14px color-#211F24 mt-12px color-#6D4CFE">{{ task.name || '未命名' }}</div>
<div class="size-14px color-#211F24 mt-12px color-#6D4CFE" @click="gotoDetail">{{ task.name || '未命名' }}</div>
<div class="flex items-center mt-12px">
<a-trigger trigger="click" align-point>
<div class="opt-btn" @click.stop="handleEditTime">修改发布时间</div>
<template #content>
<div class="custom-time-picker">
<!-- 1. 自定义触发按钮替代原输入框点击弹出面板 -->
<!-- <button @click="toggleTimePanel" class="trigger-btn">选择时间点击弹出面板</button> -->
<!-- 2. a-time-picker 核心隐藏输入框容器仅保留弹出面板 -->
<a-time-picker
format="HH:mm"
:defaultValue="defaultValue"
:visible="isPanelVisible"
@visible-change="handleVisibleChange"
@change="handleTimeChange"
class="hide-input-container"
/>
</div>
</template>
</a-trigger>
<div class="custom-time-picker">
<a-time-picker
format="HH:mm"
size="small"
:visible="isPanelVisible"
@visible-change="handleVisibleChange"
@change="handleTimeChange"
placeholder="修改发布时间"
class="hide-input-container opt-btn mr-12px"
/>
</div>
<div class="opt-btn" @click.stop="handleDelete" style="margin-right: 0px">删除</div>
</div>
</div>
@ -38,6 +30,7 @@
<script lang="ts" setup>
import { defineProps, defineEmits } from 'vue';
import { ref, computed } from 'vue';
const props = defineProps({
task: {
@ -60,29 +53,24 @@ const toggleTimePanel = () => {
const handleVisibleChange = (visible: boolean) => {
isPanelVisible.value = visible;
};
const handleTimeChange = (time: Date | null) => {
const handleTimeChange = (time: string) => {
if (time) {
console.log('Selected time:', time);
emit('edit-time', props.task, timestampToTime1() + ' ' + time + ':00');
}
};
const defaultValue = ref(new Date());
const emit = defineEmits(['editTime', 'delete', 'gotoDetail']);
// 时间戳转时间格式 (MM月DD HH:MM)
const timestampToTime1 = (timestamp: number): string => {
const date = new Date(timestamp * 1000); // 假设时间戳是秒级
// 获取月份和日期注意月份从0开始需要+1
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0');
const timestampToTime1 = (): string => {
const timestamp = Date.now();
const date = new Date(timestamp);
return `${month}${day} ${hours}:${minutes}`;
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 补零
const day = String(date.getDate()).padStart(2, '0'); // 补零
return `${year}-${month}-${day}`;
};
const handleEditTime = () => {
emit('editTime', props.task);
};
const emit = defineEmits(['edit-time', 'delete', 'gotoDetail']);
const handleDelete = () => {
emit('delete', props.task);

View File

@ -325,17 +325,12 @@
{{ deleteContent }}
</div>
</a-modal>
<!-- 添加 TimePicker 组件 -->
<a-modal v-model:visible="timePickerVisible" @ok="onTimeConfirm" @cancel="onTimeCancel" title="选择时间">
<TimePicker />
</a-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, onMounted, watch, computed, nextTick } from 'vue';
import type { TableColumnData } from '@arco-design/web-vue';
import { getTaskSchedules, delTaskSchedules, getTaskSchedulesDetail } from '@/api/all/assignment-management';
import { getTaskSchedules, delTaskSchedules, editTaskSchedules } from '@/api/all/assignment-management';
import { fetchAccountOperators, getMediaAccountList } from '@/api/all/propertyMarketing';
import icon1 from '@/assets/img/platform/icon-dy.png';
import icon2 from '@/assets/img/platform/icon-xhs.png';
@ -477,9 +472,11 @@ const handleCancel = () => {
};
const handleAddAccount = () => {};
const handleModifyTime = (task: any) => {
selectedTask.value = task;
timePickerVisible.value = true;
const handleModifyTime = (task: any, time: any) => {
editTaskSchedules(task.id, { execution_time: time }).then(() => {
handleSearch();
timePickerVisible.value = true;
});
};
const onTimeConfirm = () => {
@ -492,9 +489,6 @@ const onTimeConfirm = () => {
timePickerVisible.value = false;
};
const onTimeCancel = () => {
timePickerVisible.value = false;
};
// 计算当前日期范围内的所有日期,统一返回 number 数组
const currentDateHeaders = computed(() => {