lkk
2024-11-27 e17811c1d7b1e6318af32a366d23bd586750b6d2
src/views/system/user/index.vue
@@ -9,7 +9,7 @@
        </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
            :filter-node-method="filterNode" ref="tree" node-key="id" default-expand-all  :default-expanded-keys="treeId" highlight-current
            @node-click="handleNodeClick" />
        </div>
      </el-col>
@@ -21,8 +21,9 @@
            <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">
@@ -192,6 +193,13 @@
          <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">
@@ -634,7 +642,7 @@
    </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>
@@ -654,7 +662,7 @@
        <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">
@@ -672,10 +680,12 @@
        <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,
@@ -688,6 +698,7 @@
  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";
@@ -713,8 +724,22 @@
    "dict_user_work",
    "dict_qhdm",
  ],
  components: { Treeselect },
  components: { Treeselect, yonghu },
  data() {
    let checkPhoneNum = (rule, value, callback) => {
         console.log( value)
      let patter = new RegExp(/^1\s*[3456789]\s*(\d\s*){9}$/);
      if (value == "" && value == undefined && !value) {
        console.log(11111)
        return callback('');
      }  else if(value != undefined && value != ""){
        console.log(22222)
        return callback();
      }else if (!patter.test(value)) {
        console.log(33333)
        return callback('');
      }
    };
    return {
      row: [],
      flag: false,
@@ -724,6 +749,7 @@
      userInfoList: [],
      hospList: [],
      activeNames: ["1"],
      treeId: [],
      // 遮罩层
      loading: true,
      // 选中数组
@@ -825,37 +851,37 @@
      // 表单校验
      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",
          },
        ],
@@ -876,8 +902,17 @@
  watch: {
    // 根据名称筛选部门树
    deptName(val) {
      this.$refs.tree.filter(val);
      console.log(val)
    },
    treeId(newVal, oldVal) {
      if (newVal) {
        this.$nextTick(() => {
          document
            .querySelector('.el-tree-node__children .el-tree-node__content')
            .click();
        });
      }
    }
  },
  computed: {
    type() {
@@ -888,8 +923,9 @@
    }
  },
  created() {
    this.getList();
    this.getDeptTree();
    this.getList();
    // this.getRoleList();
    // this.getConfigKey("sys.user.initPassword").then((response) => {
    //   this.initPassword = response.msg;
@@ -900,7 +936,8 @@
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
      if(this.queryParams.deptId){
        listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
        (response) => {
          response.rows.forEach((item, index) => {
            item.newID =
@@ -913,6 +950,8 @@
          this.loading = false;
        }
      );
      }
    },
    /** 查询岗位列表 */
    getPostList() {
@@ -932,6 +971,7 @@
    getlistHosp() {
      listHosp(this.queryParams).then((response) => {
        this.hospList = response.rows;
        this.total = response.total;
      });
    },
@@ -944,6 +984,10 @@
    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
        console.log(this.queryParams.deptId)
      });
    },
    // 筛选节点
@@ -955,6 +999,19 @@
    handleNodeClick(data) {
      this.queryParams.deptId = 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) {
@@ -1047,6 +1104,12 @@
      this.title = "用户信息维护";
      this.getPostList();
      this.getlistHosp();
      getInfo(this.queryParams).then((response) => {
        this.form.hospId = response.user.hospId;
        if (this.form.hospId) {
          this.sendhospName()
        }
      });
      // getUser().then((response) => {
      //   this.postOptions = response.posts;
      //   this.roleOptions = response.roles;
@@ -1068,6 +1131,7 @@
      this.title = "用户信息维护";
      this.open = true;
      this.form = row;
      this.form.hospId = Number(row.hospId)
      // listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
      //   (response) => {
      //     response.rows.forEach((item, index) => {
@@ -1090,6 +1154,9 @@
      this.getlistHosp();
      this.reset();
      this.form = row;
      if (this.form.hospId) {
        this.sendhospName()
      }
      // this.form.userInfo.id = null;
      // if(this.form.userInfo != null){
      //   this.forms = this.form.userInfo;
@@ -1151,7 +1218,7 @@
            this.dialogVisible1 = false;
          }
        })
      }else{
      } else {
        this.$modal.msgError("用户名密码不能为空");
      }