From 4d8db47ca6e8ad9986fa80f7b5819646ea494d98 Mon Sep 17 00:00:00 2001
From: Admin <978517621@qq.com>
Date: Fri, 30 Sep 2022 09:58:21 +0800
Subject: [PATCH] Default Changelist
---
src/views/specialWorkSystem/workTicket/workApply/components/plate.vue | 412 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 364 insertions(+), 48 deletions(-)
diff --git a/src/views/specialWorkSystem/workTicket/workApply/components/plate.vue b/src/views/specialWorkSystem/workTicket/workApply/components/plate.vue
index c5833fd..b77e135 100644
--- a/src/views/specialWorkSystem/workTicket/workApply/components/plate.vue
+++ b/src/views/specialWorkSystem/workTicket/workApply/components/plate.vue
@@ -9,23 +9,9 @@
<el-select v-model="form.operatorUids" multiple>
<el-option
v-for="item in workerList"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </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"
+ :key="item.uid"
+ :label="item.username"
+ :value="item.uid"
/>
</el-select>
</el-form-item>
@@ -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">
@@ -97,7 +104,9 @@
v-model="form.workDetail.temperature"
type="number"
placeholder="请输入"
- />
+ >
+ <template #append>摄氏度(℃)</template>
+ </el-input>
</el-form-item>
</el-col>
<el-col :span="12">
@@ -106,7 +115,9 @@
v-model="form.workDetail.pressure"
type="number"
placeholder="请输入"
- />
+ >
+ <template #append>千帕(kPa)</template>
+ </el-input>
</el-form-item>
</el-col>
</el-row>
@@ -171,12 +182,62 @@
</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,最多可上传3张</div>
+ </template>
+ </el-upload>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row>
+ <el-col :span="12">
+ <el-form-item label="选择关联物资">
+ <el-button type="primary" @click="getMaList">选择物资标准</el-button>
+ </el-form-item>
+ </el-col>
+ </el-row>
</div>
</el-form>
+ <el-dialog v-model="equipmentDialog" title="关联物资标准" width="40%" center @close="closeMaterial">
+ <el-tabs tab-position="left" class="demo-tabs" type="border-card">
+ <el-tab-pane v-for="(item,index) in materialList" :label="item.materialTypeName" :key="index">
+ <div style="margin-bottom: 20px">
+ <el-form label-width="150px" label-position="top">
+ <div v-if="item.mustList.length>0" style="width: 100%;border-bottom: 1px solid #ccc;padding-bottom: 6px;margin-bottom: 10px;font-weight: bolder">必选</div>
+ <el-form-item v-if="item.mustList.length>0" class="tab-i" v-for="(i,x) in item.mustList" :key="x" :label="item.mustList[x].materialName + ':'" prop="defaultVal" :rules="[{ type: 'defaultVal', required: true, message: '该内容不能为空', trigger: 'blur'}]">
+ <el-input size="default" type="number" v-model="item.mustList[x].value" @change="(val)=>toZero(val,index,'mustList',x)" placeholder="请输入配置数量,空值默认为0">
+ <template #append>{{'库存:' + item.mustList[x].stock}}</template>
+ </el-input>
+ </el-form-item>
+ <div v-if="item.unList.length>0" style="width: 100%;border-bottom: 1px solid #ccc;padding-bottom: 6px;margin-bottom: 10px;font-weight: bolder">其他</div>
+ <el-form-item v-if="item.unList.length>0" class="tab-i" v-for="(i,x) in item.unList" :key="x" :label="item.unList[x].materialName + ':'">
+ <el-input size="default" type="number" v-model="item.unList[x].value" @change="(val)=>toZero(val,index,'unList',x)" placeholder="请输入配置数量,空值默认为0">
+ <template #append>{{'库存:' + item.unList[x].stock}}</template>
+ </el-input>
+ </el-form-item>
+ </el-form>
+ </div>
+ </el-tab-pane>
+ </el-tabs>
+ <template #footer>
+ <span class="dialog-footer">
+ <el-button @click="equipmentDialog = false" size="default">取消</el-button>
+ <el-button type="primary" @click="conFirmDevices" size="default">确认</el-button>
+ </span>
+ </template>
+ </el-dialog>
<div class="applyBtn">
<el-button type="primary" size="large" plain @click="submitForm(ruleFormRef)">发起申请</el-button>
</div>
</div>
+ <el-dialog v-model="dialogVisible">
+ <img w-full :src="dialogImageUrl" alt="Preview Image" />
+ </el-dialog>
</div>
</template>
@@ -187,31 +248,45 @@
import {useUserInfo} from "/@/stores/userInfo";
import { Session } from '/@/utils/storage';
import { Search } from '@element-plus/icons-vue'
- import { ElMessage } from 'element-plus'
- import type { FormInstance, FormRules } from 'element-plus'
+ import { ElMessage, ElMessageBox } from 'element-plus'
+ import type { FormInstance, FormRules, UploadProps, UploadUserFile } from 'element-plus'
import { workApplyApi } from '/@/api/specialWorkSystem/workApply';
-
+ import axios from 'axios';
interface stateType {
form: Object,
- workerList: Array<any>,
csDepList: Array<any>,
otherWorkList: Array<any>,
- workLevelList: Array<any>
+ workLevelList: Array<any>,
+ fileList: Array<file>,
+ uploadUrl: string,
+ dialogVisible: Boolean,
+ dialogImageUrl: string | null,
+ imgLimit: number,
+ isOverSize: boolean,
+ equipmentDialog: boolean,
+ materialList: Array<any>
+ }
+ interface file {
+ url: string;
}
export default defineComponent({
- name: 'brokenForm',
+ name: 'plateForm',
components: {},
+ props:['workerList'],
setup() {
const userInfo = useUserInfo()
const { userInfos } = storeToRefs(userInfo);
const state = reactive<stateType>({
+ equipmentDialog: false,
+ materialList: [],
form: {
operatorUids: [],
workType: 8,
workLevel: null,
workContent: '',
workLocation: '',
+ hazardIdentification: '',
workDetail:{
bpCode: '',
mainMedia: '',
@@ -220,34 +295,23 @@
bpMaterialQuality: '',
bpSpecification: '',
bpLocation: '',
- bpLocationMapPath: '',
+ bpLocationMapPath: [],
installLine: [],
installBpTime: '',
uninstallBpTime: '',
otherSpecialWork: []
},
+ wmAddReqDTOList: [],
workTimeLine: [],
expStartTime: '',
expEndTime: ''
},
- workerList:[
- {
- label: "张三",
- value: 53
- },
- {
- label: "李四",
- value: 54
- },
- {
- label: "测试一",
- value: 55
- },
- {
- label: "测试二",
- value: 56
- }
- ],
+ isOverSize: false,
+ fileList: [],
+ imgLimit: 3,
+ uploadUrl: '',
+ dialogVisible: false,
+ dialogImageUrl: null,
workLevelList: [
{
label: "抽盲板作业",
@@ -326,6 +390,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' }],
@@ -335,11 +400,55 @@
"workDetail.bpSpecification": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
"workDetail.installLine": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
"workDetail.bpLocation": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
+ "workDetail.bpLocationMapPath": [{ required: true, message: '该内容不能为空', trigger: 'blur' }]
});
+
+ const toZero = (value: string | number,index: number,name: string,x:number) =>{
+ if(!value){
+ state.materialList[index][name][x].value = 0
+ }
+ }
+
const submitForm = async (formEl: FormInstance | undefined) => {
if (!formEl) return
await formEl.validate(async (valid, fields) => {
if (valid) {
+ for(let i in state.materialList){
+ for(let j in state.materialList[i].mustList){
+ if(state.materialList[i].mustList[j].value>state.materialList[i].mustList[j].stock){
+ ElMessage({
+ type: 'warning',
+ message: '部分物资库存不足,请重新配置数量。'
+ });
+ return
+ }
+ }
+ for(let j in state.materialList[i].unList){
+ if(state.materialList[i].unList[j].value>state.materialList[i].unList[j].stock){
+ ElMessage({
+ type: 'warning',
+ message: '部分物资库存不足,请重新配置数量。'
+ });
+ return
+ }
+ }
+ state.materialList[i].mustList = state.materialList[i].mustList.map((item:any)=>{
+ const obj = {
+ defaultVal: item.value,
+ id: item.id
+ }
+ return {...obj}
+ })
+ state.materialList[i].unList = state.materialList[i].unList.map((item:any)=>{
+ const obj = {
+ defaultVal: item.value,
+ id: item.id
+ }
+ return {...obj}
+ })
+ state.materialList[i].postList = [...state.materialList[i].mustList,...state.materialList[i].unList]
+ state.form.wmAddReqDTOList = [...state.form.wmAddReqDTOList,...state.materialList[i].postList]
+ }
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]
@@ -348,9 +457,9 @@
let { installLine, ...data2 } = JSON.parse(JSON.stringify(state.form.workDetail))
data.workDetail = data2
data.workDetail.otherSpecialWork = data.workDetail.otherSpecialWork.join(',')
+ data.workDetail.bpLocationMapPath = data.workDetail.bpLocationMapPath.join(',')
data.workDetail.temperature = Number(data.workDetail.temperature)
data.workDetail.pressure = Number(data.workDetail.pressure)
- console.log(data,'data')
const res = await workApplyApi().postPlateApply(data)
if (res.data.code === '200') {
ElMessage({
@@ -358,17 +467,214 @@
message: '提交成功!'
});
formEl.resetFields()
+ state.form.workDetail.bpLocationMapPath = []
+ state.fileList = []
} else {
ElMessage({
type: 'warning',
message: res.data.msg
});
}
+ state.materialList = []
} else {
console.log('error submit!', fields)
}
})
}
+ const handlePreview: UploadProps['onPreview'] = (uploadFile) => {
+ console.log(uploadFile);
+ };
+
+ const handlePictureCardPreview = (uploadFile: { url: string }) => {
+ state.dialogImageUrl = uploadFile.url!;
+ state.dialogVisible = true;
+ };
+
+ const getUploadUrl = async (rawFile: any) => {
+ 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) => {
+ // const formData = new FormData();
+ // formData.append('file', state.fileList[0].raw);
+ let reader = new FileReader();
+ reader.readAsArrayBuffer(params.file);
+ reader.onload = async () => {
+ axios
+ .put(state.uploadUrl, reader.result, {
+ header: { 'Content-Type': 'multipart/form-data' }
+ })
+ .then(() => {
+ // if (state.fileList.length === 2) {
+ // state.fileList.splice(0, 1);
+ // }
+ // console.log(state.form.workDetail.bpLocationMapPath,'bpLocationMapPath')
+ });
+ };
+ };
+
+ const beforeRemove = (file: {}, fileList: []) => {
+ const result = new Promise((resolve, reject) => {
+ 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);
+ });
+ }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(isOverSize:boolean,fileName:string)=>{
+ console.log(fileName,'fileName')
+ const res = await workApplyApi().deleteFile({fileName: fileName})
+ if (res.data.code === '200') {
+ ElMessage({
+ type: isOverSize ? 'error' : 'success',
+ message: isOverSize ? '上传失败':'删除成功!'
+ });
+ } else {
+ ElMessage({
+ type: 'warning',
+ message: res.data.msg
+ });
+ }
+ }
+ const showTip =()=>{
+ ElMessage({
+ type: 'warning',
+ message: '超出文件上传数量'
+ });
+ }
+
+ // 确认物资标准
+ const getMaList = async() =>{
+ if(state.materialList.length == 0){
+ const data = {workType: 8,workLevel: state.form.workLevel}
+ const res = await workApplyApi().getMaterial(data)
+ if (res.data.code === '200') {
+ state.materialList = JSON.parse(JSON.stringify(res.data.data.materialTypeList))
+ for(let i in state.materialList){
+ state.materialList[i].mustList = []
+ state.materialList[i].unList = []
+ state.materialList[i].mdList = state.materialList[i].mdList?.map((item:any) => {
+ if(item.configurationLevel == 0){
+ state.materialList[i].mustList.push(item)
+ return
+ }else{
+ state.materialList[i].unList.push(item)
+ return
+ }
+ })
+ state.materialList[i].mustList = state.materialList[i].mustList.map((item:any)=>{
+ const obj = {
+ value: item.defaultVal,
+ materialName: item.materialName,
+ configurationLevel: item.configurationLevel,
+ id: item.id,
+ stock: item.stock
+ }
+ return {...obj}
+ })
+ state.materialList[i].unList = state.materialList[i].unList.map((item:any)=>{
+ const obj = {
+ value: item.defaultVal,
+ materialName: item.materialName,
+ configurationLevel: item.configurationLevel,
+ id: item.id,
+ stock: item.stock
+ }
+ return {...obj}
+ })
+ }
+ state.equipmentDialog = true
+ } else {
+ ElMessage({
+ type: 'warning',
+ message: res.data.msg
+ });
+ }
+ }else{
+ state.materialList = state.materialList
+ state.equipmentDialog = true
+ }
+ }
+ const conFirmDevices = ()=>{
+ for(let i in state.materialList){
+ for(let j in state.materialList[i].mustList){
+ if(state.materialList[i].mustList[j].value>state.materialList[i].mustList[j].stock){
+ ElMessage({
+ type: 'warning',
+ message: '部分物资库存不足,请重新配置数量。'
+ });
+ return
+ }
+ }
+ for(let j in state.materialList[i].unList){
+ if(state.materialList[i].unList[j].value>state.materialList[i].unList[j].stock){
+ ElMessage({
+ type: 'warning',
+ message: '部分物资库存不足,请重新配置数量。'
+ });
+ return
+ }
+ }
+
+ }
+ ElMessageBox.confirm('是否确认物资及数量配置?')
+ .then(() => {
+ state.equipmentDialog = false
+ })
+ .catch(() => {
+ // catch error
+ })
+ }
+
+ const closeMaterial = ()=>{
+
+ }
+
// 折线图
const renderMenu = async (value: string) => {
Session.set('projectId',value)
@@ -380,7 +686,17 @@
Search,
ruleFormRef,
applyRules,
+ toZero,
+ getMaList,
+ conFirmDevices,
+ closeMaterial,
+ handlePreview,
+ getUploadUrl,
+ beforeRemove,
+ upload,
+ showTip,
submitForm,
+ handlePictureCardPreview,
...toRefs(state),
};
},
@@ -403,7 +719,7 @@
.applyBtn{
width: 100%;
background: #fff;
- height: 80px;
+ padding-top: 15px;
z-index: 5;
box-shadow: 0 -3px 8px rgba(150,150,150,.1);
display: flex;
--
Gitblit v1.9.2