huminmin
2026-06-12 a32e60bf3366bf3b2d8d0d53b8257290acfb3d4e
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
<template>
  <div class="app-container subsidy-config-container">
    <el-row :gutter="20">
      <!-- 左侧配置表单 -->
      <el-col :span="16">
        <el-card class="config-card"
                 shadow="hover">
          <template #header>
            <div class="card-header">
              <div class="header-title">
                <el-icon class="header-icon">
                  <Setting />
                </el-icon>
                <span>补贴标准配置</span>
              </div>
              <div class="header-ops">
                <el-button type="primary"
                           :loading="loading"
                           @click="submitForm">
                  <el-icon>
                    <Check />
                  </el-icon> 保存配置
                </el-button>
              </div>
            </div>
          </template>
          <el-form ref="formRef"
                   :model="form"
                   :rules="rules"
                   label-position="top"
                   class="subsidy-form">
            <div class="config-section">
              <div class="section-title">
                <el-icon>
                  <Food />
                </el-icon> 餐补设置
              </div>
              <el-row :gutter="40">
                <el-col :span="12">
                  <el-form-item label="补贴标准金额"
                                style="margin-right:20px"
                                prop="mealAmount">
                    <el-input-number v-model="form.mealAmount"
                                     :precision="2"
                                     :step="1"
                                     :min="0"
                                     controls-position="right"
                                     class="full-width-input" />
                    <span class="input-unit">元/天</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <div class="quick-info">
                    <div class="info-item">
                      <span class="label">适用对象:</span>
                      <el-tag size="small"
                              type="warning">回族员工</el-tag>
                    </div>
                    <div class="info-item">
                      <span class="label">计算范围:</span>
                      <span>白班 + 夜班</span>
                    </div>
                  </div>
                </el-col>
              </el-row>
            </div>
            <el-divider />
            <div class="config-section">
              <div class="section-title">
                <el-icon>
                  <Moon />
                </el-icon> 夜班补助设置
              </div>
              <el-row :gutter="40">
                <el-col :span="12">
                  <el-form-item label="补助标准金额"
                                style="margin-right:20px"
                                prop="nightAmount">
                    <el-input-number v-model="form.nightAmount"
                                     :precision="2"
                                     :step="1"
                                     :min="0"
                                     controls-position="right"
                                     class="full-width-input" />
                    <span class="input-unit">元/天</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <div class="quick-info">
                    <div class="info-item">
                      <span class="label">适用对象:</span>
                      <el-tag size="small">全员(排班为夜班)</el-tag>
                    </div>
                    <div class="info-item">
                      <span class="label">计算范围:</span>
                      <span>仅限夜班</span>
                    </div>
                  </div>
                </el-col>
              </el-row>
            </div>
          </el-form>
        </el-card>
        <!-- 计算示例卡片 -->
        <el-card class="example-card"
                 shadow="never">
          <template #header>
            <div class="card-header-small">
              <el-icon>
                <InfoFilled />
              </el-icon>
              <span>薪资计算逻辑说明</span>
            </div>
          </template>
          <div class="example-content">
            <el-row :gutter="20">
              <el-col :span="12">
                <div class="example-box meal">
                  <h5>餐补计算示例</h5>
                  <p>若标准为 <strong>{{ form.mealAmount }}元/天</strong></p>
                  <p>某回族员工:白班10天,夜班10天</p>
                  <div class="formula">
                    计算:(10 + 10) * {{ form.mealAmount }} = <span>{{ (20 * form.mealAmount).toFixed(2) }}元</span>
                  </div>
                </div>
              </el-col>
              <el-col :span="12">
                <div class="example-box night">
                  <h5>夜班补助计算示例</h5>
                  <p>若标准为 <strong>{{ form.nightAmount }}元/天</strong></p>
                  <p>某员工:当月夜班10天</p>
                  <div class="formula">
                    计算:10 * {{ form.nightAmount }} = <span>{{ (10 * form.nightAmount).toFixed(2) }}元</span>
                  </div>
                </div>
              </el-col>
            </el-row>
          </div>
        </el-card>
      </el-col>
      <!-- 右侧规则说明 -->
      <el-col :span="8">
        <el-card class="rule-card"
                 shadow="hover">
          <template #header>
            <div class="card-header">
              <span>业务规则详情</span>
            </div>
          </template>
          <el-scrollbar height="500px">
            <div class="rule-item">
              <div class="rule-header">
                <span class="dot warning"></span>
                <h6>关于餐补的标准与发放</h6>
              </div>
              <p>1. 系统将自动识别员工档案中的【民族】字段,仅对标注为“回族”的员工计算此项补贴。</p>
              <p>2. 发放依据以考勤系统中的实际出勤天数为准,包含所有正常班次(白班、夜班)。</p>
              <p>3. 请假、旷工等非出勤天数不计入计算范围。</p>
            </div>
            <el-divider />
            <div class="rule-item">
              <div class="rule-header">
                <span class="dot primary"></span>
                <h6>关于夜班补助的标准与发放</h6>
              </div>
              <p>1. 只要员工的排班班次被定义为“夜班”,且有实际出勤记录,即可享受此补助。</p>
              <p>2. 补助按天计算,不区分岗位职级,统一执行此标准配置。</p>
              <p>3. 此补助与餐补可同时享受(若符合餐补条件)。</p>
            </div>
            <el-alert title="配置生效说明"
                      type="info"
                      :closable="false"
                      show-icon
                      style="margin-top: 20px">
              修改后的标准将在下一次执行“工资结算”任务时正式生效,不会影响已结算的历史薪资数据。
            </el-alert>
          </el-scrollbar>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>
 
<script setup name="SubsidyConfig">
  import { ref, onMounted } from "vue";
  import {
    Setting,
    Check,
    RefreshRight,
    Food,
    Moon,
    InfoFilled,
  } from "@element-plus/icons-vue";
  import {
    listSubsidyConfiguration,
    saveSubsidyConfiguration,
  } from "@/api/personnelManagement/subsidyConfig.js";
  import { ElMessage, ElMessageBox } from "element-plus";
 
  const formRef = ref(null);
  const loading = ref(false);
 
  const form = ref({
    id: undefined,
    mealAmount: 0,
    nightAmount: 0,
    tenantId: undefined,
    createTime: undefined,
  });
 
  const rules = {
    mealAmount: [{ required: true, message: "请输入餐补标准", trigger: "blur" }],
    nightAmount: [
      { required: true, message: "请输入夜班补助标准", trigger: "blur" },
    ],
  };
 
  /** 查询配置 */
  const getConfig = async () => {
    try {
      const res = await listSubsidyConfiguration();
      if (res.data && res.data.length > 0) {
        const config = res.data[0];
        form.value = {
          id: config.id,
          mealAmount: config.mealAmount || 0,
          nightAmount: config.nightAmount || 0,
          tenantId: config.tenantId,
          createTime: config.createTime,
        };
      }
    } catch (error) {
      console.error("获取配置失败", error);
    }
  };
 
  /** 提交表单 */
  const submitForm = async () => {
    if (!formRef.value) return;
 
    await formRef.value.validate(async valid => {
      if (valid) {
        loading.value = true;
        try {
          await saveSubsidyConfiguration(form.value);
          ElMessage.success("标准配置已更新");
          getConfig(); // 重新加载以获取可能的更新(如id)
        } catch (error) {
          console.error("保存失败", error);
        } finally {
          loading.value = false;
        }
      }
    });
  };
 
  onMounted(() => {
    getConfig();
  });
</script>
 
<style scoped lang="scss">
  .subsidy-config-container {
    padding: 20px;
    background-color: #f5f7fa;
    min-height: calc(100vh - 84px);
 
    .config-card {
      margin-bottom: 20px;
      border-radius: 8px;
 
      .card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
 
        .header-title {
          display: flex;
          align-items: center;
          font-size: 18px;
          font-weight: 600;
          color: #303133;
 
          .header-icon {
            margin-right: 8px;
            color: #409eff;
          }
        }
      }
    }
 
    .subsidy-form {
      padding: 10px 20px;
 
      .config-section {
        .section-title {
          display: flex;
          align-items: center;
          gap: 8px;
          font-size: 16px;
          font-weight: 500;
          margin-bottom: 20px;
          color: #606266;
 
          .el-icon {
            color: #409eff;
          }
        }
      }
 
      .full-width-input {
        width: 100% !important;
      }
 
      .input-unit {
        position: absolute;
        right: -45px;
        top: 0;
        color: #909399;
        font-size: 14px;
      }
 
      .quick-info {
        background: #fdf6ec;
        border-radius: 4px;
        padding: 15px;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 10px;
 
        .info-item {
          font-size: 14px;
          color: #666;
          .label {
            font-weight: 500;
          }
        }
      }
    }
 
    .example-card {
      background: #fff;
      border: 1px dashed #dcdfe6;
 
      .card-header-small {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 14px;
        color: #909399;
      }
 
      .example-box {
        padding: 15px;
        border-radius: 6px;
 
        h5 {
          margin: 0 0 10px 0;
          font-size: 14px;
          color: #303133;
        }
 
        p {
          margin: 5px 0;
          font-size: 13px;
          color: #606266;
        }
 
        .formula {
          margin-top: 10px;
          padding-top: 10px;
          border-top: 1px solid rgba(0, 0, 0, 0.05);
          font-size: 13px;
          font-weight: bold;
 
          span {
            color: #f56c6c;
            font-size: 16px;
          }
        }
 
        &.meal {
          background-color: #f0f9eb;
        }
        &.night {
          background-color: #ecf5ff;
        }
      }
    }
 
    .rule-card {
      height: 100%;
 
      .rule-item {
        padding: 5px 0;
 
        .rule-header {
          display: flex;
          align-items: center;
          gap: 8px;
          margin-bottom: 10px;
 
          .dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            &.warning {
              background: #e6a23c;
            }
            &.primary {
              background: #409eff;
            }
          }
 
          h6 {
            margin: 0;
            font-size: 15px;
            color: #303133;
          }
        }
 
        p {
          font-size: 13px;
          line-height: 1.8;
          color: #606266;
          margin: 5px 0 5px 16px;
        }
      }
    }
  }
 
  :deep(.el-divider--horizontal) {
    margin: 24px 0;
  }
</style>