Your Name
2022-03-14 f5c7ecb8db935bc07169938869e3260b21fda13a
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
<template>
    <div>
        <el-form ref="form" :model="fileForm" label-width="160px" label-position="right">
            <el-form-item label="事故救援预案:">
                <el-upload
                    accept=".pdf,.jpg,.png"
                    :action="fileRoad"
                    class="upload-demo"
                    ref="upload"
                    :headers="header"
                    :data="uploadForm"
                    :on-preview="onPreview"
                    :file-list="fileListOne">
                </el-upload>
            </el-form-item>
<!--            <el-form-item label="作业人员身体健康:">-->
<!--                <el-upload-->
<!--                    accept=".pdf,.jpg,.png"-->
<!--                    :action="fileRoad"-->
<!--                    class="upload-demo"-->
<!--                    ref="upload"-->
<!--                    :headers="header"-->
<!--                    :data="uploadForm"-->
<!--                    :on-preview="onPreview"-->
<!--                    :file-list="fileListTwo">-->
<!--                </el-upload>-->
<!--            </el-form-item>-->
<!--            <el-form-item label="作业资质证书:">-->
<!--                <el-upload-->
<!--                    accept=".pdf,.jpg,.png"-->
<!--                    :action="fileRoad"-->
<!--                    class="upload-demo"-->
<!--                    ref="upload"-->
<!--                    :data="uploadForm"-->
<!--                    :on-preview="onPreview"-->
<!--                    :file-list="fileListThree">-->
<!--                </el-upload>-->
<!--            </el-form-item>-->
        </el-form>
        <el-dialog :visible.sync="dialogVisible">
            <img width="100%" :src="dialogImageUrl" alt="">
        </el-dialog>
    </div>
</template>
 
<script>
import Cookies from 'js-cookie'
import { deleteFile, getFileData } from '../../../../../api/task'
 
export default {
    props:['basicInformation'],
    name: 'index',
    data(){
        return{
            ifApply:'',
            ifCompany:'',
            ifApplyButton:'',
            ifCompanyButton:'',
            disabled:'',
            fileForm:{},
            header:{Authorization:''},
            fileRoad:process.env.BASE_API + '/task/upload',
            dialogVisible:false,
            dialogImageUrl:'',
            riskAndDanger:[],
            safetyOrganizeAction:[],
            workSecurityAction:[],
            fileList:[],
            fileListOne:[],
            fileListTwo:[],
            fileListThree:[],
            uploadForm:{
                taskcode:'',
                type:'',
            }
        }
    },
    mounted(){
        this.getFileList()
    },
    methods:{
        async onPreview(file){
            window.open( process.env.IMG_API + file.fileurl,'_blank')
        },
        async getFileList(){
            let params = {}
            params["taskCode"] = this.basicInformation.code
            let res = await getFileData(params)
            if(res.data.code === '200'){
                this.fileList = []
                this.fileListOne = []
                this.fileListTwo = []
                this.fileListThree = []
                this.fileList = res.data.result
                this.fileList.map(item =>{
                    return Object.assign(item,{name:item.originalname})
                })
                for(let i in this.fileList){
                    if(this.fileList[i].type === '事故救援预案'){
                        this.fileListOne.push(this.fileList[i])
                    }
                }
                for(let i in this.fileList){
                    if(this.fileList[i].type === '作业人员身体健康'){
                        this.fileListTwo.push(this.fileList[i])
                    }
                }
                for(let i in this.fileList){
                    if(this.fileList[i].type === '作业资质证书'){
                        this.fileListThree.push(this.fileList[i])
                    }
                }
            }
        },
        submit(){
            this.uploadForm.type = "事故救援预案"
            this.uploadForm.taskcode = this.basicInformation.code
            this.header.Authorization = Cookies.get('token')
            this.$refs.upload.submit()
        },
        handlePictureCardPreview(file) {
            this.dialogImageUrl = file.url;
            this.dialogVisible = true;
        },
        handleChangeOne(file, fileList) {
            this.uploadForm.type = '事故救援预案'
            this.uploadForm.taskcode = this.basicInformation.code
            this.header.Authorization = Cookies.get('token')
        },
        handleChangeTwo(file, fileList) {
            this.uploadForm.type = '作业人员身体健康';
            this.uploadForm.taskcode = this.basicInformation.code
            this.header.Authorization = Cookies.get('token')
        },
        handleChangeThree(file, fileList) {
            this.uploadForm.type = '作业资质证书';
            this.uploadForm.taskcode = this.basicInformation.code
            this.header.Authorization = Cookies.get('token')
        },
        onSuccess(response){
            if(response.code === '200'){
                this.$notify({
                    type:'success',
                    duration:2000,
                    message:'上传成功',
                    title:'成功',
                })
                this.getFileList()
            }
        },
        onRemove(file,fileList){
            return this.$confirm(`确定移除 ${ file.name }?`,'提示',{
                confirmButtonText:'确定',
                cancelButtonText:'取消',
                type:'warning',
            }).then(() =>{
                let params = {}
                params["id"] = file.id
                deleteFile(params).then(res =>{
                    if(res.data.code === '200'){
                        this.$notify({
                            type:'success',
                            duration:2000,
                            message:'删除成功',
                            title:'成功',
                        })
                        this.getFileList()
                    }else{
                        this.$message({
                            type:'warning',
                            message:res.data.message
                        })
                    }
                })
            })
        },
        handleRemove(file,value) {
            return this.$confirm(`确定移除 ${ file.name }?`,'提示',{
                confirmButtonText:'确定',
                cancelButtonText:'取消',
                type:'warning',
            }).then(()=> {
                switch (value) {
                    case 'one':this.riskAndDanger.splice(this.riskAndDanger.findIndex(item =>item.name === file.name),1);
                        break;
                    case 'two':this.safetyOrganizeAction.splice(this.safetyOrganizeAction.findIndex(item =>item.name === file.name),1);
                        break;
                    case 'three':this.workSecurityAction.splice(this.workSecurityAction.findIndex(item =>item.name === file.name),1);
                        break;
                    case 'four':this.operationQualification.splice(this.operationQualification.findIndex(item =>item.name === file.name),1);
                        break;
                    case 'five':this.escortCompany.splice(this.escortCompany.findIndex(item =>item.name === file.name),1);
                        break;
                    case 'six':this.insurance.splice(this.insurance.findIndex(item =>item.name === file.name),1);
                        break;
                    case 'seven':this.safetyProduction.splice(this.safetyProduction.findIndex(item =>item.name === file.name),1);
                        break;
                }
            })
        },
    }
}
</script>
 
<style scoped>
 
</style>