<template>
  <div class="fixed-bar">
    <Card>
      <Form>
        <Form-item>
          <div>
            <Button
              v-show="showCancelButton"
              type="info"
              :loading="submitLoading"
              @click="cancelProcess"
            >
              作废付款准备
            </Button>
          </div>
        </Form-item>
      </Form>
    </Card>
  </div>
</template>
<script>
import { mapState, mapGetters, mapMutations } from 'vuex';
import util from '@paymentPlatformSrc/tools/util.js';
import extend from 'extend';

let vm;
export default {
  components: {},
  props: {
    batchId: {
      type: Number,
      default() {
        return {};
      }
    },
    server: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  data() {
    return {
      showCancelButton: true,
      submitLoading: false
    };
  },
  computed: {
    ...mapState('createPaymentPreparation', {
      selections: state => state.paymentSelects.selections
    })
  },
  watch: {},
  created: function() {
    vm = this;
  },
  beforeMount: function() {},
  mounted: function() {
    vm = this;
  },
  beforeDestroy: function() {},
  destroyed: function() {},
  methods: {
    // 作废
    cancelProcess() {
      const self = this;
      new $confirm('你确定要作废当前付款准备吗？', this).then(() => {
        vm.server
          .cancelPaymentPreparation({ payBatchId: self.batchId })
          .then(response => {
            if (response.statusCode == '-1') {
              self.$Message.info(response.msg);
            } else {
              self.$Message.success('操作成功');
            }
          });
      });
    }
  },
  directives: {}
};
</script>
<style lang="less">
// .fixed-bar {
//   position: fixed;
//   left: 0;
//   top: 0;
//   width: 100%;
//   min-width: 1200px;
//   z-index: 99999;
// }
</style>
