<template>
  <div class="app-container">
    <el-tabs v-model="activeName" @tab-click="handleTabClick">
      <el-tab-pane :label="$t('InventoryManagement.kctj')"   name="first">
        <div class="search">
          <el-date-picker v-model="tab.table.getdataListParm.parammaps.inputDatetime" :clearable="false" class="inputDatetime filter-item" type="daterange" :range-separator="$t('common.to')"  :start-placeholder="$t('common.startTime')" :end-placeholder="$t('common.endTime')" style="float: left;width: 250px;margin-bottom:10px;" :picker-options="pickerOptions" />
          <el-button class="el-icon-arrow-left elIconArrowLeft" :disabled="Beforedisabled" style="float: left;" @click="handleBefore" />
          <el-button class="el-icon-arrow-right elIconArrowRight" :disabled="Nextdisabled" style="float: left;" @click="handleNext" />
          <el-input v-model="tab.table.getdataListParm.parammaps.feedname" class="filter-item" style="float: left;width: 245px;margin-bottom:10px;":placeholder="$t('InventoryManagement.silc')"    />
          <el-button class="successBorder" style="float: left;margin-left: 10px;margin-bottom:10px;" @click="form_search('first')">{{$t('common.query')}}</el-button>
          <el-button class="export" style="float: right;margin-right: 10px;margin-bottom:10px;" icon="el-icon-upload2" @click="handleExport('tab1')">{{$t('dashboard.Export')}}</el-button>
        </div>
        <div class="table">
          <el-table
            :key="tab.table.tableKey"
            v-loading="tab.table.listLoading"
            :element-loading-text="$t('common.tableMsg')"
            :data="tab.table.list"
            border
            fit
            highlight-current-row
            style="width: 100%;"
            :row-style="rowStyle"
            :cell-style="cellStyle"
            class="elTable table-fixed"
            ref="table1"
          >
            <el-table-column sortable :label="$t('InventoryManagement.silc')"    min-width="130px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.feedname }}</span>
              </template>
            </el-table-column>
            <el-table-column :label="$t('InventoryManagement.qc')"   min-width="130px" align="center">
              <el-table-column sortable prop="startsum" align="center" :label="$t('InventoryManagement.qckc')"    min-width="120" />
              <el-table-column sortable prop="startprice" align="center" :label="$t('InventoryManagement.qcje')"    min-width="120" />
            </el-table-column>
            <el-table-column :label="$t('InventoryManagement.yl')"    min-width="110px" align="center">
              <el-table-column sortable prop="laidsum" align="center" :label="$t('InventoryManagement.rkylzl')"    min-width="120" />
              <el-table-column sortable prop="usesumXT" align="center" :label="$t('InventoryManagement.xtckyl')"    min-width="120" />
              <el-table-column sortable prop="usesumRG" align="center" :label="$t('InventoryManagement.rgylzl')"    min-width="120" />
              <el-table-column sortable prop="usesumXH" align="center" :label="$t('InventoryManagement.chzl')"    min-width="120" />
            </el-table-column>
            <el-table-column :label="$t('InventoryManagement.qm')"     min-width="130px" align="center">
              <el-table-column sortable prop="stopsum" align="center" :label="$t('InventoryManagement.qmkc')"   min-width="120" />
              <el-table-column sortable prop="stopprice" align="center" :label="$t('InventoryManagement.qmje')"    min-width="120" />
            </el-table-column>
          </el-table>
          <pagination v-show="tab.table.total>=0" :total="tab.table.total" :page.sync="tab.table.getdataListParm.offset" :limit.sync="tab.table.getdataListParm.pagecount" @pagination="getTabList" />
        </div>
      </el-tab-pane>
      <el-tab-pane :label="$t('InventoryManagement.yltj')"   name="second">
        <div class="search">
          <el-date-picker v-model="tab2.table.getdataListParm.parammaps.inputDatetime" :clearable="false" class="inputDatetime filter-item" type="daterange" :range-separator="$t('common.to')"  :start-placeholder="$t('common.startTime')" :end-placeholder="$t('common.endTime')" style="width: 245px;" :picker-options="pickerOptions2" />
          <el-button class="el-icon-arrow-left elIconArrowLeft" :disabled="Beforedisabled2" @click="handleBefore2" />
          <el-button class="el-icon-arrow-right elIconArrowRight" :disabled="Nextdisabled2" @click="handleNext2" />
          <span style="margin-left: 10px;">{{$t('errorAnalysis.typeName')}}</span>
          <el-select v-model="tab2.radio" :placeholder="$t('InventoryManagement.tjlx')"   class="filter-item" style="width: 120px;" @change="changeRadio2">
            <el-option v-for="item in statisticalTypeList2" :key="item.id" :label="item.name" :value="item.id" />
          </el-select>
          <el-checkbox v-model="tab2.table.getdataListParm.checked" :true-label="1" :false-label="0" style="margin-right:10px;" @change="changeChecked">{{$t('InventoryManagement.wc')}}</el-checkbox>
          <el-select v-model="tab2.table.getdataListParm.parammaps.ftType" :placeholder="$t('InventoryManagement.sfcfxl')"    class="filter-item" style="width: 130px;">
            <el-option v-for="item in isSplitsmallmaterialsList" :key="item.id" :label="item.name" :value="item.id" />
          </el-select>
          <el-input v-if="tab2.isRadio1" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item filter-item1" style="width: 200px;" :placeholder="$t('feedingEfficiency.cxlb')" />
          <el-input v-if="tab2.isRadio2" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item filter-item1" style="width: 200px;" :placeholder="$t('errorAnalysis.isHouseName')"  />
          <el-input v-if="tab2.isRadio3" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item filter-item1" style="width: 200px;" :placeholder="$t('InventoryManagement.rq')"    />
          <el-input v-if="tab2.isRadio4" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item filter-item1" style="width: 200px;" :placeholder="$t('InventoryManagement.tmrsbbh')"    />
          <el-input v-if="tab2.isRadio5" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item filter-item1" style="width: 200px;" :placeholder="$t('errorAnalysis.isTrainNumber')"  />
          <el-input v-if="tab2.isRadio6" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item filter-item1" style="width: 200px;" :placeholder="$t('errorAnalysis.projname')"  />
          <el-select v-model="tab2.table.getdataListParm.parammaps.typea" clearable :placeholder="$t('InventoryManagement.lbxs')"    class="filter-item" style="width: 120px;">
            <el-option v-for="item in displayList" :key="item.id" :label="item.name" :value="item.id" />
          </el-select>
          <el-select v-model="tab2.table.getdataListParm.parammaps.times" clearable filterable :placeholder="$t('errorAnalysis.isTrainNumber')"  class="filter-item" style="width: 120px;">
            <el-option v-for="item in frequencyList" :key="item.id" :label="item.name" :value="item.id" />
          </el-select>
          <el-button class="successBorder" @click="form_search('second')">{{$t('common.query')}}</el-button>
          <el-button class="export" style="float: right;margin-right: 5px;margin-top:10px;" icon="el-icon-upload2" @click="handleExport('tab2')">{{$t('dashboard.Export')}}</el-button>
          <el-button class="export" style="float: right;margin-right: 5px;margin-top:10px;" icon="el-icon-upload2" @click="handlesWitch()">{{
            $t('InventoryManagement.qhzs')
          }}</el-button>
        </div>

        <div v-if="isTable1">
        <div v-if="tab2.table.tableConfig.length > 8">
          <u-table v-if="isDispayTable2" ref="plTable2" v-loading="tab2.table.listLoading" :row-style="rowStyle" :cell-style="cellStyle" :max-height="myHeight2" use-virtual :row-height="rowHeight" border class="elTable table-fixed plTable2">
            <!-- 第一个表头 -->
            <u-table-column v-for="(header1, index1) in tab2.table.tableConfig" :key="'header1-' + index1" :label="header1.label" align="center" :fixed="index1==0" :show-overflow-tooltip="header1.showOverflow" >
              <!-- 第二个表头 -->
              <u-table-column v-for="(header2, index2) in header1.children" :key="'header2-' + index2" :label="header2.label" align="center" :fixed="index2==0" :show-overflow-tooltip="header2.showOverflow">
                <!-- 第三个表头 -->
                <u-table-column v-for="(header3, index3) in header2.children" :key="'header3-' + index3" :label="header3.label" :prop="header3.prop" align="center">
                </u-table-column>
              </u-table-column>
            </u-table-column>
          </u-table>
          <!-- <u-table v-if="isDispayTable2" ref="plTable2" v-loading="tab2.table.listLoading" :row-style="rowStyle" :cell-style="cellStyle" :max-height="myHeight2" use-virtual :row-height="rowHeight" border class="elTable table-fixed plTable2">
            <u-table-column v-for="(item,index) in tab2.table.tableConfig" :key="index" :label="item.label" :show-overflow-tooltip="item.showOverflow"  :prop="item.prop" align="center" :fixed="index==0">
              <u-table-column v-for="(item1,key1) in item.children" v-if="item.children || item.children.length>0" :key="key1" :label="item1.label" :prop="item1.prop" align="center">
                <u-table-column v-for="(item2,key2) in item1.children" v-if="item1.children || item1.children.length>0" :key="key2" :label="item2.label" :prop="item2.prop" />
              </u-table-column>
            </u-table-column>
          </u-table> -->
        </div>
        <div v-else>
          <u-table v-if="isDispayTable2" ref="plTable2" v-loading="tab2.table.listLoading" :row-style="rowStyle" :cell-style="cellStyle" :max-height="myHeight2" use-virtual :row-height="rowHeight" border class="elTable table-fixed plTable2">
            <!-- 第一个表头 -->
            <u-table-column v-for="(header1, index1) in tab2.table.tableConfig" :key="'header1-' + index1" :label="header1.label" align="center" :fixed="index1==0" :show-overflow-tooltip="header1.showOverflow">
              <!-- 第二个表头 -->
              <u-table-column v-for="(header2, index2) in header1.children" :key="'header2-' + index2" :label="header2.label" align="center" :fixed="index2==0" :show-overflow-tooltip="header2.showOverflow">
                <!-- 第三个表头 -->
                <u-table-column v-for="(header3, index3) in header2.children" :key="'header3-' + index3" :label="header3.label" :prop="header3.prop" align="center">
                </u-table-column>
              </u-table-column>
            </u-table-column>
          </u-table>
          <!-- <u-table v-if="isDispayTable2" ref="plTable2" v-loading="tab2.table.listLoading" :row-style="rowStyle" :cell-style="cellStyle" :max-height="myHeight2" use-virtual :row-height="rowHeight" border class="elTable table-fixed plTable2">
            <u-table-column v-for="(item,index) in tab2.table.tableConfig" :key="index" :label="item.label" :show-overflow-tooltip="item.showOverflow"  :prop="item.prop" align="center">
              <u-table-column v-for="(item1,key1) in item.children" v-if="item.children || item.children.length>0" :key="key1" :label="item1.label" :prop="item1.prop" align="center">
                <u-table-column v-for="(item2,key2) in item1.children" v-if="item1.children || item1.children.length>0" :key="key2" :label="item2.label" :prop="item2.prop" />
              </u-table-column>
            </u-table-column>
          </u-table> -->
        </div>

        <span v-if="tab2.table.listLoading == false && tab2.table.list.length>0" style="margin-right: 30px;margin-top: 10px;font-size: 14px;">{{$t('processAnalysis.total')}}{{ tab2.table.total }}{{$t('processAnalysis.tiao')}}</span>
        </div>
        <div v-else>
          <!-- 新展示 -->
          <u-table :span-method="objectSpanMethod" ref="plTable22" v-loading="tab2.table.listLoading" :row-style="rowStyle" :cell-style="cellStyle" :max-height="myHeight2" use-virtual :row-height="rowHeight" border class="elTable table-fixed plTable2">
            <u-table-column v-for="(column, index) in tableColumns" :key="index" :prop="column.prop" :label="column.label" align="center"></u-table-column>
          </u-table>
        </div>
      </el-tab-pane>
      <el-tab-pane :label="$t('InventoryManagement.jgfx')" name="third" >
        <div class="search">
          <el-date-picker v-model="tab3.table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" :range-separator="$t('common.to')"  :start-placeholder="$t('common.startTime')" :end-placeholder="$t('common.endTime')" :clearable="false" style="width: 250px;" :picker-options="pickerOptions" />
          <el-button class="el-icon-arrow-left elIconArrowLeft" :disabled="Beforedisabled3" @click="handleBefore3" />
          <el-button class="el-icon-arrow-right elIconArrowRight" :disabled="Nextdisabled3" @click="handleNext3" />
          <span style="margin-left: 10px;">{{$t('errorAnalysis.typeName')}}</span>
          <el-select v-model="tab3.radio" :placeholder="$t('InventoryManagement.tjlx')"   class="filter-item" style="width: 120px;" @change="changeRadio3">
            <el-option v-for="item in statisticalTypeList3" :key="item.id" :label="item.name" :value="item.id" />
          </el-select>
          <!-- <el-radio v-model="tab3.radio" label="1" @change="changeRadio3">{{$t('feedingEfficiency.cxlb')}}</el-radio>
          <el-radio v-model="tab3.radio" label="2" @change="changeRadio3">{{$t('errorAnalysis.isHouseName')}}</el-radio>
          <el-radio v-model="tab3.radio" label="3" @change="changeRadio3">{{$t('errorAnalysis.date')}}</el-radio>
          <el-radio v-model="tab3.radio" label="4" @change="changeRadio3">{{$t('InventoryManagement.tmrsbbh')}}</el-radio> -->
          <el-input v-if="tab3.isRadio1" v-model="tab3.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 185px;" :placeholder="$t('feedingEfficiency.cxlb')" />
          <el-input v-if="tab3.isRadio2" v-model="tab3.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 185px;" :placeholder="$t('errorAnalysis.isHouseName')"  />
          <el-input v-if="tab3.isRadio3" v-model="tab3.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 185px;" :placeholder="$t('InventoryManagement.rq')"    />
          <el-input v-if="tab3.isRadio4" v-model="tab3.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 185px;" :placeholder="$t('InventoryManagement.tmrsbbh')"    />
          <el-button class="successBorder" @click="form_search('third')">{{$t('common.query')}}</el-button>
          <el-button class="export filter-item1" style="float: right;margin-right: 5px;" icon="el-icon-upload2" @click="handleExport('tab3')">{{$t('dashboard.Export')}}</el-button>
        </div>
        <div v-if="tab3.table.tableConfig.length>2">
        <u-table v-if="isDispayTable3" ref="plTable3" v-loading="tab3.table.listLoading" :row-style="rowStyle" :cell-style="cellStyle" :max-height="myHeight2" use-virtual :row-height="rowHeight" border class="elTable table-fixed plTable3">
          <u-table-column v-for="(item,key) in tab3.table.tableConfig" :key="key" :label="item.label" :show-overflow-tooltip="item.showOverflow" align="center"  :prop="item.prop" :fixed="key==0">
              <u-table-column v-for="(item1,key1) in item.children" v-if="item.children || item.children.length>0" :key="key1" align="center" :label="item1.label" :prop="item1.prop" :min-width="item1.width">
                <u-table-column v-for="(item2,key2) in item1.children" v-if="item1.children || item1.children.length>0" :key="key2" :label="item2.label" :prop="item2.prop" />
              </u-table-column>
            </u-table-column>
          </u-table>
        </div>
        <div v-else>
          <u-table v-if="isDispayTable3" ref="plTable3" v-loading="tab3.table.listLoading" :row-style="rowStyle" :cell-style="cellStyle" :max-height="myHeight2" use-virtual :row-height="rowHeight" border class="elTable table-fixed plTable3">
            <u-table-column v-for="(item,key) in tab3.table.tableConfig" :key="key" :label="item.label" :show-overflow-tooltip="item.showOverflow" align="center" :prop="item.prop">
                <u-table-column v-for="(item1,key1) in item.children" v-if="item.children || item.children.length>0" :key="key1" align="center" :label="item1.label" :prop="item1.prop" :min-width="item1.width">
                  <u-table-column v-for="(item2,key2) in item1.children" v-if="item1.children || item1.children.length>0" :key="key2" :label="item2.label" :prop="item2.prop" />
                </u-table-column>
              </u-table-column>
            </u-table>
        </div>
        <span v-if="tab3.table.listLoading == false && tab3.table.list.length>0" style="margin-right: 30px;margin-top: 10px;font-size: 14px;">{{$t('processAnalysis.total')}}{{ tab3.table.total }}{{$t('processAnalysis.tiao')}}</span>
      </el-tab-pane>
    </el-tabs>
  </div>
</div>

</template>

<script>
import { GetDataByName, GetReportform,postJson } from '@/api/common'
import Cookies from 'js-cookie'
import { parseTime } from '@/utils/index.js'
import Pagination from '@/components/Pagination'
import { json2excel, export_json_to_excel } from '@/utils/index.js'
export default {
  name: 'PastureInventoryManagement',
  components: { Pagination },
  data() {
    return {
      Beforedisabled: false,
      Nextdisabled: false,
      Beforedisabled2: false,
      Nextdisabled2: false,
      Beforedisabled3: false,
      Nextdisabled3: false,
      pickerMinDate: '',
      pickerOptions: {
        onPick: ({ maxDate, minDate }) => {
          this.pickerMinDate = minDate.getTime()
          if (maxDate) {
            this.pickerMinDate = ''
          }
        },
        // 限制不能选择今天之后的日期
        disabledDate: (time) => {
          if (this.pickerMinDate !== '') {
            const one = 31 * 24 * 3600 * 1000
            const minTime = this.pickerMinDate - one
            let maxTime = this.pickerMinDate + one
            if (maxTime > new Date()) {
              maxTime = new Date()
            }
            return time.getTime() < minTime || time.getTime() > maxTime
          }
          return time.getTime() > Date.now()
        }
      },
      pickerOptions2: {
        onPick: ({ maxDate, minDate }) => {
          this.pickerMinDate = minDate.getTime()
          if (maxDate) {
            this.pickerMinDate = ''
          }
        },
        // 限制不能选择今天之后的日期
        disabledDate: (time) => {
          if (this.pickerMinDate !== '') {
            const one = 31 * 24 * 3600 * 1000
            const minTime = this.pickerMinDate - one
            let maxTime = this.pickerMinDate + one
            // if (maxTime > new Date()) {
            //   maxTime = new Date()
            // }
            return time.getTime() < minTime || time.getTime() > maxTime
          }
          // return time.getTime() > Date.now()
        }
      },
      fileComment: [{ 'label': '商务文件评分', 'children': [{ 'label': '1' }, { 'label': '2' }, { 'label': '管理员' }] }],
      displayList:[{id:'1',name:'理论'},{id:'2',name:'实际'}],//列表显示
      isSplitsmallmaterialsList:[{id:'0',name:'拆分'},{id:'1',name:'不拆分'}],
      activeName: 'first',
      tab: {
        chartDate: [],
        table: {
          getdataListParm: {
            name: 'getfsStaticlist',
            page: 1,
            offset: 1,
            pagecount: parseInt(Cookies.get('pageCount')),
            returntype: 'Map',
            parammaps: {
              pastureid: Cookies.get('pastureid'),
              startTime: parseTime(new Date(), '{y}-{m}-{d}'),
              stopTime: parseTime(new Date(), '{y}-{m}-{d}'),
              inputDatetime: [new Date(), new Date()],
              feedname: ''
            }
          },
          tableKey: 1,
          list: [],
          total: 0,
          listLoading: false
        }
      },

      tab2: {
        chartDate: [],
        display:'',
        table: {
          getdataListParm: {
            name: 'getMaterialAnalysisSC',
            page: 1,
            offset: 1,
            pagecount: '',
            returntype: 'Map',
            checked: 0,
            parammaps: {
              pastureid: Cookies.get('pastureid'),
              startTime: parseTime(new Date(), '{y}-{m}-{d}'),
              stopTime: parseTime(new Date(), '{y}-{m}-{d}'),
              inputDatetime: [new Date(), new Date()],
              fname: '',
              typea:'',
              times:'',
              ftType:'1'
            }
          },
          tableKey: 1,
          list: [],
          tableConfig: [],
          data: [],
          total: 0,
          listLoading: false
        },
        radio: '1',
        isRadio1: true,
        isRadio2: false,
        isRadio3: false,
        isRadio4: false,
        isRadio5: false,
        isRadio6: false
      },
      tab3: {
        chartDate: [],
        table: {
          getdataListParm: {
            name: 'getPriceAnalysisSC',
            page: 1,
            offset: 1,
            pagecount: parseInt(Cookies.get('pageCount')),
            returntype: 'Map',
            parammaps: {
              pastureid: Cookies.get('pastureid'),
              startTime: parseTime(new Date(), '{y}-{m}-{d}'),
              stopTime: parseTime(new Date(), '{y}-{m}-{d}'),
              inputDatetime: [new Date(), new Date()],
              fname: ''
            }
          },
          tableKey: 1,
          list: [],
          tableConfig: [],
          total: 0,
          listLoading: false
        },
        radio: '1',
        isRadio1: true,
        isRadio2: false,
        isRadio3: false,
        isRadio4: false
      },
      downLoad: {},
      rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
      cellStyle: { padding: 0 + 'px' },
      myHeight2: document.documentElement.clientHeight - 95 - 150,
      rowHeight: 30,
      isDispayTable2:false,
      isDispayTable3:false,
      statisticalTypeList2: [{ id: '1', name: this.$t('errorAnalysis.sxlb') }, { id: '2', name: this.$t('errorAnalysis.isHouseName') }, { id: '3', name:this.$t('errorAnalysis.date')  }, { id: '4', name: this.$t('InventoryManagement.tmrsbbh') }, { id: '5', name: 'TMR班次' }, { id: '6', name: this.$t('errorAnalysis.projname') }],
      statisticalTypeList3: [{ id: '1', name: this.$t('errorAnalysis.sxlb') }, { id: '2', name: this.$t('errorAnalysis.isHouseName') }, { id: '3', name:this.$t('errorAnalysis.date')  }, { id: '4', name: this.$t('InventoryManagement.tmrsbbh') }],
      frequencyList: [], // 班次
      isTable1:true,
      spanObj: {},
      mergekeys: ['A', 'B'],
      tableColumns:[],
      myData:{},
      columnsToTotal: ['10-配种']
    }
  },
  created() {
    this.getTimeFn()
    this.getIsDisplay()
  },
  methods: {
    getIsDisplay() {
      const url = 'authdata/GetDataByName'
      const data = {
        name: 'getSysoptEnable',
        page: 1,
        offset: 1,
        pagecount: 1,
        returntype: 'Map',
        parammaps: {
          pastureid: Cookies.get('pastureid'),
          inforname: 'times'
        }
      }
      postJson(url, data).then(response => {
        console.log(response.data.list[0].inforvalue)
        if (response.data.list[0].inforvalue == 1) {
          this.frequencyList = [{ id: 1, name: this.$t('errorAnalysis.one'), }]
        } else if (response.data.list[0].inforvalue == 2) {
          this.frequencyList = [
            { id: 1, name: this.$t('errorAnalysis.one'), }, { id: 2, name: this.$t('errorAnalysis.two'), }
          ]
        } else if (response.data.list[0].inforvalue == 3) {
          this.frequencyList = [
            { id: 1, name: this.$t('errorAnalysis.one'), }, { id: 2, name: this.$t('errorAnalysis.two'), }, { id: 3, name: this.$t('errorAnalysis.three'), }
          ]
        } else if (response.data.list[0].inforvalue == 4) {
          this.frequencyList = [
            { id: 1, name: this.$t('errorAnalysis.one'), }, { id: 2, name: this.$t('errorAnalysis.two'), }, { id: 3, name: this.$t('errorAnalysis.three'), }, { id: 4, name: this.$t('errorAnalysis.four'), }
          ]
        }else if (response.data.list[0].inforvalue == 5) {
          this.frequencyList = [
            { id: 1, name: this.$t('errorAnalysis.one'), }, { id: 2, name: this.$t('errorAnalysis.two'), }, { id: 3, name: this.$t('errorAnalysis.three'), }, { id: 4, name: this.$t('errorAnalysis.four'), }, { id: 5, name: this.$t('errorAnalysis.five'), }
          ]
        }else if (response.data.list[0].inforvalue == 6) {
          this.frequencyList = [
            { id: 1, name: this.$t('errorAnalysis.one'), }, { id: 2, name: this.$t('errorAnalysis.two'), }, { id: 3, name: this.$t('errorAnalysis.three'), }, { id: 4, name: this.$t('errorAnalysis.four'), }, { id: 5, name: this.$t('errorAnalysis.five'), }, { id: 6, name: this.$t('errorAnalysis.six'), },
          ]
        }
      })
    },
    getTimeFn() {
      const that = this
      const start = new Date()
      const end = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
      end.setTime(end.getTime() - 3600 * 1000 * 24 * 1)
      that.tab.table.getdataListParm.parammaps.startTime = parseTime(start, '{y}-{m}-{d}')
      that.tab.table.getdataListParm.parammaps.stopTime = parseTime(end, '{y}-{m}-{d}')
      that.tab.table.getdataListParm.parammaps.inputDatetime = [start, end]

      that.tab2.table.getdataListParm.parammaps.startTime = parseTime(end, '{y}-{m}-{d}')
      that.tab2.table.getdataListParm.parammaps.stopTime = parseTime(end, '{y}-{m}-{d}')
      that.tab2.table.getdataListParm.parammaps.inputDatetime = [end, end]

      that.tab3.table.getdataListParm.parammaps.startTime = parseTime(end, '{y}-{m}-{d}')
      that.tab3.table.getdataListParm.parammaps.stopTime = parseTime(end, '{y}-{m}-{d}')
      that.tab3.table.getdataListParm.parammaps.inputDatetime = [end, end]
      this.getTabList()
    },
    handleTabClick() {
      if (this.activeName == 'first') {
        const start = new Date()
        const end = new Date()
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
        end.setTime(end.getTime() - 3600 * 1000 * 24 * 1)
        this.tab.table.getdataListParm.parammaps.inputDatetime = [start, end]
        this.getTabList()
      } else if (this.activeName == 'second') {
        const start2 = new Date()
        const end2 = new Date()
        start2.setTime(start2.getTime() - 3600 * 1000 * 24 * 1)
        end2.setTime(end2.getTime() - 3600 * 1000 * 24 * 1)
        this.tab2.table.getdataListParm.parammaps.inputDatetime = [start2, end2]
        this.tab2.radio = '1'
        this.tab2.table.getdataListParm.parammaps.ftType = '1'
        this.tab2.table.getdataListParm.parammaps.startTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
        this.tab2.table.getdataListParm.parammaps.stopTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
        this.getTab2List()
      } else if (this.activeName == 'third') {
        const start3 = new Date()
        const end3 = new Date()
        start3.setTime(start3.getTime() - 3600 * 1000 * 24 * 1)
        end3.setTime(end3.getTime() - 3600 * 1000 * 24 * 1)
        this.tab3.table.getdataListParm.parammaps.inputDatetime = [start3, end3]
        this.tab3.radio = '1'
        this.tab3.table.getdataListParm.parammaps.startTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
        this.tab3.table.getdataListParm.parammaps.stopTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
        this.getTab3List()
      }
    },
    getTabList() {
      this.tab.table.listLoading = true
      GetDataByName(this.tab.table.getdataListParm).then(response => {
        if (response.data.list !== null) {
          console.log('库存统计table数据', response.data.list)
          this.tab.table.list = response.data.list
          this.tab.table.total = response.data.total
        } else {
          this.tab.table.list = []
        }
        setTimeout(() => {
          this.tab.table.listLoading = false
        }, 100)
      })
    },
    form_search(item) {
      if (item == 'first') {
        if (this.tab.table.getdataListParm.parammaps.inputDatetime !== '' && this.tab.table.getdataListParm.parammaps.inputDatetime !== null) {
          this.tab.table.getdataListParm.parammaps.startTime = parseTime(this.tab.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
          this.tab.table.getdataListParm.parammaps.stopTime = parseTime(this.tab.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
        } else {
          this.tab.table.getdataListParm.parammaps.inputDatetime = ''
          this.tab.table.getdataListParm.parammaps.startTime = ''
          this.tab.table.getdataListParm.parammaps.stopTime = ''
        }
        this.getTabList()
      } else if (item == 'second') {
        if (this.tab2.table.getdataListParm.parammaps.inputDatetime !== '' && this.tab2.table.getdataListParm.parammaps.inputDatetime !== null) {
          this.tab2.table.getdataListParm.parammaps.startTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
          this.tab2.table.getdataListParm.parammaps.stopTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
        } else {
          this.tab2.table.getdataListParm.parammaps.inputDatetime = ''
          this.tab2.table.getdataListParm.parammaps.startTime = ''
          this.tab2.table.getdataListParm.parammaps.stopTime = ''
        }
        this.getTab2List()
      } else if (item == 'third') {
        if (this.tab3.table.getdataListParm.parammaps.inputDatetime !== '' && this.tab3.table.getdataListParm.parammaps.inputDatetime !== null) {
          this.tab3.table.getdataListParm.parammaps.startTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
          this.tab3.table.getdataListParm.parammaps.stopTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
        } else {
          this.tab3.table.getdataListParm.parammaps.inputDatetime = ''
          this.tab3.table.getdataListParm.parammaps.startTime = ''
          this.tab3.table.getdataListParm.parammaps.stopTime = ''
        }
        this.getTab3List()
      }
    },

    // 用料分析
    getTab2List() {
      this.tab2.table.listLoading = true
      this.isDispayTable2 = false
      setTimeout(()=>{
        this.isDispayTable2 = true
        this.$nextTick(() => {
          let myList = []
          if(this.isTable1){
            this.tab2.table.getdataListParm.parammaps.mode = 0
          }else{
            this.tab2.table.getdataListParm.parammaps.mode = 1
          }
          GetReportform(this.tab2.table.getdataListParm).then(response => {
            if(this.isTable1){
              if (response.data !== null && response.data.data !== null && response.data.data1 !== null) {
                this.tab2.table.data = response.data.data
                response.data.feedcode.push('')
                response.data.feedcode.unshift('饲料编码')
                for (let i = 0; i < response.data.list.data2.length; i++) {
                  // console.log(response.data.list.data2[i],'===label')
                  for (let j = 0; j < response.data.list.data1.length; j++) {
                    for (let a = 0; a < response.data.list.data2[i].children.length; a++) {
                      if (response.data.list.data1[j][response.data.list.data2[i].children[a].prop] == undefined || response.data.list.data1[j][response.data.list.data2[i].children[a].prop] == null || response.data.list.data1[j][response.data.list.data2[i].children[a].prop] == '') {
                        response.data.list.data1[j][response.data.list.data2[i].children[a].prop] = 0
                      }
                    }
                  }
                  if (response.data.list.data2[i].children.length > 1) {
                    for (let j = 0; j < response.data.list.data2[i].children.length; j++) {
                      if (response.data.list.data2[i].children[j].label == '理论' || response.data.list.data2[i].children[j].label == '实际') {
                        this.$set(response.data.list.data2[i].children[j], 'width', '80px')
                      } else {
                        this.$set(response.data.list.data2[i].children[j], 'width', '80px')
                      }
                    }
                  } else {
                    this.$set(response.data.list.data2[i].children[0], 'width', '80px')
                  }
                }
                let list = response.data.list.data2
                let code = response.data.feedcode
                const headers = []
                for(let i=0;i<list.length;i++){
                  for(let j=0;j<code.length;j++){
                    if(i== j){
                      let obj = {
                        label:code[j],
                        children:[
                          list[i]
                        ]
                      }
                      headers.push(obj)
                    }
                  }
                }
                myList = response.data.list.data1
                this.tab2.table.list = response.data.list.data1
                this.tab2.table.tableConfig = headers
                this.tab2.table.total = response.data.list.data1.length

                console.log('库存统计-用料分析this.tab2.table.data', response.data.data)
                console.log('库存统计-用料分析this.tab2.table.feedcode', response.data.feedcode)
                console.log('库存统计-用料分析this.tab2.table.list', response.data.list.data1)
                console.log('库存统计-用料分析this.tab2.table.tableConfig',response.data.list.data2)
              } else {
                myList = []
                this.tab2.table.list = []
                this.tab2.table.tableConfig = []
              }

              console.log(this.tab2.table.list.length)
              this.$refs.plTable2.reloadData(myList)
            }else{
              this.myData = response.data
              this.tableColumns = response.data.columns;
              this.tableData = response.data.data;
              this.$refs.plTable22.reloadData(this.tableData)
              this.handleSpan()
            }
            setTimeout(() => {
              this.tab2.table.listLoading = false
            }, 100)
          })
        })
      })
    },

    changeRadio2() {
      console.log(this.tab2.radio)
      if (this.tab2.radio == '1') {
        this.tab2.isRadio1 = true,
        this.tab2.isRadio2 = false,
        this.tab2.isRadio3 = false,
        this.tab2.isRadio4 = false,
        this.tab2.isRadio5 = false,
        this.tab2.isRadio6 = false,
        this.tab2.table.getdataListParm.name = 'getMaterialAnalysisSC'
        this.tab2.table.getdataListParm.offset = 1
        this.tab2.table.getdataListParm.parammaps.startTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
        this.tab2.table.getdataListParm.parammaps.stopTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
        this.getTab2List()
      } else if (this.tab2.radio == '2') {
        this.tab2.isRadio1 = false,
        this.tab2.isRadio2 = true,
        this.tab2.isRadio3 = false,
        this.tab2.isRadio4 = false,
        this.tab2.isRadio5 = false,
        this.tab2.isRadio6 = false,
        this.tab2.table.getdataListParm.name = 'getMaterialAnalysisLS'
        this.tab2.table.getdataListParm.offset = 1
        this.tab2.table.getdataListParm.parammaps.startTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
        this.tab2.table.getdataListParm.parammaps.stopTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
        this.getTab2List()
      } else if (this.tab2.radio == '3') {
        this.tab2.isRadio1 = false,
        this.tab2.isRadio2 = false,
        this.tab2.isRadio3 = true,
        this.tab2.isRadio4 = false,
        this.tab2.isRadio5 = false,
        this.tab2.isRadio6 = false,
        this.tab2.table.getdataListParm.name = 'getMaterialAnalysisRQ'
        this.tab2.table.getdataListParm.offset = 1
        this.tab2.table.getdataListParm.parammaps.startTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
        this.tab2.table.getdataListParm.parammaps.stopTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
        this.getTab2List()
      } else if (this.tab2.radio == '4') {
        this.tab2.isRadio1 = false,
        this.tab2.isRadio2 = false,
        this.tab2.isRadio3 = false,
        this.tab2.isRadio4 = true,
        this.tab2.isRadio5 = false,
        this.tab2.isRadio6 = false,
        this.tab2.table.getdataListParm.name = 'getMaterialAnalysisTMR'
        this.tab2.table.getdataListParm.offset = 1
        this.tab2.table.getdataListParm.parammaps.startTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
        this.tab2.table.getdataListParm.parammaps.stopTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
        this.getTab2List()
      } else if (this.tab2.radio == '5') {
        this.tab2.isRadio1 = false,
        this.tab2.isRadio2 = false,
        this.tab2.isRadio3 = false,
        this.tab2.isRadio4 = false,
        this.tab2.isRadio5 = true,
        this.tab2.isRadio6 = false,
        this.tab2.table.getdataListParm.name = 'getMaterialAnalysisBC'
        this.tab2.table.getdataListParm.offset = 1
        this.tab2.table.getdataListParm.parammaps.startTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
        this.tab2.table.getdataListParm.parammaps.stopTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
        this.getTab2List()
      } else if (this.tab2.radio == '6') {
        this.tab2.isRadio1 = false,
        this.tab2.isRadio2 = false,
        this.tab2.isRadio3 = false,
        this.tab2.isRadio4 = false,
        this.tab2.isRadio5 = false,
        this.tab2.isRadio6 = true,
        this.tab2.table.getdataListParm.name = 'getMaterialAnalysisCC'
        this.tab2.table.getdataListParm.offset = 1
        this.tab2.table.getdataListParm.parammaps.startTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
        this.tab2.table.getdataListParm.parammaps.stopTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
        this.getTab2List()
      }
    },
    // 价格分析
    getTab3List() {
      this.tab3.table.listLoading = true
      this.isDispayTable3 = false
      setTimeout(()=>{
        this.isDispayTable3 = true
        this.$nextTick(() => {
          let myList = []
          GetReportform(this.tab3.table.getdataListParm).then(response => {
            if (response.data !== null && response.data.list.data1 !== null && response.data.list.data2 !== null) {
              console.log('库存统计-价格分析', response.data.list)
              for (let i = 0; i < response.data.list.data2.length; i++) {
                for (let j = 0; j < response.data.list.data1.length; j++) {
                  for (let a = 0; a < response.data.list.data2[i].children.length; a++) {
                    if (response.data.list.data1[j][response.data.list.data2[i].children[a].prop] == undefined || response.data.list.data1[j][response.data.list.data2[i].children[a].prop] == null || response.data.list.data1[j][response.data.list.data2[i].children[a].prop] == '') {
                      response.data.list.data1[j][response.data.list.data2[i].children[a].prop] = 0
                    }
                  }
                }
                if (response.data.list.data2[i].children.length > 1) {
                  for (let j = 0; j < response.data.list.data2[i].children.length; j++) {
                    if (response.data.list.data2[i].children[j].label == '理论' || response.data.list.data2[i].children[j].label == '实际') {
                      this.$set(response.data.list.data2[i].children[j], 'width', '80px')
                    } else {
                      this.$set(response.data.list.data2[i].children[j], 'width', '80px')
                    }
                  }
                } else {
                  this.$set(response.data.list.data2[i].children[0], 'width', '80px')
                }
              }
              myList = response.data.list.data1
              this.tab3.table.list = response.data.list.data1
              this.tab3.table.tableConfig = response.data.list.data2
              this.tab3.table.total = response.data.list.data1.length
            } else {
              this.tab3.table.tableConfig = []
              this.tab3.table.list = []
              myList = []
            }
            setTimeout(() => {
             this.$refs.plTable3.reloadData(myList)
              this.tab3.table.listLoading = false
            }, 100)
          })
        })
      })
    },
    handleBefore() {
      if (this.tab.table.getdataListParm.parammaps.inputDatetime !== '' && this.tab.table.getdataListParm.parammaps.inputDatetime !== null) {
        var start = new Date(this.tab.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.tab.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
        var stop = new Date(this.tab.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.tab.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
        if (stop > Date.now() - 8.64e7) {
          this.Nextdisabled = true
          this.Beforedisabled = false
        } else {
          this.Nextdisabled = false
          this.Beforedisabled = false
        }
        this.tab.table.getdataListParm.parammaps.inputDatetime.length = 0
        this.tab.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
        this.$forceUpdate()
      }
      this.tab.table.getdataListParm.parammaps.startTime = parseTime(this.tab.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
      this.tab.table.getdataListParm.parammaps.stopTime = parseTime(this.tab.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
      this.getTabList()
    },
    handleNext() {
      if (this.tab.table.getdataListParm.parammaps.inputDatetime !== '' && this.tab.table.getdataListParm.parammaps.inputDatetime !== null) {
        var start2 = new Date(this.tab.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.tab.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
        var stop2 = new Date(this.tab.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.tab.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
        if (stop2 > Date.now() - 8.64e7) {
          this.Nextdisabled = true
          this.Beforedisabled = false
        } else {
          this.Nextdisabled = false
          this.Beforedisabled = false
        }
        this.tab.table.getdataListParm.parammaps.inputDatetime.length = 0
        this.tab.table.getdataListParm.parammaps.inputDatetime.push(start2, stop2)
        this.$forceUpdate()
      }
      this.tab.table.getdataListParm.parammaps.startTime = parseTime(this.tab.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
      this.tab.table.getdataListParm.parammaps.stopTime = parseTime(this.tab.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
      this.getTabList()
    },
    handleBefore2() {
      if (this.tab2.table.getdataListParm.parammaps.inputDatetime !== '' && this.tab2.table.getdataListParm.parammaps.inputDatetime !== null) {
        var start3 = new Date(this.tab2.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.tab2.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
        var stop3 = new Date(this.tab2.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.tab2.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
        if (stop3 > Date.now() - 8.64e7) {
          this.Nextdisabled2 = true
          this.Beforedisabled2 = false
        } else {
          this.Nextdisabled2 = false
          this.Beforedisabled2 = false
        }
        this.tab2.table.getdataListParm.parammaps.inputDatetime.length = 0
        this.tab2.table.getdataListParm.parammaps.inputDatetime.push(start3, stop3)
        this.$forceUpdate()
      }
      this.tab2.table.getdataListParm.parammaps.startTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
      this.tab2.table.getdataListParm.parammaps.stopTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
      this.getTab2List()
    },
    handleNext2() {
      if (this.tab2.table.getdataListParm.parammaps.inputDatetime !== '' && this.tab2.table.getdataListParm.parammaps.inputDatetime !== null) {
        var start4 = new Date(this.tab2.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.tab2.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
        var stop4 = new Date(this.tab2.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.tab2.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
        if (stop4 > Date.now() - 8.64e7) {
          this.Nextdisabled2 = true
          this.Beforedisabled2 = false
        } else {
          this.Nextdisabled2 = false
          this.Beforedisabled2 = false
        }
        this.tab2.table.getdataListParm.parammaps.inputDatetime.length = 0
        this.tab2.table.getdataListParm.parammaps.inputDatetime.push(start4, stop4)
        this.$forceUpdate()
      }
      this.tab2.table.getdataListParm.parammaps.startTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
      this.tab2.table.getdataListParm.parammaps.stopTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
      this.getTab2List()
    },
    handleBefore3() {
      if (this.tab3.table.getdataListParm.parammaps.inputDatetime !== '' && this.tab3.table.getdataListParm.parammaps.inputDatetime !== null) {
        var start5 = new Date(this.tab3.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.tab3.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
        var stop5 = new Date(this.tab3.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.tab3.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
        if (stop5 > Date.now() - 8.64e7) {
          this.Nextdisabled3 = true
          this.Beforedisabled3 = false
        } else {
          this.Nextdisabled3 = false
          this.Beforedisabled3 = false
        }
        this.tab3.table.getdataListParm.parammaps.inputDatetime.length = 0
        this.tab3.table.getdataListParm.parammaps.inputDatetime.push(start5, stop5)
        this.$forceUpdate()
      }
      this.tab3.table.getdataListParm.parammaps.startTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
      this.tab3.table.getdataListParm.parammaps.stopTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
      this.getTab3List()
    },
    handleNext3() {
      if (this.tab3.table.getdataListParm.parammaps.inputDatetime !== '' && this.tab2.table.getdataListParm.parammaps.inputDatetime !== null) {
        var start6 = new Date(this.tab3.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.tab3.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
        var stop6 = new Date(this.tab3.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.tab3.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
        if (stop6 > Date.now() - 8.64e7) {
          this.Nextdisabled3 = true
          this.Beforedisabled3 = false
        } else {
          this.Nextdisabled3 = false
          this.Beforedisabled3 = false
        }
        this.tab3.table.getdataListParm.parammaps.inputDatetime.length = 0
        this.tab3.table.getdataListParm.parammaps.inputDatetime.push(start6, stop6)
        this.$forceUpdate()
      }
      this.tab3.table.getdataListParm.parammaps.startTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
      this.tab3.table.getdataListParm.parammaps.stopTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
      this.getTab3List()
    },
    changeRadio3() {
      console.log(this.tab3.radio)
      if (this.tab3.radio == '1') {
        this.tab3.isRadio1 = true,
        this.tab3.isRadio2 = false,
        this.tab3.isRadio3 = false,
        this.tab3.isRadio4 = false,
        this.tab3.table.getdataListParm.name = 'getPriceAnalysisSC'
        this.tab3.table.getdataListParm.offset = 1
        this.tab3.table.getdataListParm.parammaps.startTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
        this.tab3.table.getdataListParm.parammaps.stopTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
        this.getTab3List()
      } else if (this.tab3.radio == '2') {
        this.tab3.isRadio1 = false,
        this.tab3.isRadio2 = true,
        this.tab3.isRadio3 = false,
        this.tab3.isRadio4 = false,
        this.tab3.table.getdataListParm.name = 'getPriceAnalysisLS'
        this.tab3.table.getdataListParm.offset = 1
        this.tab3.table.getdataListParm.parammaps.startTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
        this.tab3.table.getdataListParm.parammaps.stopTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
        this.getTab3List()
      } else if (this.tab3.radio == '3') {
        this.tab3.isRadio1 = false,
        this.tab3.isRadio2 = false,
        this.tab3.isRadio3 = true,
        this.tab3.isRadio4 = false,
        this.tab3.table.getdataListParm.name = 'getPriceAnalysisRQ'
        this.tab3.table.getdataListParm.offset = 1
        this.tab3.table.getdataListParm.parammaps.startTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
        this.tab3.table.getdataListParm.parammaps.stopTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
        this.getTab3List()
      } else if (this.tab3.radio == '4') {
        this.tab3.isRadio1 = false,
        this.tab3.isRadio2 = false,
        this.tab3.isRadio3 = false,
        this.tab3.isRadio4 = true,
        this.tab3.table.getdataListParm.name = 'getPriceAnalysisTMR'
        this.tab3.table.getdataListParm.offset = 1
        this.tab3.table.getdataListParm.parammaps.startTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
        this.tab3.table.getdataListParm.parammaps.stopTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
        this.getTab3List()
      }
    },
    changeChecked(item) {
      this.form_search('second')
    },
    handlesWitch(item){
      this.isTable1 = !this.isTable1
        this.getTab2List()
    },
    handleSpan() {
      this.mergekeys.forEach(key => {
        this.spanObj[key] = []
        let position = 0
        this.tableData.forEach((item, index) => {
          if (index === 0) {
            this.spanObj[key].push(1)
            position = 0
          } else {
            if (key == 'B') {
              if (this.tableData[index][key] === this.tableData[index - 1][key] && this.tableData[index]['A'] === this.tableData[index - 1]['A']) {
                this.spanObj[key][position] += 1
                this.spanObj[key].push(0)
              } else {
                this.spanObj[key].push(1)
                position = index
              }
            } else {
              if (this.tableData[index][key] === this.tableData[index - 1][key]) {
                this.spanObj[key][position] += 1
                this.spanObj[key].push(0)
              } else {
                this.spanObj[key].push(1)
                position = index
              }
            }
          }
        })
      })
    },
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      for (let i = 0; i < this.mergekeys.length; i++) {
        if (column.property === this.mergekeys[i]) {
          let _row = this.spanObj[this.mergekeys[i]][rowIndex]
          let _col = _row > 0 ? 1 : 0
          console.log(_row,'_row1')
          return {
            rowspan: _row,
            colspan: _col
          }
        }
      }
    },
    handleExport(item) {
      if (item == 'tab1') {

        console.log('库存统计导出')
        this.downLoad.getdataListParm = {}
        this.downLoad.getdataListParm.name = 'getfsStaticlist'
        this.downLoad.getdataListParm.pagecount = ''
        this.downLoad.getdataListParm.parammaps = this.tab.table.getdataListParm.parammaps
        GetDataByName(this.downLoad.getdataListParm).then(response => {
          if (response.data.list !== null) {
            this.$nextTick(() => {
              this.downLoad.list = response.data.list
            })
          } else {
            this.downLoad.list = []
          }
          const table = this.$refs.table1;
        const columns = table.columns;
        const labels = columns.map(column => column.label);

          import('@/vendor/Export5Excel').then(excel => {
            const multiHeader = [[this.$t('InventoryManagement.silc'), , this.$t('InventoryManagement.qc'), '', this.$t('InventoryManagement.yl'), '', '', '', this.$t('InventoryManagement.qm'), '']]
            const multiHeader2 = labels;
            const filterVal = ['feedname', 'startsum', 'startprice', 'laidsum', 'usesumXT', 'usesumRG', 'usesumXH', 'stopsum', 'stopprice']
            const data = this.downLoad.list.map((v) => filterVal.map((j) => v[j]))
            const merges = ['A1:A2', 'B1:C1', 'D1:G1', 'H1:I1']
            excel.export_json_to_excel({ multiHeader, multiHeader2, data, filename: this.$t('InventoryManagement.kctj'), merges }) // kctj
          })
        })
      } else if (item == 'tab2') {
        if(this.isTable1){
          console.log('用料分析导出数据', this.tab2.table.list)
          console.log('用料分析导出表头', this.tab2.table.tableConfig)
          console.log(this.tab2.table.getdataListParm.checked, 'checked')
          console.log(this.tab2.table.getdataListParm)
          var startTime = this.tab2.table.getdataListParm.parammaps.startTime
          var stopTime = this.tab2.table.getdataListParm.parammaps.stopTime

          var exportData = []
          var exportTitle1 = [] // 一级标题
          var exportTitle2 = [] // 二级标题
          var exportTitle3 = [] // 一级标题
          var filterValArr = []
          for (let i = 0; i < this.tab2.table.tableConfig.length; i++) {
            exportTitle1.push(this.tab2.table.tableConfig[i].label)
            for (let j = 0; j < this.tab2.table.tableConfig[i].children.length; j++) {
              exportTitle2.push(this.tab2.table.tableConfig[i].children[j].label)
              for(let a = 0;a<this.tab2.table.tableConfig[i].children[j].children.length;a++){
                exportTitle3.push(this.tab2.table.tableConfig[i].children[j].children[a].label)
                filterValArr.push(this.tab2.table.tableConfig[i].children[j].children[a].prop)
              }
              // filterValArr.push(this.tab2.table.tableConfig[i].children[j].prop)
            }
          }
          console.log('一级标题exportTitle1', exportTitle1)
          console.log('二级标题exportTitle2', exportTitle2)
          console.log('三级标题exportTitle3', exportTitle3)
          console.log('对应字段filterValArr', filterValArr)
          var headerArr = []// 处理一级标题
          var headerArr2 = []// 处理一级标题
          if (this.tab2.table.getdataListParm.checked == 1) {
            for (let i = 0; i < exportTitle1.length; i++) {
              if (i > 0) {
                headerArr.push(exportTitle1[i], '', '', '')
              } else {
                headerArr.push(exportTitle1[i])
              }
              if (i > 0) {
                headerArr2.push(exportTitle2[i], '', '', '')
              } else {
                headerArr2.push(exportTitle2[i])
              }
            }
          } else {
            if(this.tab2.table.getdataListParm.parammaps.typea == ''){
              for (let i = 0; i < exportTitle1.length; i++) {
                if (i > 0) {
                  headerArr.push(exportTitle1[i], '')
                } else {
                  headerArr.push(exportTitle1[i])
                }
                if (i > 0) {
                  headerArr2.push(exportTitle2[i], '')
                } else {
                  headerArr2.push(exportTitle2[i])
                }
              }
            }else{
              headerArr = exportTitle1
              headerArr2 = exportTitle2
            }
          }
          console.log('headerArr', headerArr)
          console.log('exportTitle2', exportTitle2)
          console.log('filterValArr', filterValArr)
          if (headerArr.length > 0) {
            import('@/vendor/Export3Excel').then((excel) => {
              const multiHeader = [
                headerArr
              ]
              const multiHeader2 = [
                headerArr2
              ]
              const tHeader = exportTitle3
              const filterVal = filterValArr
              const data = this.tab2.table.list.map(v => filterVal.map(j => v[j]))
              // const data = []
              const merges = ['A1:A1']
              excel.export_json_to_excel({ multiHeader, multiHeader2, header: tHeader, data, filename: '用料分析-'+startTime+'-' +stopTime , merges })
            })
          }else{
            import('@/vendor/Export3Excel').then((excel) => {
              const multiHeader = [
                headerArr
              ]
              const multiHeader2 = []
              const tHeader = exportTitle2
              const filterVal = filterValArr
              const data = this.tab2.table.list.map(v => filterVal.map(j => v[j]))
              // const data = []
              // const merges = ['A1:A1']
              const merges = []
              excel.export_json_to_excel({ multiHeader, multiHeader2, header: tHeader, data, filename: '用料分析', merges })
            })
          }
        }else{
          var startTime = this.tab2.table.getdataListParm.parammaps.startTime
          var stopTime = this.tab2.table.getdataListParm.parammaps.stopTime
          var title = '用料分析-'+startTime+'-' +stopTime
          var tHeader = []
          var filterVal = []
          for (let i = 0; i < this.tableColumns.length; i++) {
            tHeader.push(this.tableColumns[i].label)
            filterVal.push(this.tableColumns[i].prop)
          }
          var excelDatas = [
            {
              tHeader: tHeader,
              filterVal: filterVal,
              tableDatas: this.tableData,
              sheetName: 'Sheet'
            }
          ]
          json2excel(excelDatas, title, true, 'xlsx')
        }
      } else if (item == 'tab3') {
        console.log('价格分析导出')
        console.log('价格分析导出数据', this.tab3.table.list)
        console.log('价格分析导出表头', this.tab3.table.tableConfig)
        var exportData = []
        var exportTitle1 = [] // 一级标题
        var exportTitle2 = [] // 二级标题
        for (let i = 0; i < this.tab3.table.tableConfig.length; i++) {
          exportTitle1.push(this.tab3.table.tableConfig[i].label)
          for (let j = 0; j < this.tab3.table.tableConfig[i].children.length; j++) {
            exportTitle2.push(this.tab3.table.tableConfig[i].children[j].label)
          }
        }
        console.log('一级标题exportTitle1', exportTitle1)
        console.log('二级标题exportTitle2', exportTitle2)
        var headerArr = []// 处理一级标题
        for (let i = 0; i < exportTitle1.length; i++) {
          if (i > 0) {
            headerArr.push(exportTitle1[i], '')
          } else {
            headerArr.push(exportTitle1[i])
          }
        }
        console.log('一级表头处理后', headerArr)
        var valueArr = [] // 对应字段
        for (let i = 0; i < exportTitle2.length; i++) {
          if (i == 0) {
            valueArr.push('A')
          } else {
            valueArr.push('a' + [i - 1])
          }
        }
        console.log('对应字段valueArr', valueArr)
        if (headerArr.length > 0) {
          import('@/vendor/Export3Excel').then((excel) => {
            const multiHeader = [
              headerArr
            ]
            const multiHeader2 = []
            const tHeader = exportTitle2
            const filterVal = valueArr// 表头所对应的字段，这里未填写
            const data = this.tab3.table.list.map(v => filterVal.map(j => v[j]))
            // const data = [];
            // 进行所有表头的单元格合并
            // const merges = ['A1:A1', 'B1:E1','F1:J1' ];
            const merges = ['A1:A1']

            excel.export_json_to_excel({ multiHeader, multiHeader2, header: tHeader, data, filename: '价格分析', merges })
          })
        }
      }
    },
    format(jsonData) { // 数据处理
      const dataList = []
      for (let i = 0; i < jsonData.length; i++) {
        const list = []
        list.push(jsonData[i].index)
        list.push(jsonData[i].Personel)
        list.push(jsonData[i].address)
        for (let j = 0; j < jsonData[0]['time'].length; j++) {
          list.push(jsonData[i]['time'][j].morning)
          list.push(jsonData[i]['time'][j].afternoon)
        }
        dataList.push(list)
      }
      return dataList
    }

  }
}
</script>
<style lang="scss" scoped>
  .search{
    margin-bottom:10px;
    .el-radio{margin-right: 10px;}
    .filter-item1{margin-top: 10px;}
  }
  /deep/ .el-table th>.cell{
    padding-left: 0 !important;;
    padding-right: 0 !important;;
  }
  /deep/ .el-table td>.cell{
    padding-left: 0 !important;;
    padding-right: 0 !important;;
  }
  // .el-radio{margin-right: 20px;}
</style>
<style lang="scss">
  .el-tooltip__popper{
  max-width: 60% !important;
  }
  .plTableBox .el-table td.is-hidden>*, .plTableBox .el-table th.is-hidden>*{
    visibility:inherit;
  }
  .plTableBox .el-table th>.cell{
    white-space: pre-wrap;
  }
</style>
