From 26e4c8c528ecea5c7fac54c8d791818953840acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E9=B8=BF?= Date: Thu, 12 Jun 2025 13:11:18 +0800 Subject: [PATCH 1/3] 6/12 --- .../src/apis/businessEntity/index.js | 137 ++- .../landIllegal/index.js | 29 + .../landInspection/index.js | 80 ++ .../src/components/AreaSelect/index.vue | 15 +- .../src/components/UrlSelect/index.vue | 8 +- .../src/hooks/useActionPermissions.js | 35 + .../src/router/modules/annualplan.js | 50 +- .../src/router/modules/resource.js | 6 +- .../component/annualPlans/index.vue | 659 --------------- .../component/annualPlans/records.vue | 37 - .../annualPlan/component/plantings/index.vue | 166 ---- .../landManage/component/landPartol/index.vue | 792 +++++++++++------- .../component/landPartol/oldindex.vue | 362 ++++++++ .../coOp/components/Attrs.vue | 137 +++ .../coOp/components/TabBasicInfo.vue | 144 +++- .../coOp/components/TabBusinessInfo.vue | 148 ++-- .../coOp/components/TabCreditEvaluation.vue | 76 +- .../coOp/components/TabMember.vue | 323 +++++++ .../coOp/components/TabRegister.vue | 61 +- .../views/productOperateMain/coOp/index.vue | 600 ++++++++----- .../productOperateMain/individual/index.vue | 98 +-- .../individual/old1index.vue | 254 ------ .../src/views/trace/record/base/index.vue | 13 +- 23 files changed, 2364 insertions(+), 1866 deletions(-) create mode 100644 sub-government-affairs-service/src/hooks/useActionPermissions.js delete mode 100644 sub-government-affairs-service/src/views/annualPlan/component/annualPlans/index.vue delete mode 100644 sub-government-affairs-service/src/views/annualPlan/component/annualPlans/records.vue delete mode 100644 sub-government-affairs-service/src/views/annualPlan/component/plantings/index.vue create mode 100644 sub-government-affairs-service/src/views/landManage/component/landPartol/oldindex.vue create mode 100644 sub-government-affairs-service/src/views/productOperateMain/coOp/components/Attrs.vue create mode 100644 sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabMember.vue delete mode 100644 sub-government-affairs-service/src/views/productOperateMain/individual/old1index.vue diff --git a/sub-government-affairs-service/src/apis/businessEntity/index.js b/sub-government-affairs-service/src/apis/businessEntity/index.js index 2dd4827..65b710a 100644 --- a/sub-government-affairs-service/src/apis/businessEntity/index.js +++ b/sub-government-affairs-service/src/apis/businessEntity/index.js @@ -59,7 +59,7 @@ export function fetchFarmerById(id) { } /** - * 删除农户接口(严格匹配文档规范) + * 农户-删除 * @param {string|string[]} ids - 单个ID或ID数组(会自动转为逗号分隔字符串) * @returns {Promise} 请求Promise */ @@ -75,29 +75,10 @@ export function deleteFarmers(ids) { } /** - * 生产经营主体 - 审核 - * @param {Object} data 审核数据 - */ -export function checkBusinessSubject(data) { - return request({ - url: '/product-business/business/businessCheck', - method: 'put', - data, - }); -} - -/** - * 经营主体审核 - 分页查询 + * 企业管理 - 列表查询 * @param {Object} params 查询参数 + * @returns {Promise} 请求Promise */ -export function fetchBusinessCheckList(params) { - return request({ - url: '/product-business/business/businessCheckPage', - method: 'get', - params, - }); -} -// 农企合作社-列表查询/product-business/business/enter/businessPage export function getEnterList(params) { return request({ url: '/product-business/business/enter/businessPage', @@ -105,3 +86,115 @@ export function getEnterList(params) { params, }); } +/** + * 企业管理 - 详情查询 + * @param {string} id 企业I + * @returns {Promise} 请求Promise + */ +export function getEnterById(id) { + return request({ + url: `/product-business/business/enter/businessInfo/${id}`, + method: 'get', + }); +} +/** + * 企业管理 - 新增 + * @param {Object} data 企业数据 + * @returns {Promise} 请求Promise + */ +export function addEnter(data) { + return request({ + url: '/product-business/business/enter/businessSave', + method: 'post', + data, + }); +} +/** + * 企业管理 - 编辑 + * @param {Object} data 企业数据 + * @returns {Promise} 请求Promise + */ +export function updateEnter(data) { + return request({ + url: '/product-business/business/enter/businessEdit', + method: 'put', + data, + }); +} +/** + * 企业管理 - 审核 + * @param {Object} data 审核数据 + */ +export function approvalEnter(data) { + return request({ + url: '/product-business/business/enter/businessApproval', + method: 'put', + data, + }); +} +/** + * 企业管理 - 删除 + * @param {string|string[]} ids - 单个ID或ID数组(会自动转为逗号分隔字符串) + * @returns {Promise} 请求Promise + */ +export function deleteEnter(ids) { + // 统一参数格式:数组转逗号分隔字符串,非数组直接使用 + const idStr = Array.isArray(ids) ? ids.join(',') : ids; + + return request({ + url: '/product-business/business/enter/deleteBusiness', + method: 'delete', + params: { businessId: idStr }, + }); +} +/** + * 社员列表查询 + * @param {Object} params 查询参数 + */ +export function getMemberList(params) { + return request({ + url: '/product-business/business/member/memberPage', + method: 'get', + params, + }); +} + +/** + * 社员新增 + * @param {Object} data 社员数据 + */ +export function addMember(data) { + return request({ + url: '/product-business/business/member/businessSave', + method: 'post', + data, + }); +} + +/** + * 社员编辑 + * @param {Object} data 社员数据 + */ +export function updateMember(data) { + return request({ + url: '/product-business/business/member/memberEdit', + method: 'put', + data, + }); +} + +/** + * 社员删除 + * @param {string|string[]} ids - 单个ID或ID数组(会自动转为逗号分隔字符串) + * @returns {Promise} 请求Promise + */ +export function deleteMembers(ids) { + // 统一参数格式:数组转逗号分隔字符串,非数组直接使用 + const idStr = Array.isArray(ids) ? ids.join(',') : ids; + + return request({ + url: '/product-business/business/member/deleteMember', + method: 'delete', + params: { ids: idStr }, + }); +} diff --git a/sub-government-affairs-service/src/apis/landResourceManagement/landIllegal/index.js b/sub-government-affairs-service/src/apis/landResourceManagement/landIllegal/index.js index e69de29..9fe9820 100644 --- a/sub-government-affairs-service/src/apis/landResourceManagement/landIllegal/index.js +++ b/sub-government-affairs-service/src/apis/landResourceManagement/landIllegal/index.js @@ -0,0 +1,29 @@ +import request from '@/utils/axios'; +/* 查询土地违法处理 */ +export function getLandIllegal(params = {}) { + return request('land-resource/landViolation/page', { + method: 'GET', + params, + }); +} +/* 新增土地违法处理 */ +export function createLandIllegal(data = {}) { + return request('land-resource/landViolation/save', { + method: 'POST', + data, + }); +} + +/* 登记处理 */ +export function registerLandIllegal(data = {}) { + return request('land-resource/landViolation/registResult', { + method: 'PUT', + data, + }); +} +/* 违法详情 */ +export function illegalInfo(id = '') { + return request('land-resource/landViolation/detail/' + id, { + method: 'GET', + }); +} diff --git a/sub-government-affairs-service/src/apis/landResourceManagement/landInspection/index.js b/sub-government-affairs-service/src/apis/landResourceManagement/landInspection/index.js index e69de29..2a98d82 100644 --- a/sub-government-affairs-service/src/apis/landResourceManagement/landInspection/index.js +++ b/sub-government-affairs-service/src/apis/landResourceManagement/landInspection/index.js @@ -0,0 +1,80 @@ +// api/landInspection.js +import request from '@/utils/axios'; + +// 新增(POST) +export function createLandInspection(data) { + return request('land-resource/landInspection/save', { + method: 'POST', + data, + }); +} + +// 删除(DELETE) +export function deleteLandInspection(id) { + return request(`land-resource/landInspection/${id}`, { + method: 'DELETE', + }); +} + +// 修改(PUT) +export function updateLandInspection(data = {}) { + return request('/land-resource/landInspection/update', { + method: 'PUT', + data, + }); +} +// 修改状态(PUT) +export function updateLandInspectionStatus(data = {}) { + return request('/land-resource/landInspection/updateStatus', { + method: 'PUT', + data, + }); +} +// 查询详情(GET) +export function getLandInspectionDetail(id) { + return request(`land-resource/landInspection/${id}`, { + method: 'GET', + }); +} + +// 查询列表 admin (GET) +export function fetchLandInspectionList(params = {}) { + return request('land-resource/landInspection/page', { + method: 'GET', + params, + }); +} +// 查询列表 执行人员 (GET) +export function fetchLandInspectionGen(params = {}) { + return request('/land-resource/landInspection/page/general', { + method: 'GET', + params, + }); +} +// 导出(GET + Blob) +export function exportLandInspection(params = {}) { + return request('/land-resource/landInspection/export', { + method: 'GET', + params, + responseType: 'blob', + }); +} +// 巡查结果-新增(POST) +export function createInspectionResult(data) { + return request('/land-resource/inspection/result/save', { + method: 'POST', + data, + }); +} +// 巡查结果-删除(DELETE) +export function deleteInspectionResult(id) { + return request(`/land-resource/inspection/result/${id}`, { + method: 'DELETE', + }); +} +// 巡查结果-违法事件查看(GET) +export function getInspectionResultDetail(id) { + return request(`/land-resource/inspection/result/${id}`, { + method: 'GET', + }); +} diff --git a/sub-government-affairs-service/src/components/AreaSelect/index.vue b/sub-government-affairs-service/src/components/AreaSelect/index.vue index ddc8b67..f4cb29a 100644 --- a/sub-government-affairs-service/src/components/AreaSelect/index.vue +++ b/sub-government-affairs-service/src/components/AreaSelect/index.vue @@ -65,18 +65,19 @@ const fetchAreaData = async () => { }, }); areaOptions.value = res.data ?? []; + console.log('AreaSelect区域数据', areaOptions.value); } catch (err) { console.error('加载行政区域失败', err); } }; -// 外部更新 => 内部同步 -watch( - () => props.modelValue, - (val) => { - selectedAreaPath.value = [...val]; - } -); +// // 外部更新 => 内部同步 +// watch( +// () => props.modelValue, +// (val) => { +// selectedAreaPath.value = [...val]; +// } +// ); // 内部更新 => 外部同步 watch(selectedAreaPath, (val) => { diff --git a/sub-government-affairs-service/src/components/UrlSelect/index.vue b/sub-government-affairs-service/src/components/UrlSelect/index.vue index 1aedec8..bbb6394 100644 --- a/sub-government-affairs-service/src/components/UrlSelect/index.vue +++ b/sub-government-affairs-service/src/components/UrlSelect/index.vue @@ -54,6 +54,10 @@ const props = defineProps({ type: String, default: 'value', }, + responseParser: { + type: Function, + default: (res) => res.data.records, // 默认解析函数 + }, }); // -------------- ② 定义要透传回父组件的 Events -------------- @@ -83,13 +87,13 @@ async function fetchOptions() { if (!props.url) return; const res = await request.get(props.url, { params: props.params }); - const records = res.data.records; + const records = props.responseParser(res); if (Array.isArray(records)) { options.value = records; // console.log('option', options.value); } else { options.value = []; - console.log('UrlSelect:接口返回数据格式不是数组,无法解析成 options'); + console.error('UrlSelect:解析后的数据不是数组'); } } diff --git a/sub-government-affairs-service/src/hooks/useActionPermissions.js b/sub-government-affairs-service/src/hooks/useActionPermissions.js new file mode 100644 index 0000000..974bd8e --- /dev/null +++ b/sub-government-affairs-service/src/hooks/useActionPermissions.js @@ -0,0 +1,35 @@ +// src/hooks/useActionPermissions.js + +import { computed } from 'vue'; + +function getBaseRoles(role, permissionMap) { + // 允许角色继承(如 admin 自动继承其他角色权限) + const inherited = permissionMap[role]; + return inherited && Array.isArray(inherited) ? inherited : [role]; +} + +function getAllowedKeys(role, status, permissionMap, statusMap) { + const baseRoles = getBaseRoles(role, permissionMap); + const roleKeys = new Set(baseRoles.flatMap((r) => permissionMap[r] || [])); + const statusKeys = new Set(statusMap[status] || []); + return [...roleKeys].filter((key) => statusKeys.has(key)); +} + +/** + * 通用权限控制 Hook + * @param {Ref} roleRef 用户角色 ref + * @param {Ref} statusRef 当前状态 ref + * @param {Array} actions 操作项列表,必须含 key 字段 + * @param {Object} permissionMap 角色权限表,如:{ operator: ['edit', ...] } + * @param {Object} statusMap 状态权限表,如:{ '00': ['edit', ...] } + */ +export function useActionPermissions(roleRef, statusRef, actions, permissionMap, statusMap) { + const filteredActions = computed(() => { + const allowedKeys = getAllowedKeys(roleRef.value, statusRef.value, permissionMap, statusMap); + return actions.filter((action) => allowedKeys.includes(action.key)); + }); + + return { + actions: filteredActions, + }; +} diff --git a/sub-government-affairs-service/src/router/modules/annualplan.js b/sub-government-affairs-service/src/router/modules/annualplan.js index 3d0574d..2cd9b50 100644 --- a/sub-government-affairs-service/src/router/modules/annualplan.js +++ b/sub-government-affairs-service/src/router/modules/annualplan.js @@ -1,26 +1,26 @@ -import Views from '@/layouts/Views.vue'; +// import Views from '@/layouts/Views.vue'; -const annualplanRoutes = [ - { - path: '/sub-government-affairs-service/annualPlan', - name: 'annualPlan', - component: Views, - redirect: '/sub-government-affairs-service/annualPlans', - meta: { title: '种植进度网格化管理', icon: '' }, - children: [ - // { - // path: '/sub-government-affairs-service/annualPlans', - // name: 'annualPlans', - // component: () => import('@/views/annualPlan/component/annualPlans/index.vue'), - // meta: { title: '年度种植计划', icon: '' }, - // }, - { - path: '/sub-government-affairs-service/annualPlans', - name: 'annualPlans', - component: () => import('@/views/annualPlan/component/annualPlans/index.vue'), - meta: { title: '种植进度网格化管理', icon: 'Memo' }, - }, - ], - }, -]; -export default annualplanRoutes; +// const annualplanRoutes = [ +// { +// path: '/sub-government-affairs-service/annualPlan', +// name: 'annualPlan', +// component: Views, +// redirect: '/sub-government-affairs-service/annualPlans', +// meta: { title: '种植进度网格化管理', icon: '' }, +// children: [ +// { +// path: '/sub-government-affairs-service/annualPlans', +// name: 'annualPlans', +// component: () => import('@/views/annualPlan/component/annualPlans/index.vue'), +// meta: { title: '年度种植计划', icon: '' }, +// }, +// { +// path: '/sub-government-affairs-service/annualPlans', +// name: 'annualPlans', +// component: () => import('@/views/annualPlan/component/annualPlans/index.vue'), +// meta: { title: '种植进度网格化管理', icon: 'Memo' }, +// }, +// ], +// }, +// ]; +// export default annualplanRoutes; diff --git a/sub-government-affairs-service/src/router/modules/resource.js b/sub-government-affairs-service/src/router/modules/resource.js index d22effb..4ef2491 100644 --- a/sub-government-affairs-service/src/router/modules/resource.js +++ b/sub-government-affairs-service/src/router/modules/resource.js @@ -1,5 +1,5 @@ import Layout from '@/layouts/index.vue'; -import annualplanRouters from './annualplan'; +// import annualplanRouters from './annualplan'; import statisticsRoutes from './statisticAnalysis'; import landsRoutes from './lands'; import dictRoutes from './dict'; @@ -29,13 +29,13 @@ export default [ path: '/sub-government-affairs-service/add-grid', component: () => import('@/views/resource/grid/AddGrid.vue'), name: 'add', - meta: { title: '新增网格', icon: '' }, + meta: { title: '网格管理', icon: '' }, }, { path: '/sub-government-affairs-service/add--grid-member', component: () => import('@/views/resource/grid/GridMember.vue'), name: 'member', - meta: { title: '新增网格员', icon: '' }, + meta: { title: '网格员管理', icon: '' }, }, // { // path: '/sub-government-affairs-service/grid--management', diff --git a/sub-government-affairs-service/src/views/annualPlan/component/annualPlans/index.vue b/sub-government-affairs-service/src/views/annualPlan/component/annualPlans/index.vue deleted file mode 100644 index 0b13ed8..0000000 --- a/sub-government-affairs-service/src/views/annualPlan/component/annualPlans/index.vue +++ /dev/null @@ -1,659 +0,0 @@ - - - diff --git a/sub-government-affairs-service/src/views/annualPlan/component/annualPlans/records.vue b/sub-government-affairs-service/src/views/annualPlan/component/annualPlans/records.vue deleted file mode 100644 index 06bc45c..0000000 --- a/sub-government-affairs-service/src/views/annualPlan/component/annualPlans/records.vue +++ /dev/null @@ -1,37 +0,0 @@ - - - - diff --git a/sub-government-affairs-service/src/views/annualPlan/component/plantings/index.vue b/sub-government-affairs-service/src/views/annualPlan/component/plantings/index.vue deleted file mode 100644 index 4267b9b..0000000 --- a/sub-government-affairs-service/src/views/annualPlan/component/plantings/index.vue +++ /dev/null @@ -1,166 +0,0 @@ - - diff --git a/sub-government-affairs-service/src/views/landManage/component/landPartol/index.vue b/sub-government-affairs-service/src/views/landManage/component/landPartol/index.vue index 6d9e854..172098f 100644 --- a/sub-government-affairs-service/src/views/landManage/component/landPartol/index.vue +++ b/sub-government-affairs-service/src/views/landManage/component/landPartol/index.vue @@ -2,361 +2,529 @@
- - - - - - - - - {{ infoData.id || '--' }} - {{ infoData.planName || '--' }} - {{ infoData.plantingArea || '--' }} - {{ infoData.plantingMonths || '--' }} - {{ infoData.growthCycle || '--' }} - {{ infoData.note || '--' }} - - + +

任务信息

+ - - - - - + + + + + + + + + - - + + + + + + + + + +
+ - diff --git a/sub-government-affairs-service/src/views/landManage/component/landPartol/oldindex.vue b/sub-government-affairs-service/src/views/landManage/component/landPartol/oldindex.vue new file mode 100644 index 0000000..6d9e854 --- /dev/null +++ b/sub-government-affairs-service/src/views/landManage/component/landPartol/oldindex.vue @@ -0,0 +1,362 @@ + + + diff --git a/sub-government-affairs-service/src/views/productOperateMain/coOp/components/Attrs.vue b/sub-government-affairs-service/src/views/productOperateMain/coOp/components/Attrs.vue new file mode 100644 index 0000000..6e8ed76 --- /dev/null +++ b/sub-government-affairs-service/src/views/productOperateMain/coOp/components/Attrs.vue @@ -0,0 +1,137 @@ + + + diff --git a/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabBasicInfo.vue b/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabBasicInfo.vue index 16a8a03..3c73b1e 100644 --- a/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabBasicInfo.vue +++ b/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabBasicInfo.vue @@ -1,12 +1,10 @@ + + diff --git a/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabBusinessInfo.vue b/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabBusinessInfo.vue index 5145b67..2d829c1 100644 --- a/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabBusinessInfo.vue +++ b/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabBusinessInfo.vue @@ -1,71 +1,76 @@ diff --git a/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabCreditEvaluation.vue b/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabCreditEvaluation.vue index 7730f73..572772d 100644 --- a/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabCreditEvaluation.vue +++ b/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabCreditEvaluation.vue @@ -1,35 +1,33 @@ + diff --git a/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabMember.vue b/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabMember.vue new file mode 100644 index 0000000..bda2994 --- /dev/null +++ b/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabMember.vue @@ -0,0 +1,323 @@ + + + + + diff --git a/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabRegister.vue b/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabRegister.vue index 6004d24..e678989 100644 --- a/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabRegister.vue +++ b/sub-government-affairs-service/src/views/productOperateMain/coOp/components/TabRegister.vue @@ -1,46 +1,58 @@ + + diff --git a/sub-government-affairs-service/src/views/productOperateMain/coOp/index.vue b/sub-government-affairs-service/src/views/productOperateMain/coOp/index.vue index a6266a5..399187c 100644 --- a/sub-government-affairs-service/src/views/productOperateMain/coOp/index.vue +++ b/sub-government-affairs-service/src/views/productOperateMain/coOp/index.vue @@ -1,35 +1,47 @@ @@ -71,7 +71,7 @@
记录 #{{ index + 1 }} - +
@@ -90,29 +90,27 @@ - - + + - - + + - - - - + + - + - - + + @@ -150,6 +155,7 @@ import { ref, reactive, watch, onMounted, computed, nextTick } from 'vue'; import { CRUD_OPTIONS } from '@/config'; import { ElMessage } from 'element-plus'; import { useActionPermissions } from '@/hooks/useActionPermissions'; +import { useUserStore } from '@/store/modules/user'; import { createLandInspection, deleteLandInspection, @@ -159,6 +165,7 @@ import { fetchLandInspectionList, exportLandInspection, createInspectionResult, + createInspectionResultBatch, deleteInspectionResult, getInspectionResultDetail, } from '@/apis/landResourceManagement/landInspection/index'; @@ -167,6 +174,9 @@ const dialogTitle = ref('新增'); const visible = ref(false); const isReadonlyInfo = ref(false); const isReadonlyRegist = ref(false); +const UserStore = useUserStore(); +const user = UserStore.getUserInfo(); +console.log('admin 属性:', user.admin); const pageData = ref({ currentPage: 1, @@ -205,7 +215,7 @@ const illegalForm = ref({ illegalTypeCode: '', // 违法类型代码 illegalTypeName: '', // 违法类型名称 desc: '', // 违法描述 - img: '111', // 违法图片 + img: '', // 违法图片 status: '', // 状态 }); const illegalForms = ref([{ ...illegalForm.value }]); @@ -224,7 +234,7 @@ const crudOptions = reactive({ { label: '巡查对象', prop: 'inspectionTarget' }, { label: '注意事项', prop: 'notes' }, { label: '是否违法', prop: 'isIllegal' }, - { label: '状态', prop: 'inspectionStatus' }, + { label: '状态', prop: 'inspectionStatusName' }, ], actions: [ { @@ -322,9 +332,17 @@ const handleView = async (id) => { const response = await getLandInspectionDetail(id); taskForm.value = response.data; const arr = response.data.inspectionResults; - if (arr && Array.isArray(arr)) { - illegalForms.value = arr; - } + illegalForms.value = arr ? arr : []; + illegalForms.value.forEach((item) => { + // 如果后端只给了一个 img 字符串 + if (item.img) { + // 直接包成数组 + item.illegalImages = [item.img]; + } else { + // 没图时给空数组 + item.illegalImages = []; + } + }); isReadonlyInfo.value = true; if (taskForm.value.inspectionUsers && Array.isArray(taskForm.value.inspectionUsers)) { taskForm.value.taskUserIds = taskForm.value.inspectionUsers.map((user) => user.userId); @@ -394,8 +412,12 @@ const handleViewResult = async (row) => { }; // 删除表单 -const handleRemoveForm = (index) => { - illegalForms.value.splice(index, 1); +const handleRemoveForm = async (index) => { + if (illegalForms.value[index].id) { + await deleteInspectionResult(illegalForms.value[index].id); + } else { + illegalForms.value.splice(index, 1); + } }; const handleSubmit = async () => { @@ -420,8 +442,30 @@ const handleSubmit = async () => { visible.value = false; await getData(); } else if (dialogTitle.value === '结果登记') { - response = await createInspectionResult(illegalForm.value); + // 1. 只保留没有 id 的新记录,并给它们补全 img 字段 + const payload = illegalForms.value + .filter((item) => !item.id) + .map((item) => { + // 安全取第一张图 + const firstImage = Array.isArray(item.illegalImages) && item.illegalImages.length ? item.illegalImages[0] : ''; + return { + ...item, + img: firstImage, + }; + }); + + // 2. 如果没有新记录,直接提示并返回 + if (payload.length === 0) { + ElMessage.warning('没有需要登记的新违法记录'); + return; + } + + // 3. 调用批量创建接口 —— 按后端期待的结构传参 + response = await createInspectionResultBatch(payload); + ElMessage.success(response?.msg || '结果登记成功'); + + // 4. 完成后重新拉列表、关闭弹窗 await getData(); } // 可刷新表格数据 @@ -467,7 +511,13 @@ function handleSizeChange(val) { // 页面权限控制相关 // --------------------------------------------------------------------- +// 如果user.admin是true就是operator,否则是inspector const role = ref('operator'); +if (user.admin) { + role.value = 'operator'; +} else { + role.value = 'inspector'; +} // 所有操作项 const allActions = [ { name: '查看', icon: 'view', key: 'view', event: ({ row }) => handleView(row.id) }, @@ -482,7 +532,7 @@ const allActions = [ // 权限表(角色 -> 可操作项) const permissionMap = { admin: ['operator', 'inspector'], // 继承 operator 和 inspector 的权限 - operator: ['view', 'edit', 'delete', 'publish', 'back', 'rePublish', 'result', 'viewResult'], + operator: ['view', 'edit', 'delete', 'publish', 'back', 'rePublish', 'viewResult'], inspector: ['result', 'viewResult'], }; // 状态控制表(状态码 -> 可操作项) @@ -492,8 +542,36 @@ const statusMap = { '01': ['viewResult'], '02': ['view', 'edit', 'delete', 'rePublish'], }; -// 使用封装 Hook -// const { actions } = useActionPermissions(role, status, allActions, permissionMap, statusMap); +function getActions(row) { + // 1. 先拿到当前角色对应的“原始权限”列表(可能是 action.key 也可能是继承的子角色名) + let raw = permissionMap[role.value] || []; + + // 2. 如果 raw 里有子角色(即 permissionMap 中也存在该 key),则把它平铺展开 + const expanded = raw.reduce((acc, key) => { + if (permissionMap[key]) { + // key 是个角色,取它的 action.key 列表 + acc.push(...permissionMap[key]); + } else { + // key 不是角色,直接当作 action.key + acc.push(key); + } + return acc; + }, []); + + // 去重 + const roleAllowed = Array.from(new Set(expanded)); + + // 3. 根据当前行状态拿到状态允许的 action.key + // 假设 row.inspectionStatus 或 row.status 存储了状态码 + const statusKey = row.inspectionStatus ?? row.status; + const statusAllowed = statusMap[statusKey] || []; + + // 4. 最终只取角色和状态都允许的 key + const finalKeys = roleAllowed.filter((key) => statusAllowed.includes(key)); + + // 5. 根据 finalKeys 过滤 allActions,并保持原始顺序 + return allActions.filter((a) => finalKeys.includes(a.key)); +}