<template>
  <!-- 撤销-->
  <div>
  </div>
</template>

<script lang="ts">
import { defineComponent, PropType, ref } from 'vue';
import Drawer from '@/common/components/drawer/index.vue';
import { WrFinanceBuyApply, WrOutInApply } from '@/services/go/wrtrade/interface';
import { ModalEnum } from '@/common/constants/modalNameEnum';
import { _closeModal } from '@/common/setup/modal/modal';
import { Modal } from 'ant-design-vue';
import { WROutCancel } from '@/services/proto/warehousetrade';
import { WROutCancelReq } from '@/services/proto/warehousetrade/interface';
import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
import { getSelectedAccountId, getUserId } from '@/services/bus/account';
import { v4 as uuidv4 } from 'uuid';
import Long from 'long';

export default defineComponent({
  name: ModalEnum.financing_manager_apply_cancel,
  components: { Drawer },
  emits: ['cancel', 'update'],
  props: {
    selectedRow: {
      type: Object as PropType<WrOutInApply>,
      default: {},
    },
  },
  setup(props, context) {
    const { visible, cancel } = _closeModal(context);
    const loading = ref<boolean>(false);
    Modal.confirm({
      title: '撤销',
      content: '是否确认撤销提货申请！',
      onOk: submit,
      onCancel: cancel,
    });
    function submit() {
      // 挂牌撤单请求
      const paramReq: WROutCancelReq = {
        applyid: Long.fromString(props.selectedRow.applyid),
        operatesrc: 2,
        ooperateid: getUserId(),
      };
      requestResultLoadingAndInfo(WROutCancel, paramReq, loading, ['撤销成功', '撤销失败:']).then(() => {
        cancel(true);
      });
    }
    return {
      visible,
      cancel,
      submit,
      loading,
    };
  },
});
</script>