From f848280fe3ed8841147fcc8f26a788580b82ae0c Mon Sep 17 00:00:00 2001 From: liudong <liudong> Date: 星期六, 17 八月 2024 10:37:46 +0800 Subject: [PATCH] 首页页面bug修改 --- src/views/authority/resource/index.vue | 470 +++++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 317 insertions(+), 153 deletions(-) diff --git a/src/views/authority/resource/index.vue b/src/views/authority/resource/index.vue index 38f1e06..b95142c 100644 --- a/src/views/authority/resource/index.vue +++ b/src/views/authority/resource/index.vue @@ -3,8 +3,11 @@ <authheader :items="menuTips"></authheader> <a-row :gutter="20"> <a-col :span="8"> - <a-card :title="$t('menu.resource.title')" :bordered="false" - :style="{ width: '100%',height: '900px', 'overflow-y': 'auto' }"> + <a-card + :title="$t('menu.resource.title')" + :bordered="false" + style=" 'width': '100%'; height: calc(100vh - 250px); 'overflow-y': 'auto' " + > <a-tree class="tree-demo" draggable @@ -12,47 +15,90 @@ :data="treeData" :show-line="showLine" :fieldNames="{ - key:'menuId', - title:'menuName', - children:'children', + key: 'menuId', + title: 'menuName', + children: 'children', }" @drop="onDrop" @select="showDetail" > <template #extra="nodeData"> <IconPlus - style="position: absolute; right: 60px; font-size: 12px; top: 10px; color: #3370ff;" + style=" + position: absolute; + right: 60px; + font-size: 12px; + top: 10px; + color: #3370ff; + " @click="() => onIconClick(nodeData)" /> - <IconDelete style="position: absolute; right: 40px; font-size: 12px; top: 10px; color: #3370ff;" - @click="() => onIconClickDelete(nodeData)" /> + <IconDelete + style=" + position: absolute; + right: 40px; + font-size: 12px; + top: 10px; + color: #3370ff; + " + @click="() => onIconClickDelete(nodeData)" + /> </template> </a-tree> - </a-card> </a-col> <a-col :span="16"> - <a-card :title="$t('menu.resource.detail')" :bordered="false" :style="{ width: '100%' }"> + <a-card + :title="$t('menu.resource.detail')" + :bordered="false" + :style="{ width: '100%' }" + > <a-form :model="resourceform" layout="horizontal"> <a-form-item field="parentName" label="涓婄骇璧勬簮" disabled> <a-input v-model="resourceform.parentName" /> </a-form-item> <a-form-item field="status" label="璧勬簮鐘舵��"> - <a-switch checked-value="0" unchecked-value="1" v-model="resourceform.status"></a-switch> + <a-switch + checked-value="0" + unchecked-value="1" + v-model="resourceform.status" + ></a-switch> </a-form-item> <a-form-item field="menuName" label="璧勬簮鍚嶇О"> <a-input v-model="resourceform.menuName" /> </a-form-item> + <a-form-item field="menuName" label="璧勬簮鍥炬爣"> + <Upload + :action="uploadAction" + :limit="1" + :url="resourceform.icon" + @update:fileList="updateFileList" + @success="handleSuccess" + ></Upload> + </a-form-item> <a-form-item field="menuType" label="璧勬簮绫诲瀷"> - <a-select v-model="resourceform.menuType" :options="options" :field-names="fieldNames" - :style="{width:'320px'}" - placeholder="璇烽�夋嫨" /> - + <a-select + v-model="resourceform.menuType" + :options="options" + :field-names="fieldNames" + :style="{ width: '320px' }" + placeholder="璇烽�夋嫨" + /> + </a-form-item> + <a-form-item field="description" label="鎻愮ず璇�"> + <a-input + v-model="resourceform.description" + placeholder="璇疯緭鍏ユ彁绀鸿瘝" + /> </a-form-item> <a-form-item field="perms" label="璧勬簮鎺у埗鏉冮檺瀛楃"> <a-input v-model="resourceform.perms" /> </a-form-item> - <a-form-item field="component" label="璧勬簮鍦板潃" style="align: start"> + <a-form-item + field="component" + label="璧勬簮鍦板潃" + style="align: start" + > <a-input v-model="resourceform.component" /> </a-form-item> <a-form-item> @@ -65,21 +111,50 @@ </a-card> </a-col> </a-row> - <a-modal width="50%" v-model:visible="visible" title="鏂板" @cancel="handleCancel" @ok="addresource"> - <a-form :model="resourceform" layout="horizontal"> + <a-modal + width="50%" + v-model:visible="visible" + title="鏂板" + @cancel="handleCancel" + @ok="addresource" + > + <a-form :rules="rules" :model="resourceform" layout="horizontal"> <a-form-item field="parentName" label="涓婄骇璧勬簮" disabled> <a-input v-model="resourceform.parentName" /> </a-form-item> <a-form-item field="status" label="璧勬簮鐘舵��"> - <a-switch checked-value="0" unchecked-value="1" v-model="resourceform.status"></a-switch> + <a-switch + checked-value="0" + unchecked-value="1" + v-model="resourceform.status" + ></a-switch> </a-form-item> <a-form-item field="menuName" label="璧勬簮鍚嶇О"> <a-input v-model="resourceform.menuName" /> </a-form-item> + <a-form-item field="icon" label="璧勬簮鍥炬爣"> + <Upload + :action="uploadAction" + :limit="1" + :url="resourceform.icon" + @update:fileList="updateFileList" + @success="handleSuccess" + ></Upload> + </a-form-item> <a-form-item field="menuType" label="璧勬簮绫诲瀷"> - <a-select v-model="resourceform.menuType" :options="options" :field-names="fieldNames" - :style="{width:'320px'}" - placeholder="璇烽�夋嫨" /> + <a-select + v-model="resourceform.menuType" + :options="options" + :field-names="fieldNames" + :style="{ width: '320px' }" + placeholder="璇烽�夋嫨" + /> + </a-form-item> + <a-form-item field="description" label="鎻愮ず璇�"> + <a-input + v-model="resourceform.description" + placeholder="璇疯緭鍏ユ彁绀鸿瘝" + /> </a-form-item> <a-form-item field="perms" label="璧勬簮鎺у埗鏉冮檺瀛楃"> <a-input v-model="resourceform.perms" /> @@ -93,156 +168,245 @@ </template> <script lang="ts" setup> -import { ref } from "vue"; -import { IconPlus } from "@arco-design/web-vue/es/icon"; -import { Resource, ResourceAdd, ResourceById, ResourceDelete, ResourceList, ResourceUpdate } from "@/api/authority"; -import Authheader from "@/views/authority/components/authheader.vue"; -import { Modal } from "@arco-design/web-vue"; + import { ref } from 'vue'; + import { IconPlus } from '@arco-design/web-vue/es/icon'; + import { + Resource, + ResourceAdd, + ResourceById, + ResourceDelete, + ResourceList, + ResourceUpdate, + } from '@/api/authority'; + import Authheader from '@/views/authority/components/authheader.vue'; + import { Modal } from '@arco-design/web-vue'; + import { userModelState } from '@/store'; -let visible = ref(false); -let treeData = ref([]); -let showLine = ref(true); -let menuTips = ref(["鏉冮檺绠$悊", "璧勬簮"]); -const fieldNames = { value: "key", label: "value" }; -// 0鐩綍 1鑿滃崟 2鎸夐挳 -let options = ref([ - { - key: "0", - value: "鐩綍" - }, - { - key: "1", - value: "鑿滃崟" - }, - { - key: "2", - value: "鎸夐挳" - } -]); -let resourceform = ref<Resource>({ - component: "", - createTime: "", - description: "", - icon: "", - menuId: "", - menuName: "", - menuType: "", - orderNum: "", - parentId: "", - parentName: "", - children: [], - path: "", - perms: "", - status: "", - syesourcetype: "", - target: "", - updateTime: "" -}); + const modelStore = userModelState(); -const onIconClick = (nodeData) => { - resourceform.value.parentId = nodeData.menuId; - visible.value = true; -}; - -const addresource = async () => { - await ResourceAdd({ - ...resourceform.value - } as unknown as Resource).then((res) => { - ResourceData(""); + let visible = ref(false); + let treeData = ref([]); + let showLine = ref(true); + let menuTips = ref(['鏉冮檺绠$悊', '璧勬簮']); + const fieldNames = { value: 'key', label: 'value' }; + // 0鐩綍 1鑿滃崟 2鎸夐挳 + let options = ref([ + { + key: '3', + value: '鐩綍', + }, + { + key: '0', + value: '鑿滃崟', + }, + { + key: '1', + value: '鎸夐挳', + }, + ]); + let resourceform = ref<Resource>({ + component: '', + createTime: '', + description: '', + icon: '', + menuId: '', + menuName: '', + menuType: '', + orderNum: '', + parentId: '', + parentName: '', + children: [], + path: '', + perms: '', + status: '', + syesourcetype: '', + target: '', + updateTime: '', }); -}; + const rules = { + // parentName: [ + // { + // required: true, + // message: '璇疯緭鍏ヤ笂绾ц祫婧�', + // }, + // ], + // menuName: [ + // { + // required: true, + // message: '璇疯緭鍏ヨ祫婧愬悕绉�', + // }, + // ], + // menuType: [ + // { + // required: true, + // message: '璇烽�夋嫨璧勬簮绫诲瀷', + // }, + // ], + // description: [ + // { + // required: true, + // message: '璇疯緭鍏ユ彁绀鸿瘝', + // }, + // ], + // perms: [ + // { + // required: true, + // message: '璇疯緭鍏ヨ祫婧愭帶鍒舵潈闄愬瓧绗�', + // }, + // ], + }; -const onIconClickDelete = (nodeData) => { - ResourceDelete(nodeData.menuId).then(() => { - ResourceData(""); - }); -}; + const onIconClick = (nodeData) => { + if (nodeData) { + resourceform.value.parentId = nodeData.menuId; + resourceform.value.parentName = nodeData.menuName; + } + resourceform.value.component = ''; + resourceform.value.createTime = ''; + resourceform.value.description = ''; + resourceform.value.icon = ''; + resourceform.value.menuId = ''; + resourceform.value.menuName = ''; + resourceform.value.menuType = ''; + resourceform.value.orderNum = '0'; + resourceform.value.path = ''; + resourceform.value.perms = ''; + resourceform.value.status = ''; + resourceform.value.syesourcetype = ''; -const showDetail = (id) => { - ResourceById(id).then((res) => { - resourceform.value = { ...res.data }; - }); -}; -const editresource = () => { - ResourceUpdate({ - ...resourceform.value - } as unknown as Resource).then((res) => { - ResourceData(""); - Modal.success({ - title: "淇濆瓨鎴愬姛", - content: "淇濆瓨鎴愬姛" + visible.value = true; + }; + const formRef = ref(); + //鍥剧墖涓婁紶 + const uploadAction = '/api/v1/llm/upload'; // 鏇挎崲涓轰綘鐨勪笂浼燗PI + const fileList = ref([]); + const imageUrls = ref([]); + const uploadUrl = ref([]); + const httpUrl = modelStore.hrefUrl; + const updateFileList = (newFileList) => { + fileList.value = newFileList; + }; + + const handleSuccess = (urls) => { + uploadUrl.value = urls; + + const urlsArr = urls.map((url) => { + return httpUrl + url; }); - }); -}; -const reset = (id) => { - ResourceById(id).then((res) => { - resourceform.value = { ...res.data }; - }); -}; + imageUrls.value = urlsArr; // 鎷垮埌涓婁紶鐨勫浘鐗囧湴鍧� + }; -const onDrop = ({ dragNode, dropNode, dropPosition }) => { - const data = treeData.value; - ResourceUpdate({ - orderNum: "0", parentId: dropNode.menuId, menuId: dragNode.menuId - }); - const loop = (data, key, callback) => { - data.some((item, index, arr) => { - if (item.menuId === key) { - callback(item, index, arr); - return true; - } - if (item.children) { - return loop(item.children, key, callback); - } - return false; + const addresource = async (done) => { + // formRef.value.validate().then(async (res) => { + // if (!res) { + // } + // done(false); + // }); + + resourceform.value.icon = uploadUrl.value[0] || ''; + await ResourceAdd({ + ...resourceform.value, + } as unknown as Resource).then((res) => { + ResourceData(''); }); }; - loop(data, dragNode.menuId, (_, index, arr) => { - arr.splice(index, 1); - }); - - if (dropPosition === 0) { - loop(data, dropNode.menuId, (item) => { - item.children = item.children || []; - item.children.push(dragNode); + const onIconClickDelete = (nodeData) => { + ResourceDelete(nodeData.menuId).then(() => { + ResourceData(''); }); - } else { - loop(data, dropNode.menuId, (_, index, arr) => { - arr.splice(dropPosition < 0 ? index : index + 1, 0, dragNode); + }; + + const showDetail = (id) => { + ResourceById(id).then((res) => { + resourceform.value = { ...res.data }; + resourceform.value.icon = res.data.icon; + + imageUrls.value.push(httpUrl + res.data.icon); }); - } -}; + }; + const editresource = () => { + resourceform.value.icon = uploadUrl.value[0] || ''; + ResourceUpdate({ + ...resourceform.value, + } as unknown as Resource).then((res) => { + ResourceData(''); + Modal.success({ + title: '淇濆瓨鎴愬姛', + content: '淇濆瓨鎴愬姛', + }); + }); + }; + const reset = (id) => { + ResourceById(id).then((res) => { + resourceform.value = { ...res.data }; + }); + }; -const handleCancel = (type) => { - if (type == 1) { - visible.value = false; - } -}; + const onDrop = ({ dragNode, dropNode, dropPosition }) => { + const data = treeData.value; + ResourceUpdate({ + orderNum: '0', + parentId: dropNode.menuId, + menuId: dragNode.menuId, + }); + const loop = (data, key, callback) => { + data.some((item, index, arr) => { + if (item.menuId === key) { + callback(item, index, arr); + return true; + } + if (item.children) { + return loop(item.children, key, callback); + } + return false; + }); + }; -const ResourceData = async (key) => { - await ResourceList(key).then((res) => { - treeData.value = [...res.rows]; - }); -}; + loop(data, dragNode.menuId, (_, index, arr) => { + arr.splice(index, 1); + }); -ResourceData(""); + if (dropPosition === 0) { + loop(data, dropNode.menuId, (item) => { + item.children = item.children || []; + item.children.push(dragNode); + }); + } else { + loop(data, dropNode.menuId, (_, index, arr) => { + arr.splice(dropPosition < 0 ? index : index + 1, 0, dragNode); + }); + } + }; + + const handleCancel = (type) => { + if (type == 1) { + visible.value = false; + } + }; + + const ResourceData = async (key) => { + await ResourceList(key).then((res) => { + treeData.value = [...res.rows]; + }); + }; + + ResourceData(''); </script> - <style scoped> -.tree-demo :deep(.tree-node-dropover) > :deep(.arco-tree-node-title), -.tree-demo :deep(.tree-node-dropover) > :deep(.arco-tree-node-title):hover { - animation: blinkBg 0.4s 2; -} - -@keyframes blinkBg { - 0% { - background-color: transparent; + .tree-demo :deep(.tree-node-dropover) > :deep(.arco-tree-node-title), + .tree-demo :deep(.tree-node-dropover) > :deep(.arco-tree-node-title):hover { + animation: blinkBg 0.4s 2; } - 100% { - background-color: var(--color-primary-light-1); + @keyframes blinkBg { + 0% { + background-color: transparent; + } + + 100% { + background-color: var(--color-primary-light-1); + } } -} </style> -- Gitblit v1.8.0