<template>
  <!-- 商品合约 议价单 撤单 -->
  <div></div>
</template>

<script lang="ts">
import Drawer from '@/common/components/drawer/index.vue';
import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
import { _closeModal } from '@/common/setup/modal/modal';
import { geLoginID_number } from '@/services/bus/login';
import { QueryTjmdTransferApplyRsp } from '@/services/go/Tjmd/interface';
import { tradeHoldTransferApplyAuditReq } from '@/services/proto/warehousetrade';
import { TradeHoldTransferApplyAuditReqType } from '@/services/proto/warehousetrade/interface';
import { Modal } from 'ant-design-vue';
import { defineComponent, PropType, ref } from 'vue';

export default defineComponent({
  name: 'commodity_contract_bargain_cancel_order',
  components: { Drawer },
  emits: ['cancel', 'update'],
  props: {
    selectedRow: {
      type: Object as PropType<QueryTjmdTransferApplyRsp>,
      default: {},
    },
  },
  setup(props, context) {
    const { visible, cancel } = _closeModal(context);
    const loading = ref<boolean>(false);

    function submit() {
      const param: TradeHoldTransferApplyAuditReqType = {
        ApplyID: props.selectedRow.applyid,
        ApplyStatus: 1, // 1:撤销2:拒绝3:通过
        AuditSrc: 2,
        AuditorID: geLoginID_number()!.toString(),
        AuditRemark: '',
      };
      requestResultLoadingAndInfo(tradeHoldTransferApplyAuditReq, param, loading, ['撤单成功', '撤单失败:']).then(() => {
        // Bus.$emit('spotTrade', true);
        cancel(true);
      });
    }

    Modal.confirm({
      title: '撤单',
      content: '是否确认撤单！',
      onOk: submit,
      onCancel: cancel,
    });

    return {
      visible,
      cancel,
    };
  },
});
</script>