diff --git a/src/assets/stylus/button.styl b/src/assets/stylus/button.styl new file mode 100644 index 0000000..47ead59 --- /dev/null +++ b/src/assets/stylus/button.styl @@ -0,0 +1,42 @@ +#app { + .el-button { + /*--el-button-text-color oklch(72% .19 231.6) !important; + --el-button-bg-color oklch(0.96 0.03 224.26) !important; + --el-button-border-color: oklch(0.96 0.03 224.26) !important; + + --el-button-hover-text-color: oklch(72% .19 231.6) !important; + --el-button-hover-bg-color: oklch(0.96 0.03 224.26) !important; + --el-button-hover-border-color: oklch(0.96 0.03 224.26) !important;*/ + } + + .el-button--default { + --el-button-text-color #5D87FF !important; + --el-button-bg-color #FFFFFF !important; + --el-button-border-color: #5D87FF !important; + + --el-button-hover-text-color #5D87FF !important; + --el-button-hover-bg-color #EEF3FF !important; + --el-button-hover-border-color: #5D87FF !important; + } + + .el-button--primary { + --el-button-text-color #FFFFFF !important; + --el-button-bg-color #5D87FF !important; + --el-button-border-color: #5D87FF !important; + + --el-button-hover-text-color: #FFFFFF !important; + --el-button-hover-bg-color: #8DABFF !important; + --el-button-hover-border-color: #8DABFF !important; + } + + .el-button--danger { + --el-button-text-color #FFFFFF !important; + --el-button-bg-color rgb(255, 130, 132) !important; + --el-button-border-color: rgb(255, 130, 132) !important; + + --el-button-hover-text-color: #FFFFFF !important; + --el-button-hover-bg-color: rgb(255, 130, 132) !important; + --el-button-hover-border-color: rgb(255, 130, 132) !important; + } + +} diff --git a/src/assets/stylus/index.styl b/src/assets/stylus/index.styl index cc78e9c..8bff194 100644 --- a/src/assets/stylus/index.styl +++ b/src/assets/stylus/index.styl @@ -1,43 +1,8 @@ +@import "root.styl" +@import "button.styl" +@import "menu.styl" // 优化 Element Plus 组件库默认样式 -:root { - --custom-radius: 9px; - // 系统主色 - --main-color: #1C6EFF; - --el-color-white: white !important; - --el-color-black: white !important; - --el-color-primary: #1C6EFF !important; - --el-button-hover-bg-color: #458FFF !important; - --el-button-hover-border-color: #458FFF !important; - --el-color-primary-light-3: #458FFF !important; - --el-color-danger: #CF171D !important; - --el-menu-text-color: #29343D !important; - --el-menu-hover-text-color: #29343D !important; - --el-menu-bg-color: #FFFFFF !important; - --el-menu-hover-bg-color: rgb(204, 204, 204) !important; - --el-menu-level: 0; - // 输入框边框颜色 - // --el-border-color: #E4E4E7 !important; // DCDFE6 - // 按钮粗度 - --el-font-weight-primary: 400 !important; - - --el-component-custom-height: 32px !important; - - --el-component-size: var(--el-component-custom-height) !important; - - // 边框、按钮圆角... - --el-border-radius-base: calc(var(--custom-radius) / 3 + 2px) !important; - - --el-border-radius-small: calc(var(--custom-radius) / 3 + 4px) !important; - --el-messagebox-border-radius: calc(var(--custom-radius) / 3 + 4px) !important; - --el-popover-border-radius: calc(var(--custom-radius) / 3 + 4px) !important; - - .region .el-radio-button__original-radio:checked + .el-radio-button__inner { - color: var(--theme-color) !important; - } -} - - // -------------------------------- 修改 el-size=default 组件默认高度 start -------------------------------- // 修改 el-button 高度 .el-button--default { @@ -96,7 +61,7 @@ } .el-dialog { - height 90% !important + //height 90% !important margin 0 !important box-sizing border-box !important } @@ -113,3 +78,44 @@ } } +.el-input-number { + width 100% !important +} + +.el-form-item.is-required:not(.is-no-asterisk).asterisk-left > .el-form-item__label-wrap > .el-form-item__label:before, .el-form-item.is-required:not(.is-no-asterisk).asterisk-left > .el-form-item__label:before { + position: absolute; + top calc(50% - 16px) + left 0 + width 7px !important; + text-align: center !important; + margin: 0 !important; +} + +.el-form-item__label { + text-align-last: justify; + display: inline-block !important; + position: relative; + padding 0 12px !important; +} + +.el-form-item.is-error { + .a-uploader { + .el-upload { + &.el-upload--text, + &.el-upload--picture, + &.el-upload--picture-card { + border-color: var(--el-color-danger); + } + } + } +} + +.el-upload-list__item.is-success:focus .el-upload-list__item-status-label { + display: inline-flex !important; + opacity: 1 !important; +} + +.el-upload-list__item.is-success:hover .el-upload-list__item-status-label { + display none !important; + opacity 0 !important; +} diff --git a/src/assets/stylus/menu.styl b/src/assets/stylus/menu.styl new file mode 100644 index 0000000..16c2877 --- /dev/null +++ b/src/assets/stylus/menu.styl @@ -0,0 +1,40 @@ +#app { + .el-menu-item.is-active { + background-color #EEF3FF !important + color #5D87FF !important + + &::after { + height: 100%; + } + } + + .el-menu-item { + position relative !important + transition: background-color, color .3s ease-in-out !important; + border-radius 4px !important + + &::after { + content: ''; + position: absolute; + top: 0; + right: 0; + width: 4px; + height: 0; + background-color: #1C6EFF; + transition height 0.3s ease-in-out + } + } + + .el-sub-menu__title, + .el-menu-item { + height: 42px !important; + line-height: 42px !important; + margin-left: 8px !important; + margin-right: 8px !important; + + &:hover { + background-color: #F2F4F5 !important; + } + } + +} diff --git a/src/assets/stylus/root.styl b/src/assets/stylus/root.styl new file mode 100644 index 0000000..f9a4464 --- /dev/null +++ b/src/assets/stylus/root.styl @@ -0,0 +1,21 @@ +#app { + --custom-radius: 9px; + --main-color: #5D87FF; + --el-color-primary: #5D87FF !important; + --el-color-danger: oklch(73% .15 25.3) !important; + + --el-menu-level: 0; + --el-font-weight-primary: 400 !important; + + --el-component-custom-height: 32px !important; + + --el-component-size: var(--el-component-custom-height) !important; + + --el-border-radius-base: 4px !important; + + --el-messagebox-border-radius: 8px !important; + + .region .el-radio-button__original-radio:checked + .el-radio-button__inner { + color: var(--theme-color) !important; + } +} diff --git a/src/common/utils/use-move.ts b/src/common/utils/use-move.ts index 85ce55f..002676e 100644 --- a/src/common/utils/use-move.ts +++ b/src/common/utils/use-move.ts @@ -1,29 +1,34 @@ -export class MoveHandle { - public id: string - public container: { +import Strings from '@/common/utils/strings.ts' + +class MoveHandle { + private static MoveHandles = new Map() + + private readonly id: string + private disabled: boolean + private container: { el?: HTMLElement; width: number; height: number; x: number; y: number; } - public widget: { + private widget: { el?: HTMLElement; width: number; height: number; x: number; y: number; } - public triggerArea?: HTMLElement - public startPoint: { + private triggerArea?: HTMLElement + private startPoint: { x: number; y: number; } - public offset: { + private offset: { x: number; y: number; } - public dragging: boolean + private dragging: boolean constructor(id: string, container?: HTMLElement, widget?: HTMLElement, triggerArea?: HTMLElement) { this.id = id @@ -32,14 +37,31 @@ export class MoveHandle { this.startPoint = {x: 0, y: 0} this.offset = {x: 0, y: 0} this.dragging = false + this.disabled = true this.setContainer(container) .setWidget(widget) .setTriggerArea(triggerArea) - MoveHandles.set(this.id, this) + MoveHandle.MoveHandles.set(this.id, this) } - setContainer(el?: HTMLElement) { - if (MoveHandleIns === this) return this + public static of(id: string, container?: HTMLElement, widget?: HTMLElement, triggerArea?: HTMLElement) { + if (Strings.isBlank(id)) throw new Error('Id 不能为空') + return MoveHandle.MoveHandles.get(id) ?? new MoveHandle(id, container, widget, triggerArea) + } + + public handleEvent(e: Event) { + if (this.disabled) return + if (e.type === 'mousedown') { + this.handlerMousedown(e) + } else if (e.type === 'mouseup') { + this.handlerMouseup() + } else if (e.type === 'mousemove') { + this.handlerMove(e) + } + } + + public setContainer(el?: HTMLElement) { + if (!this.disabled) throw new Error('不能在启用状态下设置容器') this.container.el = el if (el != null) { const containerRect = el.getBoundingClientRect() @@ -51,8 +73,8 @@ export class MoveHandle { return this } - setWidget(el?: HTMLElement) { - if (MoveHandleIns === this) return this + public setWidget(el?: HTMLElement) { + if (!this.disabled) throw new Error('不能在启用状态下设置组件') this.widget.el = el if (el != null) { const widgetRect = el.getBoundingClientRect() @@ -64,121 +86,112 @@ export class MoveHandle { return this } - setTriggerArea(el?: HTMLElement) { - if (MoveHandleIns === this) return this - this.triggerArea?.removeEventListener('mousedown', handlerMousedown) - el?.addEventListener('mousedown', handlerMousedown) + public setTriggerArea(el?: HTMLElement) { + if (!this.disabled) throw new Error('不能在启用状态下设置触发区域') + this.triggerArea?.removeEventListener('mousedown', this) + el?.addEventListener('mousedown', this) this.triggerArea = el return this } - destroy() { - MoveHandles.delete(this.id) + public destroy() { + MoveHandle.MoveHandles.delete(this.id) this.disable() this.setContainer() .setWidget() .setTriggerArea() } - enable() { + public enable() { if (this.container.el == null || this.widget.el == null || this.triggerArea == null) { return } - MoveHandleIns = this + this.disabled = false } - disable() { - if (MoveHandleIns === this) MoveHandleIns = null + public disable() { + this.disabled = true return this } -} -let MoveHandleIns: MoveHandle | null = null + private handlerMove(e: Event) { + if (!this.dragging + || this.widget.el == null + ) return + const mouseEvent = e as MouseEvent -const MoveHandles: Map = new Map() - -function handlerMousedown(e: Event) { - if (MoveHandleIns == null - || MoveHandleIns.container.el == null - || MoveHandleIns.widget.el == null - ) return - const mouseEvent = e as MouseEvent - mouseEvent.preventDefault() - mouseEvent.stopPropagation() - - MoveHandleIns.dragging = true - MoveHandleIns.startPoint.x = mouseEvent.clientX - MoveHandleIns.startPoint.y = mouseEvent.clientY - - const transform = window.getComputedStyle(MoveHandleIns.widget.el).transform - let translateX = 0 - let translateY = 0 - - if (transform !== 'none') { - const matrix = new DOMMatrix(transform) - translateX = matrix.e - translateY = matrix.f - } else { - MoveHandleIns.widget.el.style.transform = 'translate(0, 0)' + let dx = mouseEvent.clientX - this.startPoint.x + let dy = mouseEvent.clientY - this.startPoint.y + // 左右边界 + if (dx < 0) { + const min_dx = this.container.x - this.widget.x + dx = Math.max(dx, min_dx) + } else { + const max_dx = (this.container.x + this.container.width) - (this.widget.x + this.widget.width) + dx = Math.min(dx, max_dx) + } + // 上下边界 + if (dy < 0) { + const min_dy = this.container.y - this.widget.y + dy = Math.max(dy, min_dy) + } else { + const max_dy = (this.container.y + this.container.height) - (this.widget.y + this.widget.height) + dy = Math.min(dy, max_dy) + } + let newOffsetX = this.offset.x + dx + let newOffsetY = this.offset.y + dy + this.widget.el.style.transform = `translate(${newOffsetX}px, ${newOffsetY}px)` } - MoveHandleIns.offset.x = translateX - MoveHandleIns.offset.y = translateY - - const containerRect = MoveHandleIns.container.el.getBoundingClientRect() - const widgetRect = MoveHandleIns.widget.el.getBoundingClientRect() - MoveHandleIns.container.width = containerRect.width - MoveHandleIns.container.height = containerRect.height - MoveHandleIns.container.x = containerRect.x - MoveHandleIns.container.y = containerRect.y - - MoveHandleIns.widget.width = widgetRect.width - MoveHandleIns.widget.height = widgetRect.height - MoveHandleIns.widget.x = widgetRect.x - MoveHandleIns.widget.y = widgetRect.y - document.addEventListener('mouseup', handlerMouseup) - document.addEventListener('mousemove', handlerMove) -} - -function handlerMove(e: Event) { - if (MoveHandleIns == null - || !MoveHandleIns.dragging - || MoveHandleIns.widget.el == null - ) return - const mouseEvent = e as MouseEvent - - let dx = mouseEvent.clientX - MoveHandleIns.startPoint.x - let dy = mouseEvent.clientY - MoveHandleIns.startPoint.y - // 左右边界 - if (dx < 0) { - const min_dx = MoveHandleIns.container.x - MoveHandleIns.widget.x - dx = Math.max(dx, min_dx) - } else { - const max_dx = (MoveHandleIns.container.x + MoveHandleIns.container.width) - (MoveHandleIns.widget.x + MoveHandleIns.widget.width) - dx = Math.min(dx, max_dx) + private handlerMouseup() { + this.dragging = false + document.removeEventListener('mousemove', this) + document.removeEventListener('mouseup', this) } - // 上下边界 - if (dy < 0) { - const min_dy = MoveHandleIns.container.y - MoveHandleIns.widget.y - dy = Math.max(dy, min_dy) - } else { - const max_dy = (MoveHandleIns.container.y + MoveHandleIns.container.height) - (MoveHandleIns.widget.y + MoveHandleIns.widget.height) - dy = Math.min(dy, max_dy) + + private handlerMousedown(e: Event) { + if (this.container.el == null + || this.widget.el == null + ) return + const mouseEvent = e as MouseEvent + mouseEvent.preventDefault() + mouseEvent.stopPropagation() + + this.dragging = true + this.startPoint.x = mouseEvent.clientX + this.startPoint.y = mouseEvent.clientY + + const transform = window.getComputedStyle(this.widget.el).transform + let translateX = 0 + let translateY = 0 + + if (transform !== 'none') { + const matrix = new DOMMatrix(transform) + translateX = matrix.e + translateY = matrix.f + } else { + this.widget.el.style.transform = 'translate(0, 0)' + } + + this.offset.x = translateX + this.offset.y = translateY + + const containerRect = this.container.el.getBoundingClientRect() + const widgetRect = this.widget.el.getBoundingClientRect() + this.container.width = containerRect.width + this.container.height = containerRect.height + this.container.x = containerRect.x + this.container.y = containerRect.y + + this.widget.width = widgetRect.width + this.widget.height = widgetRect.height + this.widget.x = widgetRect.x + this.widget.y = widgetRect.y + document.addEventListener('mouseup', this) + document.addEventListener('mousemove', this) } - let newOffsetX = MoveHandleIns.offset.x + dx - let newOffsetY = MoveHandleIns.offset.y + dy - MoveHandleIns.widget.el.style.transform = `translate(${newOffsetX}px, ${newOffsetY}px)` } -function handlerMouseup() { - if (MoveHandleIns == null) return - MoveHandleIns.dragging = false - document.removeEventListener('mousemove', handlerMove) - document.removeEventListener('mouseup', handlerMouseup) -} - -export default function (id: string, container?: HTMLElement, widget?: HTMLElement, triggerArea?: HTMLElement) { - return MoveHandles.get(id) ?? new MoveHandle(id, container, widget, triggerArea) -} +export default MoveHandle.of diff --git a/src/components/a-dialog/ADialog.vue b/src/components/a-dialog/ADialog.vue index 43dfea4..0ad6658 100644 --- a/src/components/a-dialog/ADialog.vue +++ b/src/components/a-dialog/ADialog.vue @@ -6,12 +6,16 @@ const props = withDefaults(defineProps<{ show: boolean title: string closeOnSuccess?: boolean - maxHeight?: string + width?: string + closeBtnText?: string + submitBtnText?: string closed?: () => void submitHandler: () => Promise }>(), { - maxHeight: '90%', + width: 'fit-content', closeOnSuccess: true, + closeBtnText: '关闭', + submitBtnText: '提交', closed() { }, }) @@ -82,7 +86,7 @@ onUnmounted(() => { :title="title" class="draggable-dialog" destroy-on-close - width="fit-content" @close="closed" + :width="width" @close="closed" @closed="closedHandler" @opened="openedHandler" @update:model-value="showDialog = $event" @@ -91,8 +95,8 @@ onUnmounted(() => { diff --git a/src/components/a-drop-table/ADropTable.vue b/src/components/a-drop-table/ADropTable.vue index ec8833c..251d8bf 100644 --- a/src/components/a-drop-table/ADropTable.vue +++ b/src/components/a-drop-table/ADropTable.vue @@ -155,7 +155,7 @@ const displayData = computed(() => {