<template>
  <div class="page">
    <LayoutTable
      :data="tableData"
      :config="tableConfig"
      @cell-click="handleCellClick"
    >
    </LayoutTable>

    <drawer-show ref="drawerform" @ok="getData" />
  </div>
</template>

<script>
/** 表单弹出框模式需引入 */
import drawerShow from "./drawershow";
import table from "@/assets/mixins/table";
export default {
  name: "WindowOwnerList",
  components: {
    drawerShow,
  },
  mixins: [table],
  created() {},
  methods: {
    handleCellClick(row, column, cell, event) {
      console.log(row, cell, column);
      if (column.label == "关联人数") {
        this.toEdit(row);
      }
    },
    /** 重写新增方法 */
    toAdd(row) {
      this.$refs.drawerform.add(row);
    },
    /** 重写编辑方法 */
    toEdit(row) {
      this.$refs.drawerform.edit(row);
    },
    /** 重写查看方法 */
    toView(row) {
      this.$refs.drawerform.view(row);
    },
  },
  data() {
    return {
      config: {
        isshowTabPane: true,
        search: [
          {
            name: "salaId",
            type: "selectSalaId",
            label: "大厅",
            fuzzy: false,
          },
          {
            name: "deptId",
            type: "selectDeptId",
            label: "部门",
            fuzzy: false,
          },
          {
            name: "roleType",
            type: "select",
            label: "角色",
            fuzzy: false,
          },
          {
            name: "staffName",
            type: "text",
            label: "姓名",
            fuzzy: true,
          },
        ],
        columns: [
          { type: "selection", width: 60 },
          { type: "index", label: "序号", width: 50 },

          { label: "负责人姓名", prop: "staffName" },
          { label: "角色", prop: "roleType", formatter: this.formatter },
          { label: "所属大厅", prop: "salaName" },
          { label: "所属部门", prop: "deptName" },

          { label: "联系电话", prop: "phone", formatter: this.formatter },

          {
            label: "关联人数",
            prop: "staffCount",
            formatter: (row) => {
              return <a>{row.staffCount}</a>;
            },
          },

          {
            label: "更新时间",
            prop: "updateTime",
            formatter: this.formatterDate,
          },
          {
            label: "更新人员",
            prop: "updateUserId",
            formatter: this.formatter,
          },
          {
            label: "操作",
            width: 240,
            formatter: (row) => {
              return (
                <table-buttons
                  noAdd
                  noView
                  row={row}
                  onEdit={this.toEdit}
                  onView={this.toView}
                  onDel={this.toDel}
                />
              );
            },
          },
        ],
      },
    };
  },
};
</script>
<style lang="less" scoped>
a {
  color: rgb(103, 116, 223);
}
</style>
