Browse Source

feat: 工程子账户、嘉贤子账户

zh 2 năm trước cách đây
mục cha
commit
7f2b7c7bff

+ 20 - 1
src/api/setting.js

@@ -512,6 +512,7 @@ export function getJiaXianUserList(params) {
   })
 }
 
+
 // 新建嘉贤经销商子账号
 export function addJiaXianUser(params) {
   return request({
@@ -519,4 +520,22 @@ export function addJiaXianUser(params) {
     method: 'post',
     params
   })
-}
+}
+
+// 工程子帐号列表
+export function getEngineeringUserList(params) {
+  return request({
+    url: '/admin/user/listGongCheng',
+    method: 'get',
+    params
+  })
+}
+
+// 新建工程子账号
+export function addEngineeringUser(params) {
+  return request({
+    url: '/admin/user/user/child/addGongCheng',
+    method: 'post',
+    params
+  })
+}

+ 80 - 9
src/views/secondaryMerchant/components/subMerchantForm.vue

@@ -12,12 +12,32 @@
           <el-row :gutter="20">
             <el-col :span="6">
               <el-form-item label="上级商户编码" prop="higherPrantNumber">
-                <el-input v-model="formData.higherPrantNumber" disabled placeholder="系统自动生成" />
+                <el-input v-if="isCustomer" v-model="formData.higherPrantNumber" disabled placeholder="系统自动生成" />
+                <el-select
+                  v-else
+                  v-model="formData.higherPrantNumber"
+                  placeholder="请选择"
+                  clearable
+                  style="width: 100%"
+                  @change="handleChange"
+                >
+                  <el-option v-for="item in customerList" :key="item.id" :label="item.number" :value="item.id" />
+                </el-select>
               </el-form-item>
             </el-col>
             <el-col :span="6">
               <el-form-item label="上级商户信息" prop="higherPrantName">
-                <el-input v-model="formData.higherPrantName" disabled placeholder="系统自动生成" />
+                <el-input v-if="isCustomer" v-model="formData.higherPrantName" disabled placeholder="系统自动生成" />
+                <el-select
+                  v-else
+                  v-model="formData.higherPrantName"
+                  placeholder="请选择"
+                  clearable
+                  style="width: 100%"
+                  @change="handleChange"
+                >
+                  <el-option v-for="item in customerList" :key="item.id" :label="item.name" :value="item.id" />
+                </el-select>
               </el-form-item>
             </el-col>
           </el-row>
@@ -48,9 +68,25 @@
               <el-input v-model="formData.invoiceAddress" placeholder="请输入地址" />
             </el-form-item>
           </el-col>
+          <el-col :span="24">
+            <el-form-item label="类型" prop="jiaxianType">
+              <el-radio-group v-model="formData.jiaxianType">
+                <el-radio
+                  v-for="item in [
+                    { label: '嘉贤经销商', value: 'JIAXIAN' },
+                    { label: '商用经销商', value: 'GONGCHENG' }
+                  ]"
+                  :key="item.value"
+                  :label="item.value"
+                >
+                  {{ item.label }}
+                </el-radio>
+              </el-radio-group>
+            </el-form-item>
+          </el-col>
         </el-row>
       </el-card>
-      <el-card>
+      <el-card v-if="formData.jiaxianType === 'JIAXIAN'">
         <div slot="header" class="clearfix">
           <strong>售后系统关联信息</strong>
         </div>
@@ -110,13 +146,16 @@
         <el-row :gutter="20">
           <el-col :span="8">
             <el-form-item label="审核人">
-              <el-input v-model="formData.approvalName" placeholder="系统自动生成" disabled /> </el-form-item></el-col>
+              <el-input v-model="formData.approvalName" placeholder="系统自动生成" disabled /> </el-form-item
+          ></el-col>
           <el-col :span="8">
             <el-form-item label="审核时间">
-              <el-input v-model="formData.approvalTime" placeholder="系统自动生成" disabled /> </el-form-item></el-col>
+              <el-input v-model="formData.approvalTime" placeholder="系统自动生成" disabled /> </el-form-item
+          ></el-col>
           <el-col :span="24">
             <el-form-item label="备注">
-              <el-input v-model="formData.approvalRemark" placeholder="请输入备注" /> </el-form-item></el-col>
+              <el-input v-model="formData.approvalRemark" placeholder="请输入备注" /> </el-form-item
+          ></el-col>
         </el-row>
 
         <div style="margin: 20px">
@@ -129,6 +168,7 @@
 </template>
 
 <script>
+import { getDealerListV2 } from '@/api/basic_data/dealer'
 import {
   addStagecustomer,
   examineStagecustomer,
@@ -136,7 +176,7 @@ import {
   updateSystem,
   getStageCustomerDetail
 } from '@/api/basic_data/dealer'
-
+import { mapGetters } from 'vuex'
 export default {
   props: {
     moduleType: {
@@ -171,15 +211,21 @@ export default {
         forbidStatus: 'A',
         approvalName: '',
         approvalTime: '',
-        approvalRemark: ''
-      }
+        approvalRemark: '',
+        jiaxianType: 'JIAXIAN'
+      },
+      customerList: []
     }
   },
+  computed: {
+    ...mapGetters(['isCustomer'])
+  },
   mounted() {
     if ((this.moduleType === 3 || this.moduleType === 4) && this.detailsId) {
       this.title = this.moduleType === 3 ? '审核' : '编辑'
       this.getStageCustomerDetail()
     }
+    this.getDealerListV2()
   },
   methods: {
     goBack() {
@@ -190,6 +236,31 @@ export default {
         this.formData = res.data
       })
     },
+    getDealerListV2() {
+      getDealerListV2({
+        pageNum: 1,
+        pageSize: -1,
+        params: [
+          {
+            param: 'a.jiaxian_type',
+            compare: '=',
+            value: 'KING'
+          }
+        ]
+      }).then(res => {
+        this.customerList = res.data.records
+      })
+    },
+    handleChange(e) {
+      if (e) {
+        const item = this.customerList.find(k => k.id === e)
+        this.formData.higherPrantNumber = item.number
+        this.formData.higherPrantName = item.name
+      } else {
+        this.formData.higherPrantNumber = ''
+        this.formData.higherPrantName = ''
+      }
+    },
     handleSubmit() {
       if (this.moduleType !== 1) {
         updateStagecustomer({

+ 438 - 0
src/views/setting/engineeringSubAccount.vue

@@ -0,0 +1,438 @@
+<template>
+  <div class="app-container">
+    <div class="setting_title">工程子账号</div>
+    <el-divider />
+
+    <div class="mymain-container">
+      <div class="btn-group clearfix">
+        <div class="fl">
+          <el-button
+            v-if="checkBtnRole('add')"
+            size="small"
+            type="primary"
+            icon="el-icon-plus"
+            @click="addOrEdit('add')"
+          >新增账号</el-button>
+        </div>
+        <!--        <div class="fr">-->
+        <!--          <ImportButton :im-url="'stock/importToll'" @importSuccess="getList" />-->
+        <!--        </div>-->
+      </div>
+
+      <div class="table">
+        <el-table
+          v-loading="listLoading"
+          :data="dataList"
+          element-loading-text="Loading"
+          border
+          fit
+          highlight-current-row
+          stripe
+        >
+          <el-table-column align="left" label="序号" type="index" width="50" />
+          <el-table-column align="left" label="账号" prop="userName" />
+          <el-table-column align="left" label="创建时间" prop="createTime" />
+          <el-table-column align="left" label="最后登录时间" prop="lastLoginTime" />
+          <el-table-column align="left" label="主帐号" prop="isMaster">
+            <template slot-scope="scope">
+              <el-tag v-if="scope.row.isMaster" type="success">是</el-tag>
+              <el-tag v-else type="danger">否</el-tag>
+            </template>
+          </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
+                v-if="checkBtnRole('detail')"
+                type="text"
+                @click="setMenuRole(scope.row.adminUserId, 'role')"
+              >设置权限</el-button> -->
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+
+      <div class="pagination clearfix">
+        <div class="fr">
+          <el-pagination
+            :current-page="currentPage"
+            :page-sizes="[10, 20, 30, 50]"
+            :page-size="10"
+            layout="total, sizes, prev, pager, next, jumper"
+            :total="listTotal"
+            @size-change="handleSizeChange"
+            @current-change="handleCurrentChange"
+          />
+        </div>
+      </div>
+    </div>
+
+    <!-- 设置权限 -->
+    <el-dialog
+      title="设置权限"
+      :visible.sync="roleFormVisible"
+      :show-close="false"
+      width="40%"
+      :close-on-click-modal="false"
+      custom-class="tree-dialog"
+      top="50px"
+    >
+      <el-tree
+        ref="tree"
+        :data="menuRoleList"
+        show-checkbox
+        :check-strictly="true"
+        :default-expand-all="true"
+        :expand-on-click-node="false"
+        node-key="moduleId"
+        highlight-current
+        :props="defaultProps"
+      >
+        <span slot-scope="{ node, data }" class="custom-tree-node">
+          <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>
+          </span>
+        </span>
+      </el-tree>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="roleFormVisible = false">{{ editId != 1 ? '取 消' : '关 闭' }}</el-button>
+        <el-button v-if="editId != 1" type="primary" @click="submitRoleForm('role')">确 定</el-button>
+      </div>
+    </el-dialog>
+    <el-dialog
+      :visible.sync="dialogVisible"
+      :close-on-click-modal="false"
+      width="45%"
+      :title="'add' === addFormType ? '新增' : '修改'"
+      @close="cancelAddForm"
+    >
+      <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
+        <el-form-item v-if="addFormType !== 'edit'" 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"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="密码" prop="password">
+          <el-input v-model="ruleForm.password" type="password" autocomplete="off" />
+        </el-form-item>
+      </el-form>
+
+      <span slot="footer" class="dialog-footer">
+        <!--        <el-button type="primary" style="float: left;" @click="setMenuRole">设置权限</el-button>-->
+        <el-button @click="cancelAddForm">取 消</el-button>
+        <el-button type="primary" @click="submitAddForm">确 定</el-button>
+      </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { mapGetters } from 'vuex'
+import { getStagecustomerListV2 } from '@/api/basic_data/dealer'
+import {
+  addEngineeringUser,
+  deleteRole,
+  editRole,
+  getEngineeringUserList,
+  getMenuList,
+  getRoleChecked,
+  setMenuRole,
+  editSubAccount
+} from '@/api/setting'
+
+export default {
+  data() {
+    return {
+      imageURL: this.$imageUrl,
+      dataList: null, // 列表数据
+      listLoading: true, // 列表加载loading
+      currentPage: 1, // 当前页码
+      pageSize: 10, // 每页数量
+      listTotal: 0, // 列表总数
+
+      editId: null,
+      addFormType: 'add',
+      addFormVisible: false,
+      addForm: {
+        name: '' // 角色名
+      },
+      addFormRules: {
+        name: [{ required: true, message: '请输入角色名', trigger: 'blur' }]
+      },
+
+      roleFormVisible: false,
+
+      menuRoleList: [],
+      defaultProps: {
+        children: 'children',
+        label: 'moduleName'
+      },
+      dialogVisible: false,
+      ruleForm: {
+        account: '',
+        password: '',
+        customerId: ''
+      },
+      rules: {
+        password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
+        customerId: [{ required: true, message: '请选择子经销商', trigger: 'blur' }]
+      },
+      subCustomerList: []
+    }
+  },
+  computed: {
+    ...mapGetters(['userid', 'name', 'customerId'])
+  },
+  created() {
+    this.getList()
+  },
+  methods: {
+    // 查询按钮权限
+    checkBtnRole(value) {
+      // let btnRole = this.$route.meta.roles;
+      // if(!btnRole) {return true}
+      // let index = btnRole.indexOf(value);
+      // return index >= 0 ? true : false;
+      return true
+    },
+    // 获取子经销商
+    getStagecustomerListV2() {
+      getStagecustomerListV2({
+        pageNum: 1,
+        pageSize: -1,
+        params: [
+          {
+            param: 'a.jiaxian_type',
+            compare: '=',
+            value: 'GONGCHENG'
+          }
+        ]
+      }).then(res => {
+        this.subCustomerList = res.data.records
+      })
+    },
+    getList() {
+      this.listLoading = true
+      const params = {
+        pageNum: this.currentPage,
+        pageSize: this.pageSize,
+        customerId: this.customerId,
+        isMaster: false
+      }
+      getEngineeringUserList(params).then(res => {
+        this.dataList = res.data.records
+        this.listTotal = res.data.total
+        this.listLoading = false
+      })
+    },
+
+    // 更改每页数量
+    handleSizeChange(val) {
+      this.pageSize = val
+      this.currentPage = 1
+      this.getList()
+    },
+
+    // 更改当前页
+    handleCurrentChange(val) {
+      this.currentPage = val
+      this.getList()
+    },
+
+    // 操作 - 删除
+    handleDelete(id) {
+      deleteRole({ adminRoleId: id }).then(res => {
+        this.getList()
+        this.$successMsg()
+      })
+    },
+
+    // 新增编辑
+    addOrEdit(type, row) {
+      this.addFormType = type
+      this.dialogVisible = true
+      if (type === 'edit') {
+        this.$nextTick(() => {
+          this.ruleForm = {
+            account: row.userName,
+            password: '',
+            adminUserId: row.adminUserId,
+            customerId: row.customerId
+          }
+        })
+      }
+      this.getStagecustomerListV2()
+    },
+
+    // 取消 新增编辑
+    cancelAddForm() {
+      this.dialogVisible = false
+      this.$nextTick(() => {
+        this.$refs.tree && this.$refs.tree.setCheckedKeys([])
+      })
+      this.$refs.ruleForm.resetFields()
+    },
+
+    // 提交 新增编辑
+    submitAddForm() {
+      this.$refs.ruleForm.validate(valid => {
+        const params = {
+          userName: this.ruleForm.account,
+          password: this.ruleForm.password,
+          customerId: this.ruleForm.customerId
+          // adminModuleIds:this.$refs.tree ? this.$refs.tree.getCheckedKeys().join(',') :
+        }
+        if (valid) {
+          if (this.addFormType === 'edit') {
+            params.adminUserId = this.ruleForm.adminUserId
+            editSubAccount(params).then(res => {
+              this.cancelAddForm()
+              this.getList()
+              this.$successMsg('编辑成功')
+            })
+          } else {
+            addEngineeringUser(params).then(res => {
+              this.cancelAddForm()
+              this.getList()
+              this.$successMsg('新增成功')
+            })
+          }
+        }
+      })
+    },
+
+    // 设置权限 - 获取列表
+    setMenuRole(id, type) {
+      this.roleFormVisible = true
+      this.editId = id
+      getMenuList({ adminUserId: this.userid }).then(res => {
+        this.menuRoleList = res.data
+      })
+      getRoleChecked({ adminUserId: id }).then(res => {
+        this.$refs.tree.setCheckedKeys(res.data)
+      })
+    },
+
+    // 设置权限 - 提交数据
+    submitRoleForm(type) {
+      const params = {
+        adminModuleIds: this.$refs.tree.getCheckedKeys().join(','),
+        adminRoleId: this.editId
+      }
+      setMenuRole(params).then(res => {
+        this.getList()
+        this.$successMsg()
+      })
+
+      this.roleFormVisible = false
+    },
+
+    // 一键全选
+    quickSelection(data) {
+      const nowChecked = this.$refs.tree.getCheckedKeys()
+      const thisId = data.moduleId
+      let childId = []
+      if (data.children.length) {
+        childId = this.familyTree(data.children)
+      }
+
+      const setChecked = nowChecked.concat([thisId]).concat(childId)
+
+      this.$refs.tree.setCheckedKeys(setChecked)
+    },
+
+    // 一键取消
+    quickCancel(data) {
+      const nowChecked = this.$refs.tree.getCheckedKeys()
+      const thisId = data.moduleId
+      let childId = []
+      if (data.children.length) {
+        childId = this.familyTree(data.children)
+      }
+
+      const setChecked = nowChecked
+      if (setChecked.indexOf(thisId) >= 0) {
+        setChecked.splice(setChecked.indexOf(thisId), 1)
+      }
+
+      if (childId.length) {
+        for (var i = 0; i < childId.length; i++) {
+          if (setChecked.indexOf(childId[i]) >= 0) {
+            setChecked.splice(setChecked.indexOf(childId[i]), 1)
+          }
+        }
+      }
+
+      this.$refs.tree.setCheckedKeys(setChecked)
+    },
+
+    // 递归子id
+    familyTree(arr) {
+      var temp = []
+      var forFn = function(list) {
+        for (var i = 0; i < list.length; i++) {
+          var item = list[i]
+          if (item.children) {
+            temp.push(item.moduleId)
+            forFn(item.children)
+          }
+        }
+      }
+      forFn(arr)
+      return temp
+    },
+
+    changeStatus(id, status) {
+      editRole({
+        adminRoleId: id,
+        visitSysStatus: status
+      }).then(res => {
+        this.getList()
+        this.$successMsg('编辑成功')
+      })
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+::v-deep .tree-dialog {
+  .el-dialog__body {
+    padding: 20px;
+    .el-tree {
+      max-height: calc(100vh - 140px - 54px - 70px);
+      overflow-y: scroll;
+      padding: 0 30px;
+      > .el-tree-node {
+        padding: 15px 0;
+        border: 1px dashed #ddd;
+        margin-bottom: 15px;
+        border-radius: 10px;
+      }
+    }
+  }
+}
+::v-deep .custom-tree-node {
+  flex: 1;
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  font-size: 14px;
+  padding-right: 8px;
+}
+</style>

+ 5 - 5
src/views/setting/jiaxianSubAccount.vue

@@ -216,11 +216,11 @@ export default {
         pageNum: 1,
         pageSize: -1,
         params: [
-          // {
-          //   param: 'a.higher_prant_number',
-          //   compare: 'like',
-          //   value: this.customerId
-          // }
+          {
+            param: 'a.jiaxian_type',
+            compare: '=',
+            value: 'JIAXIAN'
+          }
         ]
       }).then(res => {
         this.subCustomerList = res.data.records