register.vue 17 KB

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