|
@@ -0,0 +1,142 @@
|
|
|
+<template>
|
|
|
+ <div id="index">
|
|
|
+ <detail-frame :title="pageTitle">
|
|
|
+ <data-table
|
|
|
+ :fields="fields"
|
|
|
+ :data="list"
|
|
|
+ :opera="opera"
|
|
|
+ :total="total"
|
|
|
+ @query="search"
|
|
|
+ @delete="toDelete"
|
|
|
+ @dot="needDot"
|
|
|
+ @start="toStart"
|
|
|
+ @result="toResult"
|
|
|
+ >
|
|
|
+ <template #options="{item}">
|
|
|
+ <template v-if="item.prop === 'status'">
|
|
|
+ <el-option label="未开始" value="0"></el-option>
|
|
|
+ <el-option label="正在进行" value="1"></el-option>
|
|
|
+ <el-option label="已完成" value="2"></el-option>
|
|
|
+ <el-option label="失败" value="3"></el-option>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </data-table>
|
|
|
+ </detail-frame>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+const _ = require('lodash');
|
|
|
+import detailFrame from '@frame/layout/admin/detail-frame';
|
|
|
+import dataTable from '@frame/components/filter-page-table.vue';
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: mission } = createNamespacedHelpers('mission');
|
|
|
+export default {
|
|
|
+ name: 'index',
|
|
|
+ props: {},
|
|
|
+ components: { detailFrame, dataTable },
|
|
|
+ data: function() {
|
|
|
+ return {
|
|
|
+ opera: [
|
|
|
+ {
|
|
|
+ label: '提示',
|
|
|
+ icon: 'el-icon-bell',
|
|
|
+ method: 'dot',
|
|
|
+ display: i => !i.dot,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '查看结果',
|
|
|
+ icon: 'el-icon-view',
|
|
|
+ method: 'result',
|
|
|
+ display: i => i.params && i.params.uri && i.status === '2',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '开始任务',
|
|
|
+ icon: 'el-icon-video-play',
|
|
|
+ method: 'start',
|
|
|
+ display: i => i.status == '0' || i.status == '1',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '重新开始任务',
|
|
|
+ icon: 'el-icon-refresh-right',
|
|
|
+ method: 'start',
|
|
|
+ display: i => i.status == '3' || i.status == '2',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '删除',
|
|
|
+ icon: 'el-icon-delete',
|
|
|
+ method: 'delete',
|
|
|
+ confirm: true,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ fields: [
|
|
|
+ { label: '待办事项', prop: 'title' },
|
|
|
+ { label: '创建时间', prop: 'create_time', options: { width: '200px' } },
|
|
|
+ { label: '进度', prop: 'progress', options: { width: '100px' }, format: i => `${i || 0}%` },
|
|
|
+ {
|
|
|
+ label: '状态',
|
|
|
+ prop: 'status',
|
|
|
+ format: i => (i == '0' ? '未开始' : i == '1' ? '正在进行' : i == '2' ? '已完成' : i == '3' ? '失败' : '未知状态'),
|
|
|
+ options: { width: '200px' },
|
|
|
+ filter: 'select',
|
|
|
+ },
|
|
|
+ { label: '提醒', prop: 'dot', format: i => (i ? '需要' : '不需要'), options: { width: '200px' } },
|
|
|
+ ],
|
|
|
+ list: [],
|
|
|
+ total: 0,
|
|
|
+ skip: 0,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...mission(['query', 'delete', 'update', 'start']),
|
|
|
+ async search({ skip = this.skip, limit = 10, ...info } = {}) {
|
|
|
+ this.skip = skip;
|
|
|
+ const res = await this.query({ skip, limit, ...info });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `list`, res.data);
|
|
|
+ this.$set(this, `total`, res.total);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async toDelete({ data }) {
|
|
|
+ const { id } = data;
|
|
|
+ const res = await this.delete(id);
|
|
|
+ if (this.$checkRes(res, '删除成功', res.errmsg || '删除失败')) {
|
|
|
+ this.search();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async needDot({ data }) {
|
|
|
+ data.dot = true;
|
|
|
+ const res = await this.update(data);
|
|
|
+ if (this.$checkRes(res, '已取消提示', res.errmsg || '取消提示失败')) {
|
|
|
+ this.search();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async toStart({ data }) {
|
|
|
+ const res = await this.start(data);
|
|
|
+ if (this.$checkRes(res, '任务开始', res.errmsg || '开始任务失败')) {
|
|
|
+ this.search();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async toResult({ data }) {
|
|
|
+ const params = _.get(data, 'params');
|
|
|
+ if (!params) this.$message.error('未找到参数位置');
|
|
|
+ const { uri } = params;
|
|
|
+ if (uri) window.open(uri);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState(['user']),
|
|
|
+ pageTitle() {
|
|
|
+ return `${this.$route.meta.title}`;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ metaInfo() {
|
|
|
+ return { title: this.$route.meta.title };
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped></style>
|