<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-form ref="form" view-code="BatchRedirect"></view-form>
      <div style="text-align: center">
        <Button type="info" custom-icon="fa fa-share" @click="batchRedirect()">{{ $t('Front_Btn_Redirect') }}</Button>
      </div>
    </Card>
  </div>
</template>
<script>
  import mixinPage from '../../mixins/page';
  import taskApi from '../../api/task';

  export default {
    name: 'system-batchRedirect',
    mixins: [mixinPage],
    components: {},
    data() {
      return {};
    },
    computed: {},
    created() {},
    methods: {
      // 批量转移
      async batchRedirect() {
        let isOK = await this.$refs.form.validate();

        if (!isOK) {
          this.error('Front_Msg_Form_Validate_Fail');
        } else {
          let model = this.$refs.form.data;

          this.confirm('Front_Msg_Sure_To_Redirect_Application|' + model.target.name, async () => {
            await taskApi.batchRedirect(model.sourceID, model.targetID, model.comment);
            this.success('Front_Msg_Success');
            this.resetNotice();

            setTimeout(() => {
              this.$refs.form.reset();
            });
          });
        }
      }
    }
  };
</script>
