<!--查看人工盘点记录-->
<template>
  <div class="container">
    <modal v-model="modal" title="人工盘点记录" width="900px" :footer-hide="true">
        <div class="main">
          <my-table
            :data="data"
            :columns="columns"
            :table-page="params"
            :is-show-filter="false"
            @on-change="changePage"></my-table>
        </div>
    </modal>
  </div>
</template>

<script>
import { GetUserCheckTaskList } from '@/api/stock'
import MyTable from '_c/my-table/my-table'
export default {
  name: 'inventory-record',
  components: {
    MyTable
  },
  props: {
    value: {
      type: Boolean,
      default: false,
      require: true
    }
  },
  watch: {
    value: {
      handler (n) {
        this.modal = n
      },
      immediate: true
    },
    modal (n) {
      this.$emit('input', n)
      if (n) {
        this.getList()
      }
    }
  },
  data () {
    return {
      modal: false,
      data: [],
      params: {
        pageIndex: 1,
        pageSize: 12,
        total: 0
      },
      columns: [
        {
          title: '序号',
          type: 'index',
          width: 60,
          align: 'center'
        },
        {
          title: '发起人',
          key: 'taskCreateUser',
          minWidth: 150
        },
        {
          title: '发起时间',
          key: 'createTime',
          minWidth: 150
        },
        {
          title: '盘点时间',
          key: 'checkTime',
          minWidth: 150
        },
        {
          title: '盘点人',
          key: 'checkUser',
          minWidth: 150
        },
        {
          title: '盘点状态',
          key: 'checkState',
          minWidth: 150
        },
        {
          title: '操作',
          key: 'operate',
          minWidth: 120,
          align: 'center',
          fixed: 'right',
          render: (h, params) => {
            let _this = this
            return h('a', {
              on: {
                click () {
                  _this.modal = false
                  _this.$router.push({
                    name: 'inventory_record_detail',
                    query: {
                      id: params.row.id
                    }
                  })
                }
              }
            }, '查看详情')
          }
        }
      ]
    }
  },
  methods: {
    getList () {
      GetUserCheckTaskList(this.params).then(res => {
        if (res.code === 0) {
          this.data = res.result.list
          this.params.total = res.result.totalCount
        }
      })
    },
    changePage (pageIndex) {
      this.params.pageIndex = pageIndex
      this.getList()
    }
  },
  mounted () {
    this.getList()
  }
}

</script>

<style  lang="less" scoped>
  .container {
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  .content {
    flex: 1;
    overflow: auto;
  }

</style>
