<template> <!-- 河道巡查填报 --> <div class="taskFormRiver"> <van-form @submit="onSubmitData"> <div class="ContentView" id="ContentViewRiver"> <van-field v-model="AllData.patrolTargetIdText" rows="2" autosize label="项目名称" type="textarea" disabled="true" /> <!-- <van-field v-model="AllData.formData.problemType" label="问题类型" placeholder="请输入问题类型" show-word-limit required :rules="[{ required: true, message: '请输入问题类型' }]" /> --> <van-field label="检查项" placeholder="请选择检查项" show-word-limit required readonly is-link @click="AllData.showPicker = true" :rules="[{ required: true, message: '请选择检查项' }]" v-model="AllData.userId" /> <van-popup v-model:show="AllData.showPicker" round position="bottom"> <van-picker :columns="inspection_items" @confirm="onConfirmOne" @cancel="AllData.showPicker = false"> </van-picker> </van-popup> <van-field label="整改状态" name="caseLevel" required :rules="[{ required: true, message: '请选择整改状态' }]"> <template #input> <van-radio-group v-model="AllData.formData.isRectification" direction="horizontal"> <van-radio :name="item.value" v-for="item in AllData.formOptions.case_level" :key="item.value"> {{ item.label }} </van-radio> </van-radio-group> </template> </van-field> <van-field v-model="AllData.formData.problemContent" rows="2" autosize label="问题描述" type="textarea" maxlength="200" placeholder="请输入问题描述" show-word-limit required :rules="[{ required: true, message: '请输入问题描述' }]" /> <div class="mediumList"> <span class="Title">现场图片(最多3张)</span> <div class="picBox"> <UploadImg :maxCount="3" :saveFileArr="AllData.formData.sysFileSaveRequestList" :acceptFormat="'image/*'" @update:saveFileArr="getImgList" /> </div> </div> </div> <div class="BottomView"> <van-button @click="closeDaKa" class="BotBtn">返回</van-button> <van-button native-type="submit" class="BotBtn" type="primary">提交</van-button> </div> </van-form> </div> </template> <script setup> import UploadImg from '@/views/components/uploadFile.vue'; import { getProjectInfoList, patrolProblemadd } from '@/api/xuncha'; import { useRouter, useRoute } from 'vue-router'; import { timestampToTime, getCurrentPositon } from '@/utils/common.js'; import CoordTransform from '@/utils/gis/CoorTransform.js'; import { useDictA } from '@/utils/dict'; const { inspection_items } = useDictA('inspection_items'); // 获取父组件传过来的patrolLogId const props = defineProps({ numberNum: String, projectName: String, projectCode: String, }); const { proxy } = getCurrentInstance(); const emits = defineEmits(['closeFormTransition']); const closeDaKa = () => { emits('closeFormTransition', 'AnJianUpdatas'); }; const route = useRoute(); const AllData = reactive({ ShowHedao: false, range3: [], showPicker: false, userId: '', formData: { problemType: '', sysFileSaveRequestList: [], //获取的图片数组 taskName: '', checkItem: '', isRectification: '2', problemContent: '', patrolTaskNo: '', projectNo: '', uploadType: '1', //1:任务巡查 lonLat: '', problemAddress: '', }, patrolTargetIdText: '', formOptions: { case_level: [ { value: '2', label: '需要整改' }, { value: '1', label: '无需整改' }, ], caseTypeData: [], }, }); const multiple = ref(true); // 获取上传的图片 function getImgList(e) { e.forEach((item) => { item.refField = 'pat_problem'; }); AllData.formData.sysFileSaveRequestList = e; } // 项目接口 async function projectTypeListM() { let { data } = await getProjectInfoList(); AllData.range3 = data.map((v) => { return { value: v.projectNo, text: v.projectAbbreviation, }; }); } //项目名称选择 const onConfirmHedao = ({ selectedOptions }) => { AllData.ShowHedao = false; AllData.patrolTargetIdText = selectedOptions[0].text; AllData.formData.taskName = selectedOptions[0].value; }; const onCancel = () => { AllData.ShowHedao = false; }; // 选着 const onConfirmOne = ({ selectedOptions }) => { AllData.showPicker = false; console.log(selectedOptions, 'selectedOptions'); AllData.userId = selectedOptions[0].text; AllData.formData.checkItem = selectedOptions[0].value; }; // 提交上报 const onSubmitData = async () => { console.log(AllData.formData, 'AllData.formData'); patrolProblemadd(AllData.formData).then((response) => { proxy.showSuccessToast('填报成功'); closeDaKa(); }); }; watch( route, (val) => { if (!!!route.query.id) return; setTimeout(() => { //option为object类型,会序列化上个页面传递的参数 AllData.formData.patrolTaskNo = props.numberNum; AllData.patrolTargetIdText = props.projectName; AllData.formData.projectNo = props.projectCode; }); }, { immediate: true } ); onMounted(() => { projectTypeListM(); getCurrentPositon((lng, lat, address) => { let NewLonLat = CoordTransform.gcj02towgs84(Number(lng), Number(lat)); AllData.formData.lonLat = String(NewLonLat); AllData.formData.problemAddress = address; }); }); </script> <style lang="less"> .taskFormRiver { width: 100%; height: calc(100% - 80px); background: #fafafa; .ContentView { width: 100%; height: calc(100vh - 360px); background-color: #ececec; box-sizing: border-box; padding: 20px 20px; overflow: auto; .van-radio { margin-bottom: 10px; } .mediumList { width: 100%; height: auto; .Title { width: 100%; height: 60px; line-height: 60px; display: inline-block; } .picBox { width: 100%; height: auto; } } } .BottomView { width: 100%; height: 120px; display: flex; justify-content: space-around; margin-top: 20px; .BotBtn { width: 45%; } } } </style>