TblSalaryCalculationForm.vue
21.4 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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
<template>
<a-spin :spinning="confirmLoading">
<j-form-container :disabled="formDisabled">
<a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
<a-row>
<a-col :span="12">
<a-form-model-item label="工资月份" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="salaryMonth">
<a-month-picker v-model="model.salaryMonth" placeholder="请选择工资月份" />
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item style="width: 630px;" label="当月工作总天数" :labelCol="labelCol" :wrapperCol="wrapperCol"
prop="workingDays" >
<a-input-number style="width: 180px;" v-model="model.workingDays" :min="0" :max="99" :step="0.5"
placeholder="请输入当月工作总天数" @blur="working"/>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="userName">
<a-input v-model="model.userName" placeholder="请输入姓名"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="身份证号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="idCard">
<a-input v-model="model.idCard" placeholder="请输入身份证号"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="银行卡号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bankCard">
<a-input v-model="model.bankCard" placeholder="请输入银行卡号"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="工作职位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jobTitle">
<a-select ref="select" v-model="model.jobTitle" placeholder="请输入工作职位" style="width: 285px"
@change="handleChange">
<a-select-option value="officeAdministrative">办公室行政人员</a-select-option>
<a-select-option value="workshopDirector">车间主任</a-select-option>
<a-select-option value="workshopGeneralWorker">车间普工</a-select-option>
<a-select-option value="otherWorker">其他</a-select-option>
</a-select>
</a-form-model-item>
</a-col>
<a-col v-if="model.jobTitle === 'workshopDirector' || model.jobTitle === 'workshopGeneralWorker'" :span="12">
<a-form-model-item label="工时" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="workingHours">
<a-input v-model="model.workingHours" placeholder="请输入工时" @blur="setWorkingHours"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="基本工资" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="basicSalary">
<a-input v-model="model.basicSalary" :readOnly="model.jobTitle != 'otherWorker'" placeholder="请输入基本工资" @blur="jbgz" class="input_dis"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<!-- @blur="autoInput" -->
<a-form-model-item label="工作天数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="day">
<a-input-number style="width: 180px;" id="inputNumber" placeholder="请输入工作天数"
v-model="model.day" :step="0.5" :min="0" :max="99" @blur="setDay"/>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="绩效工资" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="meritPay">
<a-input v-model="model.meritPay" :readOnly="model.jobTitle != 'otherWorker'" placeholder="请输入绩效工资" @blur="jxgz" class="input_dis"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="总工资" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="totalWages">
<a-input v-model="model.totalWages" :readOnly="model.jobTitle != 'otherWorker'" placeholder="请输入总工资" @blur="zgz" class="input_dis"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="餐费补助" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="mealAllowance">
<a-input v-model="model.mealAllowance" readOnly placeholder="请输入餐费补助" class="input_dis"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="全勤奖" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fullAttendanceAward">
<a-input v-model="model.fullAttendanceAward" placeholder="请输入全勤奖" @blur="qqj"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="社保公司" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="socialCompany">
<a-input v-model="model.socialCompany" placeholder="请输入社保公司" @blur="sbgs"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="社保个人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="socialPerson">
<a-input v-model="model.socialPerson" placeholder="请输入社保个人" @blur="sbgr"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="减项" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="deduction">
<a-input v-model="model.deduction" @blur="deduc" placeholder="请输入减项"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="补项" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="supplementary">
<a-input v-model="model.supplementary" @blur="mentary" placeholder="请输入补项"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="应发工资" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="salariesPayable">
<a-input v-model="model.salariesPayable" :readOnly="model.jobTitle != 'otherWorker'" placeholder="请输入应发工资" @blur="setSalariesPayable" class="input_dis"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="个税" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="personalTax">
<a-input v-model="model.personalTax" readOnly placeholder="请输入个税" class="input_dis"></a-input>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item label="实发工资" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="netSalary">
<a-input v-model="model.netSalary" :readOnly="model.jobTitle != 'otherWorker'" placeholder="请输入实发工资" class="input_dis"></a-input>
</a-form-model-item>
</a-col>
</a-row>
</a-form-model>
</j-form-container>
</a-spin>
</template>
<script>
import { httpAction, getAction } from '@/api/manage'
import { message } from 'ant-design-vue';
export default {
name: 'TblSalaryCalculationForm',
components: {
},
props: {
//表单禁用
disabled: {
type: Boolean,
default: false,
required: false
}
},
data() {
return {
model: {
workingHours: undefined,//工时
jobTitle: undefined,// 工作职位
meritPay: 0, // 绩效工资
totalWages: 0, // 总工资
mealAllowance: 0, // 餐费补助
basicSalary: 2000, // 基本工资
salariesPayable: 0,
socialCompany: 990.2, // 社保公司
socialPerson: 397.89, // 社保个人
fullAttendanceAward: 200, // 全勤奖
personalTax: 0,// 个税
netSalary:0,// 实发工资
},
// basicSalary:0,//基本工资
// meritPay:0,//绩效工资
// deduction: 0,// 减项
// laborCost: 0,//工时费
// supplementary: 0,// 补项
// day: 0, // 工作天数
// jobTitle: '',//工作职位
// workingDays: 0,//当月工作总天数
// fullAttendanceAward:0,//全勤奖
// socialcompany: 0,// 社保公司
// socialperson: 0,// 社保个人
flg: false,
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
confirmLoading: false,
validatorRules: {
salaryMonth: [{ required: true, message: '请选择工资月份!' }],
userName: [{ required: true, message: '请输入姓名!' }],
idCard: [{ required: true, message: '请输入身份证号!' }],
bankCard: [{ required: true, message: '请输入银行卡号!' }],
basicSalary: [{ required: true, message: '请输入基本工资!' }],
day: [{ required: true, message: '请输入天数!' }],
workingDays: [{ required: true, message: '请输入当月工作总天数!' }],
meritPay: [{ required: true, message: '请输入绩效工资!' }],
jobTitle: [{ required: true, message: '请输入工作职位!' }],
totalWages: [{ required: true, message: '请输入总工资!' }],
mealAllowance: [{ required: true, message: '请输入餐费补助!' }],
fullAttendanceAward: [{ required: true, message: '请输入全勤奖!' }],
socialCompany: [{ required: true, message: '请输入社保公司!' }],
socialPerson: [{ required: true, message: '请输入社保个人!' }],
deduction: [{ required: true, message: '请输入减项!' }],
supplementary: [{ required: true, message: '请输入补项!' }],
salariesPayable: [{ required: true, message: '请输入应发工资!' }],
personalTax: [{ required: true, message: '请输入个税!' }],
netSalary: [{ required: true, message: '请输入实发工资!' }],
workingHours: [{ required: true, message: '请输入工时!' }],
},
url: {
add: "/salary/calculation/add",
edit: "/salary/calculation/edit",
queryById: "/salary/calculation/queryById"
}
}
},
computed: {
formDisabled() {
return this.disabled
},
},
created() {
//备份model原始值
this.modelDefault = JSON.parse(JSON.stringify(this.model));
},
methods: {
// 判断检测
judgmentDetection() {
if (this.model.workingDays === undefined) {
message.warning('当月工作总天数不可为空');
} else if (this.model.basicSalary === undefined) {
message.warning('工作职位不可为空');
} else if (this.model.day === undefined) {
message.warning('工作天数不可为空');
} else {
this.calculatePerformancePay()
}
},
// 计算工资
calculatePerformancePay() {
// 绩效工资
this.getMeritPay()
// 总工资
this.gettotalWages()
// 餐费补助
this.getMealAllowance()
// 应发工资
this.getSalariesPayable()
// 个税
this.getPersonalTaxAndPay()
// 实发工资
this.getNetSalary()
},
// 绩效工资
getMeritPay(){
if (this.model.jobTitle === 'officeAdministrative') {
// 办公室行政人员
// let str = Number((3500 / this.model.workingDays) * this.model.day - this.model.basicSalary);
let str = Number((3500 / 26) * this.model.day - this.model.basicSalary);
this.model.meritPay = str.toFixed(1);
// 车间主任
} else if (this.model.jobTitle === 'workshopDirector') {
let str = parseFloat(this.laborCost) - parseFloat(this.model.basicSalary);
this.model.meritPay = str;
// 车间普工
} else if (this.model.jobTitle === 'workshopGeneralWorker') {
let str = parseFloat(this.laborCost) - parseFloat(this.model.basicSalary);
this.model.meritPay = str;
}
},
// 总工资
gettotalWages(){
let num = parseInt(this.model.basicSalary) + parseFloat(this.model.meritPay);
this.model.totalWages = num.toFixed(1);
},
// 餐费补助
getMealAllowance(){
this.model.mealAllowance = 25 * parseInt(this.model.day);
},
// 应发工资
getSalariesPayable(){
let yfgz = parseFloat(this.model.totalWages) + parseFloat(this.model.mealAllowance) + parseFloat(this.model.fullAttendanceAward) + parseFloat(this.model.supplementary) - parseFloat(this.model.socialPerson) - parseFloat(this.model.deduction);
this.model.salariesPayable = parseInt(yfgz);
},
// 个税
getPersonalTaxAndPay(){
var sz = [];
sz.push(((parseInt(this.model.salariesPayable) - 5000) * 0.03) - 0);
sz.push((parseInt(this.model.salariesPayable) - 5000) * 0.1 - 210);
sz.push((parseInt(this.model.salariesPayable) - 5000) * 0.2 - 1410);
sz.push((parseInt(this.model.salariesPayable) - 5000) * 0.25 - 2660);
sz.push((parseInt(this.model.salariesPayable) - 5000) * 0.3 - 4410);
sz.push((parseInt(this.model.salariesPayable) - 5000) * 0.35 - 7160);
sz.push((parseInt(this.model.salariesPayable) - 5000) * 0.45 - 15160);
let maxNum = Math.max(...sz);
if(maxNum < 0){
maxNum = 0;
}
this.model.personalTax = maxNum.toFixed(2);
},
// 实发工资
getNetSalary(){
let sfgz = parseInt(this.model.salariesPayable) - parseFloat(this.model.personalTax);
this.model.netSalary = sfgz.toFixed(0);
},
// 选择职位
handleChange(value) {
// console.log(value)
// this.model = {
// workingHours: undefined,
// jobTitle: undefined,
// meritPay: 0, // 绩效工资
// totalWages: 0, // 总工资
// mealAllowance: 0, // 餐费补助
// basicSalary: 0, // 基本工资
// salariesPayable: 0,
// deduction: 0, // 减项
// supplementary: 0, // 补项
// socialCompany: 0, // 社保公司
// socialPerson: 0, // 社保个人
// fullAttendanceAward: 0, // 全勤奖
// personalTax: 0,// 个税
// netSalary:0,// 实发工资
// }
// this.model.jobTitle = value
// this.flg = false
// 办公室行政人员
if (value === 'officeAdministrative') {
this.model.basicSalary = 3500;
// 车间主任
} else if (value === 'workshopDirector') {
this.model.basicSalary = 3000;
// 车间普工
} else if (value === 'workshopGeneralWorker') {
this.model.basicSalary = 2000;
}else if(value === 'otherWorker'){
this.model.workingHours= undefined,
this.model.meritPay= 0, // 绩效工资
this.model.totalWages= 0, // 总工资
this.model.mealAllowance= 0, // 餐费补助
this.model.basicSalary= 0, // 基本工资
this.model.salariesPayable= 0,
this.model.deduction= 0, // 减项
this.model.supplementary= 0, // 补项
this.model.socialCompany= 0, // 社保公司
this.model.socialPerson= 0, // 社保个人
this.model.fullAttendanceAward= 0, // 全勤奖
this.model.personalTax= 0,// 个税
this.model.netSalary=0,// 实发工资
this.flg = false
}
console.log(this.model.jobTitle)
if (this.flg) {
this.judgmentDetection();
}
},
// 根据工时计算工时费
setWorkingHours() {
if(this.model.jobTitle == 'otherWorker'){
// 餐补
// this.getMealAllowance()
// 应发工资
this.getSalariesPayable()
// 个税
this.getPersonalTaxAndPay()
// 实发工资
this.getNetSalary()
return
}
if(this.model.jobTitle === 'workshopDirector'){
this.laborCost = (this.model.day > 0 && this.model.workingHours > 0) ? Math.round(this.model.workingHours * 0.5) : this.model.basicSalary
}else if(this.model.jobTitle === 'workshopGeneralWorker'){
if(this.model.day == 0 && this.model.workingHours == 0){
// console.log('111111')
this.laborCost = this.model.basicSalary
}else if(this.model.day > 0 && this.model.workingHours > 0){
// console.log('222222222')
this.laborCost = this.model.day >= 26 ? (this.model.workingHours * 3.3).toFixed(0) : (this.model.workingHours * 3.2).toFixed(0)
}
}
if((this.model.jobTitle === 'workshopDirector' || this.model.jobTitle === 'workshopGeneralWorker') && ((this.model.workingHours == 0 && this.model.day == 0) || (this.model.workingHours > 0 && this.model.day > 0))){
// console.log('3333333')
this.flg = true
this.judgmentDetection()
}else if(this.model.jobTitle === 'officeAdministrative'){
// console.log('444444444')
this.flg = true
this.judgmentDetection()
}
},
// 工作天数
setDay(){
if(this.model.jobTitle == 'otherWorker'){
if(this.model.day == 0){
}else {
// 餐补
this.getMealAllowance()
// 应发工资
this.getSalariesPayable()
// 个税
this.getPersonalTaxAndPay()
// 实发工资
this.getNetSalary()
}
return
}
if(this.model.workingHours > 0){
if(this.model.jobTitle === 'workshopDirector'){
this.laborCost = Math.round(this.model.workingHours * 0.5)
}else if(this.model.jobTitle === 'workshopGeneralWorker'){
this.laborCost = this.model.day >= 26 ? (this.model.workingHours * 3.3).toFixed(0) : (this.model.workingHours * 3.2).toFixed(0)
}
}else if(this.model.workingHours == 0){
this.laborCost = this.model.basicSalary
}
this.flg = true
this.judgmentDetection()
},
add() {
this.edit(this.modelDefault);
},
edit(record) {
this.model = Object.assign({}, record);
this.visible = true;
},
// 当月工作总天数
working() {
// this.workingDays = this.model.workingDays;
if(this.flg){
this.judgmentDetection();
}
},
// 基本工资
jbgz(){
// this.basicSalary = this.model.basicSalary
if(this.flg){
this.judgmentDetection();
}
},
// 绩效工资
jxgz(){
// this.meritPay = this.model.meritPay
if(this.model.jobTitle == 'otherWorker'){
// 总工资
this.gettotalWages()
// 应发工资
this.getSalariesPayable()
// 个税
this.getPersonalTaxAndPay()
// 实发工资
this.getNetSalary()
return
}
if(this.flg){
if (this.model.workingDays === undefined) {
message.warning('当月工作总天数不可为空');
} else if (this.model.basicSalary === undefined) {
message.warning('工作职位不可为空');
} else if (this.model.day === undefined) {
message.warning('工作天数不可为空');
} else {
console.log('绩效')
this.gettotalWages()
// 应发工资
this.getSalariesPayable()
// 个税
this.getPersonalTaxAndPay()
// 实发工资
this.getNetSalary()
}
}
},
//总工资
zgz(){
if(this.model.jobTitle == 'otherWorker'){
// 应发工资
this.getSalariesPayable()
// 个税
this.getPersonalTaxAndPay()
// 实发工资
this.getNetSalary()
}
},
//全勤奖
qqj(){
// this.fullAttendanceAward = this.model.fullAttendanceAward
if(this.flg){
this.judgmentDetection();
}
},
// 社保公司
sbgs() {
// this.socialcompany = this.model.socialCompany;
if(this.flg){
this.judgmentDetection();
}
},
// 社保个人
sbgr() {
// this.socialperson = this.model.socialPerson;
if(this.flg){
this.judgmentDetection();
}
},
// 补项
mentary() {
// this.supplementary = this.model.supplementary;
if(this.flg){
this.judgmentDetection();
}
},
// 减项
deduc() {
// this.deduction = this.model.deduction;
if(this.flg){
this.judgmentDetection();
}
},
// 应发工资
setSalariesPayable(){
// 个税
this.getPersonalTaxAndPay()
// 实发工资
this.getNetSalary()
},
submitForm() {
const that = this;
// 触发表单验证
this.$refs.form.validate(valid => {
if (valid) {
that.confirmLoading = true;
let httpurl = '';
let method = '';
if (!this.model.id) {
httpurl += this.url.add;
method = 'post';
} else {
httpurl += this.url.edit;
method = 'put';
}
httpAction(httpurl, this.model, method).then((res) => {
if (res.success) {
that.$message.success(res.message);
that.$emit('ok');
} else {
that.$message.warning(res.message);
}
}).finally(() => {
that.confirmLoading = false;
})
}
})
},
}
}
</script>
<style lang="less" scoped>
.input_dis{
border-color: #91d5ff;background-color: #e6f7ff
}
</style>