index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <view class="ksqulc">
  3. <z-paging ref="paging" bgColor="#F7F7F7" safe-area-inset-bottom paging-class="paging-btm-shadow" refresher-only @onRefresh="onRefresh" scroll-with-animation>
  4. <template #top>
  5. <ut-navbar title="标记为三无一全基地" :fixed="false" border></ut-navbar>
  6. </template>
  7. <view class="p-rtv">
  8. <view ref="baseRef" class="pd-24" id="base12345">
  9. <view class="startline-title">证明材料</view>
  10. </view>
  11. <view class="pd-24 bg-#fff mb-10">
  12. <up-form class="p-rtv" labelPosition="top" :model="formSwyq" :rules="rulesSwyq" labelWidth="auto" ref="upFormRef">
  13. <!-- 校验定位:基地类型 -->
  14. <!-- 基地信息部分 -->
  15. <view>
  16. <!-- 选择获评品种 -->
  17. <view class="h-1" id="swyqMedicineCodepppp"></view>
  18. <up-form-item @click="selectMedicine" borderBottom label="获评品种" required prop="swyqMedicineCode">
  19. <view v-if="formSwyq.swyqMedicineCode" class="f-s-30 c-333 f-w-5 flex1">{{ formSwyq.swyqMedicineName }}</view>
  20. <view v-else class="f-s-30 c-ccc f-w-4 flex1">请选择获评品种</view>
  21. <template #right>
  22. <up-icon size="22rpx" color="#2A6D52" name="arrow-down-fill"></up-icon>
  23. </template>
  24. </up-form-item>
  25. <!-- 校验定位:建设时间 -->
  26. <view class="h-1" id="swyqRatedDatepppp"></view>
  27. <ut-datetime-picker v-model="formSwyq.swyqRatedDate" mode="date" dateFields="day">
  28. <up-form-item borderBottom label="获评三无一全基地时间" required prop="swyqRatedDate">
  29. <up-input v-model="formSwyq.swyqRatedDate" placeholder="请选择获评三无一全基地时间" border="none" clearable></up-input>
  30. <template #right>
  31. <up-icon size="22rpx" color="#2A6D52" name="arrow-down-fill"></up-icon>
  32. </template>
  33. </up-form-item>
  34. </ut-datetime-picker>
  35. <!-- 官方公示证明材料 -->
  36. <view class="h-1" id="swyqCertFilepppp"></view>
  37. <up-form-item borderBottom required prop="swyqCertFile">
  38. <view class="flex1">
  39. <view style="margin-bottom: 10rpx">
  40. <span class="c-666 f-s-30">官方公示证明材料</span>
  41. <span class="f-s-26 c-999">(可上传9张)</span>
  42. </view>
  43. <ut-upload v-model="formSwyq.swyqCertFile" :max-count="9"></ut-upload>
  44. </view>
  45. </up-form-item>
  46. <!-- 官方公示网址 -->
  47. <view class="h-1" id="swyqUrlpppp"></view>
  48. <up-form-item borderBottom label="官方公示网址" prop="swyqUrl" required>
  49. <up-input v-model="formSwyq.swyqUrl" placeholder="请输入官方公示网址" border="none" clearable></up-input>
  50. </up-form-item>
  51. </view>
  52. </up-form>
  53. </view>
  54. <view ref="baseRef" class="pd-24" id="base12345">
  55. <view class="startline-title">所标记的基本信息如下,请核对</view>
  56. </view>
  57. <view class="pd-24 bg-#fff mb-10">
  58. <view class="f-s-30 pd2-16-0 info-border-bottom">
  59. <span class="c-#666">基地名称:</span>
  60. <span class="c-#333">{{ form?.baseInfo?.baseName || '-' }}</span>
  61. </view>
  62. <view class="f-s-30 pd2-16-0 info-border-bottom">
  63. <span class="c-#666">基地类型:</span>
  64. <span class="c-#333">{{ selectDictLabel(pt_base_type, form?.baseInfo?.baseType) || '-' }}</span>
  65. </view>
  66. <view class="f-s-30 pd2-16-0 info-border-bottom">
  67. <view class="f-s-30 c-#666 mb-10">基地范围:</view>
  68. <view class="bg-#f7f7f7 d-flex ov-hd p-rtv">
  69. <image @click="previewImage([form?.baseInfo?.gapInfo?.basePic])" class="w-full" v-if="form?.baseInfo?.gapInfo?.basePic" preview :src="form?.baseInfo?.gapInfo?.basePic" mode="'widthFix'"></image>
  70. <view v-else class="w-full h-120 d-flex a-c j-c c-999">暂无基地范围</view>
  71. </view>
  72. </view>
  73. <view class="f-s-30 pd2-16-0 info-border-bottom">
  74. <span class="c-#666">基地面积:</span>
  75. <span class="c-#333">{{ form?.baseInfo?.gapInfo?.area || '-' }}{{ form?.baseInfo?.gapInfo?.areaUnit || mapUnitByBaseType[form?.baseInfo?.baseType || '1'] }}</span>
  76. </view>
  77. <view class="f-s-30 pd2-16-0 info-border-bottom">
  78. <span class="c-#666">基地所在地区:</span>
  79. <span class="c-#333">{{ form?.baseInfo?.gapInfo?.adcodeName || '-' }}</span>
  80. </view>
  81. <view class="f-s-30 pd2-16-0 info-border-bottom">
  82. <span class="c-#666">详细地址:</span>
  83. <span class="c-#333">{{ form?.baseInfo?.gapInfo?.address || '-' }}</span>
  84. </view>
  85. <view class="f-s-30 pd2-16-0 info-border-bottom">
  86. <span class="c-#666">基地经纬度:</span>
  87. <span class="c-#333">E{{ form?.baseInfo?.gapInfo?.lng || '-' }}, N{{ form?.baseInfo?.gapInfo?.lat || '-' }}</span>
  88. </view>
  89. </view>
  90. </view>
  91. <template #bottom>
  92. <view class="pd-20 d-flex">
  93. <up-button type="primary" @click="submitForm">确认并提交</up-button>
  94. </view>
  95. </template>
  96. </z-paging>
  97. </view>
  98. </template>
  99. <script setup lang="ts">
  100. import { useClientRequest } from '@/utils/request';
  101. import { getUrlParams, recursiveDecodeURIComponent } from '@/utils/ruoyi';
  102. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  103. const { yes_no, pt_org_type, pt_base_type, pt_water_type, pt_soil_type, pt_soil_texture, pt_light_type, pt_capacity_unit } = toRefs<any>(proxy?.useDict('yes_no', 'pt_org_type', 'pt_base_type', 'pt_water_type', 'pt_soil_type', 'pt_soil_texture', 'pt_light_type', 'pt_capacity_unit'));
  104. const tabs = reactive([
  105. { label: '基本信息', value: 'base' },
  106. { label: '地块信息', value: 'plot' },
  107. { label: '选址依据及环境信息', value: 'environment' },
  108. ]);
  109. const activeTab = ref('base');
  110. const paging = ref<any>(null);
  111. const mapUnitByBaseType: any = {
  112. '1': '亩',
  113. '2': '平方米',
  114. '3': '平方米',
  115. };
  116. const form = ref<any>({});
  117. const formSwyq = ref<any>({
  118. swyqVarietyId: undefined,
  119. swyqMedicineName: '',
  120. swyqRatedDate: '',
  121. swyqCertFile: '',
  122. swyqUrl: '',
  123. });
  124. const rulesSwyq = reactive<any>({
  125. swyqVarietyId: [{ type: 'number', required: true, message: '请选择获评品种', trigger: 'change' }],
  126. swyqRatedDate: [{ required: true, message: '请选择获评三无一全基地时间', trigger: 'change' }],
  127. swyqCertFile: [{ required: true, message: '请上传官方公示证明材料', trigger: 'change' }],
  128. swyqUrl: [{ required: true, message: '请输入官方公示网址', trigger: 'change' }],
  129. });
  130. // 改成去选择获评品种页面
  131. const selectMedicine = () => {
  132. uni.$on('medicineSelected', (medicine: any) => {
  133. console.log(medicine);
  134. formSwyq.value.swyqMedicineCode = medicine.medicineCode;
  135. formSwyq.value.swyqMedicineName = medicine.medicineName;
  136. uni.$off('medicineSelected');
  137. });
  138. uni.$u.route({
  139. type: 'navigateTo',
  140. url: '/tools/select-medicine/index',
  141. params: {
  142. singleSelect: true,
  143. },
  144. });
  145. };
  146. const did = ref('');
  147. // 根据id获取基地详情
  148. const getDetailById = async (id: string) => {
  149. const res = await useClientRequest.get(`/plt-api/app/base/getInfoAllById/${id}`);
  150. if (res && res.code === 200) {
  151. form.value = res.data || {};
  152. formSwyq.value.swyqMedicineCode = res.data?.baseInfo?.swyqMedicineCode || undefined;
  153. formSwyq.value.swyqMedicineName = res.data?.baseInfo?.swyqMedicineName || '';
  154. formSwyq.value.swyqRatedDate = res.data?.baseInfo?.swyqRatedDate || '';
  155. formSwyq.value.swyqCertFile = res.data?.baseInfo?.swyqCertFile || '';
  156. formSwyq.value.swyqUrl = res.data?.baseInfo?.swyqUrl || '';
  157. }
  158. };
  159. const onRefresh = () => {
  160. getDetailById(did.value);
  161. paging.value?.complete();
  162. };
  163. const upFormRef = ref<any>(null);
  164. const submitForm = async () => {
  165. uni.$u.debounce(
  166. async () => {
  167. try {
  168. await upFormRef.value?.validate();
  169. } catch (error: any) {
  170. // 滚动到第一个错误字段
  171. const firstErrorField = error && error[0].prop + 'pppp';
  172. paging.value?.scrollIntoViewById(firstErrorField, 30, true);
  173. return;
  174. }
  175. // 提交表单
  176. uni.showLoading({
  177. title: '提交中...',
  178. });
  179. try {
  180. const res = did.value ? await useClientRequest.post('/plt-api/app/base/updateSwyqBase', {
  181. ...formSwyq.value,
  182. id: did.value,
  183. }) : await useClientRequest.post('/plt-api/app/base/addSwyqBase', {
  184. ...formSwyq.value,
  185. });
  186. if (!res || res.code !== 200) return;
  187. uni.hideLoading();
  188. uni.showToast({
  189. title: '提交成功',
  190. icon: 'success',
  191. });
  192. uni.$emit('refreshBase');
  193. uni.$emit('refreshBaseList');
  194. // 返回上一页
  195. uni.$u.route({
  196. type: 'redirect',
  197. url: '/plant/base/mark-swyq-base-detail/index',
  198. params: {
  199. id: did.value,
  200. },
  201. });
  202. } catch (error) {
  203. }
  204. },
  205. 500,
  206. true
  207. );
  208. };
  209. // 判断节点是否在可视区域内如果在则切换tab createIntersectionObserver
  210. onLoad((options: any) => {
  211. did.value = options?.id || getUrlParams(recursiveDecodeURIComponent(options?.q))?.id || '';
  212. getDetailById(did.value);
  213. });
  214. </script>
  215. <style lang="scss" scoped>
  216. .z-paging-wrap {
  217. position: absolute;
  218. right: 0;
  219. top: 0;
  220. bottom: 0;
  221. left: 0;
  222. }
  223. .btn-aree-center {
  224. position: absolute;
  225. top: 0;
  226. right: 0;
  227. bottom: 0;
  228. left: 0;
  229. }
  230. .plot-item {
  231. border: 1rpx solid rgba($u-primary, 0.4);
  232. border-radius: 10rpx;
  233. }
  234. .gap-info-card {
  235. border: 1rpx solid rgba($u-primary, 0.4);
  236. }
  237. .ksqulc {
  238. position: relative;
  239. height: 100vh;
  240. }
  241. </style>