| | |
| | | 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' |
| | |
| | | const selectedProjectNoa = ref(''); // 当前选中的角色 |
| | | // const options = ref<any[]>([]); // 下拉选项列表 |
| | | const name = ref(''); |
| | | |
| | | const tableData = ref([]) |
| | | const options = ref([]) |
| | | const selectedOptions = ref('') |
| | | // 定义级联选择器的属性 |
| | | const cascaderProps = { |
| | | value: 'id', |
| | | label: 'menuName', |
| | | multiple: true |
| | | }; |
| | | const slot = ref('') |
| | | |
| | | const titleSelectJsona = ref({ |
| | |
| | | }; |
| | | // 添加 |
| | | const getTableRow = async () => { |
| | | |
| | | const lastId = selectedOptions.value[selectedOptions.value.length - 1]; |
| | | // sendDataToServer(dataToSend); |
| | | console.log(selectedOptions.value[selectedOptions.value.length - 1]); |
| | | // 可以进一步处理,如发送请求等 |
| | | try { |
| | | const response = await request.post('/loadGlass/sys/role/saveRole', { |
| | | const dataToSend = { |
| | | name: name.value, |
| | | }); |
| | | |
| | | // id: selectedOptions.value, |
| | | menuList: [lastId] |
| | | // [ |
| | | // { |
| | | // menuName: selectedOptions.value, |
| | | // selectedOptions.value, |
| | | // } |
| | | // ] |
| | | }; |
| | | const response = await request.post('/loadGlass/sys/role/saveRole', dataToSend); |
| | | if (response.code == 200) { |
| | | // 绑定成功,处理逻辑 |
| | | ElMessage.success(response.message); |
| | | add.value = false; |
| | | // tableData.value = response.data; |
| | | name.value = ''; |
| | | selectedOptions.value = ''; |
| | | fetchOptionsa() |
| | | // tableData.value = response.data; |
| | | } else { |
| | | // 请求失败,显示错误消息 |
| | | ElMessage.error(response.msg); |
| | | ElMessage.error(response.message); |
| | | } |
| | | } catch (error) { |
| | | // 处理错误 |
| | |
| | | }; |
| | | // 处理编辑按钮点击 |
| | | function handleEdit(row) { |
| | | editingUser.value = { ...row }; // 使用展开运算符复制当前行数据 |
| | | name.value = row.name; |
| | | selectedOptions.value = row.selectedOptions; |
| | | adda.value = true; // 显示对话框 |
| | | window.localStorage.setItem('id', row.id) |
| | | } |
| | | // 编辑 |
| | | const getTableRowa = async () => { |
| | | let id = window.localStorage.getItem('id') |
| | | |
| | | try { |
| | | const response = await request.post('/loadGlass/sys/role/updateRole', { |
| | | id: id, |
| | | name: name.value, |
| | | |
| | | }); |
| | | |
| | | if (response.code == 200) { |
| | | // 绑定成功,处理逻辑 |
| | | ElMessage.success(response.message); |
| | | editingUser.value = {}; |
| | | adda.value = false; |
| | | tableData.value = response.data; |
| | | name.value = ''; |
| | | selectedOptions.value = ''; |
| | | fetchOptionsa() |
| | | tableData.value = response.data; |
| | | } else { |
| | | // 请求失败,显示错误消息 |
| | | ElMessage.error(response.msg); |
| | | ElMessage.error(response.message); |
| | | } |
| | | } catch (error) { |
| | | // 处理错误 |
| | |
| | | ); |
| | | if (confirmResult === 'confirm') { |
| | | // 用户点击了“是”,现在调用删除接口 |
| | | const response = await request.post("/loadGlass/sys/role/delete", { |
| | | ids: row.id, |
| | | }) |
| | | const response = await request.post("/loadGlass/sys/role/delete",[row.id]) |
| | | if (response.code === 200) { |
| | | ElMessage.success(response.message); |
| | | fetchOptionsa() |
| | | } else { |
| | | // 删除失败,您可以处理错误或显示错误信息给用户 |
| | | ElMessage.error(response.msg); |
| | | ElMessage.error(response.message); |
| | | // alert('删除失败:' + deleteResponse.message); |
| | | } |
| | | } |
| | |
| | | // 处理可能出现的错误,比如 ElMessageBox 抛出的异常等 |
| | | console.error('发生错误:', error); |
| | | } |
| | | }; |
| | | }; |
| | | request.get("/loadGlass/sys/menu/nav").then((res) => { |
| | | if (res.code == 200) { |
| | | console.log(res.data); |
| | | options.value = res.data.tree |
| | | console.log( options.value); |
| | | } else { |
| | | ElMessage.warning(res.msg) |
| | | } |
| | | }); |
| | | </script> |
| | | |
| | | <template> |
| | |
| | | </div> |
| | | </el-card> |
| | | </div> |
| | | <el-dialog v-model="add" top="23vh" width="37%" :title="$t('delivery.addrole')" > |
| | | <el-dialog v-model="add" top="23vh" width="37%" :title="$t('productStock.addusername')" > |
| | | <div style="margin-left: -50px;margin-top: 10px;margin-bottom: 10px;"> |
| | | <el-form 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> |
| | | <el-form-item :label="$t('delivery.rolea')" :required="true" style="width: 25vw"> |
| | | <el-input :placeholder="$t('delivery.inrole')" v-model="name" autocomplete="off" /> |
| | | </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="$t('delivery.choice')" :required="true" style="width: 25vw;"> |
| | | <el-cascader |
| | | v-model="selectedOptions" |
| | | :placeholder="$t('delivery.inchoice')" |
| | | :props="cascaderProps" |
| | | :options="options" |
| | | style="width: 330px" |
| | | clearable /> |
| | | </el-form-item></div></div> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | </el-dialog> |
| | | <el-dialog v-model="adda" top="23vh" width="37%" :title="$t('delivery.editrole')"> |
| | | <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="$t('delivery.rolea')" :required="true" style="width: 25vw"> |
| | | <el-input :placeholder="$t('delivery.inrole')" v-model="editingUser.name" autocomplete="off" /> |
| | | <el-input :placeholder="$t('delivery.inrole')" v-model="name" autocomplete="off" /> |
| | | </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="$t('delivery.choice')" :required="true" style="width: 25vw;"> |
| | | <el-cascader |
| | | v-model="selectedOptions" |
| | | :placeholder="$t('delivery.inchoice')" |
| | | :props="cascaderProps" |
| | | :options="options" |
| | | style="width: 330px" |
| | | clearable /> |
| | | </el-form-item></div></div> |
| | | </el-col> |
| | | </el-row> |