<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 { getUserId } from '@/services/bus/user';
import { QhjTradeGoodsPickup } from '@/services/go/ermcp/qhj/interface';
import { goodsPickupConfirm } from '@/services/proto/manager';
import { GoodsPickupConfirmReq } 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_complete_stocking',
    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: GoodsPickupConfirmReq = {
                TakeOrderID: Long.fromString(props.selectedRow.takeorderid), // uint64 提货单号
                Auditer: getUserId(), // uint64 审核人
                CheckRemark: '', // string 审核备注
                ClientTicket: getUserId().toString(), // string 客户端流水号
                MarketID: props.selectedRow.marketid,
            };
            requestResultLoadingAndInfo(goodsPickupConfirm, reqParams, loading, ['完成备货成功', '完成备货失败:']).then(() => {
                cancel(true);
            });
        }
        return {
            cancel,
            visible,
            loading,
            submit,
        };
    },
});
</script>
