<template>
|
<div class="home-container">
|
<div style="height: 100%">
|
<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.id"
|
:label="item.realname"
|
:value="item.id"
|
/>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="作业内容" prop="workContent">
|
<el-input
|
v-model="form.workContent"
|
autosize
|
type="textarea"
|
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"
|
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="workLocation">
|
<el-input
|
v-model="form.workLocation"
|
autosize
|
type="textarea"
|
placeholder="请输入作业地址"
|
/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
|
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="作业单位" prop="workDetail.operationDepId">
|
<el-select v-model="form.workDetail.operationDepId">
|
<el-option
|
v-for="item in departList"
|
:key="item.id"
|
:label="item.department"
|
:value="item.id"
|
/>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="断路原因" prop="workDetail.bcReason">
|
<el-input
|
v-model="form.workDetail.bcReason"
|
autosize
|
type="textarea"
|
placeholder="请输入"
|
/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="断路地段说明" prop="workDetail.bcExplain">
|
<el-input
|
v-model="form.workDetail.bcExplain"
|
autosize
|
type="textarea"
|
placeholder="请输入"
|
/>
|
</el-form-item>
|
</el-col>
|
<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-row>
|
<el-col :span="12">
|
<el-form-item label="涉及相关部门" prop="workDetail.involvedDepIds">
|
<el-select v-model="form.workDetail.involvedDepIds">
|
<el-option
|
v-for="item in departList"
|
:key="item.id"
|
:label="item.department"
|
:value="item.id"
|
/>
|
</el-select>
|
</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.gbPath"
|
: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">
|
<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>
|
|
<script>
|
import {workApplyApi} from "../../../../../api/workApply";
|
import Cookies from "_js-cookie@2.2.0@js-cookie";
|
|
export default{
|
name: 'brokenForm',
|
components: {},
|
props:['workerList','departList'],
|
data(){
|
return{
|
fileRoad:process.env.BASE_API + '/task/web/upload',
|
uploadForm:{
|
},
|
header:{Authorization:''},
|
fileList:[],
|
disabled:false,
|
form: {
|
operatorUids: [],
|
workType: 5,
|
workLevel: 0,
|
workContent: '',
|
workLocation: '',
|
workDetail:{
|
operationDepId: null,
|
bcReason: '',
|
bcExplain: '',
|
bcPath: [],
|
involvedDepIds: []
|
},
|
workTimeLine: [],
|
expStartTime: '',
|
hazardIdentification: '',
|
expEndTime: ''
|
},
|
imgLimit: 5,
|
uploadUrl: '',
|
dialogVisible: false,
|
dialogImageUrl: null,
|
csDepList: [
|
{
|
label: "单位一",
|
value: 1
|
},
|
{
|
label: "单位二",
|
value: 2
|
},
|
{
|
label: "单位三",
|
value: 3
|
},
|
{
|
label: "单位四",
|
value: 4
|
},
|
{
|
label: "单位五",
|
value: 5
|
},
|
{
|
label: "单位六",
|
value: 6
|
}
|
],
|
casProps: {
|
emitPath: false,
|
value: 'depId',
|
label: 'depName',
|
multiple: true
|
},
|
applyRules:{
|
operatorUids: [{ required: true, message: '该内容不能为空', trigger: 'change' }],
|
workType: [{ 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.operationDepId": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
|
"workDetail.bcReason": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
|
"workDetail.bcExplain": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
|
"workDetail.bcPath": [{ required: true, message: '该内容不能为空', trigger: 'blur' }]
|
}
|
}
|
},
|
methods:{
|
submitForm(formEl) {
|
this.$refs["ruleFormRef"].validate(async (valid, fields) => {
|
if (valid) {
|
this.form.expStartTime = JSON.parse(JSON.stringify(this.form.workTimeLine))[0]
|
this.form.expEndTime = JSON.parse(JSON.stringify(this.form.workTimeLine))[1]
|
let { workTimeLine, ...data } = JSON.parse(JSON.stringify(this.form))
|
data.workDetail.involvedDepIds = data.workDetail.involvedDepIds.toString()
|
data.workDetail.bcPath = JSON.stringify(this.fileList.map(item => { return item.url.substring(process.env.IMG_API.length) }))
|
const res = await workApplyApi().postBrokenApply(data)
|
if (res.data.code === '200') {
|
this.$message({
|
type: 'success',
|
message: '提交成功!'
|
});
|
this.$refs["ruleFormRef"].clearValidate()
|
this.form = {
|
operatorUids: [],
|
workType: 5,
|
workLevel: 0,
|
workContent: '',
|
workLocation: '',
|
workDetail:{
|
operationDepId: null,
|
bcReason: '',
|
bcExplain: '',
|
bcPath: [],
|
involvedDepIds: []
|
},
|
workTimeLine: [],
|
expStartTime: '',
|
hazardIdentification: '',
|
expEndTime: ''
|
}
|
this.fileList = []
|
} else {
|
this.$message({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
} 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>
|
|
<style scoped lang="scss">
|
.home-container {
|
height: 100%;
|
overflow: hidden;
|
position: relative;
|
.homeCard{
|
width: 100%;
|
padding: 20px;
|
box-sizing: border-box;
|
background: #fff;
|
border-radius: 4px;
|
margin-bottom: 20px;
|
}
|
.applyBtn{
|
width: 100%;
|
background: #fff;
|
padding-top: 15px;
|
z-index: 5;
|
box-shadow: 0 -3px 8px rgba(150,150,150,.1);
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
}
|
.el-row{
|
margin-bottom: 20px;
|
}
|
.el-row:last-child {
|
margin-bottom: 0;
|
}
|
.el-input{
|
width: 100% !important;
|
}
|
.el-date-editor::v-deep{
|
width: 100%;
|
}
|
.el-select{
|
width: 100%;
|
}
|
.el-cascader{
|
width: 100% !important;
|
}
|
}
|
</style>
|