licp
2024-12-19 97c857f75a9ef32489678e8dd5925472e9c7a9d1
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
<template>
    <div class="flex_column">
        <TableCard title="任职授权记录" :showForm="isDepartment">
            <template v-slot:form>
                <div class="w100 items_center justify_between" v-if="isDepartment">
                    <div></div>
                    <div>
                        <el-button type="primary" size="small" @click="openDialog">新增</el-button>
                    </div>
                </div>
            </template>
            <template v-slot:table>
                <ZTTable
                    style="margin-top: 18px; padding: 0 15px;"
                    :height="'calc(100vh - 21em)'"
                    :column="columnData"
                    :table-data="tableData"
                    :table-loading="loading"
                ></ZTTable>
                <el-divider></el-divider>
                <div class="pagination">
                    <div></div>
                    <el-pagination
                        :page-sizes="[10, 20, 30, 40]"
                        :page-size="pagination.pageSize"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="pagination.total"
                        @current-change="currentChange"
                        @size-change="sizeChange"
                    >
                    </el-pagination>
                </div>
            </template>
        </TableCard>
        <Add ref="mandateModal" @refresh="getTableData"></Add>
    </div>
</template>
<script>
import TableCard from "../../../TableCard/index.vue"
import ZTTable from "../../../ZTTable/index.vue"
import Add from "./Add.vue"
import {
    getPersonPostAuthorizationRecordPage,
    deletePersonPostAuthorizationRecord
} from "../../../../../assets/api/api"
import { nextTick } from "vue";
 
export default {
    components: {
        TableCard,
        ZTTable,
        Add
    },
  props: {
    departId: {
      type: Number,
      default: () => {
        return null;
      }
    },
    isDepartment: {
      type: Boolean,
      default: false
    }
  },
    data() {
        return {
            // departId: 0,
            columnData: [
                {
                    label: '序号',
                    prop: 'id'
                }, {
                    label: '证书编号',
                    prop: 'certificateNumber'
                }, {
                    label: '被任职人员',
                    prop: 'userName'
                }, {
                    label: '任职岗位',
                    prop: 'post'
                }, {
                    label: '理论考试成绩',
                    prop: 'num1'
                },{
                    label: '操作技能考试成绩',
                    prop: 'num2'
                },{
                    label: '操作时间',
                    prop: 'updateTime'
                }, {
                    label: '备注',
                    prop: 'remarks',
                    width: 300
                }, {
                    label: '操作',
                    dataType: 'action',
                    width: 160,
                    operation: [
                        {
                            name: '编辑',
                            type: 'text',
                            clickFun: (row) => {
                                this.openDialog(row, true)
                            }
                        }, {
                            name: '下载',
                            type: 'text',
                            clickFun: (row) => {
                                this.handleDown(row)
                            }
                        }, {
                            name: '删除',
                            type: 'text',
                            color: '#f56c6c',
                            clickFun: (row) => {
                                this.deleteNotify(row.id)
                            }
                        }
                    ]
                },
            ],
            tableData: [],
            pagination: {
                current: 1,
                pageSize: 20,
                total: 0
            },
            loading: false
        }
    },
    mounted() {
      this.getTableData()
        console.log(this.departId)
    },
    methods: {
        openDialog(row, type=false) {
            this.$refs.mandateModal.openDialog(row, type)
        },
        /**
         * @desc 查询表格数据
         */
        async getTableData() {
            this.loading = true
            await nextTick()
          const params = this.isDepartment ? {
            departLimsId: this.departId,
            current: this.pagination.current,
            size: this.pagination.pageSize
          } : {
            userId: this.departId,
            current: this.pagination.current,
            size: this.pagination.pageSize
          }
            const { code, data } = await this.$axios({
                method: 'get',
                url: getPersonPostAuthorizationRecordPage,
                params: params
            })
            if(code == 200) {
                this.pagination.total = data.total
                this.tableData = data.records
                this.loading = false
            }
        },
        /**
         * @desc 当前页改变
         */
        currentChange(current) {
            this.pagination.current = current
            this.getTableData()
        },
        /**
         * @desc 每页个数改变
         */
        sizeChange(pageSize) {
            this.pagination.pageSize = pageSize
            this.getTableData()
        },
        /**
         * @desc 删除任职记录
         */
        deleteNotify(id) {
            this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.delMandate(id)
            })
        },
        /**
         * @desc api删除
         */
        async delMandate(id) {
            const formData = new FormData()
            formData.append('id', id)
            const { code, data } = await this.$axios({
                method: 'delete',
                url: deletePersonPostAuthorizationRecord,
                data: formData,
                noQs: true
            })
            if(code == 200) {
                this.$message({ message: '删除成功', type: 'success' })
                this.getTableData()
            } else {
                this.$message({ message: '删除失败', type: 'error' })
            }
        },
        /**
         * @desc 获取设备id
         */
        getDepart(id) {
            this.departId = id
            this.getTableData()
        },
        handleDown(row){
          this.$axios.post(this.$api.personPostAuthorizationRecord.exportPersonPostAuthorizationRecord,{id:row.id},{responseType: "blob"}).then(res => {
            if(res.code == 201){
              this.$message.error(res.message)
              return
            }
            this.$message.success('下载成功')
            const blob = new Blob([res],{ type: 'application/octet-stream' });
            const url = URL.createObjectURL(blob);
            const link = document.createElement('a');
            link.href = url;
            link.download = '任职授权-'+row.certificateNumber+'-'+row.post + '.docx';
            link.click();
          })
        }
    },
//   watch: {
//     departId: {
//       handler(newId, oldId) {
//         if (newId) {
//           this.getTableData();
//         }
//       }
//     }
//   }
}
</script>
<style scoped>
.flex_column {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.w100 {
    width: 100%;
}
.pagination {
    display: flex;
    justify-content: space-between
}
.items_center {
    display: flex;
    align-items: center;
}
.justify_between {
    justify-content: space-between
}
</style>