<template>
    <PageSpace>
    <template v-slot:default="{adjustHeight}">
    <BizTable
      ref="bt"
      :formatCol="formatCol"
      :tblheight="adjustHeight-120"
      metaName="role_info"
      packageName="auth"
      isMulti
      @onexec="onexec"
      :savebefore="savebefore"
      :editbefore="beforedit"
      :addbefore="beforeadd"
    ></BizTable>
      </template>
  </PageSpace>
</template>
  <script>
import BizTable from "../components/tables/biztables";
import PageSpace from "@/view/components/pagespace/page_space.vue";
export default {
  name: "roleinfo_page",
  data() {
    return {};
  },
  components: {
    BizTable,
    PageSpace
  },
  methods: {
    savebefore(key, row, cbk) {
      return cbk(row);
    },
    beforeadd(row, cbk) {
      return cbk({ value: true, message: null });
    },
    beforedit(row, cbk) {
      return cbk({ value: true, message: null });
    },
    beforesave(key, row, cbk) {
      return cbk(row);
    },
    onexec(k, row) {
      if (k == "auth") {
        this.$router.push({
          name: "role_auth",
          query: { roleid: row.id, rolecode: row.code }
        });
      }
    },
    // onnew() {
    //   this.$refs.bt.setFormCtlVisable("userName", true);
    // },
    // onedit() {
    //   this.$refs.bt.setFormCtlVisable("userName", false);
    // },
    formatCol(row, key, index) {
      // if (key == "roleName") {
      //   let rolestr = row.Roles.map(item => item.name).join(",");
      //   row.roles = row.Roles.map(item => item.id);
      //   return `<span>${rolestr}</span>`;
      // }
      // if (key == "isAdmin" || key == "isSuper") {
      //   return `<span>${row[key] ? "是" : "否"}</span>`;
      // }
      if (key == "created_at") {
        return `<span>${new Date(row[key]).toLocaleString()}</span>`;
      }
      return row[key];
    }
  }
};
</script>
  <style>
</style>
