liuxiaolong
2019-05-06 770c069996e1d2979c1170c1639c18b02d07e72f
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
<template>
  <div
    class="flex-row-between calendarIteam"
    :class="isDisabled?'paIteam':''"
    @click="$emit('checkDayFn')"
  >
    <div class="pt-2 pl-2 record-info" v-if="!isDisabled" @click="$emit('recordFn')">
      <!-- @click="repairFn('attendance:repair')" -->
      <p class="mb-2 tl">
        首次:{{data&&data.inTime?data.inTime.slice(11,19):''}}
        <br>
        位置:{{data&&data.inDeviceName?data.inDeviceName:''}}
      </p>
      <p class="mb-1 tl">
        末次:{{data&&data.outTime?data.outTime.slice(11,19):''}}
        <br>
        位置:{{data&&data.outDeviceName?data.outDeviceName:''}}
      </p>
    </div>
    <div class="pl-1 pr-1">
      <div v-if="!isDisabled" class="mb-1 pt-1">
        <!-- <b-button @click="leaveFn('attendance:leave')" size="sm" :variant="data && data.isLeave === 1?'warning':'bg-light'" class="leave-btn">假</b-button> -->
        <b-button
          @click="$emit('recordFn')"
          size="sm"
          variant="link"
          class="record-btn text-info"
          block
        >
          <i class="ion d-block ion-ios-pin f25"></i>
        </b-button>
      </div>
      <div class="dayNum" :class="dayCalsss">
        <slot></slot>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'calendarIteam',
  props: {
    isDisabled: {
      type: Boolean,
      default: false
    },
    className: {
      default: '',
      type: String
    },
    data: {
      type: Object,
      default: null
    }
  },
  data() {
    return {
      buttonAuthority: sessionStorage.getItem('buttonAuthoritys') || []
    }
  },
  computed: {
    dayCalsss() {
      if (!this.data) {
        return ''
      }
      if (this.data.isNotSign === 0) {
        // 已经签到
        if (this.data.isRepair === 1) {
          // return 'repairSign'
          return 'sign'
        }
        return 'sign'
      } else {
        // 未签
        return 'notSign'
      }
    },
    isAdmin() {
      if (
        sessionStorage.getItem('userInfo') &&
        sessionStorage.getItem('userInfo') !== ''
      ) {
        let loginName = JSON.parse(sessionStorage.getItem('userInfo')).username
        return loginName === 'admin' || loginName === 'basic'
      }
      return false
    }
  },
  methods: {
    isAuthority(str) {
      if (this.isAdmin) {
        return true
      } else if (this.buttonAuthority.indexOf(',' + str + ',') > -1) {
        return true
      } else {
        return false
      }
    },
    leaveFn() {
      if (this.isAuthority()) {
        this.$emit('leaveFn')
      } else {
        this.$toast({ message: '抱歉!您没有此权限', type: 'warning' })
      }
    },
    repairFn() {
      if (this.isAuthority()) {
        this.$emit('repairFn')
      } else {
        this.$toast({ message: '抱歉!您没有此权限', type: 'warning' })
      }
    }
  }
}
</script>
<style lang="scss" scoped>
$yellow: #ffa509;
// $green: #075a00;
 
.paIteam {
  position: absolute;
  right: 8px;
  bottom: 8px;
}
.leave-btn {
  padding: 0px 4px;
  color: #fff;
  font-size: 16px;
}
.record-info {
  font-size: 12px;
  span {
    font-size: 13px;
  }
}
.dayNum {
  // border-radius: 25px;
  margin: 0 5px;
}
.sign {
  background: #26b4ff;
  span,
  span.weekday {
    color: #fff !important;
  }
}
.notSign {
  background: $yellow;
  span,
  span.weekday {
    color: #fff !important;
  }
}
.repairSign {
  // background: #d9534f;
  // background: $green;
  span,
  span.weekday {
    color: #fff !important;
  }
}
</style>