<template>
  <div>
    <div class="i-layout-page-header">
      <PageHeader :title="$route.meta.title" :content="$route.meta.description" hidden-breadcrumb />
    </div>
    <Card :bordered="false" dis-hover class="ivu-mt">
      <view-table
        ref="table"
        view-code="PlanJob"
        :create-enable="allow('create')"
        :remove-enable="allow('remove')"
        @create="$refs.form.open()"
        @edit="({ row, index }) => $refs.form.open(row)"
      >
        <template #command="{ row }">
          <Button v-if="allow('start')" size="small" :title="$t('Front_Btn_Start_Immediately')" type="primary" custom-icon="fa fa-bolt" @click="execute(row)"></Button>
        </template>
      </view-table>
    </Card>
    <modal-form ref="form" view-code="PlanJobEdit" :create-enable="allow('create')" :edit-enable="allow('edit')" @on-after-save="$refs.table.loadData()" />
  </div>
</template>
<script>
  import mixinPage from '../../mixins/page';
  import planJobApi from '../../api/planJob';

  export default {
    name: 'system-planJob',
    mixins: [mixinPage],
    components: {},
    data() {
      return {};
    },
    computed: {},
    created() {},
    methods: {
      // 执行
      execute(row) {
        this.confirm('Front_Msg_Sure_To_Start_Immediately', async () => {
          await planJobApi.execute(row.id);
          this.success('Front_Msg_Success');
          this.$refs.table.loadData();
        });
      }
    }
  };
</script>
