|
@@ -4,17 +4,17 @@
|
|
|
<div v-show="showSearch" class="mb-[10px]">
|
|
|
<el-card shadow="hover">
|
|
|
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
|
|
- <el-form-item label="部门名称" prop="deptName">
|
|
|
- <el-input v-model="queryParams.deptName" placeholder="请输入部门名称" clearable @keyup.enter="handleQuery" />
|
|
|
+ <el-form-item label="科室名称" prop="deptName">
|
|
|
+ <el-input v-model="queryParams.deptName" placeholder="请输入科室名称" clearable @keyup.enter="handleQuery" />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="类别编码" prop="deptCategory">
|
|
|
- <el-input v-model="queryParams.deptCategory" placeholder="请输入类别编码" clearable style="width: 240px" @keyup.enter="handleQuery" />
|
|
|
+ <!-- <el-form-item label="科室编码" prop="deptCategory">
|
|
|
+ <el-input v-model="queryParams.deptCategory" placeholder="请输入科室编码" clearable style="width: 240px" @keyup.enter="handleQuery" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="状态" prop="status">
|
|
|
- <el-select v-model="queryParams.status" placeholder="部门状态" clearable>
|
|
|
+ <el-select v-model="queryParams.status" placeholder="科室状态" clearable>
|
|
|
<el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" />
|
|
|
</el-select>
|
|
|
- </el-form-item>
|
|
|
+ </el-form-item> -->
|
|
|
<el-form-item>
|
|
|
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
|
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
|
@@ -46,12 +46,12 @@
|
|
|
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
|
|
:default-expand-all="isExpandAll"
|
|
|
>
|
|
|
- <el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
|
|
|
- <el-table-column prop="deptCategory" align="center" label="类别编码" width="200"></el-table-column>
|
|
|
- <el-table-column prop="orderNum" align="center" label="排序" width="200"></el-table-column>
|
|
|
- <el-table-column prop="status" align="center" label="状态" width="100">
|
|
|
+ <el-table-column prop="deptName" label="科室名称" width="260"></el-table-column>
|
|
|
+ <el-table-column prop="deptCategory" align="center" label="科室编码" width="200"></el-table-column>
|
|
|
+ <el-table-column prop="remark" align="center" label="科室描述" width="200"></el-table-column>
|
|
|
+ <el-table-column prop="status" align="center" label="状态" width="100">
|
|
|
<template #default="scope">
|
|
|
- <dict-tag :options="sys_normal_disable" :value="scope.row.status" />
|
|
|
+ <el-switch v-model="scope.row.status" active-value="0" inactive-value="1" @change="handleStatusChange(scope.row)"></el-switch>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="创建时间" align="center" prop="createTime" width="200">
|
|
@@ -61,46 +61,47 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column fixed="right" align="center" label="操作">
|
|
|
<template #default="scope">
|
|
|
- <el-tooltip content="修改" placement="top">
|
|
|
- <el-button v-hasPermi="['system:dept:edit']" link type="primary" icon="Edit" @click="handleUpdate(scope.row)" />
|
|
|
+ <el-tooltip content="编辑" placement="top">
|
|
|
+ <el-button v-hasPermi="['system:dept:edit']" link type="primary" icon="Edit" @click="handleUpdate(scope.row)">编辑</el-button>
|
|
|
</el-tooltip>
|
|
|
- <el-tooltip content="新增" placement="top">
|
|
|
+ <!-- <el-tooltip content="新增" placement="top">
|
|
|
<el-button v-hasPermi="['system:dept:add']" link type="primary" icon="Plus" @click="handleAdd(scope.row)" />
|
|
|
- </el-tooltip>
|
|
|
+ </el-tooltip> -->
|
|
|
<el-tooltip content="删除" placement="top">
|
|
|
- <el-button v-hasPermi="['system:dept:remove']" link type="primary" icon="Delete" @click="handleDelete(scope.row)" />
|
|
|
+ <el-button v-hasPermi="['system:dept:remove']" link type="primary" icon="Delete" @click="handleDelete(scope.row)" >删除</el-button>
|
|
|
</el-tooltip>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
</el-card>
|
|
|
|
|
|
- <el-dialog v-model="dialog.visible" :title="dialog.title" destroy-on-close append-to-body width="600px">
|
|
|
+ <el-dialog v-model="dialog.visible" :title="dialog.title" destroy-on-close append-to-body width="700px">
|
|
|
<el-form ref="deptFormRef" :model="form" :rules="rules" label-width="80px">
|
|
|
<el-row>
|
|
|
- <el-col v-if="form.parentId !== 0" :span="24">
|
|
|
- <el-form-item label="上级部门" prop="parentId">
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="科室名称" prop="deptName">
|
|
|
+ <el-input v-model="form.deptName" placeholder="请输入科室名称" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="所属上级" prop="parentId">
|
|
|
<el-tree-select
|
|
|
v-model="form.parentId"
|
|
|
:data="deptOptions"
|
|
|
:props="{ value: 'deptId', label: 'deptName', children: 'children' } as any"
|
|
|
value-key="deptId"
|
|
|
- placeholder="选择上级部门"
|
|
|
+ placeholder="选择所属上级"
|
|
|
check-strictly
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
+
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="部门名称" prop="deptName">
|
|
|
- <el-input v-model="form.deptName" placeholder="请输入部门名称" />
|
|
|
+ <el-form-item label="科室编码" prop="deptCategory">
|
|
|
+ <el-input v-model="form.deptCategory" placeholder="请输入科室编码" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="类别编码" prop="deptCategory">
|
|
|
- <el-input v-model="form.deptCategory" placeholder="请输入类别编码" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="12">
|
|
|
+ <!-- <el-col :span="12">
|
|
|
<el-form-item label="显示排序" prop="orderNum">
|
|
|
<el-input-number v-model="form.orderNum" controls-position="right" :min="0" />
|
|
|
</el-form-item>
|
|
@@ -116,17 +117,20 @@
|
|
|
<el-form-item label="联系电话" prop="phone">
|
|
|
<el-input v-model="form.phone" placeholder="请输入联系电话" maxlength="11" />
|
|
|
</el-form-item>
|
|
|
- </el-col>
|
|
|
+ </el-col> -->
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="邮箱" prop="email">
|
|
|
- <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
|
|
|
+ <el-form-item label="状态" prop="status">
|
|
|
+ <el-select v-model="form.status" placeholder="请选择" clearable>
|
|
|
+ <el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" />
|
|
|
+ </el-select>
|
|
|
+ <!-- <el-radio-group v-model="form.status">
|
|
|
+ <el-radio v-for="dict in sys_normal_disable" :key="dict.value" :value="dict.value">{{ dict.label }}</el-radio>
|
|
|
+ </el-radio-group> -->
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="部门状态">
|
|
|
- <el-radio-group v-model="form.status">
|
|
|
- <el-radio v-for="dict in sys_normal_disable" :key="dict.value" :value="dict.value">{{ dict.label }}</el-radio>
|
|
|
- </el-radio-group>
|
|
|
+ <el-col >
|
|
|
+ <el-form-item label="描述" prop="remark">
|
|
|
+ <el-input v-model="form.remark" placeholder="请输入" maxlength="100" type="textarea" :rows="5"/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -142,7 +146,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup name="Dept" lang="ts">
|
|
|
-import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from '@/api/system/dept';
|
|
|
+import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild,changeDeptStatus } from '@/api/system/dept';
|
|
|
import { DeptForm, DeptQuery, DeptVO } from '@/api/system/dept/types';
|
|
|
import { UserVO } from '@/api/system/user/types';
|
|
|
import { listUserByDeptId } from '@/api/system/user';
|
|
@@ -180,7 +184,7 @@ const initFormData: DeptForm = {
|
|
|
orderNum: 0,
|
|
|
leader: undefined,
|
|
|
phone: undefined,
|
|
|
- email: undefined,
|
|
|
+ remark: undefined,
|
|
|
status: '0'
|
|
|
};
|
|
|
const initData: PageData<DeptForm, DeptQuery> = {
|
|
@@ -193,11 +197,11 @@ const initData: PageData<DeptForm, DeptQuery> = {
|
|
|
status: undefined
|
|
|
},
|
|
|
rules: {
|
|
|
- parentId: [{ required: true, message: '上级部门不能为空', trigger: 'blur' }],
|
|
|
- deptName: [{ required: true, message: '部门名称不能为空', trigger: 'blur' }],
|
|
|
- orderNum: [{ required: true, message: '显示排序不能为空', trigger: 'blur' }],
|
|
|
- email: [{ type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }],
|
|
|
- phone: [{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: '请输入正确的手机号码', trigger: 'blur' }]
|
|
|
+ // parentId: [{ required: true, message: '所属上级不能为空', trigger: 'blur' }],
|
|
|
+ deptName: [{ required: true, message: '科室名称不能为空', trigger: 'blur' }],
|
|
|
+ deptCategory: [{ required: true, message: '科室编码不能为空', trigger: 'blur' }],
|
|
|
+ status: [{ required: true, message: '状态不能为空', trigger: ['blur', 'change'] }],
|
|
|
+ // phone: [{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: '请输入正确的手机号码', trigger: 'blur' }]
|
|
|
}
|
|
|
};
|
|
|
const data = reactive<PageData<DeptForm, DeptQuery>>(initData);
|
|
@@ -215,7 +219,7 @@ const getList = async () => {
|
|
|
loading.value = false;
|
|
|
};
|
|
|
|
|
|
-/** 查询当前部门的所有用户 */
|
|
|
+/** 查询当前科室的所有用户 */
|
|
|
async function getDeptAllUser(deptId: any) {
|
|
|
if (deptId !== null && deptId !== '' && deptId !== undefined) {
|
|
|
const res = await listUserByDeptId(deptId);
|
|
@@ -262,22 +266,40 @@ const handleAdd = async (row?: DeptVO) => {
|
|
|
reset();
|
|
|
const res = await listDept();
|
|
|
const data = proxy?.handleTree<DeptOptionsType>(res.data, 'deptId');
|
|
|
- if (data) {
|
|
|
+ if (data) {
|
|
|
deptOptions.value = data;
|
|
|
if (row && row.deptId) {
|
|
|
form.value.parentId = row?.deptId;
|
|
|
}
|
|
|
dialog.visible = true;
|
|
|
- dialog.title = '添加部门';
|
|
|
+ dialog.title = '添加科室';
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/** 角色状态修改 */
|
|
|
+const handleStatusChange = async (row: DeptVO) => {
|
|
|
+ const text = row.status === '0' ? '启用' : '停用';
|
|
|
+ try {
|
|
|
+ await proxy?.$modal.confirm('确认要"' + text + '""' + row.deptName + '"科室吗?');
|
|
|
+ let param=ref<DeptForm>({
|
|
|
+ deptId: row.deptId,
|
|
|
+ status: row.status
|
|
|
+ });
|
|
|
+ await changeDeptStatus(param.value);
|
|
|
+ proxy?.$modal.msgSuccess(text + '成功');
|
|
|
+ } catch {
|
|
|
+ row.status = row.status === '0' ? '1' : '0';
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/** 修改按钮操作 */
|
|
|
-const handleUpdate = async (row: DeptVO) => {
|
|
|
+const handleUpdate = async (row: DeptVO) => {
|
|
|
reset();
|
|
|
- //查询当前部门所有用户
|
|
|
+ //查询当前科室所有用户
|
|
|
getDeptAllUser(row.deptId);
|
|
|
const res = await getDept(row.deptId);
|
|
|
+ const item= res.data;
|
|
|
+ item.parentId = item.parentId==0?null:item.parentId;
|
|
|
form.value = res.data;
|
|
|
const response = await listDeptExcludeChild(row.deptId);
|
|
|
const data = proxy?.handleTree<DeptOptionsType>(response.data, 'deptId');
|
|
@@ -293,13 +315,16 @@ const handleUpdate = async (row: DeptVO) => {
|
|
|
}
|
|
|
}
|
|
|
dialog.visible = true;
|
|
|
- dialog.title = '修改部门';
|
|
|
+ dialog.title = '修改科室';
|
|
|
};
|
|
|
/** 提交按钮 */
|
|
|
const submitForm = () => {
|
|
|
deptFormRef.value?.validate(async (valid: boolean) => {
|
|
|
if (valid) {
|
|
|
- form.value.deptId ? await updateDept(form.value) : await addDept(form.value);
|
|
|
+ let param=ref<DeptForm>();
|
|
|
+ Object.assign(param,form);
|
|
|
+ param.value.parentId=param.value.parentId?param.value.parentId:0;
|
|
|
+ param.value.deptId ? await updateDept(param.value) : await addDept(param.value);
|
|
|
proxy?.$modal.msgSuccess('操作成功');
|
|
|
dialog.visible = false;
|
|
|
await getList();
|