:qx
qx
6 天以前 a4965736d3f6e0293f16fafd044de08882958413
src/views/system/user/index.vue
@@ -2,27 +2,45 @@
  <div class="app-container">
    <el-row :gutter="20">
      <!--部门数据-->
      <el-col :span="3" :xs="24">
      <el-col :span="4" :xs="24">
        <div class="head-container">
          <el-input v-model="deptName" placeholder="请输入科室名称" clearable size="small" prefix-icon="el-icon-search"
            style="margin-bottom: 15px" />
        </div>
        <div class="head-container">
          <el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false"
            :filter-node-method="filterNode" ref="tree" node-key="id" default-expand-all highlight-current
            @node-click="handleNodeClick" />
        <!-- <div class="head-container">
          <el-tree
            :data="deptOptions"
            :props="defaultProps"
            :expand-on-click-node="false"
            :filter-node-method="filterNode"
            ref="tree"
            node-key="id"
            default-expand-all
            :default-expanded-keys="treeId"
            highlight-current
            @node-click="handleNodeClick"
          />
        </div> -->
        <div class="scrollable-container">
          <div class="content">
            <el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false"
              :filter-node-method="filterNode" ref="tree" node-key="id" :default-expanded-keys="treeId"
              highlight-current @node-click="handleNodeClick" />
          </div>
        </div>
      </el-col>
      <!--用户数据-->
      <el-col :span="20" :xs="24">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="72px">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
          label-width="72px">
          <el-form-item label="用户名称" prop="nickName">
            <el-input v-model="queryParams.nickName" placeholder="请输入用户名称" clearable style="width: 180px"
              @keyup.enter.native="handleQuery" />
          </el-form-item>
          <el-form-item label="手机号码" prop="phonenumber">
            <el-input v-model="queryParams.phonenumber" placeholder="请输入手机号码" clearable style="width: 180px"
          <el-form-item label="用户工号" prop="userName">
            <el-input v-model="queryParams.userName" placeholder="请输入用户工号" clearable style="width: 180px"
              @keyup.enter.native="handleQuery" />
          </el-form-item>
          <el-form-item label="状态" prop="status">
@@ -78,7 +96,7 @@
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
        </el-row>
        <el-table v-loading="loading" :data="userList" border @selection-change="handleSelectionChange"
        <el-table :data="userList" border @selection-change="handleSelectionChange" v-loading="loading"
          highlight-current-row>
          <el-table-column type="selection" width="50" align="center" fixed="left" />
          <el-table-column label="序号" align="center" key="newID" prop="newID" width="50px" fixed="left" />
@@ -105,7 +123,6 @@
            :show-overflow-tooltip="true" />
          <el-table-column label="医保编码" align="center" key="medicalId" prop="medicalId" width="90px"
            :show-overflow-tooltip="true" />
          <el-table-column label="创建人" align="center" key="createBy" prop="createBy" width="80px" />
          <el-table-column label="修改人" align="center" key="updateBy" prop="updateBy" width="80px" />
@@ -134,10 +151,10 @@
          <el-table-column label="操作" fixed="right" align="center" width="100px" class-name="small-padding fixed-width">
            <template slot-scope="scope" v-if="scope.row.userId !== 1">
              <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
                v-hasPermi="['system:user:edit']" title="修改"></el-button>
                v-hasPermi="['system:user:edit']" title="修改" close-on-click-modal="false"></el-button>
              <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
                v-hasPermi="['system:user:remove']" title="删除"></el-button>
                v-hasPermi="['system:user:remove']" title="删除" close-on-click-modal="false"></el-button>
              <!-- 添加用户详情按钮 点击跳出该用户的详细信息页面
              <el-button
@@ -152,20 +169,11 @@
              <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)"
                v-hasPermi="['system:user:resetPwd', 'system:user:edit']">
                <el-button size="mini" type="text" icon="el-icon-d-arrow-right" title="更多"></el-button>
                <el-dropdown-menu slot="dropdown">
                <el-dropdown-menu slot="dropdown" :append-to-body="true">
                  <el-dropdown-item command="handleResetPwd" icon="el-icon-key"
                    v-hasPermi="['system:user:resetPwd']">重置密码</el-dropdown-item>
                  <el-dropdown-item command="handleAuthRole" icon="el-icon-circle-check"
                    v-hasPermi="['system:user:edit']">分配角色</el-dropdown-item>
                  <!-- 添加用户详情按钮 点击跳出该用户的详细信息页面 -->
                  <!-- <el-button
                    size="mini"
                    type="text"
                    icon="el-icon-share"
                    @click="handleSearch(scope.row)"
                    v-hasPermi="['hosp:Userinfo:list']"
                    >详细信息</el-button
                  > -->
                </el-dropdown-menu>
              </el-dropdown>
            </template>
@@ -192,6 +200,9 @@
          <el-input v-model="form.userId" placeholder="请输入用户id" />
        </el-form-item> -->
          <el-form-item label="用户名称" prop="nickName">
            <span slot="label" style="display: inline-block; border-bottom: 2px solid blue" @click="handlePackage">
              用户名称
            </span>
            <el-input v-model="form.nickName" placeholder="请输入用户昵称" maxlength="30" style="width: 130px" />
          </el-form-item>
          <el-form-item label="用户工号" prop="userName">
@@ -233,16 +244,22 @@
            <!-- <el-input v-model="form.nationDesc" placeholder="请输入民族描述"/> -->
          </el-form-item>
          <el-form-item label="所在院区" prop="hospName">
            <el-select v-model="form.hospName" placeholder="请选择所在院区" clearable style="width: 200px" filterable>
          <el-form-item label="所在医院" prop="hospId">
            <el-select v-if="hospList.length > 0" v-model="form.hospId" placeholder="请选择所在医院" clearable
              style="width: 200px" filterable @change="sendhospName">
              <el-option v-for="dict in hospList" :key="dict.hospAreaName" :label="dict.hospAreaName"
                :value="dict.hospAreaId" />
            </el-select>
            <!-- <el-input v-model="form.hospName" placeholder="请输入组织中文名称" /> -->
          </el-form-item>
          <el-form-item label="归属科室" prop="deptId">
            <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属科室"
              style="width: 200px" />
            <!-- <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属科室"
              style="width: 200px" /> -->
            <el-select v-if="DepartmentList.length > 0" v-model="form.deptId" placeholder="请选择归属科室" clearable
              style="width: 200px" filterable>
              <el-option v-for="dict in DepartmentList" :key="dict.deptId" :label="dict.deptName"
                :value="dict.deptId" />
            </el-select>
          </el-form-item>
          <el-form-item label="入职日期" prop="entryDate">
@@ -261,8 +278,8 @@
            <el-input v-model="form.medicalId" placeholder="请输入医保编码" style="width: 200px" />
          </el-form-item>
          <el-form-item label="优惠折扣">
            <el-input-number ref="inputNumber" style="width: 200px" v-model="form.discount" :precision="2"
              :step="0.1" :max="10" :min="1" @change="numberChange"></el-input-number>
            <el-input-number ref="inputNumber" style="width: 200px" v-model="form.discount" :precision="2" :step="0.1"
              :max="10" :min="1" @change="numberChange"></el-input-number>
          </el-form-item>
          <el-form-item label="现住址" prop="liveAddr">
            <el-input v-model="form.userInfo.liveAddr" placeholder="请输入现居住地址" style="width: 440px" />
@@ -537,7 +554,8 @@
                <el-input v-model="form.phaCertifiedNo" placeholder="请输入专家-资格证号" style="width: 200px" />
              </el-form-item>
              <el-form-item label="职称级别" prop="expJobLevelCode">
                <el-select v-model="form.expJobLevelCode" placeholder="请选择职称级别" style="width: 200px" filterable clearable>
                <el-select v-model="form.expJobLevelCode" placeholder="请选择职称级别" style="width: 200px" filterable
                  clearable>
                  <el-option v-for="dict in dict.type.dict_user_zcjb" :key="dict.value" :label="dict.label"
                    :value="dict.value"></el-option>
                </el-select>
@@ -572,7 +590,8 @@
              />
            </el-form-item> -->
              <el-form-item label="政治面貌" prop="politicalStatus">
                <el-select v-model="form.politicalStatus" placeholder="请选择政治面貌" style="width: 200px" filterable clearable>
                <el-select v-model="form.politicalStatus" placeholder="请选择政治面貌" style="width: 200px" filterable
                  clearable>
                  <el-option v-for="dict in dict.type.dict_political" :key="dict.value" :label="dict.label"
                    :value="dict.value"></el-option>
                </el-select>
@@ -622,14 +641,14 @@
          </el-collapse>
        </el-form>
        <div slot="footer" class="dialog-footer1">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button :disabled="submit" type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </el-dialog>
    </div>
    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
    <!-- <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
@@ -649,32 +668,30 @@
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
    </el-dialog> -->
    <!-- 重置密码对话框 -->
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible1"
      width="30%"
      :before-close="handleClose">
      <el-form>
        <span>请输入“{{row.userName}}”的新密码</span>
        <el-form-item>
    <el-dialog title="提示" :visible.sync="dialogVisible1" width="30%" :before-close="handleClose">
      <el-form :rules="rules1">
        <span>请输入“{{ row.userName }}”的新密码</span>
        <el-form-item prop="password">
          <el-input v-model="password" :type="type" auto-complete="off" placeholder="密码" ref="barcodeMsg">
            <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
            <i slot="suffix" class="icon-style" :class="elIcon" autocomplete="auto" @click="flag = !flag" /></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button @click="dialogVisible1 = false">取 消</el-button>
        <el-button type="primary" @click="tijiao">确 定</el-button>
      </span>
    </el-dialog>
    <yonghu ref="aaa" @add="handleChanges" />
  </div>
</template>
<script>
import yonghu from "@/components/yonghu";
import {
  listUser,
  getUser,
@@ -684,9 +701,10 @@
  resetUserPwd,
  changeUserStatus,
  deptTreeSelect,
  getUserInfo,
  getDeptListByDictHospId,
} from "@/api/system/user";
import { getToken } from "@/utils/auth";
import { getInfo } from "@/api/login";
import { listHosp } from "@/api/hosp/hosp";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
@@ -712,17 +730,30 @@
    "dict_user_work",
    "dict_qhdm",
  ],
  components: { Treeselect },
  components: { Treeselect, yonghu },
  data() {
    let checkPhoneNum = (rule, value, callback) => {
      let patter = new RegExp(/^1\s*[3456789]\s*(\d\s*){9}$/);
      if (value == "" && value == undefined && !value) {
        return callback("");
      } else if (value != undefined && value != "") {
        return callback();
      } else if (!patter.test(value)) {
        return callback("");
      }
    };
    return {
      row:[],
      row: [],
      flag: false,
      password:"",
      dialogVisible1:false,
      submit: false,
      password: "",
      dialogVisible1: false,
      nums: "",
      userInfoList: [],
      hospList: [],
      activeNames: ["1"],
      treeId: [],
      selectedDeptId: null,
      // 遮罩层
      loading: true,
      // 选中数组
@@ -746,6 +777,7 @@
      dialogVisible: false,
      // 用户表格数据
      sysUserList: [],
      DepartmentList: [],
      // 岗位表格数据
      postList: [],
      // 角色表格数据
@@ -770,7 +802,7 @@
          brithday: "",
          nationDesc: "",
          entryDate: "",
          hospName: "",
          hospName: "",
        },
      },
      forms: {},
@@ -823,40 +855,51 @@
      // 表单校验
      rules: {
        userName: [
          { required: true, message: "用户名称不能为空", trigger: "blur" },
          { required: true, validator: checkPhoneNum, trigger: "blur" },
          {
            min: 2,
            max: 20,
            message: "用户名称长度必须介于 2 和 20 之间",
            validator: checkPhoneNum,
            trigger: "blur",
          },
        ],
        nickName: [
          { required: true, message: "用户昵称不能为空", trigger: "blur" },
          { required: true, validator: checkPhoneNum, trigger: "blur" },
        ],
        password: [
          { required: true, message: "用户密码不能为空", trigger: "blur" },
          { required: true, validator: checkPhoneNum, trigger: "blur" },
          {
            min: 5,
            max: 20,
            message: "用户密码长度必须介于 5 和 20 之间",
            validator: checkPhoneNum,
            trigger: "blur",
          },
        ],
        email: [
          {
            type: "email",
            message: "请输入正确的邮箱地址",
            validator: checkPhoneNum,
            trigger: ["blur", "change"],
          },
        ],
        phonenumber: [
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "请输入正确的手机号码",
            validator: checkPhoneNum,
            trigger: "blur",
          },
        ],
      },
      rules1: {
        // password: [
        //   { required: true, message: "用户密码不能为空", trigger: "blur" },
        //   {
        //     min: 5,
        //     max: 20,
        //     message: "用户密码长度必须介于 5 和 20 之间",
        //     trigger: "blur",
        //   },
        // ],
      },
    };
  },
@@ -865,6 +908,15 @@
    deptName(val) {
      this.$refs.tree.filter(val);
    },
    treeId(newVal, oldVal) {
      if (newVal) {
        this.$nextTick(() => {
          document
            .querySelector(".el-tree-node__children .el-tree-node__content")
            .click();
        });
      }
    },
  },
  computed: {
    type() {
@@ -872,42 +924,41 @@
    },
    elIcon() {
      return this.flag ? "el-icon-minus" : "el-icon-view";
    }
    },
  },
  created() {
    this.getList();
    this.getDeptTree();
    this.getlistHosp();
    this.getPostList();
    this.getRoleList();
    this.getConfigKey("sys.user.initPassword").then((response) => {
      this.initPassword = response.msg;
    });
    this.getList();
    if (this.form.hospId) {
      this.sendhospName(); // 页面加载时自动加载科室数据
    }
    // this.getRoleList();
    // this.getConfigKey("sys.user.initPassword").then((response) => {
    //   this.initPassword = response.msg;
    // });
  },
  methods: {
    handleChange(val) { },
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
        (response) => {
          response.rows.forEach((item, index) => {
            item.newID =
              (this.queryParams.pageNum - 1) * this.queryParams.pageSize +
              index +
              1;
          });
          this.userList = response.rows;
          // for(let key in this.userList){
          //   for(let i = 0; i < this.userList[key].length; i++){
          //     this.userList[key][i]["form"] = key;
          //     this.userInfoList.push(this.userList[key][i])
          //   }
          // }
          this.total = response.total;
          this.loading = false;
        }
      );
      if (this.queryParams.deptId) {
        listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
          (response) => {
            response.rows.forEach((item, index) => {
              item.newID =
                (this.queryParams.pageNum - 1) * this.queryParams.pageSize +
                index +
                1;
            });
            this.userList = response.rows;
            this.total = response.total;
            this.loading = false;
          }
        );
      }
    },
    /** 查询岗位列表 */
    getPostList() {
@@ -925,11 +976,10 @@
    },
    /** 查询院区信息列表 */
    getlistHosp() {
      this.loading = true;
      listHosp(this.queryParams).then((response) => {
        this.hospList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
@@ -941,7 +991,8 @@
    getDeptTree() {
      deptTreeSelect().then((response) => {
        this.deptOptions = response.data;
        console.log(this.deptOptions);
        this.treeId.push(this.deptOptions[0].id);
        this.queryParams.deptId = this.deptOptions[0].id;
      });
    },
    // 筛选节点
@@ -952,7 +1003,21 @@
    // 节点单击事件
    handleNodeClick(data) {
      this.queryParams.deptId = data.id;
      this.selectedDeptId = data.id;
      this.handleQuery();
    },
    handlePackage() {
      this.$refs.aaa.open = true;
      this.$refs.aaa.getList();
      this.$refs.aaa.title = "数据字典";
    },
    handleChanges(param1) {
      this.form.nickName = param1[0].staffName;
      // this.form.hisPacId = param1[0].pacId;
      // if (param1[0].price) {
      //   this.form.counterPrice = param1[0].price;
      //   this.form.retailPrice = param1[0].price;
      // }
    },
    // 用户状态修改
    handleStatusChange(row) {
@@ -973,10 +1038,11 @@
    cancel() {
      this.open = false;
      this.reset();
      this.$tab.refreshPage();
      // this.$tab.refreshPage();
    },
    handleClose() {
      this.$tab.refreshPage();
      this.cancel();
      // this.$tab.refreshPage();
    },
    // 表单重置
    reset() {
@@ -1024,7 +1090,11 @@
      this.ids = selection.map((item) => item.userId);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
      if (selection.length >= 1) {
        this.queryParams.userName = selection[0].userName
      }
    },
    // 更多操作触发
    handleCommand(command, row) {
      switch (command) {
@@ -1043,6 +1113,17 @@
      this.reset();
      this.open = true;
      this.title = "用户信息维护";
      this.getPostList();
      this.getlistHosp();
      getInfo(this.queryParams).then((response) => {
        this.form.hospId = response.user.hospId;
        if (this.form.hospId) {
          this.sendhospName();
        }
      });
      if (this.selectedDeptId) {
        this.form.deptId = this.selectedDeptId;
      }
      // getUser().then((response) => {
      //   this.postOptions = response.posts;
      //   this.roleOptions = response.roles;
@@ -1051,17 +1132,30 @@
      // });
    },
    sendhospName() {
      let data = {
        id: this.form.hospId,
      };
      getDeptListByDictHospId(data).then((res) => {
        this.DepartmentList = res.data;
        // this.form.deptId = String(this.form.deptId);
      });
    },
    handleUp(row) {
      this.title = "用户信息维护";
      // this.form = row;
      this.open = true;
      this.form = row;
      // listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
      //   (response) => {
      //     response.rows.forEach((item, index) => {
      //       this.form = item;
      //     });
      //   }
      // );
      this.submit = false
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
        (response) => {
          response.rows.forEach((item, index) => {
            this.form = item;
          });
        }
      );
    },
    select(val) {
      this.postList.forEach((item) => {
@@ -1073,13 +1167,23 @@
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.getPostList();
      this.getlistHosp();
      this.reset();
      this.form = row;
      this.form = {
        ...row,
        deptId: row.deptId != null ? String(row.deptId) : null, // 👈 确保为字符串
      };
      if (this.form.hospId) {
        this.sendhospName();
      }
      // this.form.userInfo.id = null;
      // if(this.form.userInfo != null){
      //   this.forms = this.form.userInfo;
      // }
      this.open = true;
      this.submit = false
      this.title = "用户信息维护";
    },
@@ -1089,9 +1193,11 @@
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (_this.form.userId !== undefined) {
            _this.submit = true
            updateUser(_this.form).then((response) => {
              _this.$modal.msgSuccess("修改成功");
              _this.open = false;
              _this.submit = false
              _this.getList();
            });
          } else {
@@ -1106,7 +1212,6 @@
    },
    /** 重置密码按钮操作 */
    handleResetPwd(row) {
      console.log(row);
      this.dialogVisible1 = true;
      this.row = row;
      // this.$prompt('请输入"' + row.userName + '"的新密码', "提示", {
@@ -1125,18 +1230,21 @@
      //   })
      //   .catch(() => { });
    },
    tijiao(){
      let data = {
        password:this.password,
        userId:this.row.userId,
    tijiao() {
      if (this.password) {
        let data = {
          password: this.password,
          userId: this.row.userId,
        };
        resetUserPwd(data).then((res) => {
          if (res.code == 200) {
            this.$modal.msgSuccess("修改成功");
            this.dialogVisible1 = false;
          }
        });
      } else {
        this.$modal.msgError("用户名密码不能为空");
      }
      resetUserPwd(data).then(res=>{
        console.log(res);
        if(res.code == 200){
          this.$modal.msgSuccess("修改成功");
          this.dialogVisible1 = false;
        }
      })
    },
    /** 分配角色操作 */
    handleAuthRole: function (row) {
@@ -1225,6 +1333,26 @@
  width: 200px;
}
.scrollable-container {
  width: 200px;
  /* 设置容器的宽度 */
  height: 629px;
  /* 设置容器的高度 */
  overflow: auto;
  /* 允许内容溢出时显示滚动条 */
  border: 1px solid #ccc;
  /* 可选:添加边框以更好地显示容器 */
  position: relative;
  /* 可选:使容器内的绝对定位元素能够正确显示 */
}
.content {
  width: 600px;
  /* 设置内容的宽度,以触发水平滚动条 */
  height: 1000px;
  /* 设置内容的高度,以触发垂直滚动条 */
}
.pag {
  width: 100%;
  display: flex;