<template>
    <div class="p-2">
        <el-card style="width: 100%;margin-bottom: 16px;" v-loading="qyxxLoadding">
            <el-descriptions title="企业信息" :column="4" border direction="vertical">
                <template #extra>
                    <el-button @click="eidtCpy" type="primary" text>
                        <el-icon><EditPen /></el-icon>
                        编辑
                    </el-button>
                </template>
                <el-descriptions-item label="企业logo">
                    <template #default>
                        <HAvatar :src="form.storePhoto" :name="form.cpyName"></HAvatar>
                    </template>
                </el-descriptions-item>
                <el-descriptions-item label="企业名称">{{ form.cpyName }}</el-descriptions-item>
                <el-descriptions-item label="企业类型">
                    {{ selectDictLabel(cpy_type, form.cpyType) }}
                    <template v-if="form.supervisionType">
                        {{ '>' + selectDictLabel(supervision_type, form.supervisionType) }}
                    </template>
                </el-descriptions-item>
                <!-- 监管类型 -->
                <el-descriptions-item label="监管类型">{{ selectDictLabel(supervision_type, form.supervisionType) }}</el-descriptions-item>
                <el-descriptions-item label="监管区域">
                    {{ form.supervisionAreaName || '-' }}
                </el-descriptions-item>

                <el-descriptions-item label="统一社会信用代码">{{ form.creditCode }}</el-descriptions-item>
                <el-descriptions-item label="营业执照" class="d-flex a-c">
                    <template #default>
                        <FileLook v-model="form.license"></FileLook>
                    </template>
                </el-descriptions-item>
                <el-descriptions-item label="所在行政区" class="d-flex a-c">
                    <template #default>
                        {{ form.adcdCodeName || '-'}}
                    </template>
                </el-descriptions-item>
                <el-descriptions-item label="具体地址" class="d-flex a-c">
                    <template #default>
                        {{ form.address || '-'}}
                    </template>
                </el-descriptions-item>
                <el-descriptions-item label="企业联系人">{{ form.contactPerson }}</el-descriptions-item>
                <el-descriptions-item label="企业联系电话">{{ form.tel }}</el-descriptions-item>
            </el-descriptions>
        </el-card>
        <el-card style="width: 100%;margin-bottom: 16px;">
            <div class="f-14 f-w-b mb15">普通资质</div>
            <baseAuthInfo :cpyid="(query.cpyid as string)"></baseAuthInfo>
            <div class="f-14 f-w-b mb15" style="padding-top: 16px;">特殊资质</div>
            <specialAuthInfo :cpyid="(query.cpyid as string)"></specialAuthInfo>
        </el-card>
        <el-card style="width: 100%;margin-bottom: 16px;">
            <div class="d-flex j-sb mb10">
                <div class="f-14 f-w-b mb15">授权应用</div>
                <el-button @click="addApp(authAppRef)" type="primary" text>
                    <el-icon><Plus /></el-icon>
                    新增应用
                </el-button>
            </div>
            <authApp ref="authAppRef" :cpyid="(query.cpyid as string)"></authApp>
        </el-card>
    </div>
    <!-- 添加或修改企业备案信息对话框 -->
    <editCpy v-model:show="show1" title="编辑企业信息" :info="formItem" @seccess="changeForm"></editCpy>
</template>
<script setup name="Staff" lang="ts">
import { companyDetail } from '@/api/settled';
import { AreaView } from '@/views/components';
import { FileLook } from '@/views/models';
import { editCpy, baseAuthInfo, specialAuthInfo, authApp } from '@/views/settled';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { cpy_res_status, cpy_type, supervision_type } = toRefs<any>(proxy?.useDict('cpy_res_status', 'cpy_type', 'supervision_type'));
const { query } = useRoute();
const form = ref<any>({});
const show1 = ref(false);
const qyxxLoadding = ref(false);
const authAppRef = ref();
const formItem = ref<any>(null);
const getDetail = async () => {
    qyxxLoadding.value = true;
    const res = await companyDetail(query.cpyid);
    qyxxLoadding.value = false;
    if (!res) return;
    Object.assign(form.value, res.data);
};
const eidtCpy = () => {
    formItem.value = { ...form.value };
    show1.value = true;
};
const changeForm = (event: any) => {
    Object.assign(form.value, event);
};
const addApp = (authAppRef: any) => {
  if (!authAppRef) return
  authAppRef.addApp()
}
onMounted(() => {
    getDetail();
});
</script>
<style lang="scss" scoped></style>
