可信代码库-企业认证相关接口对接
This commit is contained in:
@@ -326,3 +326,36 @@ export function acceptHistoryDelete(params): catchRt<any> {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function addEnterprise(params) {
|
||||
return request({
|
||||
url: `enterprise/add`,
|
||||
method: 'post',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
|
||||
export function uploadImage(file: File) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
return request({
|
||||
url: `enterprise/uploadPackage`,
|
||||
method: 'post',
|
||||
data: formData,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
Authorization: 'Bearer ' + localStorage.getItem('access_token')
|
||||
}
|
||||
});
|
||||
|
||||
// return axios.request({
|
||||
// url: '/gateway/detect' + `/enterprise/uploadPackage`,
|
||||
// method: 'POST',
|
||||
// data: formData,
|
||||
// headers: {
|
||||
// 'Content-Type': 'multipart/form-data',
|
||||
// Authorization: 'Bearer ' + localStorage.getItem('access_token')
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@@ -60,3 +60,18 @@ export function getGroupmemberinviteApi(params: { groupId: number }): Promise<Un
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
export function fetchEnterpriseDetail(id) {
|
||||
return request({
|
||||
url: `enterprise/detail/${id}`,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
export function addEnterprise(params) {
|
||||
return request({
|
||||
url: `enterprise/add`,
|
||||
method: 'post',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,27 +5,40 @@
|
||||
<div class="text-[14px] w-full flex items-center justify-between">
|
||||
<div class="font-bold mb-[16px]">基础信息</div>
|
||||
<div>
|
||||
<!-- <d-icon style="margin-right: 4px;color: rgb(61, 204, 166)" v-if="!isEdit" class="font-normal" name="right-o" operable @click="editIconClick">-->
|
||||
<!-- <template #suffix>-->
|
||||
<!-- <span>已认证</span>-->
|
||||
<!-- </template>-->
|
||||
<!-- </d-icon>-->
|
||||
<d-icon style="margin-right: 4px;color: rgb(245, 152, 51)" v-if="!isEdit" class="font-normal" name="warning-o" operable @click="editIconClick">
|
||||
<d-icon style="margin-right: 4px;color: rgb(245, 152, 51)" v-if="!userInfo.enterpriseId" class="font-normal" name="warning-o" operable>
|
||||
<template #suffix>
|
||||
<span>未认证</span>
|
||||
</template>
|
||||
</d-icon>
|
||||
<!-- <d-icon style="margin-right: 4px;color: rgb(249, 95, 91)" v-if="!isEdit" class="font-normal" name="error-o" operable @click="editIconClick">-->
|
||||
<!-- <template #suffix>-->
|
||||
<!-- <span>驳回</span>-->
|
||||
<!-- </template>-->
|
||||
<!-- </d-icon>-->
|
||||
<!-- <d-icon style="margin-right: 4px;color: rgb(254, 204, 85)" v-if="!isEdit" class="font-normal" name="warning-o" operable @click="editIconClick">-->
|
||||
<!-- <template #suffix>-->
|
||||
<!-- <span>审核中</span>-->
|
||||
<!-- </template>-->
|
||||
<!-- </d-icon>-->
|
||||
<d-icon v-if="!isEdit" class="font-normal" style="margin-right: 4px" name="classroom-post-results-large" operable @click="showModal">
|
||||
<d-icon v-if="userInfo.enterpriseId&&enterpriseDetail?.auditStatus===1" style="margin-right: 4px;color: rgb(61, 204, 166)" class="font-normal" name="right-o" operable>
|
||||
<template #suffix>
|
||||
<span>已认证</span>
|
||||
</template>
|
||||
</d-icon>
|
||||
<d-icon v-if="userInfo.enterpriseId&&enterpriseDetail?.auditStatus===2" style="margin-right: 4px;color: rgb(249, 95, 91)" class="font-normal" name="error-o" operable>
|
||||
<template #suffix>
|
||||
<span>驳回</span>
|
||||
</template>
|
||||
</d-icon>
|
||||
|
||||
<div v-if="userInfo.enterpriseId&&enterpriseDetail?.auditStatus===0" style="display: inline-block">
|
||||
<d-popover trigger="hover" :position="['bottom']">
|
||||
<template #content>
|
||||
<div>
|
||||
<div>企业名称: {{enterpriseDetail?.enterpriseName || '--'}}</div>
|
||||
<div>企业官网: {{enterpriseDetail?.website || '--'}}</div>
|
||||
<div>营业执照: <img style="display: inline-block" width="80" v-if="enterpriseDetail?.businessLicenseUrl" :src="enterpriseDetail?.businessLicenseUrl"/></div>
|
||||
</div>
|
||||
</template>
|
||||
<d-icon style="margin-right: 4px;color: rgb(254, 204, 85)" class="font-normal" name="warning-o" operable>
|
||||
<template #suffix>
|
||||
<span>审核中</span>
|
||||
</template>
|
||||
</d-icon>
|
||||
</d-popover>
|
||||
</div>
|
||||
|
||||
<d-icon v-if="!userInfo.enterpriseId" class="font-normal" style="margin-right: 4px" name="classroom-post-results-large" operable @click="showModal">
|
||||
<template #suffix>
|
||||
<span>申请企业认证</span>
|
||||
</template>
|
||||
@@ -240,7 +253,7 @@
|
||||
</div>
|
||||
</d-modal>
|
||||
|
||||
<QyrzModal ref="qyrzRef"/>
|
||||
<QyrzModal @refresh="queryUserInfo" ref="qyrzRef"/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -253,7 +266,7 @@ import {
|
||||
deleteOrganizationMemberApi, getGroupjoinedListApi,
|
||||
getOrganizationMemberListApi,
|
||||
inviteOrganizationMemberApi,
|
||||
updateOrganizationInfoApi,getGroupmemberinviteApi
|
||||
updateOrganizationInfoApi,getGroupmemberinviteApi,fetchEnterpriseDetail
|
||||
} from '@/api/organizationManage/organizationManageApi';
|
||||
import {
|
||||
type OrganizationInfoType,
|
||||
@@ -382,6 +395,9 @@ async function queryUserInfo() {
|
||||
} else {
|
||||
hasOrganization.value = false;
|
||||
}
|
||||
if (res.data?.data.data.enterpriseId) {
|
||||
getEnterpriseDetail(res.data?.data.data.enterpriseId);
|
||||
}
|
||||
} catch (e) {
|
||||
Message.error('查询用户信息失败');
|
||||
}
|
||||
@@ -524,6 +540,22 @@ async function getOrgList(username) {
|
||||
orgListSearchLoading.value = false;
|
||||
}
|
||||
|
||||
const enterpriseDetail = ref({});
|
||||
const getEnterpriseDetail = async (id) => {
|
||||
try {
|
||||
const response = await fetchEnterpriseDetail(id);
|
||||
debugger
|
||||
if (response.data.code === 200) {
|
||||
enterpriseDetail.value = response.data.data;
|
||||
} else {
|
||||
Message.error('数据获取失败');
|
||||
}
|
||||
} catch (error) {
|
||||
Message.error('网络请求失败');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 搜索处理函数(带防抖)
|
||||
const handleSearch = debounce(() => {
|
||||
pager.pageIndex = 1; // 搜索时重置到第一页
|
||||
@@ -546,7 +578,6 @@ function updateFilterTableList() {
|
||||
|
||||
// 修改 updateFilterTableList 函数
|
||||
function updateFilterOrgTableList() {
|
||||
debugger
|
||||
const queryStr = orgListSearchParam.value.trim().toLowerCase();
|
||||
|
||||
filterOrgList = queryStr
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
|
||||
<d-row :gutter="32" class="mb-3">
|
||||
<d-col :span="12">
|
||||
<d-form-item field="businessLicense" label="营业执照">
|
||||
<d-form-item field="businessLicenseUrl" label="营业执照">
|
||||
<div class="img-container" v-if="!showUpload">
|
||||
<img class="img-preview" :src="businessLicenseUrl" alt="营业执照预览" />
|
||||
<div class="delete-img" @click="handleDel">
|
||||
@@ -150,9 +150,15 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, nextTick } from 'vue';
|
||||
import { ref, nextTick,defineEmits } from 'vue';
|
||||
import NoData from '@/components/NoData/NoData.vue';
|
||||
import { Message } from 'vue-devui';
|
||||
import { addEnterprise } from '@/api/organizationManage/organizationManageApi';
|
||||
import { uploadImage } from '@/api/jyh';
|
||||
import { useAccountStore } from '@/stores/user';
|
||||
|
||||
const { accountInfo } = useAccountStore();
|
||||
const userName = accountInfo?.username
|
||||
|
||||
const visible = ref(false);
|
||||
const formRef = ref(null);
|
||||
@@ -164,16 +170,14 @@ const rules = ref({
|
||||
applicant: [{ required: true, message: '请填写申请人', trigger: 'blur' }],
|
||||
enterpriseName: [{ required: true, message: '请填写企业名称', trigger: 'blur' }],
|
||||
creditCode: [
|
||||
{ required: true, message: '请填写统一信用代码', trigger: 'blur' },
|
||||
{ pattern: /^[0-9A-Z]{18}$/, message: '统一信用代码格式不正确', trigger: 'blur' }
|
||||
{ required: true, message: '请填写统一信用代码', trigger: 'blur' }
|
||||
],
|
||||
website: [
|
||||
{ required: true, message: '请填写企业官网', trigger: 'blur' },
|
||||
{ pattern: /^https?:\/\/.+$/, message: '网址格式不正确', trigger: 'blur' }
|
||||
{ required: true, message: '请填写企业官网', trigger: 'blur' }
|
||||
],
|
||||
industry: [{ required: true, message: '请填写所属行业', trigger: 'blur' }],
|
||||
introduction: [{ required: true, message: '请填写企业简介', trigger: 'blur' }],
|
||||
businessLicense: [{ required: true, message: '请上传营业执照', trigger: 'change' }],
|
||||
businessLicenseUrl: [{ required: true, message: '请上传营业执照', trigger: 'change' }],
|
||||
contactEmail: [
|
||||
{ required: true, message: '请填写联系人邮箱', trigger: 'blur' },
|
||||
{ type: 'email', message: '邮箱格式不正确', trigger: 'blur' }
|
||||
@@ -194,7 +198,7 @@ const newFormData = ref({
|
||||
website: '', // 企业官网
|
||||
industry: '', // 所属行业
|
||||
introduction: '', // 企业简介
|
||||
businessLicense: '', // 营业执照(存储上传后的URL或ID)
|
||||
businessLicenseUrl: '', // 营业执照(存储上传后的URL或ID)
|
||||
contactEmail: '', // 联系人邮箱
|
||||
contactName: '', // 联系人姓名
|
||||
contactPhone: '', // 联系电话
|
||||
@@ -206,22 +210,35 @@ const uploadOptions = ref({
|
||||
uri: 'https://run.mocky.io/v3/132b3ea3-23ea-436b-aed4-c43ef9d116f0',
|
||||
});
|
||||
|
||||
const beforeUpload = (file) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = async () => {
|
||||
showUpload.value = false;
|
||||
businessLicenseUrl.value = reader.result; // 保存预览URL
|
||||
newFormData.value.businessLicense = reader.result; // 保存到表单数据
|
||||
await nextTick();
|
||||
};
|
||||
reader.readAsDataURL(file[0].file);
|
||||
const beforeUpload = async (file) => {
|
||||
debugger
|
||||
showUpload.value = false; // 先隐藏上传区域,显示加载状态
|
||||
|
||||
try {
|
||||
// 调用上传接口
|
||||
const response = await uploadImage(file[0].file);
|
||||
if (response.data.code === 200) {
|
||||
const imageUrl = response.data.data; // 获取上传后的图片地址
|
||||
businessLicenseUrl.value = imageUrl;
|
||||
newFormData.value.businessLicenseUrl = imageUrl; // 保存到表单数据
|
||||
Message.success('图片上传成功');
|
||||
} else {
|
||||
showUpload.value = true; // 上传失败,恢复上传区域
|
||||
Message.error(response.data.msg || '图片上传失败');
|
||||
}
|
||||
} catch (error) {
|
||||
showUpload.value = true; // 网络错误,恢复上传区域
|
||||
Message.error('图片上传网络失败,请重试');
|
||||
console.error('图片上传异常:', error);
|
||||
}
|
||||
|
||||
return false; // 阻止默认上传行为
|
||||
};
|
||||
|
||||
const handleDel = () => {
|
||||
showUpload.value = true;
|
||||
businessLicenseUrl.value = '';
|
||||
newFormData.value.businessLicense = ''; // 清空表单数据
|
||||
newFormData.value.businessLicenseUrl = ''; // 清空表单数据
|
||||
};
|
||||
|
||||
// 暴露给父组件的方法
|
||||
@@ -241,9 +258,9 @@ function open(initialData = {}) {
|
||||
Object.assign(newFormData.value, initialData);
|
||||
|
||||
// 如果有营业执照数据,显示预览
|
||||
if (initialData.businessLicense) {
|
||||
if (initialData.businessLicenseUrl) {
|
||||
showUpload.value = false;
|
||||
businessLicenseUrl.value = initialData.businessLicense;
|
||||
businessLicenseUrl.value = initialData.businessLicenseUrl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +283,7 @@ function resetForm() {
|
||||
website: '',
|
||||
industry: '',
|
||||
introduction: '',
|
||||
businessLicense: '',
|
||||
businessLicenseUrl: '',
|
||||
contactEmail: '',
|
||||
contactName: '',
|
||||
contactPhone: '',
|
||||
@@ -280,18 +297,41 @@ function resetForm() {
|
||||
formRef.value?.resetFields();
|
||||
}
|
||||
|
||||
const emits = defineEmits(['refresh'])
|
||||
// 提交表单
|
||||
const handleConfirm = () => {
|
||||
formRef.value.validate((isValid, invalidFields) => {
|
||||
const handleConfirm = async () => {
|
||||
formRef.value.validate(async (isValid, invalidFields) => {
|
||||
if (isValid) {
|
||||
// 表单验证通过,处理提交逻辑
|
||||
console.log('提交表单数据:', newFormData.value);
|
||||
// 构造请求参数(过滤掉空值和非必填字段)
|
||||
const requestData = {
|
||||
applicant: newFormData.value.applicant,
|
||||
userName: userName,
|
||||
enterpriseName: newFormData.value.enterpriseName,
|
||||
creditCode: newFormData.value.creditCode,
|
||||
website: newFormData.value.website || undefined, // 非必填,空值转为undefined
|
||||
industry: newFormData.value.industry,
|
||||
introduction: newFormData.value.introduction || undefined, // 非必填
|
||||
contactName: newFormData.value.contactName,
|
||||
contactEmail: newFormData.value.contactEmail || undefined, // 非必填
|
||||
contactPhone: newFormData.value.contactPhone,
|
||||
businessLicenseUrl: newFormData.value.businessLicenseUrl,
|
||||
};
|
||||
|
||||
// 这里应该调用实际的API
|
||||
// await submitEnterpriseData(newFormData.value);
|
||||
|
||||
Message.success('提交成功');
|
||||
close();
|
||||
try {
|
||||
// 调用新增接口
|
||||
const response = await addEnterprise(requestData);
|
||||
if (response.data.code === 200) {
|
||||
Message.success('企业认证添加成功');
|
||||
close(); // 关闭模态框
|
||||
// 通知父组件刷新列表(可通过事件实现)
|
||||
emits('refresh');
|
||||
} else {
|
||||
Message.error(response.data.msg || '添加失败,请重试');
|
||||
}
|
||||
} catch (error) {
|
||||
Message.error('网络请求失败,请检查网络连接');
|
||||
console.error('新增接口异常:', error);
|
||||
}
|
||||
} else {
|
||||
// 显示第一个错误字段的提示
|
||||
const firstError = Object.values(invalidFields)[0]?.[0]?.message;
|
||||
|
||||
Reference in New Issue
Block a user