Ver Fonte

feat: 用户管理

zh há 2 anos atrás
pai
commit
202bac1356
2 ficheiros alterados com 118 adições e 48 exclusões
  1. 17 0
      src/api/setting.js
  2. 101 48
      src/views/setting/engineeringSubAccount.vue

+ 17 - 0
src/api/setting.js

@@ -539,3 +539,20 @@ export function addEngineeringUser(params) {
     params
   })
 }
+// 编辑工程子账号
+export function editEngineeringUser(params) {
+  return request({
+    url: '/admin/user/user/child/updateGongCheng',
+    method: 'post',
+    params
+  })
+}
+
+// 工程子详情
+export function getDetailGongCheng(params) {
+  return request({
+    url: '/admin/user/detailGongCheng',
+    method: 'get',
+    params
+  })
+}

+ 101 - 48
src/views/setting/engineeringSubAccount.vue

@@ -12,7 +12,8 @@
             type="primary"
             icon="el-icon-plus"
             @click="addOrEdit('add')"
-          >新增账号</el-button>
+            >新增账号</el-button
+          >
         </div>
         <!--        <div class="fr">-->
         <!--          <ImportButton :im-url="'stock/importToll'" @importSuccess="getList" />-->
@@ -42,7 +43,8 @@
           </el-table-column>
           <el-table-column align="center" label="操作" width="180">
             <template slot-scope="scope">
-              <el-button type="text" @click="addOrEdit('edit', scope.row)">重置密码</el-button>
+              <el-button type="text" @click="addOrEdit('edit', scope.row)">编辑</el-button>
+              <el-button type="text" @click="addOrEdit('password', scope.row)">重置密码</el-button>
               <!-- <el-button
                 v-if="checkBtnRole('detail')"
                 type="text"
@@ -93,12 +95,9 @@
           <span>{{ node.label }}</span>
           <span v-if="data.type < 3">
             <el-button type="text" size="mini" @click="() => quickSelection(data)">一键全选</el-button>
-            <el-button
-              type="text"
-              size="mini"
-              style="color: #f56c6c"
-              @click="() => quickCancel(data)"
-            >一键取消</el-button>
+            <el-button type="text" size="mini" style="color: #f56c6c" @click="() => quickCancel(data)"
+              >一键取消</el-button
+            >
           </span>
         </span>
       </el-tree>
@@ -114,25 +113,46 @@
       :title="'add' === addFormType ? '新增' : '修改'"
       @close="cancelAddForm"
     >
-      <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="120px" class="demo-ruleForm">
-        <el-form-item v-if="addFormType !== 'edit'" label="账号" prop="account">
+      <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="140px" class="demo-ruleForm">
+        <el-form-item label="账号" prop="account">
           <el-input v-model="ruleForm.account" type="text" autocomplete="off" disabled placeholder="系统自动生成" />
         </el-form-item>
-        <el-form-item v-if="addFormType !== 'edit'" label="上级经销商" prop="customerId">
-          <el-select v-model="ruleForm.customerId" placeholder="请选择上级经销商" filterable style="width:100%">
-            <el-option
-              v-for="item in subCustomerList"
-              :key="item.id"
-              :label="item.name"
-              :value="item.id"
+        <template v-if="addFormType !== 'password'">
+          <el-form-item label="工装登录名额限制" prop="workLoginLimit">
+            <el-input
+              type="number"
+              v-model.number="ruleForm.workLoginLimit"
+              autocomplete="off"
+              placeholder="请输入工装登录名额限制"
             />
-          </el-select>
-        </el-form-item>
-        <el-form-item label="子经销商名称" prop="nickName">
-          <el-input v-model="ruleForm.nickName" type="nickName" autocomplete="off" />
-        </el-form-item>
-        <el-form-item label="密码" prop="password">
-          <el-input v-model="ruleForm.password" type="password" autocomplete="off" />
+          </el-form-item>
+          <el-form-item label="家装登录名额限制" prop="homeLoginLimit">
+            <el-input
+              type="number"
+              v-model.number="ruleForm.homeLoginLimit"
+              autocomplete="off"
+              placeholder="请输入家装登录名额限制"
+            />
+          </el-form-item>
+          <el-form-item label="跨区登录名额限制" prop="spanLoginLimit">
+            <el-input
+              type="number"
+              v-model.number="ruleForm.spanLoginLimit"
+              autocomplete="off"
+              placeholder="请输入跨区登录名额限制"
+            />
+          </el-form-item>
+          <el-form-item label="上级经销商" prop="parentId">
+            <el-select v-model="ruleForm.parentId" placeholder="请选择上级经销商" :disabled="addFormType === 'edit'" filterable style="width: 100%">
+              <el-option v-for="item in subCustomerList" :key="item.id" :label="item.name" :value="item.id" />
+            </el-select>
+          </el-form-item>
+          <el-form-item label="子经销商名称" prop="nickName">
+            <el-input v-model="ruleForm.nickName" autocomplete="off" placeholder="请输入子经销商名称" />
+          </el-form-item>
+        </template>
+        <el-form-item v-if="addFormType !== 'edit'" label="密码" prop="password">
+          <el-input v-model="ruleForm.password" type="password" autocomplete="off" placeholder="请输入密码" />
         </el-form-item>
       </el-form>
 
@@ -156,7 +176,9 @@ import {
   getMenuList,
   getRoleChecked,
   setMenuRole,
-  editSubAccount
+  editSubAccount,
+  editEngineeringUser,
+  getDetailGongCheng
 } from '@/api/setting'
 
 export default {
@@ -190,19 +212,25 @@ export default {
       ruleForm: {
         account: '',
         password: '',
-        customerId: '',
-        nickName: ''
+        parentId: '',
+        nickName: '',
+        spanLoginLimit: 5,
+        homeLoginLimit: 5,
+        workLoginLimit: 5
       },
       rules: {
         password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
-        customerId: [{ required: true, message: '请选择上级经销商', trigger: 'change' }],
-        nickName: [{ required: true, message: '请输入子经销商名称', trigger: 'blur' }]
+        parentId: [{ required: true, message: '请选择上级经销商', trigger: 'change' }],
+        nickName: [{ required: true, message: '请输入子经销商名称', trigger: 'blur' }],
+        spanLoginLimit: [{ required: true, message: '请输入跨区登录名额限制', trigger: 'blur' }],
+        homeLoginLimit: [{ required: true, message: '请输入家装登录名额限制', trigger: 'blur' }],
+        workLoginLimit: [{ required: true, message: '请输入工装登录名额限制', trigger: 'blur' }]
       },
       subCustomerList: []
     }
   },
   computed: {
-    ...mapGetters(['userid', 'name', 'customerId'])
+    ...mapGetters(['userid', 'name', 'parentId'])
   },
   created() {
     this.getList()
@@ -230,7 +258,7 @@ export default {
       const params = {
         pageNum: this.currentPage,
         pageSize: this.pageSize,
-        customerId: this.customerId,
+        parentId: this.parentId,
         isMaster: false
       }
       getEngineeringUserList(params).then(res => {
@@ -264,28 +292,41 @@ export default {
     // 新增编辑
     addOrEdit(type, row) {
       this.addFormType = type
-      this.dialogVisible = true
-      if (type === 'edit') {
-        this.$nextTick(() => {
-          this.ruleForm = {
-            account: row.userName,
-            password: '',
-            nickName: row.nickName,
-            adminUserId: row.adminUserId,
-            customerId: row.customerId
+      if (row) {
+        getDetailGongCheng({ adminUserId: row.adminUserId }).then(res => {
+          if (type === 'edit') {
+            this.ruleForm = {
+              account: res.data.userName,
+              password: '',
+              nickName: res.data.nickName,
+              adminUserId: res.data.adminUserId,
+              parentId: res.data.parentId,
+              spanLoginLimit: res.data.spanLoginLimit,
+              homeLoginLimit: res.data.homeLoginLimit,
+              workLoginLimit: res.data.workLoginLimit
+            }
+          }
+          if (type === 'password') {
+            this.ruleForm = {
+              account: res.data.userName,
+              password: '',
+              adminUserId: res.data.adminUserId
+            }
           }
         })
       }
+      this.dialogVisible = true
+
       this.getDealerListV2()
     },
 
     // 取消 新增编辑
     cancelAddForm() {
-      this.dialogVisible = false
+      this.$refs.ruleForm.resetFields()
+
       this.$nextTick(() => {
-        this.$refs.tree && this.$refs.tree.setCheckedKeys([])
+        this.dialogVisible = false
       })
-      this.$refs.ruleForm.resetFields()
     },
 
     // 提交 新增编辑
@@ -294,19 +335,31 @@ export default {
         const params = {
           userName: this.ruleForm.account,
           password: this.ruleForm.password,
-          customerId: this.ruleForm.customerId,
-          nickName: this.ruleForm.nickName
+          parentId: this.ruleForm.parentId,
+          nickName: this.ruleForm.nickName,
+          spanLoginLimit: this.ruleForm.spanLoginLimit,
+          homeLoginLimit: this.ruleForm.homeLoginLimit,
+          workLoginLimit: this.ruleForm.workLoginLimit
           // adminModuleIds:this.$refs.tree ? this.$refs.tree.getCheckedKeys().join(',') :
         }
         if (valid) {
-          if (this.addFormType === 'edit') {
+          if (this.addFormType === 'password') {
             params.adminUserId = this.ruleForm.adminUserId
             editSubAccount(params).then(res => {
               this.cancelAddForm()
               this.getList()
+              this.$successMsg('重置成功')
+            })
+          }
+          if (this.addFormType === 'edit') {
+            params.adminUserId = this.ruleForm.adminUserId
+            editEngineeringUser(params).then(res => {
+              this.cancelAddForm()
+              this.getList()
               this.$successMsg('编辑成功')
             })
-          } else {
+          }
+          if (this.addFormType === 'add') {
             addEngineeringUser(params).then(res => {
               this.cancelAddForm()
               this.getList()
@@ -385,7 +438,7 @@ export default {
     // 递归子id
     familyTree(arr) {
       var temp = []
-      var forFn = function(list) {
+      var forFn = function (list) {
         for (var i = 0; i < list.length; i++) {
           var item = list[i]
           if (item.children) {