<template>
    <div class="page">
        <LayoutTable :data="tableData" :config="tableConfig" ref="layoutTable">
                    </LayoutTable>


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

<script>
    /** 表单弹出框模式需引入 */
    import drawerShow from "./drawershow";
    import table from "@/assets/mixins/table";
    export default {
        name: "BasicSetList",
        components: {
            drawerShow
},
        mixins: [table],
        created() {
        },
        methods: {
          renderTable(tableData) {
            return (
                <el-table stripe data={tableData} class="total-table">
                  {this.columnSet.map((item) => this.renderTableColumn(item))}
                </el-table>
            );
          },
          renderTableColumn(options) {
            return (
                <el-table-column
                    prop={options.prop}
                    label={options.label}
                    width={options.width}
                    formatter={options.formatter}
                >
                </el-table-column>
            );
          },
            /** 重写新增方法 */
            toAdd(row) {
                this.$refs.drawerform.add(row);
            },
            /** 重写编辑方法 */
            toEdit(row) {
                this.$refs.drawerform.edit(row);
            },
            /** 重写查看方法 */
            toView(row) {
                this.$refs.drawerform.view(row);
            },

        },
        watch:{
          'tableData'(newval){
            if (newval.data && newval.data.length>0) {
              this.$refs.layoutTable.isshowadd=false
              this.$forceUpdate()
            }else{
              this.$refs.layoutTable.isshowadd=true
            }
          },
          deep:true,
          
        },
        data() {
            return {
              columnSet:[
                {label: "状态名称", prop: "statusName",width:100},
                {label: "颜色值", prop: "statusColor",width:100}
              ],
                config: {
                    search: [
                    ],
                    columns: [
                        {type: "selection", width: 60},
                        {type: "index",label: "序号",width: 50},

                        {label: "显示照片", prop: "showPhoto",formatter: this.formatter},

                        {label: "显示姓名 ", prop: "showName",formatter: this.formatter},

                        {label: "显示职位", prop: "showPost",formatter: this.formatter},

                        {label: "显示在岗状态", prop: "showWork",formatter: this.formatter},

                        {label: "显示电话", prop: "showPhone",formatter: this.formatter},

                        {label: "显示电子门牌信息", prop: "showElect",formatter: this.formatter},

                        {label: "显示电子门牌信息自定义内容", prop: "showElectDesc"},

                        {label: "显示会议室门牌信息", prop: "showMeet",formatter: this.formatter},

                        {label: "显示会议室门牌信息自定义内容", prop: "showMeetDesc"},
                      {label: "状态",
                        width: 120,
                        prop: "subColumns",
                        formatter: (row) => {
                          let widthsize = this.columnSet.reduce((pre, cur) => {
                            return pre + Number(cur.width);
                          }, 50);
                          return (
                              <el-popover placement="right" width={widthsize} trigger="click">
                                {this.renderTable(row.basicStatusList)}
                                <el-button type="text" slot="reference">详细</el-button>
                              </el-popover>
                          );
                        },
                      },

                        {
                            label: "操作",
                            width: 240,
                            formatter: row => {
                                return (
                                    <table-buttons noAdd row={row} onEdit={this.toEdit} onView={this.toView} onDel={this.toDel} />
                            );
                            }
                        }
                    ]
                }
            };
        }
    };
</script>

<style lang="less" scoped>
/deep/ .table-head{
  display: none !important;
}
</style>
