| | |
| | | const router = useRouter() |
| | | const add = ref(false) |
| | | const adda = ref(false) |
| | | const editingUser = ref({}); // 用于存储当前编辑的用户数据 |
| | | import request from "@/utils/request" |
| | | import { ref, onMounted } from "vue"; |
| | | // import { ref } from 'vue' |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | import { useI18n } from 'vue-i18n' |
| | | const { t } = useI18n() |
| | | let language = ref(localStorage.getItem('lang') || 'zh') |
| | | // import LanguageMixin from './lang/LanguageMixin' |
| | | const selectedProjectNoa = ref(''); // 当前选中的角色 |
| | | // const options = ref<any[]>([]); // 下拉选项列表 |
| | |
| | | }); |
| | | // 重置密码 |
| | | const open = async(row) => { |
| | | try { |
| | | try { |
| | | const confirmResult = await ElMessageBox.confirm( |
| | | '是否重置用户密码?', |
| | | '提示', |
| | | t('productStock.repassword'), |
| | | t('productStock.prompt'), |
| | | { |
| | | confirmButtonText: '是', |
| | | cancelButtonText: '取消', |
| | | confirmButtonText: t('productStock.yes'), |
| | | cancelButtonText: t('productStock.cancel'), |
| | | type: 'warning', |
| | | } |
| | | ); |
| | | } |
| | | ); |
| | | if (confirmResult === 'confirm') { |
| | | // 用户点击了“是”,现在调用删除接口 |
| | | var url="/loadGlass/sys/user/resetPassword?userId="+row.id; |
| | |
| | | const response = await request.post('/loadGlass/sys/role/queryRole',{ |
| | | key: '' |
| | | }); |
| | | if (response.code == 200) { |
| | | if (response.code === 200) { |
| | | titleSelectJsona.value.processTypea = response.data; |
| | | console.log(response.data); |
| | | |
| | |
| | | }; |
| | | // 处理编辑按钮点击 |
| | | function handleEdit(row) { |
| | | editingUser.value = { ...row }; // 使用展开运算符复制当前行数据 |
| | | userName.value = row.userName; |
| | | adda.value = true; // 显示对话框 |
| | | window.localStorage.setItem('id', row.id) |
| | | |
| | | } |
| | | // 添加 |
| | | const getTableRow = async () => { |
| | | try { |
| | | const response = await request.post('/loadGlass/sys/user/saveUser', { |
| | | userName: userName.value, |
| | | nickName: userName.value, |
| | | password: password.value, |
| | | name: selectedProjectNoa.value, |
| | | roleList: [ |
| | | { |
| | | id: selectedProjectNoa.value, |
| | | // name: selectedProjectNoa.value.name, |
| | | }] |
| | | // roleList: selectedProjectNoa.value.map(item => ({ |
| | | // id: item.id, |
| | | // name: item.name |
| | | // })) |
| | | }); |
| | | |
| | | if (response.code == 200) { |
| | | if (response.code === 200) { |
| | | // 绑定成功,处理逻辑 |
| | | ElMessage.success(response.message); |
| | | add.value = false; |
| | | // tableData.value = response.data; |
| | | tableData.value = response.data; |
| | | } else { |
| | | // 请求失败,显示错误消息 |
| | | ElMessage.error(response.msg); |
| | |
| | | }; |
| | | // 编辑 |
| | | const getTableRowa = async () => { |
| | | let id = window.localStorage.getItem('id') |
| | | try { |
| | | const response = await request.post('/loadGlass/sys/user/updateUser', { |
| | | id: id, |
| | | userName: userName.value, |
| | | password: password.value, |
| | | name: selectedProjectNoa.value, |
| | | }); |
| | | |
| | | if (response.code == 200) { |
| | | roleList: [ |
| | | { |
| | | id: selectedProjectNoa.value, |
| | | // roleKey: selectedProjectNoa.value.id, |
| | | }] |
| | | } |
| | | ); |
| | | if (response.code === 200) { |
| | | // 绑定成功,处理逻辑 |
| | | ElMessage.success(response.message); |
| | | editingUser.value = {}; |
| | | adda.value = false; |
| | | tableData.value = response.data; |
| | | } else { |
| | | // 请求失败,显示错误消息 |
| | | ElMessage.error(response.msg); |
| | | ElMessage.error(response.message); |
| | | } |
| | | } catch (error) { |
| | | // 处理错误 |
| | |
| | | }; |
| | | // 删除 |
| | | const opena = async(row) => { |
| | | try { |
| | | try { |
| | | const confirmResult = await ElMessageBox.confirm( |
| | | '是否删除该用户?', |
| | | '提示', |
| | | t('productStock.deusername'), |
| | | t('productStock.prompt'), |
| | | { |
| | | confirmButtonText: '是', |
| | | cancelButtonText: '取消', |
| | | confirmButtonText: t('productStock.yes'), |
| | | cancelButtonText: t('productStock.cancel'), |
| | | type: 'warning', |
| | | } |
| | | ); |
| | | } |
| | | ); |
| | | if (confirmResult === 'confirm') { |
| | | // 用户点击了“是”,现在调用删除接口 |
| | | const response = await request.post("/loadGlass/sys/user/deleteUser", { |
| | | ids: [row.id], |
| | | }) |
| | | const response = await request.post("/loadGlass/sys/user/deleteUser", [row.id]) |
| | | if (response.code === 200) { |
| | | ElMessage.success(response.message); |
| | | } else { |
| | |
| | | } |
| | | }; |
| | | |
| | | const gridOptions = reactive({ |
| | | border: "full",//表格加边框 |
| | | keepSource: true,//保持源数据 |
| | | align: 'center',//文字居中 |
| | | stripe:true,//斑马纹 |
| | | rowConfig: {isCurrent: true, isHover: true,height: 50},//鼠标移动或选择高亮 |
| | | id: 'OrderList', |
| | | showFooter: true,//显示脚 |
| | | printConfig: {}, |
| | | importConfig: {}, |
| | | exportConfig: {}, |
| | | scrollY:{ enabled: true },//开启虚拟滚动 |
| | | showOverflow:true, |
| | | columnConfig: { |
| | | resizable: true, |
| | | useKey: true |
| | | }, |
| | | filterConfig: { //筛选配置项 |
| | | remote: true |
| | | }, |
| | | customConfig: { |
| | | storage: true |
| | | }, |
| | | editConfig: { |
| | | trigger: 'click', |
| | | mode: 'row', |
| | | showStatus: true |
| | | }, |
| | | data: [ |
| | | { |
| | | 'id': '1', |
| | | 'long': '5', |
| | | 'wide': '1005', |
| | | 'thick': '183.6', |
| | | } |
| | | ] |
| | | |
| | | }) |
| | | </script> |
| | | |
| | | <template> |
| | | <div> |
| | | <el-button type="primary" style="margin-top: 10px;margin-left: 10px;" size="mini" id="searchButton" @click="add = true">添加用户</el-button> |
| | | <el-button type="primary" style="margin-top: 10px;margin-left: 10px;" size="mini" id="searchButton" @click="add = true">{{ $t('productStock.addusers') }}</el-button> |
| | | <el-card style="flex: 1;margin-left: 10px;margin-top: 20px;" v-loading="loading"> |
| | | <div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;"> |
| | | <el-table height="240" ref="table" |
| | | @selection-change="handleSelectionChange" |
| | | :data="tableData" :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}"> |
| | | <el-table-column prop="userName" align="center" label="用户名" min-width="180" /> |
| | | <el-table-column align="center" label="角色" min-width="80"> |
| | | <el-table-column prop="userName" align="center" :label="$t('productStock.username')" min-width="180" /> |
| | | <el-table-column align="center" :label="$t('productStock.role')" min-width="80"> |
| | | <template #default="scope"> |
| | | <el-tag v-for="role in scope.row.roleList"> |
| | | {{role.name}} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column fixed="right" label="操作" align="center" width="200"> |
| | | <el-table-column fixed="right" :label="$t('productStock.operate')" align="center" width="270"> |
| | | <template #default="scope"> |
| | | <el-button size="mini" type="text" plain @click="open(scope.row)">重置密码</el-button> |
| | | <el-button size="mini" type="text" plain @click="handleEdit(scope.row)">编辑</el-button> |
| | | <el-button size="mini" type="text" plain @click="opena(scope.row)">删除</el-button> |
| | | <el-button size="mini" type="text" plain @click="open(scope.row)">{{ $t('productStock.resetpassword') }}</el-button> |
| | | <el-button size="mini" type="text" plain @click="handleEdit(scope.row)">{{ $t('productStock.exit') }}</el-button> |
| | | <el-button size="mini" type="text" plain @click="opena(scope.row)">{{ $t('productStock.delete') }}</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | </el-card> |
| | | </div> |
| | | <el-dialog v-model="add" top="23vh" width="37%" title="添加用户" > |
| | | <el-dialog v-model="add" top="23vh" width="37%" :title="$t('productStock.addusers')"> |
| | | <div style="margin-left: -50px;margin-top: 10px;margin-bottom: 10px;"> |
| | | <el-form size="mini" label-width="150px"> |
| | | <el-form label-width="100px" label-position="right"> |
| | |
| | | <el-col :span="6"> |
| | | <div id="dt" style="font-size: 15px;"> |
| | | <div> |
| | | <el-form-item label="用户名:" :required="true" style="width: 25vw"> |
| | | <el-input v-model="userName" autocomplete="off" /> |
| | | <el-form-item :label="$t('productStock.usernamea')" :required="true" style="width: 25vw"> |
| | | <el-input v-model="userName" autocomplete="off" :placeholder="$t('productStock.inusername')" /> |
| | | </el-form-item></div></div> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | <el-col :span="6"> |
| | | <div id="dt" style="font-size: 15px;"> |
| | | <div> |
| | | <el-form-item label="角色:" :required="true" style="width: 25vw;"> |
| | | <el-form-item :label="$t('productStock.rolea')" :required="true" style="width: 25vw;"> |
| | | <el-select |
| | | v-model="selectedProjectNoa" |
| | | filterable |
| | | clearable |
| | | placeholder="请选择角色" |
| | | :placeholder="$t('productStock.inrole')" |
| | | style="width: 330px" |
| | | > |
| | | <el-option |
| | | v-for="item in titleSelectJsona['processTypea']" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item></div></div> |
| | |
| | | <el-col :span="6"> |
| | | <div id="dt" style="font-size: 15px;"> |
| | | <div> |
| | | <el-form-item label="密码:" :required="true" style="width: 25vw;"> |
| | | <el-form-item :label="$t('productStock.password')" :required="true" style="width: 25vw;"> |
| | | <el-input style="width: 340px;" |
| | | v-model="password" |
| | | :placeholder="$t('productStock.inpassword')" |
| | | autocomplete="off" |
| | | :prefix-icon="Lock" |
| | | show-password/> |
| | |
| | | <template #footer> |
| | | <div id="dialog-footer"> |
| | | <el-button type="primary" @click="getTableRow"> |
| | | 确认 |
| | | {{ $t('productStock.sure') }} |
| | | </el-button> |
| | | <el-button @click="add = false">取消</el-button> |
| | | <el-button @click="add = false">{{ $t('productStock.cancel') }}</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | <el-dialog v-model="adda" top="23vh" width="37%" title="修改用户" > |
| | | <el-dialog v-model="adda" top="23vh" width="37%" :title="$t('productStock.reusername')" > |
| | | <div style="margin-left: -50px;margin-top: 10px;margin-bottom: 10px;"> |
| | | <el-form :model="editingUser" ref="formRef" size="mini" label-width="150px"> |
| | | <el-form ref="formRef" size="mini" label-width="150px"> |
| | | <el-form label-width="100px" label-position="right"> |
| | | <el-row style="margin-top: -15px;margin-bottom: -2px;"> |
| | | <el-col :span="6"> |
| | | <div id="dt" style="font-size: 15px;"> |
| | | <div> |
| | | <el-form-item label="用户名:" :required="true" style="width: 25vw"> |
| | | <el-input v-model="editingUser.userName" autocomplete="off" /> |
| | | <el-form-item :label="$t('productStock.usernamea')" :required="true" style="width: 25vw"> |
| | | <el-input :placeholder="$t('productStock.inusername')" v-model="userName" autocomplete="off" /> |
| | | </el-form-item></div></div> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | <el-col :span="6"> |
| | | <div id="dt" style="font-size: 15px;"> |
| | | <div> |
| | | <!-- <el-table-column align="center" label="角色" min-width="80"> |
| | | <template #default="scope"> |
| | | <el-tag v-for="role in scope.row.roleList"> |
| | | {{role.name}} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> --> |
| | | <el-form-item label="角色:" :required="true" style="width: 25vw;"> |
| | | <el-form-item :label="$t('productStock.rolea')" :required="true" style="width: 25vw;"> |
| | | <el-select |
| | | v-model="selectedProjectNoa" |
| | | filterable |
| | | clearable |
| | | placeholder="请选择角色" |
| | | :placeholder="$t('productStock.inrole')" |
| | | style="width: 330px" |
| | | > |
| | | <el-option |
| | | v-for="item in titleSelectJsona['processTypea']" |
| | | v-for="item in titleSelectJsona['processTypea']" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item></div></div> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row style="margin-top: 10px;"> |
| | | <el-col :span="6"> |
| | | <div id="dt" style="font-size: 15px;"> |
| | | <div> |
| | | <el-form-item label="密码:" :required="true" style="width: 25vw;"> |
| | | <el-input style="width: 340px;" |
| | | v-model="editingUser.password" |
| | | autocomplete="off" |
| | | :prefix-icon="Lock" |
| | | show-password/> |
| | | </el-form-item></div></div> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | <template #footer> |
| | | <div id="dialog-footer"> |
| | | <el-button type="primary" @click="getTableRowa"> |
| | | 确认 |
| | | {{ $t('productStock.sure') }} |
| | | </el-button> |
| | | <el-button @click="adda = false">取消</el-button> |
| | | <el-button @click="adda = false">{{ $t('productStock.cancel') }}</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |