scorpioyq 2 жил өмнө
parent
commit
c43297e66c

+ 3 - 1
src/api/index.js

@@ -14,6 +14,7 @@ import dispatch from './dispatch/index.js'
 import store from './store/index.js'
 import msg from './msg/index.js'
 import contract from "@/api/contract/index.js";
+import role from "@/api/role/index.js";
 
 export default {
     offices: ['pdf', 'doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'PDF'],
@@ -33,5 +34,6 @@ export default {
     dispatch,
     store,
     msg,
-    contract
+    contract,
+    role
 }

+ 20 - 0
src/api/role/index.js

@@ -0,0 +1,20 @@
+import fetch from '../fetch.js'
+
+export default {
+    /**
+     * 用户管理相关借口
+     * @returns {Promise<unknown>}
+     */
+    roleList(params) { // 用户列表
+        return fetch('/blade-user/noRolePage', params, 'get')
+    },
+    roleStart(params) { // 用户启用/停用
+        return fetch('/blade-user/startOrStop', params, 'post')
+    },
+    jobList(params) { // 用户列表
+        return fetch('/blade-system/role/newList', params, 'get')
+    },
+    roleSave(params) { // 保存用户设置信息
+        return fetch('/blade-project-manage-v2/roledept/v2/save', params, 'post', 'json')
+    },
+}

+ 35 - 32
src/layout/top.vue

@@ -1,23 +1,23 @@
 <template>
   <div>
     <el-row
-      class="flex flex-align-center flex-justify-between top"
-      :class="dataType === 'project' ? 'bread' : 'bread-g'"
+        class="flex flex-align-center flex-justify-between top"
+        :class="dataType === 'project' ? 'bread' : 'bread-g'"
     >
       <el-col :span="12">
         <div class="flex flex-justify-start flex-align-center padding">
           <el-button
-            icon="Menu"
-            class="mr-20 white"
-            circle
-            color="#C1C4CB"
-            @click="openMenu"
-            v-if="mini && showMenu"
+              icon="Menu"
+              class="mr-20 white"
+              circle
+              color="#C1C4CB"
+              @click="openMenu"
+              v-if="mini && showMenu"
           />
           <router-link to="/">
             <div class="flex flex-center">
-              <img v-if="dataType === 'project'" src="@/assets/svg/logo.svg" />
-              <img v-else src="@/assets/svg/logo-white.svg" />
+              <img v-if="dataType === 'project'" src="@/assets/svg/logo.svg"/>
+              <img v-else src="@/assets/svg/logo-white.svg"/>
             </div>
           </router-link>
         </div>
@@ -25,8 +25,8 @@
       <el-col :span="12">
         <div class="flex-child-average flex-justify-end flex padding-right">
           <div
-            class="padding flex flex-align-center pointer"
-            :class="dataType === 'project' ? 'black' : 'white'"
+              class="padding flex flex-align-center pointer"
+              :class="dataType === 'project' ? 'black' : 'white'"
           >
             <!--            <el-button-->
             <!--              icon="Search"-->
@@ -36,24 +36,24 @@
             <!--            />-->
 
             <el-badge
-              :value="msgCount"
-              :max="99"
-              class="ml-20"
-              :hidden="msgCount === null || msgCount === 0"
+                :value="msgCount"
+                :max="99"
+                class="ml-20"
+                :hidden="msgCount === null || msgCount === 0"
             >
               <el-button
-                icon="Bell"
-                circle
-                color="#C1C4CB"
-                @click="$router.push('/msg')"
+                  icon="Bell"
+                  circle
+                  color="#C1C4CB"
+                  @click="$router.push('/msg')"
               />
             </el-badge>
           </div>
           <div class="padding flex flex-align-center pointer">
             <el-avatar
-              class="mr-10"
-              :size="30"
-              :src="
+                class="mr-10"
+                :size="30"
+                :src="
                 user.info.avatarUrl && user.info.avatarUrl.length > 0
                   ? user.info.avatarUrl
                   : 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
@@ -63,12 +63,13 @@
               <span class="flex flex-center">
                 {{ user.info.userName }} / {{ user.info.deptName }}
                 <el-icon class="el-icon--right">
-                  <arrow-down />
+                  <arrow-down/>
                 </el-icon>
               </span>
               <template #dropdown>
                 <el-dropdown-menu>
                   <el-dropdown-item command="info">个人中心</el-dropdown-item>
+                  <el-dropdown-item command="manage">用户管理</el-dropdown-item>
                   <el-dropdown-item command="logout">退出登录</el-dropdown-item>
                 </el-dropdown-menu>
               </template>
@@ -77,25 +78,25 @@
         </div>
       </el-col>
     </el-row>
-    <search :show="show" @close="show = false" />
+    <search :show="show" @close="show = false"/>
   </div>
 </template>
 
 <script>
 import navStore from '../store/nav.js'
-import { useStore } from '../store/user.js'
+import {useStore} from '../store/user.js'
 import permissionStore from '@/store/permission.js'
 import search from './search/index.vue'
 import config from '../config/website.js'
 
 export default {
   name: 'top',
-  components: { search },
+  components: {search},
   setup() {
     const nav = navStore()
     const user = useStore()
     const permission = permissionStore()
-    return { nav, user, permission }
+    return {nav, user, permission}
   },
   props: {
     showMenu: {
@@ -188,9 +189,9 @@ export default {
     },
     initWebSocket() {
       const wsuri =
-        location.host.indexOf('dev') > -1
-          ? 'wss://dev.wutongshucloud.com/ws/websocket/' + this.user.info.userId
-          : config.wss + this.user.info.userId
+          location.host.indexOf('dev') > -1
+              ? 'wss://dev.wutongshucloud.com/ws/websocket/' + this.user.info.userId
+              : config.wss + this.user.info.userId
       this.websock = new WebSocket(wsuri)
       this.websock.onmessage = this.websocketonmessage
       // 连接建立时触发
@@ -288,6 +289,8 @@ export default {
     dropDown(res) {
       if (res === 'info') {
         this.$router.push('/user')
+      } else if (res === 'manage') {
+        this.$router.push('/user/manage')
       } else if (res === 'logout') {
         this.$api.login.logout().then(res => {
           if (res.success === 'true') {
@@ -361,7 +364,7 @@ export default {
     },
     getTotal() {
       this.resultCount = 0
-      this.$api.project.total({ keyword: this.params.keyword }).then(res => {
+      this.$api.project.total({keyword: this.params.keyword}).then(res => {
         if (res.code === 200) {
           this.type[0].count = res.data.projectTotal
           this.type[1].count = res.data.fileTotal

+ 91 - 88
src/page/login.vue

@@ -4,8 +4,8 @@
       <div class="flex flex-center flex-child-average">
         <div class="flex left">
           <img
-            src="https://wutong-1302848345.cos.ap-chengdu.myqcloud.com/wtzx/3938373d1b0c44c899f94cba263ff4a8.jpg"
-            style="
+              src="https://wutong-1302848345.cos.ap-chengdu.myqcloud.com/wtzx/3938373d1b0c44c899f94cba263ff4a8.jpg"
+              style="
               height: 560px;
               object-fit: contain;
               border-bottom-left-radius: 10px;
@@ -17,80 +17,80 @@
         <div class="right flex flex-col flex-child-average">
           <div class="flex flex-col flex-justify-between" style="height: 560px">
             <div
-              class="flex flex-justify-end"
-              style="margin-right: 3px; margin-top: 3px"
+                class="flex flex-justify-end"
+                style="margin-right: 3px; margin-top: 3px"
             >
               <div>
                 <img
-                  v-if="qrCodeLogin"
-                  src="../assets/img/com.png"
-                  style="width: 80px"
-                  @click="qrCodeLogin = !qrCodeLogin"
+                    v-if="qrCodeLogin"
+                    src="../assets/img/com.png"
+                    style="width: 80px"
+                    @click="qrCodeLogin = !qrCodeLogin"
                 />
                 <img
-                  v-else
-                  src="../assets/img/code.png"
-                  style="width: 80px"
-                  @click="qrCodeLogin = !qrCodeLogin"
+                    v-else
+                    src="../assets/img/code.png"
+                    style="width: 80px"
+                    @click="qrCodeLogin = !qrCodeLogin"
                 />
               </div>
             </div>
 
             <div
-              v-if="qrCodeLogin"
-              class="flex flex-center flex-col"
-              style="height: 500px; margin-top: -20px"
+                v-if="qrCodeLogin"
+                class="flex flex-center flex-col"
+                style="height: 500px; margin-top: -20px"
             >
               <span class="font-24 black bold">欢迎来到梧桐树云服务👏</span>
               <div
-                class="flex flex-col flex-center"
-                style="height: 360px; width: 360px; margin-top: -20px"
+                  class="flex flex-col flex-center"
+                  style="height: 360px; width: 360px; margin-top: -20px"
               >
                 <vue-qr
-                  :currentLevel="3"
-                  :logoCornerRadius="4"
-                  :logoScale="0.25"
-                  :logoSrc="logoSrc"
-                  :text="qrCodeText"
-                  size="260"
+                    :currentLevel="3"
+                    :logoCornerRadius="4"
+                    :logoScale="0.25"
+                    :logoSrc="logoSrc"
+                    :text="qrCodeText"
+                    size="260"
                 />
               </div>
               <span
-                class="mt-10 bold main-color font-16"
-                style="margin-top: -20px"
-                >打开微信扫描二维码登录梧桐树云服务</span
+                  class="mt-10 bold main-color font-16"
+                  style="margin-top: -20px"
+              >打开微信扫描二维码登录梧桐树云服务</span
               >
             </div>
             <div v-else class="flex flex-col flex-center" style="height: 500px">
               <span class="font-24 black bold">欢迎来到梧桐树云服务👏</span>
               <div
-                class="flex flex-col flex-center mt-5"
-                style="width: 450px; height: 400px"
+                  class="flex flex-col flex-center mt-5"
+                  style="width: 450px; height: 400px"
               >
                 <el-form ref="loginForm" :model="form" :rules="rules">
                   <el-form-item prop="name">
                     <el-input
-                      v-model="form.name"
-                      placeholder="用户帐号"
-                      prefix-icon="Avatar"
-                      size="large"
+                        v-model="form.name"
+                        placeholder="用户帐号"
+                        prefix-icon="Avatar"
+                        size="large"
                     />
                   </el-form-item>
                   <el-form-item prop="pass">
                     <el-input
-                      v-model="form.pass"
-                      :type="flag ? 'text' : 'password'"
-                      placeholder="密码"
-                      prefix-icon="WalletFilled"
-                      size="large"
+                        v-model="form.pass"
+                        :type="flag ? 'text' : 'password'"
+                        placeholder="密码"
+                        prefix-icon="WalletFilled"
+                        size="large"
                     >
                       <template v-slot:suffix>
                         <div class="pointer" @click="flag = !flag">
                           <el-icon v-if="!flag">
-                            <Hide />
+                            <Hide/>
                           </el-icon>
                           <el-icon v-else>
-                            <View />
+                            <View/>
                           </el-icon>
                         </div>
                       </template>
@@ -98,70 +98,72 @@
                   </el-form-item>
                   <el-form-item prop="code">
                     <el-input
-                      v-model="form.code"
-                      class="append"
-                      placeholder="验证码"
-                      prefix-icon="Refresh"
-                      size="large"
-                      @keyup.enter="submint"
+                        v-model="form.code"
+                        class="append"
+                        placeholder="验证码"
+                        prefix-icon="Refresh"
+                        size="large"
+                        @keyup.enter="submint"
                     >
                       <template v-slot:append>
                         <img
-                          :src="code"
-                          class="pic"
-                          @click="init"
-                          style="
+                            :src="code"
+                            class="pic"
+                            @click="init"
+                            style="
                             height: 40px;
                             background-color: red;
                             background-blend-mode: lighten;
                           "
-                          alt="code"
+                            alt="code"
                         />
                       </template>
                     </el-input>
                   </el-form-item>
                   <el-form-item>
                     <div
-                      class="flex flex-align-center flex-justify-between full-width"
+                        class="flex flex-align-center flex-justify-between full-width"
                     >
                       <div></div>
                       <el-link :underline="false" class="font-12" type="primary"
-                        >忘记密码?</el-link
+                      >忘记密码?
+                      </el-link
                       >
                     </div>
                   </el-form-item>
                 </el-form>
                 <el-button
-                  size="large"
-                  style="width: 78%"
-                  type="primary"
-                  @click="submint"
-                  >登录</el-button
+                    size="large"
+                    style="width: 78%"
+                    type="primary"
+                    @click="submint"
+                >登录
+                </el-button
                 >
                 <div class="flex flex-col mt-10 flex-center">
                   <span class="grey-6">由梧桐研究院提供技术支持</span>
-                  <span class="grey-6 mt-5">使用问题请咨询:15887001274</span>
+                  <span class="grey-6 mt-5">使用问题请咨询:15587166921</span>
                   <el-button
-                    color="#558FF1"
-                    @click="
+                      color="#558FF1"
+                      @click="
                       download(
                         'https://wutong-1302848345.cos.ap-chengdu.myqcloud.com/wtzx/a53cc056c3914ae9884992dafe7a9679.pdf'
                       )
                     "
-                    style="width: 160px"
-                    plain
-                    class="mt-10 blockss"
+                      style="width: 160px"
+                      plain
+                      class="mt-10 blockss"
                   >
                     点击下载用户指南
                   </el-button>
                   <span class="grey-6 mt-5 font-12 mt-20"
-                    >为了获得最佳体验,您可以<span
+                  >为了获得最佳体验,您可以<span
                       class="blue pointer"
                       @click="
                         download('https://www.google.cn/intl/zh-CN/chrome/')
                       "
-                      >点击此处</span
-                    >获取Chrome 浏览器</span
+                  >点击此处</span
+                  >获取Chrome 浏览器</span
                   >
                 </div>
               </div>
@@ -171,7 +173,7 @@
       </div>
     </div>
     <div class="footer">
-      <foolter />
+      <foolter/>
     </div>
   </div>
 </template>
@@ -186,15 +188,15 @@ layout: 'empty',
 
 <script>
 import md5 from 'js-md5'
-import { useStore } from '@/store/user.js'
-import { removeToken, setToken } from '../utils/auth.js'
+import {useStore} from '@/store/user.js'
+import {removeToken, setToken} from '../utils/auth.js'
 import permissionStore from '@/store/permission.js'
 import VueQr from 'vue-qr/src/packages/vue-qr.vue'
 import foolter from '@/layout/foolter.vue'
 
 export default {
   name: 'login',
-  components: { VueQr, foolter },
+  components: {VueQr, foolter},
   watch: {
     qrCodeLogin: {
       handler(val) {
@@ -209,27 +211,27 @@ export default {
   setup() {
     const user = useStore()
     const permission = permissionStore()
-    return { user, permission }
+    return {user, permission}
   },
   data() {
     return {
       flag: false,
       form: {
-        name: '',
-        pass: ''
+        name: 'adminzj',
+        pass: '123456'
       },
       rules: {
         name: [
-          { required: true, message: '请输入用户帐号', trigger: 'blur' }
+          {required: true, message: '请输入用户帐号', trigger: 'blur'}
           // { min: 11, max: 11, message: '请输入11位手机号', trigger: 'blur' }
         ],
         pass: [
-          { required: true, message: '请输入密码', trigger: 'blur' },
-          { min: 3, max: 16, message: '长度在 3 到 16 个字符', trigger: 'blur' }
+          {required: true, message: '请输入密码', trigger: 'blur'},
+          {min: 3, max: 16, message: '长度在 3 到 16 个字符', trigger: 'blur'}
         ],
         code: [
-          { required: true, message: '请输入验证码', trigger: 'blur' },
-          { min: 5, max: 5, message: '验证码不正确', trigger: 'blur' }
+          {required: true, message: '请输入验证码', trigger: 'blur'},
+          {min: 5, max: 5, message: '验证码不正确', trigger: 'blur'}
         ]
       },
       code: '',
@@ -248,8 +250,8 @@ export default {
     // fixme prod 环境暂时开启账号登录功能
     // this.dev = window.location.href.indexOf('localhost') > -1 || window.location.href.indexOf('https://dev.wutongshucloud.com/') > -1 || window.location.href.indexOf('192.168.31') > -1
     this.dev =
-      window.location.href.indexOf('localhost') > -1 ||
-      window.location.href.indexOf('192.168.31') > -1
+        window.location.href.indexOf('localhost') > -1 ||
+        window.location.href.indexOf('192.168.31') > -1
     removeToken()
     this.init()
   },
@@ -259,14 +261,14 @@ export default {
   methods: {
     init() {
       const dev =
-        window.location.href.indexOf('dash.wutongshucloud.com') > -1 ||
-        window.location.href.indexOf('localhost') > -1
+          window.location.href.indexOf('dash.wutongshucloud.com') > -1 ||
+          window.location.href.indexOf('localhost') > -1
       sessionStorage.setItem('dev', dev)
       this.$api.login.captcha().then(res => {
         this.code = res.image
         this.header = res.key
       })
-      const menu = { active: 0, subActive: 0 }
+      const menu = {active: 0, subActive: 0}
       localStorage.setItem('index', JSON.stringify(menu))
       localStorage.removeItem('data-type')
     },
@@ -293,7 +295,7 @@ export default {
               this.init()
             } else {
               setToken(res.access_token)
-              this.user.setUserInfo({ name: res.real_name })
+              this.user.setUserInfo({name: res.real_name})
               this.getInfo()
             }
           })
@@ -304,8 +306,8 @@ export default {
     },
     download(url) {
       window.open(
-        url,
-        '_blank' // <- This is what makes it open in a new window.
+          url,
+          '_blank' // <- This is what makes it open in a new window.
       )
     },
     loginAdmin() {
@@ -353,12 +355,12 @@ export default {
         if (res.code === 200) {
           this.sessionId = res.data
           this.qrCodeText =
-            'https://prod.wutongshucloud.com/login?id=' + this.sessionId
+              'https://prod.wutongshucloud.com/login?id=' + this.sessionId
         }
       })
     },
     codeLogin() {
-      this.$api.login.qrCodeLogin({ sessionId: this.sessionId }).then(res => {
+      this.$api.login.qrCodeLogin({sessionId: this.sessionId}).then(res => {
         if (res.code === 200) {
           const tmp = res.data
           if (Object.prototype.hasOwnProperty.call(tmp, 'phone')) {
@@ -394,6 +396,7 @@ export default {
   background-image: url('https://wutong-1302848345.cos.ap-chengdu.myqcloud.com/wtzx/7667edec62f44063a50c66e8654eaa87.png');
   background-size: cover;
   background-repeat: no-repeat;
+
   .footer {
     position: fixed;
     bottom: 10px;

+ 369 - 0
src/views/user/manage.vue

@@ -0,0 +1,369 @@
+<template>
+  <basic-container class="mt-10">
+    <avue-crud
+        :option="option"
+        :data="data"
+        ref="crud"
+        v-model="form"
+        :before-open="beforeOpen"
+        @current-change="currentChange"
+        @size-change="sizeChange"
+        @row-save="rowSave"
+        @row-update="rowUpdate"
+        @on-load="onLoad"
+    >
+      <template #menu="{ row }">
+        <el-button
+            icon="Open"
+            type="primary"
+            text
+            @click="Enable(row)"
+        >
+          {{ row.clientId.indexOf('project_web') === -1 ? '启用' : '停用' }}
+        </el-button>
+      </template>
+      <template #status="{row}">
+        <el-tag :type="row.clientId.indexOf('project_web') === -1 ? 'danger':''">
+          {{ row.clientId.indexOf('project_web') === -1 ? '停用' : '启用' }}
+        </el-tag>
+      </template>
+    </avue-crud>
+    <el-dialog
+        v-model="showEdit"
+        append-to-body
+        center
+        title="用户信息设置"
+        width="50%"
+    >
+      <div>
+        <el-form
+            ref="form"
+            :model="userInfoForm"
+            :rules="rules"
+            class="mt-20"
+            label-width="100px"
+        >
+          <div class="flex flex-center">
+            <el-form-item class="full-width" label="用户名称" prop="name">
+              <el-input
+                  v-model="userInfoForm.name"
+                  clearable
+                  placeholder="输入用户名称"
+              />
+            </el-form-item>
+            <el-form-item
+                class="full-width mr-20"
+                label="真实姓名"
+                :rules="rules"
+                prop="realName"
+            >
+              <el-input
+                  v-model="userInfoForm.realName"
+                  clearable
+                  placeholder="输入真实姓名"
+              >
+              </el-input>
+            </el-form-item>
+          </div>
+          <div class="flex flex-center">
+            <el-form-item class="full-width" label="手机号码" prop="phone">
+              <el-input
+                  v-model="userInfoForm.phone"
+                  clearable
+                  placeholder="输入手机号码"
+              >
+              </el-input>
+            </el-form-item>
+            <el-form-item class="full-width mr-20" label="登陆密码" prop="password">
+              <el-input
+                  v-model="userInfoForm.password"
+                  clearable
+                  placeholder="输入登陆密码"
+              >
+              </el-input>
+            </el-form-item>
+          </div>
+          <div class="flex flex-align-center">
+            <span class="ml-20 bold">部门选择</span>
+            <el-form-item class="flex">
+              <el-select
+                  class="mt-20"
+                  v-model="userInfoForm.deptId"
+                  style="width: 250px;margin-left: -75px"
+                  placeholder="选择用户所属部门"
+              >
+                <el-option
+                    v-for="item in deptList"
+                    :key="item.id"
+                    :label="item.deptName"
+                    :value="item.id"
+                />
+              </el-select>
+            </el-form-item>
+          </div>
+          <div class="flex flex-col mt-10">
+            <span class="ml-20 bold">职务选择</span>
+            <el-form-item class="flex flex-wrap">
+              <div
+                  class="flex flex-center padding pointer"
+              >
+                <el-radio-group size="large" v-model="userInfoForm.roleIds">
+                  <el-radio v-for="item in jobs"
+                            :key="item.id" :label="item.id">{{ item.roleName }}
+                  </el-radio>
+                </el-radio-group>
+              </div>
+            </el-form-item>
+          </div>
+          <div class="flex flex-col" style="margin-top: -10px">
+            <div class="flex flex-align-center">
+              <span class="bold ml-20">权限选择</span>
+              <el-checkbox size="large" style="margin-left: 33px" v-model="checkAll" @change="choseAll">全选
+              </el-checkbox>
+            </div>
+            <el-form-item class="flex flex-wrap">
+              <div
+                  class="flex flex-center padding pointer"
+              >
+                <el-checkbox v-model="item.checked" :label="item.id" size="large" v-for="item in deptList"
+                             :key="item.id" @change="deptChose($event,item)">
+                  {{ item.deptName }}
+                </el-checkbox>
+              </div>
+            </el-form-item>
+          </div>
+          <div class="flex flex-center">
+            <base-button title="取消" type="0" icon="Close" @click="showEdit = false"/>
+            <base-button class="ml-10" title="保存" icon="Check" @click="roleSave"/>
+          </div>
+        </el-form>
+      </div>
+    </el-dialog>
+  </basic-container>
+</template>
+
+<route>
+{
+name: '用户管理',
+meta: { keepAlive: true }
+}
+</route>
+
+<script>
+import BasicContainer from '@/components/basic-container/main.vue'
+import {useStore} from '@/store/user.js'
+import baseButton from "@/components/base-button.vue";
+
+export default {
+  name: "manage",
+  components: {
+    BasicContainer, baseButton
+  },
+  setup() {
+    const user = useStore()
+    return {user}
+  },
+  data() {
+    return {
+      showAdd: false,
+      showEdit: false,
+      form: {},
+      data: [],
+      option: {
+        align: 'center',
+        menuAlign: 'center',
+        menuWidth: 240,
+        size: 'mini',
+        addBtn: true,
+        addBtnText: '添加用户',
+        viewBtn: false,
+        delBtn: false,
+        refreshBtn: false,
+        columnBtn: false,
+        labelWidth: 140,
+        border: true,
+        column: [
+          {
+            label: '用户名称',
+            prop: 'name',
+            display: false,
+            width: 170
+          },
+          {
+            label: '真实姓名',
+            prop: 'realName',
+          },
+          {
+            label: '手机号码',
+            prop: 'phone',
+          },
+          {
+            label: '职务',
+            prop: 'roleName',
+          },
+          {
+            label: '状态',
+            prop: 'status',
+          },
+        ]
+      },
+      jobs: [],
+      deptList: [],
+      checkAll: false,
+      userInfoForm: {
+        name: '',
+        realName: '',
+        phone: '',
+        password: '',
+        roleIds: '',
+        deptIds: [],
+        deptId: ''
+      },
+      rules: {
+        name: {
+          required: true, message: '用户名称不能为空!', trigger: 'blur',
+        },
+        realName: {
+          required: true, message: '真实姓名不能为空!', trigger: 'blur',
+        },
+        phone: [{
+          required: true, message: '手机号码不能为空!', trigger: 'blur',
+        },
+          {min: 11, max: 11, message: '请填写正确的手机号码!', trigger: 'blur'},
+        ],
+        password: [
+          {required: true, message: '请输入密码', trigger: 'blur'},
+          {min: 3, max: 16, message: '长度在 3 到 16 个字符', trigger: 'blur'}
+        ],
+      }
+    }
+  },
+  created() {
+    this.getJobList()
+    this.getOrg()
+  },
+  methods: {
+    onLoad() {
+      this.loading = true
+      const id = this.user.info.deptId
+      this.$api.role.roleList({deptId: id}).then(res => {
+        this.loading = false
+        if (res.code === 200) {
+          this.data = res.data.records
+        } else {
+          this.$message.error(msg)
+        }
+      })
+          .finally(() => {
+            this.loading = false
+          })
+    },
+    Enable(row) {
+      this.$confirm("确定启用/停用该用户?", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      })
+          .then(() => {
+            this.$api.role.roleStart({
+              userId: row.id,
+              status: row.clientId.indexOf('project_web') > -1 ? 0 : 1
+            }).then(res => {
+              if (res.code === 200) {
+                this.$message.success(res.msg)
+                this.onLoad()
+              } else {
+                this.$message.error(res.msg)
+              }
+            })
+          })
+    },
+    beforeOpen(done, type) {
+      if (type === 'edit') {
+        this.userInfoForm.name = this.form.name
+        this.userInfoForm.realName = this.form.realName
+        this.userInfoForm.phone = this.form.phone
+        this.userInfoForm.password = this.form.password
+        this.jobs.find(e => {
+          const temp = this.form.roleId.split(',').find(sub => sub === e.id)
+          if (temp) {
+            this.userInfoForm.roleIds = temp
+          }
+        })
+        // this.form.deptId.split(',').forEach(ele => {
+        //   const tmp = this.deptList.findIndex(sub => sub.id === ele)
+        //   console.log(tmp)
+        //   if (tmp > -1) {
+        //     this.deptList[tmp].checked = true
+        //   }
+        //   console.log(this.deptList)
+        // })
+        this.showEdit = true
+      } else {
+        done()
+      }
+    },
+    currentChange(currentPage) {
+      this.page.current = currentPage
+    },
+    sizeChange(pageSize) {
+      this.page.size = pageSize
+    },
+    getJobList() {
+      this.$api.role.jobList({roleAlias: 'post'}).then(res => {
+        if (res.code === 200) {
+          this.jobs = res.data
+        }
+      })
+    },
+    getOrg() {
+      this.$api.common.deptList().then(res => {
+        if (res.code === 200) {
+          this.showOrg = true
+          this.deptList = res.data.map(e => {
+            e.checked = false
+            return e
+          })
+        } else {
+          this.$message.error(res.msg)
+        }
+      })
+    },
+    choseAll(res) {
+      this.deptList.map(e => {
+        e.checked = res
+        return e
+      })
+      if (res) {
+        this.userInfoForm.deptIds = this.deptList.map(e => e.id)
+      } else {
+        this.userInfoForm.deptIds = []
+      }
+      console.log(this.userInfoForm.deptIds)
+    },
+    deptChose(res, item) {
+      const tmp = this.deptList.find(ele => ele.id === item.id)
+      if (tmp) {
+        if (tmp.checked) {
+          this.userInfoForm.deptIds.push(tmp.id)
+        } else {
+          this.userInfoForm.deptIds = this.userInfoForm.deptIds.filter(ele => ele !== tmp.id)
+        }
+      }
+      const count = this.deptList.filter(e => e.checked).length
+      this.checkAll = count === this.deptList.length;
+    },
+    roleSave() {
+      let data = this.userInfoForm
+      data.deptIds = data.deptIds.join(',')
+      this.$api.role.roleSave(data).then(res => {
+        console.log(res)
+      })
+    }
+  }
+}
+</script>
+
+<style scoped>
+
+</style>