From 14bc915349f56e1276793aedd7598380b385e5aa Mon Sep 17 00:00:00 2001
From: chenrui <1187576398@qq.com>
Date: 星期五, 07 三月 2025 13:49:07 +0800
Subject: [PATCH] bug修复
---
src/views/CNAS/personnel/personnelInfo/tabs/reward-punishment-record.vue | 217 ++++++++++++++++++++++--------------------------------
1 files changed, 89 insertions(+), 128 deletions(-)
diff --git a/src/views/CNAS/personnel/personnelInfo/tabs/reward-punishment-record.vue b/src/views/CNAS/personnel/personnelInfo/tabs/reward-punishment-record.vue
index 344051f..7b55725 100644
--- a/src/views/CNAS/personnel/personnelInfo/tabs/reward-punishment-record.vue
+++ b/src/views/CNAS/personnel/personnelInfo/tabs/reward-punishment-record.vue
@@ -1,33 +1,31 @@
<!-- 濂栨儵璁板綍 -->
<template>
<div>
- <div style="text-align: left; margin-bottom: 15px;">
- <label>濮撳悕</label>
- <el-input v-model="search.userName" clearable placeholder="璇疯緭鍏ュ叧閿瓧" size="small" style="width: 20vh;"></el-input>
- <label style="margin-left: 1em">濂栨儵鏃ユ湡</label>
- <el-date-picker
- v-model="search.searchTimeList"
- :picker-options="pickerOptions"
- align="right"
- clearable
- end-placeholder="缁撴潫鏃ユ湡"
- format="yyyy-MM-dd"
- range-separator="鑷�"
- size="small"
- start-placeholder="寮�濮嬫棩鏈�"
- style="width: 20%"
- type="daterange"
- unlink-panels
- value-format="yyyy-MM-dd 00:00:00">
- </el-date-picker>
- <el-button size="small" type="primary" @click="getPersonnelTraining(departId)">鏌ヨ</el-button>
- <div style="float: right;">
- <el-button :loading="outLoading" size="small" type="primary" @click="handleDown">瀵煎嚭</el-button>
- <el-button size="small" type="primary" @click="addRow">鏂板</el-button>
+ <div class="view">
+ <div style="display: flex;justify-content: space-between;">
+ <el-form :model="search" ref="page" size="small" :inline="true">
+ <el-form-item label="濮撳悕">
+ <el-input v-model="search.userName" clearable placeholder="璇疯緭鍏ュ叧閿瓧" size="small"
+ style="width: 20vh;"></el-input>
+ </el-form-item>
+ <el-form-item label="濂栨儵鏃ユ湡">
+ <el-date-picker v-model="search.searchTimeList" :picker-options="pickerOptions" align="right" clearable
+ end-placeholder="缁撴潫鏃ユ湡" format="yyyy-MM-dd" range-separator="鑷�" size="small" start-placeholder="寮�濮嬫棩鏈�"
+ style="width: 100%" type="daterange" unlink-panels value-format="yyyy-MM-dd 00:00:00">
+ </el-date-picker>
+ </el-form-item>
+ <el-form-item>
+ <el-button size="small" type="primary" @click="getPersonnelTraining(departId)">鏌ヨ</el-button>
+ </el-form-item>
+ </el-form>
+ <div>
+ <el-button :loading="outLoading" size="small" type="primary" @click="handleDown">瀵煎嚭</el-button>
+ <el-button size="small" type="primary" @click="addRow">鏂板</el-button>
+ </div>
</div>
</div>
<div class="table">
- <el-table :data="tableData" height="70vh" style="width: 100%">
+ <el-table :data="tableData" v-loading="tableLoading" height="66.5vh" style="width: 100%">
<el-table-column label="搴忓彿" type="index" width="120">
<template v-slot="scope">
<span>{{ (search.current - 1) * search.size + scope.$index + 1 }}</span>
@@ -49,24 +47,19 @@
</el-table-column>
<el-table-column label="鍒涘缓浜�" min-width="180" prop="createUserName">
</el-table-column>
- <el-table-column fixed="right" label="鎿嶄綔" width="100">
+ <el-table-column fixed="right" label="鎿嶄綔" width="100" align="center">
<template v-slot="scope">
<el-button size="small" type="text" @click="editForm(scope.row)">缂栬緫</el-button>
- <el-button size="small" type="text" @click="deleteRow(scope.row)">鍒犻櫎</el-button>
+ <el-button size="small" type="text" style="color: #f56c6c" @click="deleteRow(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">
+ :total="search.total" layout="->,total, sizes, prev, pager, next, jumper" background style="margin-top: 10px"
+ @size-change="handleSizeChange" @current-change="handleCurrentChange">
</el-pagination>
</div>
- <el-dialog
- :visible.sync="dialogVisible"
- title="鎻愮ず"
- width="50%"
- @open="getUserList">
+ <el-dialog :visible.sync="dialogVisible" title="濂栨儵璁板綍" width="50%" @open="getUserList">
<div style="height: 40vh">
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-col :span="12">
@@ -77,7 +70,7 @@
<el-col :span="12">
<el-form-item label="鍛樺伐濮撳悕" prop="userId">
<el-select v-model="form.userId" placeholder="璇烽�夋嫨" size="small" style="width: 100%" value-key="id"
- @change="selectUserChange" :disabled="!isDepartment">
+ @change="selectUserChange" :disabled="!isDepartment">
<el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
@@ -95,14 +88,8 @@
</el-col>
<el-col :span="12">
<el-form-item label="濂栨儵鏃堕棿" prop="rewardPunishTime">
- <el-date-picker
- v-model="form.rewardPunishTime"
- format="yyyy-MM-dd HH:mm:ss"
- placeholder="閫夋嫨鏃ユ湡"
- size="small"
- style="width: 100%"
- type="datetime"
- value-format="yyyy-MM-dd HH:mm:ss">
+ <el-date-picker v-model="form.rewardPunishTime" format="yyyy-MM-dd HH:mm:ss" placeholder="閫夋嫨鏃ユ湡"
+ size="small" style="width: 100%" type="datetime" value-format="yyyy-MM-dd HH:mm:ss">
</el-date-picker>
</el-form-item>
</el-col>
@@ -119,14 +106,22 @@
</el-form>
</div>
<span slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false">鍙� 娑�</el-button>
- <el-button type="primary" @click="saveOrUpdate">纭� 瀹�</el-button>
- </span>
+ <el-button @click="dialogVisible = false">鍙� 娑�</el-button>
+ <el-button type="primary" @click="saveOrUpdate">纭� 瀹�</el-button>
+ </span>
</el-dialog>
</div>
</template>
<script>
+import {
+ addOrUpdateRewardPunishment, deleteRewardPunishment,
+ rewardPunishmentExport,
+ rewardPunishmentPage
+} from "@/api/cnas/personal/personRewardPunishmentRecord";
+import { selectUserCondition } from "@/api/system/user";
+import { delCustomById } from "@/api/system/customer";
+
export default {
props: {
departId: {
@@ -143,6 +138,7 @@
data() {
return {
tableData: [],
+ tableLoading: false,
search: {
size: 20,
current: 1,
@@ -213,87 +209,54 @@
this.getPersonnelTraining(this.departId);
},
async getPersonnelTraining() {
- const {code, data} = await this.$axios({
- method: 'get',
- url: rewardPunishmentPageApi,
- params: {
- userId: this.isDepartment ? '' : this.departId,
- departmentId: this.isDepartment ? this.departId : '',
- current: this.search.curent,
- size: this.search.size,
- userName: this.search.userName,
- startTime: this.search.searchTimeList && this.search.searchTimeList[0],
- endTime: this.search.searchTimeList && this.search.searchTimeList[1],
- }
- })
- if (code == 200) {
- this.tableData = data.records
- this.search.total = data.total
+ const params = {
+ userId: this.isDepartment ? '' : this.departId,
+ departmentId: this.isDepartment ? this.departId : '',
+ current: this.search.curent,
+ size: this.search.size,
+ userName: this.search.userName,
+ startTime: this.search.searchTimeList && this.search.searchTimeList[0],
+ endTime: this.search.searchTimeList && this.search.searchTimeList[1],
}
+ this.tableLoading = true
+ rewardPunishmentPage(params).then(res => {
+ this.tableLoading = false
+ this.tableData = res.data.records
+ this.search.total = res.data.total
+ }).catch(err => {
+ this.tableLoading = false
+ })
},
- addRow () {
+ addRow() {
this.dialogVisible = true
if (!this.isDepartment) {
this.form.userId = this.departId
this.selectUserChange(this.form.userId)
}
},
- handleDown(){
+ handleDown() {
this.outLoading = true
- this.$axios.post(this.$api.deviceCheck.rewardPunishmentExport,{
+ rewardPunishmentExport({
userId: this.isDepartment ? '' : this.departId,
departmentId: this.isDepartment ? this.departId : '',
userName: this.search.userName,
startTime: this.search.searchTimeList && this.search.searchTimeList[0],
endTime: this.search.searchTimeList && this.search.searchTimeList[1]
- },{responseType: 'blob'}).then(res => {
+ }).then(res => {
this.outLoading = false
const blob = new Blob([res], {
type: 'application/force-download'
})
- //灏咮lob 瀵硅薄杞崲鎴愬瓧绗︿覆
- 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 elink = document.createElement('a')
- elink.download = decodeURI('濂栨儵璁板綍'+'.xlsx')
- elink.style.display = 'none'
- elink.href = URL.createObjectURL(blob)
- document.body.appendChild(elink)
- elink.click();
- URL.revokeObjectURL(elink.href) // 閲婃斁URL 瀵硅薄
- document.body.removeChild(elink)
- this.$message.success('瀵煎嚭鎴愬姛')
- }
- } catch (err) {
- console.log(err);
- // 鍒涘缓涓�涓秴閾炬帴锛屽皢鏂囦欢娴佽祴杩涘幓锛岀劧鍚庡疄鐜拌繖涓秴閾炬帴鐨勫崟鍑讳簨浠�
- const elink = document.createElement('a')
- elink.download = decodeURI('濂栨儵璁板綍'+'.xlsx')
- elink.style.display = 'none'
- elink.href = URL.createObjectURL(blob)
- document.body.appendChild(elink)
- elink.click();
- URL.revokeObjectURL(elink.href) // 閲婃斁URL 瀵硅薄
- document.body.removeChild(elink)
- this.$message.success('瀵煎嚭鎴愬姛')
- }
- }
+ this.$download.saveAs(blob, '濂栨儵璁板綍.xlsx')
})
},
// 鑾峰彇璐熻矗浜轰俊鎭帴鍙�
getUserList() {
- this.$axios.get(this.$api.deviceScope.selectUserList).then(res => {
+ selectUserCondition().then(res => {
if (res.code == 200) {
this.responsibleOptions = res.data
}
- })
+ });
},
selectUserChange(val) {
const index = this.responsibleOptions.findIndex(item => item.id === val)
@@ -302,42 +265,40 @@
this.form.account = this.responsibleOptions[index].account
}
},
+ // 鎵撳紑琛ㄥ崟寮规
editForm(row) {
this.dialogVisible = true
- this.form = {...row};
+ this.form = { ...row };
},
+ // 鎻愪氦琛ㄥ崟鏁版嵁
saveOrUpdate() {
this.$refs.form.validate(async (valid) => {
if (valid) {
- this.dialogVisible = false
- const {code, data} = await this.$axios({
- method: 'post',
- url: addOrUpdateRewardPunishmentApi,
- data: this.form,
- headers: {
- 'Content-Type': 'application/json'
- },
- noQs: true
- })
- if (code == 200) {
- this.$message.success("鎿嶄綔鎴愬姛锛�")
+ addOrUpdateRewardPunishment(this.form).then(res => {
+ this.dialogVisible = false
+ this.$message.success("鎿嶄綔鎴愬姛")
this.getPersonnelTraining(this.departId);
- }
+ })
}
})
},
- async deleteRow(row) {
- const {code, data} = await this.$axios({
- method: 'delete',
- url: deleteRewardPunishmentApi,
- params: {
- id: row.id
- }
- })
- if (code == 200) {
- this.$message.success("鎿嶄綔鎴愬姛锛�")
- this.getPersonnelTraining(this.departId);
- }
+ deleteRow(row) {
+ this.$confirm('鏄惁鍒犻櫎褰撳墠鏁版嵁?', "璀﹀憡", {
+ confirmButtonText: "纭畾",
+ cancelButtonText: "鍙栨秷",
+ type: "warning"
+ }).then(() => {
+ deleteRewardPunishment({ id: row.id }).then(res => {
+ if (res.code === 500) {
+ return
+ }
+ this.$message.success('鍒犻櫎鎴愬姛')
+ this.getPersonnelTraining(this.departId);
+ }).catch(e => {
+ this.$message.error('鍒犻櫎澶辫触')
+ })
+ }).catch(() => { })
+
}
},
watch: {
--
Gitblit v1.9.3