<template>
  <div class="app-container common-list-page">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane :label="sumAmountDCL" name="first">
        <el-table :data="listDCL" :row-style="rowStyle" :cell-style="cellStyle" :show-header="false" @cell-click="cellClickDCL">
          <el-table-column prop="remark" min-width="180" />
          <el-table-column prop="repairCode" min-width="180" />
          <el-table-column prop="mesTime" min-width="180" />
        </el-table>
        <pagination v-show="totalDCL>0" :total="totalDCL" :page.sync="getdataListParmDCL.offset" :limit.sync="getdataListParmDCL.pagecount" @pagination="getListDCL" />
      </el-tab-pane>
      <el-tab-pane :label="sumAmountAll" name="second">
        <el-table :data="listAll" :row-style="rowStyle" :cell-style="cellStyle" :show-header="false">
          <el-table-column prop="remark" min-width="180" />
          <el-table-column prop="repairCode" min-width="180" />
          <el-table-column prop="mesTime" min-width="180" />
        </el-table>
        <pagination v-show="totalAll>0" :total="totalAll" :page.sync="getdataListParmAll.offset" :limit.sync="getdataListParmAll.pagecount" @pagination="getListALL" />
      </el-tab-pane>
      <el-tab-pane :label="sumAmountYCL" name="third">
        <el-table :data="listYCL" :row-style="rowStyle" :cell-style="cellStyle" :show-header="false">
          <el-table-column prop="remark" min-width="180" />
          <el-table-column prop="repairCode" min-width="180" />
          <el-table-column prop="mesTime" min-width="180" />
        </el-table>
        <pagination v-show="totalYCL>0" :total="totalYCL" :page.sync="getdataListParmYCL.offset" :limit.sync="getdataListParmYCL.pagecount" @pagination="getListYCL" />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import { GetDataByName } from '@/api/common'
import Pagination from '@/components/Pagination'
import Cookies from 'js-cookie'
export default {
  components: { Pagination },
  data() {
    return {
      activeName: 'first',
      rowStyle: { maxHeight: 40 + 'px', height: 35 + 'px' },
      cellStyle: { padding: 0 + 'px' },
      tableKey: 0,

      getNoMesCountParm: {
        name: 'getNoMesCount',
        parammaps: {
          empId: this.$store.state.user.employeid,
          pastureId: this.$store.state.user.pastureid,
          deptId: this.$store.state.user.departmentid
        }
      },
      sumAmountDCL: null,

      getAllMesCountParm: {
        name: 'getAllMesCount',
        parammaps: {
          empId: this.$store.state.user.employeid,
          pastureId: this.$store.state.user.pastureid,
          deptId: this.$store.state.user.departmentid
        }
      },
      sumAmountAll: '',

      getMesCountParm: {
        name: 'getMesCount',
        parammaps: {
          empId: this.$store.state.user.employeid,
          pastureId: this.$store.state.user.pastureid,
          deptId: this.$store.state.user.departmentid
        }
      },
      sumAmountYCL: '',
      // 待处理
      getdataListParmDCL: {
        name: 'getNoMesList',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {
          empId: this.$store.state.user.employeid,
          pastureId: this.$store.state.user.pastureid,
          deptId: this.$store.state.user.departmentid
        }
      },
      listDCL: [],
      totalDCL: 0,
      pageNumDCL: '',
      pageSizeDCL: '',
      listLoadingDCL: true,
      // 全部
      getdataListParmAll: {
        name: 'getAllMesList',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {
          empId: this.$store.state.user.employeid,
          pastureId: this.$store.state.user.pastureid,
          deptId: this.$store.state.user.departmentid
        }
      },
      listAll: [],
      totalAll: 0,
      pageNumAll: '',
      pageSizeAll: '',
      listLoadingAll: true,
      // 已处理
      getdataListParmYCL: {
        name: 'getMesList',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {
          empId: this.$store.state.user.employeid,
          pastureId: this.$store.state.user.pastureid,
          deptId: this.$store.state.user.departmentid
        }
      },
      listYCL: [],
      totalYCL: 0,
      pageNumYCL: '',
      pageSizeYCL: '',
      listLoadingYCL: true
    }
  },
  created() {
    this.getListDCL()
    this.getNoMesCount()
    this.getAllMesCount()
    this.getMesCount()
  },
  methods: {
    // 待处理消息
    getNoMesCount() {
      GetDataByName(this.getNoMesCountParm).then(response => {
        console.log('待处理数据', response.data.list)
        this.sumAmountDCL = '待处理(' + response.data.list[0].sumAmount + ')'
      })
    },

    // 全部消息
    getAllMesCount() {
      GetDataByName(this.getAllMesCountParm).then(response => {
        console.log('全部数据', response.data.list)
        this.sumAmountAll = '全部数据(' + response.data.list[0].sumAmount + ')'
      })
    },

    // 已处理消息
    getMesCount() {
      GetDataByName(this.getMesCountParm).then(response => {
        console.log('已处理', response.data.list)
        this.sumAmountYCL = '已处理(' + response.data.list[0].sumAmount + ')'
      })
    },
    handleClick(tab) {
      if (tab.name === 'second') {
        this.getListALL()
      } else if (tab.name === 'third') {
        this.getListYCL()
      } else {
        this.getListDCL()
      }
    },

    // 待处理table
    getListDCL() {
      this.listLoadingDCL = true
      GetDataByName(this.getdataListParmDCL).then(response => {
        console.log('待处理table数据', response.data.list)
        this.listDCL = response.data.list
        this.pageNumDCL = response.data.pageNum
        this.pageSizeDCL = response.data.pageSize
        this.totalDCL = response.data.total
        setTimeout(() => {
          this.listLoadingDCL = false
        }, 100)
      })
    },

    // 全部
    getListALL() {
      this.listLoadingAll = true
      GetDataByName(this.getdataListParmAll).then(response => {
        console.log('全部table数据', response.data.list)
        this.listAll = response.data.list
        this.pageNumAll = response.data.pageNum
        ths.ageSizAll = response.data.pageSize
        if (response.data.total) {
          this.totalAll = response.data.total
        }
        setTimeout(() => {
          this.listLoadingAll = false
        }, 100)
      })
    },

    // 已处理
    getListYCL() {
      this.listLoadingYCL = true
      GetDataByName(this.getdataListParmYCL).then(response => {
        console.log('已处理table数据', response.data.list)
        this.listYCL = response.data.list
        this.paNumYCL = response.data.pageNum
        this.pageSizeYCL = response.data.pageSize
        this.totalYCL = response.data.total
        setTimeout(() => {
          this.listLoadingYCL = false
        }, 100)
      })
    },
    // 行点击
    cellClickDCL(row) {
      console.log(row.remark)
      var regex1 = /\【(.+?)\】/g
      var value = (row.remark).match(regex1)[0]
      var routerName = value.substring(1, value.length - 1)
      if (routerName === '合同审核') {
        this.$router.push('/customs/Contract')
      } else if (routerName === '申购审核') {
        this.$router.push('/customs/Subscribe')
      } else if (routerName === '采购配单') {
        this.$router.push('/customs/Purchase')
      } else if (routerName === '领用审核') {
        this.$router.push('/customs/Receive')
      } else if (routerName === '退货审核') {
        this.$router.push('/customs/Returngoods')
      } else if (routerName === '设备审核') {
        this.$router.push({ path: '/asset/Basics', query: { tabName: 'second' }})
      } else if (routerName === '设备保养' || routerName === '保养审核') {
        this.$router.push('/maintenance/Maintain')
      } else if (routerName === '维修接单' || routerName === '维修派单' || routerName === '维修审核') {
        this.$router.push('/maintenance/Repair')
      } else if (routerName === '备件审核') {
        this.$router.push({ path: '/customs/Basic', query: { tabName: 'second' }})
      } else if (routerName === '配单审核') {
        this.$router.push({ path: '/customs/Purchase', query: { activeName: 'fouth' }})
      }
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
