diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts index e459224..1eb5e30 100644 --- a/frontend/src/api/index.ts +++ b/frontend/src/api/index.ts @@ -107,6 +107,8 @@ class RequestHttp { download(url: string, params?: object, _object = {}): Promise { return this.service.post(url, params, { ..._object, responseType: "blob" }); } + + } export default new RequestHttp(config); diff --git a/frontend/src/styles/element.scss b/frontend/src/styles/element.scss index 037f605..ab4ce1e 100644 --- a/frontend/src/styles/element.scss +++ b/frontend/src/styles/element.scss @@ -306,8 +306,6 @@ // font-family:; .el-dialog__headerbtn { - top: 5px; - .el-icon { color: var(--el-color-white); } diff --git a/frontend/src/utils/elementBind.ts b/frontend/src/utils/elementBind.ts index cd7036e..4b4d3c3 100644 --- a/frontend/src/utils/elementBind.ts +++ b/frontend/src/utils/elementBind.ts @@ -1,5 +1,5 @@ export const dialogSmall = { - width:'400px', + width:'500px', closeOnClickModal:false, draggable:true, class:'dialog-small' diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index f604164..10680f6 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -1,7 +1,7 @@ -import { isArray } from "@/utils/is"; -import { FieldNamesProps } from "@/components/ProTable/interface"; +import { isArray } from '@/utils/is' +import { FieldNamesProps } from '@/components/ProTable/interface' -const mode = import.meta.env.VITE_ROUTER_MODE; +const mode = import.meta.env.VITE_ROUTER_MODE /** * @description 获取localStorage @@ -9,12 +9,12 @@ const mode = import.meta.env.VITE_ROUTER_MODE; * @returns {String} */ export function localGet(key: string) { - const value = window.localStorage.getItem(key); - try { - return JSON.parse(window.localStorage.getItem(key) as string); - } catch (error) { - return value; - } + const value = window.localStorage.getItem(key) + try { + return JSON.parse(window.localStorage.getItem(key) as string) + } catch (error) { + return value + } } /** @@ -24,7 +24,7 @@ export function localGet(key: string) { * @returns {void} */ export function localSet(key: string, value: any) { - window.localStorage.setItem(key, JSON.stringify(value)); + window.localStorage.setItem(key, JSON.stringify(value)) } /** @@ -33,7 +33,7 @@ export function localSet(key: string, value: any) { * @returns {void} */ export function localRemove(key: string) { - window.localStorage.removeItem(key); + window.localStorage.removeItem(key) } /** @@ -41,7 +41,7 @@ export function localRemove(key: string) { * @returns {void} */ export function localClear() { - window.localStorage.clear(); + window.localStorage.clear() } /** @@ -50,9 +50,9 @@ export function localClear() { * @returns {String} */ export function isType(val: any) { - if (val === null) return "null"; - if (typeof val !== "object") return typeof val; - else return Object.prototype.toString.call(val).slice(8, -1).toLocaleLowerCase(); + if (val === null) return 'null' + if (typeof val !== 'object') return typeof val + else return Object.prototype.toString.call(val).slice(8, -1).toLocaleLowerCase() } /** @@ -60,13 +60,13 @@ export function isType(val: any) { * @returns {String} */ export function generateUUID() { - let uuid = ""; - for (let i = 0; i < 32; i++) { - let random = (Math.random() * 16) | 0; - if (i === 8 || i === 12 || i === 16 || i === 20) uuid += "-"; - uuid += (i === 12 ? 4 : i === 16 ? (random & 3) | 8 : random).toString(16); - } - return uuid; + let uuid = '' + for (let i = 0; i < 32; i++) { + let random = (Math.random() * 16) | 0 + if (i === 8 || i === 12 || i === 16 || i === 20) uuid += '-' + uuid += (i === 12 ? 4 : i === 16 ? (random & 3) | 8 : random).toString(16) + } + return uuid } /** @@ -76,22 +76,22 @@ export function generateUUID() { * @returns {Boolean} 相同返回 true,反之 false */ export function isObjectValueEqual(a: { [key: string]: any }, b: { [key: string]: any }) { - if (!a || !b) return false; - let aProps = Object.getOwnPropertyNames(a); - let bProps = Object.getOwnPropertyNames(b); - if (aProps.length != bProps.length) return false; - for (let i = 0; i < aProps.length; i++) { - let propName = aProps[i]; - let propA = a[propName]; - let propB = b[propName]; - if (!b.hasOwnProperty(propName)) return false; - if (propA instanceof Object) { - if (!isObjectValueEqual(propA, propB)) return false; - } else if (propA !== propB) { - return false; + if (!a || !b) return false + let aProps = Object.getOwnPropertyNames(a) + let bProps = Object.getOwnPropertyNames(b) + if (aProps.length != bProps.length) return false + for (let i = 0; i < aProps.length; i++) { + let propName = aProps[i] + let propA = a[propName] + let propB = b[propName] + if (!b.hasOwnProperty(propName)) return false + if (propA instanceof Object) { + if (!isObjectValueEqual(propA, propB)) return false + } else if (propA !== propB) { + return false + } } - } - return true; + return true } /** @@ -101,8 +101,8 @@ export function isObjectValueEqual(a: { [key: string]: any }, b: { [key: string] * @returns {Number} */ export function randomNum(min: number, max: number): number { - let num = Math.floor(Math.random() * (min - max) + max); - return num; + let num = Math.floor(Math.random() * (min - max) + max) + return num } /** @@ -110,13 +110,13 @@ export function randomNum(min: number, max: number): number { * @returns {String} */ export function getTimeState() { - let timeNow = new Date(); - let hours = timeNow.getHours(); - if (hours >= 6 && hours <= 10) return `早上好 ⛅`; - if (hours >= 10 && hours <= 14) return `中午好 🌞`; - if (hours >= 14 && hours <= 18) return `下午好 🌞`; - if (hours >= 18 && hours <= 24) return `晚上好 🌛`; - if (hours >= 0 && hours <= 6) return `凌晨好 🌛`; + let timeNow = new Date() + let hours = timeNow.getHours() + if (hours >= 6 && hours <= 10) return `早上好 ⛅` + if (hours >= 10 && hours <= 14) return `中午好 🌞` + if (hours >= 14 && hours <= 18) return `下午好 🌞` + if (hours >= 18 && hours <= 24) return `晚上好 🌛` + if (hours >= 0 && hours <= 6) return `凌晨好 🌛` } /** @@ -124,14 +124,14 @@ export function getTimeState() { * @returns {String} */ export function getBrowserLang() { - let browserLang = navigator.language ? navigator.language : navigator.browserLanguage; - let defaultBrowserLang = ""; - if (["cn", "zh", "zh-cn"].includes(browserLang.toLowerCase())) { - defaultBrowserLang = "zh"; - } else { - defaultBrowserLang = "en"; - } - return defaultBrowserLang; + let browserLang = navigator.language ? navigator.language : navigator.browserLanguage + let defaultBrowserLang = '' + if (['cn', 'zh', 'zh-cn'].includes(browserLang.toLowerCase())) { + defaultBrowserLang = 'zh' + } else { + defaultBrowserLang = 'en' + } + return defaultBrowserLang } /** @@ -139,11 +139,11 @@ export function getBrowserLang() { * @returns {String} */ export function getUrlWithParams() { - const url = { - hash: location.hash.substring(1), - history: location.pathname + location.search - }; - return url[mode]; + const url = { + hash: location.hash.substring(1), + history: location.pathname + location.search, + } + return url[mode] } /** @@ -152,8 +152,8 @@ export function getUrlWithParams() { * @returns {Array} */ export function getFlatMenuList(menuList: Menu.MenuOptions[]): Menu.MenuOptions[] { - let newMenuList: Menu.MenuOptions[] = JSON.parse(JSON.stringify(menuList)); - return newMenuList.flatMap(item => [item, ...(item.children ? getFlatMenuList(item.children) : [])]); + let newMenuList: Menu.MenuOptions[] = JSON.parse(JSON.stringify(menuList)) + return newMenuList.flatMap(item => [item, ...(item.children ? getFlatMenuList(item.children) : [])]) } /** @@ -162,11 +162,11 @@ export function getFlatMenuList(menuList: Menu.MenuOptions[]): Menu.MenuOptions[ * @returns {Array} * */ export function getShowMenuList(menuList: Menu.MenuOptions[]) { - let newMenuList: Menu.MenuOptions[] = JSON.parse(JSON.stringify(menuList)); - return newMenuList.filter(item => { - item.children?.length && (item.children = getShowMenuList(item.children)); - return !item.meta?.isHide; - }); + let newMenuList: Menu.MenuOptions[] = JSON.parse(JSON.stringify(menuList)) + return newMenuList.filter(item => { + item.children?.length && (item.children = getShowMenuList(item.children)) + return !item.meta?.isHide + }) } /** @@ -177,12 +177,12 @@ export function getShowMenuList(menuList: Menu.MenuOptions[]) { * @returns {Object} */ export const getAllBreadcrumbList = (menuList: Menu.MenuOptions[], parent = [], result: { [key: string]: any } = {}) => { - for (const item of menuList) { - result[item.path] = [...parent, item]; - if (item.children) getAllBreadcrumbList(item.children, result[item.path], result); - } - return result; -}; + for (const item of menuList) { + result[item.path] = [...parent, item] + if (item.children) getAllBreadcrumbList(item.children, result[item.path], result) + } + return result +} /** * @description 使用递归处理路由菜单 path,生成一维数组 (第一版本地路由鉴权会用到,该函数暂未使用) @@ -191,11 +191,11 @@ export const getAllBreadcrumbList = (menuList: Menu.MenuOptions[], parent = [], * @returns {Array} */ export function getMenuListPath(menuList: Menu.MenuOptions[], menuPathArr: string[] = []): string[] { - for (const item of menuList) { - if (typeof item === "object" && item.path) menuPathArr.push(item.path); - if (item.children?.length) getMenuListPath(item.children, menuPathArr); - } - return menuPathArr; + for (const item of menuList) { + if (typeof item === 'object' && item.path) menuPathArr.push(item.path) + if (item.children?.length) getMenuListPath(item.children, menuPathArr) + } + return menuPathArr } /** @@ -205,14 +205,14 @@ export function getMenuListPath(menuList: Menu.MenuOptions[], menuPathArr: strin * @returns {Object | null} */ export function findMenuByPath(menuList: Menu.MenuOptions[], path: string): Menu.MenuOptions | null { - for (const item of menuList) { - if (item.path === path) return item; - if (item.children) { - const res = findMenuByPath(item.children, path); - if (res) return res; + for (const item of menuList) { + if (item.path === path) return item + if (item.children) { + const res = findMenuByPath(item.children, path) + if (res) return res + } } - } - return null; + return null } /** @@ -222,11 +222,11 @@ export function findMenuByPath(menuList: Menu.MenuOptions[], path: string): Menu * @returns {Array} * */ export function getKeepAliveRouterName(menuList: Menu.MenuOptions[], keepAliveNameArr: string[] = []) { - menuList.forEach(item => { - item.meta.isKeepAlive && item.name && keepAliveNameArr.push(item.name); - item.children?.length && getKeepAliveRouterName(item.children, keepAliveNameArr); - }); - return keepAliveNameArr; + menuList.forEach(item => { + item.meta.isKeepAlive && item.name && keepAliveNameArr.push(item.name) + item.children?.length && getKeepAliveRouterName(item.children, keepAliveNameArr) + }) + return keepAliveNameArr } /** @@ -237,9 +237,9 @@ export function getKeepAliveRouterName(menuList: Menu.MenuOptions[], keepAliveNa * @returns {String} * */ export function formatTableColumn(row: number, col: number, callValue: any) { - // 如果当前值为数组,使用 / 拼接(根据需求自定义) - if (isArray(callValue)) return callValue.length ? callValue.join(" / ") : "--"; - return callValue ?? "--"; + // 如果当前值为数组,使用 / 拼接(根据需求自定义) + if (isArray(callValue)) return callValue.length ? callValue.join(' / ') : '/' + return (callValue && callValue.length > 0) ? callValue : '/' } /** @@ -248,9 +248,9 @@ export function formatTableColumn(row: number, col: number, callValue: any) { * @returns {String} * */ export function formatValue(callValue: any) { - // 如果当前值为数组,使用 / 拼接(根据需求自定义) - if (isArray(callValue)) return callValue.length ? callValue.join(" / ") : "--"; - return callValue ?? "--"; + // 如果当前值为数组,使用 / 拼接(根据需求自定义) + if (isArray(callValue)) return callValue.length ? callValue.join(' / ') : '/' + return (callValue && callValue.length > 0) ? callValue : '/' } /** @@ -260,9 +260,9 @@ export function formatValue(callValue: any) { * @returns {*} * */ export function handleRowAccordingToProp(row: { [key: string]: any }, prop: string) { - if (!prop.includes(".")) return row[prop] ?? "--"; - prop.split(".").forEach(item => (row = row[item] ?? "--")); - return row; + if (!prop.includes('.')) return row[prop] ?? '/' + prop.split('.').forEach(item => (row = row[item] ?? '/')) + return row } /** @@ -271,9 +271,9 @@ export function handleRowAccordingToProp(row: { [key: string]: any }, prop: stri * @returns {String} * */ export function handleProp(prop: string) { - const propArr = prop.split("."); - if (propArr.length == 1) return prop; - return propArr[propArr.length - 1]; + const propArr = prop.split('.') + if (propArr.length == 1) return prop + return propArr[propArr.length - 1] } /** @@ -284,28 +284,28 @@ export function handleProp(prop: string) { * @param {String} type 过滤类型(目前只有 tag) * @returns {String} * */ -export function filterEnum(callValue: any, enumData?: any, fieldNames?: FieldNamesProps, type?: "tag") { - const value = fieldNames?.value ?? "value"; - const label = fieldNames?.label ?? "label"; - const children = fieldNames?.children ?? "children"; - let filterData: { [key: string]: any } = {}; - // 判断 enumData 是否为数组 - if (Array.isArray(enumData)) filterData = findItemNested(enumData, callValue, value, children); - // 判断是否输出的结果为 tag 类型 - if (type == "tag") { - return filterData?.tagType ? filterData.tagType : ""; - } else { - return filterData ? filterData[label] : "--"; - } +export function filterEnum(callValue: any, enumData?: any, fieldNames?: FieldNamesProps, type?: 'tag') { + const value = fieldNames?.value ?? 'value' + const label = fieldNames?.label ?? 'label' + const children = fieldNames?.children ?? 'children' + let filterData: { [key: string]: any } = {} + // 判断 enumData 是否为数组 + if (Array.isArray(enumData)) filterData = findItemNested(enumData, callValue, value, children) + // 判断是否输出的结果为 tag 类型 + if (type == 'tag') { + return filterData?.tagType ? filterData.tagType : '' + } else { + return filterData ? filterData[label] : '/' + } } /** * @description 递归查找 callValue 对应的 enum 值 * */ export function findItemNested(enumData: any, callValue: any, value: string, children: string) { - return enumData.reduce((accumulator: any, current: any) => { - if (accumulator) return accumulator; - if (current[value] === callValue) return current; - if (current[children]) return findItemNested(current[children], callValue, value, children); - }, null); + return enumData.reduce((accumulator: any, current: any) => { + if (accumulator) return accumulator + if (current[value] === callValue) return current + if (current[children]) return findItemNested(current[children], callValue, value, children) + }, null) } diff --git a/frontend/src/views/system/dictionary/dictPq/components/pqPopup.vue b/frontend/src/views/system/dictionary/dictPq/components/pqPopup.vue index 84cbc29..ff94988 100644 --- a/frontend/src/views/system/dictionary/dictPq/components/pqPopup.vue +++ b/frontend/src/views/system/dictionary/dictPq/components/pqPopup.vue @@ -1,6 +1,5 @@