<template>
  <!-- 提货查询 确认收货-->
  <a-modal class="add-custom custom-detail"
           title="确认收货"
           centered
           v-model:visible="visible"
           :maskClosable="false"
           @cancel="cancel"
           width="890px">
    <template #footer>
        <a-button key="submit"
                  type="primary"
                  :loading="loading"
                  @click="submit">确认收货</a-button>
      <a-button key="submit"
                type="primary"
                :loading="loading"
                @click="cancel">关闭</a-button>
    </template>
    <CommomDetail :selectedRow="selectedRow" />
  </a-modal>
</template>
<script lang="ts">
import { defineComponent, PropType, ref } from 'vue';
import { closeModal } from '@/common/setup/modal/index';
import { QueryCustomInfoType } from '@/services/go/ermcp/customInfo/interface';
import CommomDetail from '../common-detail/index.vue';
import {GoodsPickupConfirmReq, GoodsPickupOperateReq, TradeGoodsInfo} from "@/services/proto/manager/interface";
import {getUserId} from "@/services/bus/account";
import {requestResultLoadingAndInfo} from "@/common/methods/request/resultInfo";
import {goodsPickupConfirm, goodsPickupOperate} from "@/services/proto/manager";
import {QhjTradeGoodsPickup} from "@/services/go/ermcp/qhj/interface";
import {getLongTypeLoginID} from "@/services/bus/login";
import Long from "long";

export default defineComponent({
    name: 'platinum_pick_query_receipt',
    components: { CommomDetail },
    props: {
        selectedRow: {
            type: Object as PropType<QhjTradeGoodsPickup>,
            default: {},
        },
    },
    setup(props, context) {
        const { visible, cancel } = closeModal('platinum_pick_query_receipt');
        const loading = ref<boolean>(false);
        function submit() {
            let reqParams: GoodsPickupOperateReq = {
                operatetype: 3, // uint32 操作类型-1:提货单上传物流信息 2:取货确认(自提) 3:收货确认(邮寄)
                takeorderid : Long.fromString(props.selectedRow.takeorderid), // uint64 提货单号
                userid: getUserId(), // uint64 用户ID
                loginid: Number(getLongTypeLoginID()) // uint64 登录ID
            }
            requestResultLoadingAndInfo(goodsPickupOperate, reqParams, loading, ['确认收货成功', '确认收货失败:']).then(() => {
                cancel();
                context.emit('refresh');
            });
        }
        return {
            cancel,
            visible,
            loading,
            submit,
        };
    },
});
</script>
