
<!--
  @description: 查看供应商列表
  @author: gmy
  @date: 2020-8-4 20:29:58
-->
<template>
  <div>
    <el-table
      :data="supplierList"
      row-key="id"
      default-expand-all
      :tree-props="{children: 'lists', hasChildren:'hasChildren'}"
    >
      <el-table-column type="index" label="序号" width="60" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.index }}</span>
        </template>
      </el-table-column>
      <el-table-column
        header-align="center"
        align="left"
        label="供应商"
        prop="supplierName"
      />
      <el-table-column
        header-align="center"
        align="center"
        label="统一社会信用代码"
        prop="businesslicence"
      />
      <el-table-column
        header-align="center"
        align="center"
        label="联系人"
        prop="linkerName"
      />
      <el-table-column
        header-align="center"
        align="center"
        label="联系方式"
        prop="linkerTel"
      />
      <el-table-column
        v-if="dataRule.ifCombo==='01'"
        prop="supplierIfComboType"
        align="center"
        label="类型"
      >
        <template slot-scope="scope">
          <span v-if="scope.row.supplierIfComboType==='00'">牵头人</span>
          <span v-if="scope.row.supplierIfComboType==='01'">联合体成员</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
/* 公用参数 */
export default {
  name: 'ProjectSupplierListListVue',
  props: {
    // 获取供应商列表
    supplierList: {
      type: Array,
      default: () => {
        return []
      }
    },
    dataRule: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data() {
    return {
    }
  },
  watch: {
    'supplierList'(val) {
      // 判断树形数据不为空，执行方法
      if (val.length > 0) this.setTableIndex(val)
    }
  },
  methods: {
    // 树形列表index层级，实现方法（可复制直接调用）
    setTableIndex(arr, index) {
      arr.forEach((item, key) => {
        item.index = key + 1
        if (index) {
          item.index = index + '.' + (key + 1)
        }
        if (item.lists) {
          this.setTableIndex(item.lists, item.index)
        }
      })
    }
  }
}
</script>

<style scoped lang="less">

</style>
