From c819024e241b9f7c54cc3786373ad0d2998f2190 Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: 星期五, 05 五月 2023 08:55:46 +0800
Subject: [PATCH] 修改

---
 src/views/specialWorkManage/workTicket/workApply/components/plate.vue |  268 ++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 192 insertions(+), 76 deletions(-)

diff --git a/src/views/specialWorkManage/workTicket/workApply/components/plate.vue b/src/views/specialWorkManage/workTicket/workApply/components/plate.vue
index 41cfaff..c28ce17 100644
--- a/src/views/specialWorkManage/workTicket/workApply/components/plate.vue
+++ b/src/views/specialWorkManage/workTicket/workApply/components/plate.vue
@@ -4,53 +4,54 @@
 		<el-form :model="form" label-width="150px" :rules="applyRules" ref="ruleFormRef">
 			<div class="homeCard">
 			<el-row>
-				<el-col :span="12">
-					<el-form-item label="作业人" prop="operatorUids">
-						<el-select v-model="form.operatorUids" multiple>
-							<el-option
-									v-for="item in workerList"
-									:key="item.uid"
-									:label="item.username"
-									:value="item.uid"
-							/>
-						</el-select>
-					</el-form-item>
-				</el-col>
                 <el-col :span="12">
-                    <el-form-item label="危险辨识" prop="hazardIdentification">
+                    <el-form-item label="施工单位" prop="operatorCompanys">
                         <el-input
-                            v-model="form.hazardIdentification"
-                            autosize
-                            type="textarea"
-                            placeholder="请输入危险辨识"
+                            v-model="form.operatorCompanys"
+                            placeholder="请输入施工单位"
                         />
                     </el-form-item>
                 </el-col>
-			</el-row>
-			<el-row>
 				<el-col :span="12">
-					<el-form-item label="作业等级" prop="workLevel">
-						<el-select v-model="form.workLevel">
-							<el-option
-									v-for="item in workLevelList"
-									:key="item.value"
-									:label="item.label"
-									:value="item.value"
-							/>
-						</el-select>
+					<el-form-item label="作业人" prop="operatorUnames">
+<!--						<el-select v-model="form.operatorUnames" multiple>-->
+<!--							<el-option-->
+<!--									v-for="item in workerList"-->
+<!--									:key="item.id"-->
+<!--									:label="item.realname + '(' + item.username.toString().replace(/^(\d{3})\d{4}(\d{4})$/,'$1****$2') + ')'"-->
+<!--									:value="item.id"-->
+<!--							/>-->
+<!--						</el-select>-->
+                        <el-input
+                            v-model="form.operatorUnames"
+                            placeholder="请输入作业人"
+                        />
 					</el-form-item>
 				</el-col>
+			</el-row>
+			<el-row>
                 <el-col :span="12">
                     <el-form-item label="作业时间" prop="workTimeLine">
                         <el-date-picker
                             v-model="form.workTimeLine"
-                            format="yyyy-MM-dd HH:mm:ss"
                             value-format="yyyy-MM-dd HH:mm:ss"
                             type="datetimerange"
                             range-separator="至"
                             start-placeholder="开始时间"
                             end-placeholder="结束时间"
                         />
+                    </el-form-item>
+                </el-col>
+                <el-col :span="12">
+                    <el-form-item label="作业等级" prop="workLevel">
+                        <el-select v-model="form.workLevel">
+                            <el-option
+                                v-for="item in workLevelList"
+                                :key="item.value"
+                                :label="item.label"
+                                :value="item.value"
+                            />
+                        </el-select>
                     </el-form-item>
                 </el-col>
 			</el-row>
@@ -76,8 +77,19 @@
 					</el-form-item>
 				</el-col>
 			</el-row>
-
-
+            <el-row>
+                <el-col :span="12">
+                    <el-form-item label="危险辨识" prop="hazardIdentification">
+                        <el-input
+                            v-model="form.hazardIdentification"
+                            autosize
+                            type="textarea"
+                            placeholder="请输入危险辨识"
+                        />
+                    </el-form-item>
+                </el-col>
+            </el-row>
+                <el-divider border-style="dashed"/>
 			<el-row>
 				<el-col :span="12">
 					<el-form-item label="盲板编号" prop="workDetail.bpCode">
@@ -151,8 +163,7 @@
 					<el-form-item label="盲板时间" prop="workDetail.installLine">
 						<el-date-picker
 								v-model="form.workDetail.installLine"
-								format="YYYY-MM-DD HH:mm"
-								value-format="YYYY-MM-DD HH:mm:00"
+								value-format="yyyy-MM-dd HH:mm:ss"
 								type="datetimerange"
 								range-separator="--"
 								start-placeholder="装盲板时间"
@@ -160,18 +171,18 @@
 						/>
 					</el-form-item>
 				</el-col>
+                <el-col :span="12">
+                    <el-form-item label="盲板位置" prop="workDetail.bpLocation">
+                        <el-input
+                            v-model="form.workDetail.bpLocation"
+                            autosize
+                            type="textarea"
+                            placeholder="请输入"
+                        />
+                    </el-form-item>
+                </el-col>
 			</el-row>
 			<el-row>
-				<el-col :span="12">
-					<el-form-item label="盲板位置" prop="workDetail.bpLocation">
-						<el-input
-								v-model="form.workDetail.bpLocation"
-								autosize
-								type="textarea"
-								placeholder="请输入"
-						/>
-					</el-form-item>
-				</el-col>
 				<el-col :span="12">
 					<el-form-item label="关联作业" prop="workDetail.otherSpecialWork">
 						<el-select v-model="form.workDetail.otherSpecialWork" multiple>
@@ -185,18 +196,49 @@
 					</el-form-item>
 				</el-col>
 			</el-row>
-			<el-row>
-				<el-col :span="24">
-					<el-form-item label="盲板位置图" prop="workDetail.bpLocationMapPath">
-						<el-upload accept="image/*" :on-exceed="showTip" :on-preview="handlePictureCardPreview" :limit='imgLimit' v-model:file-list="fileList" :http-request="upload" :action="uploadUrl" list-type="picture-card" :on-remove="handleRemove" :before-remove="beforeRemove" :before-upload="getUploadUrl">
-							<el-icon><Plus /></el-icon>
-							<template #tip>
-								<div class="el-upload__tip">上传jpg/png图片尺寸小于500KB,最多可上传5张</div>
-							</template>
-						</el-upload>
-					</el-form-item>
-				</el-col>
-			</el-row>
+                <el-row>
+                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
+                        <el-form-item label="隐患上报图" prop="img">
+                            <el-upload
+                                accept=".pdf,.jpg,.png"
+                                :action="fileRoad"
+                                class="upload-demo"
+                                ref="upload"
+                                :headers="header"
+                                :data="uploadForm"
+                                list-type="picture-card"
+                                :file-list="fileList"
+                                v-model="form.workDetail.bpLocationMapPath"
+                                :on-change="handleChangeFile"
+                                :on-success="onFileSuccess"
+                                :multiple="false"
+                                :auto-upload="true">
+                                <i slot="default" class="el-icon-plus"></i>
+                                <div slot="file" slot-scope="{file}">
+                                    <img
+                                        class="el-upload-list__item-thumbnail"
+                                        :src="file.url" alt=""
+                                    >
+                                    <span class="el-upload-list__item-actions">
+                                <span
+                                    class="el-upload-list__item-preview"
+                                    @click="handleFile(file)"
+                                >
+                                  <i class="el-icon-zoom-in"></i>
+                                </span>
+                                <span
+                                    v-if="!disabled"
+                                    class="el-upload-list__item-delete"
+                                    @click="handleRemove(file,file.$index)"
+                                >
+                                  <i class="el-icon-delete"></i>
+                                </span>
+                              </span>
+                                </div>
+                            </el-upload>
+                        </el-form-item>
+                    </el-col>
+                </el-row>
 			</div>
 		</el-form>
 		<div class="applyBtn">
@@ -210,14 +252,28 @@
 </template>
 
 <script>
-	export default{
+	import {workApplyApi} from "../../../../../api/workApply";
+    import Cookies from "_js-cookie@2.2.0@js-cookie";
+
+    export default{
 		name: 'brokenForm',
 		components: {},
 		props:['workerList'],
         data(){
             return{
+                fileRoad:process.env.BASE_API + '/task/web/upload',
+                uploadForm:{
+                },
+                header:{Authorization:''},
+                disabled:false,
                 form: {
-                    operatorUids: [],
+                    fileRoad:process.env.BASE_API + '/task/web/upload',
+                    uploadForm:{
+                    },
+                    header:{Authorization:''},
+                    disabled:false,
+                    operatorCompanys: '',
+                    operatorUnames: '',
                     workType: 8,
                     workLevel: null,
                     workContent: '',
@@ -317,9 +373,10 @@
                     }
                 ],
                 applyRules:{
-                    operatorUids: [{ required: true, message: '该内容不能为空', trigger: 'change' }],
+                    operatorCompanys: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
+                    operatorUnames: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                     workType: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
-                    workLevel: [{ required: true, message: '该内容不能为空', trigger: 'change' }],
+                    workLevel: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                     workContent: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                     workLocation: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                     workTimeLine: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
@@ -337,41 +394,100 @@
             }
         },
         methods:{
-            async submitForm(formEl) {
-                if (!formEl) return
-                await formEl.validate(async (valid, fields) => {
+            submitForm(formEl) {
+                this.$refs["ruleFormRef"].validate(async (valid, fields) => {
                     if (valid) {
-                        state.form.expStartTime = JSON.parse(JSON.stringify(state.form.workTimeLine))[0]
-                        state.form.expEndTime = JSON.parse(JSON.stringify(state.form.workTimeLine))[1]
-                        state.form.workDetail.installBpTime = JSON.parse(JSON.stringify(state.form.workDetail.installLine))[0]
-                        state.form.workDetail.uninstallBpTime = JSON.parse(JSON.stringify(state.form.workDetail.installLine))[1]
-                        let { workTimeLine, ...data } = JSON.parse(JSON.stringify(state.form))
-                        let { installLine, ...data2 } = JSON.parse(JSON.stringify(state.form.workDetail))
+                        this.form.expStartTime = JSON.parse(JSON.stringify(this.form.workTimeLine))[0]
+                        this.form.expEndTime = JSON.parse(JSON.stringify(this.form.workTimeLine))[1]
+                        this.form.workDetail.installBpTime = JSON.parse(JSON.stringify(this.form.workDetail.installLine))[0]
+                        this.form.workDetail.uninstallBpTime = JSON.parse(JSON.stringify(this.form.workDetail.installLine))[1]
+                        let { workTimeLine, ...data } = JSON.parse(JSON.stringify(this.form))
+                        let { installLine, ...data2 } = JSON.parse(JSON.stringify(this.form.workDetail))
                         data.workDetail = data2
                         data.workDetail.otherSpecialWork = data.workDetail.otherSpecialWork.join(',')
-                        data.workDetail.bpLocationMapPath = data.workDetail.bpLocationMapPath.join(',')
+                        data.workDetail.bpLocationMapPath = JSON.stringify(this.fileList.map(item => { return item.url.substring(process.env.IMG_API.length) }))
                         data.workDetail.temperature = Number(data.workDetail.temperature)
                         data.workDetail.pressure = Number(data.workDetail.pressure)
                         const res = await workApplyApi().postPlateApply(data)
                         if (res.data.code === '200') {
-                            ElMessage({
+                            this.$message({
                                 type: 'success',
                                 message: '提交成功!'
                             });
-                            formEl.resetFields()
-                            state.form.workDetail.bpLocationMapPath = []
-                            state.fileList = []
+                            this.$refs["ruleFormRef"].clearValidate()
+                            this.form = {
+                                operatorCompanys: '',
+                                operatorUnames: '',
+                                workType: 8,
+                                workLevel: null,
+                                workContent: '',
+                                workLocation: '',
+                                workDetail:{
+                                    bpCode: '',
+                                    mainMedia: '',
+                                    temperature: null,
+                                    pressure: null,
+                                    bpMaterialQuality: '',
+                                    bpSpecification: '',
+                                    bpLocation: '',
+                                    bpLocationMapPath: [],
+                                    installLine: [],
+                                    installBpTime: '',
+                                    uninstallBpTime: '',
+                                    hazardIdentification: '',
+                                    otherSpecialWork: []
+                                },
+                                workTimeLine: [],
+                                expStartTime: '',
+                                expEndTime: ''
+                            }
+                            this.fileList = []
                         } else {
-                            ElMessage({
+                            this.$message({
                                 type: 'warning',
-                                message: res.data.msg
+                                message: res.data.message
                             });
                         }
                     } else {
                         console.log('error submit!', fields)
                     }
                 })
-            }
+            },
+            handleChangeFile(){
+                this.header.Authorization = Cookies.get('token')
+            },
+            onFileSuccess(response){
+                if(response.code === '200'){
+                    this.fileList.push({url:process.env.IMG_API + response.result.path})
+                    this.$notify({
+                        type:'success',
+                        duration:2000,
+                        message:'上传成功',
+                        title:'成功',
+                    })
+                }else{
+                    this.$message({
+                        message:res.data.message,
+                        type:'warning'
+                    })
+                }
+            },
+            handleFile(file){
+                this.dialogImageUrl = file.url;
+                this.dialogVisible = true;
+            },
+            showImg(file){
+                window.open(file, '_blank')
+            },
+            handleRemove(file,value){
+                return this.$confirm(`确定移除 ${ file.uid }?`,'提示',{
+                    confirmButtonText:'确定',
+                    cancelButtonText:'取消',
+                    type:'warning',
+                }).then(()=> {
+                    this.fileList.splice(value,1)
+                })
+            },
         },
 	};
 </script>

--
Gitblit v1.9.2