<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="入仓号">
              <a-input placeholder="请输入入仓号" v-model="queryParam.receiving_no"></a-input>
            </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="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="仓库名称">
                <j-search-select-tag placeholder="请输入仓库名称" v-model="queryParam.name" dict="iost_storage,name,name"/>
              </a-form-item>
            </a-col>
            <a-col :xl="9" :lg="7" :md="8" :sm="24">
              <a-form-item label="日期">
                  <j-date placeholder="请选择开始日期" v-model="queryParam.日期_begin"></j-date> ~ 
                  <j-date placeholder="请选择结束日期" v-model="queryParam.日期_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-col  :xl="3" :lg="7" :md="8" :sm="24" v-if="selectedRowKeys.length > 0">
            总金额：{{ totleMoney }}
          </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: 'IostWarehouseIn',
    components: {JSearchSelectTag, JDate},
    mixins:[JeecgListMixin4Report, mixinDevice],
    data () {
      return {
        description: '仓库货物报表（入库）',
        totleVolume:0,
        totleWeight:0,
        totleMoney:0,
        // 表头
        columns: [
          {
            "title": "入仓号",
            "align": "center",
            "sorter": "true",
            "dataIndex": "receiving_no"
          }, {
            "title": "客户名称",
            "align": "center",
            "sorter": "true",
            "dataIndex": "customer_name"
          }, {
            "title": "仓库名称",
            "align": "center",
            "sorter": "true",
            "dataIndex": "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": "总金额"
          }, {
            "title": "日期",
            "align": "center",
            "sorter": "true",
            "dataIndex": "日期"
          }
        ],
        url: {
          list: "/online/cgreport/api/getColumnsAndData/1326829653178609666",
          exportXlsUrl: "/online/cgreport/api/exportXls/1326829653178609666",
        },
        dictOptions:{},
      }
    },
    created() {
    },
    methods: {
      initDictConfig(){
      },
      onSelectChange(selectedRowKeys, selectionRows) {
        this.selectedRowKeys = selectedRowKeys;
        this.selectionRows = selectionRows;
        this.totleVolume = 0;
        this.totleWeight = 0;
        this.totleMoney = 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)
            fValue = Number.parseFloat(selectionRow.总金额)
            this.totleMoney = this.FloatAdd(this.totleMoney, fValue)
        }
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>