<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <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">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('han_hai_member')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <han-hai-member-modal ref="modalForm" @ok="modalFormOk"></han-hai-member-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import HanHaiMemberModal from './modules/HanHaiMemberModal'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'

  export default {
    name: 'HanHaiMemberList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      HanHaiMemberModal
    },
    data () {
      return {
        description: 'han_hai_member管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'昵称',
            align:"center",
            dataIndex: 'nickName'
          },
          {
            title:'用户头像',
            align:"center",
            dataIndex: 'headImage',
            scopedSlots: {customRender: 'imgSlot'}
          },
          {
            title:'真实姓名',
            align:"center",
            dataIndex: 'name'
          },
          {
            title:'手机号码',
            align:"center",
            dataIndex: 'phone'
          },
          {
            title:'登录账号',
            align:"center",
            dataIndex: 'account'
          },
          {
            title:'登录密码',
            align:"center",
            dataIndex: 'password'
          },
          {
            title:'登录盐',
            align:"center",
            dataIndex: 'passwordSalt'
          },
          {
            title:'店铺名称备注',
            align:"center",
            dataIndex: 'shopName'
          },
          {
            title:'角色',
            align:"center",
            dataIndex: 'role'
          },
          {
            title:'ID标识号码',
            align:"center",
            dataIndex: 'cardId'
          },
          {
            title:'是否冻结',
            align:"center",
            dataIndex: 'frozenFlag'
          },
          {
            title:'是否删除',
            align:"center",
            dataIndex: 'deleteFlag'
          },
          {
            title:'登录TOEKN',
            align:"center",
            dataIndex: 'token'
          },
          {
            title:'公众号openid',
            align:"center",
            dataIndex: 'officialOpenid'
          },
          {
            title:'小程序标识',
            align:"center",
            dataIndex: 'appletOpenid'
          },
          {
            title:'APP标识',
            align:"center",
            dataIndex: 'appOpenid'
          },
          {
            title:'微信UNIONID',
            align:"center",
            dataIndex: 'wxUnionid'
          },
          {
            title:'公众号appid',
            align:"center",
            dataIndex: 'officialAppid'
          },
          {
            title:'身份证号码',
            align:"center",
            dataIndex: 'idCard'
          },
          {
            title:'发薪平台密码',
            align:"center",
            dataIndex: 'idCardPassword'
          },
          {
            title:'发薪平台加密盐',
            align:"center",
            dataIndex: 'idCardSalt'
          },
          {
            title:'是否实名认证',
            align:"center",
            dataIndex: 'idCardOpen'
          },
          {
            title:'intentionNum',
            align:"center",
            dataIndex: 'intentionNum'
          },
          {
            title:'successNum',
            align:"center",
            dataIndex: 'successNum'
          },
          {
            title:'addNum',
            align:"center",
            dataIndex: 'addNum'
          },
          {
            title:'shareId',
            align:"center",
            dataIndex: 'shareId'
          },
          {
            title:'邀请人',
            align:"center",
            dataIndex: 'vid'
          },
          {
            title:'邀请时间',
            align:"center",
            dataIndex: 'vtime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'兼兼街会员',
            align:"center",
            dataIndex: 'isPay'
          },
          {
            title:'是否关注公众号',
            align:"center",
            dataIndex: 'follow'
          },
          {
            title:'payRole',
            align:"center",
            dataIndex: 'payRole'
          },
          {
            title:'余额',
            align:"center",
            dataIndex: 'balance'
          },
          {
            title:'积分',
            align:"center",
            dataIndex: 'integerPrice'
          },
          {
            title:'小程序appid',
            align:"center",
            dataIndex: 'appletAppid'
          },
          {
            title:'性别',
            align:"center",
            dataIndex: 'sex'
          },
          {
            title:'是否分销商',
            align:"center",
            dataIndex: 'isDai'
          },
          {
            title:'团长等级',
            align:"center",
            dataIndex: 'leaderLevelId_dictText'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/hanHaiMember/hanHaiMember/list",
          delete: "/hanHaiMember/hanHaiMember/delete",
          deleteBatch: "/hanHaiMember/hanHaiMember/deleteBatch",
          exportXlsUrl: "/hanHaiMember/hanHaiMember/exportXls",
          importExcelUrl: "hanHaiMember/hanHaiMember/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'nickName',text:'昵称',dictCode:''})
        fieldList.push({type:'string',value:'headImage',text:'用户头像',dictCode:''})
        fieldList.push({type:'string',value:'name',text:'真实姓名',dictCode:''})
        fieldList.push({type:'string',value:'phone',text:'手机号码',dictCode:''})
        fieldList.push({type:'string',value:'account',text:'登录账号',dictCode:''})
        fieldList.push({type:'string',value:'password',text:'登录密码',dictCode:''})
        fieldList.push({type:'string',value:'passwordSalt',text:'登录盐',dictCode:''})
        fieldList.push({type:'string',value:'shopName',text:'店铺名称备注',dictCode:''})
        fieldList.push({type:'string',value:'role',text:'角色',dictCode:''})
        fieldList.push({type:'string',value:'cardId',text:'ID标识号码',dictCode:''})
        fieldList.push({type:'string',value:'frozenFlag',text:'是否冻结',dictCode:''})
        fieldList.push({type:'string',value:'deleteFlag',text:'是否删除',dictCode:''})
        fieldList.push({type:'string',value:'token',text:'登录TOEKN',dictCode:''})
        fieldList.push({type:'string',value:'officialOpenid',text:'公众号openid',dictCode:''})
        fieldList.push({type:'string',value:'appletOpenid',text:'小程序标识',dictCode:''})
        fieldList.push({type:'string',value:'appOpenid',text:'APP标识',dictCode:''})
        fieldList.push({type:'string',value:'wxUnionid',text:'微信UNIONID',dictCode:''})
        fieldList.push({type:'string',value:'officialAppid',text:'公众号appid',dictCode:''})
        fieldList.push({type:'string',value:'idCard',text:'身份证号码',dictCode:''})
        fieldList.push({type:'string',value:'idCardPassword',text:'发薪平台密码',dictCode:''})
        fieldList.push({type:'string',value:'idCardSalt',text:'发薪平台加密盐',dictCode:''})
        fieldList.push({type:'string',value:'idCardOpen',text:'是否实名认证',dictCode:''})
        fieldList.push({type:'int',value:'intentionNum',text:'intentionNum',dictCode:''})
        fieldList.push({type:'int',value:'successNum',text:'successNum',dictCode:''})
        fieldList.push({type:'int',value:'addNum',text:'addNum',dictCode:''})
        fieldList.push({type:'string',value:'shareId',text:'shareId',dictCode:''})
        fieldList.push({type:'string',value:'vid',text:'邀请人',dictCode:''})
        fieldList.push({type:'date',value:'vtime',text:'邀请时间'})
        fieldList.push({type:'int',value:'isPay',text:'兼兼街会员',dictCode:''})
        fieldList.push({type:'int',value:'follow',text:'是否关注公众号',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'payRole',text:'payRole',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'balance',text:'余额',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'integerPrice',text:'积分',dictCode:''})
        fieldList.push({type:'string',value:'appletAppid',text:'小程序appid',dictCode:''})
        fieldList.push({type:'string',value:'sex',text:'性别',dictCode:''})
        fieldList.push({type:'string',value:'isDai',text:'是否分销商',dictCode:''})
        fieldList.push({type:'string',value:'leaderLevelId',text:'团长等级',dictCode:"teambuy_level,title,id"})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>