liulin
2024-11-24 b7a7fe6d139893108fe431cd670a74351755c223
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
<!DOCTYPE html>
<html>
 
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" href="favicon.ico">
    <title>青河县萨尔托海智慧水务系统</title>
 
    <link rel="stylesheet" href="css/main.css" />
 
    <link rel="stylesheet" href="js/lib/element-plus/index.css" />
    <script src="js/lib/vue.global.js"></script>
    <script src="js/lib/element-plus/element-plus.js"></script>
    <script src="js/lib/element-plus/icons-vue.js"></script>
 
    <script src="js/lib/axios.min.js"></script>
    <script src="js/lib/httpVueLoader.js"></script>
    
    <style>#app-job-record{padding:10px;}</style>
</head>
<body>
<div id="app-job-record">
    <div id="loader-wrapper" v-if="loading">
        <div id="loader"></div>
        <div class="loader-section section-left"></div>
        <div class="loader-section section-right"></div>
        <div class="load_title">正在加载系统资源,请耐心等待</div>
    </div>
 
    <el-form :model="queryParams" :inline="true">
        <el-form-item label="执行结果" prop="listStatus">
            <el-select
                v-model="queryParams.listStatus"
                multiple
                placeholder="请选择"
                style="width: 240px"
            >
                <el-option label="成功" value="200"></el-option>
                <el-option label="失败" value="300"></el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="任务执行时间">
            <el-date-picker
                v-model="dateRangeExecuteTime"
                value-format="YYYY-MM-DD HH:mm:ss"
                type="daterange"
                range-separator="-"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                :default-time="[
                    new Date(2000, 1, 1, 0, 0, 0),
                    new Date(2000, 1, 1, 23, 59, 59),
                    ]"
            ></el-date-picker>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" icon="search" @click="handleQuery">搜索</el-button>
            <el-button icon="Refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
    </el-form>
 
    <el-table
        :stripe="true"
        :border="true"
        :data="dataList"
        @selection-change="handleSelectionChange"
        @row-dblclick="handleDetail"
    >
        <el-table-column label="执行时间" min-width="155" align="center" prop="startTimeView"></el-table-column>
        <el-table-column label="任务编号" min-width="175" align="center" prop="taskNo"></el-table-column>
        <el-table-column label="任务名称" min-width="300" align="center" prop="taskName"></el-table-column>
        <el-table-column label="执行参数" min-width="175" align="center" prop="executeParameter"></el-table-column>
        <el-table-column label="执行完成时间" min-width="155" align="center" prop="endTimeView"></el-table-column>
        <el-table-column label="执行耗时(ms)" min-width="150" align="center" prop="executeTimes">
            <template #default="scope">
                {{ scope.row.executeTimes }}
                {{ showExecuteTimes(scope.row.executeTimes) }}
            </template>
        </el-table-column>
        <el-table-column label="任务状态" min-width="80" align="center" prop="taskStatusView"></el-table-column>
        <el-table-column label="执行结果" min-width="80" align="center" prop="failReason" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column
            label="操作"
            align="center"
            min-width="90"
            fixed="right"
            class-name="small-padding fixed-width"
        >
            <template #default="scope">
                <el-button
                    link
                    type="primary"
                    v-if="scope.row.taskStatus === 300"
                    @click="handleDetail(scope.row)"
                >错误信息</el-button>
            </template>
        </el-table-column>
    </el-table>
 
    <!-- 修改对话框 -->
    <el-dialog
        title="错误信息"
        v-model="dialogOpenModify"
        width="80%"
        append-to-body
    >
        <div style="white-space: pre-wrap;">
            {{ formModify.errorValue }}
        </div>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="cancelModify">关闭</el-button>
            </div>
        </template>
    </el-dialog>
    
    <el-pagination
        v-if="total > 0"
        :background="tabConfig.background"
        :hide-on-single-page="tabConfig.hideOnSinglePage"
        :page-sizes="tabConfig.listPageSize"
        :total="total"
        v-model:current-page="queryParams.page"
        v-model:page-size="queryParams.limit"
        @change ="getList"
    />
</div>
 
<script type="module">
function queryURLParams(url, paramName) {
    let parameterStr = url.split("?")[1];
    const urlSearchParams = new URLSearchParams(parameterStr);
    const params = Object.fromEntries(urlSearchParams.entries());
    
    if (!paramName) {
        // 没有传入参数名称, 返回含有所有参数的对象params
        return params;
    } else {
        if (params[paramName]) {
            return params[paramName];
        } else {
            return '';
        }
    }
}
 
    import { EState } from "/js/enums.js"
 
    const { createApp, ref, onMounted, h } = Vue
    const loading = ref(true)
 
    const Http = axios.create({
        baseURL: location.pathname.substr(0, location.pathname.lastIndexOf('/')),
        timeout: 1000,
        headers: {'X-Custom-Header': 'foobar'}
    });
    const $message = ElementPlus.ElMessage;
    const $confirm = ElementPlus.ElMessageBox;
 
    var app = Vue.createApp({
        el: '#app-job-record',
        props: {
            taskNo: String
        },
        data() {
            return {
                ddd: true
            }
        },
        methods: {
            funcA() {
                console.log(this.ddd);
                this.$message('这是一条普通info消息');
                this.$message.success('恭喜你,这是一条成功消息');
                this.$message.warning('警告哦,这是一条警告消息');
                this.$message.error('错了哦,这是一条错误消息');
                this.$message({
                    message: h('p', { style: 'line-height: 1; font-size: 14px' }, [
                        h('span', null, '这是一条自定义样式的消息 '),
                        h('i', { style: 'color: teal' }, 'VNode'),
                    ])
                });
            }
        },
 
        mounted: () => {
            //$message('这是一条普通info消息');
        },
 
        setup() {
const tabConfig = ref({
    background: true,
    hideOnSinglePage: true,
    listPageSize: [20, 50, 100, 200]
});
 
const listEState = EState.enums;
const getEStateLabel = (value) => {
    return EState.getLabelByValue(value)
}
const loading = ref(false);
const dataList = ref([]);
 
const modifyLoading = ref(false);
const dialogOpenModify = ref(false);
 
const total = ref(0);
const dateRangeExecuteTime = ref([]);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
 
const queryParams = ref({
    page: 1,
    limit: 10,
    listStatus: [],
    taskNo: queryURLParams(location.href, 'taskNo'),
    executeTimeRange: ''
});
 
const formModify = ref({});
 
/** 查询列表 */
function getList() {
    loading.value = true;
    if (
        dateRangeExecuteTime &&
        dateRangeExecuteTime.value &&
        dateRangeExecuteTime.value[0]
    ) {
        queryParams.value.executeTimeRange = dateRangeExecuteTime.value.join(" ~ ");
    }
    Http.post('/quartz/taskRecords', queryParams.value)
    .then((response) => {
        let data = response.data.data;
        dataList.value = data.list;
        total.value = data.total;
        loading.value = false;
    });
}
/** 搜索按钮操作 */
function handleQuery() {
    queryParams.value.page = 1;
    getList();
}
/** 重置按钮操作 */
function resetQuery() {
    dateRangeCreateTime.value = [];
    dateRangeJoinTime.value = [];
    handleQuery();
}
/** 选择条数  */
function handleSelectionChange(selection) {
    ids.value = selection.map((item) => item.id);
    single.value = selection.length != 1;
    multiple.value = !selection.length;
}
 
 
 
/** 详情按钮 */
function handleDetail(row) {
    modifyLoading.value = true;
    resetModify();
    const id = row.id || ids.value[0];
 
    Http.get('/quartz/taskErrors/' + row.id)
    .then((response) => {
        let data = response.data.data;
        formModify.value = data;
        if (formModify.value) {
            dialogOpenModify.value = true;
        } else {
            $message.warning("没有更多信息");
        }
    }).finally(() => {
        modifyLoading.value = false;
    })
}
/** 编辑表单重置 */
function resetModify() {
    formModify.value = {
        id: undefined,
        taskName: undefined,
        schedulerRule: undefined,
        executor: undefined,
        sendType: undefined,
        url: undefined,
        executeParameter: undefined,
    };
}
/** 取消编辑按钮 */
function cancelModify() {
    dialogOpenModify.value = false;
    resetModify();
}
 
function showExecuteTimes(times) {
    let str = (times / 1000) + '';
    if (str.indexOf('.') > -1) {
        str = str.substring(0, str.indexOf('.') + 2);
    }
    return '(' + str + 's)';
}
 
onMounted(() => {
    loading.value = false
    getList()
})
return {
    tabConfig,
    listEState,
    getEStateLabel,
    loading,
    dataList,
    modifyLoading,
    dialogOpenModify,
    total,
    dateRangeExecuteTime,
    ids,
    single,
    multiple,
    queryParams,
    formModify,
    getList,
    handleQuery,
    resetQuery,
    handleSelectionChange,
    handleDetail,
    resetModify,
    cancelModify,
    showExecuteTimes
}
        }
    })
    app.use(ElementPlus)
    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
      app.component(key, component)
    }
    app.mount("#app-job-record")
</script>
</body>
</html>