<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="cancel">关闭</a-button>
    </template>
    <Des :list="desList" />
  </a-modal>
</template>

<script lang="ts">
import { defineComponent, PropType, watchEffect } from 'vue';
import { closeModal } from '@/common/setup/modal/index';
import { Des, handleDesList } from '@/common/components/commonDes';
import { QhjAgreementConfig } from '@/services/go/ermcp/qhj/interface';
import { formatValue } from '@/common/methods';
import { getAgreementTypeName } from '@/common/constants/enumsName';
import { handleArgreementType } from '../../setup';

export default defineComponent({
    name: 'custom-detail',
    components: { Des },
    props: {
        selectedRow: {
            type: Object as PropType<QhjAgreementConfig>,
            default: {},
        },
    },
    setup(props, context) {
        const { visible, cancel } = closeModal('detail');
        const { desList, getDesList } = handleDesList();
        const { getRateEnumName } = handleArgreementType();
        watchEffect(() => {
            if (visible.value) {
                const data = props.selectedRow;
                // 个人
                const list = [
                    { label: '协议编号', value: formatValue(data.agreementno) },
                    { label: '协议名称', value: formatValue(data.agreementname) },
                    { label: '协议类型', value: getAgreementTypeName(data.agreementtype) },
                    { label: '签署频率', value: getRateEnumName(data.agreementfrequency) },
                    { label: '内容', value: formatValue(data.agreementcontent), className: 'blue' },
                ];
                getDesList(list);
            }
        });

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

<style lang="less">
.custom-detail {
    .ant-form.inlineForm {
        margin-top: 20px;
    }
    .upload {
        .look {
            margin-left: 0;
        }
    }
}
</style>;
