register.vue 16 KB

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