<template>
  <a-card :bordered="false">
    <div class="ant-alert ant-alert-info ant-alert-light">
      <span class="ant-alert-title">服务商管理列表，授权电签控制台访问</span>
    </div>
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    
    <!-- 操作按钮区域 -->
    <div class="table-operator">

    </div>

    <!-- table区域-begin -->
    <div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        :rowKey="(record,index)=>{return index}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">生成链接</a>
        </span>

      </a-table>
    </div>

  </a-card>
</template>

<script>
  import moment from 'moment'
  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { httpAction, getAction,putAction} from '@/api/manage'
  import { filterObj } from '@/utils/util';

  export default {
    name: "HwmCompanyList",
    mixins:[JeecgListMixin, mixinDevice],
    components: {
    },
    data () {
      return {
        description: 'hwm_company管理页面',
        allowClear: false,
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: "center",
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title:'服务商名称',
            align:"center",
            dataIndex: 'name'
          },
          {
            title:'服务商简称',
            align:"center",
            dataIndex: 'abbreviation'
          },
          {
            title:'渠道合作企业的应用ID',
            align:"center",
            dataIndex: 'proxyAppId',
            customRender: function (t, r, index) {
              return t ? t : '--'
            }
          },
          {
            title:'渠道合作企业的企业ID',
            align:"center",
            dataIndex: 'proxyOrganizationOpenId',
            customRender: function (t, r, index) {
              return t ? t : '--'
            }
          },
          {
            title:'渠道合作企业经办人ID',
            align:"center",
            dataIndex: 'proxyOperatorOpenId',
            customRender: function (t, r, index) {
              return t ? t : '--'
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width: 200,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/platmanager/hwPlatform/applicationSubContractorList",
          createConsoleLoginUrl: '/platmanager/hwPlatform/createConsoleLoginUrl',
        },
        dictOptions:{},
      }
    },
    methods: {
      initDictConfig(){
      },
      loadData(arg) {
        if (!this.url.list) {
          this.$message.error('请设置url.list属性!')
          return
        }
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1
        }
        var params = this.getQueryParams();//查询条件
        this.loading = true
        getAction(this.url.list, params).then((res) => {
          if (res.success) {
            this.dataSource = res.result.records
            this.ipagination.total = res.result.total
          }
          this.loading = false
        })
      },
      handleEdit(record){
        var that = this;
        that.loading = true;
        putAction(this.url.createConsoleLoginUrl,record).then(res=>{
          if(res.success){
            this.$message.success('生成链接成功');
            that.$success({
              title: '电签控制台地址',
              content: res.message,
              okText: '立即访问',
              onOk: () => {
                window.open(res.message, "_blank");
              }
            })
          }else{
            that.$error({
              title: '电签控制台地址',
              content: res.message,
            })
          }
        }).finally(() => {
          that.loading = false;
        })
      },
    }
  }
</script>
<style scoped lang="less">
  @import '~@assets/less/common.less';
  .ant-alert-title{
    font-size: 14px;
    line-height: 18px;
  }
  .ant-alert-light{
    margin-bottom: 16px;
    background-color: #f4f4f5;
    color: #909399;
    padding: 0.8rem;
    border: none;
  }
</style>