qinxianzhangyao
2023-10-19 ceb611ede1ca3988d731adffee433a1a7bcd442b
src/views/system/user/index.vue
@@ -78,7 +78,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" />
@@ -233,16 +233,21 @@
            <!-- <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-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-model="form.deptId" placeholder="请选择归属科室" clearable style="width: 200px" filterable>
              <el-option v-for="dict in DepartmentList" :key="dict.deptName" :label="dict.deptName"
                :value="dict.deptId" />
            </el-select>
          </el-form-item>
          <el-form-item label="入职日期" prop="entryDate">
@@ -261,8 +266,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" />
@@ -650,6 +655,23 @@
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 重置密码对话框 -->
    <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="dialogVisible1 = false">取 消</el-button>
        <el-button type="primary" @click="tijiao">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
@@ -663,7 +685,7 @@
  resetUserPwd,
  changeUserStatus,
  deptTreeSelect,
  getUserInfo,
  getDeptListByDictHospId,
} from "@/api/system/user";
import { getToken } from "@/utils/auth";
import { listHosp } from "@/api/hosp/hosp";
@@ -694,6 +716,10 @@
  components: { Treeselect },
  data() {
    return {
      row: [],
      flag: false,
      password: "",
      dialogVisible1: false,
      nums: "",
      userInfoList: [],
      hospList: [],
@@ -721,6 +747,7 @@
      dialogVisible: false,
      // 用户表格数据
      sysUserList: [],
      DepartmentList: [],
      // 岗位表格数据
      postList: [],
      // 角色表格数据
@@ -745,7 +772,7 @@
          brithday: "",
          nationDesc: "",
          entryDate: "",
          hospName: "",
          hospName: "",
        },
      },
      forms: {},
@@ -833,6 +860,17 @@
          },
        ],
      },
      rules1: {
        // password: [
        //   { required: true, message: "用户密码不能为空", trigger: "blur" },
        //   {
        //     min: 5,
        //     max: 20,
        //     message: "用户密码长度必须介于 5 和 20 之间",
        //     trigger: "blur",
        //   },
        // ],
      },
    };
  },
  watch: {
@@ -841,15 +879,21 @@
      this.$refs.tree.filter(val);
    },
  },
  computed: {
    type() {
      return this.flag ? "text" : "password";
    },
    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.getRoleList();
    // this.getConfigKey("sys.user.initPassword").then((response) => {
    //   this.initPassword = response.msg;
    // });
  },
  methods: {
    handleChange(val) { },
@@ -865,12 +909,6 @@
              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;
        }
@@ -892,11 +930,9 @@
    },
    /** 查询院区信息列表 */
    getlistHosp() {
      this.loading = true;
      listHosp(this.queryParams).then((response) => {
        this.hospList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
@@ -908,7 +944,6 @@
    getDeptTree() {
      deptTreeSelect().then((response) => {
        this.deptOptions = response.data;
        console.log(this.deptOptions);
      });
    },
    // 筛选节点
@@ -1010,12 +1045,23 @@
      this.reset();
      this.open = true;
      this.title = "用户信息维护";
      this.getPostList();
      this.getlistHosp();
      // getUser().then((response) => {
      //   this.postOptions = response.posts;
      //   this.roleOptions = response.roles;
      //   this.form.password = this.initPassword;
      // });
    },
    sendhospName() {
      let data = {
        id: this.form.hospId
      }
      getDeptListByDictHospId(data).then(res => {
        this.DepartmentList = res.data
      })
    },
    handleUp(row) {
@@ -1040,6 +1086,8 @@
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.getPostList();
      this.getlistHosp();
      this.reset();
      this.form = row;
      // this.form.userInfo.id = null;
@@ -1073,19 +1121,40 @@
    },
    /** 重置密码按钮操作 */
    handleResetPwd(row) {
      this.$prompt('请输入"' + row.userName + '"的新密码', "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        closeOnClickModal: false,
        inputPattern: /^.{5,20}$/,
        inputErrorMessage: "用户密码长度必须介于 5 和 20 之间",
      })
        .then(({ value }) => {
          resetUserPwd(row.userId, value).then((response) => {
            this.$modal.msgSuccess("修改成功,新密码是:" + value);
          });
      this.dialogVisible1 = true;
      this.row = row;
      // this.$prompt('请输入"' + row.userName + '"的新密码', "提示", {
      //   confirmButtonText: "确定",
      //   cancelButtonText: "取消",
      //   closeOnClickModal: false,
      //   inputPattern: /^.{5,20}$/,
      //   inputErrorMessage: "用户密码长度必须介于 5 和 20 之间",
      //   inputType:'password'
      // })
      //   .then(({ value }) => {
      //     resetUserPwd(row.userId, value).then((response) => {
      //       this.$modal.msgSuccess("修改成功");
      //       // ,新密码是:" + value
      //     });
      //   })
      //   .catch(() => { });
    },
    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;
          }
        })
        .catch(() => { });
      }else{
        this.$modal.msgError("用户名密码不能为空");
      }
    },
    /** 分配角色操作 */
    handleAuthRole: function (row) {