远程管理错误修复

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