import { h } from 'vue'; import { NTag, NSwitch, useMessage } from 'naive-ui'; import { setJobStatus } from '@/api/monitor/job'; export const columns = [ { type: 'selection', width: 50, fixed: 'left', }, { title: 'ID', key: 'id', fixed: 'left', width: 50, }, { title: '任务名称', key: 'jobName', width: 200, }, { title: '任务分组', key: 'jobGroup', width: 100, }, { title: '任务触发器', key: 'jobTrigger', width: 150, }, { title: '执行表达式', key: 'cronExpression', width: 150, }, { title: '执行策略', key: 'executePolicyText', width: 100, render(record) { return h( NTag, { style: { marginRight: '6px', }, bordered: false, type: 'info', }, { default: () => record.executePolicyText, }, ); }, }, { title: '同步任务', key: 'isSync', width: 100, render(record) { return h( NTag, { style: { marginRight: '6px', }, bordered: false, type: record.isSync == 1 ? 'success' : 'info', }, { default: () => (record.isSync == 1 ? '同步' : '异步'), }, ); }, }, { title: 'URL', key: 'url', width: 150, }, { title: '状态', key: 'status', width: 100, render(record) { const message = useMessage(); return h(NSwitch, { value: record.realStatus, onUpdateValue: async (val) => { record.realStatus = val; await setJobStatus({ id: record.id, status: record.realStatus ? 1 : 0 }); message.success('设置成功'); }, }); }, }, { title: '备注', key: 'note', width: 200, }, ];