wangzhibo
6 天以前 7bd866831780abcf5a59c4cbb7d1be456eea7c99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<template>
    <cl-dialog v-model="visible" :title="title" width="1000px">
        <cl-crud ref="Crud" padding="0">
            <cl-row>
                <!-- 刷新按钮 -->
                <cl-refresh-btn />
                <!-- 状态 -->
                <cl-filter :label="$t('状态')">
                    <cl-select :options="options.status" prop="status" :width="120" />
                </cl-filter>
            </cl-row>
 
            <cl-row>
                <!-- 数据表格 -->
                <cl-table ref="Table" />
            </cl-row>
 
            <cl-row>
                <cl-flex1 />
                <!-- 分页控件 -->
                <cl-pagination />
            </cl-row>
        </cl-crud>
    </cl-dialog>
</template>
 
<script lang="ts" setup>
defineOptions({
    name: 'task-logs'
});
 
import { useCrud, useTable } from '@cool-vue/crud';
import { nextTick, reactive, ref } from 'vue';
import { useCool } from '/@/cool';
import { useI18n } from 'vue-i18n';
 
const { service } = useCool();
const { t } = useI18n();
 
// 是否可见
const visible = ref(false);
 
// 标题
const title = ref('');
 
// 选项
const options = reactive({
    status: [
        {
            label: t('成功'),
            value: 1,
            type: 'success'
        },
        {
            label: t('失败'),
            value: 0,
            type: 'danger'
        }
    ]
});
 
// cl-table
const Table = useTable({
    autoHeight: false,
    columns: [
        {
            label: '#',
            type: 'index'
        },
        {
            label: t('描述'),
            prop: 'detail',
            showOverflowTooltip: true,
            minWidth: 200
        },
        {
            label: t('执行状态'),
            prop: 'status',
            minWidth: 120,
            dict: options.status
        },
        {
            label: t('执行时间'),
            prop: 'createTime',
            minWidth: 170
        }
    ]
});
 
// cl-crud
const Crud = useCrud({
    service: service.task.info,
    dict: {
        api: {
            page: 'log'
        }
    }
});
 
// 打开
function open(data: Eps.TaskInfoEntity) {
    visible.value = true;
    title.value = t('日志列表({name})', { name: data.name });
 
    nextTick(() => {
        Crud.value?.refresh({ id: data.id, page: 1 });
    });
}
 
// 关闭
function close() {
    visible.value = false;
}
 
defineExpose({
    open,
    close
});
</script>