spring
2025-02-19 b4c40a33424867db31b88bd4fb7d6d72a6b537be
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
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
<!-- 岗位职责 -->
<template>
  <div class="view">
    <div style="text-align: left; margin-bottom: 15px;padding: 0 10px">
      <label>员工:</label>
      <el-input
        v-model="userName"
        clearable
        placeholder="请输入员工"
        size="small"
        style="width: 20vh;"
      ></el-input>
      <el-button size="small" type="primary" @click="refreshTable"
        >查询</el-button
      >
      <div v-if="isDepartment" style="float: right;">
        <el-button size="small" type="primary" @click="addPost">新增</el-button>
        <!--        <el-button size="small" type="primary">导出excel</el-button>-->
      </div>
    </div>
    <div class="table" style="padding: 0 10px">
      <el-table :data="tableData" height="70vh" style="width: 100%">
        <el-table-column label="序号" type="index" width="60"></el-table-column>
        <el-table-column
          label="员工编号"
          min-width="120"
          prop="account"
        ></el-table-column>
        <el-table-column
          label="岗位名称"
          min-width="180"
          prop="postName"
        ></el-table-column>
        <el-table-column
          label="所属部门"
          min-width="180"
          prop="departLimsName"
        ></el-table-column>
        <el-table-column
          label="工作目标"
          min-width="180"
          prop="jobObjective"
        ></el-table-column>
        <el-table-column
          label="岗位职责"
          min-width="180"
          prop="jobResponsibilities"
        ></el-table-column>
        <el-table-column
          label="任职人"
          min-width="180"
          prop="incumbentName"
        ></el-table-column>
        <el-table-column
          label="任职人审核日期"
          min-width="180"
          prop="incumbentDate"
        ></el-table-column>
        <el-table-column
          label="主管"
          min-width="180"
          prop="supervisorName"
        ></el-table-column>
        <el-table-column
          label="主管审核日期"
          min-width="180"
          prop="supervisorDate"
        ></el-table-column>
        <el-table-column fixed="right" label="操作" width="140">
          <template v-slot="scope">
            <el-button
              v-if="!isDepartment || scope.row.currentState === '关闭'"
              size="small"
              type="text"
              @click="handleViewClick(scope.row, 'view')"
              >查看
            </el-button>
            <el-button
              v-if="isDepartment && scope.row.currentState !== '关闭'"
              size="small"
              type="text"
              @click="handleViewClick(scope.row, 'edit')"
              >编辑
            </el-button>
            <el-button size="small" type="text" @click="downLoadPost(scope.row)"
              >下载</el-button
            >
            <el-button
              v-if="isDepartment"
              size="small"
              type="text"
              @click="deletePost(scope.row)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="1"
        :page-size="search.size"
        :page-sizes="[10, 20, 30, 50, 100]"
        :total="search.total"
        layout="->,total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      >
      </el-pagination>
    </div>
    <!-- 新增岗位职责 -->
    <el-dialog
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :visible.sync="dialogVisible"
      title="新增岗位职责"
      width="50%"
      @close="resetForm"
    >
      <el-steps :active="currentStep" align-center finish-status="success">
        <el-step
          v-for="(v, i) in steps"
          :key="i"
          :title="v"
          style="cursor:pointer"
          @click.native="choiceStep(i)"
        ></el-step>
      </el-steps>
      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
        <div>
          <el-card style="margin-top: 1em; height: 40vh; overflow-y: scroll;">
            <!-- 新增设备事记录卡片 -->
            <el-row>
              <el-col :span="12">
                <el-form-item label="岗位名称:" prop="postName">
                  <el-input
                    v-model="form.postName"
                    :disabled="currentStep !== 0 || operationType === 'view'"
                    size="small"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="工作目标:" prop="jobObjective">
                  <el-input
                    v-model="form.jobObjective"
                    :disabled="currentStep !== 0 || operationType === 'view'"
                    size="small"
                    type="textarea"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="岗位职责:" prop="jobResponsibilities">
                  <el-input
                    v-model="form.jobResponsibilities"
                    :disabled="currentStep !== 0 || operationType === 'view'"
                    size="small"
                    type="textarea"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col
                v-if="currentStep === 0 || operationType === 'view'"
                :span="12"
              >
                <el-form-item
                  :rules="[
                    {
                      required: currentStep === 0,
                      message: '请选择任职人',
                      trigger: 'change'
                    }
                  ]"
                  label="任职人:"
                  prop="incumbentId"
                >
                  <el-select
                    v-model="form.incumbentId"
                    :disabled="operationType === 'view'"
                    clearable
                    filterable
                    placeholder="请选择任职人"
                    size="small"
                    style="width: 100%;"
                  >
                    <el-option
                      v-for="item in responsibleOptions"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col
                v-if="currentStep === 1 || operationType === 'view'"
                :span="12"
              >
                <el-form-item
                  :rules="[
                    {
                      required: currentStep === 1,
                      message: '请选择主管',
                      trigger: 'blur'
                    }
                  ]"
                  label="主管:"
                  prop="supervisorId"
                >
                  <el-select
                    v-model="form.supervisorId"
                    :disabled="currentStep !== 1 || operationType === 'view'"
                    clearable
                    filterable
                    placeholder="请选择主管"
                    size="small"
                    style="width: 100%;"
                  >
                    <el-option
                      v-for="item in responsibleOptions"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </el-card>
          <el-row style="margin-top: 1em;">
            <el-col :span="4"> 操作人:{{ form.submitPerson }} </el-col>
            <el-col :span="6"> 日期:{{ form.submitDate }} </el-col>
          </el-row>
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button
          v-if="currentStep !== 0 && currentStep !== 3"
          @click="submitForm('3reject')"
          >驳回</el-button
        >
        <el-button v-if="currentStep === 0" @click="submitForm('2save')"
          >保存</el-button
        >
        <el-button
          v-if="currentStep !== 3"
          type="primary"
          @click="submitForm('1submit')"
          >{{ currentStep === 0 ? "提交" : "通过" }}</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import { dateFormat } from "../../../util/date";
import { deletePersonCommunicationAbility } from "../../../assets/api/api";
 
export default {
  data() {
    return {
      userName: "",
      tableData: [],
      responsibleOptions: [],
      search: {
        size: 20,
        current: 1,
        total: 0
      },
      dialogVisible: false,
      currentStep: 0, // 步骤条显示第几步
      currentStepClick: 0, // 点击步骤条变化
      operationType: "",
      steps: ["提交", "任职人确认", "主管确认"],
      form: {
        postName: "", // 岗位名称
        jobObjective: "", // 工作目标
        jobResponsibilities: "", // 岗位职责
        incumbentId: "", // 任职人
        supervisorId: "" // 主管
      },
      rules: {
        postName: [
          { required: true, message: "请输入岗位名称", trigger: "blur" }
        ],
        jobObjective: [
          { required: true, message: "请输入工作目标", trigger: "blur" }
        ],
        jobResponsibilities: [
          { required: true, message: "请输入岗位职责", trigger: "blur" }
        ],
        incumbentId: [
          { required: true, message: "请选择任职人", trigger: "change" }
        ],
        supervisorId: [
          { required: true, message: "请选择主管", trigger: "change" }
        ]
      }
      // departId: 0
    };
  },
  props: {
    departId: {
      type: Number,
      default: () => {
        return null;
      }
    },
    isDepartment: {
      type: Boolean,
      default: false
    }
  },
  mounted() {
    this.getPostList(this.departId);
  },
  methods: {
    addPost() {
      this.dialogVisible = true;
      this.form = {
        postName: "", // 岗位名称
        jobObjective: "", // 工作目标
        jobResponsibilities: "", // 岗位职责
        incumbentId: "", // 任职人
        supervisorId: "", // 操作人
        submitPerson: "", // 主管
        submitDate: "", // 日期
        currentStep: 0 // 日期
      };
      this.currentStep = 0;
      this.getUserList();
    },
    // 查询列表信息
    getPostList(userId) {
      this.search.userId = userId;
      const name = this.isDepartment ? "departmentId" : "userId";
      this.$axios
        .get(
          this.$api.personnel.personJobResponsibilitiesSelect +
            "?userName=" +
            this.userName +
            `&${name}=` +
            this.search.userId +
            "&size=" +
            this.search.size +
            "&current=" +
            this.search.current
        )
        .then(res => {
          if (res.code === 201) return;
          this.tableData = res.data.records;
          this.search.total = res.data.total;
        });
    },
    //提交表单
    async submitForm(saveState) {
      this.$refs.form.validate(valid => {
        if (valid === true || saveState !== "1submit") {
          // 给当前环节设置创建人与时间
          let user = JSON.parse(localStorage.getItem("user"));
          const dateTime = dateFormat(new Date());
          // 获取当前环节操作人与日期
          switch (this.currentStep) {
            case 0:
              this.form.submittingOperator = user.name;
              this.form.submittingDate = dateTime;
              break;
            case 1:
              this.form.incumbentOperator = user.name;
              this.form.incumbentDate = dateTime;
              break;
            case 2:
              this.form.supervisorOperator = user.name;
              this.form.supervisorDate = dateTime;
              break;
            default:
              break;
          }
          // 获取当前环节负责人
          switch (
            saveState === "3reject" ? this.currentStep - 1 : this.currentStep
          ) {
            case 1:
              this.form.currentResponsible = this.form.submittingOperator;
              break;
            case 2:
              this.form.currentResponsible = this.form.incumbentOperator;
              break;
            default:
              break;
          }
          let currentStepAction;
          // 设置该操作判断是否为提交,保存,驳回,通过
          switch (saveState) {
            // 提交,通过
            case "1submit":
              currentStepAction = this.currentStep + 1;
              break;
            // 保存
            case "2save":
              currentStepAction = this.currentStep;
              break;
            // 驳回
            case "3reject":
              currentStepAction = this.currentStep - 1;
              break;
            default:
              break;
          }
          // 获取当前状态
          this.form.currentState =
            currentStepAction === 3 ? "关闭" : this.steps[currentStepAction];
          this.$axios
            .post(
              this.$api.personnel.personJobResponsibilitiesSave,
              this.form,
              {
                headers: {
                  "Content-Type": "application/json"
                },
                noQs: true
              }
            )
            .then(res => {
              if (res.code == 200) {
                this.$message.success("提交成功");
                this.getPostList(this.departId);
                this.dialogVisible = false;
              }
            });
        } else {
          let step = this.steps[this.currentStep];
          this.$message.warning(step + "  流程中有必填项未填!");
        }
      });
    },
    // 编辑
    handleViewClick(row, type) {
      this.operationType = type;
      this.getUserList();
      row.incumbentId = Number(row.incumbentId);
      this.form = { ...row };
      switch (row.currentState) {
        case "提交":
          this.currentStep = 0;
          break;
        case "任职人确认":
          this.currentStep = 1;
          this.form.submitPerson = row.submittingOperator;
          this.form.submitDate = row.submittingDate;
          break;
        case "主管确认":
          this.currentStep = 2;
          this.form.submitPerson = row.incumbentOperator;
          this.form.submitDate = row.incumbentDate;
          break;
        case "关闭":
          this.currentStep = 3;
          this.form.submitPerson = row.supervisorOperator;
          this.form.submitDate = row.supervisorDate;
          break;
        default:
          break;
      }
      this.form.currentState = this.currentStep;
      this.currentStepClick = this.currentStep === 3 ? 0 : this.currentStep;
      console.log("this.form---", this.form);
      this.dialogVisible = true;
    },
    // 下载岗位职责
    downLoadPost(row) {
      this.$axios
        .post(
          this.$api.personPostAuthorizationRecord
            .exportPersonJobResponsibilities,
          { id: row.id },
          { responseType: "blob" }
        )
        .then(res => {
          this.$message.success("下载成功");
          //将Blob 对象转换成字符串
          const blob = new Blob([res], { type: "application/msword" });
          let reader = new FileReader();
          reader.readAsText(blob, "utf-8");
          reader.onload = () => {
            try {
              let result = JSON.parse(reader.result);
              if (result.message) {
                this.$message.error(result.message);
              } else {
                const url = URL.createObjectURL(blob);
                const link = document.createElement("a");
                link.href = url;
                link.download = row.incumbentName + "-岗位职责" + ".docx";
                link.click();
                this.$message.success("导出成功");
              }
            } catch (err) {
              console.log(err);
              const url = URL.createObjectURL(blob);
              const link = document.createElement("a");
              link.href = url;
              link.download = row.incumbentName + "-岗位职责" + ".docx";
              link.click();
              this.$message.success("导出成功");
            }
          };
        });
    },
    // 删除岗位职责
    deletePost(row) {
      this.$confirm("此操作将永久删除此数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$axios
            .delete(
              this.$api.personnel.personJobResponsibilitiesDelete +
                "?id=" +
                row.id
            )
            .then(res => {
              if (res.code == 200) {
                this.$message.success("删除成功");
                this.getPostList(this.departId);
              }
            });
        })
        .catch(() => {
          this.$message.error("删除失败");
        });
    },
    resetForm() {
      this.$refs.form.resetFields();
    },
    refreshTable() {
      this.getPostList(this.departId);
    },
    // 获取负责人信息接口
    getUserList() {
      this.$axios.get(this.$api.deviceScope.selectUserList).then(res => {
        if (res.code == 200) {
          this.responsibleOptions = res.data;
        }
      });
    },
    choiceStep(index) {
      this.currentStepClick = index;
    },
    handleSizeChange(val) {
      this.search.size = val;
      this.getPostList(this.departId);
    },
    handleCurrentChange(val) {
      this.search.current = val;
      this.getPostList(this.departId);
    }
  },
  watch: {
    departId: {
      handler(newId, oldId) {
        this.getPostList(newId);
      }
    }
  }
};
</script>
<style scoped></style>