<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-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="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.powerAccessPoint">
|
<el-input
|
v-model="form.workDetail.powerAccessPoint"
|
autosize
|
type="textarea"
|
placeholder="请输入"
|
/>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="工作电压" prop="workDetail.workingVoltage">
|
<el-input
|
v-model="form.workDetail.workingVoltage"
|
type="number"
|
placeholder="请输入工作电压(大于等于0)"
|
>
|
<template #append>伏特(v)</template>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="用电设备及功率" prop="workDetail.equipmentAndPower">
|
<el-input
|
v-model="form.workDetail.equipmentAndPower"
|
autosize
|
type="textarea"
|
placeholder="请输入"
|
/>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="选择关联物资">
|
<el-button type="primary" @click="openMaList">选择物资标准</el-button>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</div>
|
</el-form>
|
<material-dialog ref="material" @conFirmMaterials="conFirmMaterials"></material-dialog>
|
<div class="applyBtn">
|
<el-button type="primary" size="large" plain @click="submitForm(ruleFormRef)">发起申请</el-button>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script lang="ts">
|
import {toRefs, reactive, defineComponent, ref, defineAsyncComponent} from 'vue';
|
import { storeToRefs } from 'pinia';
|
import { initBackEndControlRoutes } from '/@/router/backEnd';
|
import {useUserInfo} from "/@/stores/userInfo";
|
import { Session } from '/@/utils/storage';
|
import { Search } from '@element-plus/icons-vue'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
import type { FormInstance, FormRules } from 'element-plus'
|
import { workApplyApi } from '/@/api/specialWorkSystem/workApply';
|
|
interface stateType {
|
form: Object,
|
equipmentDialog: boolean
|
}
|
export default defineComponent({
|
name: 'powerForm',
|
components: {
|
materialDialog: defineAsyncComponent(() => import('/@/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue')),
|
},
|
props:['workerList'],
|
setup(props: any, context: any) {
|
const userInfo = useUserInfo()
|
const { userInfos } = storeToRefs(userInfo);
|
const state = reactive<stateType>({
|
equipmentDialog: false,
|
form: {
|
operatorUids: [],
|
workType: 7,
|
workLevel: 0,
|
workContent: '',
|
workLocation: '',
|
maBaseId: null,
|
hazardIdentification: '',
|
workDetail:{
|
powerAccessPoint: '',
|
workingVoltage: null,
|
equipmentAndPower: ''
|
},
|
receiveUids: [],
|
workTimeLine: [],
|
expStartTime: '',
|
expEndTime: ''
|
}
|
});
|
const material = ref()
|
const ruleFormRef = ref<FormInstance>()
|
const applyRules = reactive<FormRules>({
|
operatorUids: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
|
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.powerAccessPoint": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
|
"workDetail.workingVoltage": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
|
"workDetail.equipmentAndPower": [{ 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 openMaList = ()=>{
|
if(state.form.operatorUids == []){
|
ElMessage({
|
type: 'warning',
|
message: '请先选择作业人再获取相应物资配置'
|
});
|
}else{
|
if(material.value.receiveUids.length==0){
|
material.value.receiveUids = state.form.operatorUids
|
}
|
material.value.getMaList(state.form.workType,state.form.workLevel)
|
material.value.workerList = props.workerList
|
}
|
}
|
const conFirmMaterials = (receiveUids: Array<number>,chosenId: number) =>{
|
state.form.maBaseId = null
|
state.form.receiveUids = []
|
state.form.receiveUids = receiveUids
|
state.form.maBaseId = chosenId
|
}
|
|
const submitForm = async (formEl: FormInstance | undefined) => {
|
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.weightMass = Number(data.workDetail.weightMass)
|
const res = await workApplyApi().postPowerApply(data)
|
if (res.data.code === '200') {
|
ElMessage({
|
type: 'success',
|
message: '提交成功!'
|
});
|
formEl.resetFields()
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
material.value.maBaseId = null
|
material.value.receiveUids = []
|
} else {
|
console.log('error submit!', fields)
|
}
|
})
|
}
|
|
// 折线图
|
const renderMenu = async (value: string) => {
|
Session.set('projectId',value)
|
userInfos.value.projectId = value
|
await initBackEndControlRoutes();
|
};
|
return {
|
renderMenu,
|
Search,
|
ruleFormRef,
|
applyRules,
|
material,
|
openMaList,
|
conFirmMaterials,
|
submitForm,
|
...toRefs(state),
|
};
|
},
|
});
|
</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>
|