addenterprise.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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. <span class="tjtishi" ref="tjtishi"></span>
  8. <div>
  9. <div class="gs-worp qy-worp tj-up">
  10. <div class="qy-title" style="position: relative;">
  11. <span>完善企业信息</span>
  12. <div class="qy-anniu">
  13. <span @click= "Preservation" class="qy-xiugai dianji" style="left: -2px">保存</span>
  14. <span @click= "tjquxiao" class="qy-quxiao xs">取消</span>
  15. </div>
  16. </div>
  17. <div class="qy-conent">
  18. <ul>
  19. <li style="margin: 0">
  20. <span class="qy-biaoti"><span class="xingxing">*</span>公司名称</span>
  21. <input class="inpind" ref="qyname" @change= "spaceName" type="text">
  22. <dir class="qy-Tips"><span ref="qyno" style="color:red"></span></dir>
  23. </li>
  24. <li>
  25. <span class="qy-biaoti">所属行业</span>
  26. <select ref="qyindustry" style="width:59%;height: 30px;padding-left:5px" name="selectAge" id="selectAge">
  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. <option value="交通仓储">交通仓储</option>
  43. <option value="农林牧渔">农林牧渔</option>
  44. <option value="其他">其他</option>
  45. </select>
  46. </li>
  47. <li style="height:70px;">
  48. <span class="qy-biaoti left"><span class="xingxing">*</span>公司地址</span>
  49. <div class="addbiaoqian">
  50. <!-- <v-distpicker @province= 'qyprovince' @city= 'qycity' @area= 'qyarea'></v-distpicker> -->
  51. <v-distpicker @selected= 'selected'></v-distpicker>
  52. <input ref="address" @change="address" :disabled="disabled" class="qy-xiangxi" type="text" placeholder="输入企业详细地址">
  53. </div>
  54. <div class="qy-Tips left">
  55. <span ref="ress" style="color:red;margin-left:40px;"></span>
  56. </div>
  57. </li>
  58. </ul>
  59. </div>
  60. </div>
  61. <div class="gs-worp qy-worp tj-down">
  62. <div class="qy-title">
  63. <span>完善个人信息</span>
  64. </div>
  65. <div class="qy-conent">
  66. <ul>
  67. <li style="margin:0">
  68. <span class="qy-biaoti"><span class="xingxing">*</span>姓名</span>
  69. <input class="inpind" @change= "yzusername" ref="name" type="text" value="">
  70. <div class="qy-Tips Tips-buttom"><span ref="usname" style="color:red"></span></div>
  71. </li>
  72. <li><span class="qy-biaoti">手机号</span><span>{{mytoken.account.mobile}}</span></li>
  73. <li style='margin:0'>
  74. <span class="qy-biaoti">邮箱</span>
  75. <input class="inpind" @change="email" ref="email" type="email" value="">
  76. <div class="qy-Tips Tips-buttom"><span style="color:red">{{Email}}</span></div>
  77. </li>
  78. </ul>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </template>
  84. <script>
  85. import Session from '@/utils/session'
  86. import VDistpicker from 'v-distpicker'
  87. import { setTimeout } from 'timers';
  88. export default {
  89. data(){
  90. return {
  91. province:'',//省
  92. city:'',//市
  93. area:'',//区
  94. qymingzi: false,//企业名是否注册
  95. Email: '',
  96. mytoken: JSON.parse(localStorage.getItem('app-state-session')),//本地储存的用户信息
  97. reg: new RegExp(/[\@\#\$\%\&\*!\¥]/),//非法字符
  98. isaddress: false,//公司地址验证
  99. isaddressname: false,//公司地址是否为空
  100. isname: true,//姓名验证
  101. isspaceName: false,//公司名验证
  102. isemail: true,//验证邮箱
  103. disabled: true,
  104. isadd: false,//添加成功弹窗
  105. }
  106. },
  107. components:{
  108. VDistpicker
  109. },
  110. mounted(){
  111. this.$refs.name.value = this.mytoken.account.realname == this.mytoken.account.mobile ? '' : this.mytoken.account.realname
  112. this.$refs.email.value = this.mytoken.account.email
  113. },
  114. methods: {
  115. //取消添加企业
  116. tjquxiao(){
  117. document.documentElement.scrollTop = 0;
  118. this.$router.push({name:'company',});
  119. },
  120. //检测企业名称
  121. spaceName(){
  122. let qyname = this.$refs.qyname.value.replace(/\s+/g, "");//公司名字过滤空格
  123. if(qyname == ''){
  124. this.$refs.qyno.innerHTML = '企业名不能为空';
  125. } else {
  126. if (this.reg.test(qyname)) {
  127. this.$refs.qyno.innerHTML = '不能包含非法字符';
  128. this.isspaceName = false;
  129. } else {
  130. this.$refs.qyno.innerHTML = '';
  131. this.isspaceName = true;
  132. let token = this.mytoken.token;
  133. this.$ajax({
  134. url: this.$url.api+"/api/account/accountCenter/checkSpaceName"+`?spaceName=${qyname}`,
  135. method :'get',
  136. headers: {
  137. "Authorization":token
  138. }
  139. })
  140. .then(res=>{
  141. if (res.data.data.success) {
  142. this.qymingzi = true;
  143. } else {
  144. this.$refs.qyno.innerHTML = '该企业已在优软云注册';
  145. this.qymingzi = false
  146. }
  147. })
  148. .catch(err=>{
  149. // console.log("请求错误",err);
  150. })
  151. }
  152. }
  153. },
  154. //验证个人姓名
  155. yzusername(){
  156. let name = this.$refs.name.value.replace(/\s+/g, "");//姓名过滤空格
  157. if (name == '') {
  158. this.$refs.usname.innerHTML = '姓名不能为空'
  159. } else {
  160. if (this.reg.test(name)) {
  161. this.$refs.usname.innerHTML = '不能包含非法字符'
  162. this.isname = false
  163. } else {
  164. this.$refs.usname.innerHTML = ''
  165. this.isname = true
  166. }
  167. }
  168. },
  169. //验证公司详细地址
  170. address(){
  171. let address = this.$refs.address.value.replace(/\s+/g, "");//过滤空格
  172. if (address == '') {
  173. this.$refs.ress.innerHTML = '地址不能为空'
  174. this.isaddressname = false
  175. } else {
  176. this.isaddressname = true
  177. if (this.reg.test(address)) {
  178. this.$refs.ress.innerHTML = '不能包含非法字符'
  179. this.isaddress = false
  180. } else {
  181. this.$refs.ress.innerHTML = ''
  182. this.isaddress = true
  183. }
  184. }
  185. },
  186. email(){
  187. let reg = new RegExp("^[a-z0-9A-Z]+[- | a-z0-9A-Z . _]+@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-z]{2,}$");
  188. let email = this.$refs.email.value;//邮箱
  189. if (email == '') {
  190. this.isemail = true;
  191. this.Email = ''
  192. } else {
  193. if (!reg.test(email)) {
  194. this.Email = '请填写正确的邮箱';
  195. this.isemail = false
  196. } else {
  197. this.Email = '';
  198. this.isemail = true;
  199. }
  200. }
  201. },
  202. //保存
  203. Preservation(){
  204. let qyname = this.$refs.qyname.value.replace(/\s+/g, "");//公司名字
  205. let qyindustry = this.$refs.qyindustry.value;//所属行业
  206. let address = this.province+this.city+this.area+this.$refs.address.value.replace(/\s+/g, "");//公司详细地址
  207. let name = this.$refs.name.value.replace(/\s+/g, "");//个人姓名
  208. let email = this.$refs.email.value;//邮箱
  209. let mytoken = JSON.parse(localStorage.getItem('app-state-session'));
  210. let token = String(mytoken.token);
  211. let uu = mytoken.account.uu;
  212. let mobile = mytoken.account.mobile;//手机号
  213. let company = {'name':qyname,'address':address,'type':qyindustry};
  214. let account = {'realname':name,'email':email,'mobile':mobile, 'uu':uu}
  215. // console.log('姓名',name)//个人姓名
  216. // console.log('企业',qyname)//企业姓名
  217. // console.log('企业名字',this.qymingzi)//企业有没有注册
  218. // console.log('企业地址',this.isaddress)//企业地址
  219. // console.log('姓名',this.isname)//个人姓名正则
  220. // console.log('企业名字',this.isspaceName)//企业名字正则
  221. // console.log('邮箱',this.isemail)//邮箱正则
  222. if (name == '') {
  223. this.$refs.tjtishi.innerHTML = '个人姓名不能为空';
  224. } else if (qyname == '') {
  225. this.$refs.tjtishi.innerHTML = '企业名字不能为空';
  226. } else {
  227. switch (this.qymingzi && this.isaddress && this.isname && this.isspaceName && this.isemail && this.isaddressname) {
  228. case this.qymingzi:
  229. if (this.qymingzi) {
  230. this.$ajax({
  231. url: this.$url.api+"/api/account/accountCenter/companyAccount/save",//http://192.168.253.31:8560
  232. method: 'post',
  233. data: {
  234. companyRegDTO:company,
  235. accountRegDTO:account,
  236. type: 0
  237. },
  238. headers: {
  239. "Authorization":token,
  240. }
  241. })
  242. .then(res=>{
  243. let id = res.data.data;
  244. let logoUrl = null;
  245. let name = qyname;
  246. let addenterprise = {'id':id, 'logoUrl': logoUrl, 'name': name};
  247. let session = JSON.parse(window.localStorage.getItem('app-state-session'));
  248. session.account.companies.push(addenterprise);
  249. Session.set(session);
  250. this.isadd = true;
  251. setTimeout(()=>{
  252. document.documentElement.scrollTop = 0;
  253. this.$router.push({name:'company'})
  254. },1000)
  255. })
  256. this.$refs.tjtishi.innerHTML = '';
  257. } else {
  258. this.$refs.tjtishi.innerHTML = '企业名字已在优软云注册';
  259. }
  260. break;
  261. case this.isaddressname:
  262. this.$refs.tjtishi.innerHTML = '企业地址不能为空';
  263. break;
  264. case this.isaddress:
  265. this.$refs.tjtishi.innerHTML = '企业地址不能包含非法字符';
  266. break;
  267. case this.isname:
  268. this.$refs.tjtishi.innerHTML = '个人姓名不能包含非法字符';
  269. break;
  270. case this.isspaceName:
  271. this.$refs.tjtishi.innerHTML = '企业名字不能包含非法字符';
  272. break;
  273. case this.isemail:
  274. this.$refs.tjtishi.innerHTML = '请输入正确邮箱';
  275. break;
  276. }
  277. }
  278. },
  279. //获取省市区
  280. selected(data){
  281. this.province = data.province.value;
  282. this.city = data.city.value;
  283. this.area = data.area.value;
  284. this.disabled= false
  285. },
  286. }
  287. }
  288. </script>
  289. <style scoped>
  290. .tjtishi {
  291. color: red;
  292. display: block;
  293. text-align: center;
  294. height: 20px;
  295. }
  296. .addspace {
  297. height: 200px;
  298. border: 1px solid #cccccc
  299. }
  300. .tj-up {
  301. width: 100%;
  302. margin-bottom: 0px;
  303. border-bottom: 0;
  304. padding-bottom: 1px;
  305. border-radius: 4px 4px 0 0;
  306. /* margin-top: -30px; */
  307. }
  308. .tj-up li {
  309. margin-bottom: 26px;
  310. }
  311. .tj-down {
  312. width: 100%;
  313. border-top: 0;
  314. margin-bottom: 100px;
  315. }
  316. .tj-down li {
  317. margin-bottom: 26px;
  318. }
  319. .tj-down div:nth-child(2) {
  320. margin-bottom: 70px;
  321. }
  322. .addbiaoqian>>>.distpicker-address-wrapper select {
  323. height: 30px;
  324. }
  325. .addbiaoqian>>>.distpicker-address-wrapper {
  326. width: 110%
  327. }
  328. .qy-Tips {
  329. margin: 0;
  330. text-align: left;
  331. height: 26px;
  332. margin-left: 16%;
  333. }
  334. .Tips-buttom {
  335. margin-left: 22%;
  336. }
  337. .inpind {
  338. padding-left: 10px;
  339. }
  340. </style>