tableConfig.js 3.6 KB
const state = {
  1: "有效",
  0: "无效",
};
export const tableAttr = {
  border: true,
  loadingTable: false,
  isDragSort: false, // 拖拽tableData数据一定要加id字段
  maxHeight: 0,
  // defaultSort: { prop: "updateTime", order: "descending" },
  btnCofig: {
    isBtn: true,
    btnGroup: [
      {
        type: "primary", // text、primary、danger
        icon: "el-icon-search", // el-icon-edit 、el-icon-delete、el-icon-plus、el-icon-download、el-icon-upload el-icon--right
        btnName: "搜索",
        size: "mini", // medium / small / mini
        round: false,
        loading: false,
        event: "search",
      },
      {
        type: "primary",
        icon: "el-icon-plus",
        btnName: "添加",
        size: "mini",
        round: false,
        loading: false,
        event: "add",
      },
    ],
  },
};
export const columnHeader = (indexAdd, viewRow, editRow, deleteRow) => [
  {
    type: "index",
    label: "序号",
    prop: "id",
    align: "center",
    width: "50",
    index: indexAdd,
  },
  {
    label: "原航班",
    prop: "originOfFlightNo",
    align: "center",
    minWidth: 80,
  },
  {
    label: "配载航班",
    prop: "rankFltNoStr",
    align: "center",
    minWidth: 120,
  },
  {
    label: "航线",
    prop: "rankFltRouteStr",
    align: "center",
    minWidth: 140,
  },
  {
    label: "状态",
    prop: "status",
    align: "center",
    minWidth: 50,
    render: (h, params) => {
      const { row } = params;
      return h("div", `${state[row.status]}`);
    },
  },
  {
    label: "修改时间",
    prop: "updateTime",
    align: "center",
    minWidth: 80,
    // sortable: true,
    // "sort-method": (a, b) => a.createTime - b.createTime,
  },
  {
    label: "修改人",
    prop: "updateUserName",
    align: "center",
    minWidth: 60,
  },
  {
    label: "操作",
    prop: "operate",
    align: "center",
    minWidth: 90,
    fixed: "right",
    render: (h, params) => {
      let operateData = [];
      if (params.row.status == "1") {
        operateData = [
          h(
            "el-button",
            {
              props: {
                type: "text",
                size: "mini",
                icon: "el-icon-view",
              },
              on: {
                click() {
                  viewRow(params);
                },
              },
            },
            "查看"
          ),
          h(
            "el-button",
            {
              props: {
                type: "text",
                size: "mini",
                icon: "el-icon-edit",
              },
              on: {
                click() {
                  editRow(params);
                },
              },
            },
            "修改"
          ),
          h(
            "el-button",
            {
              style: {
                color: "#ff4949",
              },
              props: {
                type: "text",
                size: "mini",
                icon: "el-icon-delete",
              },
              on: {
                click() {
                  deleteRow(params);
                },
              },
            },
            "删除"
          ),
        ];
      } else {
        operateData = [
          h(
            "el-button",
            {
              props: {
                type: "text",
                size: "mini",
                icon: "el-icon-view",
              },
              on: {
                click() {
                  viewRow(params);
                },
              },
            },
            "查看"
          ),
        ];
      }
      return h("div", operateData);
    },
  },
];