From 417ece83b9de797f13e64097561f2c37a3d68a85 Mon Sep 17 00:00:00 2001 From: liushilong <2224574157@qq.com> Date: Wed, 17 Apr 2024 15:22:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 2 +- components.d.ts | 31 ++ src/components/RichEditor/Quill.vue | 3 +- src/views/final/comp/CustomFilterModalVue.vue | 32 +- src/views/final/comp/CustomTabelModal.vue | 97 +---- src/views/final/comp/FilterModal.vue | 26 +- src/views/final/comp/NewFilterModal.vue | 1 + src/views/home/aside/comp/AdvanceFilter.vue | 28 +- .../aside/comp/modals/CustomFilterModal.vue | 2 + .../home/aside/comp/modals/FilterModal.vue | 380 +++++++++--------- src/views/home/content/Content.vue | 23 +- src/views/task/content/Content.vue | 8 +- src/views/task/modal/CustomFieldModal.vue | 10 +- src/views/task/modal/NewFilterModal.vue | 1 + src/views/worksheet/content/Content.vue | 58 ++- 15 files changed, 382 insertions(+), 320 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 29677da..cc87c93 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -42,7 +42,7 @@ "vue3snippets.enable-compile-vue-file-on-did-save-code": true, "editor.defaultFormatter": "rvest.vs-code-prettier-eslint", "[vue]": { - "editor.defaultFormatter": "rvest.vs-code-prettier-eslint" + "editor.defaultFormatter": "Wscats.vue" }, "editor.formatOnSaveMode": "modifications" } diff --git a/components.d.ts b/components.d.ts index ddd3db7..e12f925 100644 --- a/components.d.ts +++ b/components.d.ts @@ -10,17 +10,48 @@ declare module 'vue' { Application: typeof import('./src/components/Application/Application.vue')['default'] BasicModal: typeof import('./src/components/Modal/BasicModal.vue')['default'] DataHeader: typeof import('./src/components/DataHeader/index.vue')['default'] + NAvatar: typeof import('naive-ui')['NAvatar'] + NBackTop: typeof import('naive-ui')['NBackTop'] NButton: typeof import('naive-ui')['NButton'] + NCard: typeof import('naive-ui')['NCard'] NCheckbox: typeof import('naive-ui')['NCheckbox'] + NCollapse: typeof import('naive-ui')['NCollapse'] + NCollapseItem: typeof import('naive-ui')['NCollapseItem'] NConfigProvider: typeof import('naive-ui')['NConfigProvider'] + NDatePicker: typeof import('naive-ui')['NDatePicker'] NDialogProvider: typeof import('naive-ui')['NDialogProvider'] + NDivider: typeof import('naive-ui')['NDivider'] + NDropdown: typeof import('naive-ui')['NDropdown'] + NEllipsis: typeof import('naive-ui')['NEllipsis'] + NEmpty: typeof import('naive-ui')['NEmpty'] NForm: typeof import('naive-ui')['NForm'] NFormItem: typeof import('naive-ui')['NFormItem'] + NGi: typeof import('naive-ui')['NGi'] + NGrid: typeof import('naive-ui')['NGrid'] + NGridItem: typeof import('naive-ui')['NGridItem'] + NImage: typeof import('naive-ui')['NImage'] NInput: typeof import('naive-ui')['NInput'] NMessageProvider: typeof import('naive-ui')['NMessageProvider'] NModal: typeof import('naive-ui')['NModal'] NNotificationProvider: typeof import('naive-ui')['NNotificationProvider'] NotPassed: typeof import('./src/components/NotPassed.vue')['default'] + NPopconfirm: typeof import('naive-ui')['NPopconfirm'] + NPopover: typeof import('naive-ui')['NPopover'] + NPopselect: typeof import('naive-ui')['NPopselect'] + NScrollbar: typeof import('naive-ui')['NScrollbar'] + NSelect: typeof import('naive-ui')['NSelect'] + NSlider: typeof import('naive-ui')['NSlider'] + NSpace: typeof import('naive-ui')['NSpace'] + NSpin: typeof import('naive-ui')['NSpin'] + NSwitch: typeof import('naive-ui')['NSwitch'] + NTabPane: typeof import('naive-ui')['NTabPane'] + NTabs: typeof import('naive-ui')['NTabs'] + NTag: typeof import('naive-ui')['NTag'] + NTimeline: typeof import('naive-ui')['NTimeline'] + NTimelineItem: typeof import('naive-ui')['NTimelineItem'] + NTooltip: typeof import('naive-ui')['NTooltip'] + NUpload: typeof import('naive-ui')['NUpload'] + NUploadDragger: typeof import('naive-ui')['NUploadDragger'] Quill: typeof import('./src/components/RichEditor/Quill.vue')['default'] Robot: typeof import('./src/components/Robot/index.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] diff --git a/src/components/RichEditor/Quill.vue b/src/components/RichEditor/Quill.vue index cfda6a9..c87d0ef 100644 --- a/src/components/RichEditor/Quill.vue +++ b/src/components/RichEditor/Quill.vue @@ -53,7 +53,8 @@ const saveHandler = debounce(() => { 备注信息 { extraCustomConfig.push(key) }) -function showModal() { - show.value = true +function showModal(type: boolean = true) { + show.value = type // 重置左右列表数据 const config = finalStore.getSystemConfig const customConfig = finalStore.getCustomConfig if (config == null || customConfig == null) return + // 在现有基础上添加 关闭弹窗时重置数据 + if (!type) { + const { showList, hideList } = generatList(config, customConfig) + onList.value = showList + offList.value = hideList + // 重置全选状态 + checkAll.value = hideList.every(item => item.checked) + // 重置输入框查询条件 + offKeyword.value = '' + onKeyword.value = '' + return + } if (tempList.value.length > 0 && isEqual(tempList.value, finalStore.getFilterConfig)) return const { showList, hideList } = generatList(config, customConfig) @@ -221,6 +233,19 @@ async function handleSumbit(e: MouseEvent) { function onCheckAllChange(value) { const ids: string[] = [] + if (value) { + offList.value.forEach((v) => { + if (!v.checked) + onList.value.push(v) + }) + } + else { + onList.value = offList.value.filter(v => v.fix) + offList.value.map(v => ({ + ...v, + checked: v.fix, + })) + } for (const item of offList.value) { if (!item.fix) { @@ -228,7 +253,6 @@ function onCheckAllChange(value) { ids.push(item.id) } } - selectIds.value = value ? ids : [] } @@ -478,7 +502,7 @@ onMounted(() => { 取消 diff --git a/src/views/final/comp/CustomTabelModal.vue b/src/views/final/comp/CustomTabelModal.vue index 8361da7..b2580ee 100644 --- a/src/views/final/comp/CustomTabelModal.vue +++ b/src/views/final/comp/CustomTabelModal.vue @@ -3,7 +3,6 @@ import { difference } from 'lodash-es' import { computed, onMounted, ref, watch } from 'vue' import { VueDraggable } from 'vue-draggable-plus' import { getAllfieldList, getfieldList, savefield } from '@/api/home/filter' -import { ColumnsMap } from '@/config/final' import { useUser } from '@/store/modules/user' const props = defineProps({ @@ -39,8 +38,8 @@ onMounted(async () => { */ const userFieldFixed = useList.userFieldFixed?.split(',') const userFieldUnFixed = useList.userFieldUnFixed?.split(',') - const mustList = [] - allList?.map((v) => { + const mustList: any[] = [] + allList?.forEach((v) => { const item = { name: v.fieldDesc, id: v.name, @@ -73,67 +72,6 @@ const selectCount = computed(() => { return `显示字段(共${onList.value.length}个)` }) -function generatList() { - const keys = Object.keys(ColumnsMap) - // const showStr = 'name' - // const showKeys = showStr.split(',').map((key: string) => key.toLowerCase()) - - for (const key of keys) { - const { title, fixed, fixLeft, width } = ColumnsMap[key] - const item = { - id: key, - title, - fix: fixed, - checked: ColumnsMap[key].fixed, - width, - } - - if (!fixed) - offList.value.push(item) - - if (fixLeft) - fixLeftList.value.push(item) - } - - // showList = showKeys.reduce((acc, key) => { - // const config = { - // id: key, - // title: ColumnsMap[key].name || '未配置', - // fix: ColumnsMap[key].fixed, - // } - // return [...acc, config] - // }, []) - - const fixedList = generateDefaultList() - const filterList = fixedList.filter((item) => { - return !item.fixLeft - }) - - onList.value.unshift(...filterList) - offList.value.unshift(...fixedList) -} - -function generateDefaultList() { - return Object.keys(ColumnsMap).reduce((acc, key) => { - const { title, fixed, fixLeft, width } = ColumnsMap[key] - - if (fixed) { - const config = { - id: key, - title, - fix: true, - checked: true, - fixLeft, - width, - } - return [...acc, config] - } - else { - return acc - } - }, []) -} - const show = ref(false) const checkAll = ref(false) @@ -152,10 +90,10 @@ async function handleSumbit(e: MouseEvent) { const userInfo = userStore.getUserInfo let userFieldFixed = '' let userFieldUnFixed = '' - fixLeftList.value.map((v) => { + fixLeftList.value.forEach((v) => { userFieldFixed += `${v.id},` }) - onList.value.map((v) => { + onList.value.forEach((v) => { userFieldUnFixed += `${v.id},` }) userFieldFixed = userFieldFixed.slice(0, userFieldFixed.length - 1) @@ -207,7 +145,7 @@ function onCheckAllChange(value) { } } if (value) { - offList.value.map((v) => { + offList.value.forEach((v) => { if (!v.checked) onList.value.push(v) }) @@ -215,7 +153,7 @@ function onCheckAllChange(value) { else { onList.value = [] fixLeftList.value = [] - offList.value.map((v) => { + offList.value.forEach((v) => { if (v.fix) fixLeftList.value.push(v) }) @@ -330,21 +268,21 @@ function removeHandler(id: string, type: 'fix' | 'unfix') { offList.value[index].checked = false } else { - index == fixLeftList.value.findIndex(v => v.id == id) + index = fixLeftList.value.findIndex(v => v.id == id) fixLeftList.value[index].checked = false } } const indeterminate = computed(() => { - let baseNum = 0 - offList.value.map((v) => { - if (v.fix) - baseNum += 1 - }) return ( - onList.value.length + fixLeftList.value.length - baseNum > 0 - && offList.value.length - baseNum - > onList.value.length + fixLeftList.value.length - baseNum + onList.value.length + + fixLeftList.value.length + - offList.value.filter(v => v.fix).length + > 0 + && offList.value.length - offList.value.filter(v => v.fix).length + > onList.value.length + + fixLeftList.value.length + - offList.value.filter(v => v.fix).length ) }) @@ -553,8 +491,7 @@ const indeterminate = computed(() => { .textbtnStyle { cursor: pointer; - color: #507AFD; - + color: #507afd; } .drag-wrapper { @@ -615,7 +552,7 @@ const indeterminate = computed(() => { ::v-deep(.n-button--info-type) { background: #507afd !important; } -::v-deep(.n-button--default-type){ +::v-deep(.n-button--default-type) { border: 1px solid #cad2dd !important; } // ::v-deep(.n-card__content){ diff --git a/src/views/final/comp/FilterModal.vue b/src/views/final/comp/FilterModal.vue index 0ee4b3a..a66639b 100644 --- a/src/views/final/comp/FilterModal.vue +++ b/src/views/final/comp/FilterModal.vue @@ -166,20 +166,20 @@ function handleCheck(rowKeys: DataTableRowKey[]) { } function select(key: number, id: string) { - if (key == 1) { + if (key == 1) editSelection(id) - } - else { - const modalInst = modal.create({ - title: '确认提示', - content: '确认删除该条过滤条件吗?', - positiveText: '确定', - negativeText: '取消', - preset: 'dialog', - onPositiveClick: () => deleteSelection(id), - onNegativeClick: () => modalInst.destroy(), - }) - } + + else + deleteSelection(id) + // const modalInst = modal.create({ + // title: "确认提示", + // content: "确认删除该条过滤条件吗?", + // positiveText: "确定", + // negativeText: "取消", + // preset: "dialog", + // onPositiveClick: () => deleteSelection(id), + // onNegativeClick: () => modalInst.destroy(), + // }); } function editSelection(id = '') { diff --git a/src/views/final/comp/NewFilterModal.vue b/src/views/final/comp/NewFilterModal.vue index 0700ec1..2d30431 100644 --- a/src/views/final/comp/NewFilterModal.vue +++ b/src/views/final/comp/NewFilterModal.vue @@ -302,6 +302,7 @@ defineExpose({ v-model:value="formValue.name" :style="{ width: '780px' }" placeholder="请输入过滤名称" + maxlength="15" @keydown.enter.prevent /> diff --git a/src/views/home/aside/comp/AdvanceFilter.vue b/src/views/home/aside/comp/AdvanceFilter.vue index 4a53379..0d0cf83 100644 --- a/src/views/home/aside/comp/AdvanceFilter.vue +++ b/src/views/home/aside/comp/AdvanceFilter.vue @@ -200,8 +200,7 @@ function favoriteHandler(event: MouseEvent, item: any) { data.value.forEach((v, index) => { if (v.id == id) sort(v.id, 0) - else - sort(v.id, index + 1) + else sort(v.id, index + 1) }) inputHandler(ruleForm.keyword) @@ -216,8 +215,7 @@ const rules = { validator(_rule, value) { if (value.length >= 2) return true - else - return new Error('搜索关键字最少为两个') + else return new Error('搜索关键字最少为两个') }, }, ], @@ -277,14 +275,20 @@ defineExpose({ >