zhengyiming
2 天以前 36f2c20ea3df022390b677e782d8a4cd25f21f69
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<template>
  <div class="task-check-card-wrapper" @click.stop="emit('checkReceive')">
    <TaskCheckPersonalView
      class="task-check-card-view"
      :avatar="avatar"
      :name="name"
      :gender="gender"
      :isReal="isReal"
      :contactPhoneNumber="contactPhoneNumber"
    >
      <template #actions>
        <template v-if="checkReceiveMethod === EnumTaskCheckReceiveMethod.CheckIn">
          <!-- <nut-button
            v-if="!checkInTime"
            type="primary"
            class="task-check-card-phone-btn"
            @click.stop="emit('checkInOrOut', CheckInOrOutEventEnum.CheckIn)"
            >签到</nut-button
          >
          <nut-button
            v-else-if="!checkOutTime"
            type="primary"
            class="task-check-card-phone-btn"
            @click.stop="emit('checkInOrOut', CheckInOrOutEventEnum.CheckOut)"
            >签出</nut-button
          >
          <div v-else class="task-check-card-phone-status" :style="{ color: Colors.Success }">
            {{ EnumTaskCheckReceiveStatusText[checkReceiveStatus] }}
          </div> -->
          <nut-button type="primary" class="task-check-card-phone-btn" @click.stop="handleMore"
            >操作</nut-button
          >
        </template>
        <template v-else>
          <nut-button
            v-if="checkReceiveStatus === EnumTaskCheckReceiveStatus.WaitCheckReceive"
            type="primary"
            class="task-check-card-phone-btn"
            >验收</nut-button
          >
          <div v-else class="task-check-card-phone-status" :style="{ color: Colors.Success }">
            {{ EnumTaskCheckReceiveStatusText[checkReceiveStatus] }}
          </div>
        </template>
      </template>
    </TaskCheckPersonalView>
  </div>
</template>
 
<script setup lang="ts">
import TaskCheckPersonalView from './TaskCheckPersonalView.vue';
import {
  Colors,
  EnumUserGender,
  EnumTaskCheckReceiveStatus,
  EnumTaskCheckReceiveStatusText,
  EnumTaskCheckReceiveMethod,
} from '@12333/constants';
import { CheckInOrOutEventEnum } from '../constants';
import { Portal } from 'senin-mini/components';
import { ActionSheet } from '@nutui/nutui-taro';
 
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;
  checkReceiveMethod?: EnumTaskCheckReceiveMethod;
};
 
const props = withDefaults(defineProps<Props>(), {});
 
const emit = defineEmits<{
  (e: 'checkReceive'): void;
  (e: 'checkInOrOut', ev: CheckInOrOutEventEnum): void;
}>();
 
const menuList = computed(() => {
  let _menuList = [];
  if (props.checkReceiveMethod === EnumTaskCheckReceiveMethod.CheckIn) {
    _menuList.push(
      {
        name: '签到',
        value: ManageActions.CheckIn,
      },
      {
        name: '签出',
        value: ManageActions.CheckOut,
      },
      {
        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', CheckInOrOutEventEnum.CheckIn);
      break;
    case ManageActions.CheckOut:
      emit('checkInOrOut', CheckInOrOutEventEnum.CheckOut);
      break;
    case ManageActions.OutWork:
      emit('checkInOrOut', CheckInOrOutEventEnum.CheckOut);
      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>