<template> <view class="content"> <view class="card"> <u-form labelPosition="left" :model="form" :rules="rules" ref="formRef" labelWidth="140px"> <u-form-item label="地点坐标" borderBottom required> <u-button type="primary" size="small" text="定位" :customStyle="{width:'100upx',margin:0}" @click="fnLocation"/> </u-form-item> <u-form-item label="经度" prop="WORK_LONGITUDE" borderBottom required> <u-input v-model="form.WORK_LONGITUDE" border="none" readonly/> </u-form-item> <u-form-item label="纬度" prop="WORK_LATITUDE" borderBottom required> <u-input v-model="form.WORK_LATITUDE" border="none" readonly/> </u-form-item> </u-form> <view class="mt-10"> <u-button type="primary" text="下一步" @click="$u.debounce(fnSubmit, 1000,true)"/> </view> </view> </view> </template> <script> import OtherSelect from '@/components/other-select/index.vue'; import Sign from '@/components/sign/sign.vue' import {getData, addReport} from "@/utils/submitHomeworkProcess"; export default { components: { OtherSelect, Sign }, data() { return { type: '', taskId: '', EW_RU_JOB_ID: '', vernier: '', CORP_ID: '', CORP_NAME: '', formItems: [ {name: '经度', key_name: 'WORK_LONGITUDE', type: 0}, {name: '纬度', key_name: 'WORK_LATITUDE', type: 0} ], form: { WORK_LONGITUDE: '1', WORK_LATITUDE: '1' }, rules: { WORK_LONGITUDE: [{type: 'string', required: true, message: '请输入经度', trigger: ['blur', 'change']}], WORK_LATITUDE: [{type: 'string', required: true, message: '请输入纬度', trigger: ['blur', 'change']}] } } }, async onLoad(options) { this.taskId = options.taskId this.EW_RU_JOB_ID = options.EW_RU_JOB_ID this.vernier = options.vernier this.type = options.type this.CORP_ID = options.CORP_ID this.CORP_NAME = options.CORP_NAME }, methods: { fnLocation() { uni.navigateTo({ url: '/pages/map/index', events: { acceptLocationData: (event) => { this.form.WORK_LONGITUDE = event.data.longitue.toString(); this.form.WORK_LATITUDE = event.data.latitude.toString(); } }, }) }, async fnSubmit() { try { await this.$refs.formRef.validate() try { await addReport({ form: this.form, formItems: this.formItems, TYPE: this.type, CORP_ID: this.CORP_ID, EW_RU_TASK_ID: this.taskId, EW_RU_JOB_ID: this.EW_RU_JOB_ID, vernier: this.vernier }) } catch { } } catch { uni.$u.toast('请补全必填项') } } } } </script> <style scoped lang="scss"> </style>