register.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <template>
  2. <div class="login-box py-5">
  3. <v-card class="pa-5" :class="isMobile? 'mobileBox' : 'default-width'" :elevation="isMobile? '0' : '3'">
  4. <!-- 标题 -->
  5. <div class="mt-3" v-if="!isMobile">
  6. <v-btn v-if="pageType !== 'noLoginToRegister'" color="primary" variant="text" @click="router.push('/recruitHome')">{{ `<< 回到首页` }}</v-btn>
  7. <v-btn v-else color="primary" variant="text" @click="router.push('/login')">{{ `<< 回到登录页` }}</v-btn>
  8. </div>
  9. <!-- 表单 -->
  10. <div class="CtFormClass" :style="{width: isMobile ? '' : '600px'}">
  11. <div v-if="failureReason" class="mb-8" style="color: red;">
  12. <span class="mr-5">《审核不通过》</span>
  13. <span>原因:{{ failureReason }}</span>
  14. </div>
  15. <!-- 标题 -->
  16. <div class="mb-10" :class="isMobile ? 'mt-0': 'mt-n8'" style="font-size: 22px; font-weight: bold; text-align: center;">{{ $t('enterprise.registeringNewEnterprise') }}</div>
  17. <CtForm ref="CtFormRef" :items="formItems" style="width: 100%;">
  18. <template #businessLicense>
  19. <!-- 上传照片 -->
  20. <div class="d-flex flex-column mb-6">
  21. <div style="color: var(--color-999);">
  22. <span v-if="!prepareValue" class="mr-1" style="color: var(--v-error-base);">*</span>
  23. <span>上传营业执照</span>
  24. <span>支持jpg、jpeg、png格式,图片大小不得超过10M</span>
  25. </div>
  26. <div class="file-box">
  27. <Img
  28. class="mt-3"
  29. tips="上传图片"
  30. :value="licenseUrl"
  31. :showSnackbar="false"
  32. @imgClick="showPreview = !showPreview"
  33. :showCursor="true"
  34. @success="handleUploadImg"
  35. @delete="handleDeleteImg"
  36. ></Img>
  37. </div>
  38. </div>
  39. </template>
  40. <template #contacts>
  41. <!-- 联系人 -->
  42. <v-btn class="mb-5" style="width: 100%; text-align: center;" variant="text" color="primary" prepend-icon="mdi-plus-box" @click="handleAddContact">添加联系人</v-btn>
  43. </template>
  44. </CtForm>
  45. <div class="note">
  46. <h4>注意事项:</h4>
  47. <span>企业名称为对外展示的企业名称,建议填写公司营业执照上的名称,请区分总公司和分公司</span>
  48. </div>
  49. </div>
  50. <div class="text-center">
  51. <!-- 提交 -->
  52. <v-btn
  53. :loading="loginLoading"
  54. color="primary" class="white--text my-8" min-width="350"
  55. @click="handleCommit"
  56. >
  57. {{ $t('common.complete') }}
  58. </v-btn>
  59. </div>
  60. </v-card>
  61. <PreviewImg v-if="showPreview" :current="current" :list="[licenseUrl]" @close="showPreview = !showPreview"></PreviewImg>
  62. <Loading :visible="loading"></Loading>
  63. <CtDialog :visible="showContactList" title="添加联系人" :footer="true" widthType="3" @close="showContactList = false" @submit="contactSubmit">
  64. <div style="min-height: 50vh;">
  65. <div>
  66. <div v-for="(item, index) in contactCopy" :key="index" class="contactItemCard">
  67. <div class="d-flex justify-space-between pb-2">
  68. <div class="mb-3 pl-3" style="font-size: 13px; color: 00897B; border-left: 5px solid #00897B;">{{ index ? '联系人' + index : '管理员' }}</div>
  69. <v-btn v-if="index" color="error" density="compact" variant="text" @click="delContact(index)">删除</v-btn>
  70. <div v-else style="font-size: 12px; color: #999">不可删除</div>
  71. </div>
  72. <TextUI v-model="item.contactName" :item="{...contactNameObj}"></TextUI>
  73. <TextUI v-model="item.phone" :item="{...phoneObj, disabled: (!index&&bossPhone !== '')}"></TextUI>
  74. <TextUI v-model="item.email" :item="{...emailObj}"></TextUI>
  75. <TextUI v-model="item.password" :item="{...passwordObj}"></TextUI>
  76. <TextUI v-model="item.passwordConfirm" :item="{...passwordConfirmObj}"></TextUI>
  77. </div>
  78. </div>
  79. <div class="d-flex flex-column align-center">
  80. <v-btn class="my-3" color="warning" variant="text" prepend-icon="mdi-plus-box" @click="addMore">继续添加联系人</v-btn>
  81. <span style="font-size: 13px; color: #999;">提示:信息确认无误后请点击下方提交按钮</span>
  82. </div>
  83. </div>
  84. </CtDialog>
  85. </div>
  86. </template>
  87. <script setup>
  88. defineOptions({name: 'enterprise-enterpriseRegister-register'})
  89. import CtForm from '@/components/CtForm'
  90. import Snackbar from '@/plugins/snackbar'
  91. import { useI18n } from '@/hooks/web/useI18n'
  92. import { useRouter } from 'vue-router'; const router = useRouter()
  93. import { enterpriseRegisterApply } from '@/api/personal/user'
  94. import { onMounted, ref, computed } from 'vue';
  95. import { checkEmail } from '@/utils/validate'
  96. import { getBusinessLicenseOCR } from '@/api/common'
  97. import Confirm from '@/plugins/confirm'
  98. import TextUI from '@/components/FormUI/TextInput'
  99. const { t } = useI18n()
  100. const CtFormRef = ref()
  101. const loginLoading = ref(false)
  102. // 图片预览
  103. const loading = ref(false)
  104. const showPreview = ref(false)
  105. const current = ref(0)
  106. const business = ref({})
  107. let licenseUrl = ref('')
  108. // const email = localStorage.getItem('loginAccount') && checkEmail(localStorage.getItem('loginAccount')) ? localStorage.getItem('loginAccount') : ''
  109. // 组件挂载后添加事件监听器
  110. const isMobile = ref(false)
  111. onMounted(() => {
  112. const userAgent = navigator.userAgent
  113. isMobile.value = /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(userAgent)
  114. })
  115. import { useRoute } from 'vue-router'; const route = useRoute()
  116. const pageType = route?.query?.type || '' // type: noLoginToRegister:->登录页注册企业
  117. const showContactList = ref(false)
  118. const contactInfo = { contactName: '', phone: '', email: '', password: '', passwordConfirm:'' }
  119. let contactList = [{ ...contactInfo }]
  120. const bossPhone = localStorage.getItem('userInfo') ? JSON.parse(localStorage.getItem('userInfo')).phone : ''
  121. contactList[0].phone = bossPhone // 管理员手机号不能改
  122. const contactCopy = ref([])
  123. // 注册信息保存
  124. const enterpriseRegisterInfo = ref(localStorage.getItem('enterpriseRegisterInfo') ? JSON.parse(localStorage.getItem('enterpriseRegisterInfo')) : {})
  125. const saveRegisterInfo = () => {
  126. const obj = {
  127. licenseUrl: licenseUrl.value,
  128. ocr: business.value
  129. }
  130. formItems.value.options.forEach(e => {
  131. if (e.key) obj[e.key] = e.value
  132. })
  133. obj.contactList = contactList
  134. localStorage.setItem('enterpriseRegisterInfo', JSON.stringify(obj))
  135. }
  136. const codeLabelTet = '企业统一社会信用代码(可从上传的营业执照自动识别)'
  137. // 是否筹建中
  138. const isPrepareChange = () => {
  139. const code = formItems.value.options.find(e => e.key === 'code')
  140. if (code) {
  141. code.label = prepareValue.value ? codeLabelTet : codeLabelTet + ' *'
  142. code.rules = prepareValue.value ? [] : [v => !!v || '请输入企业统一社会信用代码']
  143. }
  144. saveRegisterInfo()
  145. }
  146. const formItems = ref({
  147. options: [
  148. {
  149. type: 'ifRadio',
  150. key: 'prepare',
  151. value: false,
  152. label: '是否筹建中 *',
  153. width: 100,
  154. items: [
  155. { label: '是', value: true },
  156. { label: '否', value: false }
  157. ],
  158. change: isPrepareChange
  159. },
  160. {
  161. slotName: 'businessLicense'
  162. },
  163. {
  164. type: 'text',
  165. key: 'name',
  166. value: '',
  167. label: '企业名称(需要与营业执照完全一致,可从上传的营业执照自动识别)*',
  168. counter: 50,
  169. rules: [v => !!v || '请输入企业名称'],
  170. blur: saveRegisterInfo
  171. },
  172. {
  173. type: 'text',
  174. key: 'anotherName',
  175. value: '',
  176. label: '企业别称',
  177. counter: 50,
  178. blur: saveRegisterInfo
  179. },
  180. {
  181. type: 'text',
  182. key: 'code',
  183. value: '',
  184. counter: 18,
  185. label: codeLabelTet + ' *',
  186. rules: [v => !!v || '请输入企业统一社会信用代码'],
  187. blur: saveRegisterInfo
  188. },
  189. {
  190. slotName: 'contacts'
  191. },
  192. {
  193. type: 'textarea',
  194. key: 'description',
  195. value: '',
  196. clearable: true,
  197. resize: true,
  198. counter: 500,
  199. rows: 2,
  200. label: '备注/说明',
  201. blur: saveRegisterInfo
  202. },
  203. ]
  204. })
  205. // 是否筹建中
  206. const prepareValue = computed(() => {
  207. return formItems.value.options.find(e => e.key === 'prepare').value
  208. })
  209. // 识别营业执照图片
  210. const getOcr = async () => {
  211. loading.value = true
  212. try {
  213. const data = await getBusinessLicenseOCR(licenseUrl.value)
  214. if (data && Object.keys(data).length) {
  215. formItems.value.options.find(e => e.key === 'code').value = data.code
  216. formItems.value.options.find(e => e.key === 'name').value = data.name
  217. business.value = data
  218. saveRegisterInfo()
  219. } else {
  220. licenseUrl.value = ''
  221. Confirm(t('common.confirmTitle'), '营业执照图片识别失败,请重新上传清晰合法图片', { hideCancelBtn: true })
  222. }
  223. } catch (error) {
  224. licenseUrl.value = ''
  225. Confirm(t('common.confirmTitle'), error, { hideCancelBtn: true })
  226. } finally {
  227. loading.value = false
  228. }
  229. }
  230. // 上传
  231. const handleUploadImg = (url) => {
  232. licenseUrl.value = url
  233. if (licenseUrl.value) getOcr()
  234. }
  235. const handleDeleteImg = () => {
  236. licenseUrl.value = ''
  237. business.value = {}
  238. formItems.value.options.find(e => e.key === 'code').value = ''
  239. formItems.value.options.find(e => e.key === 'name').value = ''
  240. saveRegisterInfo()
  241. }
  242. // 提交 企业注册
  243. const handleCommit = async () => {
  244. const { valid } = await CtFormRef.value.formRef.validate()
  245. if (!valid) return
  246. const businessLicenseUrl = licenseUrl.value;
  247. if (!prepareValue.value && !businessLicenseUrl) return Snackbar.warning('请上传营业执照图片')
  248. if (!contactList || !contactList.length || !contactList[0].contactName) return Snackbar.warning('请添加联系人信息')
  249. const params = {
  250. businessLicenseUrl,
  251. prepare: prepareValue.value,
  252. }
  253. formItems.value.options.forEach(e => {
  254. if (e.key) params[e.key] = e.value
  255. })
  256. if (business.value && Object.keys(business.value).length) params.ocr = business.value
  257. // 联系人
  258. params.contacts = contactList
  259. params.contactName = contactList[0].contactName
  260. params.phone = contactList[0].phone
  261. params.email = contactList[0].email
  262. await enterpriseRegisterApply(params)
  263. localStorage.removeItem('loginAccount')
  264. localStorage.removeItem('enterpriseRegisterInfo')
  265. Snackbar.success(t('common.submittedSuccessfully'))
  266. router.push({ path: '/recruit/entRegister/inReview' })
  267. }
  268. // 不通过的企业注册申请 重新发起
  269. const failureReason = ref('')
  270. const info = JSON.parse(localStorage.getItem('userApplyInfo'))
  271. // 审核不通过的数据回显
  272. if (info && Object.keys(info).length && info.status === '2') {
  273. failureReason.value = info?.reason || ''
  274. licenseUrl.value = info?.businessLicenseUrl
  275. contactList = info?.contacts.map(e => {
  276. e.passwordConfirm = e.password
  277. return e
  278. }) || [{ ...contactInfo }]
  279. // prepareValue.value = info?.prepare || false
  280. formItems.value.options.forEach(e => {
  281. // if (e.key === 'passwordConfirm') e.value = info.password
  282. // else e.value = info[e.key]
  283. e.value = info[e.key]
  284. })
  285. isPrepareChange()
  286. } else {
  287. // 表单信息保存
  288. if (enterpriseRegisterInfo.value && Object.keys(enterpriseRegisterInfo.value).length) {
  289. licenseUrl.value = enterpriseRegisterInfo.value.licenseUrl
  290. business.value = enterpriseRegisterInfo.value?.ocr
  291. contactList = enterpriseRegisterInfo.value?.contactList || []
  292. formItems.value.options.forEach(e => {
  293. if (e.key === 'passwordConfirm') e.value = enterpriseRegisterInfo.value.password
  294. else e.value = enterpriseRegisterInfo.value[e.key]
  295. })
  296. isPrepareChange()
  297. }
  298. }
  299. // 多个联系人提交保存
  300. const contactSubmit = () => {
  301. let falseValueIndex = null
  302. let falseKey = null
  303. contactCopy.value.forEach((e, index) => {
  304. if (falseValueIndex !== null) return
  305. if (e && Object.keys(e).length) {
  306. Object.keys(e).forEach(key => {
  307. if (falseValueIndex !== null) return
  308. if (!e[key]) {
  309. falseValueIndex = index
  310. falseKey = key
  311. }
  312. })
  313. }
  314. if (e.password && e.passwordConfirm && e.password !== e.passwordConfirm) {
  315. falseValueIndex = index
  316. falseKey = 'compareFalse'
  317. }
  318. })
  319. const textList = {
  320. contactName: '姓名',
  321. phone: '联系电话',
  322. email: '企业邮箱',
  323. password: '登录密码',
  324. passwordConfirm: '登录密码',
  325. }
  326. if (falseValueIndex || falseValueIndex === 0) {
  327. //
  328. let text = ''
  329. if (falseKey === 'compareFalse') {
  330. text = falseValueIndex ? `【联系人${falseValueIndex}】两次输入的密码不一致` : `【管理员】两次输入的密码不一致`
  331. } else {
  332. text = falseValueIndex ? `请完善联系人${falseValueIndex}的【${textList[falseKey]}】` : `请完善管理员的【${textList[falseKey]}】`
  333. }
  334. Confirm(t('common.confirmTitle'), text, { hideCancelBtn: true })
  335. return
  336. }
  337. contactList = [...contactCopy.value]
  338. showContactList.value = false
  339. saveRegisterInfo()
  340. }
  341. const handleAddContact = () => {
  342. contactCopy.value = [...contactList]
  343. showContactList.value = true
  344. }
  345. const addMore = () => {
  346. contactCopy.value.push({...contactInfo})
  347. }
  348. const delContact = (index) => {
  349. Confirm('系统提示', `是否确认删除${index ? `联系人${index}` : '管理员'}?`).then(async () => {
  350. contactCopy.value.splice(index, 1)
  351. })
  352. }
  353. const contactNameObj = {
  354. type: 'text',
  355. key: 'contactName',
  356. value: '',
  357. label: '联系人姓名 *',
  358. rules: [v => !!v || '请输入联系人姓名'],
  359. }
  360. const phoneObj = {
  361. type: 'phoneNumber',
  362. key: 'phone',
  363. value: '',
  364. label: '联系电话 *',
  365. rules: [v => !!v || '请输入联系电话'],
  366. }
  367. const emailObj = {
  368. type: 'text',
  369. key: 'email',
  370. value: '',
  371. // value: email ? email : '',
  372. label: '企业邮箱 *(此邮箱将用于日后“登录邮箱”)',
  373. // label: '企业邮箱 * (此邮箱将作为企业登录的账号)',
  374. rules: [
  375. value => {
  376. if (value) return true
  377. return '请输入企业邮箱'
  378. },
  379. value => {
  380. if (checkEmail(value)) return true
  381. return '请输入正确的企业邮箱'
  382. }
  383. ],
  384. }
  385. const passwordObj = {
  386. type: 'password',
  387. key: 'password',
  388. value: '',
  389. password: true,
  390. appendInnerIcon: 'mdi-eye-off-outline',
  391. label: '账户登录密码 *',
  392. placeholder: '请输入账户登录密码',
  393. // appendInnerClick: handlePassword,
  394. rules: [
  395. value => {
  396. if (value) return true
  397. return '请输入账户登录密码'
  398. },
  399. value => {
  400. if (/^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{8,16}$/.test(value)) return true
  401. return '请输入8-16位数由数字、大小写字母组成的密码'
  402. }
  403. ],
  404. }
  405. const passwordConfirmObj = {
  406. type: 'password',
  407. key: 'passwordConfirm',
  408. value: '',
  409. password: true,
  410. appendInnerIcon: 'mdi-eye-off-outline',
  411. label: '请再次输入账户登录密码 *',
  412. placeholder: '请再次输入账户登录密码',
  413. // appendInnerClick: handleSecondConfirm,
  414. rules: [
  415. value => {
  416. if (value) return true
  417. return '请再次输入密码'
  418. },
  419. ],
  420. }
  421. </script>
  422. <style lang="scss" scoped>
  423. .CtFormClass {
  424. margin: 0 auto;
  425. }
  426. .note {
  427. color: var(--color-666);
  428. font-size: 14px;
  429. line-height: 32px;
  430. }
  431. .login-box {
  432. position: relative;
  433. width: 100%;
  434. height: 100%;
  435. background-image: url('https://minio.menduner.com/dev/menduner/login-banner.png');
  436. background-size: cover;
  437. }
  438. .file-box {
  439. display: flex;
  440. flex-wrap: wrap; /* 允许换行 */
  441. width: 100%; /* 设置容器宽度 */
  442. .file-item {
  443. height: 80px;
  444. width: 100px;
  445. border-radius: 5px;
  446. margin-right: 8px;
  447. margin-top: 12px;
  448. // border: 1px solid rgb(188, 188, 188);
  449. border: 1px solid rgba(188, 188, 188, 0.5);
  450. }
  451. .file-input-box {
  452. position: relative;
  453. border: 1px solid rgb(188, 188, 188);
  454. cursor: pointer;
  455. .icon {
  456. position: absolute;
  457. top: 45%;
  458. left: 50%;
  459. transform: translate(-50%, -50%);
  460. color: var(--color-999);
  461. }
  462. }
  463. // 验证是否为空
  464. .verifyAct {
  465. color: var(--v-error-base);
  466. border: 1px solid var(--v-error-base);
  467. .icon { color: var(--v-error-base); }
  468. }
  469. }
  470. .PrepareBox {
  471. margin-top: 74px;
  472. margin-left: 32px;
  473. }
  474. .mobileBox {
  475. width: calc(100vw - 16px);
  476. margin: 0 auto;
  477. .resume-header {
  478. margin-bottom: 12px;
  479. }
  480. }
  481. .contactItemCard {
  482. background-color: var(--default-bgc);
  483. border-radius: 8px;
  484. padding: 16px 24px;
  485. margin-bottom: 20px;
  486. }
  487. </style>