diff --git a/mock/asyncRoutes.ts b/mock/asyncRoutes.ts index 937e275ac..1a483b575 100644 --- a/mock/asyncRoutes.ts +++ b/mock/asyncRoutes.ts @@ -89,7 +89,7 @@ const frameRouter = { meta: { icon: "monitor", title: "menus.hsExternalPage", - rank: 7 + rank: 8 }, children: [ { diff --git a/package.json b/package.json index f040084d4..0edb1ef65 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,8 @@ "@logicflow/extension": "^1.1.30", "@pureadmin/components": "^1.1.0", "@pureadmin/descriptions": "^1.1.0", - "@pureadmin/table": "^1.2.0", - "@pureadmin/utils": "^1.6.5", + "@pureadmin/table": "^1.6.0", + "@pureadmin/utils": "^1.6.6", "@vueuse/core": "^9.5.0", "@vueuse/motion": "2.0.0-beta.12", "@wangeditor/editor": "^5.1.21", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e66db53a9..70940009b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,9 +20,9 @@ specifiers: "@logicflow/extension": ^1.1.30 "@pureadmin/components": ^1.1.0 "@pureadmin/descriptions": ^1.1.0 - "@pureadmin/table": ^1.2.0 + "@pureadmin/table": ^1.6.0 "@pureadmin/theme": ^2.4.0 - "@pureadmin/utils": ^1.6.5 + "@pureadmin/utils": ^1.6.6 "@types/element-resize-detector": 1.1.3 "@types/intro.js": ^5.1.0 "@types/js-cookie": ^3.0.1 @@ -132,7 +132,7 @@ dependencies: "@logicflow/extension": 1.1.31 "@pureadmin/components": 1.1.0_vue@3.2.45 "@pureadmin/descriptions": 1.1.1_element-plus@2.2.22 - "@pureadmin/table": 1.2.0_element-plus@2.2.22 + "@pureadmin/table": 1.6.0_element-plus@2.2.22 "@pureadmin/utils": 1.6.6_aotapuqn7htzdjltsyimavekky "@vueuse/core": 9.5.0_vue@3.2.45 "@vueuse/motion": 2.0.0-beta.12_vue@3.2.45 @@ -1379,10 +1379,10 @@ packages: vue: 3.2.45 dev: false - /@pureadmin/table/1.2.0_element-plus@2.2.22: + /@pureadmin/table/1.6.0_element-plus@2.2.22: resolution: { - integrity: sha512-mJBpMj0YkaqTM5TDz+ek/f8h74qRLhDc/gLJhBq0wpyfCgG++Jd/9i+QUj8gedA5oN8IL6LOSFbcvlGDYxHgkw== + integrity: sha512-ryTZbfkNT/PTUS6pdrq7vuHr3f74lXs6kgRHaAPz64iTZmzaeVzf27TPakf4YDEcnQ/Gw6RqlQzE71W9m+P48w== } peerDependencies: element-plus: ^2.0.0 diff --git a/src/layout/components/panel/index.vue b/src/layout/components/panel/index.vue index ac9f27db2..3618bdf47 100644 --- a/src/layout/components/panel/index.vue +++ b/src/layout/components/panel/index.vue @@ -21,7 +21,7 @@ emitter.on("openPanel", () => {
-

项目配置

+

项目配置

import("@/views/pure-table/index.vue"), + meta: { + title: "pure-admin-table", + extraIcon: { + svg: true, + name: "team-iconxinpin" + } + } + } + ] +}; + +export default flowChartRouter; diff --git a/src/style/reset.scss b/src/style/reset.scss index 2382a7672..97e519773 100644 --- a/src/style/reset.scss +++ b/src/style/reset.scss @@ -44,16 +44,6 @@ abbr:where([title]) { text-decoration: underline dotted; } -h1, -h2, -h3, -h4, -h5, -h6 { - font-size: inherit; - font-weight: inherit; -} - a { color: inherit; text-decoration: inherit; diff --git a/src/views/able/swiper.vue b/src/views/able/swiper.vue index e8860e087..376a9bca6 100644 --- a/src/views/able/swiper.vue +++ b/src/views/able/swiper.vue @@ -100,7 +100,7 @@ const swiperExample: any[] = [ -

{{ item.label }}

+
{{ item.label }}
{ @selectedVal="selectedVal" :disabled="item.disabled" /> -

选中范围:{{ selectRange }}

+

选中范围:{{ selectRange }}

diff --git a/src/views/pure-table/components/base.vue b/src/views/pure-table/components/base.vue new file mode 100644 index 000000000..35da65cc0 --- /dev/null +++ b/src/views/pure-table/components/base.vue @@ -0,0 +1,22 @@ + + + diff --git a/src/views/pure-table/components/border.vue b/src/views/pure-table/components/border.vue new file mode 100644 index 000000000..86078a651 --- /dev/null +++ b/src/views/pure-table/components/border.vue @@ -0,0 +1,22 @@ + + + diff --git a/src/views/pure-table/components/column-template/columns.tsx b/src/views/pure-table/components/column-template/columns.tsx new file mode 100644 index 000000000..9a51ae6d6 --- /dev/null +++ b/src/views/pure-table/components/column-template/columns.tsx @@ -0,0 +1,70 @@ +import { message } from "@pureadmin/components"; +import { tableData } from "../data"; + +// 如果您不习惯tsx写法,可以传slot,然后在template里写 +// 需是hooks写法(函数中有return),避免失去响应性 +export function useColumns() { + const columns: TableColumnList = [ + { + label: "日期", + prop: "date", + cellRenderer: ({ row }) => ( +
+ + {row.date} +
+ ) + }, + { + label: "姓名", + prop: "name", + cellRenderer: ({ row }) => ( + + {{ + default: () => ( + <> +
name: {row.name}
+
address: {row.address}
+ + ), + reference: () => {row.name} + }} +
+ ) + }, + { + label: "地址", + prop: "address" + }, + { + label: "操作", + cellRenderer: ({ index, row }) => ( + <> + handleEdit(index + 1, row)}> + Edit + + handleDelete(index + 1, row)} + > + Delete + + + ) + } + ]; + + const handleEdit = (index: number, row) => { + message.success(`您编辑了第 ${index} 行,数据为:${JSON.stringify(row)}`); + }; + + const handleDelete = (index: number, row) => { + message.error(`您删除了第 ${index} 行,数据为:${JSON.stringify(row)}`); + }; + + return { + columns, + tableData + }; +} diff --git a/src/views/pure-table/components/column-template/index.vue b/src/views/pure-table/components/column-template/index.vue new file mode 100644 index 000000000..0962509f3 --- /dev/null +++ b/src/views/pure-table/components/column-template/index.vue @@ -0,0 +1,9 @@ + + + diff --git a/src/views/pure-table/components/customIndex.vue b/src/views/pure-table/components/customIndex.vue new file mode 100644 index 000000000..f89600978 --- /dev/null +++ b/src/views/pure-table/components/customIndex.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/views/pure-table/components/data.ts b/src/views/pure-table/components/data.ts new file mode 100644 index 000000000..908c6e0fd --- /dev/null +++ b/src/views/pure-table/components/data.ts @@ -0,0 +1,285 @@ +import dayjs from "dayjs"; +import { clone } from "@pureadmin/utils"; + +const date = dayjs(new Date()).format("YYYY-MM-DD"); + +const tableData = [ + { + date, + name: "Tom", + address: "No. 189, Grove St, Los Angeles" + }, + { + date, + name: "Jack", + address: "No. 189, Grove St, Los Angeles" + }, + { + date, + name: "Dick", + address: "No. 189, Grove St, Los Angeles" + }, + { + date, + name: "Harry", + address: "No. 189, Grove St, Los Angeles" + }, + { + date, + name: "Sam", + address: "No. 189, Grove St, Los Angeles" + }, + { + date, + name: "Lucy", + address: "No. 189, Grove St, Los Angeles" + }, + { + date, + name: "Mary", + address: "No. 189, Grove St, Los Angeles" + }, + { + date, + name: "Mike", + address: "No. 189, Grove St, Los Angeles" + } +]; + +const cloneData = clone(tableData, true); + +const tableDataMore = cloneData.map(item => + Object.assign(item, { + state: "California", + city: "Los Angeles", + "post-code": "CA 90036" + }) +); + +const tableDataSortable = cloneData.map((item, index) => + Object.assign(item, { + date: `${dayjs(new Date()).format("YYYY-MM")}-${index + 1}` + }) +); + +const tableDataExpand = [ + { + date: "2016-05-03", + name: "Tom", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114", + family: [ + { + name: "Jerry", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + }, + { + name: "Spike", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + }, + { + name: "Tyke", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + } + ] + }, + { + date: "2016-05-02", + name: "Tom", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114", + family: [ + { + name: "Jerry", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + }, + { + name: "Spike", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + }, + { + name: "Tyke", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + } + ] + }, + { + date: "2016-05-04", + name: "Tom", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114", + family: [ + { + name: "Jerry", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + }, + { + name: "Spike", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + }, + { + name: "Tyke", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + } + ] + }, + { + date: "2016-05-01", + name: "Tom", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114", + family: [ + { + name: "Jerry", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + }, + { + name: "Spike", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + }, + { + name: "Tyke", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + } + ] + }, + { + date: "2016-05-08", + name: "Tom", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114", + family: [ + { + name: "Jerry", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + }, + { + name: "Spike", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + }, + { + name: "Tyke", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + } + ] + }, + { + date: "2016-05-06", + name: "Tom", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114", + family: [ + { + name: "Jerry", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + }, + { + name: "Spike", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + }, + { + name: "Tyke", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + } + ] + }, + { + date: "2016-05-07", + name: "Tom", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114", + family: [ + { + name: "Jerry", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + }, + { + name: "Spike", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + }, + { + name: "Tyke", + state: "California", + city: "San Francisco", + address: "3650 21st St, San Francisco", + zip: "CA 94114" + } + ] + } +]; + +export { tableData, tableDataMore, tableDataSortable, tableDataExpand }; diff --git a/src/views/pure-table/components/expand.vue b/src/views/pure-table/components/expand.vue new file mode 100644 index 000000000..9b8d4d102 --- /dev/null +++ b/src/views/pure-table/components/expand.vue @@ -0,0 +1,72 @@ + + + diff --git a/src/views/pure-table/components/filters.vue b/src/views/pure-table/components/filters.vue new file mode 100644 index 000000000..6c1765857 --- /dev/null +++ b/src/views/pure-table/components/filters.vue @@ -0,0 +1,104 @@ + + + diff --git a/src/views/pure-table/components/fixColumn.vue b/src/views/pure-table/components/fixColumn.vue new file mode 100644 index 000000000..5691cbdf9 --- /dev/null +++ b/src/views/pure-table/components/fixColumn.vue @@ -0,0 +1,79 @@ + + + diff --git a/src/views/pure-table/components/fixHeader.vue b/src/views/pure-table/components/fixHeader.vue new file mode 100644 index 000000000..9195f9c28 --- /dev/null +++ b/src/views/pure-table/components/fixHeader.vue @@ -0,0 +1,26 @@ + + + diff --git a/src/views/pure-table/components/fluidHeight.vue b/src/views/pure-table/components/fluidHeight.vue new file mode 100644 index 000000000..3d46a514a --- /dev/null +++ b/src/views/pure-table/components/fluidHeight.vue @@ -0,0 +1,84 @@ + + + diff --git a/src/views/pure-table/components/groupHeader.vue b/src/views/pure-table/components/groupHeader.vue new file mode 100644 index 000000000..867d53761 --- /dev/null +++ b/src/views/pure-table/components/groupHeader.vue @@ -0,0 +1,38 @@ + + + diff --git a/src/views/pure-table/components/header-renderer/columns.tsx b/src/views/pure-table/components/header-renderer/columns.tsx new file mode 100644 index 000000000..f80925fcc --- /dev/null +++ b/src/views/pure-table/components/header-renderer/columns.tsx @@ -0,0 +1,70 @@ +import { message } from "@pureadmin/components"; +import { tableData } from "../data"; +import { ref, computed } from "vue"; + +// 如果您不习惯tsx写法,可以传slot,然后在template里写 +// 需是hooks写法(函数中有return),避免失去响应性 +export function useColumns() { + const search = ref(""); + const filterTableData = computed(() => + tableData.filter( + data => + !search.value || + data.name.toLowerCase().includes(search.value.toLowerCase()) + ) + ); + + const handleEdit = (index: number, row) => { + message.success(`您编辑了第 ${index} 行,数据为:${JSON.stringify(row)}`); + }; + + const handleDelete = (index: number, row) => { + message.error(`您删除了第 ${index} 行,数据为:${JSON.stringify(row)}`); + }; + + const columns: TableColumnList = [ + { + label: "日期", + prop: "date" + }, + { + label: "姓名", + prop: "name" + }, + { + label: "地址", + prop: "address" + }, + { + align: "right", + // 自定义表头 + headerRenderer: () => ( + + ), + cellRenderer: ({ index, row }) => ( + <> + handleEdit(index + 1, row)}> + Edit + + handleDelete(index + 1, row)} + > + Delete + + + ) + } + ]; + + return { + columns, + filterTableData + }; +} diff --git a/src/views/pure-table/components/header-renderer/index.vue b/src/views/pure-table/components/header-renderer/index.vue new file mode 100644 index 000000000..6dcfc499e --- /dev/null +++ b/src/views/pure-table/components/header-renderer/index.vue @@ -0,0 +1,9 @@ + + + diff --git a/src/views/pure-table/components/index.ts b/src/views/pure-table/components/index.ts new file mode 100644 index 000000000..94d678de0 --- /dev/null +++ b/src/views/pure-table/components/index.ts @@ -0,0 +1,43 @@ +import Base from "./base.vue"; +import Stripe from "./stripe.vue"; +import Border from "./border.vue"; +import Status from "./status.vue"; +import FixHeader from "./fixHeader.vue"; +import FixColumn from "./fixColumn.vue"; +import FluidHeight from "./fluidHeight.vue"; +import GroupHeader from "./groupHeader.vue"; +import Radio from "./radio.vue"; +import MultipleChoice from "./multipleChoice.vue"; +import Sortable from "./sortable.vue"; +import Filters from "./filters.vue"; +import ColumnTemplate from "./column-template/index.vue"; +import HeaderRenderer from "./header-renderer/index.vue"; +import Expand from "./expand.vue"; +import TreeTable from "./tree.vue"; +import TotalRow from "./totalRow.vue"; +import Merge from "./merge.vue"; +import CustomIndex from "./customIndex.vue"; +import Layout from "./layout.vue"; + +export { + Base, + Stripe, + Border, + Status, + FixHeader, + FixColumn, + FluidHeight, + GroupHeader, + Radio, + MultipleChoice, + Sortable, + Filters, + ColumnTemplate, + HeaderRenderer, + Expand, + TreeTable, + TotalRow, + Merge, + CustomIndex, + Layout +}; diff --git a/src/views/pure-table/components/layout.vue b/src/views/pure-table/components/layout.vue new file mode 100644 index 000000000..7709a4244 --- /dev/null +++ b/src/views/pure-table/components/layout.vue @@ -0,0 +1,38 @@ + + + diff --git a/src/views/pure-table/components/merge.vue b/src/views/pure-table/components/merge.vue new file mode 100644 index 000000000..d09407c33 --- /dev/null +++ b/src/views/pure-table/components/merge.vue @@ -0,0 +1,124 @@ + + + diff --git a/src/views/pure-table/components/multipleChoice.vue b/src/views/pure-table/components/multipleChoice.vue new file mode 100644 index 000000000..6f4fd5729 --- /dev/null +++ b/src/views/pure-table/components/multipleChoice.vue @@ -0,0 +1,57 @@ + + + diff --git a/src/views/pure-table/components/radio.vue b/src/views/pure-table/components/radio.vue new file mode 100644 index 000000000..b2db5c04f --- /dev/null +++ b/src/views/pure-table/components/radio.vue @@ -0,0 +1,47 @@ + + + diff --git a/src/views/pure-table/components/sortable.vue b/src/views/pure-table/components/sortable.vue new file mode 100644 index 000000000..494630f7f --- /dev/null +++ b/src/views/pure-table/components/sortable.vue @@ -0,0 +1,28 @@ + + + diff --git a/src/views/pure-table/components/status.vue b/src/views/pure-table/components/status.vue new file mode 100644 index 000000000..fcfba45ff --- /dev/null +++ b/src/views/pure-table/components/status.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/src/views/pure-table/components/stripe.vue b/src/views/pure-table/components/stripe.vue new file mode 100644 index 000000000..324be621f --- /dev/null +++ b/src/views/pure-table/components/stripe.vue @@ -0,0 +1,22 @@ + + + diff --git a/src/views/pure-table/components/totalRow.vue b/src/views/pure-table/components/totalRow.vue new file mode 100644 index 000000000..17b529a5f --- /dev/null +++ b/src/views/pure-table/components/totalRow.vue @@ -0,0 +1,144 @@ + + + diff --git a/src/views/pure-table/components/tree.vue b/src/views/pure-table/components/tree.vue new file mode 100644 index 000000000..6e3b5e860 --- /dev/null +++ b/src/views/pure-table/components/tree.vue @@ -0,0 +1,122 @@ + + + diff --git a/src/views/pure-table/index.vue b/src/views/pure-table/index.vue new file mode 100644 index 000000000..6b26bba01 --- /dev/null +++ b/src/views/pure-table/index.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/src/views/pure-table/list.tsx b/src/views/pure-table/list.tsx new file mode 100644 index 000000000..74b3053f1 --- /dev/null +++ b/src/views/pure-table/list.tsx @@ -0,0 +1,154 @@ +import { + Base, + Stripe, + Border, + Status, + FixHeader, + FixColumn, + FluidHeight, + GroupHeader, + Radio, + MultipleChoice, + Sortable, + Filters, + ColumnTemplate, + HeaderRenderer, + Expand, + TreeTable, + TotalRow, + Merge, + CustomIndex, + Layout +} from "./components"; + +const rendContent = (val: string) => + `代码位置:src/views/pure-table/components/${val}.vue`; + +export const list = [ + { + key: "base", + content: rendContent("base"), + title: "基础表格", + component: Base + }, + { + key: "stripe", + content: rendContent("stripe"), + title: "带斑马纹表格", + component: Stripe + }, + { + key: "border", + content: rendContent("border"), + title: "带边框表格", + component: Border + }, + { + key: "status", + content: rendContent("status"), + title: "带状态表格", + component: Status + }, + { + key: "fixHeader", + content: rendContent("fixHeader"), + title: "固定表头", + component: FixHeader + }, + { + key: "fixColumn", + content: rendContent("fixColumn"), + title: "固定列", + component: FixColumn + }, + { + key: "fixColumnHeader", + content: rendContent("fixColumn"), + title: "固定列和表头", + component: () => + }, + { + key: "groupHeader", + content: rendContent("groupHeader"), + title: "多级表头(表头分组)", + component: GroupHeader + }, + { + key: "fluidHeight", + content: rendContent("fluidHeight"), + title: "流体高度", + component: FluidHeight + }, + { + key: "radio", + content: rendContent("radio"), + title: "单选", + component: Radio + }, + { + key: "multipleChoice", + content: rendContent("multipleChoice"), + title: "多选", + component: MultipleChoice + }, + { + key: "sortable", + content: rendContent("sortable"), + title: "排序和格式化", + component: Sortable + }, + { + key: "filters", + content: rendContent("filters"), + title: "筛选", + component: Filters + }, + { + key: "column-template", + content: rendContent("column-template/index"), + title: "自定义列模板", + component: ColumnTemplate + }, + { + key: "header-renderer", + content: rendContent("header-renderer/index"), + title: "自定义表头", + component: HeaderRenderer + }, + { + key: "expand", + content: rendContent("expand"), + title: "展开行", + component: Expand + }, + { + key: "tree", + content: rendContent("tree"), + title: "树形数据与懒加载", + component: TreeTable + }, + { + key: "totalRow", + content: rendContent("totalRow"), + title: "表尾合计行", + component: TotalRow + }, + { + key: "merge", + content: rendContent("merge"), + title: "合并行或列", + component: Merge + }, + { + key: "customIndex", + content: rendContent("customIndex"), + title: "自定义索引", + component: CustomIndex + }, + { + key: "layout", + content: rendContent("layout"), + title: "表格布局", + component: Layout + } +]; diff --git a/src/views/system/dept/columns.tsx b/src/views/system/dept/columns.tsx index fb891ff80..babbdcf77 100644 --- a/src/views/system/dept/columns.tsx +++ b/src/views/system/dept/columns.tsx @@ -1,8 +1,7 @@ -import { ref } from "vue"; import dayjs from "dayjs"; export function useColumns() { - const columns = ref([ + const columns: TableColumnList = [ { type: "selection", width: 55, @@ -13,7 +12,6 @@ export function useColumns() { label: "序号", type: "index", width: 60, - align: "left", hide: ({ checkList }) => !checkList.includes("序号列") }, { @@ -58,7 +56,7 @@ export function useColumns() { width: 140, slot: "operation" } - ]); + ]; return { columns diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue index 63c570f63..9571b5bba 100644 --- a/src/views/system/dept/index.vue +++ b/src/views/system/dept/index.vue @@ -99,11 +99,12 @@ onMounted(() => { - +
diff --git a/src/views/system/role/columns.tsx b/src/views/system/role/columns.tsx index 020cf13ac..94b62152c 100644 --- a/src/views/system/role/columns.tsx +++ b/src/views/system/role/columns.tsx @@ -6,10 +6,11 @@ import { Switch, message } from "@pureadmin/components"; export function useColumns() { const switchLoadMap = ref({}); - const columns = ref([ + const columns: TableColumnList = [ { type: "selection", width: 55, + align: "left", hide: ({ checkList }) => !checkList.includes("勾选列") }, { @@ -60,7 +61,7 @@ export function useColumns() { unCheckedValue={0} checked-children="已开启" un-checked-children="已关闭" - onChange={() => onChange(scope)} + onChange={() => onChange(scope as any)} /> ) }, @@ -77,7 +78,7 @@ export function useColumns() { width: 180, slot: "operation" } - ]); + ]; function onChange({ row, index }) { ElMessageBox.confirm( diff --git a/src/views/system/role/index.vue b/src/views/system/role/index.vue index 375c7f5fc..962b4e293 100644 --- a/src/views/system/role/index.vue +++ b/src/views/system/role/index.vue @@ -118,9 +118,9 @@ onMounted(() => { - +
diff --git a/src/views/system/user/columns.tsx b/src/views/system/user/columns.tsx index 54bf398a5..835d890fe 100644 --- a/src/views/system/user/columns.tsx +++ b/src/views/system/user/columns.tsx @@ -6,10 +6,11 @@ import { Switch, message } from "@pureadmin/components"; export function useColumns() { const switchLoadMap = ref({}); - const columns = ref([ + const columns: TableColumnList = [ { type: "selection", width: 55, + align: "left", hide: ({ checkList }) => !checkList.includes("勾选列") }, { @@ -65,7 +66,7 @@ export function useColumns() { unCheckedValue={0} checked-children="已开启" un-checked-children="已关闭" - onChange={() => onChange(scope)} + onChange={() => onChange(scope as any)} /> ) }, @@ -82,7 +83,7 @@ export function useColumns() { width: 180, slot: "operation" } - ]); + ]; function onChange({ row, index }) { ElMessageBox.confirm( diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index fc152dcbf..3d1b75b2b 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -131,9 +131,9 @@ onMounted(() => { - +
diff --git a/types/global.d.ts b/types/global.d.ts index 95cc36c08..a933c3de2 100644 --- a/types/global.d.ts +++ b/types/global.d.ts @@ -7,6 +7,7 @@ import type { } from "vue"; import type { ECharts } from "echarts"; import { type ResponsiveStorage } from "./index"; +import type { TableColumns } from "@pureadmin/table"; // GlobalComponents for Volar declare module "vue" { @@ -126,6 +127,9 @@ declare global { $config: ServerConfigs; } + // 继承 @pureadmin/table 的 TableColumns,方便全局直接调用 + declare interface TableColumnList extends Array {} + function parseInt(s: string | number, radix?: number): number; function parseFloat(string: string | number): number;