diff --git a/src/locales/zh/user.json b/src/locales/zh/user.json index a382eb2f..c9d3efdd 100644 --- a/src/locales/zh/user.json +++ b/src/locales/zh/user.json @@ -18,6 +18,7 @@ "Normal Role Title Count": "终端角色({{count}})", "Operation list": "操作列表", "Edit info": "编辑信息", + "Change password successful": "修改密码成功", "isv": "应用服务商", "user": "用户", "Set permission": "设置权限", @@ -33,6 +34,8 @@ "Selected": "所选", "of setting": "的设置", "ISV": "应用服务商", + "Activation": "激活", + "Not activation": "非激活", "Parent group groupName": "上一级组织名:{{groupName}}", "Create role success": "角色创建成功", "Create_Role_Success_Tip": "新角色默认是停用状态,请完成权限设置后再启用。", diff --git a/src/portals/admin/pages/Users/ModalActions/index.jsx b/src/portals/admin/pages/Users/ModalActions/index.jsx index cd74abf2..aed56c56 100644 --- a/src/portals/admin/pages/Users/ModalActions/index.jsx +++ b/src/portals/admin/pages/Users/ModalActions/index.jsx @@ -7,7 +7,8 @@ import { Input, Select } from 'components/Base'; import { Dialog } from 'components/Layout'; import EnhanceTable from 'components/EnhanceTable'; -import columns from '../columns'; +import columns, { filterList } from '../columns'; + import styles from '../index.scss'; const emailRegexp = '^[A-Za-z0-9._%-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}$'; @@ -106,7 +107,8 @@ export default class UserModalActions extends Component { isLoading={groupStore.isLoading} store={groupStore} data={users} - columns={columns(t)} + columns={columns()} + filterList={filterList(groupStore)} /> ); @@ -151,7 +153,7 @@ export default class UserModalActions extends Component { const { userStore, modalStore, t } = this.props; const { isOpen, hide, item } = modalStore; const { setRole, roles, userNames } = userStore; - const roleId = _.get(item, 'role'); + const roleId = _.get(item, 'role[0].role_id', ''); const userId = _.get(item, 'user_id') || userStore.selectIds.join(','); const names = userId ? item.username : userNames; const text = userId @@ -209,6 +211,7 @@ export default class UserModalActions extends Component { defaultValue={username} required /> + )}
@@ -248,6 +251,28 @@ export default class UserModalActions extends Component { ); } + renderModalResetPassword() { + const { t, modalStore, userStore } = this.props; + const { hide, isOpen, item } = modalStore; + const { changePwd } = userStore; + + return ( + +
+ + + +
+
+ ); + } + renderModalDeleteUser() { const { t, modalStore, userStore } = this.props; const { hide, isOpen, item } = modalStore; diff --git a/src/portals/admin/pages/Users/columns.js b/src/portals/admin/pages/Users/columns.js index 2fb1c3f4..ea30d6a3 100644 --- a/src/portals/admin/pages/Users/columns.js +++ b/src/portals/admin/pages/Users/columns.js @@ -5,8 +5,9 @@ import _ from 'lodash'; import Status from 'components/Status'; import TimeShow from 'components/TimeShow'; import LessText from 'components/LessText'; +import { t } from 'i18next'; -export default (t, renderHandleMenu) => { +export default renderHandleMenu => { const columns = [ { title: t('Status'), @@ -57,3 +58,15 @@ export default (t, renderHandleMenu) => { return columns; }; + +export const filterList = store => [ + { + key: 'status', + conditions: [ + { name: t('Activation'), value: 'active' }, + { name: t('Not activation'), value: 'deleted' } + ], + onChangeFilter: store.onChangeStatus, + selectValue: store.selectStatus + } +]; diff --git a/src/portals/admin/pages/Users/index.jsx b/src/portals/admin/pages/Users/index.jsx index b33bb2d8..f176f8ae 100644 --- a/src/portals/admin/pages/Users/index.jsx +++ b/src/portals/admin/pages/Users/index.jsx @@ -15,7 +15,7 @@ import Layout, { import EnhanceTable from 'components/EnhanceTable'; import Toolbar from 'components/Toolbar'; import ModalActions from './ModalActions'; -import columns from './columns'; +import columns, { filterList } from './columns'; import styles from './index.scss'; @@ -148,6 +148,9 @@ export default class Users extends Component { {_.isArray(group_id) && ( leaveGroupOnce(user)}>{t('Leave group')} )} + modalStore.show('renderModalResetPassword', user)}> + {t('Change Password')} + modalStore.show( 'renderModalDeleteUser', @@ -276,7 +279,8 @@ export default class Users extends Component { isLoading={userStore.isLoading} store={userStore} data={userStore.users} - columns={columns(t, this.renderUserHandleMenu)} + columns={columns(this.renderUserHandleMenu)} + filterList={filterList(userStore)} /> diff --git a/src/stores/user/index.js b/src/stores/user/index.js index ef2660f0..ad9b11d2 100644 --- a/src/stores/user/index.js +++ b/src/stores/user/index.js @@ -178,17 +178,15 @@ export default class UserStore extends Store { if (!params.email) { return this.error('Empty email'); } - if (!params.role) { - return this.error('Empty role'); - } - if (params.user_id) { if (!params.password) { delete params.password; } await this.modify(params); } else { - // create user + if (!params.role) { + return this.error('Empty role'); + } if (!params.password) { return this.error('Empty password'); } @@ -238,6 +236,15 @@ export default class UserStore extends Store { return result; }; + @action + changePwd = async (e, data) => { + const result = await this.changePassword(data); + if (_.get(result, 'user_id')) { + this.success('Change password successful'); + this.modal.hide(); + } + }; + @action remove = async () => { const result = await this.request.delete('users', {