From 7e5796e4813bb1f4d2696a0fd05f408147c3b96e Mon Sep 17 00:00:00 2001 From: wangfei <3597712270@qq.com> Date: 星期三, 11 六月 2025 15:16:01 +0800 Subject: [PATCH] 所有项目必填判断 --- UI-Project/src/views/User/permissions.vue | 206 +++++++++++++++++++++++++------------------------- 1 files changed, 103 insertions(+), 103 deletions(-) diff --git a/UI-Project/src/views/User/permissions.vue b/UI-Project/src/views/User/permissions.vue index 64f41a6..e3445ad 100644 --- a/UI-Project/src/views/User/permissions.vue +++ b/UI-Project/src/views/User/permissions.vue @@ -7,58 +7,40 @@ const adda = ref(false) const addc = ref(false) const addb = ref(false) - import { useI18n } from 'vue-i18n' - const { t } = useI18n() - let language = ref(localStorage.getItem('lang') || 'zh') +const { t } = useI18n() +let language = ref(localStorage.getItem('lang') || 'zh') import request from "@/utils/request" import { ref, onMounted } from "vue"; -// import { ref } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' -// import LanguageMixin from './lang/LanguageMixin' const selectedProjectNoa = ref(''); // 褰撳墠閫変腑鐨勮鑹� -// const options = ref<any[]>([]); // 涓嬫媺閫夐」鍒楄〃 - const menuName = ref(''); - const listSort = ref(''); - const url = ref(''); +const menuName = ref(''); +const listSort = ref(''); +const url = ref(''); const currentRow = reactive({}); // 褰撳墠琛岀殑鏁版嵁 const tableData = ref([]) const slot = ref('') request.get("/loadGlass/sys/menu/nav").then((res) => { if (res.code == 200) { - console.log(res.data); tableData.value = res.data.tree } else { ElMessage.warning(res.msg) - } }); const titleSelectJsona = ref({ processType: [], - }) -// const handleInputChangea = async (value: string) => { -// if (value) { -// await fetchOptionsa(value); -// } else { -// options.value = []; // 娓呯┖閫夐」鍒楄〃 -// } -// }; -onMounted(() => { - // 鍦ㄧ粍浠舵寕杞藉悗璋冪敤 fetchOptions('') 鏉ュ姞杞藉垵濮嬫暟鎹紙濡傛灉闇�瑕侊級 +onMounted(() => { fetchOptionsa(''); }); // 瑙掕壊涓嬫媺閫� const fetchOptionsa = async () => { try { - // 鍙戦�佽姹傚埌鍚庣鎺ュ彛 const response = await request.post('/loadGlass/sys/role/queryRole',{ - key: '' -}); + key: '' + }); if (response.code === 200) { titleSelectJsona.value.processTypea = response.data; - console.log(response.data); - } else { ElMessage.warning(response.data); } @@ -67,13 +49,9 @@ } }; const handleBindRack = (row) => { - // selectedRow.value = row; // 鏇存柊閫変腑鐨勮鏁版嵁 currentRow.menuName = row.menuName; // 鐩存帴璁剧疆鍝嶅簲寮忓睘鎬� - currentRow.id = row.id; // 鐩存帴璁剧疆鍝嶅簲寮忓睘鎬� - // currentRow.slot = row.slot; - // window.localStorage.setItem('deviceId', row.deviceId) - // window.localStorage.setItem('slot', row.slot) - addb.value = true; // 鎵撳紑缁戝畾鏋跺瓙瀵硅瘽妗� + currentRow.id = row.id; + addb.value = true; }; function closeDialog(row) { add.value = false; @@ -101,6 +79,18 @@ } // 娣诲姞涓�绾ц彍鍗� const getTableRow = async () => { + if (!menuName.value) { + ElMessage.error(t('customer.inmenu')) + return + } + if (!url.value) { + ElMessage.error(t('customer.inlink')) + return + } + if (!listSort.value) { + ElMessage.error(t('customer.insort')) + return + } try { const response = await request.post('/loadGlass/sys/menu/save', { menuName: menuName.value, @@ -109,39 +99,42 @@ }); if (response.code === 200) { - // 缁戝畾鎴愬姛锛屽鐞嗛�昏緫 ElMessage.success(response.message); add.value = false; - tableData.value = response.data; - menuName.value = ''; - listSort.value = ''; - url.value = ''; + tableData.value = response.data; + menuName.value = ''; + listSort.value = ''; + url.value = ''; } else { - // 璇锋眰澶辫触锛屾樉绀洪敊璇秷鎭� ElMessage.error(response.msg); } } catch (error) { - // 澶勭悊閿欒 console.error(error); } }; // 娣诲姞浜岀骇鑿滃崟 const getTableRowb = async () => { + if (!menuName.value) { + ElMessage.error(t('customer.inmenu')) + return + } + if (!url.value) { + ElMessage.error(t('customer.inlink')) + return + } + if (!listSort.value) { + ElMessage.error(t('customer.insort')) + return + } try { const dataToSend = { parentId: currentRow.id, - // menuName: currentRow.menuName, - // children: [ - // { menuName: menuName.value, listSort: listSort.value, url: url.value, - // } - // ] }; const response = await request.post('/loadGlass/sys/menu/save',dataToSend ); if (response.code === 200) { - // 缁戝畾鎴愬姛锛屽鐞嗛�昏緫 ElMessage.success(response.message); addb.value = false; tableData.value = response.data; @@ -149,11 +142,9 @@ listSort.value = ''; url.value = ''; } else { - // 璇锋眰澶辫触锛屾樉绀洪敊璇秷鎭� ElMessage.error(response.msg); } } catch (error) { - // 澶勭悊閿欒 console.error(error); } }; @@ -162,17 +153,29 @@ listSort.value = row.listSort; menuName.value = row.menuName; url.value = row.url; - adda.value = true; // 鏄剧ず瀵硅瘽妗� + adda.value = true; } // 淇敼浜岀骇鑿滃崟 function handleEditc(row) { listSort.value = row.listSort; menuName.value = row.menuName; url.value = row.url; - addc.value = true; // 鏄剧ず瀵硅瘽妗� + addc.value = true; } // 缂栬緫 const getTableRowa = async () => { + if (!menuName.value) { + ElMessage.error(t('customer.inmenu')) + return + } + if (!url.value) { + ElMessage.error(t('customer.inlink')) + return + } + if (!listSort.value) { + ElMessage.error(t('customer.insort')) + return + } try { const response = await request.post('/loadGlass/sys/menu/updateMenu', { parentId: currentRow.id, @@ -181,24 +184,33 @@ url: url.value, }); if (response.code === 200) { - // 缁戝畾鎴愬姛锛屽鐞嗛�昏緫 ElMessage.success(response.message); adda.value = false; - tableData.value = response.data; - menuName.value = ''; - listSort.value = ''; - url.value = ''; + tableData.value = response.data; + menuName.value = ''; + listSort.value = ''; + url.value = ''; } else { - // 璇锋眰澶辫触锛屾樉绀洪敊璇秷鎭� ElMessage.error(response.msg); } } catch (error) { - // 澶勭悊閿欒 console.error(error); } }; // 缂栬緫浜岀骇鑿滃崟 const getTableRowac = async () => { + if (!menuName.value) { + ElMessage.error(t('customer.inmenu')) + return + } + if (!url.value) { + ElMessage.error(t('customer.inlink')) + return + } + if (!listSort.value) { + ElMessage.error(t('customer.insort')) + return + } try { const response = await request.post('/loadGlass/sys/menu/updateMenu', { menuName: menuName.value, @@ -206,19 +218,16 @@ url: url.value, }); if (response.code === 200) { - // 缁戝畾鎴愬姛锛屽鐞嗛�昏緫 ElMessage.success(response.message); addc.value = false; - tableData.value = response.data; - menuName.value = ''; - listSort.value = ''; - url.value = ''; + tableData.value = response.data; + menuName.value = ''; + listSort.value = ''; + url.value = ''; } else { - // 璇锋眰澶辫触锛屾樉绀洪敊璇秷鎭� ElMessage.error(response.msg); } } catch (error) { - // 澶勭悊閿欒 console.error(error); } }; @@ -234,35 +243,29 @@ type: 'warning', } ); - if (confirmResult === 'confirm') { - // 鐢ㄦ埛鐐瑰嚮浜嗏�滄槸鈥濓紝鐜板湪璋冪敤鍒犻櫎鎺ュ彛 + if (confirmResult === 'confirm') { const response = await request.post("/loadGlass/sys/menu/deleteMenu", { menuId: row.id, }) if (response.code === 200) { ElMessage.success(response.message); - } else { - // 鍒犻櫎澶辫触锛屾偍鍙互澶勭悊閿欒鎴栨樉绀洪敊璇俊鎭粰鐢ㄦ埛 + } else { ElMessage.error(response.msg); - // alert('鍒犻櫎澶辫触锛�' + deleteResponse.message); } } - } catch (error) { - // 澶勭悊鍙兘鍑虹幇鐨勯敊璇紝姣斿 ElMessageBox 鎶涘嚭鐨勫紓甯哥瓑 + } catch (error) { console.error('鍙戠敓閿欒:', error); } -}; - +}; </script> - <template> <div style="height: 600px;"> - <el-button type="primary" style="margin-top: 10px;margin-left: 10px;" size="mini" id="searchButton" @click="add = true">{{ $t('customer.addmenu') }}</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;max-height: 650px;"> - <el-table + <el-button type="primary" style="margin-top: 10px;margin-left: 10px;" id="searchButton" @click="add = true">{{ $t('customer.addmenu') }}</el-button> + <el-card style="flex: 1;margin-left: 10px;margin-top: 20px;"> + <div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;max-height: 750px;"> + <el-table :data="tableData" - height="550" + height="750" @expand-change="handleExpandChange" row-key="id" :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}" @@ -277,27 +280,27 @@ row-key="id" :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}" > - <el-table-column prop="menuName" :label="$t('customer.semenu')" align="center" min-width="140" :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}"/> - <el-table-column prop="url" :label="$t('customer.link')" align="center" min-width="160"/> + <el-table-column prop="menuName" :label="$t('customer.semenu')" align="center" min-width="140" :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}"/> + <el-table-column prop="url" :label="$t('customer.link')" align="center" min-width="160"/> <el-table-column prop="listSort" align="center" :label="$t('customer.sort')" min-width="140"/> - <el-table-column fixed="right" :label="$t('customer.operate')" align="center"> + <el-table-column fixed="right" :label="$t('customer.operate')" align="center"> <template #default="scope"> - <el-button size="mini" type="text" plain @click="handleEditc(scope.row)">{{ $t('customer.exit') }}</el-button> - <el-button size="mini" type="text" plain @click="opena(scope.row)">{{ $t('customer.delete') }}</el-button> + <el-button type="text" plain @click="handleEditc(scope.row)">{{ $t('customer.exit') }}</el-button> + <el-button type="text" plain @click="opena(scope.row)">{{ $t('customer.delete') }}</el-button> </template> </el-table-column> - </el-table> - </div> - </template> - </el-table-column> + </el-table> + </div> + </template> + </el-table-column> <el-table-column prop="menuName" :label="$t('customer.firstmenu')" align="center" min-width="120" /> - <el-table-column prop="url" :label="$t('customer.link')" align="center" min-width="200"/> + <el-table-column prop="url" :label="$t('customer.link')" align="center" min-width="200"/> <el-table-column prop="listSort" align="center" :label="$t('customer.sort')" min-width="180" /> <el-table-column fixed="right" :label="$t('customer.operate')" align="center" width="200"> <template #default="scope"> - <el-button size="mini" type="text" plain @click="handleBindRack(scope.row)">{{ $t('customer.addmenua') }}</el-button> - <el-button size="mini" type="text" plain @click="handleEdit(scope.row)">{{ $t('customer.exit') }}</el-button> - <el-button size="mini" type="text" plain @click="opena(scope.row)">{{ $t('customer.delete') }}</el-button> + <el-button type="text" plain @click="handleBindRack(scope.row)">{{ $t('customer.addmenua') }}</el-button> + <el-button type="text" plain @click="handleEdit(scope.row)">{{ $t('customer.exit') }}</el-button> + <el-button type="text" plain @click="opena(scope.row)">{{ $t('customer.delete') }}</el-button> </template> </el-table-column> </el-table> @@ -306,7 +309,7 @@ </div> <el-dialog v-model="add" top="23vh" width="37%" :title="$t('customer.addmenu')"> <div style="margin-left: -50px;margin-top: 10px;margin-bottom: 10px;"> - <el-form size="mini" label-width="150px"> + <el-form label-width="150px"> <el-form label-width="150px" label-position="right"> <el-row style="margin-top: -15px;margin-bottom: -2px;"> <el-col :span="6"> @@ -353,9 +356,8 @@ <el-row style="margin-top: -15px;margin-bottom: -2px;"> <el-col :span="6"> <div id="dt" style="font-size: 15px;"> - <el-form-item :label="$t('customer.firstmenuname')" style="width: 22vw"> - <!-- {{ currentRow.menuName }} --> - <el-input disabled v-model="currentRow.menuName" autocomplete="off"></el-input> + <el-form-item :label="$t('customer.firstmenuname')" style="width: 25vw"> + <el-input disabled v-model="currentRow.menuName" autocomplete="off" style="width: 330px;"></el-input> </el-form-item> </div> </el-col> @@ -363,14 +365,14 @@ </el-form> </div> <div style="margin-left: -50px;margin-top: 10px;margin-bottom: 10px;"> - <el-form size="mini" label-width="150px"> + <el-form label-width="150px"> <el-form label-width="150px" 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('customer.semenuname')" :required="true" style="width: 25vw"> - <el-input v-model="menuName" autocomplete="off" :placeholder="$t('customer.inmenu')"/> + <el-input v-model="menuName" autocomplete="off" :placeholder="$t('customer.inmenu')" style="width: 350px;"/> </el-form-item></div></div> </el-col> </el-row> @@ -379,7 +381,7 @@ <div id="dt" style="font-size: 15px;"> <div> <el-form-item :label="$t('customer.linka')" :required="true" style="width: 25vw"> - <el-input v-model="url" autocomplete="off" :placeholder="$t('customer.inlink')"/> + <el-input v-model="url" autocomplete="off" :placeholder="$t('customer.inlink')" style="width: 350px;"/> </el-form-item></div></div> </el-col> </el-row> @@ -388,7 +390,7 @@ <div id="dt" style="font-size: 15px;"> <div> <el-form-item :label="$t('customer.sorta')" :required="true" style="width: 25vw"> - <el-input v-model="listSort" autocomplete="off" :placeholder="$t('customer.insort')"/> + <el-input v-model="listSort" autocomplete="off" :placeholder="$t('customer.insort')" style="width: 350px;"/> </el-form-item></div></div> </el-col> </el-row> @@ -406,7 +408,7 @@ </el-dialog> <el-dialog v-model="adda" top="23vh" width="37%" :title="$t('customer.exmene')"> <div style="margin-left: -50px;margin-top: 10px;margin-bottom: 10px;"> - <el-form ref="formRef" size="mini" label-width="150px"> + <el-form ref="formRef" label-width="150px"> <el-form label-width="100px" label-position="right"> <el-row style="margin-top: -15px;margin-bottom: -2px;"> <el-col :span="6"> @@ -449,7 +451,7 @@ </el-dialog> <el-dialog v-model="addc" top="23vh" width="37%" :title="$t('customer.exmenea')"> <div style="margin-left: -50px;margin-top: 10px;margin-bottom: 10px;"> - <el-form ref="formRef" size="mini" label-width="150px"> + <el-form ref="formRef" label-width="150px"> <el-form label-width="100px" label-position="right"> <el-row style="margin-top: -15px;margin-bottom: -2px;"> <el-col :span="6"> @@ -491,9 +493,7 @@ </template> </el-dialog> </template> - <style scoped> - #dt { display:block; float:left;line-height: 20px;margin-left: 100px;} #dta { display:block; float:left;line-height: 20px;margin-left: 80%;} #dialog-footer{ -- Gitblit v1.8.0