<template>
  <view>
    <CuNavbar title="升职申请">
      <template #right>
        <view class="text-sm text-white" @click="checkLogs">审核流程</view>
      </template>
    </CuNavbar>
    <uv-sticky bgColor="white">
      <view class="px-base box-shadow text-28rpx">
        <view class="px-base">
          <BaseData :data="data" :colums="titleColumns" />
        </view>
      </view>
    </uv-sticky>
    <view class="p-base">
      <view class="card-shadow px-base">
        <BaseData :data="data.employee_data" :colums="columns" />
      </view>
    </view>
  </view>
</template>
<script setup>
import CuNavbar from '@/components/cu-navbar/index'
import BaseData from '../audits/base-data.vue'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'
import { http } from '@/utils/request'

const data = ref({})

const titleColumns = [
  { title: '晋升职位', dataIndex: 'job.name' },
  { title: '申请人', dataIndex: 'employee.name' },
  { title: '推荐人', dataIndex: 'invitor.name' },
  { title: '状态', dataIndex: 'promotion_status', format: (value) => statusFun(value, 'promotion_status', 'name') },
]

const columns = [
  { title: '年龄', dataIndex: 'age' },
  { title: '性别', dataIndex: 'sex' },
  { title: '学历', dataIndex: 'education' },
  { title: '首次参加工作时间', dataIndex: 'first_work_time' },
  { title: '工作年限', dataIndex: 'work_years' },
  { title: '本公司工作年限', dataIndex: 'work_years_in_company' },
  { title: '员工自评', dataIndex: 'comment_self', labelPosition: 'top' },
  { title: '未来计划', dataIndex: 'plans', labelPosition: 'top' },
  { title: '推荐理由', dataIndex: 'reason', labelPosition: 'top' },
]

onLoad((options) => {
  http.get(`/hr/promotion/${options.id}`).then(res => {
    data.value = res
  })
})

const checkLogs = () => {
  if (data.value.workflow_check.id) {
    return uni.navigateTo({
      url: `/pages/audits/log?id=${data.value.workflow_check.id}`
    })
  }
}


</script>
