From b5215b33bfe7a76f996c1bf4acaf2673483f3726 Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Wed, 23 Nov 2022 18:29:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=20`@pureadmin/table`?= =?UTF-8?q?=20=E7=BC=96=E8=BE=91=E5=8D=95=E5=85=83=E6=A0=BC=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/pure-table/high/data.ts | 11 +++ src/views/pure-table/high/edit/columns.tsx | 94 ++++++++++++++++++++++ src/views/pure-table/high/edit/index.vue | 9 +++ src/views/pure-table/high/list.tsx | 7 ++ 4 files changed, 121 insertions(+) create mode 100644 src/views/pure-table/high/edit/columns.tsx create mode 100644 src/views/pure-table/high/edit/index.vue diff --git a/src/views/pure-table/high/data.ts b/src/views/pure-table/high/data.ts index 0ad9b38e6..a76fdda78 100644 --- a/src/views/pure-table/high/data.ts +++ b/src/views/pure-table/high/data.ts @@ -79,10 +79,21 @@ const tableDataDrag = clone(tableData, true).map((item, index) => { ); }); +const tableDataEdit = clone(tableData, true).map((item, index) => { + return Object.assign( + { + id: index + 1, + date: `${dayjs(new Date()).format("YYYY-MM")}-${index + 1}` + }, + item + ); +}); + export { tableData, tableDataDrag, tableDataMore, + tableDataEdit, tableDataImage, tableDataSortable }; diff --git a/src/views/pure-table/high/edit/columns.tsx b/src/views/pure-table/high/edit/columns.tsx new file mode 100644 index 000000000..3dc5426e1 --- /dev/null +++ b/src/views/pure-table/high/edit/columns.tsx @@ -0,0 +1,94 @@ +import { ref, computed } from "vue"; +import { tableDataEdit } from "../data"; +import { message } from "@pureadmin/components"; +import { clone, delay } from "@pureadmin/utils"; + +// 温馨提示:编辑整行方法雷同,将cellRenderer后面渲染的组件抽出来做对应处理即可 +export function useColumns() { + const inputValMap = ref({}); + const activeIndex = ref(-1); + const dataList = ref(clone(tableDataEdit, true)); + + const comVal = computed(() => { + return index => { + return inputValMap.value[index]?.value; + }; + }); + + const columns: TableColumnList = [ + { + label: "ID", + prop: "id", + // class="flex-bc" flex-bc 代表 flex justify-between items-center 具体看 src/style/tailwind.css 文件 + cellRenderer: ({ row, index }) => ( +
{row.id}
+