rax-medical/src/views/patients-manage/patients-manage.vue

144 lines
5.6 KiB
Vue
Raw Normal View History

2023-12-15 18:08:45 +08:00
<template>
2023-12-19 09:47:35 +08:00
<div class="table-page">
<div class="search-part">
<div class="search-cell">
<span class="label">患者姓名</span>
<el-input v-model="queryParams.name" placeholder="请输入患者姓名"></el-input>
</div>
<div class="search-cell">
<span class="label">科室名</span>
<el-select v-model="queryParams.dept" placeholder="请选择科室名">
<el-option v-for="item in getDeptData()" :key="item.value" :label="item.label"
:value="item.value" />
</el-select>
</div>
<el-button type="primary" icon="Search" @click="queryData(queryParams)">查询</el-button>
<el-button icon="Refresh" @click="queryParams = {}">重置</el-button>
</div>
<div class="button-part" style="justify-content: space-between;">
<div>
<el-button type="primary" icon="FirstAidKit" @click="addData">新增</el-button>
<el-button icon="FirstAidKit" @click="importData">导入</el-button>
<el-button icon="Delete" @click="removeData()">删除</el-button>
</div>
<el-button icon="Download" @click="exportData('患者信息', tableData)">下载</el-button>
</div>
<div class="table-part">
<el-table ref="tableRef" :data="tableData" height="100%" border show-overflow-tooltip
@row-click="tableRowClick">
<el-table-column type="selection" width="55" />
<el-table-column type="index" label="#" width="55" align="center" />
<el-table-column property="name" label="姓名" width="120" align="center" />
<el-table-column label="手机号" width="220" align="center">
<template #default="scope">{{ scope.row.phone.slice(0, 3) + '****' + scope.row.phone.slice(7)
}}</template>
</el-table-column>
<el-table-column property="role" label="角色" width="220" align="center" />
<el-table-column label="启用" width="120" align="center">
<template #default="scope">
<span @click.stop><el-switch v-model="scope.row.enable" @change="enableChange(scope.row)" /></span>
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template #default="scope">
<span @click.stop>
<el-button link icon="RefreshLeft" @click="resetPassword(scope.row)">密码</el-button>
<el-button link icon="EditPen" @click="editData(scope.row)">修改</el-button>
<el-button link icon="Delete" @click="removeData(scope.row)">删除</el-button>
</span>
</template>
</el-table-column>
</el-table>
</div>
<div class="pagination-part">
<CommonPagination :total="100" @paginationChange="paginationChange" />
</div>
2023-12-15 18:08:45 +08:00
</div>
2023-12-19 09:47:35 +08:00
<el-dialog v-model="isFormDialog" :title="formDialogTitle" width="40%"><PatientsForm ref="patientsFormRef" :type="formDialogTitle === '添加' ? 'add' : 'edit'" @close="isFormDialog = false" /></el-dialog>
<ImportDialog ref="importDialogRef" title="用户导入" templateUrl="#" importUrl="#" />
2023-12-15 18:08:45 +08:00
</template>
<script lang='ts' setup>
import { onMounted, reactive, ref, toRefs, watch } from 'vue'
2023-12-19 09:47:35 +08:00
import { ElMessage, ElMessageBox } from 'element-plus'
import { tableRemoveRow, exportData } from '@/utils/table-util'
import CommonPagination from '@/components/common-pagination.vue'
import PatientsForm from './form/patients-form.vue'
import ImportDialog from '@/components/import-dialog.vue'
import { getDeptData } from '@/static-data/core'
2023-12-15 18:08:45 +08:00
2023-12-19 09:47:35 +08:00
const tableRef = ref()
const patientsFormRef = ref()
const importDialogRef = ref()
const isFormDialog = ref(false)
const formDialogTitle = ref('')
const queryParams = ref({
userName: ''
} as any)
const tableData = ref([] as any)
queryData({user: '测试', dept: getDeptData()[0].label})
function queryData (e: any) {
tableData.value = []
while (tableData.value.length < 10) {
tableData.value.push({
userName: 'cscs',
2023-12-20 15:12:29 +08:00
// hospital
2023-12-19 09:47:35 +08:00
name: e.userName,
phone: '12312345678',
role: '高级管理员',
enable: true,
})
}
}
const addData = () => {
isFormDialog.value = true
formDialogTitle.value = '添加'
setTimeout(() => {
patientsFormRef.value.resetData()
}, 0)
}
const importData = () => {
setTimeout(() => {
importDialogRef.value.open()
}, 0);
}
const removeData = (e?: any) => {
const selectRow = e || tableRef.value.getSelectionRows()
tableRemoveRow({ data: selectRow }, (res: boolean) => {
if (res) {
console.log('调用删除', selectRow)
}
})
}
const enableChange = (e: any) => {
}
const resetPassword = (e: any) => {
ElMessageBox.confirm('是否确定要重置密码?', '系统提醒', { type: 'warning' }).then(() => {
ElMessage.success('重置成功!')
}).catch(() => { })
}
const editData = (e: any) => {
isFormDialog.value = true
formDialogTitle.value = '修改'
setTimeout(() => {
patientsFormRef.value.resetData()
patientsFormRef.value.formData = e
}, 0)
}
const tableRowClick = (row: any) => {
tableRef.value.toggleRowSelection(row)
}
const paginationChange = (page: number, size: number) => {
}
2023-12-15 18:08:45 +08:00
</script>
<style lang='scss' scoped>
2023-12-19 09:47:35 +08:00
2023-12-15 18:08:45 +08:00
</style>