import { ref } from "vue";
import { options } from "../data";
export function useColumns() {
const dataList = ref([]);
const columns: TableColumnList = [
{
label: "姓名",
prop: "name",
cellRenderer: ({ row }) =>
},
{
label: "性别",
prop: "sex",
cellRenderer: ({ row }) => (
)
},
{
label: "爱好",
prop: "hobby",
cellRenderer: ({ row }) => (
{options.map(item => {
return (
);
})}
)
},
{
label: "日期",
prop: "date",
cellRenderer: ({ row }) => (
),
minWidth: 110
},
{
label: "操作",
fixed: "right",
width: 90,
slot: "operation"
}
];
function onAdd() {
dataList.value.push({
id: dataList.value.length + 1,
name: "",
sex: 0,
hobby: "",
date: ""
});
}
function onDel(row) {
const index = dataList.value.indexOf(row);
if (index !== -1) dataList.value.splice(index, 1);
}
return {
columns,
dataList,
onAdd,
onDel
};
}