<template>
  <div>
    <el-button class="inline-16" type="text" size="small" @click="detailBtn">明 细</el-button>
    <el-dialog title="产品组商品明细" append-to-body :visible.sync="dialogTableVisible" width="70%">
      <add-btn ref="add" v-if="tool.checkAuth($route.name,'insert')" @onSuccess="getDetail" style="margin-bottom:16px" :id="rowData.sa_itemgroupid" />
      <tableLayout v-if="dialogTableVisible" :layout="tablecols" :data="list" :opwidth="200" :custom="true" height="40vh" fixedName="operation">
        <template v-slot:customcol="scope">
            <span v-if="scope.column.data[scope.column.columnname]">{{scope.column.data[scope.column.columnname]}}</span>
            <span v-else-if="scope.column.columnname != 'operation'">--</span>
        </template>
        <template v-slot:opreation="scope">
          <div style="display:flex;justify-content:space-around">
            <Del type="detail" v-if="tool.checkAuth($route.name,'delete')" :id="rowData.sa_itemgroupid" @deleteSuccess="getDetail" :detailId="scope.data.sa_itemgroupmxid"/>
            <!-- <editBtn v-if="tool.checkAuth($route.name,'update')" :id="rowData.sa_itemgroupid" @onSuccess="getDetail" :rowData="scope.data"/> -->
          </div>
        </template>
      </tableLayout>
    </el-dialog>
  </div>
</template>

<script>
import AddBtn from './addGroupDetailBtn'
import editBtn from './editGroupDetailBtn'
import { log } from '@antv/g2plot/lib/utils'
import Del from './delete'

export default {
  data () {
    return {
      dialogTableVisible:false,
      list:[],
      form: {
        product:[]
      },
      tablecols:[],
      rules: {
        product: [
          { required: true, message: '请选择商品', trigger: 'blur' },
        ],
      }
    }
  },
  props:['rowData'],
  components:{AddBtn,Del,editBtn},

  watch: {
  },
  created() {
    this.tablecols = this.tool.tabelCol(this.$route.name).groupDetailTable.tablecols
  },
  methods: {
    async getDetail() {
      let res = await this.$api.requested({
        "id": "20220923101603",
        "version":1,
        "content": {
          "sa_itemgroupid":this.rowData.sa_itemgroupid

        }
      })
      this.list = res.data
    },
    detailBtn() {
      this.getDetail()
      this.dialogTableVisible = true
    },
    handleClose(tag) {
      this.form.tag.splice(this.form.tag.indexOf(tag), 1);
    },
  }
}

</script>
<style scoped>
/deep/.el-dialog__body {
  padding-top: 10px !important;
}
/deep/.dialog-footer {
  margin-top: 10px !important;
}
/deep/.el-form-item__content {
  width: calc(100% - 100px) !important;
}
/deep/.el-select {
  width: 100% !important;
}
/deep/.el-form-item {
  width: 100% !important;
}
/deep/.el-input{
  width: 100% !important;
}
</style>