From 23f1bf22c42a904c05cee63e10c9fd8b60dfe8f5 Mon Sep 17 00:00:00 2001
From: Admin <978517621@qq.com>
Date: 星期二, 20 九月 2022 14:54:56 +0800
Subject: [PATCH] Default Changelist

---
 src/views/specialWorkSystem/workTicket/workApply/components/plate.vue |  121 +++++++++++++++++++++++++--------------
 1 files changed, 77 insertions(+), 44 deletions(-)

diff --git a/src/views/specialWorkSystem/workTicket/workApply/components/plate.vue b/src/views/specialWorkSystem/workTicket/workApply/components/plate.vue
index 16b94cc..6bb7136 100644
--- a/src/views/specialWorkSystem/workTicket/workApply/components/plate.vue
+++ b/src/views/specialWorkSystem/workTicket/workApply/components/plate.vue
@@ -16,20 +16,6 @@
 						</el-select>
 					</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>
-				</el-col>
 				<el-col :span="12">
 					<el-form-item label="作业时间" prop="workTimeLine">
 						<el-date-picker
@@ -46,6 +32,18 @@
 			</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>
+				</el-col>
+				<el-col :span="12">
 					<el-form-item label="作业内容" prop="workContent">
 						<el-input
 								v-model="form.workContent"
@@ -55,6 +53,8 @@
 						/>
 					</el-form-item>
 				</el-col>
+			</el-row>
+			<el-row>
 				<el-col :span="12">
 					<el-form-item label="作业地址" prop="workLocation">
 						<el-input
@@ -65,9 +65,16 @@
 						/>
 					</el-form-item>
 				</el-col>
+				<el-col :span="12">
+					<el-form-item label="危害辨识" prop="hazardIdentification">
+						<el-input
+								v-model="form.hazardIdentification"
+								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">
@@ -181,7 +188,7 @@
 						<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>
+								<div class="el-upload__tip">上传jpg/png图片尺寸小于500KB,最多可上传3张</div>
 							</template>
 						</el-upload>
 					</el-form-item>
@@ -221,6 +228,7 @@
 		dialogVisible: Boolean,
 		dialogImageUrl: string | null,
 		imgLimit: number,
+		isOverSize: boolean
 	}
 	interface file {
 		url: string;
@@ -239,6 +247,7 @@
 					workLevel: null,
 					workContent: '',
 					workLocation: '',
+					hazardIdentification: '',
 					workDetail:{
 						bpCode: '',
 						mainMedia: '',
@@ -257,8 +266,9 @@
 					expStartTime: '',
 					expEndTime: ''
 				},
+				isOverSize: false,
 				fileList: [],
-				imgLimit: 5,
+				imgLimit: 3,
 				uploadUrl: '',
 				dialogVisible: false,
 				dialogImageUrl: null,
@@ -340,6 +350,7 @@
 				workLevel: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
 				workContent: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
 				workLocation: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
+				hazardIdentification: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
 				workTimeLine: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
 				"workDetail.bpCode": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
 				"workDetail.mainMedia": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
@@ -396,10 +407,20 @@
 			};
 
 			const getUploadUrl = async (rawFile: any) => {
-				const res = await workApplyApi().getUploadUrl(rawFile.name);
-				state.form.workDetail.bpLocationMapPath.push(res.data.data.fileName)
-				state.uploadUrl = res.data.data.uploadUrl;
-				console.log(res.data.data.fileName,'name')
+				const fileSize = rawFile.size / 1024 < 500 ? '1' : '0'
+				if(fileSize === '0'){
+					ElMessage({
+						type: 'warning',
+						message: '文件大小不能超过500k。'
+					});
+					state.isOverSize = true
+					return false
+				}else{
+					const res = await workApplyApi().getUploadUrl(rawFile.name);
+					state.form.workDetail.bpLocationMapPath.push(res.data.data.fileName)
+					state.uploadUrl = res.data.data.uploadUrl;
+					console.log(res.data.data.fileName,'name')
+				}
 			};
 
 			const upload = async (params: any) => {
@@ -423,39 +444,51 @@
 
 			const beforeRemove = (file: {}, fileList: []) => {
 				const result = new Promise((resolve, reject) => {
-					ElMessageBox.confirm('此操作将删除该图片, 是否继续?', '提示', {
-						confirmButtonText: '确定',
-						cancelButtonText: '取消',
-						type: 'warning'
-					})
-							.then(() => {
-								// console.log(state.workDetail.bpLocationMapPath,'path')
-								const list = JSON.parse(JSON.stringify(state.form.workDetail.bpLocationMapPath))
-								fileList.map((item,index)=>{
-									if(item.uid === file.uid){
-										fileList.splice(index,1)
-										state.form.workDetail.bpLocationMapPath.splice(index,1)
-										deletePic(list[index])
-									}
+					if(!state.isOverSize){
+						ElMessageBox.confirm('此操作将删除该图片, 是否继续?', '提示', {
+							confirmButtonText: '确定',
+							cancelButtonText: '取消',
+							type: 'warning'
+						})
+								.then(() => {
+									// console.log(state.workDetail.bpLocationMapPath,'path')
+									const list = JSON.parse(JSON.stringify(state.form.workDetail.bpLocationMapPath))
+									fileList.map((item,index)=>{
+										if(item.uid === file.uid){
+											fileList.splice(index,1)
+											state.form.workDetail.bpLocationMapPath.splice(index,1)
+											deletePic(false,list[index])
+										}
+									})
+									// 请求删除接口
 								})
-								// 请求删除接口
-							})
-							.catch(() => {
-								reject(false);
-							});
+								.catch(() => {
+									reject(false);
+								});
+					}else{
+						const list = JSON.parse(JSON.stringify(state.form.workDetail.bpLocationMapPath))
+						fileList.map((item,index)=>{
+							if(item.uid === file.uid){
+								fileList.splice(index,1)
+								state.form.workDetail.bpLocationMapPath.splice(index,1)
+								deletePic(true,list[index])
+							}
+						})
+						state.isOverSize = false
+					}
 				});
 				return result;
 			};
 
 
 			// 删除图片接口
-			const deletePic = async(fileName)=>{
+			const deletePic = async(isOverSize:boolean,fileName:string)=>{
 				console.log(fileName,'fileName')
 				const res = await workApplyApi().deleteFile({fileName: fileName})
 				if (res.data.code === '200') {
 					ElMessage({
-						type: 'success',
-						message: '删除成功!'
+						type: isOverSize ? 'error' : 'success',
+						message: isOverSize ? '上传失败':'删除成功!'
 					});
 				} else {
 					ElMessage({

--
Gitblit v1.9.2