baseInfo.vue
9.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<template>
<div class="base_info_wrap">
<el-image class="top_bg" :src="getImage('info-bg.png', '/home')"></el-image>
<div class="info_wrap">
<div class="template_btn" @click="getTemplateAuth">获取授权书模板</div>
<div class="business_licence">
<el-row :gutter="20">
<el-col :span="12" class="upload_col">
<el-upload
action="/api/web/businessLicense/checkBusinessLicense"
:show-file-list="false"
:on-success="(response, uploadFile)=>handleAvatarSuccess(response, uploadFile, 'isUploadBusinessLicense', 'businessLicence')"
:before-upload="(rawFile)=>beforeAvatarUpload(rawFile, 'isUploadBusinessLicense')"
>
<div class="upload_wrap" v-loading="state.isUploadBusinessLicense">
<div class="bg_wrap">
<el-image class="upload_bg" :src="getImage('yyzz.png', '/home')"></el-image>
<img v-if="ruleForm.businessLicence" :src="ruleForm.businessLicence" class="licence" />
</div>
<div class="upload_btn">点击上传营业执照</div>
</div>
</el-upload>
</el-col>
<el-col :span="12" class="upload_col">
<el-upload
action="/api/web/oss/uploadFile"
:show-file-list="false"
:on-success="(response, uploadFile)=>handleAvatarSuccess(response, uploadFile, 'isUploadAuth', 'authorizeFile')"
:before-upload="(rawFile)=>beforeAvatarUpload(rawFile, 'isUploadAuth')"
:headers="{
authorization: state.token,
}"
>
<div class="upload_wrap" v-loading="state.isUploadAuth">
<div class="bg_wrap">
<el-image class="upload_bg" :src="getImage('auth.png', '/home')"></el-image>
<img v-if="ruleForm.authorizeFile" :src="ruleForm.authorizeFile" class="licence" />
</div>
<div class="upload_btn">点击上传授权书</div>
</div>
</el-upload>
</el-col>
</el-row>
</div>
<div class="info_form">
<el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-width="140px" label-position="left">
<el-form-item label="企业名称" prop="enterpriseName" class="info_form_item">
<el-input v-model="ruleForm.enterpriseName" placeholder="请输入企业名称"></el-input>
</el-form-item>
<el-form-item label="统一社会信用代码" prop="uscCode" class="info_form_item">
<el-input v-model="ruleForm.uscCode" placeholder="请输入统一社会信用代码"></el-input>
</el-form-item>
<el-form-item label="企业办公地址" prop="serviceAddress" class="info_form_item">
<el-input v-model="ruleForm.serviceAddress" placeholder="请输入企业办公地址"></el-input>
</el-form-item>
<el-form-item label="所属核心企业" prop="coreEnterprise" class="info_form_item">
<template v-for="item in ruleForm.coreEnterprise">
<span>{{item.companyName}}</span><br/>
</template>
<!--<el-select v-model="ruleForm.coreCompanyId" placeholder="请选择所属核心企业">
<el-option
v-for="item in coreCompanyList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>-->
</el-form-item>
</el-form>
</div>
<div class="info_btn_wrap">
<div class="info_btn">
<el-button type="primary" round :loading="loading" @click="linkTo" class="primary-btn" style="width: 100%">下一步</el-button>
</div>
</div>
</div>
<el-dialog v-model="state.dialogVisible" calss="template_dialog" width="80%" title="获取授权书模板" destroy-on-close :close-on-click-modal="false">
<el-form ref="templateFormRef" :model="templateForm" :rules="templateRules" label-position="top" label-width="auto">
<el-form-item prop="email" label="请输入用于接收授权书模板文件的电子邮箱:">
<el-input v-model="templateForm.email"></el-input>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button type="primary" @click="sendEmial">确定</el-button>
</span>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { CirclePlusFilled } from '@element-plus/icons-vue'
import type { UploadProps } from 'element-plus'
import router from "../../router/index";
import './../../assets/css/baseInfo.scss'
import getImage from './../../assets/getImage'
import * as api from "./../../interface/api"
import { formValidationForm } from "./../../utils/vaildation"
import { loginMain } from './../../store/index'
import { storeToRefs } from 'pinia';
let loginAct = loginMain()
let { getStoreToken } = storeToRefs(loginAct)
const arrowPath = ref("/product")
defineExpose({arrowPath})
let ruleForm = reactive({
enterpriseName: undefined,
uscCode: undefined,
serviceAddress: undefined,
businessLicence: undefined,
authorizeFile: undefined,
coreEnterprise: [],
})
let templateForm = reactive({
email: undefined
})
let loading = ref(false)
let rules = reactive<FormRules>({
enterpriseName: [
{ required: true, message: "请输入企业名称", trigger: ["blur","change"] }
],
uscCode: [
{ required: true, message: "请输入统一社会信用代码", trigger: ["blur","change"] }
],
serviceAddress: [
{ required: true, message: "请输入企业办公地址", trigger: ["blur","change"] }
]
})
let templateRules = reactive<FormRules>({
email: [
{ required: true, message: "请输入企业邮箱", trigger: ["blur","change"] },
{ validator: formValidationForm.Form().checkEmail_N, trigger: ["blur"] }
],
})
const ruleFormRef = ref<FormInstance>()
const templateFormRef = ref<FormInstance>()
let state = reactive({
dialogVisible: false,
isUploadBusinessLicense: false,
isUploadAuth: false,
token: getStoreToken.value,
})
const handleAvatarSuccess: UploadProps['onSuccess'] = ( response, uploadFile, isUpload, url ) => {
state[isUpload] = false
if (response.code == 2000) {
ElMessage.success('上传成功')
// state[url] = URL.createObjectURL(uploadFile.raw!)
if (isUpload == 'isUploadBusinessLicense') {
ruleForm[url] = response.data.businessLicenseUrl
ruleForm.enterpriseName = response.data.enterpriseName
ruleForm.uscCode = response.data.uniscid
ruleForm.serviceAddress = response.data.enterpriseAddress
ruleForm.coreEnterprise = response.data.coreEnterprise
}
if (isUpload == 'isUploadAuth') {
ruleForm[url] = response.data.path
}
} else {
ElMessage.error(response.msg)
}
}
const beforeAvatarUpload: UploadProps['beforeUpload'] = (rawFile, isUpload) => {
if (rawFile.type !== 'image/jpeg') {
ElMessage.error('文件的格式必须是JPG!')
return false
} else if (rawFile.size / 1024 / 1024 > 5) {
ElMessage.error('文件大小不能超过5M!')
return false
}
state[isUpload] = true
return true
}
let coreCompanyList = ref([
{
label: '北京大禹创联商贸有限公司',
value: 1
},
{
label: '青岛中和盛杰食品有限公司',
value: 2
}
])
let linkTo = () => {
ruleFormRef.value.validate((vaild, fileds) => {
if (vaild) {
if (ruleForm.businessLicence == undefined) {
ElMessage.error("请上传营业执照")
return
}
if (ruleForm.authorizeFile == undefined) {
ElMessage.error("请上传授权书")
return
}
api.realNameAuth(ruleForm).then(res=> {
ElMessage.success('提交成功')
router.push("/authResult")
})
}
})
}
let getTemplateAuth = () => {
state.dialogVisible = true
}
let sendEmial = () => {
templateFormRef.value.validate((vaild, fileds) => {
if (vaild) {
api.sendAuthLetterEmail(templateForm).then(res=> {
ElMessage.success("发送成功")
state.dialogVisible = false
templateFormRef.value.resetFields()
})
}
})
}
</script>
<style scoped>
</style>