hir_web/src/views/system/user/list/index.vue

407 lines
11 KiB
Vue

<template>
<box-content>
<div class="search" style="position: relative">
<SearchForm
size="mini"
:that="this"
:search-data="searchData"
:search-form="searchForm"
:search-handle="searchHandle"
@search="handleSearch"
@reset="handleReset"
@new="handleAddUser"
/>
</div>
<base-table
v-loading="loading"
:columns="columns"
:list="users"
:search-data="searchData"
:total="total"
@getList="getList"
@editCb="handleEditUser"
@deleteCb="handleDeleteUser"
@sortByColumn="sortByColumn"
>
<!-- 选择自定义slot -->
<template slot="genderSlot" slot-scope="{ scope }">
{{ scope.row.Sex ? "Male" : "Female" }}
</template>
<template slot="roleSlot" slot-scope="{ scope }">
{{ scope.row.RoleNameList.map((role) => role.RoleName).join(",") }}
</template>
<template slot="isZhiZhunSlot" slot-scope="{ scope }">
{{
scope.row.IsZhiZhun
? $t("system:userlist:table:InternalOrExternal:Internal")
: $t("system:userlist:table:InternalOrExternal:External")
}}
</template>
<template slot="isTestUserSlot" slot-scope="{ scope }">
{{
scope.row.IsTestUser
? $t("system:userlist:table:IsTestUser:Yes")
: $t("system:userlist:table:IsTestUser:No")
}}
</template>
<template slot="statusSlot" slot-scope="{ scope }">
{{
scope.row.Status
? $t("system:userlist:table:Status:Enable")
: $t("system:userlist:table:Status:Disable")
}}
</template>
</base-table>
</box-content>
</template>
<script>
import { getUserList, getUserTypeList, deleteSysUser } from "@/api/admin";
// import { searchForm, searchHandle, columns } from './list'
import BoxContent from "@/components/BoxContent";
import SearchForm from "@/components/BaseForm/search-form";
import BaseTable from "@/components/BaseTable";
import tableMixins from "@/mixins/table";
// 用户列表查询表单配置信息
// 用户列表查询表单事件配置信息
const searchDataDefault = () => {
return {
UserName: null,
Phone: null,
EMail:null,
OrganizationName: null,
UserState: null,
UserType: null,
PageIndex: 1,
PageSize: 20,
Asc: false,
RealName: "",
SortField: "CreateTime",
CreateTimeArr: [],
BeginCreateTime: null,
EndCreateTime: null,
};
};
export default {
name: "UserList",
components: { BoxContent, SearchForm, BaseTable },
mixins: [tableMixins],
data() {
return {
searchData: searchDataDefault(),
columns: [
{ type: "index" },
{
prop: "UserCode",
label: this.$t("system:userlist:table:S/N"),
width: 100,
sortable: "custom",
showOverflowTooltip: true,
},
{
prop: "UserName",
label: this.$t("system:userlist:table:UserName"),
minWidth: 100,
sortable: "custom",
showOverflowTooltip: true,
},
{
prop: "RealName",
label: this.$t("system:userlist:table:RealName"),
minWidth: 120,
sortable: "custom",
showOverflowTooltip: true,
},
{
prop: "Sex",
label: this.$t("system:userlist:table:Gender"),
hidden: true,
slot: "genderSlot",
minWidth: 100,
sortable: "custom",
showOverflowTooltip: true,
},
{
prop: "Phone",
label: this.$t("system:userlist:table:Phone"),
minWidth: 120,
sortable: "custom",
showOverflowTooltip: true,
},
{
prop: "EMail",
label: this.$t("system:userlist:table:Email"),
minWidth: 150,
sortable: "custom",
showOverflowTooltip: true,
},
{
prop: "OrganizationName",
label: this.$t("system:userlist:table:Organization"),
minWidth: 130,
showOverflowTooltip: true,
},
{
prop: "UserType",
label: this.$t("system:userlist:table:UserType"),
minWidth: 100,
sortable: "custom",
showOverflowTooltip: true,
},
{
prop: "IsZhiZhun",
label: this.$t("system:userlist:table:InternalOrExternal"),
hidden: true,
slot: "isZhiZhunSlot",
minWidth: 140,
sortable: "custom",
showOverflowTooltip: true,
},
{
prop: "Status",
label: this.$t("system:userlist:table:Status"),
hidden: true,
slot: "statusSlot",
minWidth: 100,
sortable: "custom",
showOverflowTooltip: true,
},
{
prop: "CreateTime",
label: this.$t("system:userlist:table:createTime"),
minWidth: 200,
sortable: "custom",
showOverflowTooltip: true,
},
{
type: "operate",
label: this.$t("common:action:action"),
minWidth: 100,
operates: [
{
name: this.$t("common:button:edit"),
type: "primary",
emitKey: "editCb",
},
// {
// name: this.$t("common:button:delete"),
// type: "danger",
// emitKey: "deleteCb",
// },
],
},
],
searchForm: [
{
type: "Input",
label: this.$t("system:userlist:label:UserName"),
prop: "UserName",
width: "120px",
placeholder: "",
},
{
type: "Input",
label: this.$t("system:userlist:label:RealName"),
prop: "RealName",
width: "120px",
placeholder: "",
},
{
type: "Input",
label: this.$t("system:userlist:label:Phone"),
prop: "Phone",
width: "120px",
placeholder: "",
},
{
type: "Input",
label: this.$t("system:userlist:label:EMail"),
prop: "EMail",
width: "120px",
placeholder: "",
},
{
type: "Input",
label: this.$t("system:userlist:label:Organization"),
prop: "OrganizationName",
width: "120px",
placeholder: "",
},
{
type: "Select",
label: this.$t("system:userlist:label:InternalOrExternal"),
prop: "IsZhiZhun",
width: "150px",
options: [
{
label: this.$t(
"system:userlist:label:InternalOrExternal:Internal"
),
value: true,
},
{
label: this.$t(
"system:userlist:label:InternalOrExternal:External"
),
value: false,
},
],
props: { label: "label", value: "value" },
change: (scope) => "",
placeholder: "",
},
{
type: "Select",
label: this.$t("system:userlist:label:Status"),
prop: "UserState",
width: "150px",
options: [
{ label: this.$t("system:userlist:label:Status:Enable"), value: 1 },
{
label: this.$t("system:userlist:label:Status:Disable"),
value: 0,
},
],
props: { label: "label", value: "value" },
change: (scope) => "",
placeholder: "",
},
{
type: "Select",
label: this.$t("system:userlist:label:UserType"),
prop: "UserType",
width: "150px",
options: [], // 下拉选项
props: { label: "UserType", value: "Id" }, // 下拉选项配置信息,必填
placeholder: "",
},
{
type: "Daterange",
label: this.$t("system:userlist:label:CreateTime"),
prop: "CreateTimeArr",
width: "400px",
placeholder: "",
},
],
searchHandle: [
{
label: this.$t("common:button:reset"),
type: "primary",
emitKey: "reset",
},
{
label: this.$t("common:button:search"),
type: "primary",
emitKey: "search",
},
{
label: this.$t("common:button:new"),
type: "primary",
emitKey: "new",
},
],
userTypeOptions: [],
loading: false,
total: 0,
users: [],
};
},
created() {
this.getList();
this.getInfo();
},
methods: {
// 获取用户信息
getList() {
this.loading = true;
if (
this.searchData.CreateTimeArr[0] &&
this.searchData.CreateTimeArr[1]
) {
this.searchData.BeginCreateTime =
this.searchData.CreateTimeArr[0];
this.searchData.EndCreateTime =
this.searchData.CreateTimeArr[1];
} else {
this.searchData.BeginCreateTime = null;
this.searchData.EndCreateTime = null;
}
getUserList(this.searchData)
.then((res) => {
this.loading = false;
this.users = res.Result.CurrentPageData;
this.total = res.Result.TotalCount;
})
.catch(() => {
this.loading = false;
});
},
findItemIndex(key) {
return this.searchForm.findIndex(
(value) => value.prop && value.prop === key
);
},
// 获取用户类型下拉选项信息
async getInfo() {
const res = await getUserTypeList();
let arr = [];
if (this.hasPermi(["role:admin"])) {
arr = [1];
}
if (this.hasPermi(["role:oa"])) {
arr = [1, 2];
}
if (this.hasPermi(["role:pm"])) {
arr = [1, 2, 14];
}
let roleList = res.Result.map((item) => {
if (!arr.includes(item.UserTypeEnum)) {
return item;
}
}).filter((item) => item);
const index = this.findItemIndex("UserType");
this.$set(this.searchForm[index], "options", roleList);
},
handleAddUser() {
this.$router.push({ path: "/system/user/add" });
},
// 编辑用户
handleEditUser(data) {
this.$router.push({
path: "/system/user/edit",
query: { Id: data.Id, userName: data.UserName, email: data.EMail },
});
},
// 删除用户
handleDeleteUser(data) {
this.$confirm(this.$t("trials:uploadedDicoms:message:deleteMes"), {
type: "warning",
distinguishCancelAndClose: true,
}).then(() => {
deleteSysUser(data.Id).then((res) => {
if (res.IsSuccess) {
this.users.splice(
this.users.findIndex((item) => item.Id === data.Id),
1
);
this.$message.success(
this.$t("common:message:deletedSuccessfully")
);
}
});
});
},
// 重置列表查询
handleReset() {
this.searchData = searchDataDefault();
this.getList();
},
},
};
</script>
<style scoped lang="scss">
/deep/ .box-body .search .base-search-form .el-form-item {
margin-bottom: 15px;
}
</style>