diff --git a/src/assets/css/style.scss b/src/assets/css/style.scss index 1e2a7a38..e85243c0 100644 --- a/src/assets/css/style.scss +++ b/src/assets/css/style.scss @@ -19,7 +19,7 @@ --color-header-bg: white; --color-tooltip-bg: white; - --color-tooltip-shadow: #bbbbbb; + --color-tooltip-shadow: #d9d9d9; --color-font-1: rgb(91, 91, 91); --color-font-2: rgb(46, 46, 46); --color-font-3: rgb(75, 85, 99); diff --git a/src/components/BaseIcon.vue b/src/components/BaseIcon.vue index d1000add..007a6e0d 100644 --- a/src/components/BaseIcon.vue +++ b/src/components/BaseIcon.vue @@ -7,19 +7,55 @@ import {Icon} from "@iconify/vue"; defineProps<{ title?: string, icon: string, + disabled?: boolean, }>() -defineEmits(['click']) +const emit = defineEmits(['click']) + \ No newline at end of file diff --git a/src/pages/pc/components/AItem.vue b/src/pages/pc/components/AItem.vue new file mode 100644 index 00000000..5245f981 --- /dev/null +++ b/src/pages/pc/components/AItem.vue @@ -0,0 +1,153 @@ + + + + + + \ No newline at end of file diff --git a/src/pages/pc/components/BaseTable.vue b/src/pages/pc/components/BaseTable.vue index e2f6e594..66c53613 100644 --- a/src/pages/pc/components/BaseTable.vue +++ b/src/pages/pc/components/BaseTable.vue @@ -2,29 +2,27 @@ import {useSettingStore} from "@/stores/setting.ts"; import {nextTick, useSlots} from "vue"; -import VolumeIcon from "@/components/icon/VolumeIcon.vue"; import {Sort} from "@/types.ts"; import MiniDialog from "@/pages/pc/components/dialog/MiniDialog.vue"; import BaseIcon from "@/components/BaseIcon.vue"; import BaseButton from "@/components/BaseButton.vue"; import {cloneDeep, reverse, shuffle} from "lodash-es"; import Input from "@/pages/pc/components/Input.vue"; +import PopConfirm from "@/pages/pc/components/PopConfirm.vue"; +import Empty from "@/components/Empty.vue"; +import {Icon} from "@iconify/vue"; let list = defineModel('list') const props = withDefaults(defineProps<{ - activeIndex?: number, - activeId?: string, - isActive?: boolean showBorder?: boolean + loading?: boolean del?: Function batchDel?: Function add?: Function }>(), { - activeIndex: -1, - activeId: '', - isActive: false, showBorder: false, + loading: true, del: () => void 0, add: () => void 0, batchDel: () => void 0 @@ -52,26 +50,16 @@ function scrollToItem(index: number) { }) } -function itemIsActive(item: any, index: number) { - return props.activeId ? - props.activeId === item.id - : props.activeIndex === index -} defineExpose({scrollToBottom, scrollToItem}) let pageNo = $ref(1) let pageSize = $ref(50) -let currentList = $computed({ - get() { - if (searchKey) { - return list.value.filter(v => v.word.includes(searchKey)) - } - return list.value.slice((pageNo - 1) * pageSize, (pageNo - 1) * pageSize + pageSize) - }, - set(v) { - list.value = v +let currentList = $computed(() => { + if (searchKey) { + return list.value.filter(v => v.word.includes(searchKey)) } + return list.value.slice((pageNo - 1) * pageSize, (pageNo - 1) * pageSize + pageSize) }) let selectIds = $ref([]) @@ -116,6 +104,11 @@ function handleBatchDel() { selectIds = [] } +function handlePageNo(e) { + pageNo = e + console.log('listRef', listRef) +} + const s = useSlots() defineRender( @@ -127,43 +120,55 @@ defineRender( return (
-
+
{ showSearchInput ? (
searchKey = e} class="flex-1"/> - showSearchInput = false}>取消 + (showSearchInput = false, searchKey = '')}>取消
) : (
- toggleSelectAll()} - modelValue={selectAll} - size="large"/> +
+ toggleSelectAll()} + modelValue={selectAll} + size="large"/> + {selectIds.length} / {list.value.length} +
+
{ - selectIds.length ? : null + selectIds.length ? + + + + : null } showSortDialog = !showSortDialog} /> showSearchInput = !showSearchInput} title="搜索" icon="fluent:search-24-regular"/> @@ -186,29 +191,41 @@ defineRender( ) }
-
- { - currentList.map((item, index) => { - return ( -
- {s.default({checkbox: d, item})} -
- ) - }) - } -
-
- pageNo = e} - pageSize={pageSize} - onUpdate:page-size={(e) => pageSize = e} - layout="prev, pager, next" - total={list.value.length}/> -
+ { + props.loading ? +
+ +
+ : currentList.length ? ( + <> +
+ {currentList.map((item) => { + return ( +
+ {s.default({checkbox: d, item})} +
+ ) + })} +
+
+ pageSize = e} + pageSizes={[20, 50, 100, 200]} + layout="sizes, prev, pager, next" + total={list.value.length}/> +
+ + ) : + }
) } diff --git a/src/pages/pc/components/PopConfirm.vue b/src/pages/pc/components/PopConfirm.vue index 361e7cd5..fedf5407 100644 --- a/src/pages/pc/components/PopConfirm.vue +++ b/src/pages/pc/components/PopConfirm.vue @@ -42,7 +42,7 @@ export default { this.show = true this.$nextTick(() => { let tip = this.$refs?.tip?.getBoundingClientRect() - console.log('rect', rect, tip) + // console.log('rect', rect, tip) if (!tip) return if (rect.top < 150) { this.$refs.tip.style.top = rect.top + rect.height + tip.height + 30 + 'px' @@ -65,13 +65,13 @@ export default { { this.show && ( -
-
+
+
{this.title}
-
+
this.show = false}>取消
-
this.confirm()}>确认
+
this.confirm()}>确认
) @@ -91,7 +91,7 @@ $bg-color: rgb(226, 226, 226); position: fixed; background: var(--color-tooltip-bg); padding: 1rem; - border-radius: .24rem; + border-radius: .3rem; transform: translate(-50%, calc(-100% - .6rem)); box-shadow: 0 0 6px 1px var(--color-tooltip-shadow); z-index: 999; diff --git a/src/pages/pc/components/Tooltip.vue b/src/pages/pc/components/Tooltip.vue index 60c97f9e..7626ffaf 100644 --- a/src/pages/pc/components/Tooltip.vue +++ b/src/pages/pc/components/Tooltip.vue @@ -49,19 +49,20 @@ export default { }, }, render() { + if (!this.title) return this.$slots.default() let Vnode = this.$slots.default()[0] return <> - { - this.show && this.title && ( - - -
+ + + { + this.show && ( +
{this.title}
-
-
- ) - } + ) + } + + this.show = false} onmouseenter={(e) => this.showPop(e)} @@ -72,14 +73,12 @@ export default { } \ No newline at end of file diff --git a/src/pages/pc/word/EditWordDict.vue b/src/pages/pc/word/EditWordDict.vue index b66289a8..5a459563 100644 --- a/src/pages/pc/word/EditWordDict.vue +++ b/src/pages/pc/word/EditWordDict.vue @@ -13,10 +13,12 @@ import BaseTable from "@/pages/pc/components/BaseTable.vue"; import WordItem from "@/pages/pc/components/WordItem.vue"; import type {Word} from "@/types.ts"; import type {FormInstance, FormRules} from "element-plus"; +import PopConfirm from "@/pages/pc/components/PopConfirm.vue"; const runtimeStore = useRuntimeStore() const store = useBaseStore() const route = useRoute() +let loading = $ref(false) let list = $computed({ get() { @@ -27,12 +29,16 @@ let list = $computed({ } }) -onMounted(() => { +onMounted(async () => { switch (Number(route.query.type)) { case -1: if (runtimeStore.routeData) { + loading = true runtimeStore.editDict = cloneDeep(runtimeStore.routeData) - _checkDictWords(runtimeStore.editDict) + await _checkDictWords(runtimeStore.editDict) + setTimeout(() => { + loading = false + }, 300) } break case 0: @@ -148,6 +154,10 @@ function closeWordForm() { wordForm = cloneDeep(DefaultFormWord) } +function s(ss) { + console.log('s', ss) +} + defineRender(() => { return ( @@ -165,32 +175,39 @@ defineRender(() => { }
-
+
list = e} del={delWord} batchDel={batchDel} add={addWord} > { (val) => - + {{ prefix: () => val.checkbox(val.item), suffix: () => (
editWord(val.item)} title="编辑" icon="tabler:edit"/> - delWord(val.item.id)} - title="删除" - icon="solar:trash-bin-minimalistic-linear"/> + delWord(val.item.id)} + > + + +
) }} @@ -205,7 +222,7 @@ defineRender(() => { {wordFormData.type === FormMode.Add ? '添加' : '修改'}单词