mirror of
https://github.com/jekip/naive-ui-admin.git
synced 2026-02-11 16:52:28 +08:00
Fixes bug add baseModal | baseForm 组件
This commit is contained in:
@@ -73,7 +73,6 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { NDataTable } from 'naive-ui';
|
||||
import {
|
||||
ref,
|
||||
defineComponent,
|
||||
@@ -129,7 +128,6 @@
|
||||
QuestionCircleOutlined,
|
||||
},
|
||||
props: {
|
||||
...NDataTable.props, // 这里继承原 UI 组件的 props
|
||||
...basicProps,
|
||||
},
|
||||
emits: [
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
import { set, omit } from 'lodash-es';
|
||||
import { EventEnum } from '@/components/Table/src/componentMap';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import { milliseconds } from 'date-fns';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'EditableCell',
|
||||
@@ -108,10 +108,11 @@
|
||||
|
||||
let value = isCheckValue ? (isNumber(val) && isBoolean(val) ? val : !!val) : val;
|
||||
|
||||
if (component === 'NDatePicker') {
|
||||
value = dayjs(value).valueOf();
|
||||
if (isString(value) && component === 'NDatePicker') {
|
||||
value = milliseconds(value as Duration);
|
||||
} else if (isArray(value) && component === 'NDatePicker') {
|
||||
value = value.map((item) => milliseconds(item));
|
||||
}
|
||||
|
||||
const onEvent: any = editComponent ? EventEnum[editComponent] : undefined;
|
||||
|
||||
return {
|
||||
@@ -196,12 +197,12 @@
|
||||
}
|
||||
|
||||
//TODO 这里组件参数格式,和dayjs格式不一致
|
||||
if (component === 'NDatePicker') {
|
||||
let format = (props.column.editComponentProps?.format)
|
||||
.replace(/yyyy/g, 'YYYY')
|
||||
.replace(/dd/g, 'DD');
|
||||
currentValueRef.value = dayjs(currentValueRef.value).format(format);
|
||||
}
|
||||
// if (component === 'NDatePicker') {
|
||||
// let format = (props.column.editComponentProps?.format)
|
||||
// .replace(/yyyy/g, 'YYYY')
|
||||
// .replace(/dd/g, 'DD');
|
||||
// currentValueRef.value = dayjs(currentValueRef.value).format(format);
|
||||
// }
|
||||
|
||||
const onChange = props.column?.editComponentProps?.onChange;
|
||||
if (onChange && isFunction(onChange)) onChange(...arguments);
|
||||
|
||||
@@ -81,12 +81,14 @@
|
||||
<script lang="ts">
|
||||
import { ref, defineComponent, reactive, unref, toRaw, computed, toRefs, watchEffect } from 'vue';
|
||||
import { useTableContext } from '../../hooks/useTableContext';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import {
|
||||
SettingOutlined,
|
||||
DragOutlined,
|
||||
VerticalRightOutlined,
|
||||
VerticalLeftOutlined,
|
||||
} from '@vicons/antd';
|
||||
// @ts-ignore
|
||||
import Draggable from 'vuedraggable/src/vuedraggable';
|
||||
import { useDesignSetting } from '@/hooks/setting/useDesignSetting';
|
||||
|
||||
@@ -107,7 +109,7 @@
|
||||
},
|
||||
setup() {
|
||||
const { getDarkTheme } = useDesignSetting();
|
||||
const table = useTableContext();
|
||||
const table: any = useTableContext();
|
||||
const columnsList = ref<Options[]>([]);
|
||||
const cacheColumnsList = ref<Options[]>([]);
|
||||
|
||||
@@ -135,8 +137,11 @@
|
||||
const checkList: any = columns.map((item) => item.key);
|
||||
state.checkList = checkList;
|
||||
state.defaultCheckList = checkList;
|
||||
columnsList.value = columns;
|
||||
cacheColumnsList.value = columns;
|
||||
const newColumns = columns.filter((item) => item.key != 'action' && item.title != '操作');
|
||||
if (!columnsList.value.length) {
|
||||
columnsList.value = cloneDeep(newColumns);
|
||||
cacheColumnsList.value = cloneDeep(newColumns);
|
||||
}
|
||||
}
|
||||
|
||||
//切换
|
||||
@@ -154,11 +159,11 @@
|
||||
|
||||
//获取
|
||||
function getColumns() {
|
||||
let newRet = [];
|
||||
let newRet: any[] = [];
|
||||
table.getColumns().forEach((item) => {
|
||||
newRet.push({ ...item });
|
||||
});
|
||||
return newRet.filter((item) => item.key != 'action' && item.title != '操作');
|
||||
return newRet;
|
||||
}
|
||||
|
||||
//重置
|
||||
|
||||
@@ -52,7 +52,7 @@ export function useColumns(propsRef: ComputedRef<BasicTableProps>) {
|
||||
return hasPermission(column.auth) && isIfShow(column);
|
||||
})
|
||||
.map((column) => {
|
||||
const { edit, editRow } = column;
|
||||
const { edit } = column;
|
||||
if (edit) {
|
||||
column.render = renderEditCell(column);
|
||||
if (edit) {
|
||||
@@ -140,12 +140,12 @@ export function useColumns(propsRef: ComputedRef<BasicTableProps>) {
|
||||
}
|
||||
|
||||
//更新原始数据单个字段
|
||||
function setCacheColumnsField(dataIndex: string | undefined, value: Partial<BasicColumn>) {
|
||||
if (!dataIndex || !value) {
|
||||
function setCacheColumnsField(key: string | undefined, value: Partial<BasicColumn>) {
|
||||
if (!key || !value) {
|
||||
return;
|
||||
}
|
||||
cacheColumns.forEach((item) => {
|
||||
if (item.key === dataIndex) {
|
||||
if (item.key === key) {
|
||||
Object.assign(item, value);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ export function useDataSource(
|
||||
try {
|
||||
setLoading(true);
|
||||
const { request, pagination }: any = unref(propsRef);
|
||||
|
||||
//组装分页信息
|
||||
const pageField = APISETTING.pageField;
|
||||
const sizeField = APISETTING.sizeField;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import type { PropType } from 'vue';
|
||||
import { propTypes } from '@/utils/propTypes';
|
||||
import { BasicColumn } from './types/table';
|
||||
|
||||
import { NDataTable } from 'naive-ui';
|
||||
export const basicProps = {
|
||||
...NDataTable.props, // 这里继承原 UI 组件的 props
|
||||
title: {
|
||||
type: String,
|
||||
default: null,
|
||||
|
||||
@@ -11,7 +11,7 @@ export interface BasicColumn extends TableBaseColumn {
|
||||
editValueMap?: (value: any) => string;
|
||||
onEditRow?: () => void;
|
||||
// 权限编码控制是否显示
|
||||
auth?: RoleEnum | RoleEnum[] | string | string[];
|
||||
auth?: string[];
|
||||
// 业务控制是否显示
|
||||
ifShow?: boolean | ((column: BasicColumn) => boolean);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user