<template>
  <div >
    <Modal id="staff_platform_list_modal" v-model="showMd" :title="title" :footer-hide="true" class-name="vertical-center-modal" :width="700">
      <div class="staff_platform_list">
        <div class="staff_platform_button">
          <Button type="primary" @click="handlerBindClick" class="">绑定平台</Button>
        </div>
        <Table :columns="column" border :data="list" class="table"></Table>
      </div>
    </Modal>
    <staff-platform-update :name="platformBindShowTitle" :show.sync="platformBindShow" :value="platformBindId" @platform-bind="handlerUpdateEmit"></staff-platform-update>
  </div>
</template>
<script>
import { mapState } from "vuex";
import staffPlatformUpdate from "@@/user/staff_platform_update";
export default {
  name: "staff_platform_list",
  props: {
    show: Boolean,
    value:Number,
    name:String
  },
  components: { staffPlatformUpdate },
  data() {
    return {
      title: '',
      id: 0,
      isDelete: false,
      create: false,
      delete: false,
      column: [
        {
          title: "平台名称",
          key: "platform_name"
        },
        {
          title: "平台帐号",
          key: "promote_account",
        },
        // {
        //   title:'操作',
        //   render: (h, params) => {
        //       return h('span', {
        //         class: "operate-btn",
        //         style: {
        //           color: "rgba(255, 121, 0, 1)"
        //         },
        //         on: {
        //           click: () => {
        //             this.$api.getManagerChannelDelete({manager_id: this.value, platform_id: params.row.platform_id})
        //               .then(response => {
        //                 if (response.code == 200) {
        //                   this.delete = true
        //                   this.getData()
        //                   this.$Message.success(response.msg)
        //                 } else {
        //                   this.$Message.error(response.msg)
        //                 }
        //               })
        //           }
        //         }
        //       }, '删除')
        //   },
        // }
      ],
      list: [],
      platformBindShow: false,
      platformBindId: 0,
      platformBindShowTitle: '',
    };
  },
  computed: {
    ...mapState({
      role_id: state => state.adminInfo.role_id,
    }),
    showMd: {
      get(n) {
        if(this.show){
          //this.getAuth()
          this.getData()
        }
        return this.show;
      },
      set(val) {
        if (this.delete || this.create) this.$emit("platform-update")
        this.$emit("update:show", val);
      }
    }
  },
  methods: {
    // getAuth() {
    //   this.$api.getAuthRole({id:this.role_id}).then(data=>{
    //     if(data.code===200){
    //       let checkList=data.data.auth_ids.split(',')
    //       if(checkList.indexOf('137')>=0){
    //         this.isDelete=true
    //       }
    //     }
    //   })
    // },
    getData () {
      this.$api.getManagerChannelList({manager_id:this.value})
        .then(response => {
          if (response.code == 200) {
            this.title = this.name + '绑定平台列表'
            this.list = response.data
           
          }else {
            this.$Message.error(response.msg)
            return
          }
        })
    },
    handlerBindClick () {
      this.platformBindShow = true
      this.platformBindId = this.value
      this.platformBindShowTitle = this.name
    },
    handlerUpdateEmit () {
      this.getData()
      this.create = true
    }
  },
  created() {},
};
</script>
<style scoped>
.staff_platform_list {
  padding: 20px 15px;
}
.staff_platform_button {
  padding-bottom: 20px;
}
.staff_platform_list .content {
  width: 100%;
}
</style>


