company.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. <template>
  2. <div>
  3. <!-- 遮罩 -->
  4. <div class="zhezhao" v-if="issetDefault || isOpensaas || isNoopen || isokopensaas"></div>
  5. <!-- 设置默认弹窗 -->
  6. <div class="tanchuang szmoren" v-if="issetDefault">
  7. <div class="over"><img @click="guanbitc" class="right xs" src="/static/img/qiye/chahao.png" alt=""></div>
  8. <div v-if="isDefault">
  9. <div class="tc-text tc-queren"><span>是否确认设为默认企业?</span></div>
  10. <div class="tc-anniu">
  11. <button @click="setDefault">确认</button>
  12. <button @click="guanbitc">取消</button>
  13. </div>
  14. </div>
  15. <div v-else>
  16. <div class="tc-conent"><img src="/static/img/qiye/dengji@1x.png" alt=""></div>
  17. <div class="tc-text"><span>已设为默认企业</span></div>
  18. </div>
  19. </div>
  20. <!-- 开通sass服务弹窗 -->
  21. <div class="tanchuang ktsass" v-if="isOpensaas">
  22. <div class="over"><img @click="guanbitc" class="right xs" src="/static/img/qiye/chahao.png" alt=""></div>
  23. <div v-if="ktsass">
  24. <div class="tc-text tc-queren"><span>是否确认开通saas服务?</span></div>
  25. <div class="tc-anniu">
  26. <button @click="confirmSaas">确认</button>
  27. <button @click="guanbitc">取消</button>
  28. </div>
  29. </div>
  30. <div v-else>
  31. <div class="tc-text tc-conent"><span>开通成功</span></div>
  32. <div style="margin-top: 40px;"><span @click="showServeWin" class="gs-btn1 dianji">进入服务</span></div>
  33. </div>
  34. </div>
  35. <!-- 该企业已开通服务弹窗 -->
  36. <div class="tanchuang qy-yikaitong" v-if="isokopensaas" style="width: 493px;height: 264px;">
  37. <div class="over"><img @click="guanbitc" class="right xs" src="/static/img/qiye/chahao.png" alt=""></div>
  38. <div>
  39. <div class="tc-okkaitong"><span>该企业已开通服务</span></div>
  40. <div class="tc-context">
  41. <p>进入服务方式一:可通过添加企业中加入企业申请,待管理员批准通过</p>
  42. <p>进入服务方式二:联系管理员邀请加入</p>
  43. <p><span>saas服务管理员:</span><span>{{admin}}</span></p>
  44. <p><span>saas服务管理员手机号:</span><span>{{adminMobile}}</span></p>
  45. <p><span>saas服务管理员邮箱:</span><span></span></p>
  46. </div>
  47. </div>
  48. </div>
  49. <!-- 开通10个不能继续开通 -->
  50. <div class="tanchuang nokaitong" v-if="isNoopen">
  51. <div class="over"><img @click="guanbitc" class="right xs" src="/static/img/qiye/chahao.png" alt=""></div>
  52. <div>
  53. <div class="tc-conent"><img src="/static/img/qiye/buneng kaitong@1x.png" alt=""></div>
  54. <div class="tc-text">
  55. <p>您已开通了10个企业服务</p>
  56. <p>不能再继续开通服务</p>
  57. </div>
  58. </div>
  59. </div>
  60. <div class="gs-qiyebox over" ref="qiyebox" :class="isheigh ? 'heigh' : ''" style="padding-bottom: 50px;">
  61. <div class="gs-xiangqing dotted">
  62. <router-link to="/addenterprise">
  63. <div class="gs-tianja" @click= "addEnterprise">
  64. <img src="/static/img/Fill 1.png" alt="">
  65. <p>添加企业</p>
  66. </div>
  67. </router-link>
  68. </div>
  69. <div v-for="(d , i) in arr " :key="i" class="gs-xiangqing gs-list">
  70. <!-- 上 -->
  71. <div class="gs-shang">
  72. <el-dropdown v-if= "d.saas_" trigger="hover" size="mini" placement='bottom-start'>
  73. <img class="shezhi xs" src="/static/img/shezhi.png" alt="设置">
  74. <el-dropdown-menu slot="dropdown">
  75. <el-dropdown-item v-if = "d.default_">
  76. <span @click="hideDefaultWin(i)">取消默认</span>
  77. </el-dropdown-item>
  78. <el-dropdown-item v-else>
  79. <span @click="showDefaultWin(i)">设为默认</span>
  80. </el-dropdown-item>
  81. </el-dropdown-menu>
  82. </el-dropdown>
  83. <img v-if = "d.default_" class="gs-morenimg" src="/static/img/moren2x.png" alt="">
  84. </div>
  85. <!-- 中 -->
  86. <div class="gs-xqleft">
  87. <!-- 点击查看企业详情 -->
  88. <p class="gs-qynema"><span @click= "getEnterpriseInfo(d)" class="xs">{{d.name}}</span></p>
  89. </div>
  90. <!-- 下 -->
  91. <div class="gs-xqright over">
  92. <div v-if= "d.saas_" class="gs-xqright-left left" style="margin-top: 5%;width:67%">
  93. <p><span>管理员:</span>{{d.admin}}</p>
  94. <p><span>联系方式:</span>{{d.adminMobile}}</p>
  95. <!-- <p><span>开通日期:</span></p> -->
  96. </div>
  97. <div class="gs-border gs-xqright-right right">
  98. <span v-if= "d.saas_" class="gs-btn1 xs green" @click="selectServe(d.id)">进入服务</span>
  99. <span v-else @click="showOpenServeWin(d.id , i)" class="gs-btn1 kaitong xs blue">开通服务</span>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. <div style="text-align: center;">
  105. <el-pagination
  106. background
  107. :page-size= size
  108. @current-change="handleCurrentChange"
  109. layout="prev, pager, next"
  110. :total= list.length>
  111. </el-pagination>
  112. </div>
  113. </div>
  114. </template>
  115. <script>
  116. import Session from '@/utils/session'
  117. export default {
  118. data(){
  119. return {
  120. issetDefault: false,//设置默认
  121. isOpensaas: false,//开通saas弹窗
  122. isNoopen: false,//开通10个不能继续开通
  123. isokopensaas: false,//已开通服务
  124. index:0,
  125. saasid:null,
  126. saasindex:0,
  127. ktsass: true,//开通saas
  128. isDefault: true,//开通默认
  129. isAutoLogin: this.$store.state.isAutoLogin,
  130. mytoken: Session.get(),//本地储存的用户信息
  131. list: [],//企业列表信息
  132. arr:[],
  133. isheigh:false,//是否添加默认高度
  134. admin: '',
  135. adminMobile: '',
  136. size:11,
  137. }
  138. },
  139. computed :{
  140. setTokenPage() {
  141. return this.$url.web + '/set-token.html'
  142. },
  143. },
  144. watch:{
  145. list:function(){
  146. this.$nextTick(function(){
  147. this.boxheight();
  148. })
  149. }
  150. },
  151. created(){
  152. let mytoken = Session.get();
  153. let token = String(mytoken.token);
  154. //企业列表
  155. this.$store.state.isloading = true;
  156. this.$ajax({
  157. url: this.$url.api+"/api/account/accountCenter/company/list",//http://192.168.253.41:8560
  158. method: 'get',
  159. params: {
  160. mobile: mytoken.account.mobile
  161. },
  162. headers: {
  163. "Authorization":token,
  164. "Content-Type":"application/x-www-form-urlencoded"
  165. }
  166. })
  167. .then(res=>{
  168. this.$store.state.isloading = false;
  169. if (res.data.success) {
  170. const frame = window.frames[window.frames.length - 1];
  171. this.list = res.data.data.spaces;
  172. this.pagingtion(1,this.size);
  173. let enterprise = [];
  174. let qyname = [];
  175. for (let i = 0; i < this.list.length; i++) {
  176. qyname.push(this.list[i].name);
  177. window.sessionStorage.setItem('companyname',JSON.stringify(qyname))
  178. if (this.list[i].saas_) {
  179. let addenterprise = {'id':'', 'logoUrl': '', 'name': '','dcName':''};
  180. addenterprise.id = this.list[i].id;
  181. addenterprise.logoUrl = this.list[i].logoUrl || null;
  182. addenterprise.name = this.list[i].name;
  183. addenterprise.dcName = this.list[i].dcName || null;
  184. enterprise.push(addenterprise)
  185. }
  186. };
  187. let session = Session.get();
  188. if (enterprise.length != session.account.companies.length) {
  189. session.account.companies = enterprise;
  190. Session.set(session);
  191. };
  192. let hasCompany = res.data.data.hasDefaultCompany;
  193. let companyId = res.data.data.defaultCompanyId;
  194. let token = res.data.data.token.token;
  195. if (this.isAutoLogin) {
  196. if (hasCompany) {
  197. let session = Session.get();
  198. session.account.companyId=companyId;
  199. session.span = session.timestamp - new Date().getTime();
  200. session.token=token;
  201. frame.postMessage(JSON.stringify(session), '*');
  202. window.location.href = this.$url.web
  203. }
  204. }
  205. this.$store.commit('Loginfalse')
  206. } else {
  207. this.$message.error('获取企业列表信息失败,请重试');
  208. }
  209. })
  210. .catch(err=>{
  211. // console.log("请求失败",err)
  212. })
  213. },
  214. mounted(){
  215. this.boxheight();
  216. },
  217. methods: {
  218. //分页
  219. handleCurrentChange(val){
  220. document.documentElement.scrollTop = 0;
  221. this.pagingtion(val,this.size);
  222. },
  223. //分页函数
  224. pagingtion(min,max){
  225. //定义一个空数组存放分割的数据
  226. this.arr = [];
  227. //对源数组进行分割
  228. let list = this.list.concat().splice(min * max - max, max);
  229. //循环插入新数组中进行展示
  230. for (let i = 0; i < list.length; i++) {
  231. this.arr.push(list[i]);
  232. }
  233. },
  234. //设置默认企业
  235. showDefaultWin(i){
  236. this.index = i;
  237. this.issetDefault = true;
  238. },
  239. //确认默认企业
  240. setDefault(){
  241. let i = this.index;
  242. let token = this.mytoken.token;
  243. this.$ajax({
  244. url: this.$url.api+'/api/account/accountCenter/bind/defaultCompany',
  245. method: 'post',
  246. data:{
  247. companyId: this.list[i].id,
  248. accountId: this.mytoken.account.id
  249. },
  250. headers: {
  251. "Authorization":token,
  252. }
  253. })
  254. .then(res=>{
  255. // console.log('请求成功',res);
  256. this.isDefault = false;
  257. this.$router.go(0);
  258. })
  259. },
  260. // 取消默认企业
  261. hideDefaultWin(i){
  262. this.$store.state.isloading = true;
  263. let token = this.mytoken.token;
  264. this.$ajax({
  265. url: this.$url.api+'/api/account/accountCenter/unBind/defaultCompany',
  266. method: 'post',
  267. data:{
  268. companyId: this.list[i].id,
  269. accountId: this.mytoken.account.id
  270. },
  271. headers: {
  272. "Authorization":token,
  273. }
  274. })
  275. .then(res=>{
  276. // this.$store.state.isloading = false;
  277. if (res.data.success) {
  278. this.$router.go(0);
  279. }
  280. })
  281. .catch(err=>{
  282. // console.log('请求失败',err);
  283. });
  284. },
  285. //进入服务
  286. selectServe(id){
  287. let token1 = this.mytoken.token;
  288. const frame = window.frames[window.frames.length - 1];
  289. this.$ajax({
  290. url: this.$url.api+'/api/auth/switch/company?companyId='+id,
  291. method :'get',
  292. headers: {
  293. "Authorization":token1
  294. }
  295. })
  296. .then(res=>{
  297. let mytoken = res.data.data.token;
  298. let session = Session.get();
  299. session.account.companyId=id;
  300. session.span = session.timestamp - new Date().getTime();
  301. session.token=mytoken;
  302. frame.postMessage(JSON.stringify(session), '*');
  303. window.location.href = this.$url.web
  304. })
  305. .catch(err=>{
  306. // console.log('请求失败',err)
  307. })
  308. },
  309. //开通saas服务开通数量达到10的时候禁止开通
  310. showOpenServeWin(id , i){
  311. let saasNum = [];
  312. let list = this.list;
  313. for (let j = 0; j < list.length; j++) {
  314. if (list[j].saas_) {
  315. saasNum.push(list[j].saas_)
  316. }
  317. }
  318. if (saasNum.length >= 10) {
  319. this.isNoopen = true;
  320. } else {
  321. this.isOpensaas = true;
  322. }
  323. this.saasindex = i;
  324. this.saasid = id;
  325. },
  326. confirmSaas(){//确认saas开通
  327. let i = this.saasindex;
  328. let token = this.mytoken.token;
  329. let qyname = this.list[i].name;//公司名字
  330. let address = this.list[i].address;//公司详细地址
  331. let name = this.list[i].realname;//名字
  332. let email = this.list[i].email;//邮箱
  333. let mobile = this.mytoken.account.mobile;//手机号
  334. let uu = this.list[i].uu;
  335. let company = {'name':qyname,'address':address};
  336. let account = {'realname':name,'email':email,'mobile':mobile, 'uu':uu}
  337. this.$ajax({
  338. url: this.$url.api+"/api/account/accountCenter/companyAccount/save",
  339. method: 'post',
  340. data: {
  341. companyRegDTO:company,
  342. accountRegDTO:account,
  343. type:1
  344. },
  345. headers: {
  346. "Authorization":token
  347. }
  348. })
  349. .then(res=>{
  350. // console.log('请求成功',res)
  351. if (res.data.success) {
  352. this.saasid = res.data.data;
  353. this.ktsass = false;
  354. let id = res.data.data;
  355. let name = qyname;
  356. let logoUrl = null;
  357. let addenterprise = {'id':id, 'logoUrl': logoUrl, 'name': name};
  358. let session = Session.get();
  359. session.account.companies.push(addenterprise);
  360. Session.set(session);
  361. this.$router.go(0);
  362. } else {
  363. let msg = res.data.message;
  364. let name = msg.split(" ")[1];
  365. this.admin = name.split('(')[0];
  366. this.adminMobile = name.split('(')[1].split(')')[0];
  367. this.isokopensaas = true;
  368. }
  369. })
  370. .catch(err=>{
  371. // console.log('请求失败',err)
  372. })
  373. },
  374. //进入saas服务
  375. showServeWin(){
  376. let id = this.saasid;
  377. this.isOpensaas = false;
  378. this.selectServe(id)
  379. },
  380. //查看企业详情
  381. getEnterpriseInfo(d){
  382. document.documentElement.scrollTop = 0;
  383. window.sessionStorage.setItem('content',JSON.stringify(d))
  384. this.$router.push({path:'/details'});
  385. },
  386. //添加企业
  387. addEnterprise(){
  388. document.documentElement.scrollTop = 0;
  389. },
  390. //关闭弹窗
  391. guanbitc(){
  392. this.issetDefault = false;
  393. this.isOpensaas = false;
  394. this.isNoopen = false;
  395. this.isokopensaas = false
  396. },
  397. //没有内容也要有一定的高度
  398. boxheight(){
  399. let H = this.$refs.qiyebox.offsetHeight;
  400. if (H < 500) {
  401. this.isheigh = true
  402. } else {
  403. this.isheigh = false
  404. }
  405. },
  406. }
  407. }
  408. </script>
  409. <style scoped>
  410. .heigh {
  411. height: 500px;
  412. }
  413. .gs-xqright {
  414. -webkit-user-select: none;
  415. -moz-user-select: none;
  416. -ms-user-select: none;
  417. -khtml-user-select: none;
  418. user-select: none;
  419. }
  420. .gs-morentop {
  421. position: absolute;
  422. margin-top: 0px;
  423. left: 5px;
  424. display: none;
  425. }
  426. .gs-list {
  427. background-image: url(/static/img/list.png);
  428. background-position-x: 50%;
  429. background-position-y: 84%;
  430. background-size: 157%;
  431. }
  432. .green:hover {
  433. background: #2da74a;
  434. }
  435. .blue:hover {
  436. background: #0f6fd2;
  437. }
  438. .tc-context > p {
  439. font-size: 14px;
  440. }
  441. .el-dropdown {
  442. line-height: 25px;
  443. }
  444. </style>