<template>
    <div class="demo-tabs-style right_con">
        <div v-if="platformList_type==='list'">
            <p class="title_summny">说明：添加数据获取的平台列表</p>
            <span class="iconPic"><img src="../../../static/image/icon_technology.png" alt=""></span>
            <span class="support">技术支持</span>
            <Tabs type="card" v-model="platformList_type">
                <TabPane label="我的平台" name="list">
                <div class="search">
                    <Input placeholder="平台名称" class="wid_120" v-model="search.name" @on-enter="getplatformList" />
                   <Select class="wid_120" placeholder="平台类型" clearable v-model="search.type" :transfer='true' filterable>
                        <Option value="">全部</Option>
                        <Option :value="1">系统推荐</Option>
                        <Option :value="2">自主添加</Option>
                    </Select>
                    <Button type="primary" @click="getplatformList()">搜索</Button>
                    <Button class="clear_btn" @click="removeSearch">清空</Button>
                </div>
                <Table :columns="platfromList" :data="platformData" class="clear" border></Table>
                <div class="page">
                    <Page :total="count" :current="pindex" :page-size="10" size="small" show-total show-elevator @on-change="getplatformList"/>
                </div>
                </TabPane>
                <TabPane label="添加平台" name="add"></TabPane>
        </Tabs>
        </div>
        <div v-else class="add_adminlist">
            <editPlatformList :platformList_type="platformList_type" @return_last="return_last" :curInfo="curInfo" :pindex="pindex"></editPlatformList>
        </div>
    </div>
</template>

<script>
import editPlatformList from "@@/platform/edit_platformMine";
import { removeSearch } from "@/assets/js/common";
export default {
    name: "platform_mine",
    components: {
        editPlatformList,
    },
     data() {
    return {
      count: 0,
      pindex: 1,
      is_error_tip: false,
      errorTipText: "",
      search: {
        name: "",
        type:''
      },
      curInfo: 0,
      platformList_type: "list",
      platfromList: [
        // {
        //   title: "ID",
        //   align: "left",
        //   key: "id"
        // },
        {
          title: "平台名称",
          key: "name",
          align: "left"
        },
        {
          title: "联系人",
          align: "left",
          key: "linkman"
        },
        {
          title: "联系方式",
          align: "left",
          key: "tel"
        },
        {
          title: "平台类型",
          key: "create_type_str",
          align: "left"
        },
        {
          title: "创建时间",
          key: "create_time",
          align: "left"
        },
         {
          title: "创建者",
          key: "creator",
          align: "left"
        },
        {
          title: "状态",
          align: "left",
          render: (h, params) => {
            if (params.row.status === 0) {
              return h("span",
                { style: { color: "rgba(255, 121, 0, 1)" } },"已锁定");
            } else {
              return h("span",
                { style: {} },"正常");
            }
          }
        },
        {
          title: "操作",
          align: "left",
          render: (h, params) => {
            const change_btn = h("div",
              {
                class: "operate-btn",
                style: { color: "rgba(0, 156, 255, 1)" },
                on: {
                  click: () => {
                    this.curInfo = params.row.id;
                    this.platformList_type = "edit";
                  }
                }
              },"编辑");
            const change_btn_dis = h("div",
              {
                class: "operate-btn",
                style: { color: "rgba(153, 153, 153, 1)" }
              },"编辑");
            
              if(params.row.is_admin==1){
                return [change_btn]
              }else{
                if (params.row.status === 0) {
                  return [change_btn];
                } else {
                  return [change_btn];
                }
              }
          }
        }
      ],
      platformData: []
    };
  },
    methods: {
    // 获取列表数据
    getplatformList(page = 1) {
      this.$store.commit('changeloading',true)
      this.pindex = page
      const param = {
        limit: 10,
        page: this.pindex,
        id: this.search.name,
        type: this.search.type
      }
      this.$api.getPlatformList(param)
        .then(response => {
          this.$store.commit('changeloading',false)
          if (response.code == 200) {
            this.platformData = response.data
            this.count = response.count
          } else {
            this.$Message.info(response.msg)
          }
        })
    }, 
    // 返回
    return_last(pindex) {
      this.platformList_type = "list";
      if (pindex) {
        this.getplatformList(pindex);
      }
    },
    // 清空
    removeSearch() {
      this.search = { ...removeSearch({ ...this.search }) };
    },
  },
  created() {
    this.getplatformList();
  }
}
</script>

<style lang="less" scoped>
.support {
    position: absolute;
    right: 58px;
    color: #3B82FF;
    font-size: 14px;
}
.iconPic {
    position: absolute;
    right: 124px;
    top: 2;
    top: 46px;
}
</style>