|
|
@@ -2,7 +2,7 @@
|
|
|
<z-paging class="" ref="paging" bgColor="#fff" paging-class="paging-btm-shadow" safe-area-inset-bottom
|
|
|
scroll-with-animation>
|
|
|
<template #top>
|
|
|
- <ut-navbar title="添加GAP基地信息" :fixed="false" border></ut-navbar>
|
|
|
+ <ut-navbar :title="did ? '编辑GAP基地信息' : '添加GAP基地信息'" :fixed="false" border></ut-navbar>
|
|
|
</template>
|
|
|
<view class="pd-24">
|
|
|
<up-form class="p-rtv" labelPosition="top" :model="form" :rules="rules" labelWidth="auto" ref="upFormRef">
|
|
|
@@ -75,13 +75,17 @@
|
|
|
</template>
|
|
|
</up-form-item>
|
|
|
<!-- 基地经纬度 -->
|
|
|
- <view class="h-1" id="lnglatpppp"></view>
|
|
|
- <up-form-item required label="基地经纬度" prop="lnglat">
|
|
|
- <view class="flex1 d-flex a-c">
|
|
|
- <up-input v-model="form.lng" border="bottom" placeholder="70-150内的经度数值"
|
|
|
- clearable></up-input>
|
|
|
+ <view class="h-1" id="lngpppp"></view>
|
|
|
+ <view class="h-1" id="latpppp"></view>
|
|
|
+ <up-form-item required label="基地经纬度" class="form-item-wrap-column">
|
|
|
+ <view class="d-flex" style="margin-top: -10px">
|
|
|
+ <up-form-item prop="gapInfo.lng">
|
|
|
+ <up-input v-model="form.lng" border="bottom" placeholder="70-150内的经度数值" clearable></up-input>
|
|
|
+ </up-form-item>
|
|
|
<view class="pd-5"></view>
|
|
|
- <up-input v-model="form.lat" placeholder="4-53内的纬度数值" border="bottom" clearable></up-input>
|
|
|
+ <up-form-item prop="gapInfo.lat">
|
|
|
+ <up-input v-model="form.lat" placeholder="4-53内的纬度数值" border="bottom" clearable></up-input>
|
|
|
+ </up-form-item>
|
|
|
</view>
|
|
|
</up-form-item>
|
|
|
<!-- 校验定位:建设时间 -->
|
|
|
@@ -163,53 +167,12 @@ const rules = reactive({
|
|
|
basePic: [{ required: true, message: '请绘制基地范围' }],
|
|
|
adcode: [{ required: true, message: '请选择基地具体地址' }],
|
|
|
area: [{ required: true, message: '请输入基地面积' }],
|
|
|
- lnglat: [
|
|
|
- { required: true, message: '请输入基地经纬度' },
|
|
|
- {
|
|
|
- validator: (_rule: any, value: any) => {
|
|
|
- const lng = parseFloat(form.value.lng);
|
|
|
- const lat = parseFloat(form.value.lat);
|
|
|
- if (isNaN(lng) || lng < 70 || lng > 150) {
|
|
|
- return Promise.reject('经度请输入70-150内的数值');
|
|
|
- }
|
|
|
- if (isNaN(lat) || lat < 4 || lat > 53) {
|
|
|
- return Promise.reject('纬度请输入4-53内的数值');
|
|
|
- }
|
|
|
- return Promise.resolve();
|
|
|
- },
|
|
|
- trigger: 'blur',
|
|
|
- }
|
|
|
- ],
|
|
|
ratedDate: [{ required: true, message: '请选择获评GAP基地时间' }],
|
|
|
certFile: [{ required: true, message: '请上传官方公示证明材料' }],
|
|
|
url: [{ required: true, message: '请输入官方公示网址' }],
|
|
|
|
|
|
});
|
|
|
-// saveInfo和submitForm防抖
|
|
|
-// 暂存基地信息
|
|
|
-const saveBaseInfo = async () => {
|
|
|
- uni.$u.debounce(
|
|
|
- async () => {
|
|
|
- // 提交表单
|
|
|
- uni.showLoading({
|
|
|
- title: '保存中...',
|
|
|
- });
|
|
|
- try {
|
|
|
- const res = await useClientRequest.post('/plt-api/app/base/temp', form.value);
|
|
|
- uni.hideLoading();
|
|
|
- if (!res || res !== 200) return;
|
|
|
- uni.showToast({
|
|
|
- title: '保存成功',
|
|
|
- icon: 'success',
|
|
|
- });
|
|
|
- } catch (error) {
|
|
|
- uni.hideLoading();
|
|
|
- }
|
|
|
- },
|
|
|
- 500,
|
|
|
- true
|
|
|
- );
|
|
|
-};
|
|
|
+
|
|
|
const submitForm = async () => {
|
|
|
uni.$u.debounce(
|
|
|
async () => {
|
|
|
@@ -226,7 +189,7 @@ const submitForm = async () => {
|
|
|
title: '提交中...',
|
|
|
});
|
|
|
try {
|
|
|
- const res = await useClientRequest.post('/plt-api/app/gapCertificationInfo/add', form.value);
|
|
|
+ const res = did.value ? await useClientRequest.post(`/plt-api/app/gapCertificationInfo/update`, form.value) : await useClientRequest.post('/plt-api/app/gapCertificationInfo/add', form.value);
|
|
|
uni.hideLoading();
|
|
|
if (!res || res !== 200) return;
|
|
|
uni.hideLoading();
|
|
|
@@ -302,8 +265,22 @@ const selectMedicine = () => {
|
|
|
const confirmArea = (area: any) => {
|
|
|
form.value.adcodeName = area.fullName;
|
|
|
};
|
|
|
+const getDetailById = async (id: string) => {
|
|
|
+ if (!id) return;
|
|
|
+ const res = await useClientRequest.get(`/plt-api/app/gapCertificationInfo/getInfoById/${id}`);
|
|
|
+ if (res && res.code === 200) {
|
|
|
+ form.value = {
|
|
|
+ ...res.data,
|
|
|
+ lnglat: res.data.lng + ',' + res.data.lat,
|
|
|
+ };
|
|
|
+ }
|
|
|
+};
|
|
|
+const did = ref('');
|
|
|
onLoad((optins: any) => {
|
|
|
if (optins.id) {
|
|
|
+ // 编辑加载详
|
|
|
+ did.value = optins.id;
|
|
|
+ getDetailById(optins.id);
|
|
|
} else {
|
|
|
getLocationByAddress();
|
|
|
}
|