<template>
|
<div class="app-container">
|
<el-form
|
:model="queryParams"
|
ref="queryForm"
|
:inline="true"
|
v-show="showSearch"
|
label-width="80px"
|
>
|
<el-form-item label="账号编号" prop="userno">
|
<el-input
|
v-model="queryParams.userno"
|
placeholder="请输入账号编号"
|
clearable
|
size="small"
|
@keyup.enter.native="handleQuery"
|
/>
|
</el-form-item>
|
<el-form-item label="账号名称" prop="username">
|
<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"
|
multiple
|
collapse-tags
|
>
|
<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>
|
<el-button
|
type="primary"
|
icon="el-icon-search"
|
size="mini"
|
@click="handleQuery"
|
>搜索</el-button
|
>
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
|
>重置</el-button
|
>
|
</el-form-item>
|
</el-form>
|
|
<el-row :gutter="10" class="mb8">
|
<el-col :span="1.5">
|
<el-button
|
type="primary"
|
plain
|
icon="el-icon-plus"
|
size="mini"
|
@click="handleAdd"
|
v-hasPermi="['project:externalperson:add']"
|
>新增</el-button
|
>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="success"
|
plain
|
icon="el-icon-edit"
|
size="mini"
|
:disabled="single"
|
@click="handleUpdate"
|
v-hasPermi="['project:externalperson:edit']"
|
>修改</el-button
|
>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="danger"
|
plain
|
icon="el-icon-delete"
|
size="mini"
|
:disabled="multiple"
|
@click="handleDelete"
|
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-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" width="200">
|
<template slot-scope="scope">
|
<div v-if="scope.row.usertype">
|
<el-tag
|
v-for="type in getTypeList(scope.row.usertype)"
|
:key="type"
|
size="small"
|
style="margin-right: 5px; margin-bottom: 3px"
|
>
|
{{ getTypeLabel(type) }}
|
</el-tag>
|
</div>
|
<span v-else>-</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="账号编号" align="center" prop="userno" />
|
<el-table-column label="账号名称" align="center" prop="username" />
|
<el-table-column
|
label="身份证号"
|
width="200"
|
align="center"
|
prop="idcardno"
|
/>
|
<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="操作"
|
align="center"
|
class-name="small-padding fixed-width"
|
width="150"
|
>
|
<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)"
|
>删除</el-button
|
>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<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="请选择账号类别"
|
multiple
|
collapse-tags
|
style="width: 100%"
|
>
|
<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-col>
|
<el-col :span="12">
|
<el-form-item label="账号编号" prop="userno">
|
<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-col>
|
<el-col :span="12">
|
<el-form-item
|
label="启用状态"
|
prop="userstatus"
|
:disabled="!ismanager"
|
>
|
<el-radio-group v-model="form.userstatus">
|
<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>
|
|
<!-- 个人信息(当不包含'org'类型时显示) -->
|
<div v-if="!hasOrgType(form.usertype)">
|
<el-row>
|
<el-col :span="24">
|
<el-form-item label="身份证号" prop="idcardno">
|
<el-input v-model="form.idcardno" placeholder="请输入身份证号" />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="性别" prop="sex">
|
<el-select v-model="form.sex" placeholder="请选择性别" style="width: 100%">
|
<el-option
|
v-for="dict in dict.type.sys_user_sex"
|
:key="dict.value"
|
:label="dict.label"
|
:value="dict.value"
|
></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="职称" prop="title">
|
<el-select v-model="form.title" placeholder="请选择人员职称" style="width: 100%">
|
<el-option
|
v-for="dict in dict.type.sys_professionaltitle"
|
:key="dict.value"
|
:label="dict.label"
|
:value="dict.label"
|
></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="所在单位" prop="unitname">
|
<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">
|
<el-input
|
v-model="form.personnelunitno"
|
placeholder="请输入所在单位的工号"
|
/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</div>
|
|
<!-- 银行信息(所有类型都显示) -->
|
<el-row>
|
<el-col :span="24">
|
<el-form-item label="开户银行" prop="depositbank">
|
<el-input
|
v-model="form.depositbank"
|
placeholder="请输入开户银行名称"
|
/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="24">
|
<el-form-item label="银行卡号" prop="bankcardno">
|
<el-input
|
v-model="form.bankcardno"
|
placeholder="请输入银行卡号"
|
/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
|
<!-- 联系信息 -->
|
<el-row>
|
<el-col :span="24">
|
<el-form-item label="联系地址" prop="address">
|
<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-col>
|
</el-row>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
<el-button @click="cancel">取 消</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import {
|
listExternalperson,
|
getExternalperson,
|
delExternalperson,
|
addExternalperson,
|
updateExternalperson,
|
exportExternalperson,
|
getOnlyCode
|
} from "@/api/project/externalperson";
|
|
import {
|
listOrganization,
|
getOrganization,
|
listReportname,
|
listUser
|
} from "@/api/project/organization";
|
|
import { getUserProfile } from "@/api/system/user";
|
|
export default {
|
name: "Externalperson",
|
dicts: ["sys_UserType", "sys_0_1", "sys_user_sex", "sys_professionaltitle"],
|
data() {
|
return {
|
// 遮罩层
|
loading: false,
|
// 导出遮罩层
|
exportLoading: false,
|
// 选中数组
|
ids: [],
|
// 非单个禁用
|
single: true,
|
// 非多个禁用
|
multiple: true,
|
// 显示搜索条件
|
showSearch: true,
|
// 总条数
|
total: 0,
|
// 外围单位人员表格数据
|
externalpersonList: [],
|
|
//医疗机构列表
|
unitList: [],
|
// 弹出层标题
|
title: "",
|
// 是否显示弹出层
|
open: false,
|
// 查询参数
|
queryParams: {
|
pageNum: 1,
|
pageSize: 10,
|
userno: null,
|
username: null,
|
usertype: null
|
},
|
|
// 查询最新序号参数
|
seqnoParams: {
|
businessType: "externalperson",
|
datequery: false
|
},
|
// 表单参数
|
form: {
|
usertype: [] // 初始化为数组
|
},
|
// 表单校验
|
rules: {
|
usertype: [
|
{
|
required: true,
|
message: "请至少选择一个账号类别",
|
trigger: "change",
|
validator: (rule, value, callback) => {
|
if (!value || (Array.isArray(value) && value.length === 0)) {
|
callback(new Error("请至少选择一个账号类别"));
|
} else {
|
callback();
|
}
|
}
|
}
|
],
|
username: [
|
{ required: true, message: "请输入账户名称", trigger: "blur" }
|
],
|
idcardno: [
|
{
|
required: true,
|
message: "请输入身份证号码",
|
trigger: "blur",
|
validator: (rule, value, callback) => {
|
// 当不包含'org'类型时,身份证号为必填
|
if (!this.hasOrgType(this.form.usertype) && (!value || value.trim() === '')) {
|
callback(new Error("请输入身份证号码"));
|
} else {
|
callback();
|
}
|
}
|
}
|
],
|
|
},
|
//是否是专家费的OPO审批人员
|
ismanager: false
|
};
|
},
|
created() {
|
this.getUserProfile();
|
this.getUnitList();
|
// 默认不打开
|
this.getList();
|
},
|
methods: {
|
// 检查是否包含'org'类型
|
hasOrgType(usertype) {
|
if (!usertype) return false;
|
if (Array.isArray(usertype)) {
|
return usertype.includes('org');
|
} else if (typeof usertype === 'string') {
|
return usertype.includes('org');
|
}
|
return false;
|
},
|
|
// 将逗号分隔的字符串转换为数组
|
getTypeList(usertypeStr) {
|
if (!usertypeStr) return [];
|
if (typeof usertypeStr === 'string') {
|
return usertypeStr.split(',').filter(item => item.trim() !== '');
|
} else if (Array.isArray(usertypeStr)) {
|
return usertypeStr;
|
}
|
return [];
|
},
|
|
// 获取类型标签
|
getTypeLabel(type) {
|
const dict = this.dict.type.sys_UserType;
|
if (dict) {
|
const item = dict.find(item => item.value === type);
|
return item ? item.label : type;
|
}
|
return type;
|
},
|
|
//获取当前用户信息
|
getUserProfile() {
|
getUserProfile().then(res => {
|
if (
|
res.data.userName == "admin" ||
|
res.data.userName == "053" ||
|
res.data.userName == "047"
|
) {
|
this.ismanager = true;
|
} else {
|
this.ismanager = false;
|
}
|
});
|
},
|
|
/** 查询单位、人员账号列表 */
|
getList() {
|
this.loading = true;
|
// 处理查询参数,如果是数组则转换为逗号分隔的字符串
|
const params = { ...this.queryParams };
|
if (Array.isArray(params.usertype) && params.usertype.length > 0) {
|
params.usertype = params.usertype.join(',');
|
}
|
|
listExternalperson(params).then(response => {
|
this.externalpersonList = response.rows;
|
this.total = response.total;
|
this.loading = false;
|
}).catch(() => {
|
this.loading = false;
|
});
|
},
|
|
// 取消按钮
|
cancel() {
|
this.open = false;
|
this.reset();
|
},
|
|
// 表单重置
|
reset() {
|
this.form = {
|
id: null,
|
userno: null,
|
username: null,
|
userstatus: 0,
|
usertype: [], // 重置为数组
|
personnelunitno: null,
|
delFlag: null,
|
createBy: null,
|
createTime: null,
|
updateBy: null,
|
updateTime: null,
|
pym: null,
|
wbm: null
|
};
|
this.resetForm("form");
|
},
|
|
/** 搜索按钮操作 */
|
handleQuery() {
|
console.log("handleQuery", this.queryParams);
|
this.queryParams.pageNum = 1;
|
this.getList();
|
},
|
|
/** 重置按钮操作 */
|
resetQuery() {
|
this.resetForm("queryForm");
|
this.queryParams.usertype = []; // 重置为数组
|
this.handleQuery();
|
},
|
|
// 多选框选中数据
|
handleSelectionChange(selection) {
|
this.ids = selection.map(item => item.id);
|
this.single = selection.length !== 1;
|
this.multiple = !selection.length;
|
},
|
|
/** 新增按钮操作 */
|
handleAdd() {
|
this.reset();
|
this.open = true;
|
this.title = "添加人员/单位账号信息";
|
},
|
|
/** 修改按钮操作 */
|
handleUpdate(row) {
|
this.reset();
|
const id = row.id || this.ids;
|
getExternalperson(id).then(response => {
|
const data = response.data;
|
// 将数据库中的逗号分隔字符串转换为数组
|
if (data.usertype && typeof data.usertype === 'string') {
|
data.usertype = data.usertype.split(',').filter(item => item.trim() !== '');
|
} else if (!data.usertype) {
|
data.usertype = [];
|
}
|
this.form = data;
|
this.open = true;
|
this.title = "人员/单位账号信息修改";
|
});
|
},
|
|
/** 提交按钮 */
|
submitForm() {
|
this.$refs["form"].validate(valid => {
|
if (valid) {
|
// 处理单位信息
|
this.unitList.map(res => {
|
if (res.organizationid == this.form.unitno) {
|
this.form.unitname = res.organizationname;
|
}
|
});
|
|
// 将数组转换为逗号分隔的字符串
|
const submitData = { ...this.form };
|
if (Array.isArray(submitData.usertype) && submitData.usertype.length > 0) {
|
submitData.usertype = submitData.usertype.join(',');
|
} else {
|
submitData.usertype = '';
|
}
|
|
console.log("提交数据:", submitData);
|
|
if (submitData.id != null) {
|
updateExternalperson(submitData).then(response => {
|
this.$modal.msgSuccess("修改成功");
|
this.open = false;
|
this.queryParams.username = submitData.username;
|
this.getList();
|
}).catch(error => {
|
console.error("修改失败:", error);
|
});
|
} else {
|
getOnlyCode(this.seqnoParams).then(res => {
|
submitData.userno = res.data.currentvalue;
|
|
addExternalperson(submitData).then(response => {
|
this.$modal.msgSuccess("新增成功");
|
this.open = false;
|
this.queryParams.username = submitData.username;
|
this.getList();
|
}).catch(error => {
|
console.error("新增失败:", error);
|
});
|
}).catch(error => {
|
console.error("获取编号失败:", error);
|
});
|
}
|
}
|
});
|
},
|
|
/** 删除按钮操作 */
|
handleDelete(row) {
|
const ids = row.id || this.ids;
|
this.$modal
|
.confirm('是否确认删除人员/单位账号信息编号为"' + ids + '"的数据项?')
|
.then(function() {
|
return delExternalperson(ids);
|
})
|
.then(() => {
|
this.getList();
|
this.$modal.msgSuccess("删除成功");
|
})
|
.catch(() => {});
|
},
|
|
/** 导出按钮操作 */
|
handleExport() {
|
const queryParams = { ...this.queryParams };
|
// 处理查询参数,如果是数组则转换为逗号分隔的字符串
|
if (Array.isArray(queryParams.usertype) && queryParams.usertype.length > 0) {
|
queryParams.usertype = queryParams.usertype.join(',');
|
}
|
|
this.$modal
|
.confirm("是否确认导出所有人员/单位账号信息数据项?")
|
.then(() => {
|
this.exportLoading = true;
|
return exportExternalperson(queryParams);
|
})
|
.then(response => {
|
this.$download.name(response.msg);
|
this.exportLoading = false;
|
})
|
.catch(() => {
|
this.exportLoading = false;
|
});
|
},
|
|
//获取医疗机构列表
|
getUnitList() {
|
listOrganization(3).then(response => {
|
this.unitList = response.rows.map(item => ({
|
organizationid: item.id.toString(),
|
organizationname: item.organizationname
|
}));
|
console.log("医疗机构列表:", this.unitList);
|
});
|
}
|
}
|
};
|
</script>
|
|
<style scoped>
|
::v-deep .el-select .el-tag {
|
margin: 2px 6px 2px 0;
|
}
|
|
::v-deep .el-select .el-tag__close {
|
margin-left: 4px;
|
}
|
</style>
|