WHeader.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <template>
  2. <div class="w-header">
  3. <div v-if="tabActive" class="w-header-row">
  4. <div class="w-header-row-left">
  5. <ul>
  6. <li :class="tabActive==='todo'?'active':''">
  7. <a href="javascript:void(0)" @click="tabPage('todo')"><i class="ft icon">&#xe89e;</i>{{$L('待办')}}</a>
  8. </li><li :class="tabActive==='project'?'active':''">
  9. <a href="javascript:void(0)" @click="tabPage('project')"><i class="ft icon">&#xe6b8;</i>{{$L('项目')}}</a>
  10. </li><li :class="tabActive==='docs'?'active':''">
  11. <a href="javascript:void(0)" @click="tabPage('docs')"><i class="ft icon">&#xe915;</i>{{$L('知识库')}}</a>
  12. </li><li :class="tabActive==='team'?'active':''">
  13. <a href="javascript:void(0)" @click="tabPage('team')"><i class="ft icon">&#xe90d;</i>{{$L('团队')}}</a>
  14. </li>
  15. </ul>
  16. </div>
  17. <div class="w-header-row-right">
  18. <Dropdown class="right-info" trigger="click" @on-click="setRightSelect" placement="bottom-end" transfer>
  19. <div>
  20. <span class="username">{{$L('欢迎您')}}, {{(userInfo.nickname || userInfo.username) || $L('尊敬的会员')}}</span>
  21. <Icon type="md-arrow-dropdown"/>
  22. </div>
  23. <Dropdown-menu slot="list">
  24. <Dropdown-item name="user">{{$L('个人中心')}}</Dropdown-item>
  25. <Dropdown-item name="out">{{$L('退出登录')}}</Dropdown-item>
  26. </Dropdown-menu>
  27. </Dropdown>
  28. <div class="right-info" @click="chatDrawerShow=true">
  29. <Icon class="right-mticon" type="md-notifications" size="24"/>
  30. <em v-if="chatUnreadTotal > 0" class="right-info-num">{{chatUnreadTotal}}</em>
  31. </div>
  32. <Dropdown class="right-info" trigger="click" @on-click="setLanguage" transfer>
  33. <div>
  34. <Icon class="right-mticon" type="md-globe" size="24"/>
  35. <Icon type="md-arrow-dropdown"/>
  36. </div>
  37. <Dropdown-menu slot="list">
  38. <Dropdown-item name="zh" :selected="getLanguage() === 'zh'">中文</Dropdown-item>
  39. <Dropdown-item name="en" :selected="getLanguage() === 'en'">English</Dropdown-item>
  40. </Dropdown-menu>
  41. </Dropdown>
  42. </div>
  43. </div>
  44. <WDrawer v-model="userDrawerShow" maxWidth="1000">
  45. <Tabs v-model="userDrawerTab">
  46. <TabPane :label="$L('个人资料')" name="personal">
  47. <Form ref="formDatum" :model="formDatum" :rules="ruleDatum" :label-width="80">
  48. <FormItem :label="$L('头像')" prop="userimg">
  49. <ImgUpload v-model="formDatum.userimg"></ImgUpload>
  50. </FormItem>
  51. <FormItem :label="$L('账号')">
  52. <Input v-model="userInfo.username" :disabled="true"></Input>
  53. </FormItem>
  54. <FormItem :label="$L('昵称')" prop="nickname">
  55. <Input v-model="formDatum.nickname"></Input>
  56. </FormItem>
  57. <FormItem :label="$L('职位/职称')" prop="profession">
  58. <Input v-model="formDatum.profession"></Input>
  59. </FormItem>
  60. <FormItem>
  61. <Button :loading="loadIng > 0" type="primary" @click="handleSubmit('formDatum')">{{$L('提交')}}</Button>
  62. <Button :loading="loadIng > 0" @click="handleReset('formDatum')" style="margin-left: 8px">{{$L('重置')}}</Button>
  63. </FormItem>
  64. </Form>
  65. </TabPane>
  66. <TabPane :label="$L('偏好设置')" name="setting">
  67. <Form ref="formSetting" :model="formSetting" :label-width="100">
  68. <FormItem :label="$L('系统皮肤')" prop="bgid">
  69. <ul class="setting-bg">
  70. <li v-for="i in [1,2,3,4,5,6,7,8,9,10,11,12]"
  71. :key="i"
  72. :style="`background-image:${getBgUrl(i, true)}`"
  73. :class="{active:formSetting.bgid==i}"
  74. @click="formSetting.bgid=i"></li>
  75. </ul>
  76. </FormItem>
  77. <FormItem>
  78. <Button :loading="loadIng > 0" type="primary" @click="handleSubmit('formSetting')">{{$L('提交')}}</Button>
  79. <Button :loading="loadIng > 0" @click="handleReset('formSetting')" style="margin-left: 8px">{{$L('重置')}}</Button>
  80. </FormItem>
  81. </Form>
  82. </TabPane>
  83. <TabPane :label="$L('账号密码')" name="account">
  84. <Form ref="formPass" :model="formPass" :rules="rulePass" :label-width="100">
  85. <FormItem :label="$L('旧密码')" prop="oldpass">
  86. <Input v-model="formPass.oldpass"></Input>
  87. </FormItem>
  88. <FormItem :label="$L('新密码')" prop="newpass">
  89. <Input v-model="formPass.newpass"></Input>
  90. </FormItem>
  91. <FormItem :label="$L('确认新密码')" prop="checkpass">
  92. <Input v-model="formPass.checkpass"></Input>
  93. </FormItem>
  94. <FormItem>
  95. <Button :loading="loadIng > 0" type="primary" @click="handleSubmit('formPass')">{{$L('提交')}}</Button>
  96. <Button :loading="loadIng > 0" @click="handleReset('formPass')" style="margin-left: 8px">{{$L('重置')}}</Button>
  97. </FormItem>
  98. </Form>
  99. </TabPane>
  100. <TabPane :label="$L('我创建的任务')" name="createtask">
  101. <header-create :canload="userDrawerShow && userDrawerTab == 'createtask'"></header-create>
  102. </TabPane>
  103. <TabPane :label="$L('我归档的任务')" name="archivedtask">
  104. <header-archived :canload="userDrawerShow && userDrawerTab == 'archivedtask'"></header-archived>
  105. </TabPane>
  106. </Tabs>
  107. </WDrawer>
  108. <WDrawer v-model="chatDrawerShow" :closable="false" maxWidth="1080">
  109. <chat-index v-model="chatUnreadTotal" :openWindow="chatDrawerShow" @on-open-notice="chatDrawerShow=true"></chat-index>
  110. <div class="w-header-chat-close" @click="chatDrawerShow=false"><Icon type="ios-close" /></div>
  111. </WDrawer>
  112. </div>
  113. </template>
  114. <style lang="scss">
  115. .w-header-chat-close {
  116. position: absolute;
  117. bottom: 0;
  118. left: 0;
  119. z-index: 1;
  120. color: #ffffff;
  121. font-size: 32px;
  122. width: 68px;
  123. height: 58px;
  124. line-height: 58px;
  125. text-align: center;
  126. cursor: pointer;
  127. > i {
  128. transition: all 0.2s;
  129. }
  130. &:hover {
  131. > i {
  132. transform: scale(1.12) rotate(90deg);
  133. }
  134. }
  135. }
  136. </style>
  137. <style lang="scss" scoped>
  138. .w-header {
  139. z-index: 15;
  140. position: fixed;
  141. left: 0;
  142. top: 0;
  143. right: 0;
  144. font-size: 14px;
  145. background: #0396f2 linear-gradient(45deg, #0396f2 0%, #0285d7 100%);
  146. box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.25);
  147. .icon {
  148. font-size: 16px;
  149. margin-right: 3px;
  150. }
  151. .w-header-row {
  152. display: flex;
  153. color: #fff;
  154. height: 40px;
  155. position: relative;
  156. z-index: 10;
  157. margin: 0 32px;
  158. .w-header-row-left {
  159. flex: 1;
  160. white-space: nowrap;
  161. overflow: hidden;
  162. overflow-x: auto;
  163. -webkit-backface-visibility: hidden;
  164. -webkit-overflow-scrolling: touch;
  165. li {
  166. line-height: 40px;
  167. color: #fff;
  168. display: inline-block;
  169. a {
  170. color: #fff;
  171. display: block;
  172. width: 116px;
  173. text-align: center;
  174. &:visited {
  175. color: #fff;
  176. }
  177. &:hover {
  178. color: #f2f2f2;
  179. }
  180. }
  181. }
  182. li:hover, li.active {
  183. background: #0277c0;
  184. }
  185. }
  186. .w-header-row-right {
  187. white-space: nowrap;
  188. text-align: right;
  189. line-height: 40px;
  190. .right-info {
  191. display: inline-block;
  192. position: relative;
  193. margin-left: 12px;
  194. cursor: pointer;
  195. .right-mticon {
  196. vertical-align: top;
  197. margin-top: 8px;
  198. }
  199. .right-info-num {
  200. position: absolute;
  201. top: 2px;
  202. right: -20%;
  203. height: auto;
  204. line-height: normal;
  205. color: #ffffff;
  206. background-color: #ff0000;
  207. text-align: center;
  208. border-radius: 10px;
  209. padding: 1px 5px;
  210. font-size: 12px;
  211. transform: scale(0.9);
  212. }
  213. }
  214. }
  215. }
  216. }
  217. .setting-bg {
  218. margin-top: 6px;
  219. margin-bottom: -24px;
  220. &:after,
  221. &:before {
  222. display: table;
  223. content: "";
  224. }
  225. li {
  226. margin: 0 16px 16px 0;
  227. width: 160px;
  228. height: 124px;
  229. display: inline-block;
  230. cursor: pointer;
  231. border: solid 2px #fff;
  232. background-repeat: no-repeat;
  233. background-position: center;
  234. background-size: cover;
  235. transition: all 0.2s;
  236. &.active,
  237. &:hover {
  238. border-color: #0396f2;
  239. transform: scale(1.02);
  240. }
  241. }
  242. }
  243. </style>
  244. <script>
  245. import ImgUpload from "./ImgUpload";
  246. import HeaderCreate from "./project/header/create";
  247. import HeaderArchived from "./project/header/archived";
  248. import ChatIndex from "./chat/Index";
  249. import WDrawer from "./iview/WDrawer";
  250. export default {
  251. name: 'WHeader',
  252. components: {WDrawer, ChatIndex, HeaderArchived, HeaderCreate, ImgUpload},
  253. data() {
  254. return {
  255. tabActive: '',
  256. loadIng: 0,
  257. userInfo: {},
  258. userDrawerShow: false,
  259. userDrawerTab: 'personal',
  260. formDatum: {
  261. userimg: '',
  262. nickname: '',
  263. profession: ''
  264. },
  265. ruleDatum: { },
  266. formPass: {
  267. oldpass: '',
  268. newpass: '',
  269. checkpass: '',
  270. },
  271. rulePass: { },
  272. formSetting: {
  273. bgid: 0,
  274. },
  275. chatDrawerShow: false,
  276. chatUnreadTotal: 0,
  277. }
  278. },
  279. created() {
  280. this.ruleDatum = {
  281. nickname: [
  282. { required: true, message: this.$L('请输入昵称!'), trigger: 'change' },
  283. { type: 'string', min: 2, message: this.$L('昵称长度至少2位!'), trigger: 'change' }
  284. ]
  285. };
  286. this.rulePass = {
  287. oldpass: [
  288. { required: true, message: this.$L('请输入旧密码!'), trigger: 'change' },
  289. { type: 'string', min: 6, message: this.$L('密码长度至少6位!'), trigger: 'change' }
  290. ],
  291. newpass: [
  292. {
  293. validator: (rule, value, callback) => {
  294. if (value === '') {
  295. callback(new Error(this.$L('请输入新密码!')));
  296. } else {
  297. if (this.formPass.checkpass !== '') {
  298. this.$refs.formPass.validateField('checkpass');
  299. }
  300. callback();
  301. }
  302. },
  303. required: true,
  304. trigger: 'change'
  305. },
  306. { type: 'string', min: 6, message: this.$L('密码长度至少6位!'), trigger: 'change' }
  307. ],
  308. checkpass: [
  309. {
  310. validator: (rule, value, callback) => {
  311. if (value === '') {
  312. callback(new Error(this.$L('请输入确认新密码!')));
  313. } else if (value !== this.formPass.newpass) {
  314. callback(new Error(this.$L('两次密码输入不一致!')));
  315. } else {
  316. callback();
  317. }
  318. },
  319. required: true,
  320. trigger: 'change'
  321. }
  322. ],
  323. };
  324. },
  325. mounted() {
  326. let resCall = () => {
  327. this.$set(this.formDatum, 'userimg', this.userInfo.userimg)
  328. this.$set(this.formDatum, 'nickname', this.userInfo.nickname)
  329. this.$set(this.formDatum, 'profession', this.userInfo.profession)
  330. this.$set(this.formSetting, 'bgid', this.userInfo.bgid)
  331. };
  332. this.userInfo = $A.getUserInfo((res) => {
  333. this.userInfo = res;
  334. resCall();
  335. }, false);
  336. resCall();
  337. //
  338. this.tabActive = this.$route.meta.tabActive;
  339. },
  340. watch: {
  341. '$route' () {
  342. this.tabActive = this.$route.meta.tabActive;
  343. this.userDrawerShow = false;
  344. }
  345. },
  346. methods: {
  347. getBgUrl(id, thumb) {
  348. id = Math.max(1, parseInt(id));
  349. return 'url(' + window.location.origin + '/images/bg/' + (thumb ? 'thumb/' : '') + id + '.jpg' + ')';
  350. },
  351. tabPage(path) {
  352. this.goForward({path: '/' + path});
  353. },
  354. setRightSelect(act) {
  355. switch (act) {
  356. case 'user':
  357. this.userDrawerShow = true;
  358. break;
  359. case 'out':
  360. this.logout();
  361. break;
  362. }
  363. },
  364. logout() {
  365. this.$Modal.confirm({
  366. title: this.$L('退出登录'),
  367. content: this.$L('您确定要退出登录吗?'),
  368. onOk: () => {
  369. $A.userLogout();
  370. },
  371. });
  372. },
  373. handleSubmit(name) {
  374. this.$refs[name].validate((valid) => {
  375. if (valid) {
  376. switch (name) {
  377. case "formDatum": {
  378. this.loadIng++;
  379. $A.aAjax({
  380. url: 'users/editdata',
  381. data: this.formDatum,
  382. complete: () => {
  383. this.loadIng--;
  384. },
  385. success: (res) => {
  386. if (res.ret === 1) {
  387. $A.getUserInfo(true);
  388. this.$Message.success(this.$L('修改成功'));
  389. } else {
  390. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  391. }
  392. }
  393. });
  394. break;
  395. }
  396. case "formPass": {
  397. this.loadIng++;
  398. $A.aAjax({
  399. url: 'users/editpass',
  400. data: this.formPass,
  401. complete: () => {
  402. this.loadIng--;
  403. },
  404. success: (res) => {
  405. if (res.ret === 1) {
  406. this.userDrawerShow = false;
  407. this.$Message.success(this.$L('修改成功,请重新登录!'));
  408. this.$refs[name].resetFields();
  409. $A.userLogout();
  410. } else {
  411. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  412. }
  413. }
  414. });
  415. break;
  416. }
  417. case "formSetting": {
  418. this.loadIng++;
  419. $A.aAjax({
  420. url: 'users/editdata',
  421. data: this.formSetting,
  422. complete: () => {
  423. this.loadIng--;
  424. },
  425. success: (res) => {
  426. if (res.ret === 1) {
  427. $A.getUserInfo(true);
  428. this.$Message.success(this.$L('修改成功'));
  429. } else {
  430. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  431. }
  432. }
  433. });
  434. break;
  435. }
  436. }
  437. }
  438. })
  439. },
  440. handleReset(name) {
  441. this.$refs[name].resetFields();
  442. }
  443. },
  444. }
  445. </script>