<template>
  <div class="tab-content">
    <div class="info-section">
      <div class="section-title-row">
        <div class="section-title-left">
          <span class="section-title-text">业务联系人</span>
        </div>
        <el-button v-if="!isViewMode" type="primary" icon="Plus" @click="emit('add')">新增联系人</el-button>
      </div>

      <el-table v-loading="contactLoading" :data="contactList" border style="width: 100%">
        
        <el-table-column prop="userNo" label="用户ID" align="center" />
        
        <el-table-column prop="userName" label="员工姓名" align="center" />
        <el-table-column prop="phone" label="手机号" align="center" />
        <el-table-column prop="roleNo" label="角色" align="center" />
        <el-table-column prop="departmentNo" label="部门" align="center" />
        <el-table-column prop="position" label="职位" align="center" />
        <el-table-column prop="isPrimaryContact" label="主要联系人" align="center">
          <template #default="scope">
            <span>{{ scope.row.isPrimaryContact === '1' ? '是' : '否' }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="isRegister" label="允许登录供应商端" align="center">
          <template #default="scope">
            <span>{{ scope.row.isRegister === '1' ? '是' : '否' }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center">
          <template #default="scope">
            <el-button v-if="!isViewMode" link type="primary" @click="emit('edit', scope.row)">编辑</el-button>
            <el-button v-if="!isViewMode" link type="primary" @click="emit('resetPassword', scope.row)">重置密码</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script setup lang="ts">
defineProps<{
  contactSearchParams: { userNo: string; userName: string };
  contactList: any[];
  contactLoading: boolean;
  isViewMode: boolean;
}>();

const emit = defineEmits<{
  (e: 'search'): void;
  (e: 'reset'): void;
  (e: 'add'): void;
  (e: 'edit', row: any): void;
  (e: 'resetPassword', row: any): void;
}>();
</script>
