zhoushihao
2024-07-05 f19fc4615ff988192d3077b8d99746657ff5d081
Merge remote-tracking branch 'origin/master'
1个文件已修改
97 ■■■■■ 已修改文件
UI-Project/src/views/User/rolelist.vue 97 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UI-Project/src/views/User/rolelist.vue
@@ -18,7 +18,7 @@
  const name = ref('');
const tableData = ref([])
const options = ref([])
const selectedOptions = ref('')
const selectedOptions = ref([])
// 定义级联选择器的属性  
const cascaderProps = {
  value: 'id',  
@@ -31,27 +31,19 @@
  processType: [],
 
})
// const handleInputChangea = async (value: string) => {
//   if (value) {
//     await fetchOptionsa(value);
//   } else {
//     options.value = []; // 清空选项列表
//   }
// };
onMounted(() => {  
  // 在组件挂载后调用 fetchOptions('') 来加载初始数据(如果需要)
  fetchOptionsa('');  
}); 
  // 角色下拉选  
  const fetchOptionsa = async () => {  
  try {  
    // 发送请求到后端接口
    const response = await request.post('/loadGlass/sys/role/queryRole',{
  key: ''
});  
    if (response.code == 200) {  
     tableData.value = response.data
    // titleSelectJsona.value.processTypea = response.data.menuList;
    // options.value = response.data.menuList
    console.log(response.data);
 
    } else {  
@@ -63,57 +55,82 @@
}; 
// 添加 
const getTableRow = async () => {
  const lastId = selectedOptions.value[selectedOptions.value.length - 1];
  // sendDataToServer(dataToSend);
  console.log(selectedOptions.value[selectedOptions.value.length - 1]);
  // 可以进一步处理,如发送请求等
  try {
  try {
    let menuList = [];
    selectedOptions.value.forEach(array => {
      if (array.length >= 2) {
        let id = array[0];
        let parentId = array[1];
        menuList.push({
          id: id,
          parentId: 0,
          children: [
        {
          id: parentId,
          parentId: id,
        }
      ],
        });
      }
    });
    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);
      menuList: menuList
    };
    const response = await request.post('/loadGlass/sys/role/saveRole', dataToSend);
    if (response.code == 200) {
      // 绑定成功,处理逻辑
      ElMessage.success(response.message);
      add.value = false;
      name.value = '';
       selectedOptions.value = '';
       fetchOptionsa()
      //  tableData.value = response.data;
      selectedOptions.value = '';
      fetchOptionsa();
    } else {
      // 请求失败,显示错误消息
      ElMessage.error(response.message);
    }
  } catch (error) {
    // 处理错误
    console.error(error);
  }
};
// 处理编辑按钮点击  
function handleEdit(row) {  
  name.value = row.name; 
  selectedOptions.value = row.selectedOptions;
  adda.value = true; // 显示对话框
  selectedOptions.value = row.selectedOptions
//  options.value = res.data.tree
 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,
  try {
    let menuList = [];
    selectedOptions.value.forEach(array => {
      if (array.length >= 2) {
        let id = array[0];
        let parentId = array[1];
        menuList.push({
          id: id,
          parentId: 0,
          children: [
        {
          id: parentId,
          parentId: id,
        }
      ],
        });
      }
    });
    const dataToSend = {
      id:id,
      name: name.value,
    });
      menuList: menuList
    };
    const response = await request.post('/loadGlass/sys/role/updateRole', dataToSend);
  // try {
  //   const response = await request.post('/loadGlass/sys/role/updateRole', {
  //     id: id,
  //     name: name.value,
  //   });
 
    if (response.code == 200) {
      // 绑定成功,处理逻辑
@@ -248,7 +265,7 @@
          <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-form-item :label="$t('delivery.choice')" :required="true" style="width: 25vw;">
        <el-cascader 
         v-model="selectedOptions"  
         :placeholder="$t('delivery.inchoice')"