123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654 |
- <template>
- <div class="w-header">
- <div v-if="tabActive" class="w-header-row">
- <div class="w-header-row-left">
- <Dropdown class="m768-show" @on-click="tabPage" trigger="click" transfer>
- <Icon type="md-menu" class="dropdown-menu"/>
- <DropdownMenu slot="list">
- <DropdownItem name="todo">{{$L('待办')}}</DropdownItem>
- <DropdownItem name="project">{{$L('项目')}}</DropdownItem>
- <DropdownItem name="docs">{{$L('知识库')}}</DropdownItem>
- <DropdownItem name="team">{{$L('团队')}}</DropdownItem>
- </DropdownMenu>
- </Dropdown>
- <ul class="m768-hide">
- <li :class="tabActive==='todo'?'active':''">
- <a href="javascript:void(0)" @click="tabPage('todo')"><i class="ft icon"></i>{{$L('待办')}}</a>
- </li><li :class="tabActive==='project'?'active':''">
- <a href="javascript:void(0)" @click="tabPage('project')"><i class="ft icon"></i>{{$L('项目')}}</a>
- </li><li :class="tabActive==='docs'?'active':''">
- <a href="javascript:void(0)" @click="tabPage('docs')"><i class="ft icon"></i>{{$L('知识库')}}</a>
- </li><li :class="tabActive==='team'?'active':''">
- <a href="javascript:void(0)" @click="tabPage('team')"><i class="ft icon"></i>{{$L('团队')}}</a>
- </li>
- </ul>
- </div>
- <div class="w-header-row-right">
- <Dropdown class="right-info" trigger="click" @on-click="setRightSelect" placement="bottom-end" transfer>
- <div>
- <UserImg class="userimg" :info="usrInfo"/>
- <span class="username">{{$L('欢迎您')}}, {{(usrInfo.nickname || usrInfo.username) || $L('尊敬的会员')}}</span>
- <Icon type="md-arrow-dropdown"/>
- </div>
- <Dropdown-menu slot="list">
- <Dropdown-item v-if="isAdmin" name="system">{{$L('系统设置')}}</Dropdown-item>
- <Dropdown-item name="user">{{$L('个人中心')}}</Dropdown-item>
- <Dropdown-item name="out">{{$L('退出登录')}}</Dropdown-item>
- </Dropdown-menu>
- </Dropdown>
- <div class="right-info" @click="chatDrawerShow=true">
- <Icon class="right-mticon-9" type="md-text" size="24"/>
- <em v-if="chatUnreadTotal > 0" class="right-info-num">{{chatUnreadTotal > 99 ? '99+' : chatUnreadTotal}}</em>
- </div>
- <Dropdown class="right-info" trigger="click" @on-click="setLanguage" transfer>
- <div>
- <Icon class="right-mticon" type="md-globe" size="24"/>
- <Icon type="md-arrow-dropdown"/>
- </div>
- <Dropdown-menu slot="list">
- <Dropdown-item name="zh" :selected="getLanguage() === 'zh'">中文</Dropdown-item>
- <Dropdown-item name="en" :selected="getLanguage() === 'en'">English</Dropdown-item>
- </Dropdown-menu>
- </Dropdown>
- </div>
- </div>
- <WDrawer v-model="systemDrawerShow" maxWidth="640" :title="$L('系统设置')">
- <Form ref="formSystem" :model="formSystem" :label-width="150" @submit.native.prevent>
- <FormItem :label="$L('首页Logo')">
- <ImgUpload v-model="formSystem.logo" :num="1"></ImgUpload>
- <span style="color:#777">{{$L('建议尺寸:%', '300x52')}}</span>
- </FormItem>
- <FormItem :label="$L('Github/Gitee图标')">
- <RadioGroup v-model="formSystem.github">
- <Radio label="show">{{$L('显示')}}</Radio>
- <Radio label="hidden">{{$L('隐藏')}}</Radio>
- </RadioGroup>
- </FormItem>
- <FormItem :label="$L('允许注册')">
- <RadioGroup v-model="formSystem.reg">
- <Radio label="open">{{$L('允许')}}</Radio>
- <Radio label="close">{{$L('禁止')}}</Radio>
- </RadioGroup>
- </FormItem>
- <FormItem :label="$L('音视频通话')">
- <RadioGroup v-model="formSystem.callav">
- <Radio label="open">{{$L('开启')}}</Radio>
- <Radio label="close">{{$L('关闭')}}</Radio>
- </RadioGroup>
- </FormItem>
- <FormItem :label="$L('完成自动归档')">
- <RadioGroup :value="formSystem.autoArchived" @on-change="formArchived">
- <Radio label="open">{{$L('开启')}}</Radio>
- <Radio label="close">{{$L('关闭')}}</Radio>
- </RadioGroup>
- <Tooltip v-if="formSystem.autoArchived=='open'" class="setting-auto-day" placement="right">
- <Input v-model="formSystem.archivedDay" type="number">
- <span slot="append">{{$L('天')}}</span>
- </Input>
- <div slot="content">{{$L('任务完成 % 天后自动归档。', formSystem.archivedDay)}}</div>
- </Tooltip>
- </FormItem>
- <FormItem>
- <Button :loading="loadIng > 0" type="primary" @click="handleSubmit('formSystem')">{{$L('提交')}}</Button>
- <Button :loading="loadIng > 0" @click="handleReset('formSystem')" style="margin-left: 8px">{{$L('重置')}}</Button>
- </FormItem>
- </Form>
- </WDrawer>
- <WDrawer v-model="userDrawerShow" maxWidth="1000">
- <Tabs v-model="userDrawerTab">
- <TabPane :label="$L('个人资料')" name="personal">
- <Form ref="formDatum" :model="formDatum" :rules="ruleDatum" :label-width="80" @submit.native.prevent>
- <FormItem :label="$L('头像')" prop="userimg">
- <ImgUpload v-model="formDatum.userimg" :num="1"></ImgUpload>
- <span style="color:#777">{{$L('建议尺寸:%', '200x200')}}</span>
- </FormItem>
- <FormItem :label="$L('账号')">
- <Input v-model="usrInfo.username" :disabled="true"></Input>
- </FormItem>
- <FormItem :label="$L('昵称')" prop="nickname">
- <Input v-model="formDatum.nickname"></Input>
- </FormItem>
- <FormItem :label="$L('职位/职称')" prop="profession">
- <Input v-model="formDatum.profession"></Input>
- </FormItem>
- <FormItem>
- <Button :loading="loadIng > 0" type="primary" @click="handleSubmit('formDatum')">{{$L('提交')}}</Button>
- <Button :loading="loadIng > 0" @click="handleReset('formDatum')" style="margin-left: 8px">{{$L('重置')}}</Button>
- </FormItem>
- </Form>
- </TabPane>
- <TabPane :label="$L('偏好设置')" name="setting">
- <Form ref="formSetting" :model="formSetting" :label-width="100" @submit.native.prevent>
- <FormItem :label="$L('系统皮肤')" prop="bgid">
- <ul class="setting-bg">
- <li v-for="i in [1,2,3,4,5,6,7,8,9,10,11,12]"
- :key="i"
- :style="`background-image:${getBgUrl(i, true)}`"
- :class="{active:formSetting.bgid==i}"
- @click="formSetting.bgid=i"></li>
- </ul>
- </FormItem>
- <FormItem>
- <Button :loading="loadIng > 0" type="primary" @click="handleSubmit('formSetting')">{{$L('提交')}}</Button>
- <Button :loading="loadIng > 0" @click="handleReset('formSetting')" style="margin-left: 8px">{{$L('重置')}}</Button>
- </FormItem>
- </Form>
- </TabPane>
- <TabPane :label="$L('账号密码')" name="account">
- <Alert v-if="usrInfo.changepass" type="warning" showIcon>{{$L('请先修改登录密码!')}}</Alert>
- <Form ref="formPass" :model="formPass" :rules="rulePass" :label-width="100" @submit.native.prevent>
- <FormItem :label="$L('旧密码')" prop="oldpass">
- <Input v-model="formPass.oldpass" type="password"></Input>
- </FormItem>
- <FormItem :label="$L('新密码')" prop="newpass">
- <Input v-model="formPass.newpass" type="password"></Input>
- </FormItem>
- <FormItem :label="$L('确认新密码')" prop="checkpass">
- <Input v-model="formPass.checkpass" type="password"></Input>
- </FormItem>
- <FormItem>
- <Button :loading="loadIng > 0" type="primary" @click="handleSubmit('formPass')">{{$L('提交')}}</Button>
- <Button :loading="loadIng > 0" @click="handleReset('formPass')" style="margin-left: 8px">{{$L('重置')}}</Button>
- </FormItem>
- </Form>
- </TabPane>
- <TabPane :label="$L('我创建的任务')" name="createtask">
- <header-create :canload="userDrawerShow && userDrawerTab == 'createtask'"></header-create>
- </TabPane>
- <TabPane :label="$L('我归档的任务')" name="archivedtask">
- <header-archived :canload="userDrawerShow && userDrawerTab == 'archivedtask'"></header-archived>
- </TabPane>
- </Tabs>
- </WDrawer>
- <WDrawer v-model="chatDrawerShow" :closable="false" maxWidth="1080" class="w-header-chat-draver">
- <chat-index v-model="chatUnreadTotal" :openWindow="chatDrawerShow" @on-open-notice="chatDrawerShow=true"></chat-index>
- <div class="w-header-chat-close" @click="chatDrawerShow=false"><Icon type="ios-close" /></div>
- </WDrawer>
- </div>
- </template>
- <style lang="scss">
- .w-header-chat-draver {
- .ivu-drawer-wrap,
- .ivu-drawer-mask {
- z-index: 1001;
- }
- .w-header-chat-close {
- position: absolute;
- bottom: 0;
- left: 0;
- z-index: 1;
- color: #ffffff;
- font-size: 32px;
- width: 68px;
- height: 58px;
- line-height: 58px;
- text-align: center;
- cursor: pointer;
- @media (max-width: 768px) {
- width: 50px;
- height: 50px;
- line-height: 50px;
- }
- > i {
- transition: all 0.2s;
- }
- &:hover {
- > i {
- transform: scale(1.12) rotate(90deg);
- }
- }
- }
- }
- </style>
- <style lang="scss" scoped>
- .w-header {
- z-index: 15;
- position: fixed;
- left: 0;
- top: 0;
- right: 0;
- font-size: 14px;
- background: #0396f2 linear-gradient(45deg, #0396f2 0%, #0285d7 100%);
- box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.25);
- .icon {
- font-size: 16px;
- margin-right: 3px;
- }
- .w-header-row {
- display: flex;
- color: #fff;
- height: 40px;
- position: relative;
- z-index: 10;
- margin: 0 32px;
- .w-header-row-left {
- flex: 1;
- white-space: nowrap;
- overflow: hidden;
- overflow-x: auto;
- -webkit-backface-visibility: hidden;
- -webkit-overflow-scrolling: touch;
- li {
- line-height: 40px;
- color: #fff;
- display: inline-block;
- a {
- color: #fff;
- display: block;
- min-width: 116px;
- text-align: center;
- &:visited {
- color: #fff;
- }
- &:hover {
- color: #f2f2f2;
- }
- }
- }
- li:hover, li.active {
- background: #0277c0;
- }
- }
- .w-header-row-right {
- white-space: nowrap;
- text-align: right;
- line-height: 40px;
- margin-right: -5px;
- .right-info {
- display: inline-block;
- position: relative;
- padding-left: 10px;
- padding-right: 10px;
- margin-right: -5px;
- cursor: pointer;
- &:hover {
- background: #0277c0;
- }
- .right-mticon {
- vertical-align: top;
- margin-top: 8px;
- }
- .right-mticon-9 {
- vertical-align: top;
- margin-top: 9px;
- }
- .right-info-num {
- position: absolute;
- top: 2px;
- left: 22px;
- height: auto;
- line-height: normal;
- color: #ffffff;
- background-color: #ff0000;
- text-align: center;
- border-radius: 10px;
- padding: 1px 5px;
- font-size: 12px;
- transform: scale(0.9);
- z-index: 1;
- }
- .userimg {
- display: none;
- width: 26px;
- height: 26px;
- margin-top: 7px;
- vertical-align: top;
- border-radius: 50%;
- }
- .username {
- display: inline-block;
- }
- }
- }
- @media (max-width: 768px) {
- margin: 0 16px;
- .w-header-row-left {
- .dropdown-menu {
- font-size: 28px;
- vertical-align: top;
- margin-top: 6px;
- }
- }
- .w-header-row-right {
- .right-info {
- padding-left: 8px;
- padding-right: 8px;
- .userimg {
- display: inline-block;
- }
- .username {
- display: none;
- }
- }
- }
- }
- }
- }
- .setting-auto-day {
- display: block;
- width: 110px;
- margin-top: 12px;
- line-height: 32px;
- margin-bottom: -10px;
- }
- .setting-bg {
- margin-top: 6px;
- margin-bottom: -24px;
- &:after,
- &:before {
- display: table;
- content: "";
- }
- li {
- margin: 0 16px 16px 0;
- width: 160px;
- height: 124px;
- display: inline-block;
- cursor: pointer;
- border: solid 2px #fff;
- background-repeat: no-repeat;
- background-position: center;
- background-size: cover;
- transition: all 0.2s;
- &.active,
- &:hover {
- border-color: #0396f2;
- transform: scale(1.02);
- }
- }
- }
- </style>
- <script>
- import ImgUpload from "./ImgUpload";
- import HeaderCreate from "./project/header/create";
- import HeaderArchived from "./project/header/archived";
- import ChatIndex from "./chat/Index";
- import WDrawer from "./iview/WDrawer";
- export default {
- name: 'WHeader',
- components: {WDrawer, ChatIndex, HeaderArchived, HeaderCreate, ImgUpload},
- data() {
- return {
- tabActive: '',
- loadIng: 0,
- isAdmin: false,
- systemDrawerShow: false,
- userDrawerShow: false,
- userDrawerTab: 'personal',
- formSystem: {
- github: 'show',
- reg: 'open',
- callav: 'open',
- autoArchived: 'close',
- archivedDay: 7,
- },
- formDatum: {
- userimg: '',
- nickname: '',
- profession: ''
- },
- ruleDatum: { },
- formPass: {
- oldpass: '',
- newpass: '',
- checkpass: '',
- },
- rulePass: { },
- formSetting: {
- bgid: 0,
- },
- chatDrawerShow: false,
- chatUnreadTotal: 0,
- }
- },
- mounted() {
- this.isAdmin = $A.identity('admin');
- this.formatDatum();
- //
- this.tabActive = this.$route.meta.tabActive;
- //
- if ($A.urlParameter("open") === 'chat' && $A.getToken() !== false) {
- this.chatDrawerShow = true;
- }
- },
- watch: {
- '$route' () {
- this.tabActive = this.$route.meta.tabActive;
- this.systemDrawerShow = false;
- this.chatDrawerShow = $A.urlParameter("open") === 'chat' && $A.getToken() !== false;
- if (!this.usrInfo.changepass) {
- this.userDrawerShow = false;
- }
- },
- usrName() {
- this.isAdmin = $A.identity('admin');
- this.formatDatum();
- }
- },
- methods: {
- initLanguage() {
- this.ruleDatum = {
- nickname: [
- { required: true, message: this.$L('请输入昵称!'), trigger: 'change' },
- { type: 'string', min: 2, message: this.$L('昵称长度至少2位!'), trigger: 'change' }
- ]
- };
- this.rulePass = {
- oldpass: [
- { required: true, message: this.$L('请输入旧密码!'), trigger: 'change' },
- { type: 'string', min: 6, message: this.$L('密码长度至少6位!'), trigger: 'change' }
- ],
- newpass: [
- {
- validator: (rule, value, callback) => {
- if (value === '') {
- callback(new Error(this.$L('请输入新密码!')));
- } else {
- if (this.formPass.checkpass !== '') {
- this.$refs.formPass.validateField('checkpass');
- }
- callback();
- }
- },
- required: true,
- trigger: 'change'
- },
- { type: 'string', min: 6, message: this.$L('密码长度至少6位!'), trigger: 'change' }
- ],
- checkpass: [
- {
- validator: (rule, value, callback) => {
- if (value === '') {
- callback(new Error(this.$L('请重新输入新密码!')));
- } else if (value !== this.formPass.newpass) {
- callback(new Error(this.$L('两次密码输入不一致!')));
- } else {
- callback();
- }
- },
- required: true,
- trigger: 'change'
- }
- ],
- };
- },
- formatDatum() {
- this.$set(this.formDatum, 'userimg', this.usrInfo.userimg)
- this.$set(this.formDatum, 'nickname', this.usrInfo.nickname)
- this.$set(this.formDatum, 'profession', this.usrInfo.profession)
- this.$set(this.formSetting, 'bgid', this.usrInfo.bgid)
- this.formDatum__reset = $A.cloneData(this.formDatum);
- this.formSetting__reset = $A.cloneData(this.formSetting);
- this.formPass__reset = $A.cloneData(this.formPass);
- this.changepass();
- },
- changepass() {
- if (this.usrInfo.changepass) {
- this.userDrawerShow = true;
- this.userDrawerTab = 'account';
- setTimeout(() => {
- this.changepass()
- }, 500);
- }
- },
- getBgUrl(id, thumb) {
- id = Math.max(1, parseInt(id));
- return 'url(' + window.location.origin + '/images/bg/' + (thumb ? 'thumb/' : '') + id + '.jpg' + ')';
- },
- tabPage(path) {
- this.goForward({path: '/' + path});
- },
- setRightSelect(act) {
- switch (act) {
- case 'system':
- this.systemSetting(false);
- this.systemDrawerShow = true;
- break;
- case 'user':
- this.userDrawerShow = true;
- break;
- case 'out':
- this.logout();
- break;
- }
- },
- logout() {
- this.$Modal.confirm({
- title: this.$L('退出登录'),
- content: this.$L('您确定要退出登录吗?'),
- onOk: () => {
- $A.userLogout();
- },
- });
- },
- systemSetting(save) {
- this.loadIng++;
- $A.apiAjax({
- url: 'system/setting?type=' + (save ? 'save' : 'get'),
- data: this.formSystem,
- complete: () => {
- this.loadIng--;
- },
- success: (res) => {
- if (res.ret === 1) {
- let tempData = res.data;
- tempData.github = tempData.github || 'show';
- tempData.reg = tempData.reg || 'open';
- tempData.callav = tempData.callav || 'open';
- tempData.autoArchived = tempData.autoArchived || 'close';
- tempData.archivedDay = tempData.archivedDay || 7;
- this.formSystem = tempData;
- this.formSystem__reset = $A.cloneData(this.formSystem);
- if (save) {
- this.$Message.success(this.$L('修改成功'));
- }
- } else {
- if (save) {
- this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
- }
- }
- }
- });
- },
- handleSubmit(name) {
- this.$refs[name].validate((valid) => {
- if (valid) {
- switch (name) {
- case "formSystem": {
- this.systemSetting(true);
- break;
- }
- case "formDatum": {
- this.loadIng++;
- $A.apiAjax({
- url: 'users/editdata',
- data: this.formDatum,
- complete: () => {
- this.loadIng--;
- },
- success: (res) => {
- if (res.ret === 1) {
- $A.getUserInfo(true);
- $A.getUserBasic(this.usrInfo.username, () => {}, 0);
- this.$Message.success(this.$L('修改成功'));
- } else {
- this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
- }
- }
- });
- break;
- }
- case "formPass": {
- this.loadIng++;
- $A.apiAjax({
- url: 'users/editpass',
- data: this.formPass,
- complete: () => {
- this.loadIng--;
- },
- success: (res) => {
- if (res.ret === 1) {
- this.userDrawerShow = false;
- this.$Message.success(this.$L('修改成功,请重新登录!'));
- this.$refs[name].resetFields();
- $A.userLogout();
- } else {
- this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
- }
- }
- });
- break;
- }
- case "formSetting": {
- this.loadIng++;
- $A.apiAjax({
- url: 'users/editdata',
- data: this.formSetting,
- complete: () => {
- this.loadIng--;
- },
- success: (res) => {
- if (res.ret === 1) {
- $A.getUserInfo(true);
- this.$Message.success(this.$L('修改成功'));
- } else {
- this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
- }
- }
- });
- break;
- }
- }
- }
- })
- },
- handleReset(name) {
- if (typeof this[name + '__reset'] !== "undefined") {
- this[name] = $A.cloneData(this[name + '__reset']);
- return;
- }
- this.$refs[name].resetFields();
- },
- formArchived(value) {
- this.formSystem = { ...this.formSystem, autoArchived: value };
- }
- },
- }
- </script>
|