石广澎
2024-01-02 0cd1631ceaa93e6483908fd692d2cb693b85324b
admin-web/src/views/systemManger/server/user/index.vue
@@ -18,14 +18,14 @@
          <el-row style="margin-top: 15px">
            <el-col>
              <!--列表-->
              <my-table-v2 ref="myTable" :filter="filterFrom" :table="table" />
              <my-table-v2 ref="myTable" :filter="filterFrom" :table="table"/>
            </el-col>
          </el-row>
        </el-card>
      </el-col>
    </el-row>
    <!--添加/编辑弹窗-->
    <edit v-if="editSetting.show" :setting="editSetting" @close="editSetting.show = false" @search="search" />
    <edit v-if="editSetting.show" :setting="editSetting" @close="editSetting.show = false" @search="search"/>
    <editRole
      v-if="editRoleSetting.show"
      :setting="editRoleSetting"
@@ -45,6 +45,7 @@
import editRole from './editRole';
import * as finsystenant from '@/api/baseSetting/finsystenant';
import * as user from '@/api/user';
import {LongToDateTime} from "@/utils/DateFormatter";
export default {
  name: 'index',
@@ -57,7 +58,7 @@
      treeDataList: [],
      // 搜索条件
      filterFrom: {
        tenantCode: 0,
        tenantCode: null,
        userName: null,
        userCode: null,
      },
@@ -66,6 +67,7 @@
      tenantId: null, //区划id
      tenantCode: null, //区划code
      tenantName: null, //区划名称
      data_scope: 0, //角色范围
      editSetting: {
        title: '',
        id: '',
@@ -75,6 +77,7 @@
      // 编辑角色配置
      editRoleSetting: {
        title: '',
        data_scope: 0,
        id: '',
        show: false,
      },
@@ -105,10 +108,10 @@
        },
        // 列信息
        columns: [
          { title: '编号', field: 'userCode', align: 'left' },
          { title: '用户姓名', field: 'userName', align: 'left' },
          { title: '登录名', field: 'userPhone', align: 'center' },
          { title: '所属机构', field: 'tenantName', align: 'center', width: 150 },
          {title: '人员姓名', field: 'userName', align: 'left', minWidth: 140},
          {title: '登录名', field: 'userCode', align: 'left', minWidth: 140},
          {title: '手机号', field: 'userPhone', align: 'center', width: 110},
          { title: '所属机构', field: 'tenantName', align: 'center', minWidth: 150 },
          { title: '部门', field: 'sysDeptName', align: 'center' },
          {
            field: 'status',
@@ -145,15 +148,15 @@
          width: '250', // 列宽
          attr: [
            {
              title: '编辑',
              events: (row) => {
                this.showAdd(row.id);
              },
            },
            {
              title: '角色',
              events: (row) => {
                this.showEditRole(row.id);
              },
            },
            {
              title: '编辑',
              events: (row) => {
                this.showAdd(row.id);
              },
            },
            {
@@ -180,8 +183,27 @@
  created() {
    // 获取机构树
    this.initTreeData();
    this.data_scope = this.$store.getters.userInfo ? this.$store.getters.userInfo.lv : ''
    if(this.data_scope===0){
      this.data_scope=1
    }
    this.editSetting.data_scope = this.data_scope;
    this.editRoleSetting.data_scope = this.data_scope;
  },
  methods: {
    //导入
    importUser() {
      this.importSetting.dialogShow = true
      this.importSetting.onSuccess = (response, callBack) => {
        if (response.code === 1) {
          this.$message.success(response.msg)
          this.search(1)
        } else {
          this.$message.warning(response.msg)
        }
        callBack()
      }
    },
    // 左侧树初始化
    initTreeData() {
      finsystenant.getTree().then((res) => {
@@ -198,11 +220,11 @@
    updState(row) {
      let vm = this
      let text = row.status === 0 ? "启用" : "禁用";
      vm.$modal.confirm('确认要' + text + '"' + row.userName + '"吗?').then(function() {
        let params = Object.assign({},row)
      vm.$modal.confirm('确认要' + text + '"' + row.userName + '"吗?').then(function () {
        let params = Object.assign({}, row)
        params.status = row.status === 1 ? 0 : 1
        user.updateStatus(params).then(res=>{
          if(res){
        user.updateStatus(params).then(res => {
          if (res) {
            row.status = row.status === 1 ? 0 : 1
            vm.$modal.msgSuccess(text + "成功");
          }
@@ -217,13 +239,17 @@
          id: param.id,
          name: param.name,
          code: param.code,
          lv: param.lv,
        },
      );
      let data_scope = Number(this.data_scope) + (param.lv-1)
      if (this.p.code != undefined && this.p.code != null) {
        this.filterFrom.tenantCode = this.p.code;
        this.tenantId = this.p.id;
        this.tenantName = this.p.name;
        this.editSetting.tenantCode = this.p.code;
        this.editSetting.data_scope = data_scope;
        this.editRoleSetting.data_scope = data_scope;
      } else {
        this.filterFrom.tenantCode = 0;
      }
@@ -278,6 +304,22 @@
      this.editSetting.title = title;
      this.editSetting.show = true;
    },
    // 删除用户账号
    del(row) {
      row.isDelete = 0;
      this.$modal
        .confirm('是否要删除"' + row.userName + '"的账号?')
        .then(function () {
          user.updateStatus(row).then((res) => {
          });
        })
        .then((res) => {
          this.$message.success('删除成功!');
          this.search();
        })
        .catch(() => {
        });
    },
    showEditRole(id) {
      let title = '添加';
      if (id != null) {