远程管理错误修复

This commit is contained in:
yy 2024-06-07 15:35:36 +08:00
parent 69c6cd10f7
commit 4fc1ca4d31

View File

@ -1,67 +1,67 @@
<template> <template>
<div class="table-page"> <div class="table-page">
<div class="search-part" v-show="isSearch"> <div class="search-part" v-show="isSearch">
<div class="search-cell"> <div class="search-cell">
<span class="label">用户名</span> <span class="label">用户名</span>
<el-input v-model="queryParams.userName" placeholder="请输入用户名"></el-input> <el-input v-model="queryParams.userName" placeholder="请输入用户名"></el-input>
</div> </div>
<el-button type="primary" icon="Search" @click="searchData()">查询</el-button> <el-button type="primary" icon="Search" @click="searchData()">查询</el-button>
<el-button icon="Refresh" @click="resetSearch()">重置</el-button> <el-button icon="Refresh" @click="resetSearch()">重置</el-button>
</div> </div>
<div class="button-part" style="justify-content: space-between;"> <div class="button-part" style="justify-content: space-between;">
<div> <div>
<el-button type="primary" icon="FirstAidKit" @click="addData">新增</el-button> <el-button type="primary" icon="FirstAidKit" @click="addData">新增</el-button>
<el-button icon="FirstAidKit" @click="importData">导入</el-button> <el-button icon="FirstAidKit" @click="importData">导入</el-button>
<el-button icon="Delete" @click="removeData()">删除</el-button> <el-button icon="Delete" @click="removeData()">删除</el-button>
</div> </div>
<TableAbility @searchBtn="isSearch = !isSearch" @refreshBtn="updateData()" <TableAbility @searchBtn="isSearch = !isSearch" @refreshBtn="updateData()"
@downloadBtn="exportData('医生数据', tableData)"></TableAbility> @downloadBtn="exportData('医生数据', tableData)"></TableAbility>
</div> </div>
<div class="table-part"> <div class="table-part">
<el-table ref="tableRef" v-loading="loading" :data="tableData" height="100%" border show-overflow-tooltip <el-table ref="tableRef" v-loading="loading" :data="tableData" height="100%" border show-overflow-tooltip
:row-class-name="({ row }: any) => row.lockFlag == 1 && 'disable'" @row-click="tableRowClick"> :row-class-name="({ row }: any) => row.lockFlag == 1 && 'disable'" @row-click="tableRowClick">
<el-table-column type="selection" width="55"/> <el-table-column type="selection" width="55"/>
<el-table-column type="index" label="#" width="55" align="center"/> <el-table-column type="index" label="#" width="55" align="center"/>
<el-table-column property="name" label="姓名" width="120" align="center"/> <el-table-column property="name" label="姓名" width="120" align="center"/>
<el-table-column label="手机号" width="220" align="center"> <el-table-column label="手机号" width="220" align="center">
<template #default="scope"> <template #default="scope">
<div v-if="scope.row.phone"> <div v-if="scope.row.phone">
{{ {{
scope.row.phone.slice(0, 3) + '****' + scope.row.phone.slice(7) scope.row.phone.slice(0, 3) + '****' + scope.row.phone.slice(7)
}} }}
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="角色" width="220" align="center"> <el-table-column label="角色" width="220" align="center">
<template #default="scope"> <template #default="scope">
<span v-for="(item, index) in scope.row.roleList" :key="index"> <span v-for="(item, index) in scope.row.roleList" :key="index">
{{ item.roleName }} {{ (scope.row.roleList.length - 1) == index ? '' : '' }} {{ item.roleName }} {{ (scope.row.roleList.length - 1) == index ? '' : '' }}
</span> </span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="锁定" width="120" align="center"> <el-table-column label="锁定" width="120" align="center">
<template #default="scope"> <template #default="scope">
<span><el-switch v-model="scope.row.lockFlag" @click="enableChange(scope.row)"/></span> <span><el-switch v-model="scope.row.lockFlag" @click="enableChange(scope.row)"/></span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center">
<template #default="scope"> <template #default="scope">
<span @click.stop> <span @click.stop>
<el-button link icon="RefreshLeft" @click="resetPassword(scope.row)" <el-button link icon="RefreshLeft" @click="resetPassword(scope.row)"
:disabled="scope.row.lockFlag == 1">密码</el-button> :disabled="scope.row.lockFlag == 1">密码</el-button>
<el-button link icon="EditPen" @click="editData(scope.row)" <el-button link icon="EditPen" @click="editData(scope.row)"
:disabled="scope.row.lockFlag == 1">修改</el-button> :disabled="scope.row.lockFlag == 1">修改</el-button>
<el-button link icon="Delete" @click="removeData([scope.row])" <el-button link icon="Delete" @click="removeData([scope.row])"
:disabled="scope.row.lockFlag == 1">删除</el-button> :disabled="scope.row.lockFlag == 1">删除</el-button>
</span> </span>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<div class="pagination-part"> <div class="pagination-part">
<CommonPagination :total="total" @paginationChange="paginationChange"/> <CommonPagination :total="total" @paginationChange="paginationChange"/>
</div> </div>
</div> </div>
<el-dialog v-model="psDialogVisible" title="密码重置" width="500" draggable> <el-dialog v-model="psDialogVisible" title="密码重置" width="500" draggable>
<el-form ref="formRef" :model="formData" :rules="rules" label-width="60"> <el-form ref="formRef" :model="formData" :rules="rules" label-width="60">
<el-form-item label="密码" prop="password" label-width="100"> <el-form-item label="密码" prop="password" label-width="100">
@ -82,13 +82,14 @@
</div> </div>
</template> </template>
</el-dialog> </el-dialog>
<el-dialog v-model="isFormDialog" :title="formDialogTitle" width="750px"> <el-dialog v-model="isFormDialog" :title="formDialogTitle" width="750px">
<DoctorForm ref="doctorFormRef" :type="formDialogTitle === '添加' ? 'add' : 'edit'" @close="isFormDialog = false" <DoctorForm ref="doctorFormRef" :type="formDialogTitle === '添加' ? 'add' : 'edit'"
@save="doctorFormSave"/> @close="isFormDialog = false"
</el-dialog> @save="doctorFormSave"/>
<ImportDialog ref="importDialogRef" title="用户导入" </el-dialog>
templateUrl="/admin/sys-file/local/file/user.xlsx" <ImportDialog ref="importDialogRef" title="用户导入"
importUrl="/admin/user/import"/> templateUrl="/admin/sys-file/local/file/user.xlsx"
importUrl="/admin/user/import"/>
</template> </template>
<script lang='ts' setup> <script lang='ts' setup>
@ -110,7 +111,7 @@ const isFormDialog = ref(false)
const psDialogVisible = ref(false) const psDialogVisible = ref(false)
const formDialogTitle = ref('') const formDialogTitle = ref('')
const queryParams = ref({ const queryParams = ref({
userName: '' userName: ''
} as any) } as any)
const tableData = ref([] as any) const tableData = ref([] as any)
let current = 0 let current = 0
@ -150,76 +151,76 @@ const rules = ref({
queryData() queryData()
function searchData() { function searchData() {
updateData() updateData()
} }
function resetSearch() { function resetSearch() {
queryParams.value.userName = "" queryParams.value.userName = ""
updateData() updateData()
} }
function queryData() { function queryData() {
loading.value = true loading.value = true
userPage({ userPage({
current, current,
size, size,
name: queryParams.value.userName name: queryParams.value.userName
}).then((res: any) => { }).then((res: any) => {
loading.value = false loading.value = false
total.value = res.data.total total.value = res.data.total
tableData.value = res.data.records tableData.value = res.data.records
}).catch(error => { }).catch(error => {
loading.value = false loading.value = false
}) })
} }
function updateData() { function updateData() {
current = 0 current = 0
total.value = 0 total.value = 0
tableData.value = [] tableData.value = []
queryData() queryData()
} }
const addData = () => { const addData = () => {
isFormDialog.value = true isFormDialog.value = true
formDialogTitle.value = '添加' formDialogTitle.value = '添加'
setTimeout(() => { setTimeout(() => {
doctorFormRef.value.resetData() doctorFormRef.value.resetData()
}, 0) }, 0)
} }
const importData = () => { const importData = () => {
setTimeout(() => { setTimeout(() => {
importDialogRef.value.open() importDialogRef.value.open()
}, 0); }, 0);
} }
const removeData = (e?: any) => { const removeData = (e?: any) => {
const selectRow = e || tableRef.value.getSelectionRows() const selectRow = e || tableRef.value.getSelectionRows()
tableRemoveRow({data: selectRow}, (res: boolean) => { tableRemoveRow({data: selectRow}, (res: boolean) => {
if (res) { if (res) {
const index = tableData.value.findIndex((item: any) => item === selectRow) const index = tableData.value.findIndex((item: any) => item === selectRow)
tableData.value.splice(index, 1) tableData.value.splice(index, 1)
const ids: any = []; const ids: any = [];
selectRow.forEach((row: any) => { selectRow.forEach((row: any) => {
ids.push(row.userId) ids.push(row.userId)
}) })
deleteU(ids).then(res => { deleteU(ids).then(res => {
ElMessage.success("删除成功") ElMessage.success("删除成功")
}).catch(() => { }).catch(() => {
ElMessage.error("删除失败") ElMessage.error("删除失败")
}) })
} }
}) })
} }
const enableChange = (e: any) => { const enableChange = (e: any) => {
updateUserInfo({ updateUserInfo({
username: e.username, username: e.username,
lockFlag: e.lockFlag ? '1' : '0' lockFlag: e.lockFlag ? '1' : '0'
}).then((res: any) => { }).then((res: any) => {
if (res.code == 0) { if (res.code == 0) {
ElMessage.success(e.lockFlag ? '锁定成功' : '解锁成功') ElMessage.success(e.lockFlag ? '锁定成功' : '解锁成功')
} }
}) })
} }
const resetPassword = (e: any) => { const resetPassword = (e: any) => {
formData.value = { formData.value = {
@ -228,7 +229,9 @@ const resetPassword = (e: any) => {
username: e.username username: e.username
} }
psDialogVisible.value = true psDialogVisible.value = true
formRef.value.resetFields() setTimeout(() => {
formRef.value.resetFields()
})
} }
const sbPs = () => { const sbPs = () => {
@ -250,28 +253,28 @@ const sbPs = () => {
} }
const editData = (e: any) => { const editData = (e: any) => {
isFormDialog.value = true isFormDialog.value = true
formDialogTitle.value = '修改' formDialogTitle.value = '修改'
setTimeout(() => { setTimeout(() => {
doctorFormRef.value.resetData() doctorFormRef.value.resetData()
const val = JSON.parse(JSON.stringify(e)); const val = JSON.parse(JSON.stringify(e));
val.role = [] val.role = []
val.roleList.forEach((role: any) => { val.roleList.forEach((role: any) => {
val.role.push(role.roleId) val.role.push(role.roleId)
}) })
doctorFormRef.value.formData = val doctorFormRef.value.formData = val
}, 0) }, 0)
} }
const tableRowClick = (row: any) => { const tableRowClick = (row: any) => {
tableRef.value.toggleRowSelection(row) tableRef.value.toggleRowSelection(row)
} }
const doctorFormSave = (data: any, type: string) => { const doctorFormSave = (data: any, type: string) => {
updateData() updateData()
} }
const paginationChange = (page: number, s: number) => { const paginationChange = (page: number, s: number) => {
current = page current = page
size = s size = s
queryData() queryData()
} }
</script> </script>