yxh
2026-09-30 d21d7dd23f15a0ca395a4c9d1b3bb31330ff56c0
src/views/project/externalperson/index.vue
@@ -1,6 +1,12 @@
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="80px">
      <el-form-item label="账号类别" prop="usertype">
        <el-select v-model="queryParams.usertype" placeholder="请选择账号类别" clearable size="small">
          <el-option v-for="dict in dict.type.sys_UserType" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="账号编号" prop="userno">
        <el-input v-model="queryParams.userno" placeholder="请输入账号编号" clearable size="small"
          @keyup.enter.native="handleQuery" />
@@ -9,10 +15,9 @@
        <el-input v-model="queryParams.username" placeholder="请输入账号名称" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="账号类别" prop="usertype">
        <el-select v-model="queryParams.usertype" placeholder="请选择账号类别" clearable size="small">
          <el-option v-for="dict in dict.type.sys_UserType" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      <el-form-item label="所在单位" prop="unitname">
        <el-input v-model="queryParams.unitname" placeholder="请输入所在单位" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
@@ -34,17 +39,18 @@
          v-hasPermi="['project:externalperson:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" :loading="exportLoading" @click="handleExport"
          v-hasPermi="['project:externalperson:export']">导出</el-button>
        <el-button type="warning" plain icon="el-icon-download" size="mini" :loading="exportLoading"
          @click="handleExport" v-hasPermi="['project:externalperson:export']">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="externalpersonList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="账号类别" align="center" prop="usertype">
      <el-table-column label="账号类别" align="center" prop="usertype" width="220">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_UserType" :value="scope.row.usertype" />
          <dict-tag v-for="t in splitUserType(scope.row.usertype)" :key="t"
            :options="dict.type.sys_UserType" :value="t" />
        </template>
      </el-table-column>
      <el-table-column label="账号编号" align="center" prop="userno" />
@@ -53,7 +59,7 @@
      <el-table-column label="职称" align="center" prop="title">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_professionaltitle" :value="scope.row.title" /> </template></el-table-column>
      <el-table-column label="单位名称" width="250" align="center" prop="unitname" />
      <el-table-column label="所在单位" width="250" align="center" prop="unitname" />
      <!--
      <el-table-column label="性别" align="center" prop="sex">
        <template slot-scope="scope">
@@ -72,8 +78,7 @@
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['project:externalperson:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['project:externalperson:remove']">删除</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
@@ -81,42 +86,47 @@
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
    <!-- 添加或修改外围单位人员对话框 -->
    <!-- 添加或修改人员/单位账号信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body :close-on-click-modal="false">
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-row>
          <el-col :span="12"><el-form-item label="账号类别" prop="usertype">
              <el-select v-model="form.usertype" placeholder="请选择账号类别">
              <el-select v-model="form.usertype" multiple collapse-tags placeholder="请选择账号类别(可多选)">
                <el-option v-for="dict in dict.type.sys_UserType" :key="dict.value" :label="dict.label"
                  :value="dict.value"></el-option>
              </el-select> </el-form-item>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="账号编号" prop="userno">
              <el-input v-model="form.userno" placeholder="请输入账号编号" /> </el-form-item>
              <el-input disabled="true" v-model="form.userno" placeholder="请输入账号编号" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="账号名称" prop="username">
              <el-input v-model="form.username" placeholder="请输入账号名称" /> </el-form-item>
              <el-input v-model="form.username" placeholder="请输入账号名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="启用状态" prop="userstatus">
              <el-radio-group v-model="form.userstatus" :disabled="ismanager==false">
                <el-radio v-for="dict in dict.type.sys_0_1" :key="dict.value" :label="parseInt(dict.value)">{{ dict.label
            <el-form-item label="启用状态" prop="userstatus" >
              <el-radio-group v-model="form.userstatus" :disabled="!ismanager">
                <el-radio v-for="dict in dict.type.sys_0_1" :key="dict.value" :label="parseInt(dict.value)">{{
                  dict.label
                }}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="form.usertype != 'org'">
        <el-row v-if="!isUnitForm">
          <el-col :span="24">
            <el-form-item label="身份证号" prop="idcardno">
              <el-input v-model="form.idcardno" placeholder="请输入身份证号" /> </el-form-item>
              <el-input v-model="form.idcardno" placeholder="请输入身份证号" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="form.usertype != 'org'"><el-col :span="12">
        <el-row v-if="!isUnitForm"><el-col :span="12">
            <el-form-item label="性别" prop="sex">
              <el-select v-model="form.sex" placeholder="请选择性别">
                <el-option v-for="dict in dict.type.sys_user_sex" :key="dict.value" :label="dict.label"
@@ -126,14 +136,19 @@
            <el-form-item label="职称" prop="title">
              <el-select v-model="form.title" placeholder="请选择人员职称">
                <el-option v-for="dict in dict.type.sys_professionaltitle" :key="dict.value" :label="dict.label"
                  :value="dict.value"></el-option> </el-select>
                  :value="dict.label"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="form.usertype != 'org'">
        <el-row v-if="!isUnitForm">
          <el-col :span="12">
            <el-form-item label="所在单位" prop="unitname">
              <el-input v-model="form.unitname" placeholder="请输入单位名称" /> </el-form-item>
              <el-select v-model="form.unitno" placeholder="所在单位" clearable filterable allow-create style="width: 100%">
                <el-option v-for="(spec, index) in unitList" :key="index" :label="spec.organizationname"
                  :value="spec.organizationid"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单位工号" prop="personnelunitno">
@@ -143,7 +158,8 @@
        </el-row>
        <el-row>
          <el-col :span="24"><el-form-item label="开户银行" prop="depositbank">
              <el-input v-model="form.depositbank" placeholder="请输入开户银行名称" /> </el-form-item>
              <el-input v-model="form.depositbank" placeholder="请输入开户银行名称" />
            </el-form-item>
          </el-col>
          <el-col :span="24"><el-form-item label="银行卡号" prop="bankcardno">
              <el-input v-model="form.bankcardno" placeholder="请输入银行卡号" />
@@ -153,13 +169,15 @@
        <el-row>
          <el-col :span="24">
            <el-form-item label="联系地址" prop="address">
              <el-input v-model="form.address" placeholder="请输入联系地址" /> </el-form-item>
              <el-input v-model="form.address" placeholder="请输入联系地址" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="联系电话" prop="telephone">
              <el-input v-model="form.telephone" placeholder="请输入联系电话" /> </el-form-item>
              <el-input v-model="form.telephone" placeholder="请输入联系电话" />
            </el-form-item>
          </el-col>
        </el-row>
        <!--
@@ -186,7 +204,17 @@
  addExternalperson,
  updateExternalperson,
  exportExternalperson,
  getInfoByIDCardNo,
  getOnlyCode
} from "@/api/project/externalperson";
import {
  listOrganization,
  getOrganization,
  listReportname,
  listUser
} from "@/api/project/organization";
import { getUserProfile } from "@/api/system/user";
export default {
@@ -195,7 +223,7 @@
  data() {
    return {
      // 遮罩层
      loading: true,
      loading: false,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
@@ -210,6 +238,9 @@
      total: 0,
      // 外围单位人员表格数据
      externalpersonList: [],
      //医疗机构列表
      unitList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
@@ -220,43 +251,113 @@
        pageSize: 10,
        userno: null,
        username: null,
        usertype: null,
        usertype: null
      },
      //是否是专家费的OPO审批人员
      ismanager: false,
      // 查询最新序号参数
      seqnoParams: {
        businessType: "externalperson",
        datequery: false
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      //是否是专家费的OPO审批人员
      ismanager: false,
      rules: {
        usertype: [
          { required: true, message: "请输入账户类型", trigger: "blur" }
        ],
        username: [
          { required: true, message: "请输入账户名称", trigger: "blur" }
        ],
        idcardno: [
          {
            //账号类别为"单位机构"时无需身份证号
            validator: (rule, value, callback) => {
              if (this.hasUserType(this.form.usertype, "org")) {
                return callback();
              }
              if (!value || !String(value).trim()) {
                return callback(new Error("请输入身份证号码"));
              }
              return callback();
            },
            trigger: "blur"
          }
        ],
        bankcardno: [
          { required: true, message: "请输入银行账号", trigger: "blur" }
        ],
        depositbank: [
          { required: true, message: "请输入开户银行", trigger: "blur" }
        ]
      },
    };
  },
  computed: {
    /** 表单是否选择了"单位机构"(账号类别为多值,含 org 即为单位) */
    isUnitForm() {
      return this.hasUserType(this.form.usertype, "org");
    }
  },
  created() {
    this.getUserProfile();
    this.getList();
    this.getUnitList();
    // 默认不打开
    // this.getList();
  },
  methods: {
    //获取当前用户信息
    getUserProfile() {
      getUserProfile().then(res => {
        if (
          res.data.userName == "admin" ||
          res.data.userName == "001" ||
          res.data.userName == "047"
        ) {
          this.ismanager = true;
        } else {
          this.ismanager = false;
        }
      getUserProfile().then(res => {
        const managerList = ["admin", "048", "047"];
        this.ismanager = managerList.includes(res.data.userName);
      });
    },
    /** 查询外围单位人员列表 */
    /** 人员类型(多值,逗号分隔)转数组 */
    splitUserType(usertype) {
      if (!usertype) {
        return [];
      }
      if (Array.isArray(usertype)) {
        return usertype;
      }
      return String(usertype)
        .split(",")
        .map(t => t.trim())
        .filter(t => t);
    },
    /** 人员类型数组转逗号分隔字符串 */
    joinUserType(usertype) {
      return Array.isArray(usertype) ? usertype.join(",") : usertype;
    },
    /** 人员类型是否包含指定类型(如 org = 单位机构) */
    hasUserType(usertype, code) {
      return this.splitUserType(usertype).indexOf(code) > -1;
    },
    /** 查询单位、人员账号列表 */
    getList() {
      this.loading = true;
      listExternalperson(this.queryParams).then((response) => {
      /*
      if (
        this.queryParams.username === null ||
        this.queryParams.username.replace(/\s/g, "") == ""
      ) {
        this.$modal.msgWarning(
          "查找账户时,账户名称不能为空,请输入账户名称!"
        );
        return;
      }
      */
      // this.loading = true;
      listExternalperson(this.queryParams).then(response => {
        this.externalpersonList = response.rows;
        this.total = response.total;
        this.loading = false;
        // this.loading = false;
      });
    },
    // 取消按钮
@@ -271,7 +372,7 @@
        userno: null,
        username: null,
        userstatus: 0,
        usertype: null,
        usertype: [],
        personnelunitno: null,
        delFlag: null,
        createBy: null,
@@ -279,12 +380,24 @@
        updateBy: null,
        updateTime: null,
        pym: null,
        wbm: null,
        wbm: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      /*
      if (
        this.queryParams.username === null ||
        this.queryParams.username.replace(/\s/g, "") == ""
      ) {
        this.$modal.msgWarning(
          "为限制批量查找账户信息,限制账户名称为必输项,请输入账户名称后再搜索!"
        );
        return;
      }
      */
      this.queryParams.pageNum = 1;
      this.getList();
    },
@@ -295,7 +408,7 @@
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.ids = selection.map(item => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
@@ -303,34 +416,67 @@
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加外围单位人员";
      this.title = "添加人员/单位账号信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getExternalperson(id).then((response) => {
      getExternalperson(id).then(response => {
        this.form = response.data;
        //账号类别为多值(逗号分隔),表单用数组回显
        this.form.usertype = this.splitUserType(response.data.usertype);
        this.open = true;
        this.title = "人员信息修改";
        this.title = "人员/单位账号信息修改";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
      this.$refs["form"].validate(valid => {
        if (valid) {
          console.log("unitList", this.unitList);
          this.unitList.map(res => {
            if (res.organizationid == this.form.unitno)
              this.form.unitname = res.organizationname;
          });
          //账号类别为多值:提交前转回逗号分隔的字符串
          this.form.usertype = this.joinUserType(this.form.usertype);
          console.log(this.form);
          if (this.form.id != null) {
            updateExternalperson(this.form).then((response) => {
            updateExternalperson(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.queryParams.username = this.form.username;
              this.getList();
            });
          } else {
            addExternalperson(this.form).then((response) => {
              console.log("addExternalperson", response);
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            //保存信息(单位账号没有身份证号,跳过身份证查重)
            const saveNew = () => {
              getOnlyCode(this.seqnoParams).then(res => {
                this.form.userno = res.data.currentvalue;
                addExternalperson(this.form).then(response => {
                  this.$modal.msgSuccess("专家信息保存成功!");
                  this.open = false;
                  this.queryParams.username = this.form.username;
                  this.getList();
                });
              });
            };
            if (!this.form.idcardno || !String(this.form.idcardno).trim()) {
              saveNew();
              return;
            }
            //检查身份证唯一
            getInfoByIDCardNo(this.form.idcardno).then(res => {
              if (res.data.length > 1) {
                this.$modal.msgWarning("身份证号信息已被登记,请检查身份证号!"
                );
                return;
              }
              saveNew();
            });
          }
        }
@@ -340,7 +486,7 @@
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除外围单位人员编号为"' + ids + '"的数据项?')
        .confirm('是否确认删除人员/单位账号信息编号为"' + ids + '"的数据项?')
        .then(function () {
          return delExternalperson(ids);
        })
@@ -354,17 +500,31 @@
    handleExport() {
      const queryParams = this.queryParams;
      this.$modal
        .confirm("是否确认导出所有外围单位人员数据项?")
        .confirm("是否确认导出所有人员/单位账号信息数据项?")
        .then(() => {
          this.exportLoading = true;
          return exportExternalperson(queryParams);
        })
        .then((response) => {
        .then(response => {
          this.$download.name(response.msg);
          this.exportLoading = false;
        })
        .catch(() => { });
    },
  },
    //获取医疗机构列表
    getUnitList() {
      listOrganization(3).then(response => {
        for (let i = 0; i < response.rows.length; i++) {
          this.unitList.push({
            //organizationid: response.rows[i].organizationid,
            organizationid: response.rows[i].id.toString(),
            organizationname: response.rows[i].organizationname
          });
          console.log(this.unitList);
        }
      });
    }
  }
};
</script>