deductionDialog.vue
7.25 KB
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<!-- 扣款明细 -->
<template>
<div class="deduction-dialog">
<d2-dialog
:is-visible="visible"
noCancel
:isShowFooter="false"
width="720px"
@closeDialog="handleConfirm"
@confirmDialog="handleConfirm"
>
<div slot="sub-title" class="title">扣款明细
<el-tooltip class="item" effect="light" popper-class="sub-title-tooltip" placement="right">
<template slot="content">
<img style="width: 800px;" :src="`https://img02.glsx.com.cn/weapp/resource/saas/dj/images/deduction_tips_img.png?v=${new Date().getTime()}`" />
</template>
<i class="el-icon-info"></i>
</el-tooltip>
</div>
<div class="content" v-if="show">
<div class="item" v-for="item in formData" :key="item.value">
<div class="label">{{ item.label }}:</div>
<div class="value">
<el-input :value="formatMoney(infoData[item.value], item)" disabled></el-input>
<div v-if="item.tipsKey && infoData[item.value]" class="value-tips">
月度总提成的<span style="color: #2A58AD;">{{infoData[item.tipsKey]}}%</span>延迟6个月发放
</div>
<div v-if="item.hasDetail" class="value-tips">
<template v-if="item.value === 'dailyDeductMoney'">
<div class="deduct-item" v-if="infoData.dailyDeductDetailData1.length">精品升级 本月扣
<span v-for="(subItem, subIndex) in infoData.dailyDeductDetailData1" :key="subIndex" class="tips-text">{{ subItem }}日
<span v-if="subIndex !== infoData.dailyDeductDetailData1.length - 1">、</span>
</span>
</div>
<div class="deduct-item" v-if="infoData.dailyDeductDetailData2.length">会员权益/升级 本月扣
<span v-for="(subItem, subIndex) in infoData.dailyDeductDetailData2" :key="subIndex" class="tips-text">{{ subItem }}日
<span v-if="subIndex !== infoData.dailyDeductDetailData2.length - 1">、</span>
</span>
</div>
</template>
<template v-else-if="item.value === 'padDeductMoney'">
<div>
本月录音数<span class="tips-text">{{ infoData.recordingCount || 0 }}</span>条 本月总触客数<span class="tips-text">{{ infoData.toShopFilmCount || 0 }}</span>人
</div>
</template>
<template v-else-if="item.value === 'performancePenalty' && !isEmpty(infoData.performanceSalarDeductionRatio)">
<div v-if="infoData.monthTotalPrice == 0">
若月底产值为0时,绩效工资扣减<span class="tips-text">{{ `${infoData.performanceSalarDeductionRatio}%` }}</span>
</div>
<div v-else>
若月底产值不为0时,绩效工资扣减<span class="tips-text">{{ `${infoData.performanceSalarDeductionRatio}%` }}</span>
</div>
</template>
</div>
</div>
</div>
</div>
</d2-dialog>
</div>
</template>
<script>
import { getStaffDeductDetailAPI } from '@api/resident'
import { isEmpty, filterStr } from '../util.js'
import BigNumber from 'bignumber.js'
export default {
name: 'BasicSalaryDialog',
data() {
return {
isEmpty,
dialogConfig: {
title: '',
width: '720px'
},
formData: [
{
label: '日报扣款',
value: 'dailyDeductMoney',
hasDetail: true
},
{
label: '平板扣款',
value: 'padDeductMoney',
hasDetail: true
},
{
label: '递延金扣款',
value: 'deferExpenses',
tipsKey: 'deferredRatio'
},
{
label: '递延金纳入',
value: 'deferIncome',
tipsKey: 'deferredRatio2'
},
{
label: '退单冲减',
value: 'refundOffset'
},
{
label: '绩效工资扣减',
value: 'performancePenalty',
hasDetail: true
},
{
label: '其它应发/应扣',
value: 'otherDeduction'
}
],
infoData: {},
show: false
}
},
props: {
deductionVisible: {
type: Boolean,
default: false
},
detailRow: {
type: Object,
default: () => {}
},
detailInfo: {
type: Object,
default: () => {}
}
},
computed: {
visible: {
get() {
return this.deductionVisible
},
set(newVal) {
this.$emit('dialogClose', { flag: newVal, attrName: 'deductionVisible' })
}
}
},
mounted() {
this.getDeductDetail()
},
methods: {
formatMoney(value, item) {
const num = Number(value);
return isNaN(num) ? '0元' : `${num}元`;
},
handleConfirm() {
this.$emit('dialogClose')
},
getDeductDetail() {
getStaffDeductDetailAPI({ id: this.detailRow?.id }).then(res => {
const performanceSalary = new BigNumber(res.performanceSalary || 0) // 绩效工资
const actualPerformanceSalary = new BigNumber(res.actualPerformanceSalary || 0) // 实际绩效工资
this.infoData = {
...res,
refundOffset: !this.isEmpty(res?.refundOffset) ? `-${Math.abs(res?.refundOffset)}` : 0,
dailyDeductDetailData1: res?.dailyDeductDetailData1?.length ? this.getSortedDays(res?.dailyDeductDetailData1) : [],
dailyDeductDetailData2: res?.dailyDeductDetailData2?.length ? this.getSortedDays(res?.dailyDeductDetailData2) : [],
performancePenalty: !this.isEmpty(performanceSalary.minus(actualPerformanceSalary).toNumber()) ? `-${Math.abs(performanceSalary.minus(actualPerformanceSalary).toNumber())}` : 0
}
this.show = true
})
},
getSortedDays(dateArray, ascending = true) {
// 1. 按日期排序
const sortedDates = dateArray.sort((a, b) => {
return ascending ? new Date(a) - new Date(b) : new Date(b) - new Date(a)
})
return sortedDates.map(date => {
const day = date.split("-")[2]
return parseInt(day, 10).toString()
})
}
}
}
</script>
<style lang="scss" scoped>
.deduction-dialog {
::v-deep .el-dialog__header {
border-bottom: 1px solid #e6e6e6;
}
::v-deep .el-dialog__headerbtn .el-dialog__close {
color: #666;
font-weight: 600;
font-size: 20px;
}
::v-deep .dialog-sub-title {
color: #333333;
font-family: PingFangSC-Medium;
font-size: 20px;
font-weight: 600;
}
.content{
padding: 0 30px;
max-height: calc(68vh - 70px);
overflow-y: auto;
.item {
display: flex;
// align-items: center;
margin-bottom: 20px;
.label {
width: 110px;
text-align: right;
margin-top: 8px;
color: #333333;
}
.value {
width: 432px;
.value-tips {
margin-top: 8px;
color: #666666;
.tips-text {
color: #5579bd;
}
}
.deduct-item{
margin-top: 5px;
&:first-child {
margin: 0;
}
}
}
}
}
}
</style>
<style>
.sub-title-tooltip {
max-width: 810px !important;
width: 810px !important;
}
</style>