import { ref } from "vue";
import { tableData, options } from "../data";
import { clone, delObjectProperty } from "@pureadmin/utils";
export function useColumns() {
const editMap = ref({});
const dataList = ref(clone(tableData, true));
const columns: TableColumnList = [
{
label: "姓名",
prop: "name",
cellRenderer: ({ row, index }) => (
<>
{editMap.value[index]?.editable ? (
{row.name}
)} > ) }, { label: "性别", prop: "sex", cellRenderer: ({ row, index }) => ( <> {editMap.value[index]?.editable ? ({row.sex === 0 ? "男" : "女"}
)} > ) }, { label: "爱好", prop: "hobby", cellRenderer: ({ row, index }) => ( <> {editMap.value[index]?.editable ? ({row.date}
)} > ), minWidth: 110 }, { label: "操作", fixed: "right", slot: "operation" } ]; function onEdit(row, index) { editMap.value[index] = Object.assign({ ...row, editable: true }); } function onSave(index) { editMap.value[index].editable = false; } function onCancel(index) { editMap.value[index].editable = false; dataList.value[index] = delObjectProperty(editMap.value[index], "editable"); } return { editMap, columns, dataList, onEdit, onSave, onCancel }; }