123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471 |
- <template>
- <div class="w-main team">
- <v-title>{{$L('团队')}}</v-title>
- <div class="w-nav">
- <div class="nav-row">
- <div class="w-nav-left">
- <div class="page-nav-left">
- <span><i class="ft icon"></i> {{$L('团队成员')}}</span>
- <div v-if="loadIng > 0" class="page-nav-loading"><w-loading></w-loading></div>
- <div v-else class="page-nav-refresh"><em @click="getLists(true)">{{$L('刷新')}}</em></div>
- </div>
- </div>
- <div class="w-nav-flex"></div>
- <div class="m768-show w-nav-right">
- <Dropdown @on-click="handleUser" trigger="click" transfer>
- <Icon type="md-menu" size="18"/>
- <DropdownMenu slot="list">
- <DropdownItem name="add">{{$L('添加团队成员')}}</DropdownItem>
- </DropdownMenu>
- </Dropdown>
- </div>
- <div class="m768-hide w-nav-right">
- <span class="ft hover" @click="handleUser('add')"><i class="ft icon"></i> {{$L('添加团队成员')}}</span>
- </div>
- </div>
- </div>
- <w-content>
- <div class="team-main">
- <div class="team-body">
- <!-- 列表 -->
- <Table class="tableFill" ref="tableRef" :columns="columns" :data="lists" :loading="loadIng > 0" :no-data-text="noDataText" stripe></Table>
- <!-- 分页 -->
- <Page class="pageBox" :total="listTotal" :current="listPage" :disabled="loadIng > 0" @on-change="setPage" @on-page-size-change="setPageSize" :page-size-opts="[10,20,30,50,100]" placement="top" show-elevator show-sizer show-total :simple="windowMax768"></Page>
- </div>
- </div>
- </w-content>
- <Modal
- v-model="addShow"
- :title="$L(formData.id > 0 ? '修改团队成员' : '添加团队成员')"
- :closable="false"
- :mask-closable="false"
- class-name="simple-modal">
- <Form ref="add" :model="formData" :label-width="80" @submit.native.prevent>
- <FormItem prop="userimg" :label="$L('头像')">
- <ImgUpload v-model="formData.userimg"></ImgUpload>
- </FormItem>
- <FormItem prop="nickname" :label="$L('昵称')">
- <Input type="text" v-model="formData.nickname"></Input>
- </FormItem>
- <FormItem prop="profession" :label="$L('职位/职称')">
- <Input v-model="formData.profession"></Input>
- </FormItem>
- <FormItem prop="username">
- <div slot="label"><em v-if="formData.id == 0" class="team-add-red-input">*</em>{{$L('用户名')}}</div>
- <Input v-if="formData.id > 0" disabled v-model="formData.username"></Input>
- <TagInput v-else v-model="formData.username" :placeholder="$L('添加后不可修改,使用英文逗号添加多个。')"/>
- </FormItem>
- <FormItem prop="userpass">
- <div slot="label"><em v-if="formData.id == 0" class="team-add-red-input">*</em>{{$L('登录密码')}}</div>
- <Input type="password" v-model="formData.userpass" :placeholder="$L(formData.id > 0 ? '留空不修改' : '最少6位数')"></Input>
- </FormItem>
- <FormItem class="team-add-form-item-changepass" :class="{show:formData.userpass}" v-if="formData.id == 0" prop="changepass">
- <Checkbox v-model="formData.changepass" :true-value="1" :false-value="0">{{$L('首次登陆需修改密码')}}</Checkbox>
- </FormItem>
- </Form>
- <div slot="footer">
- <Button type="default" @click="addShow=false">{{$L('取消')}}</Button>
- <Button type="primary" :loading="loadIng > 0" @click="onAdd">{{$L(formData.id > 0 ? '修改' : '添加')}}</Button>
- </div>
- </Modal>
- </div>
- </template>
- <style lang="scss">
- .team-add-red-input {
- display: inline-block;
- margin-right: 4px;
- line-height: 1;
- font-family: SimSun,serif;
- font-size: 14px;
- color: #ed4014;
- }
- .team-add-form-item-changepass {
- margin-top: -18px;
- margin-bottom: 18px;
- height: 0;
- overflow: hidden;
- transition: all 0.2s;
- &.show {
- height: 32px;
- }
- }
- </style>
- <style lang="scss" scoped>
- .team {
- .team-main {
- display: flex;
- flex-direction: column;
- width: 100%;
- height: 100%;
- padding: 15px;
- .team-body {
- display: flex;
- flex-direction: column;
- width: 100%;
- height: 100%;
- min-height: 500px;
- background: #fefefe;
- border-radius: 3px;
- .tableFill {
- margin: 20px;
- background-color: #ffffff;
- }
- }
- }
- }
- </style>
- <script>
- import WContent from "../components/WContent";
- import ImgUpload from "../components/ImgUpload";
- import TagInput from "../components/TagInput";
- export default {
- components: {TagInput, ImgUpload, WContent},
- data () {
- return {
- loadIng: 0,
- isAdmin: false,
- columns: [],
- lists: [],
- listPage: 1,
- listTotal: 0,
- noDataText: "",
- addShow: false,
- formData: {
- id: 0,
- userimg: '',
- profession: '',
- username: '',
- nickname: '',
- userpass: '',
- },
- }
- },
- mounted() {
- this.getLists(true);
- },
- deactivated() {
- this.addShow = false;
- },
- watch: {
- usrName() {
- this.usrLogin && this.getLists(true);
- }
- },
- methods: {
- initLanguage() {
- this.isAdmin = $A.identity('admin');
- this.noDataText = this.$L("数据加载中.....");
- this.columns = [{
- "title": this.$L("头像"),
- "minWidth": 60,
- "maxWidth": 100,
- render: (h, params) => {
- return h('UserImg', {
- props: {
- info: params.row,
- },
- style: {
- width: "30px",
- height: "30px",
- fontSize: "16px",
- lineHeight: "30px",
- borderRadius: "15px",
- verticalAlign: "middle"
- },
- });
- }
- }, {
- "title": this.$L("用户名"),
- "key": 'username',
- "minWidth": 80,
- "ellipsis": true,
- render: (h, params) => {
- let arr = [];
- if (params.row.username == this.usrName) {
- arr.push(h('span', {
- style: {
- color: '#ff0000',
- paddingRight: '4px'
- }
- }, '[自己]'))
- }
- if ($A.identityRaw('admin', params.row.identity)) {
- arr.push(h('span', {
- style: {
- color: '#ff0000',
- paddingRight: '4px'
- }
- }, '[管理员]'))
- }
- arr.push(h('span', params.row.username))
- return h('span', arr);
- }
- }, {
- "title": this.$L("昵称"),
- "minWidth": 80,
- "ellipsis": true,
- render: (h, params) => {
- return h('span', params.row.nickname || '-');
- }
- }, {
- "title": this.$L("职位/职称"),
- "minWidth": 100,
- "ellipsis": true,
- render: (h, params) => {
- return h('span', params.row.profession || '-');
- }
- }, {
- "title": this.$L("加入时间"),
- "width": 160,
- render: (h, params) => {
- return h('span', $A.formatDate("Y-m-d H:i:s", params.row.regdate));
- }
- }, {
- "title": this.$L("操作"),
- "key": 'action',
- "width": this.isAdmin ? 160 : 80,
- "align": 'center',
- render: (h, params) => {
- let array = [];
- array.push(h('Button', {
- props: {
- type: 'primary',
- size: 'small'
- },
- style: {
- fontSize: '12px'
- },
- on: {
- click: () => {
- this.$Modal.info({
- title: this.$L('会员信息'),
- content: `<p>${this.$L('昵称')}: ${params.row.nickname || '-'}</p><p>${this.$L('职位/职称')}: ${params.row.profession || '-'}</p>`
- });
- }
- }
- }, this.$L('查看')));
- if (this.isAdmin) {
- array.push(h('Dropdown', {
- props: {
- trigger: 'click',
- transfer: true
- },
- on: {
- 'on-click': (name) => {
- this.handleUser(name, params.row)
- }
- }
- }, [
- h('Button', {
- props: {
- type: 'warning',
- size: 'small'
- },
- style: {
- fontSize: '12px',
- marginLeft: '5px'
- },
- }, this.$L('操作')),
- h('DropdownMenu', {
- slot: 'list',
- }, [
- h('DropdownItem', {
- props: {
- name: 'edit',
- },
- }, this.$L('修改成员信息')),
- h('DropdownItem', {
- props: {
- name: $A.identityRaw('admin', params.row.identity) ? 'deladmin' : 'setadmin',
- },
- }, this.$L($A.identityRaw('admin', params.row.identity) ? '取消管理员' : '设为管理员')),
- h('DropdownItem', {
- props: {
- name: 'delete',
- },
- }, this.$L('删除'))
- ])
- ]))
- }
- return h('div', array);
- }
- }];
- },
- setPage(page) {
- this.listPage = page;
- this.getLists();
- },
- setPageSize(size) {
- if (Math.max($A.runNum(this.listPageSize), 10) != size) {
- this.listPageSize = size;
- this.getLists();
- }
- },
- getLists(resetLoad) {
- if (resetLoad === true) {
- this.listPage = 1;
- }
- this.loadIng++;
- this.noDataText = this.$L("数据加载中.....");
- $A.apiAjax({
- url: 'users/team/lists',
- data: {
- page: Math.max(this.listPage, 1),
- pagesize: Math.max($A.runNum(this.listPageSize), 10),
- },
- complete: () => {
- this.loadIng--;
- },
- error: () => {
- this.noDataText = this.$L("数据加载失败!");
- },
- success: (res) => {
- if (res.ret === 1) {
- this.lists = res.data.lists;
- this.listTotal = res.data.total;
- this.noDataText = this.$L("没有相关的数据");
- }else{
- this.lists = [];
- this.listTotal = 0;
- this.noDataText = res.msg;
- }
- }
- });
- },
- onAdd() {
- this.loadIng++;
- let id = $A.runNum(this.formData.id);
- $A.apiAjax({
- url: 'users/team/add',
- data: this.formData,
- complete: () => {
- this.loadIng--;
- },
- success: (res) => {
- if (res.ret === 1) {
- this.addShow = false;
- this.$Message.success(res.msg);
- this.$refs.add.resetFields();
- //
- this.getLists(id == 0);
- }else{
- this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
- }
- }
- });
- },
- handleUser(act, info) {
- switch (act) {
- case "add": {
- this.addShow = true;
- this.formData = {
- id: 0,
- userimg: '',
- profession: '',
- username: '',
- nickname: '',
- userpass: '',
- changepass: 1
- }
- break;
- }
- case "edit": {
- this.addShow = true;
- this.formData = Object.assign($A.cloneData(info))
- break;
- }
- case "delete": {
- this.$Modal.confirm({
- title: this.$L('删除团队成员'),
- content: this.$L('你确定要删除此团队成员吗?'),
- loading: true,
- onOk: () => {
- $A.apiAjax({
- url: 'users/team/delete?username=' + info.username,
- error: () => {
- this.$Modal.remove();
- alert(this.$L('网络繁忙,请稍后再试!'));
- },
- success: (res) => {
- this.$Modal.remove();
- this.getLists();
- setTimeout(() => {
- if (res.ret === 1) {
- this.$Message.success(res.msg);
- }else{
- this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
- }
- }, 350);
- }
- });
- }
- });
- break;
- }
- case "setadmin":
- case "deladmin": {
- this.$Modal.confirm({
- title: this.$L('确定操作'),
- content: this.$L(act=='deladmin' ? '你确定取消管理员身份的操作吗?' : '你确定设置管理员的操作吗?'),
- loading: true,
- onOk: () => {
- $A.apiAjax({
- url: 'users/team/admin?act=' + (act=='deladmin'?'del':'set') + '&username=' + info.username,
- error: () => {
- this.$Modal.remove();
- alert(this.$L('网络繁忙,请稍后再试!'));
- },
- success: (res) => {
- this.$Modal.remove();
- if (res.ret === 1) {
- this.lists.some((item) => {
- if (item.username == info.username) {
- this.$set(item, 'identity', res.data.identity);
- return true;
- }
- });
- if (res.data.up === 1) {
- let data = {
- type: 'text',
- username: this.usrInfo.username,
- userimg: this.usrInfo.userimg,
- indate: Math.round(new Date().getTime() / 1000),
- text: this.$L(act=='deladmin' ? '您的管理员身份已被撤销。' : '恭喜您成为管理员。')
- };
- $A.WSOB.sendTo('user', info.username, data, 'special');
- $A.WSOB.sendTo('info', info.username, { 'type': 'update'});
- }
- }
- setTimeout(() => {
- if (res.ret === 1) {
- this.$Message.success(res.msg);
- } else {
- this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
- }
- }, 350);
- }
- });
- }
- });
- break;
- }
- }
- }
- },
- }
- </script>
|