<template>
  <!-- 撤销款项登记-->
  <a-modal class="add-custom custom-detail"
           title="撤销款项登记"
           v-model:visible="visible"
           centered
           :maskClosable="maskClosableFlag"
           @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="back">撤销
        </a-button>
    </template>

  </a-modal>
</template>

<script lang="ts">
import { defineComponent, PropType, reactive, ref, watchEffect } from 'vue';
import { closeModal } from '@/common/setup/modal/index';
import { QueryCustomInfoType } from '@/services/go/ermcp/customInfo/interface';
import { mergeObj } from '@/utils/objHandle';
import { getStatusName } from '@/common/constants/enumsName';
import { formatValue, formatTime } from '@/common/methods';
import {Modal} from "ant-design-vue";
import {ContractOperateApplyReq} from "@/services/proto/contract/interface";
import Long from "long";
import {financeControl} from "@/views/manage/finance-review/components/setup";
import {QryBussinessKxRsp} from "@/services/go/ermcp/finance-review/interface";

export default defineComponent({
    name: 'finance_review_funds_cancel',
    components: {},
    props: {
        selectedRow: {
            type: Object as PropType<QryBussinessKxRsp>,
            default: {},
        },
    },
    setup(props, context) {
        const { visible, cancel } = closeModal('finance_review_funds_cancel');
        const loading = ref<boolean>(false);
        const maskClosableFlag = ref<boolean>(false);
        function submit() {
            loading.value = true;
            setTimeout(() => {
                loading.value = false;
                cancel();
            }, 200);
        }
        function back(){
            Modal.confirm({
                title: '是否确认撤销',
                okText: '确认撤销',
                cancelText: '取消',
                onOk() {
                    const param: ContractOperateApplyReq = {
                        OperateApplyID: Long.fromString(props.selectedRow.operateapplyid),
                        OperateType: 4,
                    }
                    financeControl(param, loading)
                        .then(res => {
                            context.emit('refresh');
                            cancel()
                        })
                        .catch(err => {

                        })
                },
                onCancel() {
                    console.log('Cancel');
                },
            });
        }
        return {
            visible,
            cancel,
            submit,
            loading,
            formatValue,
            getStatusName,
            maskClosableFlag,
            back,
        };
    },
});
</script>

<style lang="less">
.finance_review_funds_cancel {
    .ant-form.inlineForm {
        margin-top: 20px;
    }
}
</style>;
