import Vue from 'vue'
export default Vue.component('render-temp', {
  props: {
    item: Object
  },
  methods:{
    handler(val) {
      this.$emit('handler',val)
    }
  },
  render(h) {
    const _this = this;
    const autingHtml = <span class="green">审核中</span>;
    const customCodesyncHtml = <span class="danger-color">正在上传卡券Code</span>;
    const autingFaildHtml = <span class="danger-color">审核失败</span>;
    const autingUpdateFaildHtml = <span class="danger-color">更新失败</span>;
    const statushtml = <span>

      <a title="复制" onClick={_this.handler.bind(null,6)}><i class="iconfont icon-wxcard-copy"></i></a>
      <a title="投放" onClick={_this.handler.bind(null,1)}><i class="iconfont icon-daohang-"></i></a>
      <a title="报表" onClick={_this.handler.bind(null,2)}><i class="el-icon-tickets"></i></a>
      <a title="编辑" onClick={_this.handler.bind(null,3)}><i class="el-icon-edit"></i></a>
      <a title="删除" onClick={_this.handler.bind(null,4)}><i class="el-icon-delete"></i></a>
    </span>;

    const overDateHtml = <span>
      <span class="danger">已过期</span>
      <a title="复制" onClick={_this.handler.bind(null,6)}><i class="iconfont icon-wxcard-copy"></i></a>
      <a title="报表" onClick={_this.handler.bind(null,2)}><i class="el-icon-tickets"></i></a>
      <a title="详情" onClick={_this.handler.bind(null,5)}><i class="el-icon-document"></i></a>
      <a title="删除" onClick={_this.handler.bind(null,4)}><i class="el-icon-delete"></i></a>
    </span>;

    const noputonStatushtml = <span>
      <a title="复制" onClick={_this.handler.bind(null,6)}><i class="iconfont icon-wxcard-copy"></i></a>
      <a title="报表" onClick={_this.handler.bind(null,2)}><i class="el-icon-tickets"></i></a>
      <a title="编辑" onClick={_this.handler.bind(null,3)}><i class="el-icon-edit"></i></a>
      <a title="删除" onClick={_this.handler.bind(null,4)}><i class="el-icon-delete"></i></a>
    </span>;

    const statusNostockhtml = <span>
      <a title="复制" onClick={_this.handler.bind(null,6)}><i class="iconfont icon-wxcard-copy"></i></a>
      <a title="报表" onClick={_this.handler.bind(null,2)}><i class="el-icon-tickets"></i></a>
      <a title="编辑" onClick={_this.handler.bind(null,3)}><i class="el-icon-edit"></i></a>
      <a title="删除" onClick={_this.handler.bind(null,4)}><i class="el-icon-delete"></i></a>
    </span>;

    const statusFaildhtml = <span>
      <a title="复制" onClick={_this.handler.bind(null,6)}><i class="iconfont icon-wxcard-copy"></i></a>
      <a title="编辑" onClick={_this.handler.bind(null,3)}><i class="el-icon-edit"></i></a>
      <a title="删除" onClick={_this.handler.bind(null,4)}><i class="el-icon-delete"></i></a>
    </span>;
    const _html = (this.item.cardEffectiveMode == 0 && (this.item.endDate < Date.now())) ? overDateHtml : statushtml;
    if (this.item.auditingStatus === 0) {
      return (<div class="fr">{autingHtml}</div>)
    }else if (this.item.auditingStatus === -1) {
      return (<div class="fr">{autingFaildHtml}{statusFaildhtml}</div>)
    }else if (this.item.auditingStatus === -2)
    return (<div class="fr">{autingUpdateFaildHtml}{_html}</div>)
    else if (this.item.useCustomCode == 1 && this.item.customCodeSync == 1)
    return (<div class="fr">{customCodesyncHtml}</div>)
    else if (this.item.stock === 0)
    return (<div class="fr">{statusNostockhtml}</div>)
    else if (this.item.cardLimit && this.item.cardLimit == 1)
    return (<div class="fr">{_html}</div>)
    else return (<div class="fr">{noputonStatushtml}</div>)
  }
})
