种植基地-分页查询、删除接口对接
This commit is contained in:
		
							parent
							
								
									38f508e043
								
							
						
					
					
						commit
						512a2c9286
					
				| @ -3,7 +3,7 @@ import request from '@/utils/axios'; | ||||
| 
 | ||||
| // 新增(POST)
 | ||||
| export function createLandInspection(data) { | ||||
|   return request('land-resource/landInspection/save', { | ||||
|   return request('/land-resource/landInspection/save', { | ||||
|     method: 'POST', | ||||
|     data, | ||||
|   }); | ||||
| @ -11,7 +11,7 @@ export function createLandInspection(data) { | ||||
| 
 | ||||
| // 删除(DELETE)
 | ||||
| export function deleteLandInspection(id) { | ||||
|   return request(`land-resource/landInspection/${id}`, { | ||||
|   return request(`/land-resource/landInspection/${id}`, { | ||||
|     method: 'DELETE', | ||||
|   }); | ||||
| } | ||||
| @ -32,14 +32,14 @@ export function updateLandInspectionStatus(data = {}) { | ||||
| } | ||||
| // 查询详情(GET)
 | ||||
| export function getLandInspectionDetail(id) { | ||||
|   return request(`land-resource/landInspection/${id}`, { | ||||
|   return request(`/land-resource/landInspection/${id}`, { | ||||
|     method: 'GET', | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
| // 查询列表 admin (GET)
 | ||||
| export function fetchLandInspectionList(params = {}) { | ||||
|   return request('land-resource/landInspection/page', { | ||||
|   return request('/land-resource/landInspection/page', { | ||||
|     method: 'GET', | ||||
|     params, | ||||
|   }); | ||||
|  | ||||
							
								
								
									
										48
									
								
								sub-government-affairs-service/src/apis/planting/base.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								sub-government-affairs-service/src/apis/planting/base.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,48 @@ | ||||
| // 种植基地管理 (base)
 | ||||
| import request from '@/utils/axios'; | ||||
| 
 | ||||
| // 新增(POST)
 | ||||
| export function createBase(data) { | ||||
|   return request('/inputGoods/plantationInfo', { | ||||
|     method: 'POST', | ||||
|     data, | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
| // 删除(DELETE)
 | ||||
| export function deleteBase(id) { | ||||
|   return request(`/inputGoods/plantationInfo/${id}`, { | ||||
|     method: 'DELETE', | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
| // 批量删除(DELETE)
 | ||||
| export function deleteBaseBatch(data) { | ||||
|   return request(`/inputGoods/plantationInfo`, { | ||||
|     method: 'DELETE', | ||||
|     data, | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
| // 修改(PUT)
 | ||||
| export function updateBase(data = {}) { | ||||
|   return request('/inputGoods/plantationInfo', { | ||||
|     method: 'PUT', | ||||
|     data, | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
| // 查询列表(GET)
 | ||||
| export function fetchBaseList(params = {}) { | ||||
|   return request('/inputGoods/plantationInfo/page', { | ||||
|     method: 'GET', | ||||
|     params, | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
| // 查询详情(GET)
 | ||||
| export function getBaseDetail(id) { | ||||
|   return request(`/inputGoods/plantationInfo/${id}`, { | ||||
|     method: 'GET', | ||||
|   }); | ||||
| } | ||||
| @ -0,0 +1 @@ | ||||
| // 种植批次管理
 | ||||
							
								
								
									
										1
									
								
								sub-government-affairs-service/src/apis/planting/crop.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								sub-government-affairs-service/src/apis/planting/crop.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| // 作物基础数据API
 | ||||
| @ -0,0 +1 @@ | ||||
| // 统一导出入口
 | ||||
							
								
								
									
										1
									
								
								sub-government-affairs-service/src/apis/planting/task.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								sub-government-affairs-service/src/apis/planting/task.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| // 农事作业管理
 | ||||
| @ -10,11 +10,12 @@ | ||||
|         <el-button @click="handleReset">重置</el-button> | ||||
|       </el-form-item> | ||||
|     </el-form> | ||||
|     <!-- 功能区域 --> | ||||
|     <section class="function-bar"> | ||||
|     <!-- 功能区域 - 只在开发环境显示 --> | ||||
|     <section v-if="showAddButton" class="function-bar"> | ||||
|       <el-button type="primary" @click="handleAdd">新增</el-button> | ||||
|     </section> | ||||
|     <!-- 表格区域 --> | ||||
|     <div class="table-container"> | ||||
|       <TableComponent | ||||
|         :loading="loading" | ||||
|         :columns="columns" | ||||
| @ -25,13 +26,13 @@ | ||||
|         :show-pagination="true" | ||||
|         :show-border="true" | ||||
|         :show-sort="true" | ||||
|       style="max-height: calc(100vh - 220px)" | ||||
|         @page-change="handlePageChange" | ||||
|       > | ||||
|         <template #action="scope"> | ||||
|           <custom-table-operate :actions="actions" :data="scope" /> | ||||
|         </template> | ||||
|       </TableComponent> | ||||
|     </div> | ||||
| 
 | ||||
|     <!-- 详情/编辑对话框 --> | ||||
|     <el-dialog :key="dialogTitle" v-model="visible" :title="dialogTitle" width="60%" align-center :draggable="true"> | ||||
| @ -43,8 +44,8 @@ | ||||
|             <el-row :gutter="20"> | ||||
|               <el-col :span="12"> | ||||
|                 <!-- 基地编码 --> | ||||
|                 <el-form-item label="基地编码" prop="baseCode"> | ||||
|                   <el-input v-model="formData.baseCode" :readonly="isReadonly" clearable /> | ||||
|                 <el-form-item label="基地编码" prop="code"> | ||||
|                   <el-input v-model="formData.code" :readonly="isReadonly" clearable /> | ||||
|                 </el-form-item> | ||||
| 
 | ||||
|                 <!-- 所属行政区域 --> | ||||
| @ -89,8 +90,8 @@ | ||||
| 
 | ||||
|               <el-col :span="12"> | ||||
|                 <!-- 基地名称 --> | ||||
|                 <el-form-item label="基地名称" prop="baseName"> | ||||
|                   <el-input v-model="formData.baseName" :readonly="isReadonly" clearable /> | ||||
|                 <el-form-item label="基地名称" prop="name"> | ||||
|                   <el-input v-model="formData.name" :readonly="isReadonly" clearable /> | ||||
|                 </el-form-item> | ||||
| 
 | ||||
|                 <!-- 所属网格 --> | ||||
| @ -104,7 +105,7 @@ | ||||
|                     <el-input v-model="formData.longitude" placeholder="经度" :readonly="isReadonly" style="width: 45%" /> | ||||
|                     <span style="margin: 0 5px">,</span> | ||||
|                     <el-input v-model="formData.latitude" placeholder="纬度" :readonly="isReadonly" style="width: 45%" /> | ||||
|                     <el-button v-if="!isReadonly" type="primary" link @click="handleSelectOnMap"> 地图选取 </el-button> | ||||
|                     <!-- <el-button v-if="!isReadonly" type="primary" link @click="handleSelectOnMap"> 地图选取 </el-button> --> | ||||
|                   </div> | ||||
|                 </el-form-item> | ||||
| 
 | ||||
| @ -225,7 +226,9 @@ | ||||
| </template> | ||||
| 
 | ||||
| <script setup> | ||||
| import { ref, onMounted } from 'vue'; | ||||
| import { ref, onMounted, computed } from 'vue'; | ||||
| import { ElMessage, ElMessageBox } from 'element-plus'; | ||||
| import { createBase, updateBase, deleteBase, deleteBaseBatch, fetchBaseList, getBaseDetail } from '@/apis/planting/base'; | ||||
| import { mockData } from './mockData'; | ||||
| 
 | ||||
| // ==================== 常量定义 ==================== | ||||
| @ -234,7 +237,9 @@ const DIALOG_TITLE = { | ||||
|   EDIT: '编辑基地信息', | ||||
|   ADD: '新增基地信息', | ||||
| }; | ||||
| 
 | ||||
| // 获取环境变量 | ||||
| const env = import.meta.env.VITE_MODE; | ||||
| console.log('环境变量:', env); | ||||
| // ==================== 状态管理 ==================== | ||||
| const loading = ref(false); | ||||
| const visible = ref(false); | ||||
| @ -244,13 +249,7 @@ const activeFormTab = ref('basic'); | ||||
| 
 | ||||
| // 表单数据 | ||||
| const searchForm = ref({}); | ||||
| const formData = ref({ | ||||
|   gridName: '', | ||||
|   gridAreaCode: '', | ||||
|   scope: '', | ||||
|   scopeImg: '', | ||||
|   note: '', | ||||
| }); | ||||
| const formData = ref({}); | ||||
| const initialFormData = { ...formData.value }; | ||||
| 
 | ||||
| // 分页数据 | ||||
| @ -265,27 +264,27 @@ const tableData = ref([]); | ||||
| 
 | ||||
| // ==================== 表格配置 ==================== | ||||
| const columns = ref([ | ||||
|   { label: '基地编码', prop: 'baseCode' }, | ||||
|   { label: '基地名称', prop: 'baseName' }, | ||||
|   { label: '基地编码', prop: 'code' }, | ||||
|   { label: '基地名称', prop: 'name' }, | ||||
|   { label: '所属行政区域', prop: 'regionName' }, | ||||
|   { label: '所属网格', prop: 'gridName' }, | ||||
|   { label: '具体位置', prop: 'adress' }, | ||||
|   { label: '具体位置', prop: 'location' }, | ||||
|   { | ||||
|     label: '经纬度', | ||||
|     prop: 'coordinate', | ||||
|     formatter: (row) => `${row.longitude}, ${row.latitude}`, | ||||
|     // formatter: (row) => `${row.longitude}, ${row.latitude}`, | ||||
|   }, | ||||
|   { label: '气候条件', prop: 'weather' }, | ||||
|   { label: '气候条件', prop: 'climate' }, | ||||
|   { label: '海拔(米)', prop: 'altitude' }, | ||||
|   { | ||||
|     label: '面积(亩)', | ||||
|     prop: 'area', | ||||
|     formatter: (row, column, cellValue) => `${Number(cellValue).toFixed(2)} 亩`, | ||||
|   }, | ||||
|   { label: '使用状态', prop: 'status' }, | ||||
|   { label: '经营主体代码', prop: 'businessCode' }, | ||||
|   { label: '经营主体类型', prop: 'businessType' }, | ||||
|   { label: '经营主体名称', prop: 'businessSubjectName' }, | ||||
|   { label: '使用状态', prop: 'statusName' }, | ||||
|   { label: '经营主体代码', prop: 'businessId' }, | ||||
|   { label: '经营主体类型', prop: 'businessTypeName' }, | ||||
|   { label: '经营主体名称', prop: 'businessName' }, | ||||
|   { label: '创建时间', prop: 'createTime' }, | ||||
|   { | ||||
|     label: '操作', | ||||
| @ -319,13 +318,23 @@ onMounted(() => { | ||||
|   getData(); | ||||
| }); | ||||
| 
 | ||||
| // ==================== 计算属性 ==================== | ||||
| const showAddButton = computed(() => { | ||||
|   return env === 'DEV'; | ||||
| }); | ||||
| 
 | ||||
| // ==================== 数据获取 ==================== | ||||
| const getData = async () => { | ||||
|   loading.value = true; | ||||
|   try { | ||||
|     await new Promise((resolve) => setTimeout(resolve, 300)); | ||||
|     tableData.value = mockData; | ||||
|     pageData.value.total = tableData.value.length; | ||||
|     const res = await fetchBaseList({ | ||||
|       ...searchForm.value, | ||||
|       current: pageData.value.currentPage, | ||||
|       size: pageData.value.pageSize, | ||||
|     }); | ||||
| 
 | ||||
|     tableData.value = res.data.records || []; | ||||
|     pageData.value.total = res.data.total || 0; | ||||
|   } finally { | ||||
|     loading.value = false; | ||||
|   } | ||||
| @ -360,8 +369,12 @@ const handleEdit = (row) => { | ||||
| }; | ||||
| 
 | ||||
| const handleDelete = async (id) => { | ||||
|   console.log('删除', id); | ||||
|   // 实际删除逻辑 | ||||
|   await ElMessageBox.confirm('确定删除该基地信息吗?', '提示', { | ||||
|     type: 'warning', | ||||
|   }); | ||||
|   await deleteBase(id); | ||||
|   ElMessage.success('删除成功'); | ||||
|   getData(); | ||||
| }; | ||||
| 
 | ||||
| const resetForm = () => { | ||||
| @ -387,10 +400,24 @@ const submitAll = () => { | ||||
| 
 | ||||
| <style scoped lang="scss"> | ||||
| .custom-page { | ||||
|   display: flex; | ||||
|   flex-direction: column; | ||||
|   height: calc(100vh - 150px); | ||||
|   .search-bar { | ||||
|     flex-shrink: 0; | ||||
|     margin-bottom: 20px; | ||||
|   } | ||||
| 
 | ||||
|   .table-container { | ||||
|     flex: 1; | ||||
|     min-height: 0; /* 解决flex容器内滚动问题 */ | ||||
|     display: flex; | ||||
|     flex-direction: column; | ||||
|     :deep(.el-table) { | ||||
|       flex: 1; | ||||
|       overflow: auto; | ||||
|     } | ||||
|   } | ||||
|   .tabs-wrapper { | ||||
|     width: 100%; | ||||
|     display: flex; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user