生产经营主体
This commit is contained in:
		
							parent
							
								
									711c632cfc
								
							
						
					
					
						commit
						4c65ec3e9e
					
				| @ -17,5 +17,5 @@ VITE_APP_UPLOAD_API = '/uploadApis' | ||||
| # VITE_APP_UPLOAD_URL = 'http://47.109.205.240:9300' | ||||
| # 内网接口地址 | ||||
| VITE_APP_BASE_URL = 'http://192.168.18.99:8080' | ||||
| VITE_APP_UPLOAD_URL = 'http://192.168.18.74:8080' | ||||
| VITE_APP_UPLOAD_URL = 'http://192.168.18.99:8080' | ||||
| # VITE_APP_VIST_URL = 'http://192.168.18.99' | ||||
|  | ||||
| @ -14,4 +14,4 @@ VITE_APP_UPLOAD_API = '/uploadApis' | ||||
| 
 | ||||
| # 内网接口地址 | ||||
| VITE_APP_BASE_URL = 'http://192.168.18.99:8080' | ||||
| VITE_APP_UPLOAD_URL = 'http://192.168.18.74:8080' | ||||
| VITE_APP_UPLOAD_URL = 'http://192.168.18.99:8080' | ||||
|  | ||||
| @ -104,21 +104,6 @@ const fetchAreaData = async () => { | ||||
| //   } | ||||
| // ); | ||||
| 
 | ||||
| // 内部更新 => 外部同步 | ||||
| watch( | ||||
|   selectedAreaPath, | ||||
|   (val) => { | ||||
|     if (props.emitPath) { | ||||
|       // 期望数组模式,确保输出数组 | ||||
|       emit('update:modelValue', Array.isArray(val) ? val : []); | ||||
|     } else { | ||||
|       // 期望字符串模式,确保输出字符串 | ||||
|       emit('update:modelValue', typeof val === 'string' ? val : ''); | ||||
|     } | ||||
|   }, | ||||
|   { deep: true } | ||||
| ); | ||||
| 
 | ||||
| onMounted(() => { | ||||
|   fetchAreaData(); | ||||
| }); | ||||
|  | ||||
| @ -13,31 +13,31 @@ const inputSuppliesRoutes = [ | ||||
|         path: '/sub-government-affairs-service/material/pesticide', | ||||
|         name: 'input-supplies-pesticide', | ||||
|         component: () => import('@/views/inputSuppliesManage/material/pesticide/index.vue'), | ||||
|         meta: { title: '农药管理', icon: '' }, | ||||
|         meta: { title: '农药管理', icon: 'Orange' }, | ||||
|       }, | ||||
|       { | ||||
|         path: '/sub-government-affairs-service/material/fertilizer', | ||||
|         name: 'input-supplies-fertilizer', | ||||
|         component: () => import('@/views/inputSuppliesManage/material/fertilizer/index.vue'), | ||||
|         meta: { title: '肥料管理', icon: '' }, | ||||
|         meta: { title: '肥料管理', icon: 'Grid' }, | ||||
|       }, | ||||
|       { | ||||
|         path: '/sub-government-affairs-service/material/seed', | ||||
|         name: 'input-supplies-seed', | ||||
|         component: () => import('@/views/inputSuppliesManage/material/seed/index.vue'), | ||||
|         meta: { title: '种子使用监督管理', icon: '' }, | ||||
|         meta: { title: '种子使用监督管理', icon: 'Watermelon' }, | ||||
|       }, | ||||
|       { | ||||
|         path: '/sub-government-affairs-service/material/others', | ||||
|         name: 'input-supplies-others', | ||||
|         component: () => import('@/views/inputSuppliesManage/material/others/index.vue'), | ||||
|         meta: { title: '其他投入品', icon: '' }, | ||||
|         meta: { title: '其他投入品', icon: 'TakeawayBox' }, | ||||
|       }, | ||||
|       { | ||||
|         path: '/sub-government-affairs-service/material/annualPlans', | ||||
|         name: 'annualPlans', | ||||
|         component: () => import('@/views/inputSuppliesManage/material/annualPlan/index.vue'), | ||||
|         meta: { title: '种植进度网格化管理', icon: '' }, | ||||
|         meta: { title: '种植进度网格化管理', icon: 'Timer' }, | ||||
|       }, | ||||
|       // {
 | ||||
|       //   path: '/sub-government-affairs-service/materialManage',
 | ||||
|  | ||||
| @ -18,7 +18,7 @@ export default [ | ||||
|         path: '/sub-government-affairs-service/individual', | ||||
|         component: () => import('@/views/productOperateMain/individual/index.vue'), | ||||
|         name: 'individual', | ||||
|         meta: { title: '农户管理', icon: '' }, | ||||
|         meta: { title: '农户管理', icon: 'Place' }, | ||||
|       }, | ||||
|       // {
 | ||||
|       //   path: '/sub-government-affairs-service/collective',
 | ||||
| @ -30,7 +30,7 @@ export default [ | ||||
|         path: '/sub-government-affairs-service/coop', | ||||
|         component: () => import('@/views/productOperateMain/coOp/index.vue'), | ||||
|         name: 'coop', | ||||
|         meta: { title: '企业管理', icon: '' }, | ||||
|         meta: { title: '企业管理', icon: 'Finished' }, | ||||
|       }, | ||||
|       // {
 | ||||
|       //   path: '/sub-government-affairs-service/enterprise',
 | ||||
|  | ||||
| @ -13,19 +13,7 @@ | ||||
|           <el-input v-model="localForm.contactPerson" placeholder="请输入" /> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="农企/合作社照片"> | ||||
|           <el-upload | ||||
|             action="#" | ||||
|             :http-request="customUploadRequest" | ||||
|             :on-success="(res, file) => handleUploadSuccess(res, file, 'cooperativePhoto')" | ||||
|             :file-list="cooperativePhotoList" | ||||
|             list-type="picture-card" | ||||
|             :limit="1" | ||||
|             :on-exceed="handleExceed" | ||||
|             :on-remove="() => handleRemove('cooperativePhoto')" | ||||
|           > | ||||
|             <el-icon><Plus /></el-icon> | ||||
|           </el-upload> | ||||
|           <!-- <FileUploader v-model="localForm.cooperativePhoto" :limit="1" /> --> | ||||
|           <FileUploader v-model="localForm.cooperativePhoto" :limit="1" /> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
| 
 | ||||
| @ -47,18 +35,6 @@ | ||||
|     <el-row :gutter="20"> | ||||
|       <el-col :span="24"> | ||||
|         <el-form-item label="营业执照"> | ||||
|           <!-- <el-upload | ||||
|             action="#" | ||||
|             :http-request="customUploadRequest" | ||||
|             :on-success="(res, file) => handleUploadSuccess(res, file, 'businessLicence')" | ||||
|             :file-list="businessLicenceList" | ||||
|             list-type="picture-card" | ||||
|             :limit="1" | ||||
|             :on-exceed="handleExceed" | ||||
|             :on-remove="() => handleRemove('businessLicence')" | ||||
|           > | ||||
|             <el-icon><Plus /></el-icon> | ||||
|           </el-upload> --> | ||||
|           <FileUploader v-model="localForm.businessLicence" :limit="1" /> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
| @ -67,14 +43,7 @@ | ||||
| </template> | ||||
| 
 | ||||
| <script setup> | ||||
| import { ref, reactive, watch } from 'vue'; | ||||
| import { Plus } from '@element-plus/icons-vue'; | ||||
| import cloneDeep from 'lodash/cloneDeep'; | ||||
| import { CommonUpload } from '@/apis/index'; | ||||
| import { ElMessage } from 'element-plus'; | ||||
| import Attrs from './Attrs.vue'; | ||||
| import { useCoop } from '../../../../store/modules/coop'; | ||||
| const localForm = useCoop().$state.data; | ||||
| import { ref, toRefs, reactive, watch } from 'vue'; | ||||
| 
 | ||||
| const props = defineProps({ | ||||
|   modelValue: { | ||||
| @ -82,97 +51,11 @@ const props = defineProps({ | ||||
|     required: true, | ||||
|     default: () => ({}), | ||||
|   }, | ||||
|   // readonly: Boolean, | ||||
|   readonly: Boolean, | ||||
| }); | ||||
| 
 | ||||
| const ossUrl = 'http://gov-cloud.oss-cn-chengdu.aliyuncs.com/'; | ||||
| const cooperativePhotoList = ref([]); | ||||
| const businessLicenceList = ref([]); | ||||
| 
 | ||||
| const emit = defineEmits(['update:modelValue']); | ||||
| 
 | ||||
| // 建立本地副本,避免直接修改 props | ||||
| // const localForm = ref({ ...props.modelValue }); | ||||
| 
 | ||||
| // 深度监听本地副本的变化,实时更新父组件 | ||||
| // watch( | ||||
| //   localForm, | ||||
| //   (newVal) => { | ||||
| //     emit('update:modelValue', { ...newVal }); | ||||
| //   }, | ||||
| //   { deep: true } | ||||
| // ); | ||||
| // watch( | ||||
| //   () => props.modelValue, | ||||
| //   (newVal) => { | ||||
| //     Object.assign(localForm, cloneDeep(newVal)); | ||||
| //   }, | ||||
| //   { deep: true } | ||||
| // ); | ||||
| 
 | ||||
| const customUploadRequest = async (options) => { | ||||
|   const formData = new FormData(); | ||||
|   formData.append('file', options.file); | ||||
| 
 | ||||
|   try { | ||||
|     const response = await CommonUpload(formData); | ||||
|     options.onSuccess(response, options.file); | ||||
|     return response; | ||||
|   } catch (err) { | ||||
|     console.error('上传失败', err); | ||||
|     options.onError(err); | ||||
|     throw err; | ||||
|   } | ||||
| }; | ||||
| const handleUploadSuccess = (res, file, fieldName) => { | ||||
|   localForm[fieldName] = res.data.url; | ||||
|   // 更新预览列表 | ||||
|   const previewItem = { | ||||
|     name: res.data.name, | ||||
|     url: ossUrl + res.data.url, // 确保这是完整的可访问URL | ||||
|     status: 'success', | ||||
|   }; | ||||
|   if (fieldName === 'cooperativePhoto') { | ||||
|     cooperativePhotoList.value = [previewItem]; | ||||
|   } else { | ||||
|     businessLicenceList.value = [previewItem]; | ||||
|   } | ||||
| }; | ||||
| // 处理移除图片 | ||||
| const handleRemove = (fieldName) => { | ||||
|   localForm[fieldName] = ''; | ||||
|   if (fieldName === 'cooperativePhoto') { | ||||
|     cooperativePhotoList.value = []; | ||||
|   } else { | ||||
|     businessLicenceList.value = []; | ||||
|   } | ||||
| }; | ||||
| 
 | ||||
| // 处理文件超出限制 | ||||
| const handleExceed = () => { | ||||
|   ElMessage.warning('只能上传一张图片,请先删除当前图片'); | ||||
| }; | ||||
| 
 | ||||
| // 初始化时如果有图片,设置预览 | ||||
| if (localForm.cooperativePhoto) { | ||||
|   cooperativePhotoList.value = [ | ||||
|     { | ||||
|       name: '合作社照片', | ||||
|       url: ossUrl + localForm.cooperativePhoto, | ||||
|       status: 'success', | ||||
|     }, | ||||
|   ]; | ||||
| } | ||||
| 
 | ||||
| if (localForm.businessLicence) { | ||||
|   businessLicenceList.value = [ | ||||
|     { | ||||
|       name: '营业执照', | ||||
|       url: ossUrl + localForm.businessLicence, | ||||
|       status: 'success', | ||||
|     }, | ||||
|   ]; | ||||
| } | ||||
| const { modelValue: localForm } = toRefs(props); | ||||
| </script> | ||||
| 
 | ||||
| <style scoped lang="scss"> | ||||
|  | ||||
| @ -72,7 +72,7 @@ import { reactive, watch } from 'vue'; | ||||
| import { Plus } from '@element-plus/icons-vue'; | ||||
| import cloneDeep from 'lodash/cloneDeep'; | ||||
| import { useCoop } from '../../../../store/modules/coop'; | ||||
| const localForm = useCoop().$state.data; | ||||
| // const localForm = useCoop().$state.data; | ||||
| 
 | ||||
| const props = defineProps({ | ||||
|   modelValue: { | ||||
| @ -88,16 +88,16 @@ const props = defineProps({ | ||||
| const emit = defineEmits(['update:modelValue']); | ||||
| 
 | ||||
| // 本地副本,存放各表的文件列表 | ||||
| // const localForm = reactive(cloneDeep(props.modelValue)); | ||||
| const localForm = reactive(cloneDeep(props.modelValue)); | ||||
| 
 | ||||
| // watch 同步回父组件 | ||||
| // watch( | ||||
| //   () => localForm, | ||||
| //   (val) => { | ||||
| //     emit('update:modelValue', { ...val }); | ||||
| //   }, | ||||
| //   { deep: true } | ||||
| // ); | ||||
| watch( | ||||
|   () => localForm, | ||||
|   (val) => { | ||||
|     emit('update:modelValue', { ...val }); | ||||
|   }, | ||||
|   { deep: true } | ||||
| ); | ||||
| // watch( | ||||
| //   () => props.modelValue, | ||||
| //   (newVal) => { | ||||
|  | ||||
| @ -2,34 +2,32 @@ | ||||
|   <el-form :model="localForm" label-width="160px" :disabled="readonly"> | ||||
|     <div class="credit-evaluation"> | ||||
|       <h3>信用评级</h3> | ||||
| 
 | ||||
|       <el-form-item label="信用评价"> | ||||
|         <el-rate v-model="localForm.creditEvaluation" allow-half show-score score-template="{value} 分" /> | ||||
|         <el-rate v-model="localForm.creditEvaluation" show-score score-template="{value} 分" /> | ||||
|       </el-form-item> | ||||
| 
 | ||||
|       <el-form-item label="带动周边农户"> | ||||
|         <el-rate v-model="localForm.supportedFarmers" allow-half show-score score-template="{value} 分" /> | ||||
|         <el-rate v-model="localForm.supportedFarmers" show-score score-template="{value} 分" /> | ||||
|       </el-form-item> | ||||
| 
 | ||||
|       <el-form-item label="社会效益"> | ||||
|         <el-rate v-model="localForm.socialImpact" allow-half show-score score-template="{value} 分" /> | ||||
|         <el-rate v-model="localForm.socialImpact" show-score score-template="{value} 分" /> | ||||
|       </el-form-item> | ||||
| 
 | ||||
|       <el-form-item label="高新技术应用"> | ||||
|         <el-rate v-model="localForm.techApplication" allow-half show-score score-template="{value} 分" /> | ||||
|         <el-rate v-model="localForm.techApplication" show-score score-template="{value} 分" /> | ||||
|       </el-form-item> | ||||
| 
 | ||||
|       <el-form-item label="产品质量及服务保障"> | ||||
|         <el-rate v-model="localForm.productQuality" allow-half show-score score-template="{value} 分" /> | ||||
|         <el-rate v-model="localForm.productQuality" show-score score-template="{value} 分" /> | ||||
|       </el-form-item> | ||||
|     </div> | ||||
|   </el-form> | ||||
| </template> | ||||
| 
 | ||||
| <script setup> | ||||
| import { reactive, watch } from 'vue'; | ||||
| import cloneDeep from 'lodash/cloneDeep'; | ||||
| import { useCoop } from '../../../../store/modules/coop'; | ||||
| const localForm = useCoop().$state.data; | ||||
| import { toRefs, watch } from 'vue'; | ||||
| 
 | ||||
| const props = defineProps({ | ||||
|   modelValue: { | ||||
| @ -42,8 +40,10 @@ const props = defineProps({ | ||||
| 
 | ||||
| const emit = defineEmits(['update:modelValue']); | ||||
| 
 | ||||
| // const localForm = reactive(cloneDeep(props.modelValue)); | ||||
| // 解构出响应式引用,保持与父组件绑定 | ||||
| const { modelValue: localForm } = toRefs(props); | ||||
| 
 | ||||
| // 如需在评分变化时同步更新父组件(可选,某些场景可能冗余) | ||||
| // watch( | ||||
| //   localForm, | ||||
| //   (newVal) => { | ||||
| @ -51,14 +51,8 @@ const emit = defineEmits(['update:modelValue']); | ||||
| //   }, | ||||
| //   { deep: true } | ||||
| // ); | ||||
| // watch( | ||||
| //   () => props.modelValue, | ||||
| //   (newVal) => { | ||||
| //     Object.assign(localForm, cloneDeep(newVal)); | ||||
| //   }, | ||||
| //   { deep: true } | ||||
| // ); | ||||
| </script> | ||||
| 
 | ||||
| <style scoped lang="scss"> | ||||
| .credit-evaluation { | ||||
|   width: 600px; | ||||
|  | ||||
| @ -105,8 +105,8 @@ import { ref, reactive, watch, onMounted, computed } from 'vue'; | ||||
| import { CRUD_OPTIONS } from '@/config'; | ||||
| import { ElMessageBox, ElMessage } from 'element-plus'; | ||||
| import { getMemberList, addMember, updateMember, deleteMembers } from '@/apis/businessEntity'; | ||||
| import { useCoop } from '../../../../store/modules/coop'; | ||||
| const defaultFormData = useCoop().$state.data; | ||||
| // import { useCoop } from '../../../../store/modules/coop'; | ||||
| // const defaultFormData = useCoop().$state.data; | ||||
| 
 | ||||
| const dialogTitle = ref('新增'); | ||||
| const dialogVisible = ref(false); | ||||
| @ -126,31 +126,31 @@ const searchForm = ref({ | ||||
| }); | ||||
| const crudData = ref([]); | ||||
| // 定义默认表单数据 | ||||
| // const defaultFormData = { | ||||
| //   id: '', | ||||
| //   entId: '', | ||||
| //   name: '', | ||||
| //   idType: '101', | ||||
| //   idCard: '', | ||||
| //   sex: '1', | ||||
| //   age: '', | ||||
| //   phone: '', | ||||
| //   provinceCode: '', // 省 | ||||
| //   cityCode: '', // 市 | ||||
| //   countyCode: '', // 区县 | ||||
| //   townCode: '', // 镇 | ||||
| //   street: '', // 村 | ||||
| //   addressArr: [], | ||||
| //   detailAddress: '', | ||||
| //   area: '', | ||||
| //   planCrop: '', | ||||
| //   planCropName: '', | ||||
| //   address: '', | ||||
| //   createTime: '', | ||||
| //   createUser: '', | ||||
| //   updateTime: '', | ||||
| //   updateUser: '', | ||||
| // }; | ||||
| const defaultFormData = { | ||||
|   id: '', | ||||
|   entId: '', | ||||
|   name: '', | ||||
|   idType: '101', | ||||
|   idCard: '', | ||||
|   sex: '1', | ||||
|   age: '', | ||||
|   phone: '', | ||||
|   provinceCode: '', // 省 | ||||
|   cityCode: '', // 市 | ||||
|   countyCode: '', // 区县 | ||||
|   townCode: '', // 镇 | ||||
|   street: '', // 村 | ||||
|   addressArr: [], | ||||
|   detailAddress: '', | ||||
|   area: '', | ||||
|   planCrop: '', | ||||
|   planCropName: '', | ||||
|   address: '', | ||||
|   createTime: '', | ||||
|   createUser: '', | ||||
|   updateTime: '', | ||||
|   updateUser: '', | ||||
| }; | ||||
| // 新增表单数据,使用默认数据初始化 | ||||
| const formData = ref({ ...defaultFormData }); | ||||
| const resetForm = () => { | ||||
|  | ||||
| @ -71,10 +71,7 @@ | ||||
| </template> | ||||
| 
 | ||||
| <script setup> | ||||
| import { reactive, watch } from 'vue'; | ||||
| import cloneDeep from 'lodash/cloneDeep'; | ||||
| import { useCoop } from '../../../../store/modules/coop'; | ||||
| const localForm = useCoop().$state.data; | ||||
| import { toRefs, reactive, watch } from 'vue'; | ||||
| 
 | ||||
| const props = defineProps({ | ||||
|   modelValue: { | ||||
| @ -86,25 +83,8 @@ const props = defineProps({ | ||||
| }); | ||||
| 
 | ||||
| const emit = defineEmits(['update:modelValue']); | ||||
| 
 | ||||
| // 创建本地副本(为了避免直接修改 props) | ||||
| // const localForm = reactive(cloneDeep(props.modelValue)); | ||||
| 
 | ||||
| // 监听本地副本的变化,自动回传给父组件 | ||||
| // watch( | ||||
| //   localForm, | ||||
| //   (newVal) => { | ||||
| //     emit('update:modelValue', { ...newVal }); | ||||
| //   }, | ||||
| //   { deep: true } | ||||
| // ); | ||||
| // watch( | ||||
| //   () => props.modelValue, | ||||
| //   (newVal) => { | ||||
| //     Object.assign(localForm, cloneDeep(newVal)); | ||||
| //   }, | ||||
| //   { deep: true } | ||||
| // ); | ||||
| // 解构出响应式引用,保持与父组件绑定 | ||||
| const { modelValue: localForm } = toRefs(props); | ||||
| </script> | ||||
| 
 | ||||
| <style scoped lang="scss"> | ||||
|  | ||||
| @ -23,7 +23,7 @@ | ||||
|           <TabBasicInfo v-model="formData" :readonly="isReadonly" /> | ||||
|         </el-tab-pane> | ||||
|         <el-tab-pane label="登记注册信息" name="register"> | ||||
|           <TabRegister v-model="formData" /> | ||||
|           <TabRegister v-model="formData" :readonly="isReadonly" /> | ||||
|         </el-tab-pane> | ||||
|         <el-tab-pane label="经营信息" name="business"> | ||||
|           <TabBusinessInfo v-model="formData" :readonly="isReadonly" /> | ||||
| @ -57,10 +57,6 @@ import TabBusinessInfo from './components/TabBusinessInfo.vue'; | ||||
| import TabCreditEvaluation from './components/TabCreditEvaluation.vue'; | ||||
| import TabMember from './components/TabMember.vue'; | ||||
| import { getEnterList, getEnterById, addEnter, updateEnter, approvalEnter, deleteEnter } from '@/apis/businessEntity'; | ||||
| import { cloneDeep } from 'lodash'; | ||||
| import { useCoop } from '../../../store/modules/coop'; | ||||
| 
 | ||||
| const useCoopData = useCoop(); | ||||
| 
 | ||||
| // 控制弹窗显示 | ||||
| const visible = ref(false); | ||||
| @ -76,6 +72,7 @@ const searchForm = ref({ | ||||
|   productType: '', | ||||
|   primaryProduct: '', | ||||
| }); | ||||
| const initialSearchForm = { ...searchForm.value }; | ||||
| // 数据和状态 | ||||
| const formData = ref({ | ||||
|   id: '', | ||||
| @ -116,6 +113,19 @@ const formData = ref({ | ||||
|   techApplication: 2, | ||||
|   productQuality: 1, | ||||
| }); | ||||
| const initialFormData = { ...formData.value }; | ||||
| 
 | ||||
| const resetForm = () => { | ||||
|   formData.value = { ...initialFormData }; | ||||
| }; | ||||
| const syncAddressToForm = () => { | ||||
|   const arr = Array.isArray(formData.value.addressArr) ? formData.value.addressArr : []; | ||||
|   formData.value.provinceCode = arr[0] || ''; | ||||
|   formData.value.cityCode = arr[1] || ''; | ||||
|   formData.value.countyCode = arr[2] || ''; | ||||
|   formData.value.townCode = arr[3] || ''; | ||||
|   formData.value.villageCode = arr[4] || ''; | ||||
| }; | ||||
| 
 | ||||
| // 保存处理 | ||||
| const handleSubmit = async () => { | ||||
| @ -124,27 +134,22 @@ const handleSubmit = async () => { | ||||
|     let response; | ||||
|     if (dialogTitle.value === '新增') { | ||||
|       formData.value.id = ''; | ||||
|       syncAddressToForm(); | ||||
|       response = await addEnter(formData.value); | ||||
|       if (response.code === 200) { | ||||
|         ElMessage.success('新增成功'); | ||||
|         visible.value = false; | ||||
|         getData(); // 刷新表格数据 | ||||
|         getData(); | ||||
|       } | ||||
|     } else if (dialogTitle.value === '编辑') { | ||||
|       formData.value.provinceCode = formData.value.addressArr[0]; | ||||
|       formData.value.cityCode = formData.value.addressArr[1]; | ||||
|       formData.value.countyCode = formData.value.addressArr[2]; | ||||
|       formData.value.townCode = formData.value.addressArr[3]; | ||||
|       formData.value.villageCode = formData.value.addressArr[4]; | ||||
| 
 | ||||
|       syncAddressToForm(); | ||||
|       response = await updateEnter(formData.value); | ||||
|       if (response.code === 200) { | ||||
|         ElMessage.success('编辑成功'); | ||||
|         visible.value = false; | ||||
|         getData(); // 刷新表格数据 | ||||
|         getData(); | ||||
|       } | ||||
|     } | ||||
|     // 可刷新表格数据 | ||||
|   } catch (e) { | ||||
|     ElMessage.error('保存失败'); | ||||
|   } finally { | ||||
| @ -178,70 +183,6 @@ const crudOptions = reactive({ | ||||
|     { label: '信息录入时间', prop: 'createTime' }, | ||||
|     { label: '信息更新时间', prop: 'updateTime' }, | ||||
|   ], | ||||
|   // actions: [ | ||||
|   //   { | ||||
|   //     name: '查看', | ||||
|   //     icon: 'view', | ||||
|   //     event: ({ row }) => handleView(row), | ||||
|   //   }, | ||||
|   //   { | ||||
|   //     name: '编辑', | ||||
|   //     icon: 'edit', | ||||
|   //     event: ({ row }) => handleEdit(row), | ||||
|   //   }, | ||||
|   //   { | ||||
|   //     type: 'danger', | ||||
|   //     name: '删除', | ||||
|   //     icon: 'delete', | ||||
|   //     event: ({ row }) => handleDelete(row.id), | ||||
|   //   }, | ||||
|   //   { | ||||
|   //     name: '驳回原因', | ||||
|   //     icon: 'warning', | ||||
|   //     event: ({ row }) => { | ||||
|   //       showRejectReason(row); | ||||
|   //     }, | ||||
|   //   }, | ||||
|   //   { | ||||
|   //     name: '提交审核', | ||||
|   //     icon: 'check', | ||||
|   //     event: ({ row }) => { | ||||
|   //       if (row.status === '待提交') { | ||||
|   //         handleSubmit(); | ||||
|   //       } else { | ||||
|   //         ElMessage.warning('当前状态不允许提交审核'); | ||||
|   //       } | ||||
|   //     }, | ||||
|   //   }, | ||||
|   //   { | ||||
|   //     name: '撤销', | ||||
|   //     icon: 'undo', | ||||
|   //     event: ({ row }) => { | ||||
|   //       handleWithdraw(row); | ||||
|   //     }, | ||||
|   //   }, | ||||
|   //   { | ||||
|   //     name: '重新提交', | ||||
|   //     icon: 'resubmit', | ||||
|   //     event: (row) => { | ||||
|   //       handleResubmit(row); | ||||
|   //     }, | ||||
|   //   }, | ||||
|   //   { | ||||
|   //     name: '通过', | ||||
|   //     icon: 'check-circle', | ||||
|   //     event: ({ row }) => { | ||||
|   //       handleApprove(row); | ||||
|   //     }, | ||||
|   //   }, | ||||
|   //   { | ||||
|   //     name: '驳回', | ||||
|   //     icon: 'close-circle', | ||||
|   //     event: ({ row }) => { | ||||
|   //       handleReject(row); | ||||
|   //     }, | ||||
|   //   }, | ||||
|   // ], | ||||
| }); | ||||
| // watch( | ||||
| //   () => formData.value.addressArr, | ||||
| @ -271,7 +212,6 @@ const getData = async () => { | ||||
|       page: pageData.value.currentPage, | ||||
|       size: pageData.value.pageSize, | ||||
|     }); | ||||
|     console.log('response', response); | ||||
|     crudData.value = response.data.records; | ||||
|     pageData.value.total = response.data.total; | ||||
|     pageData.value.currentPage = response.data.current; | ||||
| @ -285,27 +225,20 @@ const getData = async () => { | ||||
| 
 | ||||
| const getEnterDetail = async (id) => { | ||||
|   try { | ||||
|     resetForm(); | ||||
|     const response = await getEnterById(id); | ||||
|     if (response?.code === 200 && response.data) { | ||||
|       // 使用深拷贝避免污染原始数据 | ||||
|       formData.value = { | ||||
|         ...cloneDeep(response.data), | ||||
|         // 确保addressArr始终是5个元素,不足的用空字符串填充 | ||||
|         addressArr: [ | ||||
|           response.data.provinceCode || '', | ||||
|           response.data.cityCode || '', | ||||
|           response.data.countyCode || '', | ||||
|           response.data.townCode || '', | ||||
|           response.data.villageCode || '', | ||||
|         ], | ||||
|       }; | ||||
| 
 | ||||
|       console.log('详情数据加载完成', formData.value); | ||||
|     } else { | ||||
|       ElMessage.error(response?.msg || '获取详情失败:服务器未返回有效数据'); | ||||
|     } | ||||
|     formData.value = { | ||||
|       ...response.data, | ||||
|       // 确保addressArr始终是5个元素,不足的用空字符串填充 | ||||
|       addressArr: [ | ||||
|         response.data.provinceCode || '', | ||||
|         response.data.cityCode || '', | ||||
|         response.data.countyCode || '', | ||||
|         response.data.townCode || '', | ||||
|         response.data.villageCode || '', | ||||
|       ], | ||||
|     }; | ||||
|   } catch (error) { | ||||
|     console.error('获取详情失败:', error); | ||||
|     ElMessage.error(`获取详情失败:${error.message || '请稍后重试'}`); | ||||
|   } | ||||
| }; | ||||
| @ -317,9 +250,8 @@ function handleTabChange(tab) { | ||||
| } | ||||
| 
 | ||||
| const handleAdd = () => { | ||||
|   useCoopData.getData({}); | ||||
|   isReadonly.value = false; | ||||
|   // resetForm(); | ||||
|   resetForm(); | ||||
|   dialogTitle.value = '新增'; | ||||
|   visible.value = true; | ||||
| }; | ||||
| @ -327,7 +259,6 @@ const handleAdd = () => { | ||||
| const handleView = async (row) => { | ||||
|   loading.value = true; | ||||
|   dialogTitle.value = '查看'; | ||||
|   formData.value = null; | ||||
|   try { | ||||
|     await getEnterDetail(row.id); | ||||
|     isReadonly.value = true; | ||||
| @ -340,14 +271,10 @@ const handleView = async (row) => { | ||||
| 
 | ||||
| // 编辑详情(可修改) | ||||
| const handleEdit = async (row) => { | ||||
|   console.log(row); | ||||
|   formData.value = row; | ||||
|   formData.value.addressArr = [row.provinceCode, row.cityCode, row.countyCode, row.townCode, row.villageCode]; | ||||
|   useCoopData.getData(formData.value); | ||||
|   loading.value = true; | ||||
|   dialogTitle.value = '编辑'; | ||||
|   try { | ||||
|     await getEnterById(row.id); | ||||
|     await getEnterDetail(row.id); | ||||
|     isReadonly.value = false; | ||||
|     activeTab.value = 'basic'; | ||||
|     visible.value = true; | ||||
| @ -355,6 +282,26 @@ const handleEdit = async (row) => { | ||||
|     loading.value = false; | ||||
|   } | ||||
| }; | ||||
| // 提交审核 | ||||
| const handleSubmitApprove = async (row) => { | ||||
|   try { | ||||
|     const params = { | ||||
|       id: row.id, | ||||
|       status: '1', // 待审核 | ||||
|       reason: '提交审核', | ||||
|     }; | ||||
|     const res = await approvalEnter(params); | ||||
|     if (res.code === 200) { | ||||
|       ElMessage.success('提交审核成功'); | ||||
|       row.status = '1'; | ||||
|       getData(); // 刷新表格数据 | ||||
|     } else { | ||||
|       ElMessage.error(res.msg || '提交审核失败'); | ||||
|     } | ||||
|   } catch (error) { | ||||
|     ElMessage.error('提交审核失败'); | ||||
|   } | ||||
| }; | ||||
| // 重新提交(被驳回 → 待审核) | ||||
| function handleResubmit(row) { | ||||
|   ElMessageBox.confirm('确认重新提交吗?', '重新提交').then(() => { | ||||
| @ -513,16 +460,16 @@ console.log('admin 属性:', user.admin); | ||||
| const isAdmin = user.admin; | ||||
| const getActions = (row) => { | ||||
|   const actions = [ | ||||
|     // { | ||||
|     //   name: '查看', | ||||
|     //   icon: 'view', | ||||
|     //   event: () => handleView(row), | ||||
|     // }, | ||||
|     // { | ||||
|     //   name: '编辑', | ||||
|     //   icon: 'edit', | ||||
|     //   event: () => handleEdit(row), | ||||
|     // }, | ||||
|     { | ||||
|       name: '查看', | ||||
|       icon: 'view', | ||||
|       event: () => handleView(row), | ||||
|     }, | ||||
|     { | ||||
|       name: '编辑', | ||||
|       icon: 'edit', | ||||
|       event: () => handleEdit(row), | ||||
|     }, | ||||
|     { | ||||
|       type: 'danger', | ||||
|       name: '删除', | ||||
| @ -537,7 +484,7 @@ const getActions = (row) => { | ||||
|         { | ||||
|           name: '提交审核', | ||||
|           icon: 'check', | ||||
|           event: () => handleSubmit(row), | ||||
|           event: () => handleSubmitApprove(row), | ||||
|         }, | ||||
|         { | ||||
|           name: '重新提交', | ||||
|  | ||||
| @ -30,7 +30,7 @@ | ||||
|     </avue-crud> | ||||
| 
 | ||||
|     <!-- 新增弹窗 --> | ||||
|     <el-dialog :key="dialogTitle" v-model="dialogVisible" :title="dialogTitle" width="80%" align-center :draggable="true"> | ||||
|     <el-dialog :key="dialogTitle" v-model="dialogVisible" :title="dialogTitle" width="60%" align-center :draggable="true"> | ||||
|       <el-form :model="formData" label-width="120px" class="custom-form" :disabled="isReadonly"> | ||||
|         <el-row :gutter="20"> | ||||
|           <el-col :span="12"> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user