<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="cancel"
                type="primary"
                :loading="loading"
                @click="cancel">关闭</a-button>
    </template>
    <CommomDetail :selectedRow="selectedRow" />
  </a-modal>
</template>
<script lang="ts">
import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
import { _closeModal } from '@/common/setup/modal/modal';
import { geLoginID_number } from '@/services/bus/login';
import { getUserId } from '@/services/bus/user';
import { QhjTradeGoodsPickup } from '@/services/go/ermcp/qhj/interface';
import { goodsPickupOperate } from '@/services/proto/manager';
import { GoodsPickupOperateReq } from '@/services/proto/manager/interface';
import Long from 'long';
import { defineComponent, PropType, ref } from 'vue';
import CommomDetail from '../common-detail/index.vue';

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