|
@@ -1,332 +0,0 @@
|
|
|
-<template>
|
|
|
|
|
- <view class="z-paging-wrap">
|
|
|
|
|
- <z-paging class="" ref="paging" bgColor="#fff" :fixed="false" safe-area-inset-bottom scroll-with-animation>
|
|
|
|
|
- <view class="pd-24">
|
|
|
|
|
- <up-alert type="primary" fontSize="24rpx" description="注意:基地不强制与品种挂钩!基地地址以行政村为界,可成片集中或相对集中,跨村则视为另一基地(连片跨村除外)。"></up-alert>
|
|
|
|
|
- <view class="pd-10"></view>
|
|
|
|
|
- <up-form class="p-rtv" labelPosition="top" :model="form" :rules="rules" labelWidth="auto" ref="upFormRef">
|
|
|
|
|
- <!-- 校验定位:基地类型 -->
|
|
|
|
|
- <view class="h-1" id="baseTypepppp"></view>
|
|
|
|
|
- <ut-action-sheet v-model="form.baseType" :tabs="pt_base_type" title="选择基地类型">
|
|
|
|
|
- <up-form-item borderBottom label="基地类型" required prop="baseType">
|
|
|
|
|
- <view v-if="form.baseType" class="f-s-30 c-333 f-w-5 flex1">{{ selectDictLabel(pt_base_type, form.baseType) }}</view>
|
|
|
|
|
- <view v-else class="f-s-30 c-ccc f-w-4 flex1">请选择基地类型</view>
|
|
|
|
|
- <template #right>
|
|
|
|
|
- <up-icon size="22rpx" color="#2A6D52" name="arrow-down-fill"></up-icon>
|
|
|
|
|
- </template>
|
|
|
|
|
- </up-form-item>
|
|
|
|
|
- </ut-action-sheet>
|
|
|
|
|
- <!-- 基地名称 -->
|
|
|
|
|
- <view class="h-1" id="baseNamepppp"></view>
|
|
|
|
|
- <up-form-item borderBottom label="基地名称" required prop="baseName">
|
|
|
|
|
- <up-input v-model="form.baseName" placeholder="请输入基地名称" border="none" clearable></up-input>
|
|
|
|
|
- </up-form-item>
|
|
|
|
|
- <!-- 基地编号 -->
|
|
|
|
|
- <view class="h-1" id="baseCodepppp"></view>
|
|
|
|
|
- <up-form-item borderBottom label="基地编号" prop="baseCode">
|
|
|
|
|
- <up-input v-model="form.baseCode" placeholder="请输入基地编号" border="none" clearable></up-input>
|
|
|
|
|
- </up-form-item>
|
|
|
|
|
- <!-- 校验定位:建设时间 -->
|
|
|
|
|
- <view class="h-1" id="buildDatepppp"></view>
|
|
|
|
|
- <ut-datetime-picker v-model="form.buildDate" mode="date" dateFields="month">
|
|
|
|
|
- <up-form-item borderBottom label="建设时间" required prop="buildDate">
|
|
|
|
|
- <up-input v-model="form.buildDate" placeholder="请选择基地建设年份" border="none" clearable></up-input>
|
|
|
|
|
- </up-form-item>
|
|
|
|
|
- </ut-datetime-picker>
|
|
|
|
|
- <!-- 选择基地组织方式 -->
|
|
|
|
|
- <view class="h-1" id="orgTypepppp"></view>
|
|
|
|
|
- <ut-action-sheet v-model="form.orgType" :tabs="pt_org_type" title="选择基地组织方式">
|
|
|
|
|
- <up-form-item borderBottom label="基地组织方式" required prop="orgType">
|
|
|
|
|
- <view v-if="form.orgType" class="f-s-30 c-333 f-w-5 flex1">{{ selectDictLabel(pt_org_type, form.orgType) }}</view>
|
|
|
|
|
- <view v-else class="f-s-30 c-ccc f-w-4 flex1">请选择基地组织方式</view>
|
|
|
|
|
- <template #right>
|
|
|
|
|
- <up-icon size="22rpx" color="#2A6D52" name="arrow-down-fill"></up-icon>
|
|
|
|
|
- </template>
|
|
|
|
|
- </up-form-item>
|
|
|
|
|
- </ut-action-sheet>
|
|
|
|
|
- <!-- 选择基地负责人 -->
|
|
|
|
|
- <!-- 校验定位:基地负责人 -->
|
|
|
|
|
- <view class="h-1" id="contactIdpppp"></view>
|
|
|
|
|
- <up-form-item @click="selectCpyMember" borderBottom label="基地负责人" required prop="contactId">
|
|
|
|
|
- <view v-if="form.contactId" class="f-s-30 c-333 f-w-5 flex1">{{ form.contactName }}</view>
|
|
|
|
|
- <view v-else class="f-s-30 c-ccc f-w-4 flex1">请选择基地负责人</view>
|
|
|
|
|
- <template #right>
|
|
|
|
|
- <up-icon size="22rpx" color="#2A6D52" name="arrow-down-fill"></up-icon>
|
|
|
|
|
- </template>
|
|
|
|
|
- </up-form-item>
|
|
|
|
|
- <!-- 填写基地联系电话 -->
|
|
|
|
|
- <view class="h-1" id="contactTelpppp"></view>
|
|
|
|
|
- <up-form-item borderBottom label="基地联系电话" required prop="contactTel">
|
|
|
|
|
- <up-input v-model="form.contactTel" placeholder="请输入基地联系电话" border="none" clearable></up-input>
|
|
|
|
|
- </up-form-item>
|
|
|
|
|
- <!-- 是否Gap基地 -->
|
|
|
|
|
- <view class="h-1" id="gapFlagpppp"></view>
|
|
|
|
|
- <up-form-item borderBottom label="是否为Gap基地" required prop="gapFlag">
|
|
|
|
|
- <up-radio-group v-model="form.gapFlag">
|
|
|
|
|
- <up-radio :customStyle="{ marginRight: '60rpx' }" v-for="(item, index) in yes_no" :key="index" :label="item.label" :name="item.value"></up-radio>
|
|
|
|
|
- </up-radio-group>
|
|
|
|
|
- </up-form-item>
|
|
|
|
|
- <view class="h-1" id="adcodepppp"></view>
|
|
|
|
|
- <up-form-item @click="showArea = true" borderBottom label="基地具体地址" required prop="gapInfo.adcode">
|
|
|
|
|
- <!-- <up-input v-model="form.address" placeholder="请选择基地所在省/市/县/镇(乡)" border="none" clearable></up-input> -->
|
|
|
|
|
- <view v-if="form?.gapInfo?.adcode" class="f-s-30 c-333 f-w-5 flex1">{{ form?.gapInfo?.adcodeName }}</view>
|
|
|
|
|
- <view v-else class="f-s-30 c-ccc f-w-4 flex1">请选择基地所在省/市/县/镇(乡)</view>
|
|
|
|
|
- <template #right>
|
|
|
|
|
- <up-icon size="22rpx" color="#2A6D52" name="arrow-down-fill"></up-icon>
|
|
|
|
|
- </template>
|
|
|
|
|
- </up-form-item>
|
|
|
|
|
- <up-form-item borderBottom prop="gapInfo.address">
|
|
|
|
|
- <up-input v-model="form.gapInfo.address" placeholder="请填写村级以下的具体地址信息" border="none" clearable></up-input>
|
|
|
|
|
- </up-form-item>
|
|
|
|
|
- <up-form-item borderBottom>
|
|
|
|
|
- <view class="flex1 ov-hd">
|
|
|
|
|
- <view class="d-flex a-c mb-10" style="margin-bottom: 5px">
|
|
|
|
|
- <view class="f-s-30 c-#666">基地范围</view>
|
|
|
|
|
- </view>
|
|
|
|
|
- <view class="bg-#ccc d-flex ov-hd p-rtv" @click="mapDrawArea">
|
|
|
|
|
- <image class="w-full h-380" v-if="form.gapInfo?.basePic" :src="form.gapInfo.basePic" mode="widthFix" />
|
|
|
|
|
- <image class="w-full h-380" v-else src="@/static/images/plant/base/select_base_gap.png" mode="widthFix" />
|
|
|
|
|
- <view v-if="!form.gapInfo?.basePic" class="btn-aree-center d-flex flex-cln a-c j-c">
|
|
|
|
|
- <image class="w-52 h-52 mb-10" src="@/static/images/plant/base/draw_area_icon.png" mode="widthFix" />
|
|
|
|
|
- <view class="c-primary f-s-28 f-w-400">点击绘制基地范围</view>
|
|
|
|
|
- </view>
|
|
|
|
|
- </view>
|
|
|
|
|
- </view>
|
|
|
|
|
- </up-form-item>
|
|
|
|
|
- <view class="h-1" id="areaPppp"></view>
|
|
|
|
|
- <up-form-item required borderBottom label="基地面积" prop="gapInfo.area">
|
|
|
|
|
- <up-input v-model="form.gapInfo.area" placeholder="地块绘制后自动带出可修改" border="none" clearable></up-input>
|
|
|
|
|
- <template #right>
|
|
|
|
|
- <span>{{ form.gapInfo.areaUnit }}</span>
|
|
|
|
|
- </template>
|
|
|
|
|
- </up-form-item>
|
|
|
|
|
- <!-- 基地经纬度 -->
|
|
|
|
|
- <view class="h-1" id="lnglatpppp"></view>
|
|
|
|
|
- <up-form-item required label="基地经纬度" prop="longitudeLatitude">
|
|
|
|
|
- <view class="flex1 d-flex a-c">
|
|
|
|
|
- <up-input v-model="form.gapInfo.lng" border="bottom" placeholder="70-150内的经度数值" clearable></up-input>
|
|
|
|
|
- <view class="pd-5"></view>
|
|
|
|
|
- <up-input v-model="form.gapInfo.lat" placeholder="4-53内的纬度数值" border="bottom" clearable></up-input>
|
|
|
|
|
- </view>
|
|
|
|
|
- </up-form-item>
|
|
|
|
|
- </up-form>
|
|
|
|
|
- </view>
|
|
|
|
|
- <template #bottom>
|
|
|
|
|
- <view class="pd-20 d-flex">
|
|
|
|
|
- <up-button @click="saveBaseInfo" class="mr-30" color="#F19F18" type="primary">暂存</up-button>
|
|
|
|
|
- <up-button @click="submitForm" type="primary">提交</up-button>
|
|
|
|
|
- </view>
|
|
|
|
|
- </template>
|
|
|
|
|
- </z-paging>
|
|
|
|
|
- </view>
|
|
|
|
|
- <ut-picker-area v-model:show="showArea" v-model="form.gapInfo.adcode" @confirm="confirmArea"></ut-picker-area>
|
|
|
|
|
-</template>
|
|
|
|
|
-<script setup lang="ts" name="base-info">
|
|
|
|
|
-import { isOpenSetting } from '@/utils/common';
|
|
|
|
|
-import { generateUniqueId } from '@/utils/public';
|
|
|
|
|
-import { useClientRequest } from '@/utils/request';
|
|
|
|
|
-const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
|
-const { yes_no, pt_org_type, pt_base_type } = toRefs<any>(proxy?.useDict('yes_no', 'pt_org_type', 'pt_base_type'));
|
|
|
|
|
-const paging = ref<any>(null);
|
|
|
|
|
-const upFormRef = ref<any>(null);
|
|
|
|
|
-const showArea = ref(false);
|
|
|
|
|
-const form = ref<any>({
|
|
|
|
|
- baseType: '',
|
|
|
|
|
- baseName: '',
|
|
|
|
|
- baseCode: '',
|
|
|
|
|
- gapInfo: {
|
|
|
|
|
- adcode: '',
|
|
|
|
|
- adcodeName: '',
|
|
|
|
|
- address: '',
|
|
|
|
|
- areaUnit: '亩',
|
|
|
|
|
- area: undefined
|
|
|
|
|
- },
|
|
|
|
|
- randomCode: generateUniqueId(),
|
|
|
|
|
- // 当前位置经纬度
|
|
|
|
|
- longitudeLatitude: {
|
|
|
|
|
- lng: '',
|
|
|
|
|
- lat: '',
|
|
|
|
|
- },
|
|
|
|
|
- coordinates: [],
|
|
|
|
|
-});
|
|
|
|
|
-const rules = reactive({
|
|
|
|
|
- baseType: [{ required: true, message: '请选择基地类型', trigger: ['change'] }],
|
|
|
|
|
- baseName: [{ required: true, message: '请输入基地名称', trigger: ['blur', 'change'] }],
|
|
|
|
|
- buildDate: [{ required: true, message: '请选择基地建设年份', trigger: ['change'] }],
|
|
|
|
|
- orgType: [{ required: true, message: '请选择基地组织方式', trigger: ['change'] }],
|
|
|
|
|
- contactId: [{ required: true, message: '请选择基地负责人', trigger: ['change'] }],
|
|
|
|
|
- contactTel: [{ required: true, message: '请输入基地联系电话', trigger: ['blur'] }],
|
|
|
|
|
- gapFlag: [{ required: true, message: '请选择是否为Gap基地', trigger: ['change'] }],
|
|
|
|
|
- 'gapInfo.adcode': [{ required: true, message: '请选择基地所在省/市/县/镇(乡)', trigger: ['change'] }],
|
|
|
|
|
- 'gapInfo.area': [{ required: true, message: '请填写基地面积', trigger: ['change'] }],
|
|
|
|
|
- longitudeLatitude: [
|
|
|
|
|
- {
|
|
|
|
|
- message: '请填写有效的经纬度(经度70-150,纬度4-53)',
|
|
|
|
|
- validator: (rule: any, value: any) => {
|
|
|
|
|
- const lng = Number(form.value?.gapInfo?.lng);
|
|
|
|
|
- const lat = Number(form.value?.gapInfo?.lat);
|
|
|
|
|
- if (!lng || !lat) return false;
|
|
|
|
|
- if (Number.isNaN(lng) || Number.isNaN(lat)) return false;
|
|
|
|
|
- return lng >= 70 && lng <= 150 && lat >= 4 && lat <= 53;
|
|
|
|
|
- },
|
|
|
|
|
- trigger: ['blur', 'change'],
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
-});
|
|
|
|
|
-// 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 () => {
|
|
|
|
|
- try {
|
|
|
|
|
- await upFormRef.value?.validate();
|
|
|
|
|
- } catch (error: any) {
|
|
|
|
|
- console.log(form.value);
|
|
|
|
|
-
|
|
|
|
|
- console.log(error, '++++++++');
|
|
|
|
|
- // 滚动到第一个错误字段
|
|
|
|
|
- const firstErrorField = error && error[0].prop;
|
|
|
|
|
- paging.value?.scrollIntoViewById(firstErrorField, 30, true);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- // 提交表单
|
|
|
|
|
- uni.showLoading({
|
|
|
|
|
- title: '提交中...',
|
|
|
|
|
- });
|
|
|
|
|
- try {
|
|
|
|
|
- const res = await useClientRequest.post('/plt-api/app/base/add', form.value);
|
|
|
|
|
- uni.hideLoading();
|
|
|
|
|
- if (!res || res !== 200) return;
|
|
|
|
|
- uni.hideLoading();
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '提交成功',
|
|
|
|
|
- icon: 'success',
|
|
|
|
|
- });
|
|
|
|
|
- // 返回上一页
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- uni.navigateBack();
|
|
|
|
|
- }, 1500);
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- uni.hideLoading();
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- 500,
|
|
|
|
|
- true
|
|
|
|
|
- );
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-const mapDrawArea = async () => {
|
|
|
|
|
- uni.$on('mapAreaData', (data: any) => {
|
|
|
|
|
- // 这里可以将 data 赋值给 form 中的相应字段
|
|
|
|
|
- form.value.gapInfo.basePic = data.gapInfo.basePic;
|
|
|
|
|
- form.value.gapInfo.area = String(data.gapInfo.area);
|
|
|
|
|
- form.value.gapInfo.areaUnit = data.gapInfo.areaUnit;
|
|
|
|
|
- form.value.coordinates = data.coordinates;
|
|
|
|
|
- uni.$off('mapAreaData');
|
|
|
|
|
- });
|
|
|
|
|
- if (form.value.gapInfo?.basePic) {
|
|
|
|
|
- // 暂存地图当前数据后跳转
|
|
|
|
|
- await useClientRequest.post('/plt-api/app/gapCertificationInfo/painting', {
|
|
|
|
|
- randomCode: form.value.id || form.value.randomCode,
|
|
|
|
|
- value: JSON.stringify({
|
|
|
|
|
- gapInfo: form.value.gapInfo,
|
|
|
|
|
- coordinates: form.value.coordinates,
|
|
|
|
|
- }),
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- uni.$u.route({
|
|
|
|
|
- type: 'navigateTo',
|
|
|
|
|
- url: '/tools/map-draw-area/index',
|
|
|
|
|
- params: {
|
|
|
|
|
- drawId: form.value.id || form.value.randomCode,
|
|
|
|
|
- unit: form.value.gapInfo.areaUnit || '亩',
|
|
|
|
|
- lng: form.value.gapInfo.lng || form.value.longitudeLatitude.lng || '',
|
|
|
|
|
- lat: form.value.gapInfo.lat || form.value.longitudeLatitude.lat || '',
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-const selectCpyMember = () => {
|
|
|
|
|
- uni.$on('selectCpyMember', (item: any) => {
|
|
|
|
|
- form.value.contactId = item.userInfo?.id;
|
|
|
|
|
- form.value.contactName = item.userInfo?.name;
|
|
|
|
|
- form.value.contactTel = item.userInfo?.phone;
|
|
|
|
|
- uni.$off('selectCpyMember');
|
|
|
|
|
- });
|
|
|
|
|
- uni.$u.route({
|
|
|
|
|
- type: 'navigateTo',
|
|
|
|
|
- url: '/tools/select-cpy-member/index',
|
|
|
|
|
- });
|
|
|
|
|
-};
|
|
|
|
|
-const confirmArea = (area: any) => {
|
|
|
|
|
- form.value.gapInfo.adcodeName = area.fullName;
|
|
|
|
|
-};
|
|
|
|
|
-onLoad((optins: any) => {
|
|
|
|
|
- if (optins.id) {
|
|
|
|
|
- } else {
|
|
|
|
|
- getLocationByAddress();
|
|
|
|
|
- }
|
|
|
|
|
-});
|
|
|
|
|
-// 获取当前经纬度返回地址
|
|
|
|
|
-const getLocationByAddress = async () => {
|
|
|
|
|
- const info = await uni.getSystemInfo();
|
|
|
|
|
- let locationEnabled = info.locationEnabled; //判断手机定位服务是否开启
|
|
|
|
|
- let locationAuthorized = info.locationAuthorized; //判断定位服务是否允许微信授权
|
|
|
|
|
- if (locationEnabled == false || locationAuthorized == false) {
|
|
|
|
|
- //手机定位服务(GPS)未授权
|
|
|
|
|
- uni.showModal({
|
|
|
|
|
- title: '提示',
|
|
|
|
|
- content: '请打开定位服务功能',
|
|
|
|
|
- showCancel: false, // 不显示取消按钮
|
|
|
|
|
- });
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const scope = await isOpenSetting('scope.userLocation');
|
|
|
|
|
- if (!scope) return;
|
|
|
|
|
- const location = await uni.getLocation({ type: 'gcj02', isHighAccuracy: true });
|
|
|
|
|
- form.value.longitudeLatitude = {
|
|
|
|
|
- lng: location.longitude,
|
|
|
|
|
- lat: location.latitude,
|
|
|
|
|
- };
|
|
|
|
|
-};
|
|
|
|
|
-</script>
|
|
|
|
|
-<style lang="scss" scoped>
|
|
|
|
|
-.z-paging-wrap {
|
|
|
|
|
- position: absolute;
|
|
|
|
|
- right: 0;
|
|
|
|
|
- top: 0;
|
|
|
|
|
- bottom: 0;
|
|
|
|
|
- left: 0;
|
|
|
|
|
-}
|
|
|
|
|
-.btn-aree-center {
|
|
|
|
|
- position: absolute;
|
|
|
|
|
- top: 0;
|
|
|
|
|
- right: 0;
|
|
|
|
|
- bottom: 0;
|
|
|
|
|
- left: 0;
|
|
|
|
|
-}
|
|
|
|
|
-</style>
|
|
|