<template>
  <div class="mod-config pad" style="margin-top: 10px">

    <el-form inline="true" style="margin-top: 0px;" label-position="top">
      <el-form-item :label="'工厂编号'" style="margin-left: 20px">
        <el-select filterable v-model="searchData.site" style="width: 160px">
          <el-option label="1-沪声" value="1"></el-option>
          <el-option label="2-赫艾" value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'产品编码/名称/规格型号：'"  style="margin-left: 20px">
        <el-input v-model="searchData.searchIn" style="width: 220px"></el-input>
      </el-form-item>
      <el-form-item :label="' '">
        <el-button @click="search()" style="margin-left: 24px;height: 35px;width: 80px" type="primary">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :height="height"
      :data="tableData"
      border
      style="margin-top: 10px;width: 100%">
      <el-table-column
        prop="site"
        header-align="center"
        align="left"
        min-width="30"
        label="工厂编号">
      </el-table-column>
      <el-table-column
        prop="partNo"
        header-align="center"
        align="left"
        min-width="60"
        label="产品编码">
      </el-table-column>
      <el-table-column
        prop="partDescription"
        header-align="center"
        align="left"
        min-width="60"
        label="产品名称">
      </el-table-column>
      <el-table-column
        prop="spec"
        header-align="center"
        align="left"
        min-width="60"
        label="规格型号">
      </el-table-column>
      <el-table-column
        prop=""
        fixed="right"
        header-align="center"
        align="center"
        min-width="30"
        label="操作">
        <template slot-scope="scope">
          <a type="text" size="small" @click="jumpPadPartAttribute(scope.row)">属性</a> &nbsp&nbsp|&nbsp&nbsp
          <a type="text" size="small" @click="jumpPadPartPhoto(scope.row)">SOP</a>
        </template>
      </el-table-column>
    </el-table>
  </div>

</template>

<script>
  import {
    getPartData
  } from '@/api/pad.js'
  export default {
    name: 'padPart1',
    data () {
      return {
        height:200,
        tableData:[],
        searchData:{
          site:'1',
          searchIn:'',
        },

      }

    },
    mounted () {
      this.$nextTick(() => {
        this.height = window.innerHeight - 150
      })
    },
    methods: {
      jumpPadPartAttribute(row){
        localStorage.removeItem("search")
        localStorage.removeItem("flag")
        localStorage.setItem("partData",JSON.stringify(row))
        localStorage.setItem("search",JSON.stringify(this.searchData))
        localStorage.setItem("tableData",JSON.stringify(this.tableData))
        this.$router.push('/padPartAttribute');
      },
      jumpPadPartPhoto(row){
        localStorage.removeItem("search")
        localStorage.removeItem("flag")
        localStorage.setItem("pictureData",JSON.stringify(row))
        localStorage.setItem("search",JSON.stringify(this.searchData))
        localStorage.setItem("tableData",JSON.stringify(this.tableData))
        this.$router.push('/padPartPhoto');
      },
      search(){
        getPartData(this.searchData).then(({data}) => {
          this.tableData = data.rows
        })
      },
      getData(){
        let data1= JSON.parse(localStorage.getItem("search"))
        this.searchData.site=data1.site;
        this.searchData.searchIn=data1.searchIn;
        this.tableData= JSON.parse(localStorage.getItem("tableData"))

      }
    },
    created () {
      localStorage.removeItem("partData")
      localStorage.removeItem("pictureData")
      this.getData();
    }
  }
</script>

<style scoped>
  .el-select-dropdown__item{
    font-size: 18px;
  }
</style>
