<!-- 合同付款详情 -->
<template>
  <div class="container-wrap">
    <div class="container">
      <div class="tabs">
        <div
          @click="tabClick(index)"
          :class="tabsIndex === index ? 'active' : ''"
          class="tab-item"
          v-for="(item, index) in tabs"
          :key="index">
          {{ item }}
        </div>
      </div>
      <div class="filter">
        <RadioGroup v-model="params.isCountEqual" @on-change="stateChange">
          <Radio label="">全部</Radio>
          <Radio :label="1">
            盘点结果一致
            <span style="color: #3F92F9">（{{ data.equelCount || 0 }}）</span>
          </Radio>
          <Radio :label="0">
            盘点结果不一致
            <span style="color: #f11111">（{{ data.notEquelCount || 0 }}）</span>
          </Radio>
        </RadioGroup>
      </div>
      <!-- 表格 -->
      <div class="table-content">
        <my-table :data="data.checkRecordDetialList.list" :border="true" :tooltip="false" :columns="tabsIndex === 0 ? columns1 : columns2" :isShowFilter="false" :table-page="params" @on-change="changePage"></my-table>
      </div>
  </div>
  </div>
</template>

<script>
import { GetCheckRecordDetailList } from '@/api/stock'
import MyTable from '_c/my-table/my-table'
export default {
  name: 'material_pay_detail',
  components: {
    MyTable
  },
  data () {
    return {
      id: '',
      tabs: ['总额', '直喷', '热转', '打纸'],
      tabsIndex: 0,
      titleData: {},
      data: {
        checkRecordDetialList: {}
      },
      columns1: [
        {
          title: '序号',
          type: 'index',
          width: 40,
          align: 'center',
          fixed: 'left'
        },
        {
          title: '类型',
          key: 'technologyType',
          minWidth: 40,
          fixed: 'left'
        },
        {
          title: '用途',
          key: 'materialUse',
          minWidth: 60,
          fixed: 'left'
        },
        {
          title: '仓库名称',
          key: 'stockHouseName',
          minWidth: 80,
          fixed: 'left'
        },
        {
          title: '物料名称',
          key: 'materialName',
          minWidth: 150,
          fixed: 'left'
        },
        {
          title: '物料编码',
          key: 'materialCode',
          minWidth: 90,
          fixed: 'left'
        },
        {
          title: '库存数量',
          key: 'stockQty',
          minWidth: 80
        },
        {
          title: '扫描数量',
          key: 'checkStockQty',
          minWidth: 80
        },
        {
          title: '盘点数量',
          key: 'everyDayHandTagQty',
          minWidth: 80
        },
        {
          title: '数量对比',
          key: 'qtyCompare',
          minWidth: 80
        },
        {
          title: '库存件数',
          key: 'tagCount',
          minWidth: 80
        },
        {
          title: '扫描件数',
          key: 'checkTagCount',
          minWidth: 80
        },
        {
          title: '盘点件数',
          key: 'everyDayHandQty',
          minWidth: 80
        },
        {
          title: '件数对比',
          key: 'tagCountCompare',
          minWidth: 80
        },
        // {
        //   title: '处置意见',
        //   key: 'dealRemark',
        //   minWidth: 80
        // },
        {
          title: '盘点时间',
          key: 'checkTime',
          minWidth: 80
        },
        {
          title: '盘点人',
          key: 'checkUser',
          minWidth: 80,
          align: 'center',
          fixed: 'right'
        }
      ],
      columns2: [
        {
          title: '序号',
          type: 'index',
          width: 40,
          align: 'center',
          fixed: 'left'
        },
        {
          title: '用途',
          key: 'materialUse',
          minWidth: 60,
          fixed: 'left'
        },
        {
          title: '仓库名称',
          key: 'stockHouseName',
          minWidth: 80,
          fixed: 'left'
        },
        {
          title: '物料名称',
          key: 'materialName',
          minWidth: 150,
          fixed: 'left'
        },
        {
          title: '物料编码',
          key: 'materialCode',
          minWidth: 90,
          fixed: 'left'
        },
        {
          title: '库存数量',
          key: 'stockQty',
          minWidth: 80
        },
        {
          title: '扫描数量',
          key: 'checkStockQty',
          minWidth: 80
        },
        {
          title: '盘点数量',
          key: 'everyDayHandTagQty',
          minWidth: 80
        },
        {
          title: '数量对比',
          key: 'qtyCompare',
          minWidth: 80
        },
        {
          title: '库存件数',
          key: 'tagCount',
          minWidth: 80
        },
        {
          title: '扫描件数',
          key: 'checkTagCount',
          minWidth: 80
        },
        {
          title: '盘点件数',
          key: 'everyDayHandQty',
          minWidth: 80
        },
        {
          title: '件数对比',
          key: 'tagCountCompare',
          minWidth: 80
        },
        // {
        //   title: '处置意见',
        //   key: 'dealRemark',
        //   minWidth: 80
        // },
        {
          title: '盘点时间',
          key: 'checkTime',
          minWidth: 80
        },
        {
          title: '盘点人',
          key: 'checkUser',
          minWidth: 80,
          align: 'center',
          fixed: 'right'
        }
      ],
      params: {
        pageIndex: 1,
        pageSize: 10,
        total: 0,
        isCountEqual: ''
      }
    }
  },
  methods: {
    /* 单选框切换 */
    stateChange () {
      this.params.pageIndex = 1
      this.getList()
    },
    /* 选项卡切换 */
    tabClick (index) {
      this.data = {
        allStockCheckPageList: {}
      }
      this.tabsIndex = index
      this.params.pageIndex = 1
      this.params.isCountEqual = ''
      if (index === 0) {
        this.params.technologyType = ''
      } else if (index === 1) {
        this.params.technologyType = 0
      } else if (index === 2) {
        this.params.technologyType = 1
      } else if (index === 3) {
        this.params.technologyType = 2
      }
      this.getList()
    },
    changePage (pageIndex) {
      this.params.pageIndex = pageIndex
      this.getList()
    },
    getList () {
      /* 盘点记录 */
      GetCheckRecordDetailList({
        ...this.params,
        recordId: this.id
      }).then(res => {
        if (res.code === 0) {
          this.data = res.result
          this.params.total = res.result.checkRecordDetialList.totalCount
        }
      })
    }
  },
  mounted () {
    this.id = this.$route.query.id
    this.getList()
  }
}
</script>

<style lang="less" scoped>
.container-wrap {
  height: 100%;
  overflow: hidden;
  .container {
    height: 100%;
    background: #FFFFFF;
    .tabs {
      box-sizing: border-box;
      height: 50px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .tab-item {
        box-sizing: border-box;
        flex: 1;
        overflow: auto;
        border-right: 1px solid #dcdee2;
        border-bottom: 1px solid #dcdee2;
        text-align: center;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        font-weight: bold;
        cursor: pointer;
        &:last-child {
          border-right: none;
        }
        &.active {
          color: #3F92F9;
          border-bottom: 3px solid #3F92F9;
        }
      }
    }
    .filter {
      padding: 0 20px;
      height: 60px;
      line-height: 60px;
      font-weight: bold;
    }
    .table-content {
      padding: 10px 20px;
      padding-top: 0;
      overflow: auto;
      height: ~"calc(100% - 110px)";
      .table-item {
        width: 100%;
        .row {
          display: flex;
          justify-content: space-between;
          align-items: center;
          .col {
            padding: 0 5px;
            flex: 1;
            display: flex;
            align-items: center;
            height: 30px;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
            word-break: break-all;
            &.red {
              color: red;
            }
            &.orange {
              color: orange;
            }
            &.blue {
              color: #169bd5;
            }
          }
        }
      }
      .content {
        padding-left: 30px;
      }
    }
  }
}
/deep/ .ivu-table-cell {
  padding: 0 6px;
}
</style>
