<script setup lang="ts" name="EmployeesDisciplinaryDetailFlow">
/* 员工奖惩详情 */
import { ref, reactive, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
// import { showImagePreview } from 'vant'
import { getFlowChart } from '@/api/flowEngine/flowInterface'
import { getEmployeesDisciplinary } from '@/api/personnel/employeesDisciplinary'
import { useDict } from '@/common/utils/dict'
import { selectDictLabel } from '@/common/utils/ruoyi'
import FlowTimeline from '@/components/Flow/FlowTimeline.vue'
import ListItemDisciplinary from './ListItemDisciplinary.vue'
import DetailDisciplinary from './DetailDisciplinary.vue'
import UploadImage from '@/components/Upload/UploadImage.vue'
// import { getDeptName } from '@/common/utils/transcoding'
import { parseTime } from '@/common/utils/ruoyi'

const {
  disciplinary_type
}
= useDict(
  'disciplinary_type'
)

const router = useRouter()
const props = defineProps<{
  id: string
  instanceId: string
}>()

const active = ref('1')
const detail = ref<any>({})
const employeesDetail = ref<any>({})
const nodeData = ref<any>()
const activeTab = ref('0')

getEmployeesDisciplinary(props.id).then(res => {
  detail.value = res.data
})
getFlowChart({ instanceId: props.instanceId }).then(res => {
  nodeData.value = res.data
})

// 点击员工列表，查看详情
function onDetailEmployees(item) {
  employeesDetail.value = item
  active.value = '2'
}

function onBack() {
  active.value = '1'
}
</script>

<template>
  <div class="container__body">
    <div v-show="active === '1'" class="container__card flex">
      <van-tabs v-model="activeTab">
        <van-tab name="0" title="详情">
          <van-cell title="申请人工号" :value="detail.applyEmployeeNumber" />
          <van-cell title="申请人姓名" :value="detail.applyName" />
          <van-cell title="申请人部门" :value="detail.applyDepartment" />
          <van-cell title="申请人岗位" :value="detail.applyPosition" />
          <van-cell title="奖惩日期" :value="detail.effectiveDate" />
          <van-cell title="事实说明" :value="detail.memo" />
          <FlowTimeline :node-data="nodeData" />
        </van-tab>
        <van-tab name="1" title="奖惩明细">
          <ListItemDisciplinary
            :list="detail.items"
            :disciplinary_type="disciplinary_type"
            @on-detail="onDetailEmployees" />
        </van-tab>
      </van-tabs>
    </div>
    <DetailDisciplinary
      v-show="active === '2'"
      :disciplinary_type="disciplinary_type"
      :detail="employeesDetail"
      @back="onBack" />
  </div>
</template>

<style lang="less" scoped>
.grid {
  :deep(.van-image) {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 100%;
    border-radius: 0.6rem;
    box-shadow: 0.2rem 0.2rem 0.5rem rgba(0,0,0,0.5);
    overflow: hidden;
    .van-image__img {
      position: absolute;
      object-fit: cover;
    }
  }
}

:deep(.van-cell:not(.van-collapse-item__title)) {
  .van-cell__title {
    margin-right: 1rem;
    flex: none;
  }
  .van-cell__value {
    display: flex;
    justify-content: flex-end;
    color: var(--van-cell-text-color);
    overflow: hidden;
    span {
      text-align: justify;
      white-space: pre-wrap;
      word-break: break-word;
    }
  }
}

:deep(.van-collapse-item__content) {
  padding: 0 1.2rem;
}

:deep(.tag-label) {
  font-size: 1.4rem;
}

.list {

}
</style>
