lrf402788946 4 anni fa
parent
commit
5801854dfd

+ 2 - 0
src/store/index.js

@@ -44,6 +44,7 @@ import groupscore from '@frame/store/groupscore';
 import cerconfirm from '@frame/store/cerconfirm';
 import experience from '@frame/store/experience';
 import talented from '@frame/store/talented';
+import mission from '@frame/store/mission';
 import * as ustate from '@frame/store/user/state';
 import * as umutations from '@frame/store/user/mutations';
 import * as dostate from '@frame/store/setting/state';
@@ -100,6 +101,7 @@ export default new Vuex.Store({
     cerconfirm,
     experience,
     talented,
+    mission,
   },
   state: { ...ustate, ...dostate },
   mutations: { ...umutations, ...domutations },

+ 142 - 0
src/views/mission/index.vue

@@ -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>

+ 1 - 3
src/views/statistics/detail.vue

@@ -326,9 +326,7 @@ export default {
       const data = { range, direction, questionnaireid, modelList };
       msg.close();
       const res = await this.export(data);
-      if (this.$checkRes(res, '导出成功', res.errmsg || '导出失败')) {
-        window.open(res.data);
-      }
+      this.$checkRes(res, '任务已执行,请在 "菜单 - 待办事项" 中查看执行进度');
     },
   },
   computed: {

+ 1 - 4
src/views/student/index.vue

@@ -261,10 +261,7 @@ export default {
       const msg = this.$message({ duration: 0, message: '正在导出,请稍后...' });
       const res = await this.toExport(obj);
       msg.close();
-      if (this.$checkRes(res)) {
-        const { data } = res;
-        window.open(data);
-      }
+      this.$checkRes(res, '任务已执行,请在 "菜单 - 待办事项" 中查看执行进度');
     },
     getTerm(termid) {
       console.log(termid);

+ 1 - 4
src/views/task/index.vue

@@ -161,10 +161,7 @@ export default {
       if (this.subid) data.subid = this.subid;
       const res = await this.export(data);
       msg.close();
-      if (this.$checkRes(res, '导出成功', res.errmsg || '导出失败')) {
-        window.open(res.data);
-        this.subid = undefined;
-      }
+      this.$checkRes(res, '任务已执行,请在 "菜单 - 待办事项" 中查看执行进度');
     },
   },
   watch: {