<template>
  <div class="ele-body">
    <ele-pro-table
      ref="table"
      :columns="columns"
      :datasource="datasource"

      tool-class="ele-toolbar-form"
      :needPage="false"
      cache-key="eomContactPageTable"
    >
      <template v-slot:name="{ row }">
        <el-link type="primary" :underline="false" @click="openDetail(row)">
          {{ row.name }}</el-link
        >
      </template>
    </ele-pro-table>

    <ContactDetailDialog  ref="contactDetailDialogRef"></ContactDetailDialog>
  </div>
</template>

<script>
  import ContactDetailDialog from './contactDetailDialog.vue';
  import {
    contactApplyList,
  } from '@/api/bpm/components/saleManage/contact';
  export default {
    components: {
      ContactDetailDialog
    },
    props:{
      businessId:{
        default:""
      }
    },
    data() {
      return {
        datasource:[],
        columns: [
          {
            columnKey: 'index',
            label: '序号',
            type: 'index',
            width: 55,
            align: 'center',
            showOverflowTooltip: true,
            fixed: 'left'
          },
          {
            prop: 'code',
            label: '客户编码',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 140
          },
          {
            prop: 'name',
            label: '客户名称',
            align: 'center',
            slot: 'name',
            showOverflowTooltip: true,
            minWidth: 200
          },
          {
            prop: 'serialNo',
            label: '客户代号',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 140
          },
          {
            prop: 'phone',
            label: '客户电话',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 120
          },
          {
            prop: 'addressName',
            label: '单位地址',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 120,
            formatter: (_row, _column, cellValue) => {
              let addr =
                '' + _row.addressName
                  ? _row.addressName.replaceAll(',', '')
                  : '';
              addr += _row.address ? _row.address : '';
              return addr;
            }
          },
          {
            prop: 'linkName',
            label: '联系人',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 120
          },
          {
            prop: 'linkPhone',
            label: '联系人电话',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 120
          },

          {
            prop: 'parentName',
            label: '上级单位',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 120
          },
          {
            prop: 'status',
            label: '状态',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 100,
            formatter: (_row, _column, cellValue) => {
              return _row.status === 1 ? '启用' : '禁用';
            }
          },
          {
            prop: 'createUsername',
            label: '创建人',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 100
          },
          {
            prop: 'createTime',
            label: '创建时间',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 160,
            formatter: (_row, _column, cellValue) => {
              return this.$util.toDateString(cellValue);
            }
          }
        ]
      };
    },
    computed: {},
    created() {

      contactApplyList(this.businessId).then(res=>{
        console.log(res)
           this.datasource=res.data.contactList
      })
    },
    methods: {

      openDetail(row) {
        this.$refs.contactDetailDialogRef.open(row);
      }
    },

  };
</script>

<style lang="scss" scoped></style>
