Merge branch 'dev' of http://47.109.205.240:3000/Web/daimp-front into dev
This commit is contained in:
		
						commit
						6f17345c1a
					
				| @ -0,0 +1,87 @@ | |||||||
|  | // src/apis/businessEntity/index.js
 | ||||||
|  | import request from '@/utils/axios'; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 生产经营主体 - 新增 | ||||||
|  |  * @param {Object} data 经营主体数据 | ||||||
|  |  */ | ||||||
|  | export function saveBusinessSubject(data) { | ||||||
|  |   return request({ | ||||||
|  |     url: '/product-business/business/businessSave', | ||||||
|  |     method: 'post', | ||||||
|  |     data, | ||||||
|  |   }); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 生产经营主体 - 编辑 | ||||||
|  |  * @param {Object} data 经营主体数据 | ||||||
|  |  */ | ||||||
|  | export function editBusinessSubject(data) { | ||||||
|  |   return request({ | ||||||
|  |     url: '/product-business/business/businessEdit', | ||||||
|  |     method: 'put', | ||||||
|  |     data, | ||||||
|  |   }); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 生产经营主体 - 分页查询 | ||||||
|  |  * @param {Object} params 查询参数 | ||||||
|  |  */ | ||||||
|  | export function fetchBusinessSubjectList(query) { | ||||||
|  |   return request({ | ||||||
|  |     url: '/product-business/business/businessPage', | ||||||
|  |     method: 'get', | ||||||
|  |     params: { | ||||||
|  |       businessSubjectQuery: JSON.stringify(query), | ||||||
|  |     }, | ||||||
|  |   }); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 生产经营主体 - 详情查询 | ||||||
|  |  * @param {string} id 主体ID | ||||||
|  |  */ | ||||||
|  | export function fetchBusinessSubjectInfo(id) { | ||||||
|  |   return request({ | ||||||
|  |     url: `/product-business/business/businessInfo/${id}`, | ||||||
|  |     method: 'get', | ||||||
|  |   }); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 生产经营主体 - 批量删除 | ||||||
|  |  * @param {string} businessId 主体ID | ||||||
|  |  */ | ||||||
|  | export function deleteBusinessSubject(businessId) { | ||||||
|  |   return request({ | ||||||
|  |     url: '/product-business/business/deleteBusiness', | ||||||
|  |     method: 'delete', | ||||||
|  |     params: { businessId }, | ||||||
|  |   }); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 生产经营主体 - 审核 | ||||||
|  |  * @param {Object} data 审核数据 | ||||||
|  |  */ | ||||||
|  | export function checkBusinessSubject(data) { | ||||||
|  |   return request({ | ||||||
|  |     url: '/product-business/business/businessCheck', | ||||||
|  |     method: 'put', | ||||||
|  |     data, | ||||||
|  |   }); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 经营主体审核 - 分页查询 | ||||||
|  |  * @param {Object} params 查询参数 | ||||||
|  |  */ | ||||||
|  | export function fetchBusinessCheckList(params) { | ||||||
|  |   return request({ | ||||||
|  |     url: '/product-business/business/businessCheckPage', | ||||||
|  |     method: 'get', | ||||||
|  |     params, | ||||||
|  |   }); | ||||||
|  | } | ||||||
| @ -21,12 +21,12 @@ const landsRoutes = [ | |||||||
|       //   component: () => import('@/views/landManage/component/plantPlan/index.vue'),
 |       //   component: () => import('@/views/landManage/component/plantPlan/index.vue'),
 | ||||||
|       //   meta: { title: '种植计划', icon: '' },
 |       //   meta: { title: '种植计划', icon: '' },
 | ||||||
|       // },
 |       // },
 | ||||||
|       { |       // {
 | ||||||
|         path: '/sub-government-affairs-service/operationRecord', |       //   path: '/sub-government-affairs-service/operationRecord',
 | ||||||
|         name: 'operationRecord', |       //   name: 'operationRecord',
 | ||||||
|         component: () => import('@/views/landManage/component/operationRecord/index.vue'), |       //   component: () => import('@/views/landManage/component/operationRecord/index.vue'),
 | ||||||
|         meta: { title: '作业记录', icon: '' }, |       //   meta: { title: '作业记录', icon: '' },
 | ||||||
|       }, |       // },
 | ||||||
|       { |       { | ||||||
|         path: '/sub-government-affairs-service/landPartol', |         path: '/sub-government-affairs-service/landPartol', | ||||||
|         name: 'landPartol', |         name: 'landPartol', | ||||||
|  | |||||||
| @ -26,7 +26,7 @@ | |||||||
|               @row-del="rowDel" |               @row-del="rowDel" | ||||||
|             > |             > | ||||||
|               <template #menu-left> |               <template #menu-left> | ||||||
|                 <el-button type="primary" icon="Plus" @click="onAdd">新增</el-button> |                 <!-- <el-button type="primary" icon="Plus" @click="onAdd">新增</el-button> --> | ||||||
|                 <el-button type="success" icon="download" @click="onExport">导出</el-button> |                 <el-button type="success" icon="download" @click="onExport">导出</el-button> | ||||||
|               </template> |               </template> | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -3,14 +3,11 @@ | |||||||
|     <avue-crud |     <avue-crud | ||||||
|       ref="crudRef" |       ref="crudRef" | ||||||
|       v-model="state.form" |       v-model="state.form" | ||||||
|       v-model:search="state.query" |  | ||||||
|       v-model:page="state.pageData" |       v-model:page="state.pageData" | ||||||
|       :table-loading="state.loading" |       :table-loading="state.loading" | ||||||
|       :data="state.data" |       :data="state.data" | ||||||
|       :option="state.options" |       :option="state.options" | ||||||
|       @refresh-change="refreshChange" |       @refresh-change="refreshChange" | ||||||
|       @search-reset="searchChange" |  | ||||||
|       @search-change="searchChange" |  | ||||||
|       @selection-change="selectionChange" |       @selection-change="selectionChange" | ||||||
|       @current-change="currentChange" |       @current-change="currentChange" | ||||||
|       @size-change="sizeChange" |       @size-change="sizeChange" | ||||||
| @ -20,7 +17,7 @@ | |||||||
|     > |     > | ||||||
|       <template #menu-left> |       <template #menu-left> | ||||||
|         <!-- <el-button type="primary" icon="Upload" @click="onImport">导入</el-button> --> |         <!-- <el-button type="primary" icon="Upload" @click="onImport">导入</el-button> --> | ||||||
|         <el-button type="danger" icon="Delete" @click="onBatchDel">批量删除</el-button> |         <!-- <el-button type="danger" icon="Delete" @click="onBatchDel">批量删除</el-button> --> | ||||||
|       </template> |       </template> | ||||||
| 
 | 
 | ||||||
|       <!-- <template #operationDate-search> |       <!-- <template #operationDate-search> | ||||||
| @ -39,279 +36,132 @@ import { useApp } from '@/hooks'; | |||||||
| import { CRUD_OPTIONS } from '@/config'; | import { CRUD_OPTIONS } from '@/config'; | ||||||
| import { isEmpty, downloadFile } from '@/utils'; | import { isEmpty, downloadFile } from '@/utils'; | ||||||
| import { useUserStore } from '@/store/modules/user'; | import { useUserStore } from '@/store/modules/user'; | ||||||
|  | 
 | ||||||
| import { | import { | ||||||
|   getOperationRecord, |   fetchBusinessSubjectList, | ||||||
|   saveOperationRecord, |   saveBusinessSubject, | ||||||
|   editOperationRecord, |   editBusinessSubject, | ||||||
|   delOperationRecord, |   deleteBusinessSubject, | ||||||
|   exportOperationRecord, |   fetchBusinessSubjectInfo, | ||||||
|   getAddrCropByLand, | } from '@/apis/businessEntity'; | ||||||
|   importOperationRecord, |  | ||||||
| } from '@/apis/land'; |  | ||||||
| 
 | 
 | ||||||
| const { VITE_APP_BASE_API } = import.meta.env; | const { VITE_APP_BASE_API } = import.meta.env; | ||||||
| const app = useApp(); | const app = useApp(); | ||||||
| const UserStore = useUserStore(); | const UserStore = useUserStore(); | ||||||
| const crudRef = ref(null); | const crudRef = ref(null); | ||||||
| const handleLandChange = async (value, form, done) => { |  | ||||||
|   if (!value || !value.item || !value.item.id) return; // 如果没有选择任何地块,则直接返回 |  | ||||||
|   let val = {}; |  | ||||||
|   getAddrCropByLand(value.item?.id || '') |  | ||||||
|     .then((res) => { |  | ||||||
|       if (res.code === 200) { |  | ||||||
|         val = res.data || {}; |  | ||||||
|       } |  | ||||||
|     }) |  | ||||||
|     .catch((err) => { |  | ||||||
|       val = {}; |  | ||||||
|     }) |  | ||||||
|     .finally(() => {}); |  | ||||||
|   state.form.crop = val?.crop || value.item?.crop; |  | ||||||
|   state.form.address = val?.county + val?.town + val?.village || value.item?.address; |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| const jobTypeOptions = reactive([ |  | ||||||
|   { label: '蔬菜', value: '0' }, |  | ||||||
|   { label: '水果', value: '1' }, |  | ||||||
| ]); |  | ||||||
| 
 |  | ||||||
| let timeVal = ref([]); |  | ||||||
| 
 | 
 | ||||||
| const state = reactive({ | const state = reactive({ | ||||||
|   loading: false, |   loading: false, | ||||||
|   query: { |   query: { current: 1, size: 10, businessType: 0 }, | ||||||
|     current: 1, |  | ||||||
|     size: 10, |  | ||||||
|   }, |  | ||||||
|   form: {}, |   form: {}, | ||||||
|   selection: [], |   selection: [], | ||||||
|  |   pageData: { currentPage: 1, pageSize: 10, total: 0 }, | ||||||
|  |   data: [], | ||||||
|   options: { |   options: { | ||||||
|     ...CRUD_OPTIONS, |     ...CRUD_OPTIONS, | ||||||
|     addBtnText: '添加', |     addBtnText: '添加', | ||||||
|     searchLabelWidth: '120px', |  | ||||||
|     searchSpan: 8, |  | ||||||
|     searchGutter: 100, |  | ||||||
|     searchMenuPosition: 'center', |  | ||||||
|     column: [ |     column: [ | ||||||
|       { |       { label: '主体代码', prop: 'id' }, | ||||||
|         label: '主体代码', |       { label: '主体名称', prop: 'businessName' }, | ||||||
|         prop: 'executor', |  | ||||||
|         addDisplay: false, |  | ||||||
|         editDisplay: false, |  | ||||||
|         search: true, |  | ||||||
|         rules: { |  | ||||||
|           required: true, |  | ||||||
|           message: '请输入', |  | ||||||
|           trigger: 'blur', |  | ||||||
|         }, |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         label: '主体名称', |  | ||||||
|         prop: 'executor', |  | ||||||
|         search: true, |  | ||||||
|         rules: { |  | ||||||
|           required: true, |  | ||||||
|           message: '请输入', |  | ||||||
|           trigger: 'blur', |  | ||||||
|         }, |  | ||||||
|       }, |  | ||||||
|       { |       { | ||||||
|         label: '经营产品种类', |         label: '经营产品种类', | ||||||
|         prop: 'landId', |         prop: 'productType', | ||||||
|         type: 'select', |         type: 'select', | ||||||
|         remote: false, |         dicData: [ | ||||||
|         search: true, |           { label: '蔬菜', value: '0' }, | ||||||
|         props: { |           { label: '水果', value: '1' }, | ||||||
|           label: 'landName', |           { label: '畜产品', value: '2' }, | ||||||
|           value: 'id', |           { label: '水产品', value: '3' }, | ||||||
|         }, |           { label: '谷物', value: '4' }, | ||||||
|         dicHeaders: { |           { label: '农资', value: '5' }, | ||||||
|           authorization: UserStore.token, |           { label: '种源', value: '6' }, | ||||||
|         }, |           { label: '农产品加工', value: '7' }, | ||||||
|         dicUrl: `${VITE_APP_BASE_API}/land-resource/landManage/page?current=1&size=9999&draftsSaveType=0&landName=&gridName=&owner=`, |           { label: '其他', value: '8' }, | ||||||
|         dicFormatter: (res) => res.data.records ?? [], |  | ||||||
|         rules: [ |  | ||||||
|           { |  | ||||||
|             required: true, |  | ||||||
|             message: '请选择地块', |  | ||||||
|             trigger: 'blur', |  | ||||||
|           }, |  | ||||||
|         ], |         ], | ||||||
|         change: handleLandChange, |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         label: '主要经营产品', |  | ||||||
|         showOverflowTooltip: true, |  | ||||||
|         search: false, |  | ||||||
|         rules: { |  | ||||||
|           required: true, |  | ||||||
|           message: '请输入', |  | ||||||
|           trigger: 'blur', |  | ||||||
|         }, |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         label: '户主身份证号', |  | ||||||
|         prop: 'crop', |  | ||||||
|         search: false, |  | ||||||
|         rules: { |  | ||||||
|           required: true, |  | ||||||
|           message: '请输入', |  | ||||||
|           trigger: 'blur', |  | ||||||
|         }, |  | ||||||
|       }, |       }, | ||||||
|  |       { label: '主要经营产品', prop: 'primaryProduct' }, | ||||||
|  |       { label: '户主身份证号', prop: 'idCard' }, | ||||||
|       { |       { | ||||||
|         label: '联系地址', |         label: '联系地址', | ||||||
|         prop: 'villageCode', |         prop: 'address', | ||||||
|         type: 'cascader', |         type: 'cascader', | ||||||
|         checkStrictly: false, |         props: { label: 'areaName', value: 'areaCode', children: 'areaChildVOS' }, | ||||||
|         search: false, |  | ||||||
|         props: { |  | ||||||
|           label: 'areaName', |  | ||||||
|           value: 'areaCode', |  | ||||||
|           children: 'areaChildVOS', |  | ||||||
|         }, |  | ||||||
|         dicUrl: `${VITE_APP_BASE_API}/system/area/region?areaCode=530000`, |         dicUrl: `${VITE_APP_BASE_API}/system/area/region?areaCode=530000`, | ||||||
|         dicHeaders: { |         dicHeaders: { authorization: UserStore.token }, | ||||||
|           authorization: UserStore.token, |  | ||||||
|         }, |  | ||||||
|         dicFormatter: (res) => res.data ?? [], |  | ||||||
|         rules: [ |  | ||||||
|           { |  | ||||||
|             required: true, |  | ||||||
|             message: '请选择', |  | ||||||
|             trigger: 'blur', |  | ||||||
|           }, |  | ||||||
|         ], |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         label: '详细地址', |  | ||||||
|         prop: 'crop', |  | ||||||
|         search: false, |  | ||||||
|         rules: { |  | ||||||
|           required: true, |  | ||||||
|           message: '请输入', |  | ||||||
|           trigger: 'blur', |  | ||||||
|         }, |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         label: '联系电话', |  | ||||||
|         prop: 'crop', |  | ||||||
|         search: false, |  | ||||||
|         rules: { |  | ||||||
|           required: true, |  | ||||||
|           message: '请输入', |  | ||||||
|           trigger: 'blur', |  | ||||||
|         }, |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         label: '联系电话', |  | ||||||
|         prop: 'crop', |  | ||||||
|         search: false, |  | ||||||
|         rules: { |  | ||||||
|           required: true, |  | ||||||
|           message: '请输入', |  | ||||||
|           trigger: 'blur', |  | ||||||
|         }, |  | ||||||
|       }, |       }, | ||||||
|  |       { label: '详细地址', prop: 'detailAddress' }, | ||||||
|  |       { label: '联系电话', prop: 'phone' }, | ||||||
|       { |       { | ||||||
|         label: '审核状态', |         label: '审核状态', | ||||||
|         prop: 'crop', |         prop: 'status', | ||||||
|         addDisplay: false, |  | ||||||
|         editDisplay: false, |  | ||||||
|         search: false, |  | ||||||
|         rules: { |  | ||||||
|           required: true, |  | ||||||
|           message: '请输入', |  | ||||||
|           trigger: 'blur', |  | ||||||
|         }, |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         label: '审核意见', |  | ||||||
|         prop: 'crop', |  | ||||||
|         addDisplay: false, |  | ||||||
|         editDisplay: false, |  | ||||||
|         rules: { |  | ||||||
|           required: true, |  | ||||||
|           message: '请输入', |  | ||||||
|           trigger: 'blur', |  | ||||||
|         }, |  | ||||||
|       }, |  | ||||||
|       { label: '创建时间', prop: 'crop', addDisplay: false, editDisplay: false, search: false }, |  | ||||||
|     ], |  | ||||||
|     searchColumn: [ |  | ||||||
|       { label: '主体代码', prop: 'landName', search: true }, |  | ||||||
|       { label: '主体名称', prop: 'crop', search: true }, |  | ||||||
|       { |  | ||||||
|         label: '经营产品种类', |  | ||||||
|         prop: 'operationType', |  | ||||||
|         type: 'select', |         type: 'select', | ||||||
|         search: true, |         dicData: [ | ||||||
|         dicData: jobTypeOptions, |           { label: '未审核', value: 0 }, | ||||||
|       }, |           { label: '通过', value: 1 }, | ||||||
|       { |           { label: '拒绝', value: 2 }, | ||||||
|         label: '创建日期', |         ], | ||||||
|         prop: 'operationDate', |  | ||||||
|         type: 'daterange', |  | ||||||
|         format: 'YYYY-MM-DD', |  | ||||||
|         valueFormat: 'YYYY-MM-DD', |  | ||||||
|         width: 200, |  | ||||||
|         search: true, |  | ||||||
|       }, |       }, | ||||||
|  |       { label: '审核意见', prop: 'reviewSuggestion' }, | ||||||
|  |       { label: '创建时间', prop: 'createTime', type: 'datetime', format: 'YYYY-MM-DD HH:mm:ss' }, | ||||||
|     ], |     ], | ||||||
|     actions: [ |     actions: [ | ||||||
|       { |       { name: '详情', event: ({ row }) => viewRow(row) }, | ||||||
|         name: '详情', |       { name: '编辑', event: ({ row }) => editRow(row) }, | ||||||
|         icon: 'View', |       { type: 'danger', name: '删除', event: ({ row }) => deleteRow(row) }, | ||||||
|         event: ({ row }) => doDetail(row), |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         name: '编辑', |  | ||||||
|         icon: 'edit', |  | ||||||
|         event: ({ row }) => rowEdit(row), |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         type: 'danger', |  | ||||||
|         name: '删除', |  | ||||||
|         icon: 'delete', |  | ||||||
|         event: ({ row }) => rowDel(row), |  | ||||||
|       }, |  | ||||||
|     ], |     ], | ||||||
|   }, |   }, | ||||||
|   pageData: { |  | ||||||
|     total: 0, |  | ||||||
|     currentPage: 1, |  | ||||||
|     pageSize: 10, |  | ||||||
|   }, |  | ||||||
|   data: [], |  | ||||||
|   currentRow: {}, |  | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| // 加载 | // 加载 | ||||||
| const loadData = () => { | const loadData = () => { | ||||||
|   // state.loading = true; |   state.loading = true; | ||||||
|   // getOperationRecord(state.query) |   fetchBusinessSubjectList(state.query) | ||||||
|   //   .then((res) => { |     .then((res) => { | ||||||
|   //     if (res.code === 200) { |       if (res.code === 200) { | ||||||
|   //       const { current, size, total, records } = res.data; |         const { current, size, total, records } = res.data; | ||||||
|   //       state.data = records; |         state.data = records; | ||||||
|   //       state.pageData = { |         state.pageData = { | ||||||
|   //         currentPage: current || 1, |           currentPage: current || 1, | ||||||
|   //         pageSize: size || 10, |           pageSize: size || 10, | ||||||
|   //         total: total, |           total: total, | ||||||
|   //       }; |         }; | ||||||
|   //     } |       } | ||||||
|   //   }) |     }) | ||||||
|   //   .catch((err) => { |     .catch((err) => { | ||||||
|   //     app.$message.error(err.msg); |       app.$message.error(err.msg); | ||||||
|   //     state.data = []; |       state.data = []; | ||||||
|   //   }) |     }) | ||||||
|   //   .finally(() => { |     .finally(() => { | ||||||
|   //     state.loading = false; |       state.loading = false; | ||||||
|   //   }); |     }); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| loadData(); | loadData(); | ||||||
| 
 | 
 | ||||||
|  | const editRow = (row) => { | ||||||
|  |   fetchBusinessSubjectInfo(row.id).then((res) => { | ||||||
|  |     crudRef.value.rowEdit(res.data); | ||||||
|  |   }); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | const viewRow = (row) => { | ||||||
|  |   fetchBusinessSubjectInfo(row.id).then((res) => { | ||||||
|  |     crudRef.value.rowView(res.data); | ||||||
|  |   }); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | const deleteRow = (row) => { | ||||||
|  |   app | ||||||
|  |     .$confirm('确认删除?', '删除', { type: 'warning' }) | ||||||
|  |     .then(() => | ||||||
|  |       deleteBusinessSubject(row.id).then(() => { | ||||||
|  |         app.$message.success('删除成功'); | ||||||
|  |         loadData(); | ||||||
|  |       }) | ||||||
|  |     ) | ||||||
|  |     .catch(() => {}); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| // 页数 | // 页数 | ||||||
| const currentChange = (current) => { | const currentChange = (current) => { | ||||||
|   state.query.current = current; |   state.query.current = current; | ||||||
| @ -367,35 +217,19 @@ function uniqueObjects(arr, key) { | |||||||
| } | } | ||||||
| // 新增 | // 新增 | ||||||
| const rowSave = (row, done, loading) => { | const rowSave = (row, done, loading) => { | ||||||
|   // console.info('新增', row); |   saveBusinessSubject(row) | ||||||
|   saveOperationRecord(row) |     .then(() => { | ||||||
|     .then((res) => { |       app.$message.success('添加成功'); | ||||||
|       if (res.code === 200) { |       done(); | ||||||
|         app.$message.success('添加成功!'); |       loadData(); | ||||||
|         done(); |  | ||||||
|         loadData(); |  | ||||||
|       } |  | ||||||
|     }) |     }) | ||||||
|     .catch((err) => { |     .catch((e) => app.$message.error(e.msg)) | ||||||
|       app.$message.error(err.msg); |     .finally(() => loading()); | ||||||
|     }) |  | ||||||
|     .finally(() => { |  | ||||||
|       loading(); |  | ||||||
|     }); |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| // 编辑 |  | ||||||
| const rowEdit = (row) => { |  | ||||||
|   console.info('编辑', row); |  | ||||||
|   crudRef.value.rowEdit(row); |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| const doDetail = (row) => { |  | ||||||
|   crudRef.value.rowView(row); |  | ||||||
| }; |  | ||||||
| const rowUpdate = (row, index, done, loading) => { | const rowUpdate = (row, index, done, loading) => { | ||||||
|   console.info('更新'); |   console.info('更新'); | ||||||
|   editOperationRecord(row) |   editBusinessSubject(row) | ||||||
|     .then((res) => { |     .then((res) => { | ||||||
|       if (res.code === 200) { |       if (res.code === 200) { | ||||||
|         app.$message.success('更新成功!'); |         app.$message.success('更新成功!'); | ||||||
| @ -412,30 +246,30 @@ const rowUpdate = (row, index, done, loading) => { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| // 删除 | // 删除 | ||||||
| const rowDel = (row, index, done) => { | // const rowDel = (row, index, done) => { | ||||||
|   if (isEmpty(row)) return; | //   if (isEmpty(row)) return; | ||||||
|   app | //   app | ||||||
|     .$confirm(`删除后信息将不可查看,确认要删除吗?`, '确定删除', { | //     .$confirm(`删除后信息将不可查看,确认要删除吗?`, '确定删除', { | ||||||
|       confirmButtonText: '确定', | //       confirmButtonText: '确定', | ||||||
|       cancelButtonText: '取消', | //       cancelButtonText: '取消', | ||||||
|       type: 'warning', | //       type: 'warning', | ||||||
|     }) | //     }) | ||||||
|     .then(() => { | //     .then(() => { | ||||||
|       console.info('删除', row.recordId); | //       console.info('删除', row.recordId); | ||||||
|       delOperationRecord(row.recordId || '') | //       delOperationRecord(row.recordId || '') | ||||||
|         .then((res) => { | //         .then((res) => { | ||||||
|           if (res.code === 200) { | //           if (res.code === 200) { | ||||||
|             app.$message.success('删除成功!'); | //             app.$message.success('删除成功!'); | ||||||
|             loadData(); | //             loadData(); | ||||||
|             done(); | //             done(); | ||||||
|           } | //           } | ||||||
|         }) | //         }) | ||||||
|         .catch((err) => { | //         .catch((err) => { | ||||||
|           app.$message.error(err.msg); | //           app.$message.error(err.msg); | ||||||
|         }); | //         }); | ||||||
|     }) | //     }) | ||||||
|     .catch(() => {}); | //     .catch(() => {}); | ||||||
| }; | // }; | ||||||
| 
 | 
 | ||||||
| const onBatchDel = () => { | const onBatchDel = () => { | ||||||
|   let ids = handleIds(); |   let ids = handleIds(); | ||||||
|  | |||||||
| @ -0,0 +1,436 @@ | |||||||
|  | <template> | ||||||
|  |   <div class="custom-page"> | ||||||
|  |     <avue-crud | ||||||
|  |       ref="crudRef" | ||||||
|  |       v-model="state.form" | ||||||
|  |       v-model:search="state.query" | ||||||
|  |       v-model:page="state.pageData" | ||||||
|  |       :table-loading="state.loading" | ||||||
|  |       :data="state.data" | ||||||
|  |       :option="state.options" | ||||||
|  |       @refresh-change="refreshChange" | ||||||
|  |       @search-reset="searchChange" | ||||||
|  |       @search-change="searchChange" | ||||||
|  |       @selection-change="selectionChange" | ||||||
|  |       @current-change="currentChange" | ||||||
|  |       @size-change="sizeChange" | ||||||
|  |       @row-save="rowSave" | ||||||
|  |       @row-update="rowUpdate" | ||||||
|  |       @row-del="rowDel" | ||||||
|  |     > | ||||||
|  |       <template #menu-left> | ||||||
|  |         <!-- <el-button type="primary" icon="Upload" @click="onImport">导入</el-button> --> | ||||||
|  |         <el-button type="danger" icon="Delete" @click="onBatchDel">批量删除</el-button> | ||||||
|  |       </template> | ||||||
|  | 
 | ||||||
|  |       <!-- <template #operationDate-search> | ||||||
|  |         <el-date-picker v-model="timeVal" type="daterange" style="width: 230px" start-placeholder="开始" end-placeholder="结束" /> | ||||||
|  |       </template> --> | ||||||
|  | 
 | ||||||
|  |       <template #menu="scope"> | ||||||
|  |         <custom-table-operate :actions="state.options.actions" :data="scope" /> | ||||||
|  |       </template> | ||||||
|  |     </avue-crud> | ||||||
|  |   </div> | ||||||
|  | </template> | ||||||
|  | <script setup> | ||||||
|  | import { reactive, ref } from 'vue'; | ||||||
|  | import { useApp } from '@/hooks'; | ||||||
|  | import { CRUD_OPTIONS } from '@/config'; | ||||||
|  | import { isEmpty, downloadFile } from '@/utils'; | ||||||
|  | import { useUserStore } from '@/store/modules/user'; | ||||||
|  | import { | ||||||
|  |   getOperationRecord, | ||||||
|  |   saveOperationRecord, | ||||||
|  |   editOperationRecord, | ||||||
|  |   delOperationRecord, | ||||||
|  |   exportOperationRecord, | ||||||
|  |   getAddrCropByLand, | ||||||
|  |   importOperationRecord, | ||||||
|  | } from '@/apis/land'; | ||||||
|  | 
 | ||||||
|  | const { VITE_APP_BASE_API } = import.meta.env; | ||||||
|  | const app = useApp(); | ||||||
|  | const UserStore = useUserStore(); | ||||||
|  | const crudRef = ref(null); | ||||||
|  | const handleLandChange = async (value, form, done) => { | ||||||
|  |   if (!value || !value.item || !value.item.id) return; // 如果没有选择任何地块,则直接返回 | ||||||
|  |   let val = {}; | ||||||
|  |   getAddrCropByLand(value.item?.id || '') | ||||||
|  |     .then((res) => { | ||||||
|  |       if (res.code === 200) { | ||||||
|  |         val = res.data || {}; | ||||||
|  |       } | ||||||
|  |     }) | ||||||
|  |     .catch((err) => { | ||||||
|  |       val = {}; | ||||||
|  |     }) | ||||||
|  |     .finally(() => {}); | ||||||
|  |   state.form.crop = val?.crop || value.item?.crop; | ||||||
|  |   state.form.address = val?.county + val?.town + val?.village || value.item?.address; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | const jobTypeOptions = reactive([ | ||||||
|  |   { label: '蔬菜', value: '0' }, | ||||||
|  |   { label: '水果', value: '1' }, | ||||||
|  | ]); | ||||||
|  | 
 | ||||||
|  | let timeVal = ref([]); | ||||||
|  | 
 | ||||||
|  | const state = reactive({ | ||||||
|  |   loading: false, | ||||||
|  |   query: { | ||||||
|  |     current: 1, | ||||||
|  |     size: 10, | ||||||
|  |   }, | ||||||
|  |   form: {}, | ||||||
|  |   selection: [], | ||||||
|  |   options: { | ||||||
|  |     ...CRUD_OPTIONS, | ||||||
|  |     addBtnText: '添加', | ||||||
|  |     searchLabelWidth: '120px', | ||||||
|  |     searchSpan: 8, | ||||||
|  |     searchGutter: 100, | ||||||
|  |     searchMenuPosition: 'center', | ||||||
|  |     column: [ | ||||||
|  |       { | ||||||
|  |         label: '主体代码', | ||||||
|  |         prop: 'executor', | ||||||
|  |         addDisplay: false, | ||||||
|  |         editDisplay: false, | ||||||
|  |         search: true, | ||||||
|  |         rules: { | ||||||
|  |           required: true, | ||||||
|  |           message: '请输入', | ||||||
|  |           trigger: 'blur', | ||||||
|  |         }, | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         label: '主体名称', | ||||||
|  |         prop: 'executor', | ||||||
|  |         search: true, | ||||||
|  |         rules: { | ||||||
|  |           required: true, | ||||||
|  |           message: '请输入', | ||||||
|  |           trigger: 'blur', | ||||||
|  |         }, | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         label: '经营产品种类', | ||||||
|  |         prop: 'landId', | ||||||
|  |         type: 'select', | ||||||
|  |         remote: false, | ||||||
|  |         search: true, | ||||||
|  |         props: { | ||||||
|  |           label: 'landName', | ||||||
|  |           value: 'id', | ||||||
|  |         }, | ||||||
|  |         dicHeaders: { | ||||||
|  |           authorization: UserStore.token, | ||||||
|  |         }, | ||||||
|  |         dicUrl: `${VITE_APP_BASE_API}/land-resource/landManage/page?current=1&size=9999&draftsSaveType=0&landName=&gridName=&owner=`, | ||||||
|  |         dicFormatter: (res) => res.data.records ?? [], | ||||||
|  |         rules: [ | ||||||
|  |           { | ||||||
|  |             required: true, | ||||||
|  |             message: '请选择地块', | ||||||
|  |             trigger: 'blur', | ||||||
|  |           }, | ||||||
|  |         ], | ||||||
|  |         change: handleLandChange, | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         label: '主要经营产品', | ||||||
|  |         showOverflowTooltip: true, | ||||||
|  |         search: false, | ||||||
|  |         rules: { | ||||||
|  |           required: true, | ||||||
|  |           message: '请输入', | ||||||
|  |           trigger: 'blur', | ||||||
|  |         }, | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         label: '户主身份证号', | ||||||
|  |         prop: 'crop2', | ||||||
|  |         search: false, | ||||||
|  |         rules: { | ||||||
|  |           required: true, | ||||||
|  |           message: '请输入', | ||||||
|  |           trigger: 'blur', | ||||||
|  |         }, | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         label: '联系地址', | ||||||
|  |         prop: 'villageCode', | ||||||
|  |         type: 'cascader', | ||||||
|  |         checkStrictly: false, | ||||||
|  |         search: false, | ||||||
|  |         props: { | ||||||
|  |           label: 'areaName', | ||||||
|  |           value: 'areaCode', | ||||||
|  |           children: 'areaChildVOS', | ||||||
|  |         }, | ||||||
|  |         dicUrl: `${VITE_APP_BASE_API}/system/area/region?areaCode=530000`, | ||||||
|  |         dicHeaders: { | ||||||
|  |           authorization: UserStore.token, | ||||||
|  |         }, | ||||||
|  |         dicFormatter: (res) => res.data ?? [], | ||||||
|  |         rules: [ | ||||||
|  |           { | ||||||
|  |             required: true, | ||||||
|  |             message: '请选择', | ||||||
|  |             trigger: 'blur', | ||||||
|  |           }, | ||||||
|  |         ], | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         label: '详细地址', | ||||||
|  |         prop: 'crop3', | ||||||
|  |         search: false, | ||||||
|  |         rules: { | ||||||
|  |           required: true, | ||||||
|  |           message: '请输入', | ||||||
|  |           trigger: 'blur', | ||||||
|  |         }, | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         label: '联系电话', | ||||||
|  |         prop: 'crop4', | ||||||
|  |         search: false, | ||||||
|  |         rules: { | ||||||
|  |           required: true, | ||||||
|  |           message: '请输入', | ||||||
|  |           trigger: 'blur', | ||||||
|  |         }, | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         label: '审核状态', | ||||||
|  |         prop: 'crop', | ||||||
|  |         addDisplay: false, | ||||||
|  |         editDisplay: false, | ||||||
|  |         search: false, | ||||||
|  |         rules: { | ||||||
|  |           required: true, | ||||||
|  |           message: '请输入', | ||||||
|  |           trigger: 'blur', | ||||||
|  |         }, | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         label: '审核意见', | ||||||
|  |         prop: 'crop', | ||||||
|  |         addDisplay: false, | ||||||
|  |         editDisplay: false, | ||||||
|  |         rules: { | ||||||
|  |           required: true, | ||||||
|  |           message: '请输入', | ||||||
|  |           trigger: 'blur', | ||||||
|  |         }, | ||||||
|  |       }, | ||||||
|  |       { label: '创建时间', prop: 'crop', addDisplay: false, editDisplay: false, search: false }, | ||||||
|  |     ], | ||||||
|  |     searchColumn: [ | ||||||
|  |       { label: '主体代码', prop: 'landName', search: true }, | ||||||
|  |       { label: '主体名称', prop: 'crop', search: true }, | ||||||
|  |       { | ||||||
|  |         label: '经营产品种类', | ||||||
|  |         prop: 'operationType', | ||||||
|  |         type: 'select', | ||||||
|  |         search: true, | ||||||
|  |         dicData: jobTypeOptions, | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         label: '创建日期', | ||||||
|  |         prop: 'operationDate', | ||||||
|  |         type: 'daterange', | ||||||
|  |         format: 'YYYY-MM-DD', | ||||||
|  |         valueFormat: 'YYYY-MM-DD', | ||||||
|  |         width: 200, | ||||||
|  |         search: true, | ||||||
|  |       }, | ||||||
|  |     ], | ||||||
|  |     actions: [ | ||||||
|  |       { | ||||||
|  |         name: '详情', | ||||||
|  |         icon: 'View', | ||||||
|  |         event: ({ row }) => doDetail(row), | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         name: '编辑', | ||||||
|  |         icon: 'edit', | ||||||
|  |         event: ({ row }) => rowEdit(row), | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         type: 'danger', | ||||||
|  |         name: '删除', | ||||||
|  |         icon: 'delete', | ||||||
|  |         event: ({ row }) => rowDel(row), | ||||||
|  |       }, | ||||||
|  |     ], | ||||||
|  |   }, | ||||||
|  |   pageData: { | ||||||
|  |     total: 0, | ||||||
|  |     currentPage: 1, | ||||||
|  |     pageSize: 10, | ||||||
|  |   }, | ||||||
|  |   data: [], | ||||||
|  |   currentRow: {}, | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | // 加载 | ||||||
|  | const loadData = () => { | ||||||
|  |   // state.loading = true; | ||||||
|  |   // getOperationRecord(state.query) | ||||||
|  |   //   .then((res) => { | ||||||
|  |   //     if (res.code === 200) { | ||||||
|  |   //       const { current, size, total, records } = res.data; | ||||||
|  |   //       state.data = records; | ||||||
|  |   //       state.pageData = { | ||||||
|  |   //         currentPage: current || 1, | ||||||
|  |   //         pageSize: size || 10, | ||||||
|  |   //         total: total, | ||||||
|  |   //       }; | ||||||
|  |   //     } | ||||||
|  |   //   }) | ||||||
|  |   //   .catch((err) => { | ||||||
|  |   //     app.$message.error(err.msg); | ||||||
|  |   //     state.data = []; | ||||||
|  |   //   }) | ||||||
|  |   //   .finally(() => { | ||||||
|  |   //     state.loading = false; | ||||||
|  |   //   }); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | loadData(); | ||||||
|  | 
 | ||||||
|  | // 页数 | ||||||
|  | const currentChange = (current) => { | ||||||
|  |   state.query.current = current; | ||||||
|  |   loadData(); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | // 条数 | ||||||
|  | const sizeChange = (size) => { | ||||||
|  |   state.query.size = size; | ||||||
|  |   loadData(); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | // 搜索 | ||||||
|  | const searchChange = (params, done) => { | ||||||
|  |   if (done) done(); | ||||||
|  |   state.query = params; | ||||||
|  |   state.query.current = 1; | ||||||
|  |   loadData(); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | // 刷新 | ||||||
|  | const refreshChange = () => { | ||||||
|  |   loadData(); | ||||||
|  |   app.$message.success('刷新成功'); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | // 选择 | ||||||
|  | const selectionChange = (rows) => { | ||||||
|  |   state.selection = rows; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | const handleIds = () => { | ||||||
|  |   let datalist = state.selection.map((m) => { | ||||||
|  |     return { landId: m.landId, landName: m.landName }; | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   let selectIdlist = uniqueObjects(datalist, 'landId'); | ||||||
|  |   let selectIdsVal = selectIdlist.map((n) => { | ||||||
|  |     return n.landId; | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   return selectIdsVal.toString() || ''; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | function uniqueObjects(arr, key) { | ||||||
|  |   return arr.reduce((acc, current) => { | ||||||
|  |     const duplicate = acc.find((element) => element[key] === current[key]); | ||||||
|  |     if (!duplicate) { | ||||||
|  |       acc.push(current); | ||||||
|  |     } | ||||||
|  |     return acc; | ||||||
|  |   }, []); | ||||||
|  | } | ||||||
|  | // 新增 | ||||||
|  | const rowSave = (row, done, loading) => { | ||||||
|  |   // console.info('新增', row); | ||||||
|  |   saveOperationRecord(row) | ||||||
|  |     .then((res) => { | ||||||
|  |       if (res.code === 200) { | ||||||
|  |         app.$message.success('添加成功!'); | ||||||
|  |         done(); | ||||||
|  |         loadData(); | ||||||
|  |       } | ||||||
|  |     }) | ||||||
|  |     .catch((err) => { | ||||||
|  |       app.$message.error(err.msg); | ||||||
|  |     }) | ||||||
|  |     .finally(() => { | ||||||
|  |       loading(); | ||||||
|  |     }); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | // 编辑 | ||||||
|  | const rowEdit = (row) => { | ||||||
|  |   console.info('编辑', row); | ||||||
|  |   crudRef.value.rowEdit(row); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | const doDetail = (row) => { | ||||||
|  |   crudRef.value.rowView(row); | ||||||
|  | }; | ||||||
|  | const rowUpdate = (row, index, done, loading) => { | ||||||
|  |   console.info('更新'); | ||||||
|  |   editOperationRecord(row) | ||||||
|  |     .then((res) => { | ||||||
|  |       if (res.code === 200) { | ||||||
|  |         app.$message.success('更新成功!'); | ||||||
|  |         done(); | ||||||
|  |         loadData(); | ||||||
|  |       } | ||||||
|  |     }) | ||||||
|  |     .catch((err) => { | ||||||
|  |       app.$message.error(err.msg); | ||||||
|  |     }) | ||||||
|  |     .finally(() => { | ||||||
|  |       loading(); | ||||||
|  |     }); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | // 删除 | ||||||
|  | const rowDel = (row, index, done) => { | ||||||
|  |   if (isEmpty(row)) return; | ||||||
|  |   app | ||||||
|  |     .$confirm(`删除后信息将不可查看,确认要删除吗?`, '确定删除', { | ||||||
|  |       confirmButtonText: '确定', | ||||||
|  |       cancelButtonText: '取消', | ||||||
|  |       type: 'warning', | ||||||
|  |     }) | ||||||
|  |     .then(() => { | ||||||
|  |       console.info('删除', row.recordId); | ||||||
|  |       delOperationRecord(row.recordId || '') | ||||||
|  |         .then((res) => { | ||||||
|  |           if (res.code === 200) { | ||||||
|  |             app.$message.success('删除成功!'); | ||||||
|  |             loadData(); | ||||||
|  |             done(); | ||||||
|  |           } | ||||||
|  |         }) | ||||||
|  |         .catch((err) => { | ||||||
|  |           app.$message.error(err.msg); | ||||||
|  |         }); | ||||||
|  |     }) | ||||||
|  |     .catch(() => {}); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | const onBatchDel = () => { | ||||||
|  |   let ids = handleIds(); | ||||||
|  |   if (!ids.length || ids.length <= 0) { | ||||||
|  |     return app.$message.error('请先选择要删除的数据'); | ||||||
|  |   } | ||||||
|  | }; | ||||||
|  | </script> | ||||||
| @ -276,7 +276,7 @@ const setCity = (row) => { | |||||||
|   if (!isEmpty(row.cities)) { |   if (!isEmpty(row.cities)) { | ||||||
|     row.provinceCode = row?.cities[0] ?? null; |     row.provinceCode = row?.cities[0] ?? null; | ||||||
|     row.cityCode = row?.cities[1] ?? null; |     row.cityCode = row?.cities[1] ?? null; | ||||||
|     row.gridAreaCode = row?.cities[2] ?? null; |     row.gridAreaCode = row?.cities[4] ?? null; | ||||||
|     row.townCode = row?.cities[3] ?? null; |     row.townCode = row?.cities[3] ?? null; | ||||||
|     row.village = row?.cities[4] ?? null; |     row.village = row?.cities[4] ?? null; | ||||||
|     // row.village = row?.cities.join(','); |     // row.village = row?.cities.join(','); | ||||||
|  | |||||||
| @ -187,20 +187,20 @@ const loadGridOptions = async () => { | |||||||
| }; | }; | ||||||
| loadGridOptions(); | loadGridOptions(); | ||||||
| const currentChange = (current) => { | const currentChange = (current) => { | ||||||
|   // state.query.current = current; |   state.query.current = current; | ||||||
|   // loadData(); |   loadData(); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const sizeChange = (size) => { | const sizeChange = (size) => { | ||||||
|   // state.query.size = size; |   state.query.size = size; | ||||||
|   // loadData(); |   loadData(); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const searchChange = (params, done) => { | const searchChange = (params, done) => { | ||||||
|   // if (done) done(); |   if (done) done(); | ||||||
|   // state.query = params; |   state.query = params; | ||||||
|   // state.query.current = 1; |   state.query.current = 1; | ||||||
|   // loadData(); |   loadData(); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const refreshChange = () => { | const refreshChange = () => { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user