diff --git a/src/assets/stylus/index.styl b/src/assets/stylus/index.styl new file mode 100644 index 0000000..17ea86e --- /dev/null +++ b/src/assets/stylus/index.styl @@ -0,0 +1,572 @@ +// 优化 Element Plus 组件库默认样式 + +:root { + --custom-radius: 5px; + // 系统主色 + --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-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); + } +} + +// 优化 el-form-item 标签高度 +.el-form-item__label { + height: var(--el-component-custom-height) !important; + line-height: var(--el-component-custom-height) !important; +} + +// 日期选择器 +.el-date-range-picker { + --el-datepicker-inrange-bg-color: var(--art-gray-200) !important; +} + +// el-card 背景色跟系统背景色保持一致 +html.dark .el-card { + --el-card-bg-color: var(--default-box-color) !important; +} + +.el-pagination { + justify-content: center; + + .el-pager { + li { + box-sizing: border-box; + font-weight: 400 !important; + border: 1px solid #E6EAEB; + transition: border-color 0.15s; + padding: 0 10px !important; + + &:not(.is-active) { + background-color: transparent !important; + } + + &:hover { + border-color: var(--main-color) !important; + } + } + } + + .el-pagination__jump { + .el-input { + height: 32px; + } + } +} + + +// 优化菜单折叠展开动画(提升动画流畅度) +.el-menu.el-menu--inline { + transition: max-height 0.26s cubic-bezier(0.4, 0, 0.2, 1) !important; +} + +.el-sub-menu { + position: relative; +} + +.el-sub-menu .el-sub-menu__icon-arrow { + position: absolute; + top: 50%; + right: var(--el-menu-base-level-padding); + margin-top: -6px; + transition: transform var(--el-transition-duration); + font-size: 12px; + margin-right: 0; + display: block; + width: auto; +} + +// 优化菜单 item hover 动画(提升鼠标跟手感) +.el-sub-menu__title, +.el-menu-item { + height: 42px !important; + margin-bottom: 4px; + line-height: 42px !important; + transition: background-color 0s !important; + width: calc(100% - 16px); + margin-left: 8px; + border-radius: 6px; + + &:hover { + background-color: #F2F4F5 !important; + } +} + +.menus:not(.el-menu--collapse) { + width: 230px !important; +} + +.el-menu--collapse { + width: calc(16px + var(--el-menu-icon-width) + var(--el-menu-base-level-padding) * 2) !important; +} + +.el-menu-item.is-active { + background-color: rgb(238, 243, 255) !important; +} + +// -------------------------------- 修改 el-size=default 组件默认高度 start -------------------------------- +// 修改 el-button 高度 +.el-button--default { + height: var(--el-component-custom-height) !important; +} + +// circle 按钮宽度优化 +.el-button--default.is-circle { + width: var(--el-component-custom-height) !important; +} + +// 修改 el-select 高度 +.el-select--default { + .el-select__wrapper { + min-height: var(--el-component-custom-height) !important; + } +} + +// 修改 el-checkbox-button 高度 +.el-checkbox-button--default .el-checkbox-button__inner, + // 修改 el-radio-button 高度 +.el-radio-button--default .el-radio-button__inner { + padding: 10px 15px !important; +} + +.el-scrollbar__bar.is-vertical { + width: 4px; +} + +// -------------------------------- 修改 el-size=default 组件默认高度 end -------------------------------- + +.el-pagination.is-background .btn-next, +.el-pagination.is-background .btn-prev, +.el-pagination.is-background .el-pager li { + border-radius: 6px; +} + +.el-popover { + min-width: 80px; + border-radius: var(--el-border-radius-small) !important; +} + +.el-dialog { + border-radius: 100px !important; + border-radius: calc(var(--custom-radius) / 1.2 + 2px) !important; + overflow: hidden; +} + +.el-dialog__header { + .el-dialog__title { + font-size: 16px; + } +} + +.el-dialog__body { + padding: 25px 0 !important; + position: relative; // 为了兼容 el-pagination 样式,需要设置 relative,不然会影响 el-pagination 的样式,比如 el-pagination__jump--small 会被影响,导致 el-pagination__jump--small 按钮无法点击,详见 URL_ADDRESS.com/element-plus/element-plus/issues/5684#issuecomment-1176299275; +} + +.el-dialog.el-dialog-border { + .el-dialog__body { + // 上边框 + + &::before, + // 下边框 + &::after { + content: ''; + position: absolute; + left: -16px; + width: calc(100% + 32px); + height: 1px; + background-color: var(--art-gray-300); + } + + &::before { + top: 0; + } + + &::after { + bottom: 0; + } + } +} + +// el-message 样式优化 +.el-message { + background-color: var(--default-box-color) !important; + border: 0 !important; + box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), + 0 3px 6px -4px rgba(0, 0, 0, 0.12), + 0 9px 28px 8px rgba(0, 0, 0, 0.05) !important; + + p { + font-size: 13px; + } +} + +// 修改 el-dropdown 样式 +.el-dropdown-menu { + padding: 6px !important; + border-radius: 10px !important; + border: none !important; + + .el-dropdown-menu__item { + padding: 6px 16px !important; + border-radius: 6px !important; + + &:hover:not(.is-disabled) { + color: var(--art-gray-900) !important; + background-color: var(--art-el-active-color) !important; + } + + &:focus:not(.is-disabled) { + color: var(--art-gray-900) !important; + background-color: var(--art-gray-200) !important; + } + } +} + +// 隐藏 select、dropdown 的三角 +.el-select__popper, +.el-dropdown__popper { + margin-top: -6px !important; + + .el-popper__arrow { + display: none; + } +} + +.el-dropdown-selfdefine:focus { + outline: none !important; +} + +// 处理移动端组件兼容性 +@media screen and (max-width: 640px) { + .el-message-box, + .el-dialog { + width: calc(100% - 24px) !important; + } + + .el-date-picker.has-sidebar.has-time { + width: calc(100% - 24px); + left: 12px !important; + } + + .el-picker-panel *[slot='sidebar'], + .el-picker-panel__sidebar { + display: none; + } + + .el-picker-panel *[slot='sidebar'] + .el-picker-panel__body, + .el-picker-panel__sidebar + .el-picker-panel__body { + margin-left: 0; + } +} + +// 修改el-button样式 +.el-button { + &.el-button--text { + background-color: transparent !important; + padding: 0 !important; + + span { + margin-left: 0 !important; + } + } +} + +// 修改el-tag样式 +.el-tag { + font-weight: 500; + transition: all 0s !important; + + &.el-tag--default { + height: 26px !important; + } +} + +.el-checkbox-group { + &.el-table-filter__checkbox-group label.el-checkbox { + height: 17px !important; + + .el-checkbox__label { + font-weight: 400 !important; + } + } +} + +.el-radio--default { + // 优化单选按钮大小 + + .el-radio__input { + .el-radio__inner { + width: 16px; + height: 16px; + + &::after { + width: 6px; + height: 6px; + } + } + } +} + +.el-checkbox { + .el-checkbox__inner { + border-radius: 2px !important; + } +} + +// 优化复选框样式 +.el-checkbox--default { + .el-checkbox__inner { + width: 16px !important; + height: 16px !important; + border-radius: 4px !important; + + &::before { + content: ''; + height: 4px !important; + top: 5px !important; + background-color: #FFFFFF !important; + transform: scale(0.6) !important; + } + } + + .is-checked { + .el-checkbox__inner { + &::after { + width: 3px; + height: 8px; + margin: auto; + border: 2px solid var(--el-checkbox-checked-icon-color); + border-left: 0; + border-top: 0; + transform: translate(-45%, -60%) rotate(45deg) scale(0.86) !important; + transform-origin: center; + } + } + } +} + +.el-notification .el-notification__icon { + font-size: 22px !important; +} + +// 修改 el-message-box 样式 +.el-message-box__headerbtn .el-message-box__close, +.el-dialog__headerbtn .el-dialog__close { + top: 7px; + right: 7px; + width: 30px; + height: 30px; + border-radius: 5px; + transition: all 0.3s; + + &:hover { + background-color: var(--art-hover-color) !important; + color: var(--art-gray-900) !important; + } +} + +.el-message-box { + padding: 25px 20px !important; +} + +.el-message-box__title { + font-weight: 500 !important; +} + +.el-table__column-filter-trigger i { + color: var(--theme-color) !important; + margin: -3px 0 0 2px; +} + +// 去除 el-dropdown 鼠标放上去出现的边框 +.el-tooltip__trigger:focus-visible { + outline: unset; +} + +// ipad 表单右侧按钮优化 +@media screen and (max-width: 1180px) { + .el-table-fixed-column--right { + padding-right: 0 !important; + } +} + +.login-out-dialog { + padding: 30px 20px !important; + border-radius: 10px !important; +} + +// 修改 dialog 动画 +.dialog-fade-enter-active { + .el-dialog:not(.is-draggable) { + animation: dialog-open 0.3s cubic-bezier(0.32, 0.14, 0.15, 0.86); + + // 修复 el-dialog 动画后宽度不自适应问题 + + .el-select__selected-item { + display: inline-block; + } + } +} + +.dialog-fade-leave-active { + animation: fade-out 0.2s linear; + + .el-dialog:not(.is-draggable) { + animation: dialog-close 0.5s !important; + } +} + +@keyframes dialog-open { + 0% { + opacity: 0; + transform: scale(0.2); + } + + 100% { + opacity: 1; + transform: scale(1); + } +} + +@keyframes dialog-close { + 0% { + opacity: 1; + transform: scale(1); + } + + 100% { + opacity: 0; + transform: scale(0.2); + } +} + +// 遮罩层动画 +@keyframes fade-out { + 0% { + opacity: 1; + } + + 100% { + opacity: 0; + } +} + +// 修改 el-select 样式 +/* .el-select__popper:not(.el-tree-select__popper) { + .el-select-dropdown__list { + padding: 5px !important; + + .el-select-dropdown__item { + height: 34px !important; + line-height: 34px !important; + border-radius: 6px !important; + + &.is-selected { + color: var(--art-gray-900) !important; + font-weight: 400 !important; + background-color: var(--art-el-active-color) !important; + margin-bottom: 4px !important; + } + + &:hover { + background-color: var(--art-hover-color) !important; + } + } + + .el-select-dropdown__item:hover ~ .is-selected, + .el-select-dropdown__item.is-selected:has(~ .el-select-dropdown__item:hover) { + background-color: transparent !important; + } + } +} */ + +// 修改 el-tree-select 样式 +.el-tree-select__popper { + .el-select-dropdown__list { + padding: 5px !important; + + .el-tree-node { + .el-tree-node__content { + height: 36px !important; + border-radius: 6px !important; + + &:hover { + background-color: var(--art-gray-200) !important; + } + } + } + } +} + +// 实现水波纹在文字下面效果 +.el-button > span { + position: relative; + z-index: 10; +} + +// 优化颜色选择器圆角 +.el-color-picker__color { + border-radius: 2px !important; +} + +// 优化日期时间选择器底部圆角 +.el-picker-panel { + .el-picker-panel__footer { + border-radius: 0 0 var(--el-border-radius-base) var(--el-border-radius-base); + } +} + +// 优化树型菜单样式 +.el-tree-node__content { + border-radius: 4px; + margin-bottom: 4px; + padding: 1px 0; + + &:hover { + background-color: var(--art-hover-color) !important; + } +} + +.dark { + .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content { + background-color: var(--art-gray-300) !important; + } +} + +// 隐藏折叠菜单弹窗 hover 出现的边框 +.menu-left-popper:focus-within, +.horizontal-menu-popper:focus-within { + box-shadow: none !important; + outline: none !important; +} + +// 数字输入组件右侧按钮高度跟随自定义组件高度 +.el-input-number--default.is-controls-right { + .el-input-number__decrease, + .el-input-number__increase { + height: calc((var(--el-component-size) / 2)) !important; + } +} diff --git a/src/components/page/FormPage.vue b/src/components/page/FormPage.vue index 6fad208..01b4717 100644 --- a/src/components/page/FormPage.vue +++ b/src/components/page/FormPage.vue @@ -58,6 +58,7 @@ const props = withDefaults( searchFormProps?: FormPropsType simpleSearchFormProps?: FormPropsType formStyle?: { + border: boolean colCount?: number vgap?: string hgap?: string @@ -71,14 +72,19 @@ const props = withDefaults( }, // @ts-ignore searchFormProps: { + labelPosition: 'left', + labelWidth: '90px', inline: true, } as FormPropsType, // @ts-ignore simpleSearchFormProps: { + labelWidth: '90px', + labelPosition: 'left', inline: true, } as FormPropsType, formStyle: { // @ts-ignore + border: false, colCount: 4, vgap: '20px', hgap: '20px', @@ -148,7 +154,7 @@ onMounted(doSearch)
- + @@ -325,6 +331,40 @@ onMounted(doSearch) width 100%; } + + .border-form { + :deep(.el-form-item) { + &:not(.form-action-btn) { + background-color white + border-radius: var(--el-input-border-radius, var(--el-border-radius-base)); + box-shadow: 0 0 0 1px var(--el-input-border-color, var(--el-border-color)); + padding: 1px; + + .el-form-item__label { + border-right 1px solid #DCDFE6 + padding 1px 11px + } + + .el-form-item__content { + .el-input { + .el-input__wrapper { + border-radius unset + box-shadow unset + } + } + + .el-select { + .el-select__wrapper { + border-radius unset + box-shadow unset + } + } + } + } + + } + } + :deep(.el-form) { display grid grid-template-columns repeat(v-bind('formStyle.colCount'), 1fr) @@ -333,40 +373,12 @@ onMounted(doSearch) row-gap v-bind('formStyle.vgap'); padding 5px - .el-form-item:not(.form-action-btn) { - background-color white - //border 1px solid #DCDFE6 - border-radius: var(--el-input-border-radius, var(--el-border-radius-base)); - box-shadow: 0 0 0 1px var(--el-input-border-color, var(--el-border-color)); - padding: 1px; + .el-form-item { margin 0 - - .el-form-item__label { - border-right 1px solid #DCDFE6 - padding 1px 11px - } - - .el-form-item__content { - .el-input { - .el-input__wrapper { - border-radius unset - box-shadow unset - } - } - - .el-select { - .el-select__wrapper { - border-radius unset - box-shadow unset - } - } - } } .el-form-item.form-action-btn { grid-column: 1 / -1; - margin: 0; - .el-form-item__content { justify-content end } diff --git a/src/main.ts b/src/main.ts index e503324..329e812 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,4 @@ -import '@/assets/scss/index.scss' +import '@/assets/stylus/index.styl' import { createApp } from 'vue' import App from './App.vue' import { Settings } from 'luxon' @@ -8,7 +8,6 @@ import piniaPluginPersistedstate from 'pinia-plugin-persistedstate' // import Ws from '@/common/ws/ws.ts' import element from '@/common/element/element.ts' import router from '@/common/router' -// import '@/assets/css/index.css' createApp(App) .use(element) diff --git a/src/pages/cst/customer/Customer.vue b/src/pages/cst/customer/Customer.vue index 429738f..86e6b6b 100644 --- a/src/pages/cst/customer/Customer.vue +++ b/src/pages/cst/customer/Customer.vue @@ -6,12 +6,12 @@ :paging="paging">