瀏覽代碼

Finish Hotfix-mo-5

莫绍宝 3 年之前
父節點
當前提交
adf4ba5211

+ 10 - 0
src/api/common.js

@@ -0,0 +1,10 @@
+import request from '@/utils/request'
+
+// 获取列表
+export function getDictList(params) {
+  return request({
+    url: '/common/dict/list',
+    method: 'get',
+    params
+  })
+}

+ 0 - 117
src/api/merchant.js

@@ -49,120 +49,3 @@ export function editAccount(params) {
     data: params
   })
 }
-
-// 获取模版信息
-export function getTemplate(params) {
-  return request({
-    url: '/admin/company/template/detail',
-    method: 'get',
-    params
-  })
-}
-
-// 更改模版信息
-export function editTemplate(params) {
-  return request({
-    url: '/admin/company/template/updateCompanyWithTemplate',
-    method: 'post',
-    data: params
-  })
-}
-
-// 获取部门列表
-export function getDepartmentList(params) {
-  return request({
-    url: '/admin/websit/tree',
-    method: 'get',
-    params
-  })
-}
-
-// 添加部门
-export function addDepartment(params) {
-  return request({
-    url: '/admin/websit/add',
-    method: 'post',
-    data: params
-  })
-}
-
-// 修改部门
-export function editDepartment(params) {
-  return request({
-    url: '/admin/websit/update',
-    method: 'post',
-    data: params
-  })
-}
-
-// 删除部门
-export function deleteDepartment(params) {
-  return request({
-    url: '/admin/websit/delete',
-    method: 'post',
-    params
-  })
-}
-
-// 获取成员列表
-export function getMemberList(params) {
-  return request({
-    url: '/admin/user/list',
-    method: 'get',
-    params
-  })
-}
-
-// 添加成员
-export function addMember(params) {
-  return request({
-    url: '/admin/user/add',
-    method: 'post',
-    data: params
-  })
-}
-
-// 修改成员
-export function editMember(params) {
-  return request({
-    url: '/admin/user/user/update',
-    method: 'post',
-    data: params
-  })
-}
-
-// 删除成员
-export function deleteMember(params) {
-  return request({
-    url: '/wechat/enterprise/delete',
-    method: 'post',
-    params
-  })
-}
-
-// 获取成员详情
-export function getMemberDetail(params) {
-  return request({
-    url: '/admin/user/detail',
-    method: 'get',
-    params
-  })
-}
-
-// 获取角色列表
-export function getRoleList(params) {
-  return request({
-    url: '/admin/role/list',
-    method: 'get',
-    params
-  })
-}
-
-// 获取商户列表
-export function getMerchantList(params) {
-  return request({
-    url: '/admin/user/mch/list',
-    method: 'get',
-    params
-  })
-}

+ 54 - 9
src/api/setting.js

@@ -72,6 +72,15 @@ export function editAccount(params) {
   })
 }
 
+// 获取账户详情
+export function getAccountDetail(params) {
+  return request({
+    url: '/admin/user/detail',
+    method: 'get',
+    params
+  })
+}
+
 // 获取字段列表
 export function getFieldList(params) {
   return request({
@@ -306,15 +315,6 @@ export function editNotice(params) {
   })
 }
 
-// 获取部门列表
-export function getDepartmentList(params) {
-  return request({
-    url: '/admin/websit/tree',
-    method: 'get',
-    params
-  })
-}
-
 // 获取菜单列表
 export function getMenuList(params) {
   return request({
@@ -386,3 +386,48 @@ export function editAgreement(params) {
     params
   })
 }
+
+// 获取部门列表
+export function getDepartmentList(params) {
+  return request({
+    url: '/admin/websit/tree',
+    method: 'get',
+    params
+  })
+}
+
+// 添加部门
+export function addDepartment(params) {
+  return request({
+    url: '/admin/websit/add',
+    method: 'post',
+    data: params
+  })
+}
+
+// 修改部门
+export function editDepartment(params) {
+  return request({
+    url: '/admin/websit/update',
+    method: 'post',
+    data: params
+  })
+}
+
+// 删除部门
+export function deleteDepartment(params) {
+  return request({
+    url: '/admin/websit/delete',
+    method: 'post',
+    params
+  })
+}
+
+// 获取部门详情
+export function getDepartmentDetail(params) {
+  return request({
+    url: '/admin/websit/detail',
+    method: 'get',
+    params
+  })
+}

+ 0 - 829
src/views/merchant/department.vue

@@ -1,829 +0,0 @@
-<template>
-  <div class="app-container">
-    <div class="tree-container">
-      <div style="padding: 10px; display: flex;">
-        <el-button icon="el-icon-refresh-right" size="small" @click="refreshDepartment()" style="padding: 9px 10px; margin-right: 6px"></el-button>
-        <el-input
-          placeholder="输入关键字进行过滤"
-          size="small"
-          clearable
-          v-model="filterText">
-        </el-input>
-      </div>
-      <el-tree
-        :data="departmentList"
-        :props="defaultProps"
-        default-expand-all
-        highlight-current
-        :expand-on-click-node="false"
-        :filter-node-method="filterNode"
-        @node-click="handleNodeClick"
-        node-key="id"
-        ref="listTree">
-        <div class="custom-tree-node" slot-scope="{ node, data }">
-          <i :class="data.children && data.children.length > 0 ? 'el-icon-folder-opened':'el-icon-document-remove'"></i><span>{{ node.label }}</span>
-        </div>
-      </el-tree>
-    </div>
-    <div class="mymain-container">
-      <div class="screen-container">
-        <!-- <div class="top clearfix">
-          <div class="title fl">条件筛选</div>
-        </div> -->
-        <el-form ref="screenForm" :model="screenForm" label-width="70px" size="small" label-position="left">
-          <el-row :gutter="20">
-            <el-col :xs="24" :sm="12" :lg="12">
-              <el-form-item label="账号名称" prop="name">
-                <el-input v-model="screenForm.name" placeholder="请输入账号名称"></el-input>
-              </el-form-item>
-            </el-col>
-            <el-col :xs="24" :sm="12" :lg="12" class="tr">
-              <el-form-item label="">
-                <el-button size="small" @click="resetScreenForm">清空</el-button>
-                <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
-              </el-form-item>
-            </el-col>
-          </el-row>
-        </el-form>
-      </div>
-      <div class="btn-group clearfix" style="margin-top: 20px">
-        <div class="fl">
-          <el-button size="small" type="primary" @click="openDepartmentForm('add')">添加部门</el-button>
-          <el-button size="small" type="primary" @click="openDepartmentForm('edit')">编辑部门</el-button>
-          <el-divider direction="vertical"></el-divider>
-          <el-button size="small" type="primary" @click="openMemberForm('add')">添加账号</el-button>
-
-        </div>
-        <div class="fr">
-          <!-- <el-upload
-            class="import-btn"
-            style="height: 0; width: 0; overflow: hidden;"
-            :action="baseURL + 'student/import'"
-            :http-request="handleImport"
-            :file-list="importFileList"
-            v-if="checkBtnRole('import')"
-          >
-            <el-button size="small" type="primary" :loading="importLoading">{{ importLoading ? '导入中...' : '导入' }}</el-button>
-          </el-upload>
-
-          <el-button size="small" type="primary" @click="handleExport">导出</el-button>
-
-          <el-button size="small" type="primary" :loading="importLoading" @click="clickImport">{{ importLoading ? '导入中...' : '导入' }}</el-button>
-          
-          <el-button size="small" @click="handleDownload" v-if="checkBtnRole('download')">下载导入模板</el-button> -->
-        </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="center" type="selection" width="55" fixed></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>
-          <el-table-column align="center" label="角色" prop="roleName" min-width="100"></el-table-column>
-          <el-table-column align="center" label="创建时间" prop="createTime" min-width="160"></el-table-column>
-          <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>
-            </template>
-          </el-table-column>
-          <el-table-column align="center" label="操作" min-width="200">
-            <template slot-scope="scope">
-              <template v-if="checkBtnRole('status')">
-                <el-popconfirm v-if="scope.row.status" style="margin-right: 10px;" title="确定冻结吗?" @onConfirm="changeStatus(scope.row.adminUserId, 0)" >
-                  <el-button slot="reference" type="text">冻结</el-button>
-                </el-popconfirm>
-                <el-popconfirm v-else style="margin-right: 10px;" title="确定恢复吗?" @onConfirm="changeStatus(scope.row.adminUserId, 1)" >
-                  <el-button slot="reference" type="text">恢复</el-button>
-                </el-popconfirm>
-              </template>
-
-              <el-button type="text" @click="openMemberForm('edit', scope.row.adminUserId)" v-if="checkBtnRole('edit')">编辑</el-button>
-              <el-button type="text" @click="handleReset(scope.row.adminUserId)" v-if="checkBtnRole('reset')">重置密码</el-button>
-
-              <el-popconfirm style="margin-left: 10px;" title="确定删除吗?" @onConfirm="deleteMember(scope.row.id)" v-if="checkBtnRole('del')">
-                <el-button slot="reference" type="text">删除</el-button>
-              </el-popconfirm>
-            </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"
-            :total="listTotal">
-          </el-pagination>
-        </div>
-      </div>
-    </div>
-    
-    <!-- 添加编辑部门 -->
-    <el-dialog :title="departmentFormType == 'add' ? '添加部门':'编辑部门'" :visible.sync="departmentFormVisible" :show-close="false" width="40%" :close-on-click-modal="false">
-      <el-form ref="departmentForm" :model="departmentForm" :rules="departmentFormRules" label-position="right" label-width="80px">
-        <el-form-item label="部门名称" prop="name">
-          <el-input placeholder="请输入部门名称" v-model="departmentForm.name"></el-input>
-        </el-form-item>
-      </el-form>
-      <div slot="footer" class="dialog-footer">
-        <el-button @click="cancelDepartmentForm">取 消</el-button>
-        <el-button type="primary" @click="submitDepartmentForm">确 定</el-button>
-      </div>
-    </el-dialog>
-
-    <!-- 添加编辑账号 -->
-    <el-dialog :title="memberFormType == 'add' ? '添加账号':'编辑账号'" :visible.sync="memberFormVisible" :show-close="false" width="40%" :close-on-click-modal="false">
-      <el-form ref="memberForm" :model="memberForm" :rules="memberFormRules" label-position="left" label-width="80px">
-        <el-form-item label="账号" prop="account">
-          <el-input v-model="memberForm.account" autocomplete="off" placeholder="请输入账号"></el-input>
-        </el-form-item>
-        <el-form-item label="用户名" prop="nickName">
-          <el-input v-model="memberForm.nickName" autocomplete="off" placeholder="请输入用户名"></el-input>
-        </el-form-item>
-        <el-form-item label="角色组" prop="role">
-          <el-select v-model="memberForm.role" placeholder="请选择角色组" style="width: 100%;">
-            <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="department" v-show="accountType === 0">
-          <el-tree
-            :data="departmentList"
-            show-checkbox
-            node-key="adminWebsitId"
-            ref="tree"
-            highlight-current
-            :props="props">
-          </el-tree>
-        </el-form-item>
-        <el-form-item label="商户" prop="merchant" v-show="accountType === 1 || accountType === 2">
-          <el-select v-model="memberForm.merchant" placeholder="请选择商户" style="width: 100%;">
-            <el-option :label="item.adminCompanyName" :value="item.adminCompanyId" v-for="(item, index) in merchantList" :key="index"></el-option>
-          </el-select>
-        </el-form-item>
-        <el-form-item label="密码" prop="newPassword">
-          <el-input v-model="memberForm.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="memberForm.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>
-      <div slot="footer" class="dialog-footer">
-        <el-button @click="cancelMemberForm">取 消</el-button>
-        <el-button type="primary" @click="submitMemberForm">确 定</el-button>
-      </div>
-    </el-dialog>
-
-    <!-- 重置密码 -->
-    <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>
-          <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>
-          <span class="show-pwd" @click="showPwd(2)">
-            <svg-icon :icon-class="passwordType2 === 'password' ? 'eye' : 'eye-open'" />
-          </span>
-        </el-form-item>
-      </el-form>
-      <div slot="footer" class="dialog-footer">
-        <el-button @click="cancelResetForm">取 消</el-button>
-        <el-button type="primary" @click="submitResetForm">确 定</el-button>
-      </div>
-    </el-dialog>
-
-  </div>
-</template>
-
-<script>
-import { 
-  getDepartmentList, addDepartment, editDepartment, deleteDepartment,
-  getMemberList, addMember, editMember, deleteMember, getMemberDetail, getRoleList, getMerchantList, changeAccountStatus, resetPassword
-  } from '@/api/merchant'
-import { findElem, downloadFiles, handleImport } from '@/utils/util'
-
-export default {
-  data() {
-    var validatePass = (rule, value, callback) => {
-      if (value === '') {
-        callback(new Error('请输入新密码'));
-      } else if (value && value.length < 6) {
-        callback(new Error('密码长度至少6位'));
-      } else {
-        if (this.resetForm.confirmPassword !== '') {
-          this.$refs.resetForm.validateField('confirmPassword');
-        }
-        callback();
-      }
-    };
-    var validatePass2 = (rule, value, callback) => {
-      if (value === '') {
-        callback(new Error('请再次输入密码'));
-      } else if (value !== this.resetForm.newPassword) {
-        callback(new Error('两次输入密码不一致'));
-      } else {
-        callback();
-      }
-    };
-    var validatePass3 = (rule, value, callback) => {
-      if (value === '') {
-        callback(new Error('请输入新密码'));
-      } else if (value && value.length < 6) {
-        callback(new Error('密码长度至少6位'));
-      } else {
-        if (this.memberForm.confirmPassword !== '') {
-          this.$refs.memberForm.validateField('confirmPassword');
-        }
-        callback();
-      }
-    };
-    var validatePass4 = (rule, value, callback) => {
-      if (value === '') {
-        callback(new Error('请再次输入密码'));
-      } else if (value !== this.memberForm.newPassword) {
-        callback(new Error('两次输入密码不一致'));
-      } else {
-        callback();
-      }
-    };
-    return {
-      baseURL: process.env.VUE_APP_BASE_API,
-      dataList: null, // 列表数据
-      moduleList: null, // 模块列表
-      listLoading: true, // 列表加载loading
-      screenForm: { // 筛选表单数据
-        name: '', // 名称
-      },
-      currentPage: 1, // 当前页码
-      pageSize: 10, // 每页数量
-      listTotal: 0, // 列表总数
-
-      departmentFormType: 'add',
-      departmentFormVisible: false,
-      departmentForm: {
-        name: '',
-      },
-      departmentFormRules: {
-        name: [
-          { required: true, message: '请填写部门名称', trigger: 'blur' },
-        ],
-      },
-      selectDepartment: null, // 选中的部门
-
-      memberFormType: 'add',
-      memberFormVisible: false,
-      memberForm: {
-        account: '', // 账号
-        nickName: '', // 用户名
-        merchant: '', // 商户
-        role: '', // 角色组
-        newPassword: '', // 新密码
-        confirmPassword: '', // 确认密码
-      },
-      memberFormRules: {
-        account: [
-          { required: true, message: '请输入账号', trigger: 'blur' }
-        ],
-        nickName: [
-          { required: true, message: '请输入用户名', trigger: 'blur' }
-        ],
-        role: [
-          { required: true, message: '请选择角色组', trigger: 'change' }
-        ],
-        newPassword: [
-          { required: true, validator: validatePass3, trigger: 'blur' }
-        ],
-        confirmPassword: [
-          { required: true, validator: validatePass4, trigger: 'blur' }
-        ],
-      },
-      editMemberId: null, 
-
-      filterText: '',
-      departmentList: [],
-      defaultProps: {
-        children: 'children',
-        label: 'name'
-      },
-      props: {
-        multiple: true,
-        value: 'adminWebsitId',
-        label: 'name',
-        children: 'children',
-      },
-
-      tableSelection: [],
-
-      importLoading: false, // 导入加载loading
-      importFileList: [], // 导入列表
-
-      resetId:  null,
-      resetFormVisible: false,
-      resetForm: {
-        newPassword: '', // 新密码
-        confirmPassword: '', // 确认密码
-      },
-      resetFormRules: {
-        newPassword: [
-          { required: true, validator: validatePass, trigger: 'blur' }
-        ],
-        confirmPassword: [
-          { required: true, validator: validatePass2, trigger: 'blur' }
-        ],
-      },
-
-      accountType: '',
-      roleList: [], // 角色列表
-      merchantList: [],
-
-      passwordType1: 'password',
-      passwordType2: 'password',
-    }
-  },
-  watch: {
-    filterText(val) {
-      this.$refs.listTree.filter(val);
-    },
-    'memberForm.role'() {
-      if(this.memberForm.role) {
-        let index = findElem(this.roleList, 'adminRoleId', this.memberForm.role);
-        this.accountType = this.roleList[index].type;
-      }
-    }
-  },
-  async created() {
-    this.getTree();
-    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;
-    },
-
-    // 获取角色列表
-    async getRoleList() {
-      const result = await new Promise((resolve, reject) => {
-        getRoleList({pageNum: 1, pageSize: 1000}).then(res => {
-          this.roleList = res.data.records;
-          resolve(res.data);
-        }).catch(res => {
-          resolve([]);
-        })
-      })
-      return result;
-    },
-
-    // 获取商户列表
-    async getMerchantList() {
-      const result = await new Promise((resolve, reject) => {
-        getMerchantList({
-          pageNum: 1,
-          pageSize: 1000
-        }).then(res => {
-          this.merchantList = res.data.records;
-          resolve(res.data.records);
-        }).catch(res => {
-          resolve([]);
-        })
-      })
-      return result;
-    },
-
-    // 获取部门列表
-    getTree() {
-      getDepartmentList().then(res => {
-        this.departmentList = res.data;
-      })
-    },
-
-    // 获取账号列表
-    getList() {
-      this.listLoading = true;
-
-      let params = {
-        pageNum: this.currentPage,
-        pageSize: this.pageSize,
-        adminWebsitId: this.selectDepartment ? this.selectDepartment.adminWebsitId : '',
-        keyword: this.screenForm.name
-      };
-
-      getMemberList(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();
-    },
-
-    // 提交筛选表单
-    submitScreenForm() {
-      this.currentPage = 1;
-      this.getList();
-    },
-
-    // 重置筛选表单
-    resetScreenForm() {
-      this.$refs.screenForm.resetFields();
-      this.currentPage = 1;
-      this.getList();
-    },
-
-    // 筛选部门
-    filterNode(value, data) {
-      if (!value) return true;
-      return data.name.indexOf(value) !== -1;
-    },
-
-    // 选择部门
-    handleNodeClick(data) {
-      console.log(data);
-      if(this.selectDepartment && data.adminWebsitId === this.selectDepartment.adminWebsitId) {
-        this.$refs.listTree.setCurrentKey(null);
-        this.selectDepartment = null;
-      }else {
-        this.selectDepartment = data;
-      }
-      this.getList();
-    },
-
-    // 刷新部门
-    refreshDepartment() {
-      this.$refs.listTree.setCurrentKey(null);
-      this.selectDepartment = null;
-      this.getTree();
-      this.getList();
-    },
-
-    // 打开 新增编辑 部门表单
-    openDepartmentForm(type) {
-      this.departmentFormType = type;
-      if(!this.selectDepartment) {
-        return this.$errorMsg('请选择部门');
-      }
-      if(type == 'edit') {
-        this.departmentForm = {
-          name: this.selectDepartment.name,
-        }
-      }
-      this.departmentFormVisible = true;
-    },
-
-    // 取消 新增编辑 部门表单
-    cancelDepartmentForm(){
-      this.departmentFormVisible = false;
-      this.$refs.departmentForm.resetFields();
-      this.departmentForm.name = '';
-    },
-
-    // 提交 部门表单
-    submitDepartmentForm() {
-      this.$refs.departmentForm.validate((valid) => {
-        if (valid) {
-          let params = {
-            name: this.departmentForm.name,
-          }
-          if(this.departmentFormType == 'edit') {
-            params.id = this.selectDepartment.id;
-            params.adminWebsitId = this.selectDepartment.adminWebsitId;
-            params.parentId = this.selectDepartment.parentId;
-            editDepartment(params).then(res => {
-              this.cancelDepartmentForm();
-              this.getTree();
-              this.getList();
-              this.$successMsg('编辑成功');
-            })
-          }else {
-            params.parentId = this.selectDepartment ? this.selectDepartment.adminWebsitId : 0;
-            addDepartment(params).then(res => {
-              this.cancelDepartmentForm();
-              this.getTree();
-              this.getList();
-              this.$successMsg('添加成功');
-            })
-          }
-        }
-      })
-    },
-
-    // 打开 新增编辑 账号表单
-    async openMemberForm(type, id) {
-
-      this.memberFormType = type;
-      this.memberFormVisible = true;
-      await this.getMerchantList();
-      await this.getRoleList();
-      if(type == 'add') {
-        if(this.selectDepartment) {
-          this.$refs.tree.setCheckedKeys([this.selectDepartment.adminWebsitId]);
-        }
-      }
-
-      if(type == 'edit') {
-        this.editMemberId = id;
-        getMemberDetail({adminUserId: id}).then(res => {
-          this.memberForm.account = res.data.userName;
-          this.memberForm.role = res.data.roleId;
-          this.memberForm.nickName = res.data.nickName;
-          this.memberForm.merchant = res.data.companyWechatId;
-          this.$refs.tree.setCheckedKeys(res.data.adminWebsitIds || []);
-        })
-      }
-    },
-
-    // 取消 新增编辑 账号表单
-    cancelMemberForm(){
-      this.memberFormVisible = false;
-      this.$refs.memberForm.resetFields();
-      this.passwordType1 = 'password';
-      this.passwordType2 = 'password';
-    },
-
-    // 提交 账号表单
-    submitMemberForm() {
-      this.$refs.memberForm.validate((valid) => {
-        if (valid) {
-          let params = {
-            userName: this.memberForm.account,
-            nickName: this.memberForm.nickName,
-            roleId: this.memberForm.role,
-            password: this.memberForm.newPassword,
-          }
-          if(this.accountType === 0) {
-            params.adminWebsitIds = this.$refs.tree.getCheckedKeys();
-          }else {
-            params.adminCompanyId = this.memberForm.merchant;
-          }
-          if(this.memberFormType == 'edit') {
-            params.adminUserId = this.editMemberId;
-            editMember(params).then(res => {
-              this.cancelMemberForm();
-              this.getList();
-              this.$successMsg('编辑成功');
-            })
-          }else {
-            addMember(params).then(res => {
-              this.cancelMemberForm();
-              this.getList();
-              this.$successMsg('添加成功');
-            })
-          }
-        }
-      })
-    },
-
-    // 表格选择列
-    handleTableSelection(val) {
-      this.tableSelection = val;
-    },
-
-    // 批量删除账号
-    batchDeleteMember() {
-      if(this.tableSelection.length < 1) {
-        return this.$errorMsg('至少选择一名账号');
-      }
-      this.$confirm(`确定删除选中的账号吗?`, '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(() => {
-        let memberIds = [];
-        this.tableSelection.forEach(item => {
-          memberIds.push(item.id);
-        });
-        deleteMember({id: memberIds.join(',')}).then(res => {
-          this.$successMsg();
-          this.getTree();
-          this.getList();
-        })
-      }).catch(() => {});
-    },
-
-    // 删除账号
-    deleteMember(id) {
-      deleteMember({id: id}).then(res => {
-        this.$successMsg();
-        this.getTree();
-        this.getList();
-      })
-    },
-
-    // 操作 - 更改状态(type: 禁用0,启用1)
-    changeStatus(id, type) {
-      type = type ? true : false
-      changeAccountStatus({adminUserId: id, status: type}).then(res => {
-        this.getList();
-        this.$successMsg();
-      })
-    },
-
-    // 显示隐藏密码
-    showPwd(num) {
-      if(num == 1) {
-        if (this.passwordType1 === 'password') {
-          this.passwordType1 = ''
-        } else {
-          this.passwordType1 = 'password'
-        }
-        this.$nextTick(() => {
-          this.$refs.password1.focus()
-        })
-      }
-      if(num == 2) {
-        if (this.passwordType2 === 'password') {
-          this.passwordType2 = ''
-        } else {
-          this.passwordType2 = 'password'
-        }
-        this.$nextTick(() => {
-          this.$refs.password2.focus()
-        })
-      }
-    },
-
-    // 重置密码
-    handleReset(id) {
-      this.resetId = id;
-      this.resetFormVisible = true;
-    },
-
-    // 取消重置密码
-    cancelResetForm(){
-      this.resetFormVisible = false;
-      this.passwordType1 = 'password';
-      this.passwordType2 = 'password';
-      this.$refs.resetForm.resetFields();
-    },
-
-    // 提交重置密码
-    submitResetForm() {
-      this.$refs.resetForm.validate((valid) => {
-        if (valid) {
-          let params = {
-            password: this.resetForm.newPassword,
-            adminUserId: this.resetId
-          }
-          resetPassword(params).then(res => {
-            this.cancelResetForm();
-            this.getList();
-            this.$successMsg();
-          })
-        }
-      })
-    },
-
-
-    // 导出
-    handleExport() {
-      let screenData = {
-        adminWebsitId: this.selectDepartment ? this.selectDepartment.websitId : '',
-        keyword: this.screenForm.name
-      };
-      downloadFiles('wechat/enterprise/export', screenData);
-    },
-
-    // 下载导入模版
-    handleDownload() {
-      downloadFiles('wechat/enterprise/download');
-    },
-
-    clickImport() {
-      if(!this.selectDepartment) {
-        return this.$errorMsg('请选择部门');
-      }else {
-        document.querySelector('.import-btn input').click();
-      }
-    },
-
-    // 导入
-    async handleImport(param) {
-      this.importLoading = true;
-      const file = param.file;
-      const formData = new FormData();
-      formData.append("file", file);
-      formData.append("mainDepartmentId", this.selectDepartment.websitId);
-      let result = await handleImport('wechat/enterprise/import', formData);
-      this.importLoading = false;
-      this.importFileList = [];
-      if(result.code == 200) {
-        this.$alert(result.message, '导入成功', {
-          confirmButtonText: '确定'
-        });
-        this.getList();
-      }else {
-        this.$alert(result.message, '导入失败', {
-          confirmButtonText: '确定'
-        });
-      }
-    },
-
-  }
-}
-</script>
-
-<style scoped lang="scss">
-  .app-container {
-    display: flex;
-    .tree-container {
-      width: 18%;
-      height: calc(100vh - 110px);
-      flex-shrink: 0;
-      background: #f5f5f5;
-      margin-right: 2%;
-      display: flex;
-      flex-direction: column;
-      overflow-y: hidden;
-      .el-tree {
-        height: 100%;
-        background: none;
-        width: 100%;
-        overflow: scroll;
-        // ::v-deep .el-tree-node:focus > .el-tree-node__content {
-        //   color: #ffffff;
-        //   background-color: #409EFF;
-        // }
-        ::v-deep >.el-tree-node {
-          display: inline-block;
-          min-width: 100%;
-        }
-        ::v-deep .el-tree-node>.el-tree-node__content {
-          padding-right: 10px;
-          align-self: baseline;
-        }
-        ::v-deep .el-tree-node.is-current>.el-tree-node__content {
-          background-color: #409EFF;
-          .custom-tree-node {
-            i {
-              color: #fff;
-            }
-            span {
-              color: #fff;
-            }
-          }
-        }
-        ::v-deep .el-tree-node>.el-tree-node__children {
-          overflow: unset;
-        }
-        .custom-tree-node {
-          i {
-            font-size: 14px;
-            color: #999;
-          }
-          span {
-            font-size: 14px;
-            margin-left: 6px;
-            color: #666;
-          }
-        }
-      }
-    }
-    .mymain-container {
-      width: 80%;
-      margin-top: 0;
-    }
-  }
-  ::v-deep .el-divider--vertical {
-    margin: 0 15px;
-  }
-  .show-pwd {
-    position: absolute;
-    right: 15px;
-    top: 0;
-    font-size: 16px;
-    cursor: pointer;
-    user-select: none;
-  }
-</style>

+ 0 - 597
src/views/merchant/mall_set.vue

@@ -1,597 +0,0 @@
-<template>
-  <div class="app-container">
-    <div v-if="!isAdmin">
-      <el-tabs v-model="step">
-        <el-tab-pane label="首页模版配置" name="first"></el-tab-pane>
-        <el-tab-pane label="商城logo配置" name="second"></el-tab-pane>
-      </el-tabs>
-
-      <div v-show="step == 'first'">
-        <el-form label-width="120px" label-position="right">
-          <el-form-item label="选择模版:" style="margin-bottom: 40px">
-            <el-radio-group v-model="currentTemplate" @change="changeTemplate()">
-              <div class="item">
-                <el-radio :label="1">模版一</el-radio>
-                <el-image :src="require('@/assets/template/tmp_1_thumb.png')" :preview-src-list="[require('@/assets/template/tmp_1.png')]" fit="cover"></el-image>
-              </div>
-              <div class="item">
-                <el-radio :label="2">模版二</el-radio>
-                <el-image :src="require('@/assets/template/tmp_2_thumb.png')" :preview-src-list="[require('@/assets/template/tmp_2.png')]" fit="cover"></el-image>
-              </div>
-            </el-radio-group>
-          </el-form-item>
-          <el-form-item label="首页模块设置:" v-show="currentTemplate === 1">
-            <div class="diy-table">
-              <div class="item head">
-                <div class="label">模块名称</div> 
-                <div class="value">状态</div>
-              </div>
-              <div class="item">
-                <div class="label">分类</div>
-                <div class="value">
-                  <el-switch v-model="switch_classify" disabled></el-switch>
-                  <span :class="switch_classify ? 'on':''">{{switch_classify ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-              <div class="item">
-                <div class="label">轮播图</div>
-                <div class="value">
-                  <el-switch v-model="switch_banner"></el-switch>
-                  <span :class="switch_banner ? 'on':''">{{switch_banner ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-              <div class="item">
-                <div class="label">公告</div>
-                <div class="value">
-                  <el-switch v-model="switch_notice"></el-switch>
-                  <span :class="switch_notice ? 'on':''">{{switch_notice ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-              <div class="item">
-                <div class="label">专属优惠券</div>
-                <div class="value">
-                  <el-switch v-model="switch_coupon"></el-switch>
-                  <span :class="switch_coupon ? 'on':''">{{switch_coupon ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-              <div class="item">
-                <div class="label">客户经理</div>
-                <div class="value">
-                  <el-switch v-model="switch_manager"></el-switch>
-                  <span :class="switch_manager ? 'on':''">{{switch_manager ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-              <div class="item">
-                <div class="label">秒杀专区</div>
-                <div class="value">
-                  <el-switch v-model="switch_seckill"></el-switch>
-                  <span :class="switch_seckill ? 'on':''">{{switch_seckill ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-              <div class="item">
-                <div class="label">好物推荐</div>
-                <div class="value">
-                  <el-switch v-model="switch_recom" disabled></el-switch>
-                  <span :class="switch_recom ? 'on':''">{{switch_recom ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-            </div>
-          </el-form-item>
-          <el-form-item label="首页模块设置:" v-show="currentTemplate === 2">
-            <div class="diy-table">
-              <div class="item head">
-                <div class="label">模块名称</div> 
-                <div class="value">状态</div>
-              </div>
-              <div class="item">
-                <div class="label">首页弹窗</div>
-                <div class="value">
-                  <el-switch v-model="switch_dialog"></el-switch>
-                  <span :class="switch_dialog ? 'on':''">{{switch_dialog ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-              <div class="item">
-                <div class="label">轮播图</div>
-                <div class="value">
-                  <el-switch v-model="switch_banner"></el-switch>
-                  <span :class="switch_banner ? 'on':''">{{switch_banner ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-              <div class="item">
-                <div class="label">活动专区1</div>
-                <div class="value">
-                  <el-switch v-model="switch_activity1"></el-switch>
-                  <span :class="switch_activity1 ? 'on':''">{{switch_activity1 ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-              <div class="item">
-                <div class="label">分类</div>
-                <div class="value">
-                  <el-switch v-model="switch_classify" disabled></el-switch>
-                  <span :class="switch_classify ? 'on':''">{{switch_classify ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-              <div class="item">
-                <div class="label">活动专区2</div>
-                <div class="value">
-                  <el-switch v-model="switch_activity2"></el-switch>
-                  <span :class="switch_activity2 ? 'on':''">{{switch_activity2 ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-              <div class="item">
-                <div class="label">专场专区</div>
-                <div class="value">
-                  <el-switch v-model="switch_special"></el-switch>
-                  <span :class="switch_special ? 'on':''">{{switch_special ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-              <div class="item">
-                <div class="label">秒杀专区</div>
-                <div class="value">
-                  <el-switch v-model="switch_seckill"></el-switch>
-                  <span :class="switch_seckill ? 'on':''">{{switch_seckill ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-              <div class="item">
-                <div class="label">专属优惠券</div>
-                <div class="value">
-                  <el-switch v-model="switch_coupon"></el-switch>
-                  <span :class="switch_coupon ? 'on':''">{{switch_coupon ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-              <div class="item">
-                <div class="label">客户经理</div>
-                <div class="value">
-                  <el-switch v-model="switch_manager"></el-switch>
-                  <span :class="switch_manager ? 'on':''">{{switch_manager ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-              <div class="item">
-                <div class="label">公告</div>
-                <div class="value">
-                  <el-switch v-model="switch_notice"></el-switch>
-                  <span :class="switch_notice ? 'on':''">{{switch_notice ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-              <div class="item">
-                <div class="label">新维度分类专区</div>
-                <div class="value">
-                  <el-switch v-model="switch_newclassify" disabled></el-switch>
-                  <span :class="switch_newclassify ? 'on':''">{{switch_newclassify ? '开启':'隐藏'}}</span>
-                </div>
-              </div>
-            </div>
-          </el-form-item>
-        </el-form>
-      </div>
-
-      <div v-show="step == 'second'">
-        <el-form label-width="120px" label-position="right">
-          <el-upload
-            class="avatar-uploader"
-            :action="baseURL + 'common/upload'"
-            :headers="myHeaders"
-            :show-file-list="false"
-            :on-success="uploadSuccess"
-            :before-upload="beforeUpload">
-          </el-upload>
-          <el-form-item label="主logo:" prop="imgUrl">
-            <div class="images">
-              <div class="main-img">
-                <div class="img" v-if="img1_url" @mouseover="img1_hover = true;" @mouseout="img1_hover = false;">
-                  <el-image ref="img1" :src="img1_url" :preview-src-list="[img1_url]" style="width: 120px; height: 120px" fit="contain"></el-image>
-                  <div class="mask" v-show="img1_hover">
-                    <i class="el-icon-zoom-in" @click="previewImage('img1')"></i>
-                    <i class="el-icon-upload2" @click="uploadImage('img1')"></i>
-                  </div>
-                </div>
-                <div class="add" v-else @click="uploadImage('img1')">
-                  <i class="el-icon-plus avatar-uploader-icon"></i>
-                </div>
-              </div>
-              <div class="tmp-img">
-                <el-image :src="require('@/assets/template/template_1.png')" :preview-src-list="[require('@/assets/template/template_1.png')]" style="width: 120px; height: 120px; display: block" fit="contain"></el-image>
-                <div class="tmp">示例图</div>
-              </div>
-            </div>
-            <div class="tips">
-              <span>建议尺寸:400*400</span>
-            </div>
-          </el-form-item>
-          <el-form-item label="通用logo:" prop="imgUrl">
-            <div class="images">
-              <div class="main-img">
-                <div class="img" v-if="img2_url" @mouseover="img2_hover = true;" @mouseout="img2_hover = false;">
-                  <el-image ref="img2" :src="img2_url" :preview-src-list="[img2_url]" style="width: 120px; height: 120px" fit="contain"></el-image>
-                  <div class="mask" v-show="img2_hover">
-                    <i class="el-icon-zoom-in" @click="previewImage('img2')"></i>
-                    <i class="el-icon-upload2" @click="uploadImage('img2')"></i>
-                  </div>
-                </div>
-                <div class="add" v-else @click="uploadImage('img2')">
-                  <i class="el-icon-plus avatar-uploader-icon"></i>
-                </div>
-              </div>
-              <div class="tmp-img">
-                <el-image :src="require('@/assets/template/template_2.png')" :preview-src-list="[require('@/assets/template/template_2.png')]" style="width: 120px; height: 120px; display: block" fit="contain"></el-image>
-                <div class="tmp">示例图</div>
-              </div>
-            </div>
-            <div class="tips">
-              <span>建议尺寸:280*60</span>
-            </div>
-          </el-form-item>
-          <el-form-item label="头像logo:" prop="imgUrl">
-            <div class="images">
-              <div class="main-img">
-                <div class="img" v-if="img3_url" @mouseover="img3_hover = true;" @mouseout="img3_hover = false;">
-                  <el-image ref="img3" :src="img3_url" :preview-src-list="[img3_url]" style="width: 120px; height: 120px" fit="contain"></el-image>
-                  <div class="mask" v-show="img3_hover">
-                    <i class="el-icon-zoom-in" @click="previewImage('img3')"></i>
-                    <i class="el-icon-upload2" @click="uploadImage('img3')"></i>
-                  </div>
-                </div>
-                <div class="add" v-else @click="uploadImage('img3')">
-                  <i class="el-icon-plus avatar-uploader-icon"></i>
-                </div>
-              </div>
-              <div class="tmp-img">
-                <el-image :src="require('@/assets/template/template_3.png')" :preview-src-list="[require('@/assets/template/template_3.png')]" style="width: 120px; height: 120px; display: block" fit="contain"></el-image>
-                <div class="tmp">示例图</div>
-              </div>
-            </div>
-            <div class="tips">
-              <span>建议尺寸:400*400</span>
-            </div>
-          </el-form-item>
-        </el-form>
-      </div>
-
-      <div class="page-footer">
-        <div class="footer" :class="classObj">
-          <el-button type="primary" @click="submitStep1Form" :loading="formLoading" v-if="step == 'first'">{{ formLoading ? '保存中 ...' : '保 存' }}</el-button>
-          <el-button type="primary" @click="submitStep2Form" :loading="formLoading" v-if="step == 'second'">{{ formLoading ? '保存中 ...' : '保 存' }}</el-button>
-        </div>
-      </div>
-    </div>
-
-    <div v-else>
-      <div class="nodata">超级管理员无法进行商城配置</div>
-    </div>
-    
-  </div>
-</template>
-
-<script>
-import { getToken, getUserid } from '@/utils/auth';
-import { getTemplate, editAccount, editTemplate, getDetail } from "@/api/merchant";
-import { findElem } from '@/utils/util';
-import { getInfo } from '@/api/user'
-
-export default {
-  data() {
-    return {
-      isAdmin: JSON.parse(localStorage.getItem("supply_user")).type === 2,
-      baseURL: process.env.VUE_APP_BASE_API,
-      myHeaders: {'x-token': getToken()},
-      step: 'first',
-      companyId: JSON.parse(localStorage.getItem("supply_user")).companyWechatId,
-      currentTemplate: JSON.parse(localStorage.getItem("supply_user")).useTemplate,
-
-      switch_dialog: true,
-      switch_banner: true,
-      switch_activity1: true,
-      switch_classify: true,
-      switch_activity2: true,
-      switch_special: true,
-      switch_seckill: true,
-      switch_coupon: true,
-      switch_manager: true,
-      switch_notice: true,
-      switch_newclassify: true,
-      switch_recom: true,
-
-      templateList: [],
-
-      uploadImageType: null,
-      img1_url: '',
-      img1_hover: false,
-      img2_url: '',
-      img2_hover: false,
-      img3_url: '',
-      img3_hover: false,
-
-      formLoading: false
-    }
-  },
-  computed: {
-    sidebar() {
-      return this.$store.state.app.sidebar
-    },
-    classObj() {
-      return {
-        hideSidebar: !this.sidebar.opened,
-        openSidebar: this.sidebar.opened
-      }
-    },
-  },
-
-  created() {
-    if(this.isAdmin) return false;
-    this.getTemplate();
-  },
-
-  watch: {
-    step() {
-      if(this.step === 'first') {
-        this.getTemplate();
-      }else {
-        this.getLogoDetail();
-      }
-    }
-  },
-
-  methods: {
-    // 获取模版列表
-    getTemplate() {
-      getTemplate({
-        companyId: this.companyId
-      }).then(res => {
-        this.templateList = res.data;
-        this.initHome();
-      })
-    },
-
-    // 切换模版
-    changeTemplate() {
-      this.initHome();
-    },
-
-    // 初始化配置
-    initHome() {
-      let index = findElem(this.templateList, 'templateType', this.currentTemplate);
-      this.switch_dialog = this.templateList[index].popupStatus;
-      this.switch_banner = this.templateList[index].carouseStatus;
-      this.switch_activity1 = this.templateList[index].active1Status;
-      this.switch_classify = this.templateList[index].categoryStatus;
-      this.switch_activity2 = this.templateList[index].active2Status;
-      this.switch_special = this.templateList[index].onlyStatus;
-      this.switch_seckill = this.templateList[index].killStatus;
-      this.switch_coupon = this.templateList[index].couponStatus;
-      this.switch_manager = this.templateList[index].customerStatus;
-      this.switch_notice = this.templateList[index].notiveStatus;
-      this.switch_newclassify = this.templateList[index].newsStatus;
-      this.switch_recom = this.templateList[index].okStatus;
-    },
-    
-    // 保存首页配置
-    submitStep1Form() {
-      let index = findElem(this.templateList, 'templateType', this.currentTemplate);
-      let params = {
-        companyWechatId: this.companyId,
-        useTemplate: this.currentTemplate,
-        companyWechatTemplatesList: [{
-          companyWechatTemplateId: this.templateList[index].companyWechatTemplateId,
-          templateType: this.templateList[index].templateType,
-          popupStatus: this.switch_dialog,
-          carouseStatus: this.switch_banner,
-          active1Status: this.switch_activity1,
-          categoryStatus: this.switch_classify,
-          active2Status: this.switch_activity2,
-          onlyStatus: this.switch_special,
-          killStatus: this.switch_seckill,
-          couponStatus: this.switch_coupon,
-          customerStatus: this.switch_manager,
-          notiveStatus: this.switch_notice,
-          newsStatus: this.switch_newclassify,
-          okStatus: this.switch_recom,
-        }],
-      }
-      this.formLoading = true;
-      editTemplate(params).then(res => {
-        this.getTemplate();
-        this.$successMsg('保存成功');
-        getInfo(getUserid()).then(response => {
-          localStorage.setItem("supply_user", JSON.stringify(response.data));
-        })
-      }).finally(res => {
-        this.formLoading = false;
-      })
-    },
-
-    // 获取logo信息
-    getLogoDetail() {
-      getDetail({adminUserId: getUserid()}).then(res => {
-        this.img1_url = res.data.minLogo1;
-        this.img2_url = res.data.minLogo2;
-        this.img3_url = res.data.minLogo3;
-      })
-    },
-
-    uploadImage(type) {
-      this.uploadImageType = type;
-      document.querySelector('.avatar-uploader input').click();
-    },
-
-    // 上传图片
-    uploadSuccess(res, file) {
-      this[this.uploadImageType + '_url'] = res.data.url;
-    },
-
-    beforeUpload(file) {
-      const fileSuffix = file.name.substring(file.name.lastIndexOf(".") + 1);
-      const whiteList = ['jpg', 'jpeg', 'png'];
-      if (whiteList.indexOf(fileSuffix) === -1) {
-        this.$errorMsg('只支持上传jpg/jpeg/png文件!');
-        return false;
-      }
-    },
-
-    // 预览图片
-    previewImage(type) {
-      this.$refs[type].showViewer = true;
-    },
-
-    submitStep2Form() {
-      if(!this.img1_url) {
-        return this.$errorMsg('请上传主logo');
-      }
-      if(!this.img2_url) {
-        return this.$errorMsg('请上传通用logo');
-      }
-      if(!this.img3_url) {
-        return this.$errorMsg('请上传头像logo');
-      }
-      this.formLoading = true;
-      let params = {
-        companyWechatId: this.companyId,
-        mainLog: this.img1_url,
-        commonLog: this.img2_url,
-        minLogo: this.img3_url,
-      }
-      editTemplate(params).then(res => {
-        this.getLogoDetail();
-        this.$successMsg('保存成功');
-      }).finally(res => {
-        this.formLoading = false;
-      })
-    },
-  }
-}
-</script>
-
-<style lang="scss" scoped>
-  ::v-deep .el-radio-group {
-    display: flex;
-    .item {
-      margin-right: 20px;
-      .el-radio {
-        height: 40px;
-        line-height: 40px;
-      }
-      .el-image {
-        width: 120px;
-        height: 200px;
-        display: block;
-      }
-    }
-  }
-  .images {
-    display: flex;
-    flex-wrap: wrap;
-    .main-img {
-      display: flex;
-      flex-direction: column;
-      justify-content: center;
-      align-items: center;
-      width: 120px;
-      margin-right: 20px;
-      .img {
-        border: 1px dashed #eaeaea;
-        border-radius: 5px;
-        overflow: hidden;
-        position: relative;
-        .el-image {
-          display: block;
-        }
-        .mask {
-          position: absolute;
-          left: 0;
-          top: 0;
-          width: 120px;
-          height: 120px;
-          background: rgba($color: #000000, $alpha: 0.3);
-          display: flex;
-          align-items: center;
-          justify-content: center;
-          i {
-            font-size: 20px;
-            color: #ffffff;
-            cursor: pointer;
-            margin: 0 8px;
-          }
-        }
-      }
-      .text {
-        font-size: 14px;
-        color: #666666;
-      }
-    }
-    .add {
-      width: 120px;
-      height: 120px;
-      border: 1px dashed #eaeaea;
-      border-radius: 5px;
-      cursor: pointer;
-      display: flex;
-      align-items: center;
-      justify-content: center;
-      i {
-        font-size: 30px;
-        color: #999;
-      }
-    }
-    .tmp-img {
-      position: relative;
-      .tmp {
-        position: absolute;
-        left: 0;
-        top: 0;
-        line-height: 20px;
-        padding: 0 8px;
-        background: #f66460;
-        border-radius: 0 0 10px 0;
-        font-size: 12px;
-        color: #ffffff;
-      }
-    }
-  }
-  .tips {
-    margin-top: 10px;
-    span {
-      display: inline-block;
-      width: 300px;
-      text-align: center;
-      line-height: 32px;
-      background: #ffefef;
-      font-size: 14px;
-      color: #f66460;
-    }
-  }
-  .diy-table {
-    width: 400px;
-    .item {
-      display: flex;
-      border: 1px solid #eaeaea;
-      border-bottom: none;
-      &.head {
-        font-weight: bold;
-      }
-      &:last-child {
-        border-bottom: 1px solid #eaeaea;
-      }
-      >div {
-        flex: 1;
-        display: flex;
-        align-items: center;
-        justify-content: center;
-      }
-      .label {
-        border-right: 1px solid #eaeaea;
-      }
-      .value {
-        span {
-          margin-left: 10px;
-          color: #666666;
-          &.on {
-            color: #409EFF;
-          }
-        }
-      }
-    }
-  }
-  .nodata {
-    font-size: 18px;
-    color: #666666;
-  }
-</style>

+ 0 - 410
src/views/merchant/merchant_detail.vue

@@ -1,410 +0,0 @@
-<template>
-
-   <div class="app-container">
-    <div>
-      <el-form class="my-form" ref="mainForm" :model="mainForm" label-width="100px" label-position="right">
-        <el-form-item label="商户账号" prop="account">
-          <el-input v-model="mainForm.account" disabled></el-input>
-        </el-form-item>
-        <el-form-item label="账户昵称" prop="nickName">
-          <el-input v-model="mainForm.nickName" disabled></el-input>
-        </el-form-item>
-        <el-form-item label="负责人" prop="chargePerson">
-          <el-input v-model="mainForm.chargePerson" disabled></el-input>
-        </el-form-item>
-        <el-form-item label="联系电话" prop="phone">
-          <el-input v-model="mainForm.phone" disabled></el-input>
-        </el-form-item>
-        <el-form-item label="金蝶主体账号" prop="kingdeeId">
-          <el-input v-model="mainForm.kingdeeId" disabled></el-input>
-        </el-form-item>
-        <el-form-item label="金蝶主体名称" prop="kingdeeName">
-          <el-input v-model="mainForm.kingdeeName" disabled></el-input>
-        </el-form-item>
-        <el-form-item label="电子邮箱" prop="email">
-          <el-input v-model="mainForm.email" disabled></el-input>
-        </el-form-item>
-        <el-form-item label="地址" prop="address">
-          <el-input v-model="mainForm.address" disabled></el-input>
-        </el-form-item>
-        <el-form-item label="登录密码" prop="password">
-          <el-input v-model="mainForm.password" type="password" disabled></el-input>
-          <el-button class="reset" @click="handleReset()">重置密码</el-button>
-        </el-form-item>
-        <!-- <el-form-item class="tr">
-          <el-button type="primary" @click="submitmainForm">保存</el-button>
-        </el-form-item> -->
-      </el-form>
-    </div>
-
-    <div class="page-footer">
-      <div class="footer" :class="classObj">
-        <!-- <el-button type="primary" @click="submitMainForm" :loading="formLoading">{{ formLoading ? '保存中 ...' : '保 存' }}</el-button> -->
-        <el-popconfirm
-          title="确定关闭吗?"
-          @onConfirm="goBack"
-          style="margin-left: 10px;"
-        >
-          <el-button slot="reference">关 闭</el-button>
-        </el-popconfirm>
-      </div>
-    </div>
-    
-    <!-- 重置密码 -->
-    <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>
-          <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>
-          <span class="show-pwd" @click="showPwd(2)">
-            <svg-icon :icon-class="passwordType2 === 'password' ? 'eye' : 'eye-open'" />
-          </span>
-        </el-form-item>
-      </el-form>
-      <div slot="footer" class="dialog-footer">
-        <el-button @click="cancelResetForm">取 消</el-button>
-        <el-button type="primary" @click="submitResetForm">确 定</el-button>
-      </div>
-    </el-dialog>
-
-  </div>
-  
-
- 
-</template>
-
-<script>
-import { getToken } from '@/utils/auth'
-import { getDetail, resetPassword, editAccount } from "@/api/merchant";
-
-export default {
- 
-  data() {
-    var validatePass = (rule, value, callback) => {
-      if (value === '') {
-        callback(new Error('请输入登录密码'));
-      } else if (value.length < 12) {
-        callback(new Error('密码长度至少12位'));
-      } else if (/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/.test(value) == false) {
-        callback(new Error('密码必须包含数字和字母'));
-      } else {
-        if (this.resetForm.confirmPassword !== '') {
-          this.$refs.resetForm.validateField('confirmPassword');
-        }
-        callback();
-      }
-    };
-    var validatePass2 = (rule, value, callback) => {
-      if (value === '') {
-        callback(new Error('请再次输入密码'));
-      } else if (value !== this.resetForm.newPassword) {
-        callback(new Error('两次输入密码不一致'));
-      } else {
-        callback();
-      }
-    };
-    return {
-      baseURL: process.env.VUE_APP_BASE_API,
-      myHeaders: {'x-token': getToken()},
-      id: null,
-      companyWechatId: null,
-      step: 'first',
-      mainForm: {
-        account: '', // 账号
-        nickName: '', // 用户名
-        chargePerson: '', // 负责人
-        phone: '', // 联系电话
-        kingdeeId: '',
-        kingdeeName: '',
-        email: '', // 电子邮箱
-        address: '', // 地址
-        newPassword: '', // 新密码
-        confirmPassword: '', // 确认密码
-      },
-
-      passwordType1: 'password',
-      passwordType2: 'password',
-
-      
-      resetFormVisible: false,
-      resetForm: {
-        newPassword: '', // 新密码
-        confirmPassword: '', // 确认密码
-      },
-      resetFormRules: {
-        newPassword: [
-          { required: true, validator: validatePass, trigger: 'blur' }
-        ],
-        confirmPassword: [
-          { required: true, validator: validatePass2, trigger: 'blur' }
-        ],
-      },
-
-      formLoading: false,
-    }
-  },
-  computed: {
-    sidebar() {
-      return this.$store.state.app.sidebar
-    },
-    classObj() {
-      return {
-        hideSidebar: !this.sidebar.opened,
-        openSidebar: this.sidebar.opened
-      }
-    },
-  },
-  created() {
-    const { id } = this.$route.query;
-    this.id = id;
-    this.getDetail();
-  },
-  methods: {
-    goBack() {
-      this.$router.go(-1);
-    },
-
-    // 获取详情
-    getDetail() {
-      getDetail({adminUserId: this.id}).then(res => {
-        this.mainForm.account = res.data.userName;
-        this.mainForm.nickName = res.data.nickName;
-        this.mainForm.chargePerson = res.data.linkName;
-        this.mainForm.phone = res.data.linkPhone;
-        this.mainForm.kingdeeId = res.data.useOrgNumber;
-        this.mainForm.kingdeeName = res.data.useOrgName;
-        this.mainForm.email = res.data.email;
-        this.mainForm.address = res.data.address;
-        this.mainForm.password = '************';
-      })
-    },
-
-    // 重置密码
-    handleReset(id) {
-      this.resetId = id;
-      this.resetFormVisible = true;
-    },
-
-    // 取消重置密码
-    cancelResetForm(){
-      this.resetFormVisible = false;
-      this.passwordType1 = 'password';
-      this.passwordType2 = 'password';
-      this.$refs.resetForm.resetFields();
-    },
-
-    // 提交重置密码
-    submitResetForm() {
-      this.$refs.resetForm.validate((valid) => {
-        if (valid) {
-          let params = {
-            password: this.resetForm.newPassword,
-            adminUserId: this.id
-          }
-          resetPassword(params).then(res => {
-            this.cancelResetForm();
-            this.getDetail();
-            this.$successMsg();
-          })
-        }
-      })
-    },
-
-    // 显示隐藏密码
-    showPwd(num) {
-      if(num == 1) {
-        if (this.passwordType1 === 'password') {
-          this.passwordType1 = ''
-        } else {
-          this.passwordType1 = 'password'
-        }
-        this.$nextTick(() => {
-          this.$refs.password1.focus()
-        })
-      }
-      if(num == 2) {
-        if (this.passwordType2 === 'password') {
-          this.passwordType2 = ''
-        } else {
-          this.passwordType2 = 'password'
-        }
-        this.$nextTick(() => {
-          this.$refs.password2.focus()
-        })
-      }
-    },
-
-    submitMainForm() {
-      this.$refs.mainForm.validate((valid) => {
-        if (valid) {
-          this.formLoading = true;
-
-          let params = {
-            adminUserId: this.id,
-            corpId: this.mainForm.enterpriseId,
-            secret2: this.mainForm.listSecret,
-            secret3: this.mainForm.listSyncSecret,
-            agentId1: this.mainForm.appAgentId,
-            secret1: this.mainForm.appSecret,
-            appId: this.mainForm.appId,
-            mchId: this.mainForm.merchantId,
-            mchKey: this.mainForm.merchantKey,
-            subAppId: this.mainForm.childAppId,
-            subSecret: this.mainForm.childKey,
-            subMchId: this.mainForm.childMerchantId,
-            template: this.mainForm.templateId,
-            companyWechatId: this.companyWechatId
-          }
-          editAccount(params).then(res => {
-            this.$successMsg('保存成功');
-            setTimeout(() => {
-              this.goBack();
-            }, 1500)
-          }).finally(res => {
-            this.formLoading = false;
-          })
-        }
-      })
-    }
-  }
-}
-</script>
-
-<style lang="scss" scoped>
-  .setting_title {
-    padding-left: 0;
-  }
-  .tips {
-    font-size: 14px;
-  }
-  .my-card {
-    margin-top: 20px;
-    .box {
-      background: rgb(235, 240, 249);
-      padding: 10px;
-      font-size: 14px;
-      margin: 20px 0;
-      line-height: 18px;
-      ::v-deep .el-link {
-        vertical-align: unset;
-      }
-    }
-  }
-  .my-form {
-    width: 450px;
-    margin-top: 20px;
-  }
-  .show-pwd {
-    position: absolute;
-    right: 15px;
-    top: 0;
-    font-size: 16px;
-    cursor: pointer;
-    user-select: none;
-  }
-  .question {
-    position: absolute;
-    right: -30px;
-    top: 0;
-    font-size: 20px;
-    cursor: pointer;
-    user-select: none;
-  }
-  .reset {
-    position: absolute;
-    right: -110px;
-    top: 0;
-  }
-  .my-form2 {
-    ::v-deep input {
-      width: 400px;
-    }
-  }
-  .tips {
-    margin-top: 10px;
-    span {
-      display: inline-block;
-      width: 300px;
-      text-align: center;
-      line-height: 32px;
-      background: #ffefef;
-      font-size: 14px;
-      color: #f66460;
-    }
-  }
-  .images {
-    display: flex;
-    flex-wrap: wrap;
-    .main-img {
-      display: flex;
-      flex-direction: column;
-      justify-content: center;
-      align-items: center;
-      width: 120px;
-      margin-right: 20px;
-      .img {
-        border: 1px dashed #eaeaea;
-        border-radius: 5px;
-        overflow: hidden;
-        position: relative;
-        .el-image {
-          display: block;
-        }
-        .mask {
-          position: absolute;
-          left: 0;
-          top: 0;
-          width: 120px;
-          height: 120px;
-          background: rgba($color: #000000, $alpha: 0.3);
-          display: flex;
-          align-items: center;
-          justify-content: center;
-          i {
-            font-size: 20px;
-            color: #ffffff;
-            cursor: pointer;
-            margin: 0 8px;
-          }
-        }
-      }
-      .text {
-        font-size: 14px;
-        color: #666666;
-      }
-    }
-    .add {
-      width: 120px;
-      height: 120px;
-      border: 1px dashed #eaeaea;
-      border-radius: 5px;
-      cursor: pointer;
-      display: flex;
-      align-items: center;
-      justify-content: center;
-      i {
-        font-size: 30px;
-        color: #999;
-      }
-    }
-    .tmp-img {
-      position: relative;
-      .tmp {
-        position: absolute;
-        left: 0;
-        top: 0;
-        line-height: 20px;
-        padding: 0 8px;
-        background: #f66460;
-        border-radius: 0 0 10px 0;
-        font-size: 12px;
-        color: #ffffff;
-      }
-    }
-  }
-</style>

+ 1 - 2
src/views/merchant/merchant_list.vue

@@ -180,10 +180,9 @@
 
 <script>
 import { COMMON_SELECT } from '@/utils/select_data'
-import {getList, changeAccountStatus} from "@/api/merchant";
+import { getList, changeAccountStatus, getDetail, resetPassword, editAccount } from "@/api/merchant";
 import {downloadFiles} from '@/utils/util'
 import { getToken } from '@/utils/auth'
-import { getDetail, resetPassword, editAccount } from "@/api/merchant";
 
 export default {
   // components:{MERCHANT_DETAIL},

+ 438 - 210
src/views/setting/account.vue

@@ -1,32 +1,79 @@
 <template>
   <div class="app-container">
-    <div class="setting_title">账户管理</div>
-    <el-divider></el-divider>
-
+    <div class="tree-container">
+      <div style="padding: 10px; display: flex;">
+        <el-button icon="el-icon-refresh-right" size="small" @click="refreshDepartment()" style="padding: 9px 10px; margin-right: 6px"></el-button>
+        <el-input
+          placeholder="输入关键字进行过滤"
+          size="small"
+          clearable
+          v-model="filterText">
+        </el-input>
+      </div>
+      <el-tree
+        :data="departmentList"
+        :props="defaultProps"
+        default-expand-all
+        highlight-current
+        :expand-on-click-node="false"
+        :filter-node-method="filterNode"
+        @node-click="handleNodeClick"
+        node-key="id"
+        ref="listTree">
+        <div class="custom-tree-node" slot-scope="{ node, data }">
+          <i :class="data.children && data.children.length > 0 ? 'el-icon-folder-opened':'el-icon-document-remove'"></i><span>{{ node.label }}</span>
+        </div>
+      </el-tree>
+    </div>
     <div class="mymain-container">
-      <div class="btn-group clearfix">
+      <div class="screen-container">
+        <!-- <div class="top clearfix">
+          <div class="title fl">条件筛选</div>
+        </div> -->
+        <el-form ref="screenForm" :model="screenForm" label-width="70px" size="small" label-position="left">
+          <el-row :gutter="20">
+            <el-col :xs="24" :sm="12" :lg="12">
+              <el-form-item label="账号名称" prop="name">
+                <el-input v-model="screenForm.name" placeholder="请输入账号名称"></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :xs="24" :sm="12" :lg="12" class="tr">
+              <el-form-item label="">
+                <el-button size="small" @click="resetScreenForm">清空</el-button>
+                <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
+              </el-form-item>
+            </el-col>
+          </el-row>
+        </el-form>
+      </div>
+      <div class="btn-group clearfix" style="margin-top: 20px">
         <div class="fl">
-          <el-button size="small" type="primary" icon="el-icon-plus" @click="addOrEdit('add')" v-if="checkBtnRole('add')">新增账户</el-button>
+          <el-button size="small" type="primary" @click="openAccountForm('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-option label="全部角色" value=""></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-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-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>
-          </el-input>
+          <!-- <el-upload
+            class="import-btn"
+            style="height: 0; width: 0; overflow: hidden;"
+            :action="baseURL + 'student/import'"
+            :http-request="handleImport"
+            :file-list="importFileList"
+            v-if="checkBtnRole('import')"
+          >
+            <el-button size="small" type="primary" :loading="importLoading">{{ importLoading ? '导入中...' : '导入' }}</el-button>
+          </el-upload>
+
+          <el-button size="small" type="primary" @click="handleExport">导出</el-button>
+
+          <el-button size="small" type="primary" :loading="importLoading" @click="clickImport">{{ importLoading ? '导入中...' : '导入' }}</el-button>
+          
+          <el-button size="small" @click="handleDownload" v-if="checkBtnRole('download')">下载导入模板</el-button> -->
         </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="center" label="序号" type="index" width="50"></el-table-column>
+          <!-- <el-table-column align="center" type="selection" width="55" fixed></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>
           <el-table-column align="center" label="角色" prop="roleName" min-width="100"></el-table-column>
@@ -48,13 +95,18 @@
                 </el-popconfirm>
               </template>
 
-              <el-button type="text" @click="addOrEdit('edit', scope.row.adminUserId)" v-if="checkBtnRole('edit')">编辑</el-button>
+              <el-button type="text" @click="openAccountForm('edit', scope.row.adminUserId)" v-if="checkBtnRole('edit')">编辑</el-button>
               <el-button type="text" @click="handleReset(scope.row.adminUserId)" v-if="checkBtnRole('reset')">重置密码</el-button>
+
+              <!-- <el-popconfirm style="margin-left: 10px;" title="确定删除吗?" @onConfirm="deleteAccount(scope.row.id)" v-if="checkBtnRole('del')">
+                <el-button slot="reference" type="text">删除</el-button>
+              </el-popconfirm> -->
             </template>
           </el-table-column>
+          
         </el-table>
       </div>
-
+      
       <div class="pagination clearfix">
         <div class="fr">
           <el-pagination
@@ -69,40 +121,18 @@
         </div>
       </div>
     </div>
-
-    <!-- 重置密码 -->
-    <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>
-          <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>
-          <span class="show-pwd" @click="showPwd(2)">
-            <svg-icon :icon-class="passwordType2 === 'password' ? 'eye' : 'eye-open'" />
-          </span>
-        </el-form-item>
-      </el-form>
-      <div slot="footer" class="dialog-footer">
-        <el-button @click="cancelResetForm">取 消</el-button>
-        <el-button type="primary" @click="submitResetForm">确 定</el-button>
-      </div>
-    </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="AccountFormType == 'add' ? '添加账号':'编辑账号'" :visible.sync="AccountFormVisible" :show-close="false" width="40%" :close-on-click-modal="false">
+      <el-form ref="AccountForm" :model="AccountForm" :rules="AccountFormRules" label-position="left" label-width="80px">
         <el-form-item label="账号" prop="account">
-          <el-input v-model="addForm.account" autocomplete="off" placeholder="请输入账号"></el-input>
+          <el-input v-model="AccountForm.account" autocomplete="off" placeholder="请输入账号"></el-input>
         </el-form-item>
         <el-form-item label="用户名" prop="nickName">
-          <el-input v-model="addForm.nickName" autocomplete="off" placeholder="请输入用户名"></el-input>
+          <el-input v-model="AccountForm.nickName" autocomplete="off" placeholder="请输入用户名"></el-input>
         </el-form-item>
         <el-form-item label="角色组" prop="role">
-          <el-select v-model="addForm.role" placeholder="请选择角色组" style="width: 100%;">
+          <el-select v-model="AccountForm.role" placeholder="请选择角色组" style="width: 100%;">
             <el-option :label="item.name" :value="item.adminRoleId" v-for="(item, index) in roleList" :key="index"></el-option>
           </el-select>
         </el-form-item>
@@ -110,25 +140,25 @@
           <el-tree
             :data="departmentList"
             show-checkbox
-            node-key="id"
+            node-key="adminWebsitId"
             ref="tree"
             highlight-current
             :props="props">
           </el-tree>
         </el-form-item>
         <el-form-item label="商户" prop="merchant" v-show="accountType === 1 || accountType === 2">
-          <el-select v-model="addForm.merchant" placeholder="请选择商户" style="width: 100%;">
+          <el-select v-model="AccountForm.merchant" placeholder="请选择商户" style="width: 100%;">
             <el-option :label="item.adminCompanyName" :value="item.adminCompanyId" v-for="(item, index) in merchantList" :key="index"></el-option>
           </el-select>
         </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="AccountForm.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="AccountForm.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>
@@ -136,8 +166,30 @@
 
       </el-form>
       <div slot="footer" class="dialog-footer">
-        <el-button @click="cancelAddForm">取 消</el-button>
-        <el-button type="primary" @click="submitAddForm">确 定</el-button>
+        <el-button @click="cancelAccountForm">取 消</el-button>
+        <el-button type="primary" @click="submitAccountForm">确 定</el-button>
+      </div>
+    </el-dialog>
+
+    <!-- 重置密码 -->
+    <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>
+          <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>
+          <span class="show-pwd" @click="showPwd(2)">
+            <svg-icon :icon-class="passwordType2 === 'password' ? 'eye' : 'eye-open'" />
+          </span>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="cancelResetForm">取 消</el-button>
+        <el-button type="primary" @click="submitResetForm">确 定</el-button>
       </div>
     </el-dialog>
 
@@ -145,8 +197,8 @@
 </template>
 
 <script>
-import { getAccountList, getRoleList, changeAccountStatus, resetPassword, addAccount, editAccount, getUserInfo, getDepartmentList, getMerchantList } from '@/api/setting'
-import { findElem } from '@/utils/util'
+import { getDepartmentList, getAccountList, addAccount, editAccount, deleteAccount, getAccountDetail, getRoleList, getMerchantList, changeAccountStatus, resetPassword } from '@/api/setting'
+import { findElem, downloadFiles, handleImport } from '@/utils/util'
 
 export default {
   data() {
@@ -177,8 +229,8 @@ export default {
       } else if (value && value.length < 6) {
         callback(new Error('密码长度至少6位'));
       } else {
-        if (this.addForm.confirmPassword !== '') {
-          this.$refs.addForm.validateField('confirmPassword');
+        if (this.AccountForm.confirmPassword !== '') {
+          this.$refs.AccountForm.validateField('confirmPassword');
         }
         callback();
       }
@@ -186,57 +238,29 @@ export default {
     var validatePass4 = (rule, value, callback) => {
       if (value === '') {
         callback(new Error('请再次输入密码'));
-      } else if (value !== this.addForm.newPassword) {
+      } else if (value !== this.AccountForm.newPassword) {
         callback(new Error('两次输入密码不一致'));
       } else {
         callback();
       }
     };
     return {
+      baseURL: process.env.VUE_APP_BASE_API,
       dataList: null, // 列表数据
+      moduleList: null, // 模块列表
       listLoading: true, // 列表加载loading
       screenForm: { // 筛选表单数据
-        role: '', // 角色
-        status: '', // 状态
-        keyword: '', // 关键词
+        name: '', // 名称
       },
-      select_status: [ // 筛选字段 - 状态
-        { label: '正常', value: true },
-        { label: '冻结', value: false }
-      ],
       currentPage: 1, // 当前页码
       pageSize: 10, // 每页数量
       listTotal: 0, // 列表总数
-      roleList: [], // 角色列表
-      departmentList: [], // 部门列表
-      props: {
-        multiple: true,
-        value: 'id',
-        label: 'name',
-        children: 'children',
-      },
-      merchantList: [], // 商户列表
 
-      resetId:  null,
-      resetFormVisible: false,
-      resetForm: {
-        newPassword: '', // 新密码
-        confirmPassword: '', // 确认密码
-      },
-      resetFormRules: {
-        newPassword: [
-          { required: true, validator: validatePass, trigger: 'blur' }
-        ],
-        confirmPassword: [
-          { required: true, validator: validatePass2, trigger: 'blur' }
-        ],
-      },
+      selectDepartment: null, // 选中的部门
 
-      editId:  null,
-      accountType: '',
-      addFormType: 'add',
-      addFormVisible: false,
-      addForm: {
+      AccountFormType: 'add',
+      AccountFormVisible: false,
+      AccountForm: {
         account: '', // 账号
         nickName: '', // 用户名
         merchant: '', // 商户
@@ -244,7 +268,7 @@ export default {
         newPassword: '', // 新密码
         confirmPassword: '', // 确认密码
       },
-      addFormRules: {
+      AccountFormRules: {
         account: [
           { required: true, message: '请输入账号', trigger: 'blur' }
         ],
@@ -261,30 +285,64 @@ export default {
           { required: true, validator: validatePass4, trigger: 'blur' }
         ],
       },
+      editAccountId: null, 
+
+      filterText: '',
+      departmentList: [],
+      defaultProps: {
+        children: 'children',
+        label: 'name'
+      },
+      props: {
+        multiple: true,
+        value: 'adminWebsitId',
+        label: 'name',
+        children: 'children',
+      },
+
+      tableSelection: [],
+
+      importLoading: false, // 导入加载loading
+      importFileList: [], // 导入列表
+
+      resetId:  null,
+      resetFormVisible: false,
+      resetForm: {
+        newPassword: '', // 新密码
+        confirmPassword: '', // 确认密码
+      },
+      resetFormRules: {
+        newPassword: [
+          { required: true, validator: validatePass, trigger: 'blur' }
+        ],
+        confirmPassword: [
+          { required: true, validator: validatePass2, trigger: 'blur' }
+        ],
+      },
+
+      accountType: '',
+      roleList: [], // 角色列表
+      merchantList: [],
 
       passwordType1: 'password',
       passwordType2: 'password',
     }
   },
-  async created() {
-    await this.getRoleList();
-    if(this.$route.query.type) {
-      let index = findElem(this.roleList, 'name', '企业负责人');
-      this.screenForm.role = this.roleList[index].adminRoleId;
-    }
-    this.getList();
-  },
   watch: {
-    'addForm.role'() {
-      console.log('change role');
-      if(this.addForm.role) {
-        let index = findElem(this.roleList, 'adminRoleId', this.addForm.role);
-        this.accountType = this.roleList[index].type - 1;
+    filterText(val) {
+      this.$refs.listTree.filter(val);
+    },
+    'AccountForm.role'() {
+      if(this.AccountForm.role) {
+        let index = findElem(this.roleList, 'adminRoleId', this.AccountForm.role);
+        this.accountType = this.roleList[index].type;
       }
-      // this.$refs.tree.setCheckedKeys([]);
-      // this.addForm.merchant = '';
     }
   },
+  async created() {
+    this.getTree();
+    this.getList();
+  },
   methods: {
     // 查询按钮权限
     checkBtnRole(value) {
@@ -295,30 +353,6 @@ export default {
       return true;
     },
 
-    getList() {
-      this.listLoading = true;
-
-      let params = {
-        roleId: this.screenForm.role,
-        status: this.screenForm.status,
-        userName: this.screenForm.keyword,
-        pageNum: this.currentPage,
-        pageSize: this.pageSize
-      };
-
-      getAccountList(params).then(res => {
-        this.dataList = res.data.records;
-        this.listTotal = res.data.total;
-        this.listLoading = false;
-      })
-    },
-
-    // 筛选后重新获取列表
-    getListByScreen() {
-      this.currentPage = 1;
-      this.getList();
-    },
-
     // 获取角色列表
     async getRoleList() {
       const result = await new Promise((resolve, reject) => {
@@ -332,18 +366,6 @@ export default {
       return result;
     },
 
-    // 获取部门列表
-    async getDepartmentList() {
-      const result = await new Promise((resolve, reject) => {
-        getDepartmentList().then(res => {
-          resolve(res.data);
-        }).catch(res => {
-          resolve([]);
-        })
-      })
-      return result;
-    },
-
     // 获取商户列表
     async getMerchantList() {
       const result = await new Promise((resolve, reject) => {
@@ -351,7 +373,7 @@ export default {
           pageNum: 1,
           pageSize: 1000
         }).then(res => {
-          console.log('--------------',res.data.records)
+          this.merchantList = res.data.records;
           resolve(res.data.records);
         }).catch(res => {
           resolve([]);
@@ -360,6 +382,31 @@ export default {
       return result;
     },
 
+    // 获取部门列表
+    getTree() {
+      getDepartmentList().then(res => {
+        this.departmentList = res.data;
+      })
+    },
+
+    // 获取账号列表
+    getList() {
+      this.listLoading = true;
+
+      let params = {
+        pageNum: this.currentPage,
+        pageSize: this.pageSize,
+        adminWebsitId: this.selectDepartment ? this.selectDepartment.adminWebsitId : '',
+        keyword: this.screenForm.name
+      };
+
+      getAccountList(params).then(res => {
+        this.dataList = res.data.records;
+        this.listTotal = res.data.total;
+        this.listLoading = false;
+      })
+    },
+
     // 更改每页数量
     handleSizeChange(val) {
       this.pageSize = val;
@@ -373,6 +420,147 @@ export default {
       this.getList();
     },
 
+    // 提交筛选表单
+    submitScreenForm() {
+      this.currentPage = 1;
+      this.getList();
+    },
+
+    // 重置筛选表单
+    resetScreenForm() {
+      this.$refs.screenForm.resetFields();
+      this.currentPage = 1;
+      this.getList();
+    },
+
+    // 筛选部门
+    filterNode(value, data) {
+      if (!value) return true;
+      return data.name.indexOf(value) !== -1;
+    },
+
+    // 选择部门
+    handleNodeClick(data) {
+      console.log(data);
+      if(this.selectDepartment && data.adminWebsitId === this.selectDepartment.adminWebsitId) {
+        this.$refs.listTree.setCurrentKey(null);
+        this.selectDepartment = null;
+      }else {
+        this.selectDepartment = data;
+      }
+      this.getList();
+    },
+
+    // 刷新部门
+    refreshDepartment() {
+      this.$refs.listTree.setCurrentKey(null);
+      this.selectDepartment = null;
+      this.getTree();
+      this.getList();
+    },
+
+    // 打开 新增编辑 账号表单
+    async openAccountForm(type, id) {
+
+      this.AccountFormType = type;
+      this.AccountFormVisible = true;
+      await this.getMerchantList();
+      await this.getRoleList();
+      if(type == 'add') {
+        if(this.selectDepartment) {
+          this.$refs.tree.setCheckedKeys([this.selectDepartment.adminWebsitId]);
+        }
+      }
+
+      if(type == 'edit') {
+        this.editAccountId = id;
+        getAccountDetail({adminUserId: id}).then(res => {
+          this.AccountForm.account = res.data.userName;
+          this.AccountForm.role = res.data.roleId;
+          this.AccountForm.nickName = res.data.nickName;
+          this.AccountForm.merchant = res.data.companyWechatId;
+          this.$refs.tree.setCheckedKeys(res.data.adminWebsitIds || []);
+        })
+      }
+    },
+
+    // 取消 新增编辑 账号表单
+    cancelAccountForm(){
+      this.AccountFormVisible = false;
+      this.$refs.AccountForm.resetFields();
+      this.passwordType1 = 'password';
+      this.passwordType2 = 'password';
+    },
+
+    // 提交 账号表单
+    submitAccountForm() {
+      this.$refs.AccountForm.validate((valid) => {
+        if (valid) {
+          let params = {
+            userName: this.AccountForm.account,
+            nickName: this.AccountForm.nickName,
+            roleId: this.AccountForm.role,
+            password: this.AccountForm.newPassword,
+          }
+          if(this.accountType === 0) {
+            params.adminWebsitIds = this.$refs.tree.getCheckedKeys();
+          }else {
+            params.adminCompanyId = this.AccountForm.merchant;
+          }
+          if(this.AccountFormType == 'edit') {
+            params.adminUserId = this.editAccountId;
+            editAccount(params).then(res => {
+              this.cancelAccountForm();
+              this.getList();
+              this.$successMsg('编辑成功');
+            })
+          }else {
+            addAccount(params).then(res => {
+              this.cancelAccountForm();
+              this.getList();
+              this.$successMsg('添加成功');
+            })
+          }
+        }
+      })
+    },
+
+    // 表格选择列
+    handleTableSelection(val) {
+      this.tableSelection = val;
+    },
+
+    // 批量删除账号
+    batchDeleteAccount() {
+      if(this.tableSelection.length < 1) {
+        return this.$errorMsg('至少选择一名账号');
+      }
+      this.$confirm(`确定删除选中的账号吗?`, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        let AccountIds = [];
+        this.tableSelection.forEach(item => {
+          AccountIds.push(item.id);
+        });
+        deleteAccount({id: AccountIds.join(',')}).then(res => {
+          this.$successMsg();
+          this.getTree();
+          this.getList();
+        })
+      }).catch(() => {});
+    },
+
+    // 删除账号
+    deleteAccount(id) {
+      deleteAccount({id: id}).then(res => {
+        this.$successMsg();
+        this.getTree();
+        this.getList();
+      })
+    },
+
     // 操作 - 更改状态(type: 禁用0,启用1)
     changeStatus(id, type) {
       type = type ? true : false
@@ -437,72 +625,49 @@ export default {
       })
     },
 
-    // 新增编辑 账户
-    async addOrEdit(type, id) {
-      this.addFormType = type;
-      this.addFormVisible = true;
-      this.departmentList = await this.getDepartmentList();
-      this.merchantList = await this.getMerchantList();
 
-      if(type == 'edit') {
-        this.editId = id;
-        getUserInfo({adminUserId: id}).then(res => {
-          this.addForm = {
-            account: res.data.userName,
-            role: res.data.roleId,
-            nickName: res.data.nickName,
-            merchant: res.data.companyWechatId
-          }
-          this.$refs.tree.setCheckedKeys(res.data.adminWebsitIds || []);
-        })
-      }
+    // 导出
+    handleExport() {
+      let screenData = {
+        adminWebsitId: this.selectDepartment ? this.selectDepartment.websitId : '',
+        keyword: this.screenForm.name
+      };
+      downloadFiles('wechat/enterprise/export', screenData);
     },
 
-    // 取消 新增编辑账户
-    cancelAddForm(){
-      this.addFormVisible = false;
-      this.passwordType1 = 'password';
-      this.passwordType2 = 'password';
-      this.$refs.addForm.resetFields();
+    // 下载导入模版
+    handleDownload() {
+      downloadFiles('wechat/enterprise/download');
     },
 
-    // 提交 新增编辑账户
-    submitAddForm() {
-      this.$refs.addForm.validate((valid) => {
-        if (valid) {
-          let params = {
-            userName: this.addForm.account,
-            nickName: this.addForm.nickName,
-            roleId: this.addForm.role,
-            password: this.addForm.newPassword,
-            type: this.accountType
-          }
-          if(this.accountType === 0) {
-            params.adminWebsitIds = this.$refs.tree.getCheckedKeys();
-          }else {
-            let index = findElem(this.merchantList, 'adminCompanyId', this.addForm.merchant);
-            params.adminCompanyId = this.addForm.merchant;
-            params.linkName = this.merchantList[index].linkName || '';
-            params.linkPhone = this.merchantList[index].linkPhone || '';
-            params.email = this.merchantList[index].email || '';
-            params.address = this.merchantList[index].address || '';
-          }
-          if(this.addFormType == 'edit') {
-            params.adminUserId = this.editId;
-            editAccount(params).then(res => {
-              this.cancelAddForm();
-              this.getList();
-              this.$successMsg('编辑成功');
-            })
-          }else {
-            addAccount(params).then(res => {
-              this.cancelAddForm();
-              this.getList();
-              this.$successMsg('新增成功');
-            })
-          }
-        }
-      })
+    clickImport() {
+      if(!this.selectDepartment) {
+        return this.$errorMsg('请选择部门');
+      }else {
+        document.querySelector('.import-btn input').click();
+      }
+    },
+
+    // 导入
+    async handleImport(param) {
+      this.importLoading = true;
+      const file = param.file;
+      const formData = new FormData();
+      formData.append("file", file);
+      formData.append("mainDepartmentId", this.selectDepartment.websitId);
+      let result = await handleImport('wechat/enterprise/import', formData);
+      this.importLoading = false;
+      this.importFileList = [];
+      if(result.code == 200) {
+        this.$alert(result.message, '导入成功', {
+          confirmButtonText: '确定'
+        });
+        this.getList();
+      }else {
+        this.$alert(result.message, '导入失败', {
+          confirmButtonText: '确定'
+        });
+      }
     },
 
   }
@@ -510,6 +675,69 @@ export default {
 </script>
 
 <style scoped lang="scss">
+  .app-container {
+    display: flex;
+    .tree-container {
+      width: 18%;
+      height: calc(100vh - 110px);
+      flex-shrink: 0;
+      background: #f5f5f5;
+      margin-right: 2%;
+      display: flex;
+      flex-direction: column;
+      overflow-y: hidden;
+      .el-tree {
+        height: 100%;
+        background: none;
+        width: 100%;
+        overflow: scroll;
+        // ::v-deep .el-tree-node:focus > .el-tree-node__content {
+        //   color: #ffffff;
+        //   background-color: #409EFF;
+        // }
+        ::v-deep >.el-tree-node {
+          display: inline-block;
+          min-width: 100%;
+        }
+        ::v-deep .el-tree-node>.el-tree-node__content {
+          padding-right: 10px;
+          align-self: baseline;
+        }
+        ::v-deep .el-tree-node.is-current>.el-tree-node__content {
+          background-color: #409EFF;
+          .custom-tree-node {
+            i {
+              color: #fff;
+            }
+            span {
+              color: #fff;
+            }
+          }
+        }
+        ::v-deep .el-tree-node>.el-tree-node__children {
+          overflow: unset;
+        }
+        .custom-tree-node {
+          i {
+            font-size: 14px;
+            color: #999;
+          }
+          span {
+            font-size: 14px;
+            margin-left: 6px;
+            color: #666;
+          }
+        }
+      }
+    }
+    .mymain-container {
+      width: 80%;
+      margin-top: 0;
+    }
+  }
+  ::v-deep .el-divider--vertical {
+    margin: 0 15px;
+  }
   .show-pwd {
     position: absolute;
     right: 15px;
@@ -518,4 +746,4 @@ export default {
     cursor: pointer;
     user-select: none;
   }
-</style>
+</style>

+ 235 - 0
src/views/setting/department.vue

@@ -0,0 +1,235 @@
+<template>
+  <div class="app-container">
+    <div class="mymain-container">
+      <div class="table">
+        <el-table :data="dataList" row-key="adminWebsitId" border default-expand-all :tree-props="{children: 'children'}">
+          <el-table-column prop="name" label="部门名称"></el-table-column>
+          <el-table-column prop="mainNames" label="业务范围" align="center"></el-table-column>
+
+          <el-table-column align="center" label="状态" class-name="status-col" width="80">
+            <template slot-scope="scope">
+              <el-tag :type="scope.row.status ? 'success':'danger'">{{ scope.row.status ? '启用':'禁用' }}</el-tag>
+            </template>
+          </el-table-column>
+          <el-table-column label="操作" width="268" fixed="right">
+            <template slot-scope="scope">
+              <el-button type="primary" size="mini" icon="el-icon-plus" @click="openMainForm('add', scope.row.adminWebsitId)">添加子部门</el-button>
+              <el-button type="primary" size="mini" icon="el-icon-edit" v-if="scope.row.parentId > 0" @click="openMainForm('edit', scope.row.adminWebsitId)">编辑</el-button>
+              <el-popconfirm style="margin-left: 10px;" title="确定删除吗?" v-if="scope.row.parentId > 0" @onConfirm="handleDelete(scope.row.adminWebsitId)" >
+                <el-button slot="reference" size="mini" icon="el-icon-delete">删除</el-button>
+              </el-popconfirm>
+            </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"
+            :total="listTotal">
+          </el-pagination>
+        </div>
+      </div>
+    </div>
+    
+    <!-- 添加编辑部门 -->
+    <el-dialog :title="mainFormType == 'add' ? '添加部门':'编辑部门'" :visible.sync="mainFormVisible" :show-close="false" width="40%" :close-on-click-modal="false">
+      <el-form ref="mainForm" :model="mainForm" :rules="mainFormRules" label-position="right" label-width="80px">
+        <el-form-item label="上级菜单" prop="pid">
+          <el-cascader
+            style="width: 100%"
+            :options="dataList"
+            :props="{ checkStrictly: true, value: 'adminWebsitId', label: 'name' }"
+            v-model="mainForm.pid"
+            filterable
+            clearable>
+          </el-cascader>
+        </el-form-item>
+        <el-form-item label="部门名称" prop="name">
+          <el-input placeholder="请输入部门名称" v-model="mainForm.name"></el-input>
+        </el-form-item>
+        <el-form-item label="业务范围" prop="work">
+          <el-select v-model="mainForm.work" multiple placeholder="请选择" style="width: 100%">
+            <el-option
+              v-for="item in workList"
+              :key="item.dictCode"
+              :label="item.dictValue"
+              :value="item.dictCode">
+            </el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="状态" prop="status">
+          <el-radio-group v-model="mainForm.status">
+            <el-radio :label="true">启用</el-radio>
+            <el-radio :label="false">禁用</el-radio>
+          </el-radio-group>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="cancelMainForm">取 消</el-button>
+        <el-button type="primary" @click="submitMainForm">确 定</el-button>
+      </div>
+    </el-dialog>
+
+  </div>
+</template>
+
+<script>
+import { getDepartmentList, addDepartment, editDepartment, getDepartmentDetail, deleteDepartment } from '@/api/setting'
+import { getDictList } from '@/api/common'
+import { findElem } from '@/utils/util'
+
+export default {
+  data() {
+    return {
+      dataList: [], // 列表数据
+      listLoading: true, // 列表加载loading
+      currentPage: 1, // 当前页码
+      pageSize: 10, // 每页数量
+      listTotal: 0, // 列表总数
+
+      editId: null,
+      mainFormType: 'add',
+      mainFormVisible: false,
+      mainForm: {
+        pid: '',
+        name: '',
+        work: '',
+        status: true,
+      },
+      mainFormRules: {
+        name: [
+          { required: true, message: '请填写部门名称', trigger: 'blur' },
+        ],
+        work: [
+          { required: true, message: '请选择业务范围', trigger: 'change' },
+        ],
+      },
+
+      workList: []
+    }
+  },
+
+  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;
+    },
+
+    // 获取部门列表
+    getList() {
+      getDepartmentList().then(res => {
+        this.dataList = res.data;
+      })
+    },
+
+    // 更改每页数量
+    handleSizeChange(val) {
+      this.pageSize = val;
+      this.currentPage = 1;
+      this.getList();
+    },
+
+    // 更改当前页
+    handleCurrentChange(val) {
+      this.currentPage = val;
+      this.getList();
+    },
+
+    // 操作 - 删除
+    handleDelete(id) {
+      deleteDepartment({id: id}).then(res => {
+        this.getList();
+        this.$successMsg();
+      })
+    },
+
+    getDictList() {
+      getDictList({sysDictEnum: 'PRODUCT_TYPE'}).then(res => {
+        this.workList = res.data;
+      })
+    },
+
+    // 打开 新增编辑 部门表单
+    openMainForm(type, id) {
+      this.mainFormType = type;
+      this.mainFormVisible = true;
+      this.getDictList();
+
+      if(type == 'add') {
+        this.mainForm.pid = id;
+      }else {
+        this.editId = id;
+        getDepartmentDetail({id}).then(res => {
+          this.mainForm = {
+            pid: res.data.parentId,
+            name: res.data.name,
+            work: res.data.mainIds,
+            status: res.data.status,
+          }
+        })
+      }
+    },
+
+    // 取消 新增编辑 部门表单
+    cancelMainForm(){
+      this.mainFormVisible = false;
+      this.$refs.mainForm.resetFields();
+      this.mainForm.name = '';
+    },
+
+    // 提交 部门表单
+    submitMainForm() {
+      this.$refs.mainForm.validate((valid) => {
+        if (valid) {
+          let parentId = null;
+          if(this.mainForm.pid instanceof Array) {
+            parentId = this.mainForm.pid[this.mainForm.pid.length - 1];
+          }else {
+            parentId = this.mainForm.pid;
+          }
+          let params = {
+            parentId,
+            name: this.mainForm.name,
+            mainIds: this.mainForm.work,
+            status: this.mainForm.status,
+          }
+          if(this.mainFormType == 'edit') {
+            params.adminWebsitId = this.editId;
+            editDepartment(params).then(res => {
+              this.cancelMainForm();
+              this.getList();
+              this.$successMsg('编辑成功');
+            })
+          }else {
+            addDepartment(params).then(res => {
+              this.cancelMainForm();
+              this.getList();
+              this.$successMsg('添加成功');
+            })
+          }
+        }
+      })
+    },
+
+  }
+}
+</script>
+
+<style scoped lang="scss">
+  
+</style>

+ 19 - 6
src/views/setting/menu.vue

@@ -69,10 +69,18 @@
     <!-- 新增编辑 二级菜单 -->
     <el-dialog :title="addChildFormType == 'add' ? '添加二级菜单':'编辑二级菜单'" :visible.sync="addChildFormVisible" :show-close="false" width="40%" :close-on-click-modal="false">
       <el-form ref="addChildForm" :model="addChildForm" :rules="addChildFormRules" label-position="left" label-width="80px">
-        <el-form-item label="级菜单" prop="oneMenu">
-          <el-select v-model="addChildForm.oneMenu" placeholder="请选择一级菜单" style="width: 100%">
+        <el-form-item label="级菜单" prop="oneMenu">
+          <!-- <el-select v-model="addChildForm.oneMenu" placeholder="请选择一级菜单" style="width: 100%">
             <el-option :label="item.moduleName" :value="item.moduleId" v-for="(item, index) in dataList" :key="index"></el-option>
-          </el-select>
+          </el-select> -->
+          <el-cascader
+            style="width: 100%"
+            :options="dataList"
+            :props="{ checkStrictly: true, value: 'moduleId', label: 'moduleName' }"
+            v-model="addChildForm.oneMenu"
+            filterable
+            clearable>
+          </el-cascader>
         </el-form-item>
         <el-form-item label="二级菜单" prop="twoMenu">
           <el-input type="text" placeholder="请输入二级菜单名称" v-model="addChildForm.twoMenu" maxlength="10" show-word-limit></el-input>
@@ -612,9 +620,15 @@ export default {
       this.$refs.addChildForm.validate((valid) => {
         if (valid) {
           let params = {}
+          let parentId = null;
+          if(this.addChildForm.oneMenu instanceof Array) {
+            parentId = this.addChildForm.oneMenu[this.addChildForm.oneMenu.length - 1];
+          }else {
+            parentId = this.addChildForm.oneMenu;
+          }
           if(this.addChildFormType == 'edit') {
             params = {
-              parentId: this.addChildForm.oneMenu,
+              parentId,
               moduleId: this.editChildId,
               moduleName: this.addChildForm.twoMenu,
               code: this.addChildForm.code,
@@ -629,7 +643,7 @@ export default {
             })
           }else {
             params = {
-              parentId: this.addChildForm.oneMenu,
+              parentId,
               moduleName: this.addChildForm.twoMenu,
               code: this.addChildForm.code,
               url: this.addChildForm.url,
@@ -649,7 +663,6 @@ export default {
 
     // 操作 - 删除
     handleDelete(id) {
-      console.log(123123);
       deleteMenu({id: id}).then(res => {
         this.getList();
         this.$successMsg();