diff --git a/package.json b/package.json
index e128807fb..e0829354d 100644
--- a/package.json
+++ b/package.json
@@ -34,7 +34,7 @@
},
"dependencies": {
"@ant-design/icons-vue": "~6.1.0",
- "@vueuse/core": "~9.1.0",
+ "@vueuse/core": "~9.1.1",
"ant-design-vue": "3.2.11",
"axios": "~0.27.2",
"core-js": "~3.24.1",
@@ -58,10 +58,10 @@
"@commitlint/cli": "~17.0.3",
"@commitlint/config-conventional": "~17.0.3",
"@types/lodash-es": "~4.17.6",
- "@types/node": "~18.7.6",
+ "@types/node": "~18.7.13",
"@types/webpack-env": "~1.18.0",
- "@typescript-eslint/eslint-plugin": "~5.33.1",
- "@typescript-eslint/parser": "~5.33.1",
+ "@typescript-eslint/eslint-plugin": "~5.34.0",
+ "@typescript-eslint/parser": "~5.34.0",
"@vue/cli-plugin-babel": "~5.0.8",
"@vue/cli-plugin-eslint": "~5.0.8",
"@vue/cli-plugin-router": "~5.0.8",
@@ -72,13 +72,13 @@
"babel-plugin-import": "~1.13.5",
"conventional-changelog-cli": "~2.2.2",
"cross-env": "~7.0.3",
- "cz-git": "~1.3.10",
- "czg": "~1.3.10",
+ "cz-git": "~1.3.11",
+ "czg": "~1.3.11",
"eslint": "~8.22.0",
"eslint-config-prettier": "~8.5.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-prettier": "~4.2.1",
- "eslint-plugin-vue": "~9.3.0",
+ "eslint-plugin-vue": "~9.4.0",
"husky": "~8.0.1",
"less": "~4.1.3",
"less-loader": "11.0.0",
@@ -95,7 +95,7 @@
"stylelint-config-prettier": "~9.0.3",
"stylelint-config-recommended": "~9.0.0",
"stylelint-config-recommended-vue": "~1.4.0",
- "stylelint-config-standard": "~27.0.0",
+ "stylelint-config-standard": "~28.0.0",
"stylelint-order": "~5.0.0",
"svg-sprite-loader": "~6.0.11",
"typescript": "~4.7.4",
diff --git a/src/components/core/dynamic-table/src/components/table-action.vue b/src/components/core/dynamic-table/src/components/table-action.vue
index 6a26b15eb..12926d44d 100644
--- a/src/components/core/dynamic-table/src/components/table-action.vue
+++ b/src/components/core/dynamic-table/src/components/table-action.vue
@@ -1,55 +1,98 @@
-
+
- {{ actionItem.label }}
+
+ {{ actionItem.label }}
+
-
diff --git a/src/components/core/dynamic-table/src/hooks/useColumns.tsx b/src/components/core/dynamic-table/src/hooks/useColumns.tsx
index 6b3e320fa..6fbf53700 100644
--- a/src/components/core/dynamic-table/src/hooks/useColumns.tsx
+++ b/src/components/core/dynamic-table/src/hooks/useColumns.tsx
@@ -56,11 +56,11 @@ export const useColumns = ({ state, methods, props, tableAction }: UseTableColum
return columns.map((item) => {
const customRender = item.customRender;
+ const rowKey = props.rowKey as string;
const columnKey = getColumnKey(item) as string;
item.customRender = (options) => {
- const { record } = options;
- const rowKey = props.rowKey as string;
+ const { record, index } = options;
/** 当前行是否开启了编辑行模式 */
const isEditableRow = isEditable(record[rowKey]);
/** 当前单元格是否允许被编辑 */
@@ -74,7 +74,7 @@ export const useColumns = ({ state, methods, props, tableAction }: UseTableColum
// @ts-ignore
) : (
@@ -84,9 +84,15 @@ export const useColumns = ({ state, methods, props, tableAction }: UseTableColum
// 操作列
if (item.actions && columnKey === ColumnKeyFlag.ACTION) {
- item.customRender = (columnParams) => {
- // @ts-ignore
- return ;
+ item.customRender = (options) => {
+ const { record, index } = options;
+ return (
+
+ );
};
}
return {
diff --git a/src/components/core/dynamic-table/src/types/tableAction.ts b/src/components/core/dynamic-table/src/types/tableAction.ts
index 8e0df9a22..cb8e1c1c7 100644
--- a/src/components/core/dynamic-table/src/types/tableAction.ts
+++ b/src/components/core/dynamic-table/src/types/tableAction.ts
@@ -1,13 +1,15 @@
+import type { Ref } from 'vue';
import type { CustomRenderParams } from './column';
import type { PopconfirmProps } from 'ant-design-vue/es/popconfirm';
import type { ButtonProps, TooltipProps } from 'ant-design-vue/es/components';
import type { PermissionType } from '@/core/permission/modules/types';
import type { TableMethods, UseEditableType } from '../hooks/';
-export interface ActionItem extends Omit {
+export type ActionItem = Omit & {
onClick?: Fn;
label?: string;
color?: 'success' | 'error' | 'warning';
+ loading?: Ref | ButtonProps['loading'];
icon?: string;
popConfirm?: PopConfirm;
disabled?: boolean;
@@ -24,7 +26,7 @@ export interface ActionItem extends Omit {
perm: PermissionType;
effect?: 'delete' | 'disable';
};
-}
+};
export type PopConfirm = PopconfirmProps & {
title: string;
diff --git a/src/utils/is/index.ts b/src/utils/is/index.ts
index 4638a4d0e..208951ac5 100644
--- a/src/utils/is/index.ts
+++ b/src/utils/is/index.ts
@@ -1,5 +1,7 @@
const toString = Object.prototype.toString;
+const AsyncFunction = async function () {}.constructor;
+
export function is(val: unknown, type: string) {
return toString.call(val) === `[object ${type}]`;
}
@@ -68,6 +70,10 @@ export function isFunction(val: unknown): val is Function {
return typeof val === 'function';
}
+export function isAsyncFunction(val: unknown): val is Function {
+ return val instanceof AsyncFunction || (isFunction(val) && isPromise(val));
+}
+
export function isBoolean(val: unknown): val is boolean {
return is(val, 'Boolean');
}
diff --git a/src/views/demos/tables/edit-row-table/columns.tsx b/src/views/demos/tables/edit-row-table/columns.tsx
index 8d239503d..639e9b417 100644
--- a/src/views/demos/tables/edit-row-table/columns.tsx
+++ b/src/views/demos/tables/edit-row-table/columns.tsx
@@ -7,6 +7,7 @@ import {
getClothesByGender,
tableData,
} from '@/views/demos/tables/search-table/columns';
+import { waitTime } from '@/utils/common';
export { tableData };
@@ -87,6 +88,9 @@ export const columns: TableColumn[] = [
dataIndex: 'clothes',
formItemProps: {
component: 'Select',
+ componentProps: ({ formModel }) => ({
+ options: getClothesByGender(formModel.gender),
+ }),
},
},
{
@@ -146,7 +150,6 @@ export const columns: TableColumn[] = [
dataIndex: 'ACTION',
actions: ({ record }, action) => {
const { startEditable, cancelEditable, isEditable, getEditFormModel, validateRow } = action;
-
return isEditable(record.id)
? [
{
@@ -156,10 +159,9 @@ export const columns: TableColumn[] = [
message.loading({ content: '保存中...', key: record.id });
console.log('result', result);
console.log('保存', getEditFormModel(record.id));
- setTimeout(() => {
- cancelEditable(record.id);
- message.success({ content: '保存成功!', key: record.id, duration: 2 });
- }, 1500);
+ await waitTime(2000);
+ cancelEditable(record.id);
+ message.success({ content: '保存成功!', key: record.id, duration: 2 });
},
},
{
diff --git a/src/views/demos/tables/edit-row-table/index.vue b/src/views/demos/tables/edit-row-table/index.vue
index a02ff4918..6493b3311 100644
--- a/src/views/demos/tables/edit-row-table/index.vue
+++ b/src/views/demos/tables/edit-row-table/index.vue
@@ -4,14 +4,28 @@
可编辑行表格-可编辑行表格使用示例
-
+
+
+
+