From 966571bdcb11c2729ab9ce212bd3e195f7bf3a59 Mon Sep 17 00:00:00 2001 From: liuzhidong <51448229+liuzhidong0918@users.noreply.github.com> Date: Mon, 7 Jun 2021 12:23:34 +0800 Subject: [PATCH 1/5] fix(Tinymce): Read only status upload button can also be used (#718) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit *修复富文本组件在只读状态下上传图片按钮也能点击的bug --- src/components/Tinymce/src/Editor.vue | 8 ++++++++ src/components/Tinymce/src/ImgUpload.vue | 18 +++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/components/Tinymce/src/Editor.vue b/src/components/Tinymce/src/Editor.vue index 72223f721..de9419707 100644 --- a/src/components/Tinymce/src/Editor.vue +++ b/src/components/Tinymce/src/Editor.vue @@ -6,6 +6,7 @@ @done="handleDone" v-if="showImageUpload" v-show="editorRef" + :disabled="disabled" /> @@ -170,6 +171,12 @@ }; }); + const disabled = computed(() => { + const { options } = props; + const getdDisabled = options && Reflect.get(options, 'readonly'); + return getdDisabled ?? false; + }); + watch( () => attrs.disabled, () => { @@ -301,6 +308,7 @@ handleDone, editorRef, fullscreen, + disabled, }; }, }); diff --git a/src/components/Tinymce/src/ImgUpload.vue b/src/components/Tinymce/src/ImgUpload.vue index 41c8ce6de..2963a50c7 100644 --- a/src/components/Tinymce/src/ImgUpload.vue +++ b/src/components/Tinymce/src/ImgUpload.vue @@ -8,14 +8,14 @@ :showUploadList="false" accept=".jpg,.jpeg,.gif,.png,.webp" > - + {{ t('component.upload.imgUpload') }} diff --git a/src/components/Table/src/components/settings/ColumnSetting.vue b/src/components/Table/src/components/settings/ColumnSetting.vue index 9c78c8269..e77dae9b6 100644 --- a/src/components/Table/src/components/settings/ColumnSetting.vue +++ b/src/components/Table/src/components/settings/ColumnSetting.vue @@ -114,7 +114,7 @@ import { getPopupContainer } from '/@/utils'; import { omit } from 'lodash-es'; - import type { BasicColumn } from '../../types/table'; + import type { BasicColumn, ColumnChangeParam } from '../../types/table'; interface State { checkAll: boolean; @@ -141,8 +141,9 @@ Divider, Icon, }, + emits: ['columns-change'], - setup() { + setup(_, { emit }) { const { t } = useI18n(); const table = useTableContext(); @@ -234,10 +235,10 @@ const checkList = plainOptions.value.map((item) => item.value); if (e.target.checked) { state.checkedList = checkList; - table.setColumns(checkList); + setColumns(checkList); } else { state.checkedList = []; - table.setColumns([]); + setColumns([]); } } @@ -257,7 +258,7 @@ checkedList.sort((prev, next) => { return sortList.indexOf(prev) - sortList.indexOf(next); }); - table.setColumns(checkedList); + setColumns(checkedList); } // reset columns @@ -266,7 +267,7 @@ state.checkAll = true; plainOptions.value = unref(cachePlainOptions); plainSortOptions.value = unref(cachePlainOptions); - table.setColumns(table.getCacheColumns()); + setColumns(table.getCacheColumns()); } // Open the pop-up window for drag and drop initialization @@ -298,7 +299,7 @@ plainSortOptions.value = columns; plainOptions.value = columns; - table.setColumns(columns); + setColumns(columns); }, }); initSortable(); @@ -335,7 +336,21 @@ item.width = 100; } table.setCacheColumnsByField?.(item.dataIndex, { fixed: isFixed }); + setColumns(columns); + } + + function setColumns(columns: BasicColumn[] | string[]) { table.setColumns(columns); + const data: ColumnChangeParam[] = unref(plainOptions).map((col) => { + const visible = + columns.findIndex( + (c: BasicColumn | string) => + c === col.value || (typeof c !== 'string' && c.dataIndex === col.value) + ) !== -1; + return { dataIndex: col.value, fixed: col.fixed, visible }; + }); + + emit('columns-change', data); } return { diff --git a/src/components/Table/src/components/settings/index.vue b/src/components/Table/src/components/settings/index.vue index ed0799934..4c0b054d0 100644 --- a/src/components/Table/src/components/settings/index.vue +++ b/src/components/Table/src/components/settings/index.vue @@ -2,13 +2,13 @@
- +
diff --git a/src/components/Table/src/hooks/useTableHeader.ts b/src/components/Table/src/hooks/useTableHeader.ts index 93c3ef4a6..a3e77a29a 100644 --- a/src/components/Table/src/hooks/useTableHeader.ts +++ b/src/components/Table/src/hooks/useTableHeader.ts @@ -1,5 +1,5 @@ import type { ComputedRef, Slots } from 'vue'; -import type { BasicTableProps } from '../types/table'; +import type { BasicTableProps, InnerHandlers } from '../types/table'; import { unref, computed, h } from 'vue'; import TableHeader from '../components/TableHeader.vue'; @@ -7,7 +7,11 @@ import TableHeader from '../components/TableHeader.vue'; import { isString } from '/@/utils/is'; import { getSlot } from '/@/utils/helper/tsxHelper'; -export function useTableHeader(propsRef: ComputedRef, slots: Slots) { +export function useTableHeader( + propsRef: ComputedRef, + slots: Slots, + handlers: InnerHandlers +) { const getHeaderProps = computed((): Recordable => { const { title, showTableSetting, titleHelpMessage, tableSetting } = unref(propsRef); const hideTitle = !slots.tableTitle && !title && !slots.toolbar && !showTableSetting; @@ -26,6 +30,7 @@ export function useTableHeader(propsRef: ComputedRef, slots: Sl titleHelpMessage, showTableSetting, tableSetting, + onColumnsChange: handlers.onColumnsChange, } as Recordable, { ...(slots.toolbar diff --git a/src/components/Table/src/types/table.ts b/src/components/Table/src/types/table.ts index 7e61c015c..9b5b217ab 100644 --- a/src/components/Table/src/types/table.ts +++ b/src/components/Table/src/types/table.ts @@ -381,6 +381,8 @@ export interface BasicTableProps { * @param expandedRows */ onExpandedRowsChange?: (expandedRows: string[] | number[]) => void; + + onColumnsChange?: (data: ColumnChangeParam[]) => void; } export type CellFormat = @@ -427,3 +429,13 @@ export interface BasicColumn extends ColumnProps { // 业务控制是否显示 ifShow?: boolean | ((column: BasicColumn) => boolean); } + +export type ColumnChangeParam = { + dataIndex: string; + fixed: boolean | 'left' | 'right' | undefined; + visible: boolean; +}; + +export interface InnerHandlers { + onColumnsChange: (data: ColumnChangeParam[]) => void; +} diff --git a/src/views/demo/table/Basic.vue b/src/views/demo/table/Basic.vue index 48cde076c..4d8e88cd1 100644 --- a/src/views/demo/table/Basic.vue +++ b/src/views/demo/table/Basic.vue @@ -11,6 +11,7 @@ :bordered="border" showTableSetting :pagination="pagination" + @columns-change="handleColumnChange" > diff --git a/src/components/Button/src/PopConfirmButton.vue b/src/components/Button/src/PopConfirmButton.vue index 7691cf607..4e546a05e 100644 --- a/src/components/Button/src/PopConfirmButton.vue +++ b/src/components/Button/src/PopConfirmButton.vue @@ -1,31 +1,33 @@