<!-- 移交记录 -->
<template>
    <div>
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="queryPage()">
        <el-form-item label="名称">
          <el-input v-model="dataForm.name" placeholder="名称" clearable/>
        </el-form-item>
        <el-form-item label="产品编号">
          <el-input v-model="dataForm.code" placeholder="产品编号" clearable/>
        </el-form-item>
        <el-form-item>
          <el-button @click="queryPage()">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :data="dataList"
        border
        v-loading="dataListLoading"
        style="width: 100%;">
        <el-table-column
          label="序号"
          type="index"
          width="50"
          align="center">
        </el-table-column>
        <el-table-column
          prop="productName"
          header-align="center"
          align="center"
          width="160"
          :show-overflow-tooltip="true"
          label="产品名称">
        </el-table-column>
        <el-table-column
          prop="prodCode"
          header-align="center"
          align="center"
          width="160"
          :show-overflow-tooltip="true"
          label="产品编号">
        </el-table-column>
        <el-table-column
          prop="techName"
          header-align="center"
          align="center"
          width="160"
          :show-overflow-tooltip="true"
          label="工艺名称">
        </el-table-column>
        <el-table-column
          prop="nodeName"
          header-align="center"
          align="center"
          width="160"
          :show-overflow-tooltip="true"
          label="工序名称">
        </el-table-column>
        <el-table-column
          prop="transferUserName"
          header-align="center"
          align="center"
          width="120"
          :show-overflow-tooltip="true"
          label="移交接收人">
        </el-table-column>
        <el-table-column
          prop="creatorName"
          header-align="center"
          align="center"
          min-width="120"
          :show-overflow-tooltip="true"
          label="移交发起人">
        </el-table-column>
        <el-table-column
          prop="transferExplain"
          header-align="center"
          align="center"
          min-width="160"
          :show-overflow-tooltip="true"
          label="移交说明">
        </el-table-column>
        <el-table-column
          prop="createTime"
          header-align="center"
          align="center"
          min-width="160"
          label="移交时间">
        </el-table-column>
        <el-table-column
          v-if="isAuth('prod:transfer:info')"
          fixed="right"
          header-align="center"
          align="center"
          width="140"
          label="操作">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="detailHandle(scope.row.recordId)">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        @size-change="sizeChangeHandle"
        @current-change="currentChangeHandle"
        :current-page="pageIndex"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        :total="totalPage"
        layout="total, sizes, prev, pager, next, jumper">
      </el-pagination>
      <detail v-if="detailVisible" ref="detail"/>
    </div>
</template>

<script>
  import {getTransferList} from '@/api/task'
  import Detail from './handover-records-details'
  export default {
    name: 'handover-records',
    components: {Detail},
    data () {
      return {
        detailVisible: false,
        dataForm: {},
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: []
      }
    },
    created () {
      this.getDataList()
    },
    methods: {
      // 查询
      queryPage () {
        this.pageIndex = 1
        this.getDataList()
      },
      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        this.addOrUpdateVisible = false
        // 接口调用
        let params = {
          'current': this.pageIndex,
          'size': this.pageSize,
          'productName': this.dataForm.name ? this.dataForm.name : null,
          'prodCode': this.dataForm.code ? this.dataForm.code : null
        }
        getTransferList(params).then(({data}) => {
          if (data && data.code === '200') {
            this.dataList = data.data.records
            this.totalPage = Number(data.data.total)
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },
      // 多选
      selectionChangeHandle (val) {
        this.dataListSelections = val
      },
      // 详情
      detailHandle (id) {
        this.detailVisible = true
        this.$nextTick(() => {
          this.$refs.detail.init(id)
        })
      }
    }
  }
</script>

<style scoped>

</style>
