lct
Your Name
2022-09-02 91ccfa3ebdc7a68b6f632c3e59757ec03b15ac1f
src/views/specialWorkManage/workTicket/workApply/components/hoist.vue
@@ -9,15 +9,13 @@
                  <el-select v-model="form.operatorUids" multiple>
                     <el-option
                           v-for="item in workerList"
                           :key="item.uid"
                           :label="item.username"
                           :value="item.uid"
                           :key="item.id"
                           :label="item.realname"
                           :value="item.id"
                     />
                  </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">
@@ -30,12 +28,23 @@
                  </el-select>
               </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"
                                autosize
                                type="textarea"
                                placeholder="请输入危险辨识"
                            />
                        </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"
                                value-format="yyyy-MM-dd HH:mm:ss"
                        type="datetimerange"
                        range-separator="至"
                        start-placeholder="开始时间"
@@ -89,16 +98,19 @@
               </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>
         <el-button type="primary" size="large" plain @click="submitForm()">发起申请</el-button>
      </div>
   </div>
   </div>
</template>
<script>
   import {workApplyApi} from "../../../../../api/workApply";
   export default{
      name: 'hoistForm',
@@ -118,6 +130,7 @@
                    },
                    workTimeLine: [],
                    expStartTime: '',
                    hazardIdentification: '',
                    expEndTime: ''
                },
                workLevelList: [
@@ -135,10 +148,11 @@
                    }
                ],
                applyRules:{
                    operatorUids: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                    operatorUids: [{ required: true, message: '该内容不能为空', trigger: 'change' }],
                    workType: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                    workLevel: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                    workLevel: [{ required: true, message: '该内容不能为空', trigger: 'change' }],
                    workContent: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                    hazardIdentification: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                    workLocation: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                    workTimeLine: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                    "workDetail.hoistingToolName": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
@@ -147,23 +161,37 @@
            }
        },
        methods:{
            async submitForm (formEl) {
                if (!formEl) return
                await formEl.validate(async (valid, fields) => {
            submitForm (formEl) {
                this.$refs["ruleFormRef"].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))
                        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.weightMass = Number(data.workDetail.weightMass)
                        const res = await workApplyApi().postHoistApply(data)
                        if (res.data.code === '200') {
                            ElMessage({
                            this.$message({
                                type: 'success',
                                message: '提交成功!'
                            });
                            formEl.resetFields()
                            this.$refs["ruleFormRef"].clearValidate()
                            this.form = {
                                operatorUids: [],
                                workType: 3,
                                workLevel: null,
                                workContent: '',
                                workLocation: '',
                                workDetail:{
                                    hoistingToolName: '',
                                    weightMass: null
                                },
                                workTimeLine: [],
                                expStartTime: '',
                                hazardIdentification: '',
                                expEndTime: ''
                            }
                        } else {
                            ElMessage({
                            this.$message({
                                type: 'warning',
                                message: res.data.msg
                            });