<template>
  <view v-if="list.length > 0">
    <view v-for="(item, index) in list" :key="index" class="list-item defaultBgc default-border">
      <view class="sub-li-bottom" @click.stop="jumpToEnterpriseDetail(item.enterprise?.id)">
        <view class="avatarBox">
          <image class="enterAvatar" :src="item.enterprise?.logoUrl || 'https://minio.citupro.com/dev/menduner/company-avatar.png'"></image>
        </view>
        <view>
          <span class="ss-m-x-20 color-66 MiSans-Medium" style="font-weight: bold;">{{ item.contact?.name || ' -- ' }}</span>
          <span class="MiSans-Normal ss-m-r-10">{{ item.contact?.postNameCn }}</span>
          <span class="ss-m-r-10 MiSans-Normal">{{ item.invitePhone }}</span>
        </view>
      </view>
      <!-- 职位信息 -->
      <view class="list-shape ss-m-t-30">
        <view class="titleBox" @click="toDetail(item)">
          <span class="MiSans-Semibold" style="font-size: 16px;font-weight: 700; color: #0E100F;">{{ formatName(item.job?.name) }}</span>
          <span v-if="!item.job?.payFrom && !item.job?.payTo" class="salary-text MiSans-Semibold">面议</span>
          <span v-else class="salary-text MiSans-Semibold">{{ item.job?.payFrom }}-{{ item.job?.payTo }}{{ item.job?.payName ? '/' + item.job?.payName : '' }}</span>
        </view>
        <!-- 面试时间、地点 -->
        <view class="color-666 font-size-14 ss-m-t-20" @click="toDetail(item)">
          <view class="MiSans-Normal">面试时间：{{ timesTampChange(item.time, 'Y-M-D h:m') }}</view>
          <view class="ss-m-t-20 MiSans-Normal">面试地点：{{ item.address }}</view>
        </view>

        <view v-if="item.status === '0'">
					<view class="ss-m-y-30" style="border-top: 1rpx solid #E1E4E9;"></view>
					<view class="d-flex justify-end">
						<span class="MiSans-Normal" style="color: #dd524d;text-decoration: underline;" @click="handleAction(item, 'refuse')">拒绝</span>
						<span class="MiSans-Normal" style="color: #00B760;margin-left: 65rpx;text-decoration: underline;" @click="handleAction(item, 'agree')">同意</span>
					</view>
				</view>
      </view>
    </view>
  </view>

</template>

<script setup>
import { timesTampChange } from '@/utils/date'
import { formatName } from '@/utils/getText'
import { jumpToEnterpriseDetail } from '@/utils/position'

const emits = defineEmits(['action'])
const props = defineProps({
  list: { type: Array, default: () => [] }
})

//岗位详情
const toDetail = (item) =>{
  uni.navigateTo({ url: `/pagesB/positionDetail/index?id=${item.job?.id}&area=${item.job.area?.str ?? '全国'}` })
}

const handleAction = (item, type) => {
  emits('action', item, type)
}

</script>

<style scoped lang="scss">
.list-item {
  margin: 30rpx;
  border-radius: 20rpx;
  padding: 30rpx;
  box-shadow: 1px 2px 12px rgba(0, 0, 0, 0.17);
  &:last-child {
    margin-bottom: 0;
  }
}

.enterAvatar{
	width: 40px;
	height: 40px;
	border-radius: 50%;
	margin: auto;
}

.sub-li-bottom {
  display: flex;
  align-items: center;
  font-size: 13px;
  .avatarBox {
    max-width: 40px;
    max-height: 40px;
  }
}

.salary-text {
	float: right;
	color: #00B760;
  font-weight: 700;
}
.list-shape {
  .titleBox {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}
</style>
