ZhangXianQiang
2024-05-06 72f13e697d40c8fffc7aa0197fec4509bbe41569
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
<template>
  <div class="app-container">
    <el-page-header @back="goBack()" content="详情页面">
    </el-page-header>
 
    <el-container>
      <el-main>
        <h2>考核规则</h2>
        <el-table v-loading="loading" :data="checkRuleList" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55" align="center"/>
          <el-table-column label="规则名称" align="center" prop="checkRuleName"/>
          <el-table-column label="规则权重" align="center" prop="weight"/>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleRuleUpdate(scope.row)"
              >修改
              </el-button>
            </template>
          </el-table-column>
        </el-table>
 
      </el-main>
    </el-container>
 
    <el-container>
      <el-main>
        <h2>考核成绩</h2>
        <el-row :gutter="10" class="mb5">
          <el-col :span="1.5" style="margin-right: 20px">
            <el-button
              type="warning"
              plain
              icon="el-icon-download"
              size="mini"
              @click="handleExport"
            >导出
            </el-button>
          </el-col>
          <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
            <el-form-item label="考核日期" prop="name">
              <el-date-picker v-model="date" format="yyyy-MM" value-format="yyyy-MM" type="month" placeholder="选择日期"
                              @change="dateChange">
              </el-date-picker>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            </el-form-item>
          </el-form>
 
        </el-row>
 
        <el-table v-loading="loading" :data="dataMap" @selection-change="handleSelectionChange">
          <el-table-column label="考核日期" align="center" prop="create_time" width="120px" fixed>
            <template slot-scope="scope">
              <span>{{ scope.row.create_time.split('T')[0] }}</span>
            </template>
          </el-table-column>
          <el-table-column label="考核对象" align="center" prop="dept_id" width="120px" fixed>
            <template slot-scope="scope">
              <span>{{ translateDeptId(scope.row.dept_id) }}</span>
            </template>
          </el-table-column>
          <template v-for="item in tableData">
            <el-table-column
              :key="item.ruleName"
              :label="item.ruleName"
              align="center"
              width="180px"
            >
              <template slot-scope="scope">
                <span>{{ scope.row[item.ruleIndex] }}</span>
              </template>
            </el-table-column>
          </template>
          <!--          <el-table-column label="操作" align="center" class-name="small-padding fixed-width"  fixed="right">-->
          <!--            <template slot-scope="scope">-->
          <!--              <el-button-->
          <!--                size="mini"-->
          <!--                type="text"-->
          <!--                icon="el-icon-edit"-->
          <!--                @click="handleIndexUpdate(scope.row,scope.index)"-->
          <!--              >修改</el-button>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
        </el-table>
      </el-main>
    </el-container>
 
    <!-- 修改考核权重对话框 -->
    <el-dialog :title="title" :visible.sync="ruleOpen" width="600px" append-to-body>
      <el-form ref="form" :model="ruleForm" :rules="rules" label-width="80px">
        <el-form-item label="规则名称" prop="checkRuleName">
          <el-input v-model="ruleForm.checkRuleName" placeholder="请输入规则名称" disabled/>
        </el-form-item>
        <el-form-item label="规则权重" prop="weight">
          <el-input-number v-model="ruleForm.weight" :precision="1" :step="0.1" placeholder="请输入规则权重"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
 
    <!-- 修改考核指标对话框 -->
    <el-dialog :title="title" :visible.sync="indexOpen" width="600px" append-to-body>
      <el-form ref="form" :model="indexForm" :rules="rules" label-width="150px">
        <el-form-item label="考核日期" prop="create_time">
          <el-input v-model="formattedCreateTime" placeholder="" disabled>
          </el-input>
        </el-form-item>
        <div v-for="item in tableData" :key="item.ruleIndex">
          <el-form-item :label="item.ruleName" :prop="item.ruleIndex">
            <el-input-number v-model="indexForm[item.ruleIndex]" :precision="4" :step="0.1" placeholder="请输入指标"></el-input-number>
          </el-form-item>
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
 
import {listScore, getScoreIndex, delScore, addScore, updateScore} from "@/api/platform/check-score";
import {updateWeight} from "@/api/platform/check-template";
import {areaSelect} from '@/api/system/dept'
 
export default {
  name: "CheckResult",
  dicts: ['platform_audit_state'],
  data() {
    return {
      id: null,
      examineCategory: null,
      date: '',
      examineTag: null,
      deptId: null,
      areaList: [],
      tableData: [],
      dataMap: [],
      manualScoreOpen: false,
      manualScoreForm: {},
      manualScoreTitle: '',
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 考核结果表格数据
      checkRuleList: [],
      scoreTotal: 3,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      ruleOpen: false,
      indexOpen: false,
      // 逻辑删除时间范围
      daterangeCheckTime: [],
      // 表单参数
      indexForm: {},
      ruleForm: {},
      //请求参数
      queryParams: {
        id: null,
        date: null,
      },
      // 表单校验
      rules: {}
    };
  },
  computed: {
    formattedCreateTime() {
      // 如果 create_time 存在,则返回日期部分,否则返回空字符串
      return this.indexForm.create_time ? this.indexForm.create_time.split('T')[0] : '';
    },
  },
  created() {
    //考核成绩详情跳转参数接收
    if (this.$route.query.id) {
      this.queryParams.id = this.$route.query.id
    }
    // 考核积分列表
    this.getList();
    this.areaSelect();
  },
  methods: {
    /** 查询考核计分列表 */
    getList() {
      this.loading = true;
      getScoreIndex(this.queryParams).then(response => {
        this.checkRuleList = response.data.checkRuleList;
        this.dataMap = response.data.scoreMap.dataMap;
        this.tableData = response.data.scoreMap.tableData
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.ruleOpen = false;
      this.indexOpen = false;
      this.reset("ruleForm");
      this.reset("indexForm");
    },
    // 表单重置
    reset(formName) {
      this.ruleForm = {
        checkRuleName: null,
        weight: null,
      };
      this.indexForm = {};
      this.resetForm(formName);
    },
    translateDeptId(deptId) {
      const department = this.areaList.find(dept => dept.id == deptId);
      return department ? department.value : '未知';
    },
    // 区域下拉数据
    areaSelect() {
      areaSelect().then(res => {
        this.areaList = res.data;
      })
    },
    /** 返回按钮 */
    goBack() {
      const obj = { path: "/examine/detail", query: { index: this.$route.query.deptId, examineTag: this.$route.query.examineTag, pageNum: this.$route.query.pageNum } };
      this.$tab.closeOpenPage(obj);
    },
    // 关闭当前tab页签,打开新页签
    closeOpenPage(obj) {
      store.dispatch("tagsView/delView", router.currentRoute);
      if (obj !== undefined) {
        return router.push(obj);
      }
    },
    dateChange() {
      this.queryParams.date = this.date;
      console.log(this.queryParams);
      this.getList();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeCheckTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加考核结果";
    },
    /** 修改指标按钮操作 */
    handleIndexUpdate(row) {
      this.reset("indexForm");
      this.indexForm = row;
      this.indexOpen = true;
      this.title = "修改考核指标";
    },
    /** 修改按钮操作 */
    handleRuleUpdate(row) {
      this.reset("ruleForm");
      this.ruleForm = row;
      this.ruleOpen = true;
      this.title = "修改考核规则";
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.ruleForm.id != null) {
            updateWeight(this.ruleForm).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.ruleOpen = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('/check/score/export', {
        ...this.queryParams
      }, `考核指标_${new Date().getTime()}.xlsx`)
    },
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
    },
  }
};
</script>
<style scoped>
 
 
.header-container h2 {
  margin-right: 10px; /* 根据需要调整标题和菜单之间的间距 */
}
 
</style>