<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.uid"
|
:label="item.username"
|
:value="item.uid"
|
/>
|
</el-select>
|
</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"
|
value-format="YYYY-MM-DD HH:mm:00"
|
type="datetimerange"
|
range-separator="至"
|
start-placeholder="开始时间"
|
end-placeholder="结束时间"
|
/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<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-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 csDepList"
|
: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="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="workDetail.involvedDepIds">
|
<el-cascader v-model="form.workDetail.involvedDepIds" :options="departList" :props="casProps" :show-all-levels="false" @change="handleChange" />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="24">
|
<el-form-item label="图片上传" prop="workDetail.bcPath">
|
<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>
|
</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>
|
export default{
|
name: 'brokenForm',
|
components: {},
|
props:['workerList','departList'],
|
data(){
|
return{
|
form: {
|
operatorUids: [],
|
workType: 5,
|
workLevel: 0,
|
workContent: '',
|
workLocation: '',
|
workDetail:{
|
operationDepId: null,
|
bcReason: '',
|
bcExplain: '',
|
bcPath: [],
|
involvedDepIds: []
|
},
|
workTimeLine: [],
|
expStartTime: '',
|
expEndTime: ''
|
},
|
fileList: [],
|
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: 'blur' }],
|
workType: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
|
workContent: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
|
workLocation: [{ 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:{
|
async submitForm(formEl) {
|
if (!formEl) return
|
await formEl.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]
|
let { workTimeLine, ...data } = JSON.parse(JSON.stringify(state.form))
|
data.workDetail.involvedDepIds = data.workDetail.involvedDepIds.join(',')
|
data.workDetail.bcPath = data.workDetail.bcPath.join(',')
|
const res = await workApplyApi().postBrokenApply(data)
|
if (res.data.code === '200') {
|
ElMessage({
|
type: 'success',
|
message: '提交成功!'
|
});
|
formEl.resetFields()
|
state.form.workDetail.bcPath = []
|
state.fileList = []
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
} else {
|
console.log('error submit!', fields)
|
}
|
})
|
}
|
},
|
};
|
</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>
|