linwenxin 1 rok pred
rodič
commit
6e79f33141

+ 5 - 25
src/components/template/operation_mixin.js

@@ -23,40 +23,20 @@ export default {
     optionsEvensAuth(key, obj) {
       var roleItems = this.$route.meta.roleItems
       if (!roleItems || !roleItems.length) {
-        return {
-          isRole: false,
-          name: ""
-        }
+        return { isRole: false }
       }
       if (key instanceof Array) {
         if (!hasCommonElements(roleItems.map(item => item.code), key)) {
-          return {
-            isRole: false,
-            name: ""
-          }
+          return { isRole: false }
         } else {
-          if (typeof obj == 'function') {
-            return obj(roleItems)
-          } else {
-            return obj
-          }
+          return typeof obj == 'function' ? obj(roleItems) : obj
         }
       } else {
         var role = roleItems?.find(item => item.code === key)
         if (!role) {
-          return {
-            isRole: false,
-            name: ""
-          }
+          return { isRole: false }
         } else {
-          if (typeof obj == 'function') {
-            return obj(role)
-          } else {
-            return {
-              name: role.moduleName,
-              ...obj
-            }
-          }
+          return typeof obj == 'function' ? obj(role) : { name: role.moduleName, ...obj }
         }
       }
     },

+ 68 - 60
src/views/setting/account/index.vue

@@ -9,13 +9,17 @@
           <el-button size="small" type="primary" icon="el-icon-plus" @click="addOrEdit('add')">新增账户</el-button>
         </div>
         <div class="fr">
-          <el-select v-model="screenForm.role" placeholder="全部" size="small" style="width: 120px; margin-right: 10px;" @change="getListByScreen">
+          <el-select v-model="screenForm.role" placeholder="全部" size="small" style="width: 120px; margin-right: 10px;"
+            @change="getListByScreen">
             <el-option label="全部角色" value=""></el-option>
-            <el-option :label="item.name" :value="item.adminRoleId" v-for="(item, index) in roleList" :key="index"></el-option>
+            <el-option :label="item.name" :value="item.adminRoleId" v-for="(item, index) in roleList"
+              :key="index"></el-option>
           </el-select>
-          <el-select v-model="screenForm.status" placeholder="全部" size="small" style="width: 120px; margin-right: 10px;" @change="getListByScreen">
+          <el-select v-model="screenForm.status" placeholder="全部" size="small" style="width: 120px; margin-right: 10px;"
+            @change="getListByScreen">
             <el-option label="全部状态" value=""></el-option>
-            <el-option :label="item.label" :value="item.value" v-for="(item, index) in select_status" :key="index"></el-option>
+            <el-option :label="item.label" :value="item.value" v-for="(item, index) in select_status"
+              :key="index"></el-option>
           </el-select>
           <el-input placeholder="请输入内容" v-model="screenForm.keyword" size="small" style="width: 180px;">
             <el-button slot="append" icon="el-icon-search" size="small" @click="getListByScreen"></el-button>
@@ -24,8 +28,8 @@
       </div>
 
       <div class="table">
-        <el-table v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe>
-
+        <el-table v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit highlight-current-row
+          stripe>
           <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
           <el-table-column align="center" label="账号" prop="userName" min-width="120"></el-table-column>
           <el-table-column align="center" label="用户名" prop="nickName" min-width="120"></el-table-column>
@@ -34,34 +38,31 @@
           <el-table-column align="center" label="最后登录时间" prop="lastLoginTime" min-width="160"></el-table-column>
           <el-table-column align="center" label="状态" class-name="status-col">
             <template slot-scope="scope">
-              <el-tag :type="scope.row.status ? 'success':'danger'">{{ scope.row.status ? '正常':'冻结' }}</el-tag>
+              <el-tag :type="scope.row.status ? 'success' : 'danger'">{{ scope.row.status ? '正常' : '冻结' }}</el-tag>
             </template>
           </el-table-column>
           <el-table-column align="center" label="操作" min-width="160">
             <template slot-scope="scope">
-              <el-popconfirm v-if="scope.row.status" style="margin-right: 10px;" title="确定冻结吗?" @confirm="changeStatus(scope.row.adminUserId, 0)" >
+              <el-popconfirm v-if="scope.row.status" style="margin-right: 10px;" title="确定冻结吗?"
+                @confirm="changeStatus(scope.row.adminUserId, 0)">
                 <el-button slot="reference" type="text">冻结</el-button>
               </el-popconfirm>
-              <el-popconfirm v-else style="margin-right: 10px;" title="确定恢复吗?" @confirm="changeStatus(scope.row.adminUserId, 1)" >
+              <el-popconfirm v-else style="margin-right: 10px;" title="确定恢复吗?"
+                @confirm="changeStatus(scope.row.adminUserId, 1)">
                 <el-button slot="reference" type="text">恢复</el-button>
               </el-popconfirm>
-              
+
               <el-button type="text" @click="addOrEdit('edit', scope.row.adminUserId)">编辑</el-button>
               <el-button type="text" @click="handleReset(scope.row.adminUserId)">重置密码</el-button>
             </template>
           </el-table-column>
         </el-table>
       </div>
-      
+
       <div class="pagination clearfix">
         <div class="fr">
-          <el-pagination
-            @size-change="handleSizeChange"
-            @current-change="handleCurrentChange"
-            :current-page="currentPage"
-            :page-sizes="[10, 20, 30, 50]"
-            :page-size="10"
-            layout="total, sizes, prev, pager, next, jumper"
+          <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
+            :page-sizes="[10, 20, 30, 50]" :page-size="10" layout="total, sizes, prev, pager, next, jumper"
             :total="listTotal">
           </el-pagination>
         </div>
@@ -69,16 +70,19 @@
     </div>
 
     <!-- 重置密码 -->
-    <el-dialog title="重置密码" :visible.sync="resetFormVisible" :show-close="false" width="40%" :close-on-click-modal="false">
+    <el-dialog title="重置密码" :visible.sync="resetFormVisible" :show-close="false" width="40%"
+      :close-on-click-modal="false">
       <el-form ref="resetForm" :model="resetForm" :rules="resetFormRules" label-position="left" label-width="100px">
         <el-form-item label="输入新密码" prop="newPassword">
-          <el-input v-model="resetForm.newPassword" ref="password1" autocomplete="off" placeholder="请输入新密码" :type="passwordType1"></el-input>
+          <el-input v-model="resetForm.newPassword" ref="password1" autocomplete="off" placeholder="请输入新密码"
+            :type="passwordType1"></el-input>
           <span class="show-pwd" @click="showPwd(1)">
             <svg-icon :icon-class="passwordType1 === 'password' ? 'eye' : 'eye-open'" />
           </span>
         </el-form-item>
         <el-form-item label="确认密码" prop="confirmPassword">
-          <el-input v-model="resetForm.confirmPassword" ref="password2" autocomplete="off" placeholder="请再次输入新密码" :type="passwordType2"></el-input>
+          <el-input v-model="resetForm.confirmPassword" ref="password2" autocomplete="off" placeholder="请再次输入新密码"
+            :type="passwordType2"></el-input>
           <span class="show-pwd" @click="showPwd(2)">
             <svg-icon :icon-class="passwordType2 === 'password' ? 'eye' : 'eye-open'" />
           </span>
@@ -91,8 +95,9 @@
     </el-dialog>
 
     <!-- 新增编辑账户 -->
-    <el-dialog :title="addFormType == 'add' ? '新增账户':'编辑账户'" :visible.sync="addFormVisible" :show-close="false" width="40%" :close-on-click-modal="false">
-      <el-form ref="addForm" :model="addForm" :rules="addFormRules" label-position="left" label-width="80px">
+    <el-dialog :title="addFormType == 'add' ? '新增账户' : '编辑账户'" :visible.sync="addFormVisible" :show-close="false"
+      width="500px" :close-on-click-modal="false">
+      <el-form ref="addForm" :model="addForm" :rules="addFormRules" label-position="left" label-width="120px">
         <el-form-item label="账号" prop="account">
           <el-input v-model="addForm.account" autocomplete="off" placeholder="请输入账号"></el-input>
         </el-form-item>
@@ -101,33 +106,33 @@
         </el-form-item>
         <el-form-item label="角色组" prop="role">
           <el-select v-model="addForm.role" placeholder="请选择角色组" style="width: 100%;">
-            <el-option :label="item.name" :value="item.adminRoleId" v-for="(item, index) in roleList" :key="index"></el-option>
+            <el-option :label="item.name" :value="item.adminRoleId" v-for="(item, index) in roleList"
+              :key="index"></el-option>
           </el-select>
         </el-form-item>
         <el-form-item label="网点" prop="adminWebsitId">
-          <!-- filterable -->
-          <el-cascader
-            style="width: 100%"
-            :options="departmentList"
-            :props="{ checkStrictly: true, value: 'websitId', label: 'name' }"
-            v-model="addForm.adminWebsitId"
-            clearable
-          >
+          <el-cascader style="width: 100%" :options="departmentList"
+            :props="{ checkStrictly: true, value: 'websitId', label: 'name' }" v-model="addForm.adminWebsitId" clearable>
           </el-cascader>
         </el-form-item>
         <el-form-item label="密码" prop="newPassword">
-          <el-input v-model="addForm.newPassword" ref="password1" autocomplete="off" placeholder="请输入密码" :type="passwordType1"></el-input>
+          <el-input v-model="addForm.newPassword" ref="password1" autocomplete="off" placeholder="请输入密码"
+            :type="passwordType1"></el-input>
           <span class="show-pwd" @click="showPwd(1)">
             <svg-icon :icon-class="passwordType1 === 'password' ? 'eye' : 'eye-open'" />
           </span>
         </el-form-item>
         <el-form-item label="确认密码" prop="confirmPassword">
-          <el-input v-model="addForm.confirmPassword" ref="password2" autocomplete="off" placeholder="请再次输入密码" :type="passwordType2"></el-input>
+          <el-input v-model="addForm.confirmPassword" ref="password2" autocomplete="off" placeholder="请再次输入密码"
+            :type="passwordType2"></el-input>
           <span class="show-pwd" @click="showPwd(2)">
             <svg-icon :icon-class="passwordType2 === 'password' ? 'eye' : 'eye-open'" />
           </span>
         </el-form-item>
-
+        <el-form-item label="是否公众号通知" prop="pubNotice">
+          <el-switch v-model="addForm.pubNotice" active-color="#13ce66" inactive-color="#ff4949">
+          </el-switch>
+        </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button @click="cancelAddForm">取 消</el-button>
@@ -209,7 +214,7 @@ export default {
       },
       merchantList: [], // 商户列表
 
-      resetId:  null,
+      resetId: null,
       resetFormVisible: false,
       resetForm: {
         newPassword: '', // 新密码
@@ -224,16 +229,17 @@ export default {
         ],
       },
 
-      editId:  null,
+      editId: null,
       addFormType: 'add',
       addFormVisible: false,
       addForm: {
         account: '', // 账号
         nickName: '', // 用户名
         role: '', // 角色组
-        adminWebsitId:'',
+        adminWebsitId: '',
         newPassword: '', // 新密码
         confirmPassword: '', // 确认密码
+        pubNotice: true,
       },
       addFormRules: {
         account: [
@@ -262,7 +268,7 @@ export default {
   },
   async created() {
     await this.getRoleList();
-    if(this.$route.query.type) {
+    if (this.$route.query.type) {
       let index = this.$findElem(this.roleList, 'name', '企业负责人');
       this.screenForm.role = this.roleList[index].adminRoleId;
     }
@@ -270,7 +276,7 @@ export default {
   },
   watch: {
     'addForm.role'() {
-      if(this.addForm.role) {
+      if (this.addForm.role) {
         let index = this.$findElem(this.roleList, 'adminRoleId', this.addForm.role);
       }
     }
@@ -285,8 +291,8 @@ export default {
         userName: this.screenForm.keyword,
         pageNum: this.currentPage,
         pageSize: this.pageSize,
-        ...(()=>{
-          if(this.$route.query.companyWechatId){
+        ...(() => {
+          if (this.$route.query.companyWechatId) {
             return {
               companyWechatId: this.$route.query.companyWechatId
             }
@@ -311,7 +317,7 @@ export default {
     // 获取角色列表
     async getRoleList() {
       const result = await new Promise((resolve, reject) => {
-        getRoleList({pageNum: 1, pageSize: 1000}).then(res => {
+        getRoleList({ pageNum: 1, pageSize: 1000 }).then(res => {
           this.roleList = res.data.records;
           resolve(res.data);
         }).catch(res => {
@@ -349,7 +355,7 @@ export default {
     // 操作 - 更改状态(type: 禁用0,启用1)
     changeStatus(id, type) {
       type = type ? true : false
-      changeAccountStatus({adminUserId: id, status: type}).then(res => {
+      changeAccountStatus({ adminUserId: id, status: type }).then(res => {
         this.getList();
         this.$successMsg();
       })
@@ -357,7 +363,7 @@ export default {
 
     // 显示隐藏密码
     showPwd(num) {
-      if(num == 1) {
+      if (num == 1) {
         if (this.passwordType1 === 'password') {
           this.passwordType1 = ''
         } else {
@@ -367,7 +373,7 @@ export default {
           this.$refs.password1.focus()
         })
       }
-      if(num == 2) {
+      if (num == 2) {
         if (this.passwordType2 === 'password') {
           this.passwordType2 = ''
         } else {
@@ -386,7 +392,7 @@ export default {
     },
 
     // 取消重置密码
-    cancelResetForm(){
+    cancelResetForm() {
       this.resetFormVisible = false;
       this.passwordType1 = 'password';
       this.passwordType2 = 'password';
@@ -416,13 +422,14 @@ export default {
       this.addFormVisible = true;
       this.departmentList = await this.getDepartmentList();
 
-      if(type == 'edit') {
+      if (type == 'edit') {
         this.editId = id;
-        getUserInfo({adminUserId: id}).then(res => {
+        getUserInfo({ adminUserId: id }).then(res => {
           this.addForm = {
             account: res.data.userName,
             role: res.data.roleId,
             nickName: res.data.nickName,
+            pubNotice: res.data.pubNotice,
             adminWebsitId: res.data.adminWebsitId
           }
         })
@@ -430,7 +437,7 @@ export default {
     },
 
     // 取消 新增编辑账户
-    cancelAddForm(){
+    cancelAddForm() {
       this.addFormVisible = false;
       this.passwordType1 = 'password';
       this.passwordType2 = 'password';
@@ -453,15 +460,16 @@ export default {
             roleId: this.addForm.role,
             adminWebsitId: adminWebsitId,
             password: this.addForm.newPassword,
+            pubNotice: this.addForm.pubNotice,
           }
-          if(this.addFormType == 'edit') {
+          if (this.addFormType == 'edit') {
             params.adminUserId = this.editId;
             editAccount(params).then(res => {
               this.cancelAddForm();
               this.getList();
               this.$successMsg('编辑成功');
             })
-          }else {
+          } else {
             addAccount(params).then(res => {
               this.cancelAddForm();
               this.getList();
@@ -477,12 +485,12 @@ export default {
 </script>
 
 <style scoped lang="scss">
-  .show-pwd {
-    position: absolute;
-    right: 15px;
-    top: 0;
-    font-size: 16px;
-    cursor: pointer;
-    user-select: none;
-  }
+.show-pwd {
+  position: absolute;
+  right: 15px;
+  top: 0;
+  font-size: 16px;
+  cursor: pointer;
+  user-select: none;
+}
 </style>