<template>
  <div>
    <el-table
      ref="multipleTable"
      :data="data"
      style="width: 100%"
      :header-cell-style="{height:'50px',color:'#606266',fontWeight:'400'}"
      :cell-style="{height:'50px',color:'#666666',fontWeight:'400'}">
      <!-- <el-table-column
          align="center"
          label="产品图"
          width="80">
        <template slot-scope="scope">
          <div v-if="scope.row.attinfos[0]">
            <previewImage style="height:38px;width:38px" :image="scope.row.attinfos[0]" :list="scope.row.attinfos" :deletebtn="false"></previewImage>
          </div>
        </template>
      </el-table-column> -->
      <el-table-column
          prop="itemno"
          label="产品编号"
          width="0">
      </el-table-column>
      <el-table-column
          prop="sequence"
          label="排序"
          width="100" v-if="type == 'add'">
        <template slot-scope="scope">
            <el-input type="text" size="mini" @input="onInput($event,scope.row)" v-model="scope.row.sequence"></el-input>
        </template>
      </el-table-column>
      <el-table-column
          prop="itemname"
          label="产品名称"
          width="0">
      </el-table-column>
      <el-table-column
          prop="erpitemname"
          label="品名"
          width="0">
      </el-table-column>
      <el-table-column
          prop="erpitemno"
          label="品号"
          width="0">
      </el-table-column>
      <el-table-column
          label="型号"
          width="0">
        <template slot-scope="scope">
          <p><span>{{scope.row.model}}</span></p>
        </template>
      </el-table-column>
      <el-table-column
          label="规格"
          width="0">
        <template slot-scope="scope">
          <p><span>{{scope.row.spec}}</span></p>
        </template>
      </el-table-column>
      <!-- <el-table-column
          prop="caliber"
          label="口径"
          width="180">
      </el-table-column>
      <el-table-column
          prop="pressure"
          label="压力"
          width="180">
      </el-table-column> -->
      <el-table-column
          prop="material"
          label="材质"
          width="0">
      </el-table-column>
      <!-- <el-table-column
          prop="brand"
          label="品牌"
          width="180">
        <template slot-scope="scope">
          <p v-for="(item,index) in scope.row.brand" :key="index">
            <span style="float: left" v-if="index === scope.row.brand.length -1">{{item?item.brandname+'':'--'}}</span>
            <span style="float: left" v-else>{{item?item.brandname+',':'--'}}</span>
          </p>
        </template>
      </el-table-column> -->
      <el-table-column
          prop="itemclass"
          label="类别"
          width="0">
        <template slot-scope="scope">
          <span v-for="(item,index) in scope.row.itemclass" :key="index">
            {{item?item.itemclassname+',':'--'}}
          </span>
        </template>
      </el-table-column>
      <!-- <el-table-column
          prop="unitid"
          label="计量单位"
          width="100">
        <template slot-scope="scope">
          <el-tag size="mini" type="info" effect="plain">{{scope.row.unitname}}/{{scope.row.axunitname}}</el-tag>
        </template>
      </el-table-column> -->
      <el-table-column
          prop="marketprice"
          label="牌价"
          width="0">
      </el-table-column>
      <el-table-column
          label="操作"
          width="90"
          fixed="right">
        <template slot-scope="scope">
          <el-popconfirm
            title="确定删除吗？"
            @confirm="deleteProduct(scope.row)">
            <el-button slot="reference" type="text" size="mini">删 除</el-button>
          </el-popconfirm>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import previewImage from '@/components/previewImage/index'
import { log } from '@antv/g2plot/lib/utils'

export default {
  components:{
    previewImage
  },
  props:['data','type'],
  data () {
    return {
    }
  },
  methods:{
    async submitProduct (id) {
      const res = await this.$api.requested({
        "id": "20220923110303",
        "content": {
          "sa_itemgroupid":id,
          "itemclassinfos":this.data.map(e=>{
            return {
              "sa_itemgroupmxid":0,
              "itemno":e.itemno,
              "itemid":e.itemid,
              "sequence":e.sequence
            }
          })
        }
      })
      res.code === 1?this.$emit('onSuccess'):this.tool.showMessage(res)
      
    },
    onInput ($event,data) {
      this.$forceUpdate()
    },
    deleteProduct (row) {
      this.$emit('deleteProduct',row)
    }
  },
}

</script>
<style scoped>

/deep/.el-table__header .DisableSelection > .cell {
  display: none !important;
}
</style>