Login.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. <template>
  2. <div class="content">
  3. <div class="main">
  4. <!-- 待办 头部 -->
  5. <div class="todoContain">
  6. <a-card title="待办" style="width: 100%" class="todoTitle">
  7. <template #extra>
  8. <a @click.stop.prevent="todo()" class="more">
  9. <span>更多</span>
  10. </a>
  11. </template>
  12. <!-- 无 待办 -->
  13. <span v-if="todoList.length == 0">
  14. <div class="nothing">
  15. <img src="@assets/noOne.png" alt="?????" class="nothingImg" />
  16. <p>暂无代办</p>
  17. </div>
  18. </span>
  19. <!-- 待办 -->
  20. <span v-if="todoList.length > 0">
  21. <div class="haveSomething">
  22. <img src="@assets/haveSomething.png" alt="?????" class="haveSomethingImg" />
  23. <p>
  24. 我的待办
  25. <a-badge class="numTips">{{ todoList.length }}</a-badge>
  26. </p>
  27. </div>
  28. </span>
  29. </a-card>
  30. </div>
  31. <!-- OA工作台 -->
  32. <div class="oaContain">
  33. <a-card title="OA工作台" style="width: 100%" class="oaTitle">
  34. <div class="oaButton">
  35. <a
  36. class="oaItem"
  37. v-for="(item, index) in activeKeyAll"
  38. :key="index.id"
  39. @click.prevent="aClick(item)"
  40. >
  41. <span>
  42. <img :src="item.iconAddress" />
  43. </span>
  44. <p>{{ item.name }}</p>
  45. </a>
  46. </div>
  47. </a-card>
  48. </div>
  49. <!-- 其他弹框 -->
  50. <a-modal
  51. v-model="lcModal.visible"
  52. :title="lcModal.Title"
  53. :footer="null"
  54. :maskClosable="false"
  55. >
  56. <component
  57. :disabled="lcModal.disabled"
  58. v-if="lcModal.visible"
  59. :is="lcModal.formComponent"
  60. :processData="lcModal.processData"
  61. :isNew="lcModal.isNew"
  62. @afterSubmit="afterSub"
  63. @close=";(lcModal.visible = false), (lcModal.disabled = false)"
  64. ></component>
  65. </a-modal>
  66. </div>
  67. <a-modal
  68. title="登录公司选择"
  69. :width="450"
  70. :visible="departVisible"
  71. :closable="false"
  72. :maskClosable="false"
  73. >
  74. <template slot="footer">
  75. <a-button type="primary" @click="departOk">确认</a-button>
  76. </template>
  77. <a-form>
  78. <!-- <a-form-item
  79. :labelCol="{span:4}"
  80. :wrapperCol="{span:20}"
  81. style="margin-bottom:10px"
  82. :validate-status="validate_status">
  83. <a-tooltip placement="topLeft" >
  84. <template slot="title">
  85. <span>您隶属于多部门,请选择登录部门</span>
  86. </template>
  87. <a-avatar style="backgroundColor:#87d068" icon="gold" />
  88. </a-tooltip>
  89. <a-select @change="departChange" :class="{'valid-error':validate_status=='error'}" placeholder="请选择登录部门" style="margin-left:10px;width: 80%">
  90. <a-icon slot="suffixIcon" type="gold" />
  91. <a-select-option
  92. v-for="d in departList"
  93. :key="d.id"
  94. :value="d.orgCode">
  95. {{ d.departName }}
  96. </a-select-option>
  97. </a-select>
  98. </a-form-item>-->
  99. <a-form-item
  100. :labelCol="{span:4}"
  101. :wrapperCol="{span:20}"
  102. style="margin-bottom:10px"
  103. :validate-status="validate_status"
  104. >
  105. <a-tooltip placement="topLeft">
  106. <template slot="title">
  107. <span>您隶属于多公司,请选择登录公司</span>
  108. </template>
  109. <a-avatar style="backgroundColor:#87d068" icon="gold" />
  110. </a-tooltip>
  111. <a-select
  112. @change="departChange"
  113. :class="{'valid-error':validate_status=='error'}"
  114. placeholder="请选择登录公司"
  115. style="margin-left:10px;width: 80%"
  116. >
  117. <a-icon slot="suffixIcon" type="gold" />
  118. <a-select-option v-for="d in orgList" :key="d.id" :value="d.id">{{ d.departName }}</a-select-option>
  119. </a-select>
  120. </a-form-item>
  121. </a-form>
  122. </a-modal>
  123. <!-- 底部 -->
  124. <a-layout-footer class="footer">上海萃颠信息科技有限公司出品</a-layout-footer>
  125. </div>
  126. </template>
  127. <script>
  128. // 组件中使用映射,所以需要导入
  129. import { mapActions } from 'vuex'
  130. import Vue from 'vue'
  131. import { ACCESS_TOKEN, ENCRYPTED_STRING, USER_INFO } from '@/store/mutation-types'
  132. import api from '@/api'
  133. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  134. import { activitiMixin } from '@/views/activiti/mixins/activitiMixin'
  135. import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep'
  136. import { getCode } from '../../utils/dingding'
  137. import { putAction, postAction, getAction } from '@/api/manage'
  138. import store from '@/store/'
  139. export default {
  140. loading: true,
  141. name: 'Login',
  142. components: {},
  143. data() {
  144. return {
  145. orgList: [],
  146. validate_status: '',
  147. departVisible: false,
  148. todoList: [],
  149. activeKeyAll: [],
  150. url: {
  151. todoList: '/actTask/todoList',
  152. doneList: '/actTask/doneList'
  153. },
  154. //按钮弹框
  155. lcModal: {
  156. title: '',
  157. visible: false,
  158. disabled: false,
  159. formComponent: null,
  160. isNew: false
  161. },
  162. isshow: '0'
  163. }
  164. },
  165. // 页面打开时,默认已登录
  166. created() {
  167. Vue.ls.remove(ACCESS_TOKEN)
  168. //钉钉免登录
  169. //获取临时授权码
  170. getCode(code => {
  171. //登录
  172. // 异步操作
  173. this.dingLogin({ code: code })
  174. .then(res => {
  175. const userInfo = res.result.userInfo
  176. Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
  177. store.commit('SET_INFO', userInfo)
  178. if (userInfo) {
  179. this.getDataList() // 待办、已办 列表
  180. this.getActiveKeyAll() // OA 4个按钮
  181. }
  182. })
  183. .catch(err => {
  184. console.log(err)
  185. })
  186. })
  187. // 进入页面自动登录
  188. // this.autoLogin()
  189. // .then(res => {
  190. // this.getDataList() // 待办、已办 列表
  191. // })
  192. // .then(res => {
  193. // this.getActiveKeyAll() // OA 4个按钮
  194. // })
  195. },
  196. methods: {
  197. // init() {
  198. // this.getDataList()
  199. // },
  200. // 映射store/user.js 中 actions的方法
  201. ...mapActions(['Login', 'dingLogin']),
  202. // 自动登录
  203. async autoLogin() {
  204. var that = this
  205. let loginParams = {}
  206. loginParams.username = 'fenghf'
  207. loginParams.password = 'fenghf`123456'
  208. loginParams.slidered = true // 默认滑块
  209. // 异步操作
  210. await that
  211. .Login(loginParams)
  212. .then(res => {
  213. // this.departConfirm(res)
  214. console.log('Login拿到token | 登录上啦!')
  215. })
  216. .catch(err => {
  217. console.log(err)
  218. })
  219. },
  220. // 点击全部 跳转页面
  221. todo() {
  222. this.$router.push({ name: 'todo' })
  223. console.log(this.$router)
  224. },
  225. // 待办 num
  226. getDataList() {
  227. this.postFormAction(this.url.todoList, {}).then(res => {
  228. if (res.success) {
  229. this.todoList = res.result || []
  230. console.log('login 待办num:', this.todoList.length)
  231. if (this.todoList && this.todoList.length > 0) {
  232. this.isshow = '1'
  233. } else {
  234. this.isshow = '2'
  235. }
  236. }
  237. })
  238. },
  239. // 获取 OA 按钮
  240. getActiveKeyAll() {
  241. this.postFormAction('/activiti_process/listData', { status: 1, roles: true }).then(res => {
  242. this.activeKeyAll = []
  243. if (res.success) {
  244. var result = res.result || []
  245. if (result.length > 0) {
  246. this.activeKeyAll = result
  247. // this.activeKeyAll.push.apply(this.activeKeyAll,result);
  248. // console.log(this.activeKeyAll)
  249. console.log('OA 4个按钮被渲染')
  250. }
  251. }
  252. })
  253. },
  254. //OA图标点击事件
  255. aClick(v) {
  256. //点击的该项按钮
  257. console.log(v)
  258. // this.$refs.modal.add("1")
  259. if (!v.routeName) {
  260. this.$message.warning('该流程信息未配置表单,请联系开发人员!')
  261. return
  262. }
  263. if (v.routeName.indexOf('外部表单') != -1) {
  264. alert('调用其他项目页面')
  265. } else if (v.routeName.indexOf('自定义') != -1) {
  266. this.lcModal.disabled = false
  267. let com = { component: () => import(`@/views/activiti/form/demoForm2`) }
  268. this.lcModal.formComponent = com.component
  269. this.lcModal.title = '发起流程:' + v.name
  270. this.lcModal.isNew = true
  271. this.lcModal.processData = v
  272. this.lcModal.visible = true
  273. } else {
  274. this.lcModal.disabled = false
  275. this.lcModal.formComponent = this.getFormComponent(v.routeName).component
  276. this.lcModal.title = '发起流程:' + v.name
  277. this.lcModal.isNew = true
  278. this.lcModal.processData = v
  279. this.lcModal.visible = true
  280. }
  281. console.log('发起', v)
  282. // this.getDataList()
  283. },
  284. //提交后
  285. afterSub(formData) {
  286. this.lcModal.visible = false
  287. },
  288. departConfirm(res) {
  289. if (res.success) {
  290. console.log('用户信息', res)
  291. let multi_depart = res.result.multi_depart
  292. //0:无部门 1:一个部门 2:多个部门
  293. if (multi_depart == 0) {
  294. this.loginSuccess()
  295. this.$notification.warn({
  296. message: '提示',
  297. // description: `您尚未归属部门,请确认账号信息`,
  298. description: `您尚未归属公司,请确认账号信息`,
  299. duration: 3
  300. })
  301. } else if (multi_depart == 2) {
  302. this.departVisible = true
  303. // this.currentUsername = this.form.getFieldValue('username')
  304. this.currentUsername = res.result.userInfo.username
  305. this.departList = res.result.departs
  306. this.orgList = res.result.orgList
  307. console.log('公司', this.orgList)
  308. } else {
  309. console.log('登录')
  310. const userInfo = res.result.userInfo
  311. Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
  312. store.commit('SET_INFO', userInfo)
  313. this.loginSuccess()
  314. }
  315. } else {
  316. this.requestFailed(res)
  317. this.Logout()
  318. }
  319. },
  320. requestFailed(err) {
  321. this.$notification['error']({
  322. message: '登录失败',
  323. description: ((err.response || {}).data || {}).message || err.message || '请求出现错误,请稍后再试',
  324. duration: 4
  325. })
  326. this.loginBtn = false
  327. },
  328. departOk() {
  329. if (!this.departSelected) {
  330. this.validate_status = 'error'
  331. return false
  332. }
  333. let obj = {
  334. orgCode: this.departSelected,
  335. // username: this.form.getFieldValue('username')
  336. username: this.currentUsername
  337. }
  338. putAction('/sys/selectDepart', obj).then(res => {
  339. if (res.success) {
  340. const userInfo = res.result.userInfo
  341. Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
  342. store.commit('SET_INFO', userInfo)
  343. //console.log("---切换组织机构---userInfo-------",store.getters.userInfo.orgCode);
  344. this.departClear()
  345. // this.loginSuccess()
  346. } else {
  347. this.requestFailed(res)
  348. this.Logout().then(() => {
  349. this.departClear()
  350. })
  351. }
  352. })
  353. },
  354. departChange(value) {
  355. this.validate_status = 'success'
  356. this.departSelected = value
  357. },
  358. departClear() {
  359. this.departList = []
  360. this.departSelected = ''
  361. this.currentUsername = ''
  362. this.departVisible = false
  363. this.validate_status = ''
  364. this.orgList = []
  365. }
  366. }
  367. }
  368. </script>
  369. <style src="@assets/less/overwrite.less" lang="less" scoped></style>
  370. <style lang="less" scoped>
  371. /deep/.ant-card-head-title {
  372. margin-top: 14px;
  373. }
  374. /deep/.ant-card-body {
  375. padding: 30px 20px;
  376. }
  377. /deep/.ant-layout-header {
  378. line-height: 0;
  379. }
  380. /deep/.ant-card-head-title {
  381. font-size: 18px;
  382. }
  383. .content {
  384. width: 100%;
  385. height: 100%;
  386. .main {
  387. // OA 工作台
  388. .oaContain,
  389. .todoContain {
  390. border-radius: 10px;
  391. margin: 15px;
  392. background-color: #efeeee;
  393. .oaTitle,
  394. .todoTitle {
  395. font-size: 18px;
  396. font-weight: 700;
  397. border-radius: 10px;
  398. }
  399. .more {
  400. color: white;
  401. padding: 10px 20px;
  402. border-radius: 999em;
  403. border: transparent;
  404. background-color: rgba(37, 104, 239, 0.8);
  405. box-shadow: 10px 1px 10px rgba(0, 0, 0, 0.8);
  406. -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  407. -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  408. }
  409. .nothing,
  410. .haveSomething {
  411. text-align: center;
  412. .nothingImg,
  413. .haveSomethingImg {
  414. width: 150px;
  415. height: 150px;
  416. position: relative;
  417. }
  418. p {
  419. font-size: 14px;
  420. .numTips {
  421. margin-top: 10px;
  422. background-color: red;
  423. color: white;
  424. padding: 6px 8px;
  425. border-radius: 50%;
  426. }
  427. }
  428. }
  429. // 工作台按钮
  430. .oaButton {
  431. display: flex;
  432. flex-flow: row wrap;
  433. justify-content: space-between;
  434. text-align: center;
  435. //四个按钮
  436. .oaItem {
  437. width: calc((100% - 10px) / 4);
  438. display: flex;
  439. justify-content: space-around;
  440. flex-direction: column;
  441. align-items: center;
  442. // 图
  443. span {
  444. width: 70px;
  445. height: 70px;
  446. border: transparent;
  447. background-color: rgba(247, 239, 239, 0.3);
  448. box-shadow: 2px 8px 2px rgba(0, 0, 0, 0.8);
  449. -webkit-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.3);
  450. -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  451. border-radius: 10px;
  452. display: flex;
  453. align-items: center;
  454. justify-content: center;
  455. position: relative;
  456. img {
  457. width: 36px;
  458. height: 36px;
  459. }
  460. }
  461. // 文字
  462. p {
  463. font-size: 14px;
  464. margin-top: 16px;
  465. color: rgb(128, 127, 127);
  466. font-weight: 400;
  467. letter-spacing: 1px;
  468. }
  469. }
  470. }
  471. }
  472. }
  473. }
  474. </style>