mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-05 19:41:40 +08:00
feat: table切换成TMagicDesign
This commit is contained in:
parent
4090536c97
commit
32a24ad578
@ -9,6 +9,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@element-plus/icons-vue": "^2.0.9",
|
"@element-plus/icons-vue": "^2.0.9",
|
||||||
|
"@tmagic/design": "1.2.0-beta.2",
|
||||||
"@tmagic/element-plus-adapter": "1.2.0-beta.2",
|
"@tmagic/element-plus-adapter": "1.2.0-beta.2",
|
||||||
"@tmagic/form": "1.2.0-beta.2",
|
"@tmagic/form": "1.2.0-beta.2",
|
||||||
"@tmagic/schema": "1.2.0-beta.2",
|
"@tmagic/schema": "1.2.0-beta.2",
|
||||||
|
@ -4,6 +4,7 @@ import 'highlight.js/styles/github.css';
|
|||||||
import './polyfills';
|
import './polyfills';
|
||||||
import { defineClientConfig } from '@vuepress/client';
|
import { defineClientConfig } from '@vuepress/client';
|
||||||
import ElementPlus from 'element-plus';
|
import ElementPlus from 'element-plus';
|
||||||
|
import TMagicDesign from '@tmagic/design';
|
||||||
import MagicElementPlusAdapter from '@tmagic/element-plus-adapter';
|
import MagicElementPlusAdapter from '@tmagic/element-plus-adapter';
|
||||||
import MagicForm from '@tmagic/form';
|
import MagicForm from '@tmagic/form';
|
||||||
import DemoBlock from './demo-block.vue';
|
import DemoBlock from './demo-block.vue';
|
||||||
@ -11,8 +12,8 @@ import DemoBlock from './demo-block.vue';
|
|||||||
export default defineClientConfig({
|
export default defineClientConfig({
|
||||||
enhance({ app, router, siteData }) {
|
enhance({ app, router, siteData }) {
|
||||||
app.use(ElementPlus);
|
app.use(ElementPlus);
|
||||||
|
app.use(TMagicDesign, MagicElementPlusAdapter)
|
||||||
app.use(MagicForm, {
|
app.use(MagicForm, {
|
||||||
uiAdapter: MagicElementPlusAdapter,
|
|
||||||
request: (options: any) => new Promise((resolve) => {
|
request: (options: any) => new Promise((resolve) => {
|
||||||
if (options.url === 'select/remote') {
|
if (options.url === 'select/remote') {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -228,6 +228,7 @@ export default defineUserConfig({
|
|||||||
{ find: /^@tmagic\/form/, replacement: path.join(__dirname, '../../../packages/form/src/index.ts') },
|
{ find: /^@tmagic\/form/, replacement: path.join(__dirname, '../../../packages/form/src/index.ts') },
|
||||||
{ find: /^@tmagic\/utils/, replacement: path.join(__dirname, '../../../packages/utils/src/index.ts') },
|
{ find: /^@tmagic\/utils/, replacement: path.join(__dirname, '../../../packages/utils/src/index.ts') },
|
||||||
{ find: /^@tmagic\/schema/, replacement: path.join(__dirname, '../../../packages/schema/src/index.ts') },
|
{ find: /^@tmagic\/schema/, replacement: path.join(__dirname, '../../../packages/schema/src/index.ts') },
|
||||||
|
{ find: /^@tmagic\/design/, replacement: path.join(__dirname, '../../../packages/design/src/index.ts') },
|
||||||
{ find: /^@tmagic\/element-plus-adapter/, replacement: path.join(__dirname, '../../../packages/element-plus-adapter/src/index.ts') },
|
{ find: /^@tmagic\/element-plus-adapter/, replacement: path.join(__dirname, '../../../packages/element-plus-adapter/src/index.ts') },
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<component :is="uiComponent.component" v-bind="uiProps">
|
<component ref="optionGroup" :is="uiComponent.component" v-bind="uiProps">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</component>
|
</component>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue';
|
import { computed, onMounted, ref } from 'vue';
|
||||||
|
|
||||||
import { getConfig } from './config';
|
import { getConfig } from './config';
|
||||||
|
|
||||||
@ -17,4 +17,10 @@ const props = defineProps<{
|
|||||||
const uiComponent = getConfig('components').optionGroup;
|
const uiComponent = getConfig('components').optionGroup;
|
||||||
|
|
||||||
const uiProps = computed(() => uiComponent.props(props));
|
const uiProps = computed(() => uiComponent.props(props));
|
||||||
|
|
||||||
|
const optionGroup = ref<any>();
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
optionGroup.value.visible = true;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
25
packages/design/src/Popover.vue
Normal file
25
packages/design/src/Popover.vue
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<template>
|
||||||
|
<component :is="uiComponent.component" v-bind="uiProps">
|
||||||
|
<slot></slot>
|
||||||
|
|
||||||
|
<template #reference>
|
||||||
|
<slot name="reference"></slot>
|
||||||
|
</template>
|
||||||
|
</component>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
|
import { getConfig } from './config';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
placement?: string;
|
||||||
|
width?: string;
|
||||||
|
trigger?: string;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const uiComponent = getConfig('components').popover;
|
||||||
|
|
||||||
|
const uiProps = computed(() => uiComponent.props(props));
|
||||||
|
</script>
|
@ -53,5 +53,9 @@ defineExpose({
|
|||||||
toggleRowSelection(...args: any[]) {
|
toggleRowSelection(...args: any[]) {
|
||||||
table.value?.toggleRowSelection(...args);
|
table.value?.toggleRowSelection(...args);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
toggleRowExpansion(...args: any[]) {
|
||||||
|
table.value?.toggleRowExpansion(...args);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
20
packages/design/src/Tag.vue
Normal file
20
packages/design/src/Tag.vue
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<template>
|
||||||
|
<component :is="uiComponent.component" v-bind="uiProps">
|
||||||
|
<slot></slot>
|
||||||
|
</component>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
|
import { getConfig } from './config';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
type?: string;
|
||||||
|
closeTransition?: boolean;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const uiComponent = getConfig('components').tab;
|
||||||
|
|
||||||
|
const uiProps = computed(() => uiComponent.props(props));
|
||||||
|
</script>
|
@ -1,9 +1,10 @@
|
|||||||
import { App } from 'vue';
|
import { App } from 'vue';
|
||||||
|
|
||||||
import { getConfig, setConfig } from './config';
|
import { getConfig, setConfig } from './config';
|
||||||
import { PluginOptions, TMagicMessage } from './type';
|
import { PluginOptions, TMagicMessage, TMagicMessageBox } from './type';
|
||||||
|
|
||||||
export * from './type';
|
export * from './type';
|
||||||
|
export * from './config';
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
export { default as TMagicButton } from './Button.vue';
|
export { default as TMagicButton } from './Button.vue';
|
||||||
@ -23,6 +24,7 @@ export { default as TMagicInputNumber } from './InputNumber.vue';
|
|||||||
export { default as TMagicOption } from './Option.vue';
|
export { default as TMagicOption } from './Option.vue';
|
||||||
export { default as TMagicOptionGroup } from './OptionGroup.vue';
|
export { default as TMagicOptionGroup } from './OptionGroup.vue';
|
||||||
export { default as TMagicPagination } from './Pagination.vue';
|
export { default as TMagicPagination } from './Pagination.vue';
|
||||||
|
export { default as TMagicPopover } from './Popover.vue';
|
||||||
export { default as TMagicRadio } from './Radio.vue';
|
export { default as TMagicRadio } from './Radio.vue';
|
||||||
export { default as TMagicRadioGroup } from './RadioGroup.vue';
|
export { default as TMagicRadioGroup } from './RadioGroup.vue';
|
||||||
export { default as TMagicRow } from './Row.vue';
|
export { default as TMagicRow } from './Row.vue';
|
||||||
@ -34,11 +36,13 @@ export { default as TMagicTable } from './Table.vue';
|
|||||||
export { default as TMagicTableColumn } from './TableColumn.vue';
|
export { default as TMagicTableColumn } from './TableColumn.vue';
|
||||||
export { default as TMagicTabPane } from './TabPane.vue';
|
export { default as TMagicTabPane } from './TabPane.vue';
|
||||||
export { default as TMagicTabs } from './Tabs.vue';
|
export { default as TMagicTabs } from './Tabs.vue';
|
||||||
|
export { default as TMagicTag } from './Tag.vue';
|
||||||
export { default as TMagicTimePicker } from './TimePicker.vue';
|
export { default as TMagicTimePicker } from './TimePicker.vue';
|
||||||
export { default as TMagicTooltip } from './Tooltip.vue';
|
export { default as TMagicTooltip } from './Tooltip.vue';
|
||||||
export { default as TMagicUpload } from './Upload.vue';
|
export { default as TMagicUpload } from './Upload.vue';
|
||||||
|
|
||||||
export const tMagicMessage: TMagicMessage = getConfig('message') as TMagicMessage;
|
export const tMagicMessage: TMagicMessage = getConfig('message') as TMagicMessage;
|
||||||
|
export const tMagicMessageBox: TMagicMessageBox = getConfig('messageBox') as TMagicMessageBox;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
install(app: App, options: PluginOptions) {
|
install(app: App, options: PluginOptions) {
|
||||||
|
@ -14,7 +14,26 @@ export interface TMagicMessage {
|
|||||||
error: (msg: string) => void;
|
error: (msg: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ElMessageBoxShortcutMethod = ((
|
||||||
|
message: string,
|
||||||
|
title: string,
|
||||||
|
options?: any,
|
||||||
|
appContext?: any | null,
|
||||||
|
) => Promise<any>) &
|
||||||
|
((message: string, options?: any, appContext?: any | null) => Promise<any>);
|
||||||
|
|
||||||
|
export interface TMagicMessageBox {
|
||||||
|
alert: ElMessageBoxShortcutMethod;
|
||||||
|
|
||||||
|
confirm: ElMessageBoxShortcutMethod;
|
||||||
|
|
||||||
|
prompt: ElMessageBoxShortcutMethod;
|
||||||
|
|
||||||
|
close(): void;
|
||||||
|
}
|
||||||
|
|
||||||
export interface PluginOptions {
|
export interface PluginOptions {
|
||||||
message?: TMagicMessage;
|
message?: TMagicMessage;
|
||||||
|
messageBox?: TMagicMessageBox;
|
||||||
components?: Record<string, any>;
|
components?: Record<string, any>;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import {
|
|||||||
ElInput,
|
ElInput,
|
||||||
ElInputNumber,
|
ElInputNumber,
|
||||||
ElMessage,
|
ElMessage,
|
||||||
|
ElMessageBox,
|
||||||
ElOption,
|
ElOption,
|
||||||
ElOptionGroup,
|
ElOptionGroup,
|
||||||
ElPagination,
|
ElPagination,
|
||||||
@ -35,6 +36,7 @@ import {
|
|||||||
|
|
||||||
const adapter: any = {
|
const adapter: any = {
|
||||||
message: ElMessage,
|
message: ElMessage,
|
||||||
|
messageBox: ElMessageBox,
|
||||||
components: {
|
components: {
|
||||||
button: {
|
button: {
|
||||||
component: ElButton,
|
component: ElButton,
|
||||||
@ -176,6 +178,11 @@ const adapter: any = {
|
|||||||
props: (props: any) => props,
|
props: (props: any) => props,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
tag: {
|
||||||
|
component: ElTabs,
|
||||||
|
props: (props: any) => props,
|
||||||
|
},
|
||||||
|
|
||||||
timePicker: {
|
timePicker: {
|
||||||
component: ElTimePicker,
|
component: ElTimePicker,
|
||||||
props: (props: any) => props,
|
props: (props: any) => props,
|
||||||
|
@ -1,22 +1,25 @@
|
|||||||
<template>
|
<template>
|
||||||
<TMagicOptionGroup v-for="(group, index) in options" :key="index" :label="group.label" :disabled="group.disabled">
|
<TMagicOptionGroup v-for="(group, index) in options" :key="index" :label="group.label" :disabled="group.disabled">
|
||||||
<TMagicOption
|
<component
|
||||||
v-for="(item, index) in group.options"
|
v-for="(item, index) in group.options"
|
||||||
|
:is="uiComponent.component"
|
||||||
:key="index"
|
:key="index"
|
||||||
:label="item.label"
|
:label="item.label || item.text"
|
||||||
:value="item.value"
|
:value="item.value"
|
||||||
:disabled="item.disabled"
|
:disabled="item.disabled"
|
||||||
>
|
>
|
||||||
</TMagicOption>
|
</component>
|
||||||
</TMagicOptionGroup>
|
</TMagicOptionGroup>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { TMagicOption, TMagicOptionGroup } from '@tmagic/design';
|
import { getConfig, TMagicOptionGroup } from '@tmagic/design';
|
||||||
|
|
||||||
import { SelectGroupOption } from '../schema';
|
import { SelectGroupOption } from '../schema';
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
options: SelectGroupOption[];
|
options: SelectGroupOption[];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const uiComponent = getConfig('components').option;
|
||||||
</script>
|
</script>
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
|
|
||||||
import { App } from 'vue';
|
import { App } from 'vue';
|
||||||
|
|
||||||
import TMagicDesign from '@tmagic/design';
|
|
||||||
|
|
||||||
import Container from './containers/Container.vue';
|
import Container from './containers/Container.vue';
|
||||||
import Fieldset from './containers/Fieldset.vue';
|
import Fieldset from './containers/Fieldset.vue';
|
||||||
import GroupList from './containers/GroupList.vue';
|
import GroupList from './containers/GroupList.vue';
|
||||||
@ -87,8 +85,6 @@ export { default as MDynamicField } from './fields/DynamicField.vue';
|
|||||||
const defaultInstallOpt = {};
|
const defaultInstallOpt = {};
|
||||||
|
|
||||||
const install = (app: App, opt: any) => {
|
const install = (app: App, opt: any) => {
|
||||||
app.use(TMagicDesign, opt.uiAdapter);
|
|
||||||
|
|
||||||
const option = Object.assign(defaultInstallOpt, opt);
|
const option = Object.assign(defaultInstallOpt, opt);
|
||||||
|
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
|
@ -215,7 +215,8 @@ export interface SelectGroupOption {
|
|||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
options: {
|
options: {
|
||||||
/** 选项的标签 */
|
/** 选项的标签 */
|
||||||
label: string;
|
label?: string;
|
||||||
|
text?: string;
|
||||||
/** 选项的值 */
|
/** 选项的值 */
|
||||||
value: any;
|
value: any;
|
||||||
/** 是否禁用该选项 */
|
/** 是否禁用该选项 */
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
"url": "https://github.com/Tencent/tmagic-editor.git"
|
"url": "https://github.com/Tencent/tmagic-editor.git"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@tmagic/design": "1.2.0-beta.2",
|
||||||
"@tmagic/form": "1.2.0-beta.2",
|
"@tmagic/form": "1.2.0-beta.2",
|
||||||
"@tmagic/utils": "1.2.0-beta.2",
|
"@tmagic/utils": "1.2.0-beta.2",
|
||||||
"element-plus": "^2.2.17",
|
"element-plus": "^2.2.17",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-table-column :label="config.label" :width="config.width" :fixed="config.fixed">
|
<TMagicTableColumn :label="config.label" :width="config.width" :fixed="config.fixed">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-button
|
<TMagicButton
|
||||||
v-for="(action, actionIndex) in config.actions"
|
v-for="(action, actionIndex) in config.actions"
|
||||||
v-show="display(action.display, scope.row) && !editState[scope.$index]"
|
v-show="display(action.display, scope.row) && !editState[scope.$index]"
|
||||||
v-html="action.text"
|
v-html="action.text"
|
||||||
@ -11,60 +11,48 @@
|
|||||||
size="small"
|
size="small"
|
||||||
:key="actionIndex"
|
:key="actionIndex"
|
||||||
@click="actionHandler(action, scope.row, scope.$index)"
|
@click="actionHandler(action, scope.row, scope.$index)"
|
||||||
></el-button>
|
></TMagicButton>
|
||||||
<el-button
|
<TMagicButton
|
||||||
class="action-btn"
|
class="action-btn"
|
||||||
v-show="editState[scope.$index]"
|
v-show="editState[scope.$index]"
|
||||||
text
|
text
|
||||||
type="primary"
|
type="primary"
|
||||||
size="small"
|
size="small"
|
||||||
@click="save(scope.$index, config)"
|
@click="save(scope.$index, config)"
|
||||||
>保存</el-button
|
>保存</TMagicButton
|
||||||
>
|
>
|
||||||
<el-button
|
<TMagicButton
|
||||||
class="action-btn"
|
class="action-btn"
|
||||||
v-show="editState[scope.$index]"
|
v-show="editState[scope.$index]"
|
||||||
text
|
text
|
||||||
type="primary"
|
type="primary"
|
||||||
size="small"
|
size="small"
|
||||||
@click="editState[scope.$index] = undefined"
|
@click="editState[scope.$index] = undefined"
|
||||||
>取消</el-button
|
>取消</TMagicButton
|
||||||
>
|
>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</TMagicTableColumn>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { PropType } from 'vue';
|
import { TMagicButton, tMagicMessage, tMagicMessageBox, TMagicTableColumn } from '@tmagic/design';
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
|
||||||
|
|
||||||
import { ColumnActionConfig, ColumnConfig } from './schema';
|
import { ColumnActionConfig, ColumnConfig } from './schema';
|
||||||
</script>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
const props = withDefaults(
|
||||||
const props = defineProps({
|
defineProps<{
|
||||||
columns: {
|
columns: any[];
|
||||||
type: Array as PropType<any[]>,
|
config: ColumnConfig;
|
||||||
require: true,
|
rowkeyName?: string;
|
||||||
default: () => [],
|
editState?: any;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
columns: () => [],
|
||||||
|
config: () => ({}),
|
||||||
|
rowkeyName: 'c_id',
|
||||||
|
editState: () => [],
|
||||||
},
|
},
|
||||||
|
);
|
||||||
config: {
|
|
||||||
type: Object as PropType<ColumnConfig>,
|
|
||||||
require: true,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
|
|
||||||
rowkeyName: {
|
|
||||||
type: String,
|
|
||||||
default: 'c_id',
|
|
||||||
},
|
|
||||||
|
|
||||||
editState: {
|
|
||||||
type: Object,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits(['afterAction']);
|
const emit = defineEmits(['afterAction']);
|
||||||
|
|
||||||
@ -76,14 +64,14 @@ const display = (fuc: boolean | Function | undefined, row: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const success = (msg: string, action: ColumnActionConfig, row: any) => {
|
const success = (msg: string, action: ColumnActionConfig, row: any) => {
|
||||||
ElMessage.success(msg);
|
tMagicMessage.success(msg);
|
||||||
action.after?.(row);
|
action.after?.(row);
|
||||||
};
|
};
|
||||||
|
|
||||||
const error = (msg: string) => ElMessage.error(msg);
|
const error = (msg: string) => tMagicMessage.error(msg);
|
||||||
|
|
||||||
const deleteAction = async (action: ColumnActionConfig, row: any) => {
|
const deleteAction = async (action: ColumnActionConfig, row: any) => {
|
||||||
await ElMessageBox.confirm(`确认删除${row[action.name || 'c_name']}(${row[props.rowkeyName]})?`, '提示', {
|
await tMagicMessageBox.confirm(`确认删除${row[action.name || 'c_name']}(${row[props.rowkeyName]})?`, '提示', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
@ -99,7 +87,7 @@ const deleteAction = async (action: ColumnActionConfig, row: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const copyHandler = async (action: ColumnActionConfig, row: any) => {
|
const copyHandler = async (action: ColumnActionConfig, row: any) => {
|
||||||
await ElMessageBox.confirm(`确定复制${row[action.name || 'c_name']}(${row.c_id})?`, '提示', {
|
await tMagicMessageBox.confirm(`确定复制${row[action.name || 'c_name']}(${row.c_id})?`, '提示', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
@ -150,16 +138,11 @@ const save = async (index: number, config: ColumnConfig) => {
|
|||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
if (res.ret === 0) {
|
if (res.ret === 0) {
|
||||||
ElMessage.success('保存成功');
|
tMagicMessage.success('保存成功');
|
||||||
props.editState[index] = undefined;
|
props.editState[index] = undefined;
|
||||||
emit('afterAction');
|
emit('afterAction');
|
||||||
} else {
|
} else {
|
||||||
ElMessage.error({
|
tMagicMessage.error(res.msg || '保存失败');
|
||||||
duration: 10000,
|
|
||||||
showClose: true,
|
|
||||||
dangerouslyUseHTMLString: true,
|
|
||||||
message: res.msg || '保存失败',
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
props.editState[index] = undefined;
|
props.editState[index] = undefined;
|
||||||
|
@ -1,37 +1,34 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-table-column type="expand">
|
<TMagicTableColumn type="expand">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<m-table
|
<MTable
|
||||||
v-if="config.table"
|
v-if="config.table"
|
||||||
:show-header="false"
|
:show-header="false"
|
||||||
:columns="config.table"
|
:columns="config.table"
|
||||||
:data="scope.row[config.prop]"
|
:data="(config.prop && scope.row[config.prop]) || []"
|
||||||
></m-table>
|
></MTable>
|
||||||
<m-form
|
<MForm
|
||||||
v-if="config.form"
|
v-if="config.form"
|
||||||
:config="config.form"
|
:config="config.form"
|
||||||
:init-values="config.values || scope.row[config.prop] || {}"
|
:init-values="config.values || (config.prop && scope.row[config.prop]) || {}"
|
||||||
></m-form>
|
></MForm>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</TMagicTableColumn>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, PropType } from 'vue';
|
import { TMagicTableColumn } from '@tmagic/design';
|
||||||
|
|
||||||
import { MForm } from '@tmagic/form';
|
import { MForm } from '@tmagic/form';
|
||||||
|
|
||||||
import { ColumnConfig } from './schema';
|
import { ColumnConfig } from './schema';
|
||||||
|
import MTable from './Table.vue';
|
||||||
|
|
||||||
export default defineComponent({
|
withDefaults(
|
||||||
components: { MForm },
|
defineProps<{
|
||||||
|
config: ColumnConfig;
|
||||||
props: {
|
}>(),
|
||||||
config: {
|
{
|
||||||
type: Object as PropType<ColumnConfig>,
|
config: () => ({}),
|
||||||
default: () => ({}),
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
);
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,40 +1,39 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-table-column :label="config.label" :width="config.width" :fixed="config.fixed">
|
<TMagicTableColumn :label="config.label" :width="config.width" :fixed="config.fixed">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-popover :placement="config.popover.placement" :width="config.popover.width" :trigger="config.popover.trigger">
|
<TMagicPopover
|
||||||
<m-table
|
v-if="config.popover"
|
||||||
|
:placement="config.popover.placement"
|
||||||
|
:width="config.popover.width"
|
||||||
|
:trigger="config.popover.trigger"
|
||||||
|
>
|
||||||
|
<MTable
|
||||||
v-if="config.popover.tableEmbed"
|
v-if="config.popover.tableEmbed"
|
||||||
:show-header="config.showHeader"
|
:show-header="config.showHeader"
|
||||||
:columns="config.table"
|
:columns="config.table"
|
||||||
:data="scope.row[config.prop]"
|
:data="(config.prop && scope.row[config.prop]) || []"
|
||||||
></m-table>
|
></MTable>
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<el-button text type="primary"> {{ config.text || formatter(config, scope.row) }}</el-button>
|
<TMagicButton text type="primary"> {{ config.text || formatter(config, scope.row) }}</TMagicButton>
|
||||||
</template>
|
</template>
|
||||||
</el-popover>
|
</TMagicPopover>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</TMagicTableColumn>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, PropType } from 'vue';
|
import { TMagicButton, TMagicPopover, TMagicTableColumn } from '@tmagic/design';
|
||||||
|
|
||||||
import { ColumnConfig } from './schema';
|
import { ColumnConfig } from './schema';
|
||||||
|
import MTable from './Table.vue';
|
||||||
import { formatter } from './utils';
|
import { formatter } from './utils';
|
||||||
|
|
||||||
export default defineComponent({
|
withDefaults(
|
||||||
props: {
|
defineProps<{
|
||||||
config: {
|
config: ColumnConfig;
|
||||||
type: Object as PropType<ColumnConfig>,
|
}>(),
|
||||||
default: () => ({}),
|
{
|
||||||
required: true,
|
config: () => ({}),
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
);
|
||||||
setup() {
|
|
||||||
return {
|
|
||||||
formatter,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-table
|
<TMagicTable
|
||||||
tooltip-effect="dark"
|
tooltip-effect="dark"
|
||||||
class="m-table"
|
class="m-table"
|
||||||
ref="table"
|
ref="tMagicTable"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
:data="tableData"
|
:data="tableData"
|
||||||
:show-header="showHeader"
|
:show-header="showHeader"
|
||||||
@ -20,187 +20,151 @@
|
|||||||
>
|
>
|
||||||
<template v-for="(item, columnIndex) in columns">
|
<template v-for="(item, columnIndex) in columns">
|
||||||
<template v-if="item.type === 'expand'">
|
<template v-if="item.type === 'expand'">
|
||||||
<expand-column :config="item" :key="columnIndex"></expand-column>
|
<ExpandColumn :config="item" :key="columnIndex"></ExpandColumn>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-else-if="item.selection">
|
<template v-else-if="item.selection">
|
||||||
<el-table-column type="selection" :key="columnIndex" width="40" :selectable="item.selectable"></el-table-column>
|
<TMagicTableColumn
|
||||||
|
type="selection"
|
||||||
|
:key="columnIndex"
|
||||||
|
width="40"
|
||||||
|
:selectable="item.selectable"
|
||||||
|
></TMagicTableColumn>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-else-if="item.actions">
|
<template v-else-if="item.actions">
|
||||||
<actions-column
|
<ActionsColumn
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:config="item"
|
:config="item"
|
||||||
:rowkey-name="rowkeyName"
|
:rowkey-name="rowkeyName"
|
||||||
:edit-state="editState"
|
:edit-state="editState"
|
||||||
:key="columnIndex"
|
:key="columnIndex"
|
||||||
@afterAction="$emit('afterAction')"
|
@afterAction="$emit('afterAction')"
|
||||||
></actions-column>
|
></ActionsColumn>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-else-if="item.type === 'popover'">
|
<template v-else-if="item.type === 'popover'">
|
||||||
<popover-column :key="columnIndex" :config="item"></popover-column>
|
<PopoverColumn :key="columnIndex" :config="item"></PopoverColumn>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<text-column :key="columnIndex" :config="item" :edit-state="editState"></text-column>
|
<TextColumn :key="columnIndex" :config="item" :edit-state="editState"></TextColumn>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</el-table>
|
</TMagicTable>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, PropType } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { ElTable } from 'element-plus';
|
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep } from 'lodash-es';
|
||||||
|
|
||||||
|
import { TMagicTable, TMagicTableColumn } from '@tmagic/design';
|
||||||
|
|
||||||
import ActionsColumn from './ActionsColumn.vue';
|
import ActionsColumn from './ActionsColumn.vue';
|
||||||
import ExpandColumn from './ExpandColumn.vue';
|
import ExpandColumn from './ExpandColumn.vue';
|
||||||
import PopoverColumn from './PopoverColumn.vue';
|
import PopoverColumn from './PopoverColumn.vue';
|
||||||
import TextColumn from './TextColumn.vue';
|
import TextColumn from './TextColumn.vue';
|
||||||
|
|
||||||
export default defineComponent({
|
const props = withDefaults(
|
||||||
name: 'm-table',
|
defineProps<{
|
||||||
|
data: any[];
|
||||||
components: { ExpandColumn, ActionsColumn, PopoverColumn, TextColumn },
|
columns?: any[];
|
||||||
|
|
||||||
props: {
|
|
||||||
data: {
|
|
||||||
type: Array,
|
|
||||||
require: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
columns: {
|
|
||||||
type: Array as PropType<any[]>,
|
|
||||||
require: true,
|
|
||||||
default: () => [],
|
|
||||||
},
|
|
||||||
|
|
||||||
/** 合并行或列的计算方法 */
|
/** 合并行或列的计算方法 */
|
||||||
spanMethod: {
|
spanMethod?: (data: { row: any; column: any; rowIndex: number; columnIndex: number }) => [number, number];
|
||||||
type: Function as PropType<
|
loading?: boolean;
|
||||||
(data: { row: any; column: any; rowIndex: number; columnIndex: number }) => [number, number]
|
|
||||||
>,
|
|
||||||
},
|
|
||||||
|
|
||||||
loading: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
|
|
||||||
/** Table 的最大高度。合法的值为数字或者单位为 px 的高度 */
|
/** Table 的最大高度。合法的值为数字或者单位为 px 的高度 */
|
||||||
bodyHeight: {
|
bodyHeight?: string | number;
|
||||||
type: [String, Number],
|
|
||||||
},
|
|
||||||
|
|
||||||
/** 是否显示表头 */
|
/** 是否显示表头 */
|
||||||
showHeader: {
|
showHeader?: boolean;
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
/** 空数据时显示的文本内容 */
|
/** 空数据时显示的文本内容 */
|
||||||
emptyText: {
|
emptyText?: string;
|
||||||
type: String,
|
|
||||||
},
|
|
||||||
|
|
||||||
/** 是否默认展开所有行,当 Table 包含展开行存在或者为树形表格时有效 */
|
/** 是否默认展开所有行,当 Table 包含展开行存在或者为树形表格时有效 */
|
||||||
defaultExpandAll: {
|
defaultExpandAll?: boolean;
|
||||||
type: Boolean,
|
rowkeyName?: string;
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
|
|
||||||
rowkeyName: {
|
|
||||||
type: String,
|
|
||||||
},
|
|
||||||
|
|
||||||
/** 是否带有纵向边框 */
|
/** 是否带有纵向边框 */
|
||||||
border: {
|
border?: boolean;
|
||||||
type: Boolean,
|
}>(),
|
||||||
default: false,
|
{
|
||||||
},
|
columns: () => [],
|
||||||
|
loading: false,
|
||||||
|
showHeader: true,
|
||||||
|
defaultExpandAll: false,
|
||||||
|
border: false,
|
||||||
},
|
},
|
||||||
|
);
|
||||||
|
|
||||||
emits: ['sort-change', 'afterAction', 'select', 'select-all', 'selection-change'],
|
const emit = defineEmits(['sort-change', 'afterAction', 'select', 'select-all', 'selection-change']);
|
||||||
|
|
||||||
data(): {
|
const tMagicTable = ref<InstanceType<typeof TMagicTable>>();
|
||||||
editState: any[];
|
|
||||||
} {
|
|
||||||
return {
|
|
||||||
editState: [],
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
const editState = ref([]);
|
||||||
tableData() {
|
|
||||||
if (this.selectionColumn) {
|
|
||||||
return this.data || [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return cloneDeep(this.data) || [];
|
const selectionColumn = computed(() => {
|
||||||
},
|
const column = props.columns.filter((item) => item.selection);
|
||||||
|
return column.length ? column[0] : null;
|
||||||
|
});
|
||||||
|
|
||||||
selectionColumn() {
|
const tableData = computed(() => {
|
||||||
const column = this.columns.filter((item) => item.selection);
|
if (selectionColumn.value) {
|
||||||
return column.length ? column[0] : null;
|
return props.data || [];
|
||||||
},
|
}
|
||||||
|
|
||||||
hasBorder() {
|
return cloneDeep(props.data) || [];
|
||||||
return typeof this.border !== 'undefined' ? this.border : true;
|
});
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
const hasBorder = computed(() => (typeof props.border !== 'undefined' ? props.border : true));
|
||||||
sortChange(data: any) {
|
|
||||||
this.$emit('sort-change', data);
|
|
||||||
},
|
|
||||||
|
|
||||||
selectHandler(selection: any, row: any) {
|
const sortChange = (data: any) => {
|
||||||
const column = this.selectionColumn;
|
emit('sort-change', data);
|
||||||
if (!column) {
|
};
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (column.selection === 'single') {
|
const selectHandler = (selection: any, row: any) => {
|
||||||
// this.clearSelection()
|
const column = selectionColumn.value;
|
||||||
// this.toggleRowSelection(row, true)
|
if (!column) {
|
||||||
}
|
return;
|
||||||
this.$emit('select', selection, row);
|
}
|
||||||
},
|
|
||||||
|
|
||||||
selectAllHandler(selection: any) {
|
if (column.selection === 'single') {
|
||||||
this.$emit('select-all', selection);
|
// this.clearSelection()
|
||||||
},
|
// this.toggleRowSelection(row, true)
|
||||||
|
}
|
||||||
|
emit('select', selection, row);
|
||||||
|
};
|
||||||
|
|
||||||
selectionChangeHandler(selection: any) {
|
const selectAllHandler = (selection: any) => {
|
||||||
this.$emit('selection-change', selection);
|
emit('select-all', selection);
|
||||||
},
|
};
|
||||||
|
|
||||||
toggleRowSelection(row: any, selected: boolean) {
|
const selectionChangeHandler = (selection: any) => {
|
||||||
const table = this.$refs.table as InstanceType<typeof ElTable>;
|
emit('selection-change', selection);
|
||||||
table.toggleRowSelection.bind(table)(row, selected);
|
};
|
||||||
},
|
|
||||||
|
|
||||||
toggleRowExpansion(row: any, expanded: boolean) {
|
const toggleRowSelection = (row: any, selected: boolean) => {
|
||||||
const table = this.$refs.table as InstanceType<typeof ElTable>;
|
tMagicTable.value?.toggleRowSelection(row, selected);
|
||||||
table.toggleRowExpansion.bind(table)(row, expanded);
|
};
|
||||||
},
|
|
||||||
|
|
||||||
clearSelection() {
|
const toggleRowExpansion = (row: any, expanded: boolean) => {
|
||||||
const table = this.$refs.table as InstanceType<typeof ElTable>;
|
tMagicTable.value?.toggleRowExpansion(row, expanded);
|
||||||
table.clearSelection.bind(table)();
|
};
|
||||||
},
|
|
||||||
|
|
||||||
objectSpanMethod(data: any) {
|
const clearSelection = () => {
|
||||||
if (typeof this.spanMethod === 'function') {
|
tMagicTable.value?.clearSelection();
|
||||||
return this.spanMethod(data);
|
};
|
||||||
}
|
|
||||||
return () => ({
|
const objectSpanMethod = (data: any) => {
|
||||||
rowspan: 0,
|
if (typeof props.spanMethod === 'function') {
|
||||||
colspan: 0,
|
return props.spanMethod(data);
|
||||||
});
|
}
|
||||||
},
|
return () => ({
|
||||||
},
|
rowspan: 0,
|
||||||
|
colspan: 0,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
toggleRowSelection,
|
||||||
|
toggleRowExpansion,
|
||||||
|
clearSelection,
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-table-column
|
<TMagicTableColumn
|
||||||
show-overflow-tooltip
|
show-overflow-tooltip
|
||||||
:label="config.label"
|
:label="config.label"
|
||||||
:width="config.width"
|
:width="config.width"
|
||||||
@ -8,7 +8,7 @@
|
|||||||
:prop="config.prop"
|
:prop="config.prop"
|
||||||
>
|
>
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-form v-if="config.type && editState[scope.$index]" label-width="0" :model="editState[scope.$index]">
|
<TMagicForm v-if="config.type && editState[scope.$index]" label-width="0" :model="editState[scope.$index]">
|
||||||
<m-form-container
|
<m-form-container
|
||||||
:prop="config.prop"
|
:prop="config.prop"
|
||||||
:rules="config.rules"
|
:rules="config.rules"
|
||||||
@ -16,62 +16,61 @@
|
|||||||
:name="config.prop"
|
:name="config.prop"
|
||||||
:model="editState[scope.$index]"
|
:model="editState[scope.$index]"
|
||||||
></m-form-container>
|
></m-form-container>
|
||||||
</el-form>
|
</TMagicForm>
|
||||||
|
|
||||||
<el-button v-else-if="config.action === 'actionLink'" text type="primary" @click="config.handler(scope.row)">
|
<TMagicButton
|
||||||
|
v-else-if="config.action === 'actionLink' && config.prop"
|
||||||
|
text
|
||||||
|
type="primary"
|
||||||
|
@click="config.handler?.(scope.row)"
|
||||||
|
>
|
||||||
{{ formatter(config, scope.row) }}
|
{{ formatter(config, scope.row) }}
|
||||||
</el-button>
|
</TMagicButton>
|
||||||
|
|
||||||
<a v-else-if="config.action === 'img'" target="_blank" :href="scope.row[config.prop]"
|
<a v-else-if="config.action === 'img' && config.prop" target="_blank" :href="scope.row[config.prop]"
|
||||||
><img :src="scope.row[config.prop]" height="50"
|
><img :src="scope.row[config.prop]" height="50"
|
||||||
/></a>
|
/></a>
|
||||||
|
|
||||||
<a v-else-if="config.action === 'link'" target="_blank" :href="scope.row[config.prop]" class="keep-all">{{
|
<a
|
||||||
scope.row[config.prop]
|
v-else-if="config.action === 'link' && config.prop"
|
||||||
}}</a>
|
target="_blank"
|
||||||
|
:href="scope.row[config.prop]"
|
||||||
|
class="keep-all"
|
||||||
|
>{{ scope.row[config.prop] }}</a
|
||||||
|
>
|
||||||
|
|
||||||
<el-tooltip v-else-if="config.action === 'tip'" placement="left">
|
<el-tooltip v-else-if="config.action === 'tip'" placement="left">
|
||||||
<template #content>
|
<template #content>
|
||||||
<div>{{ formatter(config, scope.row) }}</div>
|
<div>{{ formatter(config, scope.row) }}</div>
|
||||||
</template>
|
</template>
|
||||||
<el-button text type="primary">扩展配置</el-button>
|
<TMagicButton text type="primary">扩展配置</TMagicButton>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
|
||||||
<el-tag
|
<TMagicTag
|
||||||
v-else-if="config.action === 'tag'"
|
v-else-if="config.action === 'tag' && config.prop"
|
||||||
:type="typeof config.type === 'function' ? config.type(scope.row[config.prop], scope.row) : config.type"
|
:type="typeof config.type === 'function' ? config.type(scope.row[config.prop], scope.row) : config.type"
|
||||||
close-transition
|
close-transition
|
||||||
>{{ formatter(config, scope.row) }}</el-tag
|
>{{ formatter(config, scope.row) }}</TMagicTag
|
||||||
>
|
>
|
||||||
<div v-else v-html="formatter(config, scope.row)"></div>
|
<div v-else v-html="formatter(config, scope.row)"></div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</TMagicTableColumn>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, PropType } from 'vue';
|
import { TMagicButton, TMagicForm, TMagicTableColumn, TMagicTag } from '@tmagic/design';
|
||||||
|
|
||||||
import { ColumnConfig } from './schema';
|
import { ColumnConfig } from './schema';
|
||||||
import { formatter } from './utils';
|
import { formatter } from './utils';
|
||||||
|
|
||||||
export default defineComponent({
|
withDefaults(
|
||||||
props: {
|
defineProps<{
|
||||||
config: {
|
config: ColumnConfig;
|
||||||
type: Object as PropType<ColumnConfig>,
|
editState?: any;
|
||||||
default: () => ({}),
|
}>(),
|
||||||
required: true,
|
{
|
||||||
},
|
config: () => ({}),
|
||||||
|
editState: () => ({}),
|
||||||
editState: {
|
|
||||||
type: Object,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
);
|
||||||
setup() {
|
|
||||||
return {
|
|
||||||
formatter,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -22,12 +22,8 @@ import Table from './Table.vue';
|
|||||||
|
|
||||||
export { default as MagicTable } from './Table.vue';
|
export { default as MagicTable } from './Table.vue';
|
||||||
|
|
||||||
const components = [Table];
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
install(app: App) {
|
install(app: App) {
|
||||||
components.forEach((component) => {
|
app.component('m-table', Table);
|
||||||
app.component(component.name, component);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -35,23 +35,23 @@ export type ColumnConfig = {
|
|||||||
values?: FormValue;
|
values?: FormValue;
|
||||||
selection?: boolean | 'single';
|
selection?: boolean | 'single';
|
||||||
selectable?: (row: any, index: number) => boolean;
|
selectable?: (row: any, index: number) => boolean;
|
||||||
label: string;
|
label?: string;
|
||||||
fixed?: 'left' | 'right' | boolean;
|
fixed?: 'left' | 'right' | boolean;
|
||||||
width?: number | string;
|
width?: number | string;
|
||||||
actions?: ColumnActionConfig[];
|
actions?: ColumnActionConfig[];
|
||||||
type: 'popover' | 'expand' | string | ((value: any, row: any) => string);
|
type?: 'popover' | 'expand' | string | ((value: any, row: any) => string);
|
||||||
text: string;
|
text?: string;
|
||||||
prop: string;
|
prop?: string;
|
||||||
showHeader: boolean;
|
showHeader?: boolean;
|
||||||
table?: ColumnConfig[];
|
table?: ColumnConfig[];
|
||||||
formatter?: 'datetime' | ((item: any, row: Record<string, any>) => any);
|
formatter?: 'datetime' | ((item: any, row: Record<string, any>) => any);
|
||||||
popover: {
|
popover?: {
|
||||||
placement: '';
|
placement: string;
|
||||||
width: '';
|
width: string;
|
||||||
trigger: '';
|
trigger: string;
|
||||||
tableEmbed: '';
|
tableEmbed: string;
|
||||||
};
|
};
|
||||||
sortable?: boolean | 'custom';
|
sortable?: boolean | 'custom';
|
||||||
action?: 'tip' | 'actionLink' | 'img' | 'link' | 'tag';
|
action?: 'tip' | 'actionLink' | 'img' | 'link' | 'tag';
|
||||||
handler: (row: any) => void;
|
handler?: (row: any) => void;
|
||||||
};
|
};
|
||||||
|
@ -21,6 +21,8 @@ import { datetimeFormatter } from '@tmagic/utils';
|
|||||||
import { ColumnConfig } from './schema';
|
import { ColumnConfig } from './schema';
|
||||||
|
|
||||||
export const formatter = (item: ColumnConfig, row: any) => {
|
export const formatter = (item: ColumnConfig, row: any) => {
|
||||||
|
if (!item.prop) return '';
|
||||||
|
|
||||||
if (item.formatter) {
|
if (item.formatter) {
|
||||||
if (item.formatter === 'datetime') {
|
if (item.formatter === 'datetime') {
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
|
@ -30,7 +30,10 @@ export default defineConfig({
|
|||||||
alias:
|
alias:
|
||||||
process.env.NODE_ENV === 'production'
|
process.env.NODE_ENV === 'production'
|
||||||
? []
|
? []
|
||||||
: [{ find: /^@tmagic\/form/, replacement: path.join(__dirname, '../form/src/index.ts') }],
|
: [
|
||||||
|
{ find: /^@tmagic\/form/, replacement: path.join(__dirname, '../form/src/index.ts') },
|
||||||
|
{ find: /^@tmagic\/design/, replacement: path.join(__dirname, '../form/design/index.ts') },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
build: {
|
build: {
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@element-plus/icons-vue": "^2.0.9",
|
"@element-plus/icons-vue": "^2.0.9",
|
||||||
|
"@tmagic/design": "1.2.0-beta.2",
|
||||||
"@tmagic/editor": "1.2.0-beta.2",
|
"@tmagic/editor": "1.2.0-beta.2",
|
||||||
"@tmagic/element-plus-adapter": "1.2.0-beta.2",
|
"@tmagic/element-plus-adapter": "1.2.0-beta.2",
|
||||||
"@tmagic/form": "1.2.0-beta.2",
|
"@tmagic/form": "1.2.0-beta.2",
|
||||||
|
@ -26,6 +26,7 @@ import HtmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';
|
|||||||
import JsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
|
import JsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
|
||||||
import TsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
|
import TsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
|
||||||
|
|
||||||
|
import TMagicDesign from '@tmagic/design';
|
||||||
import MagicEditor from '@tmagic/editor';
|
import MagicEditor from '@tmagic/editor';
|
||||||
import MagicElementPlusAdapter from '@tmagic/element-plus-adapter';
|
import MagicElementPlusAdapter from '@tmagic/element-plus-adapter';
|
||||||
import MagicForm from '@tmagic/form';
|
import MagicForm from '@tmagic/form';
|
||||||
@ -63,9 +64,8 @@ app.use(router);
|
|||||||
app.use(ElementPlus, {
|
app.use(ElementPlus, {
|
||||||
locale: zhCn,
|
locale: zhCn,
|
||||||
});
|
});
|
||||||
|
app.use(TMagicDesign, MagicElementPlusAdapter);
|
||||||
app.use(MagicEditor);
|
app.use(MagicEditor);
|
||||||
app.use(MagicForm, {
|
app.use(MagicForm);
|
||||||
uiAdapter: MagicElementPlusAdapter,
|
|
||||||
});
|
|
||||||
app.use(MagicTable);
|
app.use(MagicTable);
|
||||||
app.mount('#app');
|
app.mount('#app');
|
||||||
|
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
@ -77,6 +77,7 @@ importers:
|
|||||||
docs:
|
docs:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@element-plus/icons-vue': ^2.0.9
|
'@element-plus/icons-vue': ^2.0.9
|
||||||
|
'@tmagic/design': 1.2.0-beta.2
|
||||||
'@tmagic/element-plus-adapter': 1.2.0-beta.2
|
'@tmagic/element-plus-adapter': 1.2.0-beta.2
|
||||||
'@tmagic/form': 1.2.0-beta.2
|
'@tmagic/form': 1.2.0-beta.2
|
||||||
'@tmagic/schema': 1.2.0-beta.2
|
'@tmagic/schema': 1.2.0-beta.2
|
||||||
@ -96,6 +97,7 @@ importers:
|
|||||||
vuepress: ^2.0.0-beta.51
|
vuepress: ^2.0.0-beta.51
|
||||||
dependencies:
|
dependencies:
|
||||||
'@element-plus/icons-vue': 2.0.9_vue@3.2.37
|
'@element-plus/icons-vue': 2.0.9_vue@3.2.37
|
||||||
|
'@tmagic/design': link:../packages/design
|
||||||
'@tmagic/element-plus-adapter': link:../packages/element-plus-adapter
|
'@tmagic/element-plus-adapter': link:../packages/element-plus-adapter
|
||||||
'@tmagic/form': link:../packages/form
|
'@tmagic/form': link:../packages/form
|
||||||
'@tmagic/schema': link:../packages/schema
|
'@tmagic/schema': link:../packages/schema
|
||||||
@ -354,6 +356,7 @@ importers:
|
|||||||
|
|
||||||
packages/table:
|
packages/table:
|
||||||
specifiers:
|
specifiers:
|
||||||
|
'@tmagic/design': 1.2.0-beta.2
|
||||||
'@tmagic/form': 1.2.0-beta.2
|
'@tmagic/form': 1.2.0-beta.2
|
||||||
'@tmagic/utils': 1.2.0-beta.2
|
'@tmagic/utils': 1.2.0-beta.2
|
||||||
'@types/color': ^3.0.1
|
'@types/color': ^3.0.1
|
||||||
@ -371,6 +374,7 @@ importers:
|
|||||||
vue: ^3.2.37
|
vue: ^3.2.37
|
||||||
vue-tsc: ^0.39.4
|
vue-tsc: ^0.39.4
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@tmagic/design': link:../design
|
||||||
'@tmagic/form': link:../form
|
'@tmagic/form': link:../form
|
||||||
'@tmagic/utils': link:../utils
|
'@tmagic/utils': link:../utils
|
||||||
element-plus: 2.2.17_vue@3.2.37
|
element-plus: 2.2.17_vue@3.2.37
|
||||||
@ -476,6 +480,7 @@ importers:
|
|||||||
playground:
|
playground:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@element-plus/icons-vue': ^2.0.9
|
'@element-plus/icons-vue': ^2.0.9
|
||||||
|
'@tmagic/design': 1.2.0-beta.2
|
||||||
'@tmagic/editor': 1.2.0-beta.2
|
'@tmagic/editor': 1.2.0-beta.2
|
||||||
'@tmagic/element-plus-adapter': 1.2.0-beta.2
|
'@tmagic/element-plus-adapter': 1.2.0-beta.2
|
||||||
'@tmagic/form': 1.2.0-beta.2
|
'@tmagic/form': 1.2.0-beta.2
|
||||||
@ -500,6 +505,7 @@ importers:
|
|||||||
vue-tsc: ^0.39.4
|
vue-tsc: ^0.39.4
|
||||||
dependencies:
|
dependencies:
|
||||||
'@element-plus/icons-vue': 2.0.9_vue@3.2.37
|
'@element-plus/icons-vue': 2.0.9_vue@3.2.37
|
||||||
|
'@tmagic/design': link:../packages/design
|
||||||
'@tmagic/editor': link:../packages/editor
|
'@tmagic/editor': link:../packages/editor
|
||||||
'@tmagic/element-plus-adapter': link:../packages/element-plus-adapter
|
'@tmagic/element-plus-adapter': link:../packages/element-plus-adapter
|
||||||
'@tmagic/form': link:../packages/form
|
'@tmagic/form': link:../packages/form
|
||||||
|
Loading…
x
Reference in New Issue
Block a user