<template>
|
<div class="task-check-card-wrapper">
|
<TaskCheckPersonalView
|
class="task-check-card-view"
|
:avatar="avatar"
|
:name="name"
|
:gender="gender"
|
:isReal="isReal"
|
:contactPhoneNumber="contactPhoneNumber"
|
>
|
<template #actions v-if="checkReceiveStatus === EnumTaskCheckReceiveStatus.WaitCheckReceive">
|
<template v-if="OrderUtils.isContainCheckIn(checkReceiveMethods)">
|
<nut-button
|
v-if="
|
!checkHistoryType || checkHistoryType === EnumTaskUserSubmitCheckHistoryType.CheckIn
|
"
|
type="primary"
|
class="task-check-card-phone-btn"
|
@click.stop="handleMore"
|
>操作</nut-button
|
>
|
<nut-button
|
v-else
|
type="primary"
|
class="task-check-card-phone-btn"
|
@click.stop="emit('checkReceive')"
|
>验收</nut-button
|
>
|
</template>
|
<nut-button
|
v-else
|
type="primary"
|
class="task-check-card-phone-btn"
|
@click.stop="emit('checkReceive')"
|
>验收</nut-button
|
>
|
</template>
|
</TaskCheckPersonalView>
|
</div>
|
</template>
|
|
<script setup lang="ts">
|
import {
|
Colors,
|
EnumUserGender,
|
EnumTaskCheckReceiveStatus,
|
EnumTaskCheckReceiveStatusText,
|
EnumTaskCheckReceiveMethod,
|
EnumGetCheckReceiveTasksQueryResultItemCheckStatus,
|
EnumTaskUserSubmitCheckReceiveStatus,
|
EnumTaskUserSubmitCheckHistoryType,
|
} from '@12333/constants';
|
import { TaskCheckPersonalView } from '@12333/components';
|
import { CheckInOrOutEventEnum } from '../constants';
|
import { Portal } from 'senin-mini/components';
|
import { ActionSheet } from '@nutui/nutui-taro';
|
import { OrderUtils } from '@12333/utils';
|
|
defineOptions({
|
name: 'TaskCheckCard',
|
});
|
|
enum ManageActions {
|
CheckIn = 1,
|
CheckOut,
|
OutWork,
|
}
|
|
type Props = {
|
avatar?: string;
|
name?: string;
|
gender?: EnumUserGender;
|
isReal?: boolean;
|
contactPhoneNumber?: string;
|
checkReceiveStatus?: EnumTaskCheckReceiveStatus;
|
/** 签到时间 */
|
checkInTime?: string;
|
/** 签出时间 */
|
checkOutTime?: string;
|
checkReceiveMethods?: EnumTaskCheckReceiveMethod[];
|
|
submitCheckReceiveStatus?: EnumTaskUserSubmitCheckReceiveStatus;
|
|
checkHistoryType?: EnumTaskUserSubmitCheckHistoryType;
|
};
|
|
const props = withDefaults(defineProps<Props>(), {});
|
|
const emit = defineEmits<{
|
(e: 'checkReceive'): void;
|
(e: 'checkInOrOut', ev: EnumTaskUserSubmitCheckHistoryType): void;
|
}>();
|
|
const menuList = computed(() => {
|
let _menuList = [];
|
if (OrderUtils.isContainCheckIn(props.checkReceiveMethods)) {
|
if (!props.checkInTime) {
|
_menuList.push({
|
name: '签到',
|
value: ManageActions.CheckIn,
|
});
|
} else if (!props.checkOutTime) {
|
_menuList.push({
|
name: '签出',
|
value: ManageActions.CheckOut,
|
});
|
}
|
_menuList.push({
|
name: '未到岗',
|
value: ManageActions.OutWork,
|
});
|
}
|
|
return _menuList;
|
});
|
|
function handleMore() {
|
Portal.add((key) => {
|
return h(
|
Portal.Container,
|
{ keyNumber: key, delayOpen: true },
|
{
|
default: ({ open, onClose }) =>
|
// @ts-ignore
|
h(ActionSheet, {
|
visible: open.value,
|
'onUpdate:visible': () => onClose(),
|
menuItems: menuList.value,
|
onChoose: (item) => {
|
handleEmit(item);
|
onClose();
|
},
|
}),
|
}
|
);
|
});
|
}
|
|
function handleEmit(action: { name: string; value: number }) {
|
switch (action.value) {
|
case ManageActions.CheckIn:
|
emit('checkInOrOut', EnumTaskUserSubmitCheckHistoryType.CheckIn);
|
break;
|
case ManageActions.CheckOut:
|
emit('checkInOrOut', EnumTaskUserSubmitCheckHistoryType.CheckOut);
|
break;
|
case ManageActions.OutWork:
|
emit('checkInOrOut', EnumTaskUserSubmitCheckHistoryType.UnCheckIn);
|
break;
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
@import '@/styles/common.scss';
|
|
.task-check-card-wrapper {
|
background: #ffffff;
|
border-radius: 12px;
|
padding: 40px;
|
padding-right: 26px;
|
margin-bottom: 24px;
|
|
&:last-child {
|
margin-bottom: 0;
|
}
|
|
.task-check-card-view {
|
.task-check-card-phone-container {
|
margin-top: 0;
|
}
|
}
|
|
.task-check-card-phone-status {
|
font-size: 24px;
|
height: 52px;
|
line-height: 52px;
|
}
|
}
|
</style>
|