addenterprise.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. <template>
  2. <div>
  3. <div class="tanchuang addspace" v-if="isadd">
  4. <div class="tc-conent"><img src="/static/img/qiye/dengji@1x.png" alt=""></div>
  5. <div class="tc-text"><span>添加企业成功</span></div>
  6. </div>
  7. <div>
  8. <div class="gs-worp qy-worp tj-up">
  9. <div class="qy-title" style="position: relative;">
  10. <ul class="over">
  11. <li class="left xs" v-for="(d, i) in tab" :key="i" :class= "{qyactive:nowindex == i}" @click="tabwatch(i)">{{d.name}}</li>
  12. </ul>
  13. </div>
  14. <div class="qy-conent" :class= "{showqiye:nowindex == 0}" style="padding-top: 60px;">
  15. <ul style="padding:0;text-align: center;">
  16. <li>
  17. <span class="qy-biaoti"><span class="xingxing">*</span>企业名称</span>
  18. <input autofocus class="inpind" ref="qyname" @change= "spaceName" type="text" placeholder="请填写企业全称">
  19. <div class="qy-Tips Tips-buttom"><span ref="qyno" style="color:red"></span></div>
  20. </li>
  21. <li>
  22. <span class="qy-biaoti">所属行业</span>
  23. <select ref="qyindustry" style="width:30%;height: 32px;padding-left:5px" name="selectAge" id="selectAge">
  24. <option value="">请选择所属行业</option>
  25. <option value="贸易零售">贸易零售</option>
  26. <option value="制造加工">制造加工</option>
  27. <option value="服务业">服务业</option>
  28. <option value="教育">教育</option>
  29. <option value="信息传媒">信息传媒</option>
  30. <option value="金融">金融</option>
  31. <option value="高新科技">高新科技</option>
  32. <option value="电子商务">电子商务</option>
  33. <option value="互联网">互联网</option>
  34. <option value="医疗服务">医疗服务</option>
  35. <option value="艺术娱乐">艺术娱乐</option>
  36. <option value="地产建筑">地产建筑</option>
  37. <option value="公共服务">公共服务</option>
  38. <option value="开采冶金">开采冶金</option>
  39. <option value="交通仓储">交通仓储</option>
  40. <option value="农林牧渔">农林牧渔</option>
  41. <option value="其他">其他</option>
  42. </select>
  43. </li>
  44. <li>
  45. <span class="qy-biaoti"><span class="xingxing">*</span>企业地址</span>
  46. <input ref="address" @change="address" class="inpind" type="text" placeholder="输入企业详细地址">
  47. <!-- <div class="addbiaoqian">
  48. <v-distpicker @selected= 'selected' @province= 'qyprovince' :placeholders= 'placeholder'></v-distpicker>
  49. <input ref="address" @change="address" class="qy-xiangxi" type="text" placeholder="输入企业详细地址">
  50. </div> -->
  51. <div class="qy-Tips Tips-buttom">
  52. <span ref="ress" style="color:red"></span>
  53. </div>
  54. </li>
  55. <li>
  56. <span class="qy-biaoti"><span class="xingxing">*</span>姓名</span>
  57. <input class="inpind" @change= "yzusername" ref="name" type="text" value="">
  58. <div class="qy-Tips Tips-buttom"><span ref="usname" style="color:red"></span></div>
  59. </li>
  60. <li><span class="qy-biaoti">手机号</span><span class="qy-mobile">{{mytoken.account.mobile}}</span></li>
  61. <li style="margin-bottom: 64px;">
  62. <span class="qy-biaoti">邮箱</span>
  63. <input class="inpind" @change="email" ref="email" type="email" value="">
  64. <div class="qy-Tips Tips-buttom"><span style="color:red" v-html="Email"></span></div>
  65. </li>
  66. <li>
  67. <div class="qy-anniu">
  68. <span @click= "Preservation" class="qy-xiugai dianji" style="left: 0;">保存</span>
  69. <span @click= "tjquxiao" class="qy-quxiao xs">取消</span>
  70. </div>
  71. </li>
  72. </ul>
  73. </div>
  74. <div class="qy-conent jr-conent" :class= "{showqiye:nowindex == 1}">
  75. <ul style="padding:0;position: relative;">
  76. <li>
  77. <span class="qy-biaoti"><span class="xingxing marght">*</span>查找企业</span>
  78. <input @input="Testingqyname" ref="lookupqyname" class="inpind" type="text" placeholder="输入企业名称或管理员">
  79. <span class="warning" ref="warningqyname"></span>
  80. </li>
  81. <!-- 匹配企业后显示的内容 -->
  82. <!-- <li v-if="isqylist" class="hied" :class= "{showlookup:islookup}"> -->
  83. <div class="lookup hied" :class= "{showlookup:islookup}">
  84. <ul>
  85. <li v-for="(d, i) in arr" :key="i" @click="qylist(i)" :class="{'hui':newindex === i}">
  86. <span>{{d.adminMobile}}</span>
  87. <span>{{d.admin}}</span>
  88. <span>{{d.name}}</span>
  89. </li>
  90. </ul>
  91. </div>
  92. <!-- </li> -->
  93. <li>
  94. <span class="qy-biaoti"><span class="xingxing marght">*</span>姓<span style="width:2em;display: inline-block;"></span>名</span>
  95. <input @blur.prevent="Testingname" class="inpind" maxlength="5" type="text" ref="lookupname" placeholder="输入真实姓名,待管理员审核">
  96. <span class="warning" ref="warningname"></span>
  97. </li>
  98. <li>
  99. <div class="qy-anniu" style="margin-top: 70px;">
  100. <span @click="Submission" class="qy-xiugai dianji" style="left: 0;">提交</span>
  101. <span @click= "tjquxiao" class="qy-quxiao xs">取消</span>
  102. </div>
  103. </li>
  104. </ul>
  105. </div>
  106. </div>
  107. </div>
  108. </div>
  109. </template>
  110. <script>
  111. import Session from '@/utils/session'
  112. // import VDistpicker from 'v-distpicker'
  113. import { setTimeout, clearTimeout } from 'timers';
  114. export default {
  115. data(){
  116. return {
  117. // province:'',//省
  118. // city:'',//市
  119. // area:'',//区
  120. qymingzi: false,//企业名是否注册
  121. Email: '',
  122. mytoken: Session.get(),//本地储存的用户信息
  123. reg: new RegExp(/[\@\#\$\%\&\*!!\¥]/),//非法字符
  124. regname:new RegExp(/[\@\#\$\%\&\*!!\¥0-9a-zA-Z]/),//非法字符加数字加英文
  125. isaddress: false,//公司地址验证
  126. isaddressname: false,//公司地址是否为空
  127. isname: true,//姓名验证
  128. isspaceName: false,//公司名验证
  129. isemail: true,//验证邮箱
  130. // disabled: true,
  131. isadd: false,//添加成功弹窗
  132. // placeholder:{province:"省", city:"市", area:"区"},
  133. // placeholde:{province:"", city:"", area:""},
  134. tab:[
  135. {name:'创建新企业'},
  136. {name:'加入企业'},
  137. ],
  138. nowindex:0,
  139. newindex:'',
  140. islookup:false,
  141. isTestingname:false,
  142. isregname:false,
  143. companyId:null,
  144. admin:null,
  145. isgsname:false,
  146. arr:[],
  147. times:null
  148. }
  149. },
  150. components:{
  151. // VDistpicker
  152. },
  153. mounted(){
  154. this.$refs.name.value = this.mytoken.account.realname;
  155. this.$refs.email.value = this.mytoken.account.email;
  156. },
  157. methods: {
  158. tabwatch(i){
  159. this.nowindex = i;
  160. },
  161. //取消添加企业
  162. tjquxiao(){
  163. document.documentElement.scrollTop = 0;
  164. this.$router.push({name:'company',});
  165. },
  166. //检测企业名称1
  167. spaceName(){
  168. let qyname = this.$refs.qyname.value.replace(/\s+/g, "");//公司名字过滤空格
  169. if(qyname == ''){
  170. this.$refs.qyno.innerHTML = ' <img style="width:14px" src="/static/img/warning.png" alt=""> 企业名称不能为空';
  171. } else {
  172. if (this.reg.test(qyname)) {
  173. this.$refs.qyno.innerHTML = ' <img style="width:14px" src="/static/img/warning.png" alt=""> 不能包含符号等非法字符';
  174. this.isspaceName = false;
  175. } else {
  176. this.$refs.qyno.innerHTML = '';
  177. this.isspaceName = true;
  178. let token = this.mytoken.token;
  179. this.$ajax({
  180. url: this.$url.api+"/api/account/accountCenter/checkSpaceName"+`?spaceName=${qyname}`,
  181. method :'get',
  182. headers: {
  183. "Authorization":token
  184. }
  185. })
  186. .then(res=>{
  187. if (res.data.data.success) {
  188. this.qymingzi = true;
  189. this.$refs.qyno.innerHTML = '<span style="color:green"><img style="width:14px" src="/static/img/ok.png" alt=""></span>';
  190. } else {
  191. this.$refs.qyno.innerHTML = ' <img style="width:14px" src="/static/img/warning.png" alt=""> 该企业已在优软云注册';
  192. this.qymingzi = false;
  193. }
  194. })
  195. }
  196. }
  197. },
  198. //检测企业名称2
  199. Testingqyname(){
  200. let qyname = this.$refs.lookupqyname.value.replace(/\s+/g, "");//企业名字
  201. let token = this.mytoken.token;
  202. clearTimeout(this.times);
  203. if(qyname == ''){
  204. this.$refs.warningqyname.innerHTML = '<img style="width:14px" src="/static/img/warning.png" alt=""> 企业或管理员不能为空';
  205. this.islookup = false;
  206. } else {
  207. this.times = setTimeout(()=>{
  208. this.$ajax({
  209. url: this.$url.api+"/api/account/accountCenter/company/isOpen",//http://192.168.253.41:8560
  210. method:'GET',
  211. params: {
  212. companyName: qyname
  213. },
  214. headers:{
  215. "Authorization":token,
  216. }
  217. })
  218. .then(res=>{
  219. if (res.data.success) {
  220. this.newindex = '';
  221. this.arr = res.data.data;
  222. this.$refs.warningqyname.innerHTML = '<img style="width:14px" src="/static/img/ok.png" alt="">';
  223. this.islookup = true;
  224. this.companyId = null;
  225. this.isgsname = true;//公司是否存在
  226. } else if (res.data.success == false && res.data.message == '公司不存在') {
  227. this.$refs.warningqyname.innerHTML = '<img style="width:14px" src="/static/img/warning.png" alt=""> 该企业不存在';
  228. this.islookup = false;
  229. this.isgsname = false;//公司是否存在
  230. } else {
  231. this.$message.error('请求失败,请重试');
  232. this.islookup = false;
  233. this.$refs.warningqyname.innerHTML = '<img style="width:14px" src="/static/img/warning.png" alt="">'
  234. }
  235. })
  236. },500)
  237. }
  238. },
  239. //验证个人姓名1
  240. yzusername(){
  241. let name = this.$refs.name.value.replace(/\s+/g, "");//姓名过滤空格
  242. if (name == '') {
  243. this.$refs.usname.innerHTML = '<img style="width:14px" src="/static/img/warning.png" alt=""> 个人姓名不能为空';
  244. } else {
  245. if (this.reg.test(name)) {
  246. this.$refs.usname.innerHTML = '<img style="width:14px" src="/static/img/warning.png" alt=""> 不能包含符号等非法字符';
  247. this.isname = false;
  248. } else {
  249. this.$refs.usname.innerHTML = '<img style="width:14px" src="/static/img/ok.png" alt="">';
  250. this.isname = true;
  251. }
  252. }
  253. },
  254. //验证个人姓名2
  255. Testingname(){
  256. let name = this.$refs.lookupname.value.replace(/\s+/g, "");//姓名过滤空格
  257. if (name == '') {
  258. this.$refs.warningname.innerHTML = '<img style="width:14px" src="/static/img/warning.png" alt=""> 姓名不能为空';
  259. this.isTestingname = false;
  260. } else {
  261. this.isTestingname = true;
  262. if (this.regname.test(name)) {
  263. this.$refs.warningname.innerHTML = '<img style="width:14px" src="/static/img/warning.png" alt=""> 姓名不能包含符号、数字、英文等非法字符';
  264. this.isregname = false;
  265. } else {
  266. this.$refs.warningname.innerHTML = '<img style="width:14px" src="/static/img/ok.png" alt="">';
  267. this.isregname = true;
  268. }
  269. }
  270. },
  271. // 选择要加入的企业
  272. qylist(i){
  273. this.companyId = this.arr[i].id,
  274. this.admin = this.arr[i].admin,
  275. this.newindex = i,
  276. this.$refs.lookupqyname.value = this.arr[i].name,
  277. this.islookup = false;
  278. if (this.admin == this.mytoken.account.realname) {
  279. this.$refs.warningqyname.innerHTML = '<img style="width:14px" src="/static/img/warning.png" alt=""> 账号已在企业服务中,不能重复加入';
  280. }
  281. },
  282. //加入企业提交按钮
  283. Submission(){
  284. let token = this.mytoken.token;
  285. let qyname = this.$refs.lookupqyname.value.replace(/\s+/g, "");//企业名字
  286. let username = this.$refs.lookupname.value.replace(/\s+/g, "");//姓名过滤空格
  287. if (qyname == '') {
  288. this.$message.error('企业或管理员不能为空');
  289. } else if(!this.isgsname) {
  290. this.$message.error('该企业不存在');
  291. } else if (!this.isTestingname) {
  292. this.$message.error('姓名不能为空');
  293. } else if (!this.isregname) {
  294. this.$message.error('姓名不能包含符号、数字等非法字符');
  295. } else if (this.companyId){
  296. if (this.admin == this.mytoken.account.realname) {
  297. this.$message.error('账号已在企业服务中,不能重复加入');
  298. } else {
  299. this.$ajax({
  300. url: this.$url.api+'/api/account/accountCenter/company/join',
  301. method:'POST',
  302. data:{
  303. username:username,
  304. accountId:this.mytoken.account.id,
  305. companyId:this.companyId,
  306. },
  307. headers:{
  308. "Authorization":token,
  309. }
  310. })
  311. .then(res=>{
  312. if (res.data.success) {
  313. this.$message.success('提交成功,待管理员批准加入');
  314. // this.$store.state.ishongdian = true;//显示红点
  315. setTimeout(()=>{
  316. this.$router.push({name:'company'});
  317. document.documentElement.scrollTop = 0;
  318. },3000)
  319. } else {
  320. this.$message.error(res.data.message);
  321. }
  322. })
  323. }
  324. } else {
  325. this.$message.error('请选择要加入的企业');
  326. }
  327. },
  328. //验证公司详细地址
  329. address(){
  330. let address = this.$refs.address.value.replace(/\s+/g, "");//过滤空格
  331. if (address == '') {
  332. this.$refs.ress.innerHTML = '<img style="width:14px" src="/static/img/warning.png" alt=""> 企业地址不能为空';
  333. this.isaddressname = false;
  334. } else {
  335. this.isaddressname = true;
  336. if (this.reg.test(address)) {
  337. this.$refs.ress.innerHTML = '<img style="width:14px" src="/static/img/warning.png" alt=""> 不能包含符号等非法字符';
  338. this.isaddress = false;
  339. } else {
  340. this.$refs.ress.innerHTML = '<img style="width:14px" src="/static/img/ok.png" alt="">';
  341. this.isaddress = true;
  342. }
  343. }
  344. },
  345. email(){
  346. let reg = new RegExp("^[a-z0-9A-Z]+[- | a-z0-9A-Z . _]+@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-z]{2,}$");
  347. let email = this.$refs.email.value;//邮箱
  348. if (email == '') {
  349. this.isemail = true;
  350. this.Email = '';
  351. } else {
  352. if (!reg.test(email)) {
  353. this.Email = '<img style="width:14px" src="/static/img/warning.png" alt=""> 请填写正确的邮箱';
  354. this.isemail = false;
  355. } else {
  356. this.Email = '<img style="width:14px" src="/static/img/ok.png" alt="">';
  357. this.isemail = true;
  358. }
  359. }
  360. },
  361. //保存
  362. Preservation(){
  363. this.listLoading = true;
  364. let qyname = this.$refs.qyname.value.replace(/\s+/g, "");//公司名字
  365. let qyindustry = this.$refs.qyindustry.value;//所属行业
  366. let address = this.$refs.address.value.replace(/\s+/g, "");//公司详细地址
  367. let name = this.$refs.name.value.replace(/\s+/g, "");//个人姓名
  368. let email = this.$refs.email.value;//邮箱
  369. let token = this.mytoken.token;
  370. let uu = this.mytoken.account.uu;
  371. let mobile = this.mytoken.account.mobile;//手机号
  372. let company = {'name':qyname,'address':address,'type':qyindustry};
  373. let account = {'realname':name,'email':email,'mobile':mobile, 'uu':uu};
  374. // console.log('姓名',name)//个人姓名
  375. // console.log('企业',qyname)//企业姓名
  376. // console.log('企业名字',this.qymingzi)//企业有没有注册
  377. // console.log('企业地址',this.isaddress)//企业地址
  378. // console.log('姓名',this.isname)//个人姓名正则
  379. // console.log('企业名字',this.isspaceName)//企业名字正则
  380. // console.log('邮箱',this.isemail)//邮箱正则
  381. if (name == '') {
  382. this.$message.error('个人姓名不能为空');
  383. } else if (qyname == '') {
  384. this.$message.error('企业名称不能为空');
  385. } else {
  386. switch (this.isspaceName && this.isaddress && this.isname && this.qymingzi && this.isemail && this.isaddressname) {
  387. case this.isspaceName:
  388. if (this.isspaceName) {
  389. this.$ajax({
  390. url: this.$url.api+"/api/account/accountCenter/companyAccount/save",//http://192.168.253.31:8560
  391. method: 'post',
  392. data: {
  393. companyRegDTO:company,
  394. accountRegDTO:account,
  395. type: 0
  396. },
  397. headers: {
  398. "Authorization":token,
  399. }
  400. })
  401. .then(res=>{
  402. this.isadd = true;//添加成功弹窗
  403. setTimeout(()=>{
  404. document.documentElement.scrollTop = 0;
  405. let session = Session.get();
  406. session.account.realname = name;
  407. Session.set(session);
  408. // this.$router.push({name:'company'})
  409. this.$router.push({path: '/enterprise'});
  410. },3000)
  411. })
  412. this.$message.success('保存成功,待管理员批准');
  413. } else {
  414. this.$message.error('企业名称不能包含符号等非法字符');
  415. }
  416. break;
  417. case this.qymingzi:
  418. this.$message.error('该企业已在优软云注册');
  419. break;
  420. case this.isaddressname:
  421. this.$message.error('企业地址不能为空');
  422. break;
  423. case this.isaddress:
  424. this.$message.error('企业地址不能包含符号等非法字符');
  425. break;
  426. case this.isname:
  427. this.$message.error('个人姓名不能包含符号等非法字符');
  428. break;
  429. case this.isemail:
  430. this.$message.error('请填写正确的邮箱');
  431. break;
  432. }
  433. }
  434. this.listLoading = false;
  435. },
  436. //获取省市区
  437. // selected(data){
  438. // this.province = data.province.value;
  439. // this.city = data.city.value;
  440. // this.area = data.area.value;
  441. // this.disabled= false
  442. // },
  443. // qyprovince(){
  444. // this.placeholder = this.placeholde
  445. // },
  446. }
  447. }
  448. </script>
  449. <style scoped>
  450. .addspace {
  451. height: 200px;
  452. border: 1px solid #cccccc
  453. }
  454. .tj-up {
  455. width: 100%;
  456. margin-bottom: 0px;
  457. padding-bottom: 1px;
  458. border-radius: 4px 4px 0 0;
  459. /* margin-top: -30px; */
  460. }
  461. .tj-up li {
  462. margin-bottom: 26px;
  463. }
  464. .tj-down {
  465. width: 100%;
  466. border-top: 0;
  467. margin-bottom: 100px;
  468. }
  469. .tj-down li {
  470. margin-bottom: 26px;
  471. }
  472. .tj-down div:nth-child(2) {
  473. margin-bottom: 70px;
  474. }
  475. .addbiaoqian>>>.distpicker-address-wrapper select {
  476. height: 30px;
  477. }
  478. .addbiaoqian>>>.distpicker-address-wrapper {
  479. width: 130%;
  480. margin-bottom: 10px;
  481. }
  482. .qy-Tips {
  483. margin: 0;
  484. text-align: left;
  485. height: 26px;
  486. display: inline-block;
  487. position: absolute;
  488. margin-left: 10px;
  489. }
  490. .Tips-buttom {
  491. /* margin-left: 22%; */
  492. }
  493. .inpind {
  494. padding-left: 10px;
  495. }
  496. .qyactive {
  497. border-bottom: 3px solid #1E88F5;
  498. }
  499. .qy-conent {
  500. display: none;
  501. }
  502. .showqiye {
  503. display: block !important;
  504. }
  505. .warning {
  506. color: red;
  507. margin-left: 25px;
  508. font-size: 12px;
  509. position: absolute;
  510. display: inline-block;
  511. width: 150px;
  512. text-align: left;
  513. text-indent: -16px;
  514. }
  515. .warning img {
  516. width: 14px;
  517. }
  518. .marght {
  519. margin-right: 5px;
  520. }
  521. .hui {
  522. background: #c5c5c5 !important;
  523. }
  524. .lookup > ul > li:hover {
  525. background: #f5f4f4
  526. }
  527. .lookup > ul {
  528. max-height: 170px;
  529. overflow-y: scroll;
  530. }
  531. .qy-mobile {
  532. display: inline-block;
  533. width: 30%;
  534. text-align: left;
  535. }
  536. .qy-anniu > span {
  537. margin-left: 40px;
  538. }
  539. </style>