<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="仓库名称">
              <j-search-select-tag placeholder="请输入仓库名称" v-model="queryParam.仓库名称" dict="iost_storage,name,name"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="客户姓名">
              <j-search-select-tag placeholder="请输入客户姓名" v-model="queryParam.customer_name" dict="iost_customer,name_chs,name_chs"/>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="9" :lg="7" :md="8" :sm="24">
              <a-form-item label="日期">
                  <j-date placeholder="请选择开始日期" v-model="queryParam.loading_date_begin"></j-date> ~ 
                  <j-date placeholder="请选择结束日期" v-model="queryParam.loading_date_end"></j-date>
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
        <a-row :gutter="24">
          <a-col :xl="3" :lg="7" :md="8" :sm="24">
            <a-button type="primary" icon="download" @click="handleExportXls('商品类别')">导出</a-button>
          </a-col>
          <a-col  :xl="3" :lg="7" :md="8" :sm="24" v-if="selectedRowKeys.length > 0">
            <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
          </a-col>
          <a-col  :xl="3" :lg="7" :md="8" :sm="24" v-if="selectedRowKeys.length > 0">
            总体积：{{ totleVolume }}　
          </a-col>
          <a-col  :xl="3" :lg="7" :md="8" :sm="24" v-if="selectedRowKeys.length > 0">
            总重量：{{ totleWeight }}
          </a-col>
        </a-row>
    </div>


    <!-- table区域-begin -->
    <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">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" 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>

      </a-table>
    </div>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin4Report } from '@/mixins/JeecgListMixin4Report'
  import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
  import JDate from '@/components/jeecg/JDate.vue'

  export default {
    name: 'IostWarehouseOut',
    components: {JSearchSelectTag, JDate},
    mixins:[JeecgListMixin4Report, mixinDevice],
    data () {
      return {
        description: '仓库货物报表（入库）',
        // 表头
        columns: [
          {
            "title": "仓库名称",
            "align": "center",
            "sorter": "true",
            "dataIndex": "仓库名称"
          }, {
            "title": "客户名称",
            "align": "center",
            "sorter": "true",
            "dataIndex": "customer_name",
          }, {
            "title": "总件数",
            "align": "center",
            "sorter": "true",
            "dataIndex": "总件数"
          }, {
            "title": "总体积",
            "align": "center",
            "sorter": "true",
            "dataIndex": "总体积"
          }, {
            "title": "总重量",
            "align": "center",
            "sorter": "true",
            "dataIndex": "总重量"
          }, {
            "title": "日期",
            "align": "center",
            "sorter": "true",
            "dataIndex": "日期"
          }
        ],
        url: {
          list: "/online/cgreport/api/getColumnsAndData/1326832190489260034",
          exportXlsUrl: "/online/cgreport/api/exportXls/1326832190489260034",
        },
        dictOptions:{},
      }
    },
    created() {
    },
    methods: {
      initDictConfig(){
      },
      onSelectChange(selectedRowKeys, selectionRows) {
        this.selectedRowKeys = selectedRowKeys;
        this.selectionRows = selectionRows;
        this.totleVolume = 0;
        this.totleWeight = 0;
        for(let selectIndex in selectionRows)
        {
            let selectionRow = selectionRows[selectIndex]
            let fValue = Number.parseFloat(selectionRow.总体积)
            this.totleVolume = this.FloatAdd(this.totleVolume, fValue)
            fValue = Number.parseFloat(selectionRow.总重量)
            this.totleWeight = this.FloatAdd(this.totleWeight, fValue)
        }
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>