Browse Source

no message

kuaifan 5 năm trước cách đây
mục cha
commit
97f3d84956

+ 123 - 0
app/Http/Controllers/Api/UsersController.php

@@ -148,6 +148,8 @@ class UsersController extends Controller
         $newpass = trim(Request::input('newpass'));
         if (strlen($newpass) < 6) {
             return Base::retError('密码设置不能小于6位数!');
+        } elseif (strlen($newpass) > 32) {
+            return Base::retError('密码最多只能设置32位数!');
         }
         if ($oldpass == $newpass) {
             return Base::retError('新旧密码一致!');
@@ -162,4 +164,125 @@ class UsersController extends Controller
         DB::table('users')->where('id', $user['id'])->update(['encrypt' => Base::generatePassword(6), 'userpass'=>Base::md52($newpass)]);
         return Base::retSuccess('修改成功');
     }
+
+    /**
+     * 团队列表
+     */
+    public function team__lists()
+    {
+        $user = Users::authE();
+        if (Base::isError($user)) {
+            return $user;
+        } else {
+            $user = $user['data'];
+        }
+        //
+        $lists = DB::table('users')->select(['id', 'username', 'nickname', 'userimg', 'profession', 'regdate'])->orderByDesc('id')->paginate(Min(Max(Base::nullShow(Request::input('pagesize'), 10), 1), 200));
+        $lists = Base::getPageList($lists);
+        if ($lists['total'] == 0) {
+            return Base::retError('未找到任何相关的团队成员');
+        }
+        foreach ($lists['lists'] AS $key => $item) {
+            $lists['lists'][$key]['userimg'] = Users::userimg($item['userimg']);
+        }
+        return Base::retSuccess('success', $lists);
+    }
+
+    /**
+     * 添加团队成员
+     */
+    public function team__add()
+    {
+        $user = Users::authE();
+        if (Base::isError($user)) {
+            return $user;
+        } else {
+            $user = $user['data'];
+        }
+        //
+        if (Base::isError(Users::identity('admin'))) {
+            return Base::retError('身份权限不足!', [], -1);
+        }
+        //头像
+        $userimg = Request::input('userimg');
+        if ($userimg) {
+            $userimg = is_array($userimg) ? $userimg[0]['path'] : $userimg;
+        }
+        //昵称
+        $nickname = trim(Request::input('nickname'));
+        if ($nickname) {
+            if (mb_strlen($nickname) < 2) {
+                return Base::retError('昵称不可以少于2个字!');
+            } elseif (mb_strlen($nickname) > 8) {
+                return Base::retError('昵称最多只能设置8个字!');
+            }
+        }
+        //职位/职称
+        $profession = trim(Request::input('profession'));
+        if ($profession) {
+            if (mb_strlen($profession) < 2) {
+                return Base::retError('昵称不可以少于2个字!');
+            } elseif (mb_strlen($profession) > 20) {
+                return Base::retError('昵称最多只能设置20个字!');
+            }
+        }
+        //用户名
+        $username = trim(Request::input('username'));
+        if (strlen($username) < 2) {
+            return Base::retError('用户名不可以少于2个字符!');
+        } elseif (strlen($username) > 12) {
+            return Base::retError('用户名最多只能设置12个字符!');
+        }
+        if (Users::username2id($username) > 0) {
+            return Base::retError('用户名已存在!');
+        }
+        //密码
+        $userpass = trim(Request::input('userpass'));
+        if (strlen($userpass) < 6) {
+            return Base::retError('密码设置不能小于6位数!');
+        } elseif (strlen($userpass) > 32) {
+            return Base::retError('密码最多只能设置32位数!');
+        }
+        //
+        if (DB::table('users')->insert([
+            'userimg' => $userimg ?: '',
+            'nickname' => $nickname ?: '',
+            'profession' => $profession ?: '',
+            'username' => $username,
+            'userpass' => Base::md52($userpass),
+            'regip' => Base::getIp(),
+            'regdate' => Base::time()
+        ])) {
+            return Base::retSuccess('添加成功!');
+        } else {
+            return Base::retError('添加失败!');
+        }
+    }
+
+    /**
+     * 删除团队成员
+     */
+    public function team__delete()
+    {
+        $user = Users::authE();
+        if (Base::isError($user)) {
+            return $user;
+        } else {
+            $user = $user['data'];
+        }
+        //
+        if (Base::isError(Users::identity('admin'))) {
+            return Base::retError('身份权限不足!', [], -1);
+        }
+        $id = intval(Request::input('id'));
+        if ($user['id'] == $id) {
+            return Base::retError('不能删除自己!');
+        }
+        //
+        if (DB::table('users')->where('id', $id)->delete()) {
+            return Base::retSuccess('删除成功!');
+        } else {
+            return Base::retError('删除失败!');
+        }
+    }
 }

+ 1 - 1
app/Http/Controllers/IndexController.php

@@ -16,7 +16,7 @@ use Request;
 class IndexController extends Controller
 {
 
-    private $version = '100001';
+    private $version = '100000';
 
     public function __invoke($method, $action = '', $child = '', $name = '')
     {

+ 6 - 4
app/Module/Base.php

@@ -1754,9 +1754,10 @@ class Base
     /**
      * 获取分页详细信息
      * @param LengthAwarePaginator $lists
+     * @param bool $getTotal
      * @return array
      */
-    public static function getPageInfo(LengthAwarePaginator $lists)
+    public static function getPageInfo(LengthAwarePaginator $lists, $getTotal = true)
     {
         return [
             "currentPage" => $lists->currentPage(),
@@ -1767,18 +1768,19 @@ class Base
             "nextPageUrl" => $lists->nextPageUrl(),
             "previousPageUrl" => $lists->previousPageUrl(),
             "perPage" => $lists->perPage(),
-            "total" => $lists->total(),
+            "total" => $getTotal === true ? $lists->total() : -1,
         ];
     }
 
     /**
      * 获取分页数据
      * @param $lists
+     * @param bool $getTotal
      * @return array
      */
-    public static function getPageList($lists)
+    public static function getPageList($lists, $getTotal = true)
     {
-        $data = Base::getPageInfo($lists);
+        $data = Base::getPageInfo($lists, $getTotal);
         $data['lists'] = Base::coll2array($lists);
         return $data;
     }

+ 36 - 0
app/Module/Users.php

@@ -2,6 +2,7 @@
 
 namespace App\Module;
 
+use App\Model\DBCache;
 use DB;
 use Request;
 use Session;
@@ -175,4 +176,39 @@ class Users
         unset($userinfo['userpass']);
         return $userinfo;
     }
+
+    /**
+     * userid 获取 基本信息
+     * @param int $userid           会员ID
+     * @return array
+     */
+    public static function userid2basic($userid)
+    {
+        if (empty($userid)) {
+            return [];
+        }
+        $fields = ['username', 'nickname', 'userimg', 'profession'];
+        $userInfo = DBCache::table('users')->where('id', $userid)->select($fields)->cacheMinutes(1)->first();
+        if ($userInfo) {
+            $userInfo['userimg'] = Users::userimg($userInfo['userimg']);
+        }
+        return $userInfo ?: [];
+    }
+
+    /**
+     * 用户头像,不存在时返回默认
+     * @param string|int $var 头像地址 或 会员ID
+     * @return \Illuminate\Contracts\Routing\UrlGenerator|string
+     */
+    public static function userimg($var) {
+        if (Base::isNumber($var)) {
+            if (empty($var)) {
+                $var = "";
+            }else{
+                $userInfo = self::userid2basic($var);
+                $var = $userInfo['userimg'];
+            }
+        }
+        return $var ? Base::fillUrl($var) : url('images/other/avatar.png');
+    }
 }

+ 1 - 1
resources/assets/js/_modules/language/global/en.js

@@ -32,7 +32,7 @@ export default {
     "不重要不紧急": null,
     "项目": null,
     "知识库": null,
-    "同事": null,
+    "团队": null,
     "欢迎您": null,
     "个人中心": null,
     "退出登录": null,

+ 3 - 3
resources/assets/js/main/components/WHeader.vue

@@ -10,13 +10,13 @@
                     </li><li :class="value==='doc'?'active':''">
                         <a href="javascript:void(0)" @click="tabPage('doc')"><i class="ft icon">&#xe915;</i>{{$L('知识库')}}</a>
                     </li><li :class="value==='team'?'active':''">
-                        <a href="javascript:void(0)" @click="tabPage('team')"><i class="ft icon">&#xe90d;</i>{{$L('同事')}}</a>
+                        <a href="javascript:void(0)" @click="tabPage('team')"><i class="ft icon">&#xe90d;</i>{{$L('团队')}}</a>
                     </li>
                 </ul>
             </div>
             <div class="w-header-row-flex"></div>
             <div class="w-header-row-right">
-                <Dropdown class="right-info" trigger="hover" @on-click="setRightSelect" placement="bottom-end" transfer>
+                <Dropdown class="right-info" trigger="click" @on-click="setRightSelect" placement="bottom-end" transfer>
                    <div>
                        <span class="username">{{$L('欢迎您')}}, {{(userInfo.nickname || userInfo.username) || $L('尊敬的会员')}}</span>
                        <Icon type="md-arrow-dropdown"/>
@@ -26,7 +26,7 @@
                         <Dropdown-item name="out">{{$L('退出登录')}}</Dropdown-item>
                     </Dropdown-menu>
                 </Dropdown>
-                <Dropdown class="right-info" trigger="hover" @on-click="setLanguage" transfer>
+                <Dropdown class="right-info" trigger="click" @on-click="setLanguage" transfer>
                     <div>
                         <Icon class="right-globe" type="md-globe" size="24"/>
                         <Icon type="md-arrow-dropdown"/>

+ 17 - 0
resources/assets/js/main/main.js

@@ -159,6 +159,23 @@ import '../../sass/main.scss';
         },
 
         /**
+         * 权限是否通过
+         * @param role
+         * @returns {boolean}
+         */
+        identity(role) {
+            let userInfo = $A.getUserInfo();
+            let identity = userInfo.identity;
+            let isRole = false;
+            $A.each(identity, (index, res) => {
+                if (res === role) {
+                    isRole = true;
+                }
+            });
+            return isRole;
+        },
+
+        /**
          * 监听用户信息发生变化
          * @param callback
          */

+ 256 - 5
resources/assets/js/main/pages/team.vue

@@ -8,36 +8,226 @@
         <div class="w-nav">
             <div class="nav-row">
                 <div class="w-nav-left">
-                    <i class="ft icon"></i> {{$L('同事列表')}}
+                    <i class="ft icon">&#xE90D;</i> {{$L('团队成员')}}
                 </div>
                 <div class="w-nav-flex"></div>
                 <div class="w-nav-right">
-                    <span class="ft hover"><i class="ft icon"></i> {{$L('添加同事')}}</span>
+                    <span class="ft hover" @click="addShow=true"><i class="ft icon">&#xE740;</i> {{$L('添加团队成员')}}</span>
                 </div>
             </div>
         </div>
 
-        <w-content></w-content>
+        <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" @on-change="setPage" @on-page-size-change="setPageSize" :page-size-opts="[10,20,30,50,100]" placement="top" show-elevator show-sizer show-total></Page>
+                </div>
+            </div>
+        </w-content>
+
+        <Modal
+            v-model="addShow"
+            :title="$L('添加团队成员')"
+            :closable="false"
+            :mask-closable="false">
+            <Form ref="add" :model="formAdd" :rules="ruleAdd" :label-width="80">
+                <FormItem prop="userimg" :label="$L('头像')">
+                    <ImgUpload v-model="formAdd.userimg"></ImgUpload>
+                </FormItem>
+                <FormItem prop="nickname" :label="$L('昵称')">
+                    <Input type="text" v-model="formAdd.nickname"></Input>
+                </FormItem>
+                <FormItem prop="profession" :label="$L('职位/职称')">
+                    <Input v-model="formAdd.profession"></Input>
+                </FormItem>
+                <FormItem prop="username" :label="$L('用户名')">
+                    <Input type="text" v-model="formAdd.username" :placeholder="$L('添加后不可修改')"></Input>
+                </FormItem>
+                <FormItem prop="userpass" :label="$L('登录密码')">
+                    <Input type="password" v-model="formAdd.userpass" :placeholder="$L('最少6位数')"></Input>
+                </FormItem>
+            </Form>
+            <div slot="footer">
+                <Button type="default" @click="addShow=false">{{$L('取消')}}</Button>
+                <Button type="primary" :loading="loadIng > 0" @click="onAdd">{{$L('添加')}}</Button>
+            </div>
+        </Modal>
 
     </div>
 </template>
 
 <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 WHeader from "../components/WHeader";
     import WContent from "../components/WContent";
+    import ImgUpload from "../components/ImgUpload";
     export default {
-        components: {WContent, WHeader},
+        components: {ImgUpload, WContent, WHeader},
         data () {
             return {
+                loadIng: 0,
+
+                columns: [],
 
+                lists: [],
+                listPage: 1,
+                listTotal: 0,
+                noDataText: "数据加载中.....",
+
+                addShow: false,
+                formAdd: {
+                    userimg: '',
+                    profession: '',
+                    username: '',
+                    nickname: '',
+                    userpass: ''
+                },
+                ruleAdd: {}
             }
         },
+        created() {
+            let isAdmin = $A.identity('admin');
+            this.columns = [{
+                "title": "头像",
+                "minWidth": 50,
+                "maxWidth": 100,
+                render: (h, params) => {
+                    return h('img', {
+                        style: {
+                            width: "36px",
+                            height: "36px",
+                            verticalAlign: "middle",
+                            objectFit: "cover",
+                            borderRadius: "50%"
+                        },
+                        attrs: {
+                            src: params.row.userimg
+                        },
+                    });
+                }
+            }, {
+                "title": "昵称",
+                "minWidth": 80,
+                render: (h, params) => {
+                    return h('span', params.row.nickname || '-');
+                }
+            }, {
+                "title": "账号",
+                "key": 'username',
+                "minWidth": 80,
+            }, {
+                "title": "职位/职称",
+                "minWidth": 80,
+                render: (h, params) => {
+                    return h('span', params.row.profession || '-');
+                }
+            }, {
+                "title": "加入时间",
+                "minWidth": 160,
+                render: (h, params) => {
+                    return h('span', $A.formatDate("Y-m-d H:i:s", params.row.regdate));
+                }
+            }, {
+                "title": "操作",
+                "key": 'action',
+                "width": isAdmin ? 160 : 80,
+                "align": 'center',
+                render: (h, params) => {
+                    let array = [];
+                    array.push(h('Button', {
+                        props: {
+                            type: 'primary',
+                            size: 'small'
+                        },
+                        on: {
+                            click: () => {
+                                this.$Modal.info({
+                                    title: '会员信息',
+                                    content: `<p>昵称: ${params.row.nickname || '-'}</p><p>职位/职称: ${params.row.profession || '-'}</p>`
+                                });
+                            }
+                        }
+                    }, '查看'));
+                    if (isAdmin) {
+                        array.push(h('Button', {
+                            props: {
+                                type: 'warning',
+                                size: 'small'
+                            },
+                            style: {
+                                marginLeft: '5px'
+                            },
+                            on: {
+                                click: () => {
+                                    this.$Modal.confirm({
+                                        title: '删除团队成员',
+                                        content: '你确定要删除此团队成员吗?',
+                                        loading: true,
+                                        onOk: () => {
+                                            $A.aAjax({
+                                                url: 'users/team/delete?id=' + params.row.id,
+                                                success: (res) => {
+                                                    this.$Modal.remove();
+                                                    setTimeout(() => {
+                                                        if (res.ret === 1) {
+                                                            this.$Message.success(res.msg);
+                                                            //
+                                                            this.getLists();
+                                                        }else{
+                                                            this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
+                                                        }
+                                                    }, 350);
+                                                }
+                                            });
+                                        }
+                                    });
+                                }
+                            }
+                        }, '删除'));
+                    }
+                    return h('div', array);
+                }
+            }];
+            //
+            this.ruleAdd = {
+                username: [
+                    { required: true, message: this.$L('请填写用户名!'), trigger: 'blur' }
+                ],
+                userpass: [
+                    { required: true, message: this.$L('请填写登录密码!'), trigger: 'blur' },
+                    { type: 'string', min: 6, message: this.$L('密码长度不能少于6位!'), trigger: 'blur' }
+                ]
+            };
+        },
         mounted() {
-
+            this.listPage = 1;
+            this.getLists();
         },
         computed: {
 
@@ -46,7 +236,68 @@
 
         },
         methods: {
+            setPage(page) {
+                this.listPage = page;
+                this.getLists();
+            },
 
+            setPageSize(size) {
+                if (Math.max($A.runNum(this.listPageSize), 10) != size) {
+                    this.listPageSize = size;
+                    this.getLists();
+                }
+            },
+
+            getLists() {
+                this.loadIng++;
+                $A.aAjax({
+                    url: 'users/team/lists',
+                    data: {
+                        page: Math.max(this.listPage, 1),
+                        pagesize: Math.max($A.runNum(this.listPageSize), 10),
+                    },
+                    complete: () => {
+                        this.loadIng--;
+                    },
+                    success: (res) => {
+                        if (res.ret === 1) {
+                            this.lists = res.data.lists;
+                            this.listTotal = res.data.total;
+                        }else{
+                            this.lists = [];
+                            this.listTotal = 0;
+                            this.noDataText = res.msg;
+                        }
+                    }
+                });
+            },
+
+            onAdd() {
+                this.$refs.add.validate((valid) => {
+                    if (valid) {
+                        this.loadIng++;
+                        $A.aAjax({
+                            url: 'users/team/add',
+                            data: this.formAdd,
+                            complete: () => {
+                                this.loadIng--;
+                            },
+                            success: (res) => {
+                                if (res.ret === 1) {
+                                    this.addShow = false;
+                                    this.$Message.success(res.msg);
+                                    this.$refs.add.resetFields();
+                                    //
+                                    this.listPage = 1;
+                                    this.getLists();
+                                }else{
+                                    this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
+                                }
+                            }
+                        });
+                    }
+                });
+            }
         },
     }
 </script>

+ 29 - 0
resources/assets/sass/main.scss

@@ -140,3 +140,32 @@
         }
     }
 }
+
+.tableFill {
+    .ivu-table {
+        table {
+            width: 100% !important;
+            .ivu-table-cell {
+                display: block;
+                overflow: hidden;
+                white-space: nowrap;
+                text-overflow: ellipsis;
+                padding-left: 12px;
+                padding-right: 12px;
+                > div {
+                    max-width: 100%;
+                    overflow: hidden;
+                    white-space: nowrap;
+                    text-overflow: ellipsis;
+                    vertical-align: middle;
+                    .ivu-tooltip-rel {
+                        vertical-align: middle;
+                    }
+                }
+            }
+        }
+    }
+}
+.pageBox {
+    text-align: center;
+}

+ 1 - 0
resources/assets/statics/README.md

@@ -0,0 +1 @@
+## public目录所有资源将拷贝到public下

+ 0 - 1
resources/assets/statics/public/README.md

@@ -1 +0,0 @@
-## 此目录所有资源将拷贝到public下

resources/assets/statics/public/images/aiwrap.png → resources/assets/statics/public/images/other/aiwrap.png


resources/assets/statics/public/images/alipay.png → resources/assets/statics/public/images/other/alipay.png


resources/assets/statics/public/images/avatar.png → resources/assets/statics/public/images/other/avatar.png


resources/assets/statics/public/images/dir.png → resources/assets/statics/public/images/other/dir.png


resources/assets/statics/public/images/imgerr.jpg → resources/assets/statics/public/images/other/imgerr.jpg


resources/assets/statics/public/images/qq.png → resources/assets/statics/public/images/other/qq.png


resources/assets/statics/public/images/weixin.png → resources/assets/statics/public/images/other/weixin.png


+ 6 - 6
resources/views/ie.blade.php

@@ -60,27 +60,27 @@ if(strstr($uarowser, 'MSIE 6') || strstr($uarowser, 'MSIE 7') || strstr($uarowse
         <div class="browser_list">
             <span>
                 <a href="http://www.google.cn/chrome/browser/desktop/" target="_blank">
-                <img src="{{ asset('statics/images/browser/chrome.png') }}"><br>chrome
+                <img src="{{ asset('images/browser/chrome.png') }}"><br>chrome
                 </a>
             </span>
             <span>
                 <a href="http://www.firefox.com.cn/download/" target="_blank">
-                    <img src="{{ asset('statics/images/browser/firefox.png') }}"><br>firefox
+                    <img src="{{ asset('images/browser/firefox.png') }}"><br>firefox
                 </a>
             </span>
             <span>
                 <a href="https://www.apple.com/cn/safari/" target="_blank">
-                    <img src="{{ asset('statics/images/browser/safari.png') }}"><br>safari
+                    <img src="{{ asset('images/browser/safari.png') }}"><br>safari
                 </a>
             </span>
             <span>
                 <a href="http://chrome.360.cn/" target="_blank">
-                    <img src="{{ asset('statics/images/browser/360.png') }}"><br>360浏览器
+                    <img src="{{ asset('images/browser/360.png') }}"><br>360浏览器
                 </a>
             </span>
             <span>
                 <a href="http://ie.microsoft.com/" target="_blank">
-                    <img src="{{ asset('statics/images/browser/ie.png') }}"><br>ie9及以上
+                    <img src="{{ asset('images/browser/ie.png') }}"><br>ie9及以上
                 </a>
             </span>
         </div>
@@ -88,4 +88,4 @@ if(strstr($uarowser, 'MSIE 6') || strstr($uarowser, 'MSIE 7') || strstr($uarowse
 </div>
 <?php
 }
-?>
+?>

+ 1 - 0
resources/views/main.blade.php

@@ -20,6 +20,7 @@
 </head>
 <body>
 
+@extends('ie')
 <div id="app">
     <div class="app-view-loading">
         <div>