<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('bus_market_member_info')">导出</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>

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

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import marketMemberModal from './components/marketMemberModal'

  export default {
    name: 'marketMemberList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      marketMemberModal
    },
    data () {
      return {
        description: 'bus_market_member_info管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'关联租户',
            align:"center",
            dataIndex: 'tenantId'
          },
          {
            title:'关联酒店',
            align:"center",
            dataIndex: 'hotelId'
          },
          {
            title:'会员名称',
            align:"center",
            dataIndex: 'name'
          },
          {
            title:'会员类型（0-会员折扣；1-房价方案）',
            align:"center",
            dataIndex: 'type'
          },
          {
            title:'会员折扣值',
            align:"center",
            dataIndex: 'discount'
          },
          {
            title:'关联房价方案',
            align:"center",
            dataIndex: 'schemeId'
          },
          {
            title:'是否需要支付（0-否；1-是）',
            align:"center",
            dataIndex: 'payFlag'
          },
          {
            title:'支付金额',
            align:"center",
            dataIndex: 'payAmount'
          },
          {
            title:'购买会员卡所需积分',
            align:"center",
            dataIndex: 'payIntegral'
          },
          {
            title:'是否可以储值（0-否；1-是）',
            align:"center",
            dataIndex: 'payStored'
          },
          {
            title:'会员等级',
            align:"center",
            dataIndex: 'level'
          },
          {
            title:'会员优惠（每一积分可抵扣金额）',
            align:"center",
            dataIndex: 'hyyh'
          },
          {
            title:'充值是否自动续期',
            align:"center",
            dataIndex: 'renewal'
          },
          {
            title:'自动续期天数',
            align:"center",
            dataIndex: 'renewalDay'
          },
          {
            title:'积分类型',
            align:"center",
            dataIndex: 'integralTypes'
          },
          {
            title:'客房积分模式（1-所有的消费转成积分；2-只房费转积分；）',
            align:"center",
            dataIndex: 'tenantPoints'
          },
          {
            title:'客房消费金额',
            align:"center",
            dataIndex: 'tenantRoomIntegral'
          },
          {
            title:'客房消费可增加积分',
            align:"center",
            dataIndex: 'addTenantRoomIntegral'
          },
          {
            title:'储值卡消费金额',
            align:"center",
            dataIndex: 'roomIntegral'
          },
          {
            title:'储值卡消费可增加积分',
            align:"center",
            dataIndex: 'addRoomIntegral'
          },
          {
            title:'入住天数',
            align:"center",
            dataIndex: 'dayIntegral'
          },
          {
            title:'入住可增加积分',
            align:"center",
            dataIndex: 'addDayIntegral'
          },
          {
            title:'充值金额',
            align:"center",
            dataIndex: 'rechargeIntegral'
          },
          {
            title:'充值可增加积分',
            align:"center",
            dataIndex: 'addRechargeIntegral'
          },
          {
            title:'自动升级所需积分',
            align:"center",
            dataIndex: 'upLevelIntegral'
          },
          {
            title:'自动升级等级',
            align:"center",
            dataIndex: 'upLevel'
          },
          {
            title:'升级后剩余积分',
            align:"center",
            dataIndex: 'subLevelIntegral'
          },
          {
            title:'会员图标',
            align:"center",
            dataIndex: 'icon'
          },
          {
            title:'卡片背景',
            align:"center",
            dataIndex: 'bgImage'
          },
          {
            title:'卡片描述',
            align:"center",
            dataIndex: 'content'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/business/busMarketMember/list",
          delete: "/business/busMarketMember/delete",
          deleteBatch: "/business/busMarketMember/deleteBatch",
          exportXlsUrl: "/business/busMarketMember/exportXls",
          importExcelUrl: "business/busMarketMember/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:'tenantId',text:'关联租户'})
        fieldList.push({type:'string',value:'hotelId',text:'关联酒店'})
        fieldList.push({type:'string',value:'name',text:'会员名称'})
        fieldList.push({type:'int',value:'type',text:'会员类型（0-会员折扣；1-房价方案）'})
        fieldList.push({type:'number',value:'discount',text:'会员折扣值'})
        fieldList.push({type:'string',value:'schemeId',text:'关联房价方案'})
        fieldList.push({type:'int',value:'payFlag',text:'是否需要支付（0-否；1-是）'})
        fieldList.push({type:'number',value:'payAmount',text:'支付金额'})
        fieldList.push({type:'number',value:'payIntegral',text:'购买会员卡所需积分'})
        fieldList.push({type:'int',value:'payStored',text:'是否可以储值（0-否；1-是）'})
        fieldList.push({type:'int',value:'level',text:'会员等级'})
        fieldList.push({type:'number',value:'hyyh',text:'会员优惠（每一积分可抵扣金额）'})
        fieldList.push({type:'string',value:'renewal',text:'充值是否自动续期'})
        fieldList.push({type:'number',value:'renewalDay',text:'自动续期天数'})
        fieldList.push({type:'string',value:'integralTypes',text:'积分类型'})
        fieldList.push({type:'string',value:'tenantPoints',text:'客房积分模式（1-所有的消费转成积分；2-只房费转积分；）'})
        fieldList.push({type:'number',value:'tenantRoomIntegral',text:'客房消费金额'})
        fieldList.push({type:'number',value:'addTenantRoomIntegral',text:'客房消费可增加积分'})
        fieldList.push({type:'number',value:'roomIntegral',text:'储值卡消费金额'})
        fieldList.push({type:'number',value:'addRoomIntegral',text:'储值卡消费可增加积分'})
        fieldList.push({type:'number',value:'dayIntegral',text:'入住天数'})
        fieldList.push({type:'number',value:'addDayIntegral',text:'入住可增加积分'})
        fieldList.push({type:'number',value:'rechargeIntegral',text:'充值金额'})
        fieldList.push({type:'number',value:'addRechargeIntegral',text:'充值可增加积分'})
        fieldList.push({type:'number',value:'upLevelIntegral',text:'自动升级所需积分'})
        fieldList.push({type:'int',value:'upLevel',text:'自动升级等级'})
        fieldList.push({type:'number',value:'subLevelIntegral',text:'升级后剩余积分'})
        fieldList.push({type:'string',value:'icon',text:'会员图标'})
        fieldList.push({type:'string',value:'bgImage',text:'卡片背景'})
        fieldList.push({type:'string',value:'content',text:'卡片描述'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
