Your Name
2022-04-08 1f2a259f8cbb7eb0b12d12895116c309eb8cd609
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
<template>
    <el-dialog
    :visible.sync="workLicenseDialog"
    :close-on-click-modal="false"
    title="工作证"
    width="60%"
    >
        <div class="app-container">
            <div class="filter-container">
                <div class="basic_search">
                    <el-button type="primary" @click="showLicenseForm('','新增')">新增</el-button>
                    <el-button type="primary" icon="el-icon-search">查询</el-button>
                </div>
            </div>
            <div class="table_content">
                <el-table :data="workLicenseData" v-loading="listLoading" :key="tableKey" fit border highlight-current-row style="width: 100%;">
                    <el-table-column type="index" label="" align="center" width="60"/>
                    <el-table-column label="姓名" prop="realname" align="center" sortable="custom">
                    </el-table-column>
                    <el-table-column label="手机号" prop="mobile" align="center" sortable="custom">
                    </el-table-column>
                    <el-table-column label="身份证" prop="idcard" align="center" sortable="custom">
                    </el-table-column>
                    <el-table-column label="特殊作业工种" prop="branch" align="center" sortable="custom">
                    </el-table-column>
                    <el-table-column label="特殊作业证件号" prop="certname" align="center" sortable="custom">
                    </el-table-column>
                    <el-table-column label="文件路径" prop="certpath" align="center" sortable="custom">
                        <template slot-scope="scope">
                            <a :href="baseUrl+scope.row.certpath" target="_blank">{{baseUrl+scope.row.url}}</a>
                        </template>
                    </el-table-column>
                    <el-table-column label="有效期开始时间" prop="starttime" align="center" >
                    </el-table-column>
                    <el-table-column label="有效期结束时间" prop="endtime" align="center" >
                    </el-table-column>
                    <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width">
                        <template slot-scope="scope">
                            <el-button type="text" @click="showLicenseForm(scope.row,'编辑')">编辑</el-button>
                            <el-button type="text" style="color: red" @click="deleteById(scope.row)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
        </div>
        <el-dialog
            :visible.sync="LicenseFormDialog"
            :close-on-click-modal="false"
            :append-to-body="true"
            :title="title"
            width="30%"
        >
            <el-form ref="licenseForm" :rules="licenseRules" :model="licenseForm" label-position="right" label-width="150px" style="padding-right: 50px" element-loading-text="保存中...">
                <el-form-item label="真实姓名:" prop="realname">
                    <el-input v-model.trim="licenseForm.realname" :disabled="true"/>
                </el-form-item>
                <el-form-item label="联系方式:" prop="mobile">
                    <el-input v-model.trim="licenseForm.mobile" :disabled="true"/>
                </el-form-item>
                <el-form-item label="身份证:" prop="idcard">
                    <el-input v-model.trim="licenseForm.idcard" :disabled="true"/>
                </el-form-item>
                <el-form-item label="特种作业工种:" prop="branch">
                    <el-select v-model.trim="licenseForm.branch">
                    <el-option
                        v-for="item in branchList"
                        :key="item.id"
                        :label="item.name"
                        :value="item.name"
                    >
                    </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="特种作业证件号:" prop="certname">
                    <el-input v-model.trim="licenseForm.certname"/>
                </el-form-item>
                <el-form-item label="受否人员安全健康证:" prop="ishealth">
                    <el-select v-model.trim="licenseForm.ishealth">
                        <el-option
                        v-for="item in isHealthList"
                        :key="item.id"
                        :value="item.id"
                        :label="item.name"
                        >
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="有效期开始时间:" prop="starttime">
                    <el-date-picker
                        value-format="yyyy-MM-dd"
                        v-model="licenseForm.starttime"
                        type="date"
                        placeholder="选择日期时间">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="有效期结束时间:" prop="endtime">
                    <el-date-picker
                        value-format="yyyy-MM-dd"
                        v-model="licenseForm.endtime"
                        type="date"
                        placeholder="选择日期时间">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="文件:" prop="upload">
                    <input id="upload" ref="upload"  type="file"/>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="LicenseFormDialog = false">取消</el-button>
                <el-button  type="primary" @click="submit()">确定</el-button>
            </div>
        </el-dialog>
    </el-dialog>
</template>
 
<script>
import { addWorkLicense, deleteWorkLicense, getWorkLicenseList, updateWorkLicense } from '@/api/user'
import { parseError } from '@/utils/messageDialog'
 
export default {
    name: 'index',
    data(){
        return{
            baseUrl: process.env.IMG_API,
            title:'',
            tableKey:'',
            mobile:'',
            listLoading:false,
            workLicenseData:[],
            isHealthList:[{id:1,name:'是'},{id:0,name:'否'},],
            branchList:[{id:1,name:'电工作业'},{id:2,name:'焊接与热切割作业'},{id:3,name:'高处作业'},{id:4,name:'制冷与空调作业'},{id:5,name:'煤矿安全作业'},{id:6,name:'压力容器作业'},{id:7,name:'采掘(剥)作业'},{id:8,name:'矿山提升运输作业'},{id:9,name:'矿山安全检查作业'},{id:10,name:'矿山通风作业'},{id:11,name:'矿山排水作业'},],
            workLicenseDialog:false,
            LicenseFormDialog:false,
            licenseForm:{
                id:'',
                realname:'',
                mobile:'',
                idcard:'',
                certname:'',
                starttime:'',
                endtime:'',
                branch:'',
                ishealth:0,
            },
            licenseRules:{
 
            }
        }
    },
    methods:{
        openWorkLicense(row){
            this.workLicenseDialog = true
            this.licenseForm.realname = row.realname
            this.licenseForm.mobile = row.username
            this.licenseForm.idcard = row.idcard
            this.licenseForm.branch = row.branch
            this.getWorkLicenseData()
        },
        async getWorkLicenseData(){
            let res = await getWorkLicenseList(this.licenseForm.mobile)
            if(res.data.code === '200'){
                this.workLicenseData  = res.data.result
            }else{
                this.$message({
                    type:'warning',
                    message:res.data.message
                })
            }
        },
        showLicenseForm(value,type){
            this.LicenseFormDialog = true
            if(type === '新增'){
                this.licenseForm.certname = ''
                this.licenseForm.starttime = ''
                this.licenseForm.endtime = ''
                this.licenseForm.branch = ''
                this.licenseForm.ishealth = 0
                this.title = '新增'
            }else{
                this.title = '编辑'
                this.licenseForm = value
            }
        },
        submit(){
            if(this.title === '新增'){
                const formData = new FormData();
                for (const i in this.licenseForm) {
                    if (
                        this.licenseForm[i] != undefined &&
                        this.licenseForm[i].toString() != ""
                    ) {
                        formData.append(i, this.licenseForm[i]);
                    }
                }
                if(this.$refs["upload"].files.length !== 0){
                    formData.append('file', this.$refs["upload"].files[0])
                }
                addWorkLicense(formData).then(res =>{
                    if(res.data.code === '200'){
                        this.LicenseFormDialog = false
                        this.getWorkLicenseData()
                        this.$notify({
                            title:'成功',
                            message:'新增成功',
                            duration:2000,
                            type:'success'
                        })
                    }else{
                        this.$message({
                            type:'warning',
                            message:res.data.message
                        })
                    }
                }).catch(error => {
                    parseError({ error: error, vm: this })
                })
            }else{
                const formData = new FormData();
                for (const i in this.licenseForm) {
                    if (
                        this.licenseForm[i] != undefined &&
                        this.licenseForm[i].toString() != ""
                    ) {
                        formData.append(i, this.licenseForm[i]);
                    }
                }
                if(this.$refs["upload"].files.length !== 0){
                    formData.append('file', this.$refs["upload"].files[0])
                }
                updateWorkLicense(formData).then(res =>{
                    if(res.data.code === '200'){
                        this.LicenseFormDialog = false
                        this.getWorkLicenseData()
                        this.$notify({
                            type:'success',
                            message:'新增成功',
                            duration:2000,
                            title:'成功'
                        })
                    }else{
                        this.$message({
                            message:res.data.message,
                            type:'warning'
                        })
                    }
                }).catch(error =>{
                    parseError({error:error,vm:this})
                })
            }
        },
        deleteById(row){
            this.$confirm('删除此条工作证,是否继续','提示',{
                confirmButtonText:'确定',
                cancelButtonText:'取消',
                type:'warning',
            }).then(()=> {
                deleteWorkLicense({id:row.id}).then( ()=>{
                    this.getWorkLicenseData()
                    this.$notify({
                        title:'成功',
                        message:'删除成功',
                        type:'success',
                        duration:2000,
                    })
                })
            }).catch(error => parseError({error:error, vm:this}))
        }
    }
}
</script>
 
<style scoped>
 
</style>