一大波修改 #1

Merged
shenhong merged 6 commits from 一大波修改 into dev 2025-06-09 17:55:45 +08:00
38 changed files with 2538 additions and 1151 deletions
Showing only changes of commit 2e860c91f2 - Show all commits

View File

@ -13,8 +13,8 @@ VITE_APP_SUB_GSR = '//localhost:9530/new-digital-agriculture-screen/'
VITE_APP_BASE_API = '/apis'
VITE_APP_UPLOAD_API = '/uploadApis'
# 阿里云接口地址
# VITE_APP_BASE_URL = 'http://47.109.205.240:8080'
# VITE_APP_UPLOAD_URL = 'http://47.109.205.240:9300'
VITE_APP_BASE_URL = 'http://47.109.205.240:8080'
VITE_APP_UPLOAD_URL = 'http://47.109.205.240:9300'
# 内网接口地址
VITE_APP_BASE_URL = 'http://192.168.18.9:8080'
VITE_APP_UPLOAD_URL = 'http://192.168.18.9:9300'
# VITE_APP_BASE_URL = 'http://192.168.18.74:8080'
# VITE_APP_UPLOAD_URL = 'http://192.168.18.74:8080'

View File

@ -9,9 +9,9 @@ VITE_APP_BASE_API = '/apis'
VITE_APP_UPLOAD_API = '/uploadApis'
# 阿里云接口地址
# VITE_APP_BASE_URL = 'http://47.109.205.240:8080'
# VITE_APP_UPLOAD_URL = 'http://47.109.205.240:9300'
VITE_APP_BASE_URL = 'http://47.109.205.240:8080'
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.99:9300'
# VITE_APP_BASE_URL = 'http://192.168.18.74:8080'
# VITE_APP_UPLOAD_URL = 'http://192.168.18.74:8080'

View File

@ -5,7 +5,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>政务服务</title>
<title>农业产业政务平台</title>
</head>
<body>

View File

@ -0,0 +1,16 @@
import request from '@/utils/axios';
/**
* 获取种植作物分页列表
* @param {Object} params - 请求参数
* @param {string} [params.status] - 状态 0-禁用1-启用
* @param {number} [params.current] - 页码
* @param {number} [params.size] - 每页数量
* @returns {Promise<Object>} - 返回包含种植作物分页数据的 Promise
*/
export function pageCropsList(params = {}) {
return request('/land-resource/crops/page', {
method: 'GET',
params,
});
}

View File

@ -0,0 +1,19 @@
import * as plantingPlan from './plantingPlan';
import * as operationRecord from './operationRecord';
import * as landIllegal from './landIllegal';
import * as landInspection from './landInspection';
import * as gridManagement from './gridManagement';
import * as gridMemberManagement from './gridMemberManagement';
import * as basicInfoMaintenance from './basicInfoMaintenance';
import * as cropsManagement from './cropsManagement';
export default {
...plantingPlan,
...operationRecord,
...landIllegal,
...landInspection,
...gridManagement,
...gridMemberManagement,
...basicInfoMaintenance,
...cropsManagement,
};

View File

@ -0,0 +1,71 @@
import request from '@/utils/axios';
/**
* 分页查询土地列表
* @param {Object} params 请求参数
* @param {string} [params.current] 每页条数
* @param {string} [params.size] 分页
* @param {string} [params.landType] 土地类型 传入id土地资源管理/基础信息维护/土地类型列表查询
* @param {string} [params.regionCode] 区域编码
* @param {string} [params.keyword] 关键字
* @param {string} [params.gridId] 网格id
* @returns {Promise<Object>} 返回包含接口响应数据的 Promise
*/
export function getLandList(params) {
return request({
url: '/land-resource/landManage/page',
method: 'get',
params,
});
}
/**
* 保存土地基础信息
* @param {Object} [data={}] 请求数据默认为空对象
* @returns {Promise<Object>} 返回包含接口响应数据的 Promise
*/
export function saveBaseInfo(data = {}) {
return request({
url: '/land-resource/landManage/v1/saveBaseInfo',
method: 'post',
data,
});
}
/**
* 保存土地产权信息
* @param {Object} [data={}] 请求数据默认为空对象
* @returns {Promise<Object>} 返回包含接口响应数据的 Promise
*/
export function saveProperty(data = {}) {
return request({
url: '/land-resource/landManage/v1/saveProperty',
method: 'put',
data,
});
}
/**
* 编辑土地信息
* @param {Object} [data={}] 请求数据默认为空对象用于传递要编辑的土地信息
* @returns {Promise<Object>} 返回包含接口响应数据的 Promise
*/
export function editLand(data = {}) {
return request({
url: '/land-resource/landManage/edit',
method: 'post',
data,
});
}
/**
* 删除指定 ID 的土地信息
* @param {string|number} id 要删除的土地信息的 ID
* @returns {Promise<Object>} 返回包含接口响应数据的 Promise
*/
export function deleteLand(id) {
return request({
url: `/land-resource/landManage/delete/${id}`,
method: 'delete',
});
}

View File

@ -0,0 +1,68 @@
import request from '@/utils/axios';
/**
* 年度计划管理-新增
* @param {Object} data 年度计划新增数据对象
* @param {string} [data.year] 计划年份
* @param {string} [data.regionCode] 区划编码
* @param {string} [data.gridId] 网格id
* @param {string} data.planName 计划名称
* @param {string} [data.cropsId] 作物id,调用接口种植作物/列表
* @param {number} [data.plantingArea] 种植面积
* @param {string} [data.plantingMonths] 种植月份
* @param {string} [data.growthCycle] 成长周期
* @param {string} [data.note] 备注
* @param {string} [data.growthCycleUnit] 成长周期单位 1 2 3 4
* @returns {Promise<Object>} 返回包含接口响应数据的 Promise
*/
export function saveAnnual(data = {}) {
return request('/land-resource/annualManage/save', {
method: 'POST',
data,
});
}
/**
* 年度计划管理-编辑
* @param {Object} data 年度计划更新数据对象
* @param {string} [data.id] 计划 ID
* @param {string} [data.planName] 计划名称
* @param {string} [data.plantingMonths] 种植月份
* @param {number} [data.plantingArea] 种植面积
* @param {string} [data.growthCycle] 成长周期
* @param {string} [data.growthCycleUnit] 成长周期单位 1 2 3 4
* @returns {Promise<Object>} 返回包含接口响应数据的 Promise
*/
export function editAnnual(data = {}) {
return request('/land-resource/annualManage/edit', {
method: 'PUT',
data: data,
});
}
/**
* 填报实际进度
* @param {Object} annualActualAddDTO 年度计划实际进度新增数据对象
* @param {string} [annualActualAddDTO.planId] 年度计划id
* @param {number} [annualActualAddDTO.plantingArea] 实际种植面积
* @param {number} [annualActualAddDTO.plantingMonths] 实际种植月份
* @param {number} [annualActualAddDTO.growthCycle] 实际种植周期
* @returns {Promise<Object>} 返回包含接口响应数据的 Promise
*/
export function saveActualProgress(annualActualAddDTO = {}) {
return request('/land-resource/annualManage/save-actual', {
method: 'POST',
data: annualActualAddDTO,
});
}
/**
* 年度计划管理-获取详情
* @param {string} id 计划编号
* @returns {Promise<Object>} 返回包含接口响应数据的 Promise响应数据包含年度计划详情
*/
export function getAnnualDetail(id) {
return request(`/land-resource/annualManage/${id}`, {
method: 'GET',
});
}

View File

@ -0,0 +1,31 @@
src/
├── apis/
│ ├── landResourceManagement/ # 土地资源管理
│ │ ├── plantingPlan/ # 种植规划
│ │ │ ├── index.js
│ │ ├── operationRecord/ # 作业记录
│ │ │ ├── index.js
│ │ ├── landIllegal/ # 土地违法处理
│ │ │ ├── index.js
│ │ ├── landManagement/ # 土地管理
│ │ │ ├── index.js
│ │ ├── landInspection/ # 土地巡查
│ │ │ ├── index.js
│ │ ├── gridManagement/ # 网格管理
│ │ │ ├── index.js
│ │ ├── gridMemberManagement/ # 网格员管理
│ │ │ ├── index.js
│ │ ├── basicInfoMaintenance/ # 基础信息维护
│ │ │ ├── index.js
│ │ ├── cropsManagement/ # 种植作物
│ │ │ ├── index.js
│ │ ├── index.js # 土地资源管理模块统一入口
│ ├── productionEntityManagement/ # 生产经营主体管理
│ │ ├── index.js
│ ├── inputManagement/ # 投入品管理
│ │ ├── index.js
│ ├── productTraceability/ # 农产品溯源
│ │ ├── index.js
│ ├── index.js # 项目统一入口文件
├── utils/
│ ├── axios.js # 封装的请求工具

View File

@ -1,7 +1,9 @@
<template>
<div class="area-cascader-container">
<div class="area-cascader-container" :style="{ width: width + 'px' }">
<!-- 一行显示模式 -->
<template v-if="!splitRows">
<div v-if="label" class="area-cascader-label">{{ label }}</div>
<div style="display: flex; gap: 8px" :style="{ width: width + 'px' }">
<div style="display: flex; gap: 8px; flex: 1">
<el-cascader
v-model="selectedAreaCode"
:options="areaOptions"
@ -10,27 +12,68 @@
style="flex: 1"
clearable
/>
<el-select v-model="selectedGridName" :placeholder="gridPlaceholder" style="flex: 1" clearable :disabled="!selectedAreaCode">
<el-option v-for="item in gridOptions" :key="item.gridName" :label="item.gridName" :value="item.gridName" />
<span v-if="showSeparator" class="area-cascader-separator">{{ separator }}</span>
<el-select v-model="selectedGridId" :placeholder="gridPlaceholder" style="flex: 1" clearable :disabled="!selectedAreaCode">
<el-option v-for="item in gridOptions" :key="item.gridName" :label="item.gridName" :value="item.id" />
</el-select>
</div>
</template>
<!-- 两行显示模式 -->
<template v-else>
<div class="area-item">
<div class="area-cascader-label">所属行政区域</div>
<el-cascader
v-model="selectedAreaCode"
:options="areaOptions"
:props="cascaderProps"
:placeholder="areaPlaceholder"
style="flex: 1"
clearable
/>
</div>
<div class="area-item">
<div class="area-cascader-label">网格</div>
<el-select v-model="selectedGridId" :placeholder="gridPlaceholder" style="flex: 1" clearable :disabled="!selectedAreaCode">
<el-option v-for="item in gridOptions" :key="item.gridName" :label="item.gridName" :value="item.id" />
</el-select>
</div>
</template>
</div>
</template>
<script setup>
/**
* @description 区域选择组件
* 该组件用于选择行政区域和对应的网格支持级联选择和动态加载网格列表
* 组件接受以下 props
* - regionCode: 当前选中的区域编码
* - gridId: 当前选中的网格ID
* - label: 组件标签默认为 '所属区域-网格:'
* - placeholder: 组件占位符默认为 '请选择区域'
* - width: 组件宽度默认为 500px
* - showSeparator: 是否显示分隔符默认为 false
* - separator: 分隔符默认为 '-'
* - splitRows: 是否分行显示默认为 false
* * 组件会在 mounted 时加载行政区域数据并根据选中的区域动态加载对应的网格列表
* * 组件会在选中区域或网格时触发 update:regionCode update:gridId 事件用于更新外部绑定的值
*/
import { ref, watch, onMounted, computed } from 'vue';
import { ElCascader, ElSelect, ElOption } from 'element-plus';
import axios from 'axios';
import { useUserStore } from '@/store/modules/user';
const props = defineProps({
value: {
type: Object,
default: () => ({}),
regionCode: {
type: String,
default: '',
},
gridId: {
type: [String, Number],
default: '',
},
label: {
type: String,
default: '所属行政区域-网格:',
default: '行政区域-网格:',
},
placeholder: {
type: String,
@ -38,19 +81,32 @@ const props = defineProps({
},
width: {
type: [Number, String],
default: 300,
default: 500,
},
showSeparator: {
type: Boolean,
default: false,
},
separator: {
type: String,
default: '-',
},
splitRows: {
type: Boolean,
default: false,
},
});
const emit = defineEmits(['update:value']);
const emit = defineEmits(['update:regionCode', 'update:gridId']);
const userStore = useUserStore();
const areaOptions = ref([]);
const gridOptions = ref([]);
const selectedAreaCode = ref('');
const selectedGridName = ref('');
//
const selectedAreaCode = ref(props.regionCode);
const selectedGridId = ref(props.gridId);
//
const fetchAreaData = async () => {
@ -80,36 +136,61 @@ const fetchGridList = async (regionCode) => {
console.error('网格数据加载失败', err);
}
};
//
watch(selectedAreaCode, (val) => {
selectedGridName.value = '';
fetchGridList(val);
updateValue();
const selectedAreaLabel = computed(() => {
const findLabel = (options, code) => {
for (const item of options) {
if (item.areaCode === code) return item.areaName;
if (item.areaChildVOS?.length) {
const res = findLabel(item.areaChildVOS, code);
if (res) return res;
}
}
return '';
};
return findLabel(areaOptions.value, selectedAreaCode.value);
});
//
watch(selectedGridName, () => {
updateValue();
const selectedGridLabel = computed(() => {
const item = gridOptions.value.find((g) => g.id === selectedGridId.value);
return item?.gridName || '';
});
//
//
watch(
() => props.value,
() => props.regionCode,
(val) => {
selectedAreaCode.value = val.regionCode ?? '';
selectedGridName.value = val.gridName ?? '';
},
{ immediate: true }
selectedAreaCode.value = val;
}
);
watch(
() => props.gridId,
(val) => {
selectedGridId.value = val;
}
);
//
watch(selectedAreaCode, (val) => {
emit('update:regionCode', val);
selectedGridId.value = ''; // gridId
emit('update:gridId', '');
fetchGridList(val);
});
watch(selectedGridId, (val) => {
emit('update:gridId', val);
});
// v-model:value
const updateValue = () => {
emit('update:value', {
regionCode: selectedAreaCode.value,
gridName: selectedGridName.value,
});
};
// const updateValue = () => {
// console.log('update:value', selectedAreaCode.value, selectedGridName.value, selectedGridId.value);
// emit('update:value', {
// regionCode: selectedAreaCode.value,
// gridName: selectedGridName.value,
// gridId: selectedGridId.value,
// });
// };
onMounted(() => {
fetchAreaData();
@ -128,13 +209,32 @@ const cascaderProps = computed(() => ({
<style scoped>
.area-cascader-container {
display: flex;
/* flex-direction: column; */
gap: 8px;
gap: 18px;
margin: 0;
padding: 0;
/* 分行显示时垂直排列 */
flex-direction: v-bind('splitRows ? "column" : "row"');
}
.area-cascader-label {
font-size: 14px;
color: #606266;
text-align: right;
line-height: 32px;
box-sizing: border-box;
width: 120px;
padding-right: v-bind('splitRows ? "12px" : "0"');
}
.area-cascader-separator {
align-self: center;
font-size: 16px;
color: #606266;
margin: 0;
padding: 0;
}
.area-item {
display: flex;
gap: 0;
}
</style>

View File

@ -0,0 +1,105 @@
<!-- components/UrlSelect.vue -->
<template>
<el-select
v-bind="$attrs"
v-model="internalValue"
@change="$emit('change', $event)"
@blur="$emit('blur', $event)"
@focus="$emit('focus', $event)"
@clear="$emit('clear', $event)"
@visible-change="$emit('visible-change', $event)"
@remove-tag="$emit('remove-tag', $event)"
@scroll="$emit('scroll', $event)"
>
<!-- 1. 原生 prefix 插槽 -->
<slot name="prefix" />
<!-- 2. 如果要实现分组插槽也照搬 el-option-group 的结构 -->
<slot name="option-group">
<!-- 默认选项渲染 -->
<el-option v-for="item in options" :key="item[valueKey]" :label="item[labelKey]" :value="item[valueKey]" />
</slot>
<!-- 3. 其他自定义插槽不指定 name 的默认为 default slot -->
<slot />
<!-- 4. 下面这几个插槽是 el-select 也常见的 -->
<slot name="empty" />
<slot name="no-match" />
<slot name="footer" />
</el-select>
</template>
<script setup>
import { ref, watch, onMounted } from 'vue';
import request from '@/utils/axios';
// -------------- / Props --------------
const props = defineProps({
modelValue: {
type: [String, Number, Array],
default: null,
},
url: {
type: String,
default: null,
},
params: {
type: Object,
default: () => ({}),
},
// label value
labelKey: {
type: String,
default: 'label',
},
valueKey: {
type: String,
default: 'value',
},
});
// -------------- Events --------------
const emit = defineEmits(['update:modelValue', 'change', 'blur', 'focus', 'clear', 'visible-change', 'remove-tag', 'scroll']);
// -------------- --------------
// ref
const internalValue = ref(props.modelValue);
// prop internalValue
watch(
() => props.modelValue,
(newVal) => {
internalValue.value = newVal;
}
);
// internalValue emit update:modelValue
watch(internalValue, (newVal) => {
emit('update:modelValue', newVal);
});
// -------------- --------------
const options = ref([]);
// -------------- --------------
async function fetchOptions() {
console.log('fetchOptions :>> ', props.url, props.params);
if (!props.url) return;
try {
const res = await request.get(props.url, { params: props.params });
// : { code: 200, data: { records: [ {...}, {...} ] } }
// data: [{...}, {...}]
const records = res.data.records;
if (Array.isArray(records)) {
options.value = records;
// console.log('option', options.value);
} else {
options.value = [];
console.log('UrlSelect接口返回数据格式不是数组无法解析成 options');
}
} catch (err) {
console.error('UrlSelect拉取选项失败', err);
}
}
// -------------- --------------
onMounted(() => {
fetchOptions();
});
</script>

View File

@ -8,9 +8,9 @@
<template>
<el-breadcrumb class="layout-breadcrumb" separator="/">
<transition-group name="breadcrumb">
<el-breadcrumb-item v-if="matched[0].meta.title !== '政务服务'" key="home" :to="{ path: '/' }">
<el-breadcrumb-item v-if="matched[0].meta.title !== '农业产业政务平台'" key="home" :to="{ path: '/' }">
<div class="layout-breadcrumb-item">
<span class="layout-breadcrumb-title">政务服务</span>
<span class="layout-breadcrumb-title">农业产业政务平台</span>
</div>
</el-breadcrumb-item>
<el-breadcrumb-item v-for="(item, index) in matched" :key="item.name">

View File

@ -1,10 +1,3 @@
/**
* @Description:
* @Author: zenghua.wang
* @Date: 2024-01-24 17:14:41
* @LastEditors: zenghua.wang
* @LastEditTime: 2024-03-22 10:11:34
*/
import 'virtual:svg-icons-register';
import { createApp } from 'vue';
import App from './App.vue';

View File

@ -34,7 +34,7 @@ export const constantRoutes = [
name: 'layout',
component: Layout,
redirect: '/sub-government-affairs-service/home',
meta: { title: '政务服务', icon: 'House' },
meta: { title: '农业产业政务平台', icon: 'House' },
children: [
{
path: '/sub-government-affairs-service/home',

View File

@ -18,7 +18,7 @@ const annualplanRoutes = [
path: '/sub-government-affairs-service/annualPlans',
name: 'annualPlans',
component: () => import('@/views/annualPlan/component/annualPlans/index.vue'),
meta: { title: '网格种植进度', icon: 'Memo' },
meta: { title: '年度种植计划&实际', icon: 'Memo' },
},
],
},

View File

@ -3,24 +3,11 @@ import Views from '@/layouts/Views.vue';
const inputSuppliesRoutes = [
{
path: '/sub-government-affairs-service/inputSuppliesManage',
path: '/sub-government-affairs-service/material',
name: 'inputSuppliesManage',
component: Layout,
redirect: '/sub-government-affairs-service/materialManage',
meta: { title: '投入品监管平台', icon: 'FullScreen' },
children: [
// {
// path: '/sub-government-affairs-service/inputDataView',
// name: 'inputDataView',
// component: () => import('@/views/inputSuppliesManage/inputDataView/index.vue'),
// meta: { title: '投入品资源一张图', icon: 'Document' },
// },
{
path: '/sub-government-affairs-service/material',
name: 'material',
component: Views,
redirect: '/sub-government-affairs-service/material/pesticide',
meta: { title: '投入品管理', icon: 'OfficeBuilding' },
meta: { title: '投入品管理', icon: 'FullScreen' },
children: [
{
path: '/sub-government-affairs-service/material/pesticide',
@ -34,6 +21,25 @@ const inputSuppliesRoutes = [
component: () => import('@/views/inputSuppliesManage/material/fertilizer/index.vue'),
meta: { title: '肥料管理', icon: '' },
},
{
path: '/sub-government-affairs-service/material/seed',
name: 'input-supplies-seed',
component: () => import('@/views/inputSuppliesManage/material/seed/index.vue'),
meta: { title: '种子管理', icon: '' },
},
{
path: '/sub-government-affairs-service/material/others',
name: 'input-supplies-others',
component: () => import('@/views/inputSuppliesManage/material/others/index.vue'),
meta: { title: '其他投入品', icon: '' },
},
// {
// path: '/sub-government-affairs-service/materialManage',
// name: 'materialManage',
// component: Views,
// redirect: '/sub-government-affairs-service/material/pesticide',
// meta: { title: '投入品管理', icon: 'OfficeBuilding' },
// children: [
// {
// path: '/sub-government-affairs-service/material/pesticide',
// name: 'input-supplies-pesticide',
@ -41,25 +47,37 @@ const inputSuppliesRoutes = [
// meta: { title: '农药管理', icon: '' },
// },
// {
// path: '/sub-government-affairs-service/material/ratPoison',
// name: 'input-supplies-ratPoison',
// component: () => import('@/views/inputSuppliesManage/material/ratPoison/index.vue'),
// meta: { title: '兽药管理', icon: '' },
// path: '/sub-government-affairs-service/material/fertilizer',
// name: 'input-supplies-fertilizer',
// component: () => import('@/views/inputSuppliesManage/material/fertilizer/index.vue'),
// meta: { title: '肥料管理', icon: '' },
// },
{
path: '/sub-government-affairs-service/material/seed',
name: 'input-supplies-seed',
component: () => import('@/views/inputSuppliesManage/material/seed/index.vue'),
meta: { title: '种子管理', icon: '' },
},
// // {
// // path: '/sub-government-affairs-service/material/pesticide',
// // name: 'input-supplies-pesticide',
// // component: () => import('@/views/inputSuppliesManage/material/pesticide/index.vue'),
// // meta: { title: '农药管理', icon: '' },
// // },
// // {
// // path: '/sub-government-affairs-service/material/ratPoison',
// // name: 'input-supplies-ratPoison',
// // component: () => import('@/views/inputSuppliesManage/material/ratPoison/index.vue'),
// // meta: { title: '兽药管理', icon: '' },
// // },
// {
// path: '/sub-government-affairs-service/material/farmMachinery',
// name: 'input-supplies-farmMachinery',
// component: () => import('@/views/inputSuppliesManage/material/farmMachinery/index.vue'),
// meta: { title: '农机管理', icon: '' },
// path: '/sub-government-affairs-service/material/seed',
// name: 'input-supplies-seed',
// component: () => import('@/views/inputSuppliesManage/material/seed/index.vue'),
// meta: { title: '种子管理', icon: '' },
// },
// // {
// // path: '/sub-government-affairs-service/material/farmMachinery',
// // name: 'input-supplies-farmMachinery',
// // component: () => import('@/views/inputSuppliesManage/material/farmMachinery/index.vue'),
// // meta: { title: '农机管理', icon: '' },
// // },
// ],
// },
],
},
// {
// path: '/sub-government-affairs-service/productionDealer',
// name: 'productionDealer',
@ -90,12 +108,12 @@ const inputSuppliesRoutes = [
// component: () => import('@/views/inputSuppliesManage/redBlackRank/index.vue'),
// meta: { title: '企业红黑榜', icon: '' },
// },
{
path: '/sub-government-affairs-service/knowledgeManage',
name: 'knowledgeManage',
component: () => import('@/views/inputSuppliesManage/knowledgeManage/index.vue'),
meta: { title: '知识库', icon: '' },
},
// {
// path: '/sub-government-affairs-service/knowledgeManage',
// name: 'knowledgeManage',
// component: () => import('@/views/inputSuppliesManage/knowledgeManage/index.vue'),
// meta: { title: '知识库', icon: '' },
// },
// {
// path: '/sub-government-affairs-service/patrolCaseManage',
// name: 'patrolCaseManage',

View File

@ -13,31 +13,31 @@ const landsRoutes = [
path: '/sub-government-affairs-service/landsManage',
name: 'landsManage',
component: () => import('@/views/landManage/component/landsManage/index.vue'),
meta: { title: '土地信息登记', icon: '' },
},
{
path: '/sub-government-affairs-service/plantPlan',
name: 'plantPlan',
component: () => import('@/views/landManage/component/plantPlan/index.vue'),
meta: { title: '种植计划', icon: '' },
},
{
path: '/sub-government-affairs-service/operationRecord',
name: 'operationRecord',
component: () => import('@/views/landManage/component/operationRecord/index.vue'),
meta: { title: '作业记录', icon: '' },
meta: { title: '土地资源信息登记', icon: '' },
},
// {
// path: '/sub-government-affairs-service/plantPlan',
// name: 'plantPlan',
// component: () => import('@/views/landManage/component/plantPlan/index.vue'),
// meta: { title: '种植计划', icon: '' },
// },
// {
// path: '/sub-government-affairs-service/operationRecord',
// name: 'operationRecord',
// component: () => import('@/views/landManage/component/operationRecord/index.vue'),
// meta: { title: '作业记录', icon: '' },
// },
{
path: '/sub-government-affairs-service/landPartol',
name: 'landPartol',
component: () => import('@/views/landManage/component/landPartol/index.vue'),
meta: { title: '土地巡查', icon: '' },
meta: { title: '土地使用巡查', icon: '' },
},
{
path: '/sub-government-affairs-service/illegalHandle',
name: 'illegalHandle',
component: () => import('@/views/landManage/component/illegalHandle/index.vue'),
meta: { title: '土地违法处理', icon: '' },
meta: { title: '土地案件', icon: '' },
},
],
},

View File

@ -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: '' },
},
// {
// 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: '' },
},
// {
// path: '/sub-government-affairs-service/enterprise',
@ -62,12 +62,12 @@ export default [
// name: 'enterprise',
// meta: { title: '经营企业', icon: 'Document' },
// },
{
path: '/sub-government-affairs-service/examineList',
component: () => import('@/views/productOperateMain/examine/list.vue'),
name: 'examineList',
meta: { title: '主体审核管理', icon: '' },
},
// {
// path: '/sub-government-affairs-service/examineList',
// component: () => import('@/views/productOperateMain/examine/list.vue'),
// name: 'examineList',
// meta: { title: '主体审核管理', icon: '' },
// },
// {
// path: '/sub-government-affairs-service/examineRecord',
// component: () => import('@/views/productOperateMain/examine/record.vue'),

View File

@ -31,12 +31,12 @@ export default [
name: 'member',
meta: { title: '新增网格员', icon: '' },
},
{
path: '/sub-government-affairs-service/grid--management',
component: () => import('@/views/resource/grid/GridManagement.vue'),
name: 'management',
meta: { title: '网格化管理', icon: '' },
},
// {
// path: '/sub-government-affairs-service/grid--management',
// component: () => import('@/views/resource/grid/GridManagement.vue'),
// name: 'management',
// meta: { title: '网格化管理', icon: '' },
// },
],
},
...annualplanRouters,

View File

@ -1,10 +1,3 @@
/*
* @Descripttion:
* @Author: zenghua.wang
* @Date: 2022-02-23 21:12:37
* @LastEditors: zenghua.wang
* @LastEditTime: 2025-03-26 10:02:18
*/
import axios from 'axios';
import { ElNotification } from 'element-plus';
import router from '@/router';
@ -18,7 +11,7 @@ const { VITE_APP_BASE_API, VITE_APP_UPLOAD_API, VITE_APP_DICDATA_API } = import.
*/
const publicAxios = axios.create({
baseURL: VITE_APP_BASE_API, // API请求的默认前缀
timeout: 30000,
timeout: 10000, // 10秒超时
});
/**
* 异常拦截处理器
@ -26,8 +19,14 @@ const publicAxios = axios.create({
* @returns
*/
const errorHandler = async (error) => {
const { response } = error;
const { response, code, message } = error;
const UserStore = useUserStore();
// 1. 处理超时错误
if (code === 'ECONNABORTED' || message.includes('timeout')) {
ElNotification.error('请求超时,请检查网络或稍后重试');
return Promise.reject({ code: 'TIMEOUT', message: '请求超时' });
}
// 2. 处理HTTP状态码错误
if (response && response.status) {
switch (response.status) {
case 401:
@ -38,6 +37,7 @@ const errorHandler = async (error) => {
break;
}
}
// 3. 其他错误传递到业务层
return Promise.reject(error?.response?.data);
};
/**
@ -98,9 +98,9 @@ const formatResult = async (res) => {
/**
* 响应拦截器
*/
publicAxios.interceptors.response.use((response) => {
publicAxios.interceptors.response.use(
(response) => {
const { config } = response;
// console.info('响应拦截器', response);
if (config?.responseType) {
return response;
}
@ -114,6 +114,17 @@ publicAxios.interceptors.response.use((response) => {
return result;
}
throw new Error(response.data.msg);
}, errorHandler);
},
(error) => {
// 1. 直接处理超时错误(避免进入 errorHandler 重复提示)
if (error.code === 'ECONNABORTED' || error.message.includes('timeout')) {
ElNotification.error('请求超时,请稍后重试');
return Promise.reject({ code: 'TIMEOUT', message: '请求超时' });
}
// 2. 其他错误交给 errorHandler 处理(如 401 跳登录页)
return errorHandler(error);
}
);
export default publicAxios;

View File

@ -1,10 +1,3 @@
/**
* @Description: 路由权限
* @Author: zenghua.wang
* @Date: 2022-01-26 22:04:31
* @LastEditors: zenghua.wang
* @LastEditTime: 2024-02-26 13:54:43
*/
import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
@ -19,7 +12,7 @@ const whiteList = [];
router.beforeEach(async (to, from, next) => {
NProgress.start();
if (typeof to.meta.title === 'string') {
document.title = '政务服务 | ' + to.meta.title;
document.title = '农业产业政务平台 | ' + to.meta.title;
}
const userStore = useUserStore();

View File

@ -3,111 +3,291 @@
<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="Plus" @click="onAdd">新增</el-button>
<el-button type="success" icon="download" @click="onExport">导出</el-button>
</template>
<template #planStatus="{ row }">
<el-tag v-if="row.planStatus == '1'" type="warning" size="small">待提交</el-tag>
<el-tag v-if="row.planStatus == '2'" type="primary" size="small">审核中</el-tag>
<el-tag v-if="row.planStatus == '3'" type="success" size="small">通过</el-tag>
<el-tag v-if="row.planStatus == '4'" type="danger" size="small">拒绝</el-tag>
<template #menu="{ row }">
<custom-table-operate :actions="state.options.actions" :data="{ row }" />
</template>
<template #growthCycle-form="{ row, column, value, type }">
<el-input-number v-model="growthCycleVal[0]" :disabled="type == 'view' ? true : false" :min="1" :max="30" style="width: 130px">
<template #suffix>
<span></span>
</template>
</el-input-number>
&nbsp; - &nbsp;
<el-input-number v-model="growthCycleVal[1]" :min="1" :disabled="type == 'view' ? true : false" :max="30" style="width: 130px">
<template #suffix>
<span></span>
</template>
</el-input-number>
</template>
<template #plantingMonths-form="{ row, column, value, type }">
<el-select
v-model="plantingMonths"
placeholder="请选择月份"
:disabled="type == 'view' ? true : false"
style="width: 200px"
:clearable="true"
:multiple="true"
>
<el-option v-for="item in monthsOptions" :key="item.value" :label="item.label" :value="item.value" />
<template #search>
<div class="custom-search">
<div class="search-fields">
<div class="search-item">
<AreaCascader
v-model:region-code="areaQuery.regionCode"
v-model:grid-id="areaQuery.gridId"
placeholder="选择行政区域与网格"
:show-separator="true"
:width="500"
/>
</div>
<div class="search-item">
<span>种植作物</span>
<el-select v-model="state.query.cropsId" placeholder="种植作物" :clearable="true">
<el-option v-for="item in cropsOptions" :key="item.id" :label="item.cropsName" :value="item.id" />
</el-select>
</template>
<template #menu="scope">
<custom-table-operate :actions="state.options.actions" :data="scope" />
</div>
<div class="search-item">
<span>计划编号</span>
<el-input v-model="state.query.id" placeholder="计划编号" :clearable="true" />
</div>
<div class="search-item">
<span>计划名称</span>
<el-input v-model="state.query.planName" placeholder="计划名称" :clearable="true" />
</div>
</div>
<div class="search-buttons">
<el-button type="primary" @click="searchChange"> 查询 </el-button>
<el-button @click="resetSearch"> 重置 </el-button>
</div>
</div>
</template>
</avue-crud>
<el-dialog v-model="examVisible" title="审核计划" width="500" center>
<template #footer>
<div class="dialog-footer">
<el-button type="danger" @click="examCancel">审核拒绝</el-button>
<el-button type="primary" @click="examPast"> 审核通过 </el-button>
<el-dialog v-model="detailDialogVisible" title="年度种植计划详情页" width="800" class="detail-dialog">
<el-tabs v-model="activeTab">
<el-tab-pane label="年度种植计划" name="basic">
<h3>{{ currentDetailRow.planName }}</h3>
<div>所属行政区域{{ currentDetailRow.regionName }}</div>
<div>所属网格{{ currentDetailRow.gridName }}</div>
<div>计划编号{{ currentDetailRow.id }}</div>
<div>计划名称{{ currentDetailRow.planName }}</div>
<div>种植作物{{ currentDetailRow.cropsName }}</div>
<div>种植面积{{ currentDetailRow.planParameters?.plantingArea }}</div>
<div>种植月份{{ currentDetailRow.planParameters?.plantingMonths }}</div>
<div>
生长周期{{ currentDetailRow.planParameters?.growthCycle }}
{{ getGrowthCycleUnitName(currentDetailRow.planParameters?.growthCycleUnit) }}
</div>
</el-tab-pane>
<el-tab-pane label="实际种植情况" name="planting">
<h3>{{ currentDetailRow.planName }}</h3>
<div>所属行政区域{{ currentDetailRow.regionName }}</div>
<div>所属网格{{ currentDetailRow.gridName }}</div>
<div>计划编号{{ currentDetailRow.id }}</div>
<div>计划名称{{ currentDetailRow.planName }}</div>
<div>种植作物{{ currentDetailRow.cropsName }}</div>
<div>种植面积{{ currentDetailRow.actualParameters?.plantingArea }}</div>
<div>种植月份{{ currentDetailRow.actualParameters?.plantingMonths }}</div>
<div>
生长周期{{ currentDetailRow.actualParameters?.growthCycle }}
{{ getGrowthCycleUnitName(currentDetailRow.actualParameters?.growthCycleUnit) }}
</div>
<div>当前进度{{ currentDetailRow.currentProgress }}%</div>
</el-tab-pane>
</el-tabs>
<template #footer>
<span class="dialog-footer">
<el-button @click="detailDialogVisible = false">关闭</el-button>
</span>
</template>
</el-dialog>
<!-- 新增重新制定计划和填写实际种植信息操作的共用弹窗 -->
<el-dialog v-model="commonDialogVisible" :title="dialogTitle">
<template #default>
<el-form ref="planForm" :model="formData" :rules="formRules" label-width="120px" class="common-dialog">
<el-form-item label="" label-width="0px">
<AreaCascader v-model:value="areaFormData" split-rows label="所属行政区域-网格" :width="500" />
</el-form-item>
<!-- <AreaCascader v-model:value="areaFormData" split-rows label="所属行政区域-网格" :width="500" /> -->
<el-form-item label="计划名称">
<el-input v-model="formData.planName" style="width: 380px" />
</el-form-item>
<el-form-item label="种植作物" prop="cropsName">
<el-select v-model="formData.cropsId" placeholder="种植作物" style="width: 380px" :clearable="true">
<el-option v-for="item in cropsOptions" :key="item.id" :label="item.cropsName" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="种植面积" prop="plantingArea">
<el-input v-model="formData.plantingArea" style="width: 380px" />
</el-form-item>
<el-form-item label="种植月份" prop="plantingMonths">
<el-select v-model="formData.plantingMonths" placeholder="请选择月份" style="width: 380px" :clearable="true">
<el-option v-for="item in monthsOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="生长周期" prop="growthCycle">
<el-input-number v-model="formData.growthCycle" :min="1" style="width: 300px" />
<el-select v-model="formData.growthCycleUnit" disabled style="width: 68px; margin: 0; padding: 0">
<el-option label="天" value="1" />
<el-option label="周" value="2" />
<el-option label="月" value="3" />
<el-option label="年" value="4" />
</el-select>
</el-form-item>
</el-form>
</template>
<template #footer>
<span class="dialog-footer">
<el-button @click="commonDialogVisible = false">取消</el-button>
<el-button type="primary" @click="submitForm">确定</el-button>
</span>
</template>
</el-dialog>
</div>
</template>
<script setup>
import { reactive, ref } from 'vue';
import { reactive, ref, computed, onMounted, watch } from 'vue';
import { useApp } from '@/hooks';
import { CRUD_OPTIONS } from '@/config';
import { isEmpty, downloadFile } from '@/utils';
import { getAnnualList, saveAnnual, editAnnual, examineAnnual, delAnnual, exportAnnua } from '@/apis/land.js';
import { useUserStore } from '@/store/modules/user';
import { getAnnualList, examineAnnual, delAnnual, exportAnnua } from '@/apis/land.js';
import { pageCropsList } from '@/apis/landResourceManagement/cropsManagement/index.js';
import { saveAnnual, editAnnual, saveActualProgress, getAnnualDetail } from '@/apis/landResourceManagement/plantingPlan/index.js';
const app = useApp();
const crudRef = ref(null);
const userStore = useUserStore();
// AreaCascader
const areaFormData = ref({
regionCode: '',
gridName: '',
gridId: '',
});
watch(
areaFormData,
(newVal) => {
formData.value.regionCode = newVal.regionCode;
formData.value.gridName = newVal.gridName;
formData.value.gridId = newVal.gridId;
},
{ deep: true }
);
const formRules = reactive({
// planName: [{ required: true, message: '', trigger: 'blur' }],
// cropsId: [{ required: true, message: '', trigger: 'change' }],
// plantingArea: [
// { required: true, message: '', trigger: 'blur' },
// { type: 'number', message: '', trigger: 'blur' },
// ],
// plantingMonths: [{ required: true, message: '', trigger: 'change' }],
// growthCycle: [
// { required: true, message: '', trigger: 'blur' },
// { type: 'number', message: '', trigger: 'blur' },
// ],
});
//
const cropsOptions = ref([]);
//
const fetchCropsList = async () => {
try {
// pageCropsList
const res = await pageCropsList({ status: '0' });
if (res.code === 200) {
console.log('res :>> ', res.data.records);
cropsOptions.value = res.data.records;
console.log('object :>> ', cropsOptions.value);
}
} catch (error) {
app.$message.error('获取种植作物列表失败');
}
};
onMounted(() => {
fetchCropsList();
});
const monthsOptions = reactive([
{ label: '1月份', value: '1月' },
{ label: '2月份', value: '2月' },
{ label: '3月份', value: '3月' },
{ label: '4月份', value: '4月' },
{ label: '5月份', value: '5月' },
{ label: '6月份', value: '6月' },
{ label: '7月份', value: '7月' },
{ label: '8月份', value: '8月' },
{ label: '9月份', value: '9月' },
{ label: '10月份', value: '10月' },
{ label: '11月份', value: '11月' },
{ label: '12月份', value: '12月' },
//
const getGrowthCycleUnitName = (unit) => {
const unitMap = {
1: '天',
2: '周',
3: '月',
4: '年',
};
return unitMap[unit] || '';
};
//
const fetchDetailData = async (id) => {
try {
const res = await getAnnualDetail(id);
if (res.code === 200) {
currentDetailRow.value = res.data;
} else {
app.$message.error(res.msg || '获取详情数据失败');
}
} catch (error) {
console.error('获取详情数据出错:', error);
app.$message.error('获取详情数据失败,请稍后重试');
}
};
const openDetailDialog = async (row) => {
detailDialogVisible.value = true;
await fetchDetailData(row.id);
};
//
const detailDialogVisible = ref(false);
//
const activeTab = ref('basic');
const currentDetailRow = ref({});
//
const commonDialogVisible = ref(false);
//
const currentAction = ref('');
//
const dialogTitle = computed(() => {
if (currentAction.value === 'reCreate') {
return '重新制定计划';
} else if (currentAction.value === 'fillActual') {
return '填写实际种植信息';
} else if (currentAction.value === 'add') {
return '新增年度种植计划';
}
return '';
});
const monthsOptions = ref([
{ value: 1, label: '1月' },
{ value: 2, label: '2月' },
{ value: 3, label: '3月' },
{ value: 4, label: '4月' },
{ value: 5, label: '5月' },
{ value: 6, label: '6月' },
{ value: 7, label: '7月' },
{ value: 8, label: '8月' },
{ value: 9, label: '9月' },
{ value: 10, label: '10月' },
{ value: 11, label: '11月' },
{ value: 12, label: '12月' },
]);
//
const planForm = ref(null);
//
const isGridMember = computed(() => {
const userRoles = userStore.getUserInfo().roles;
console.log('当前用户角色:', userRoles);
return userRoles.some((role) => role.roleKey === 'gridMember');
// return true;
});
let infoData = reactive({ id: '' });
const examVisible = ref(false);
let growthCycleVal = reactive([0, 0]);
let plantingMonths = ref([]);
// 使 ref 使 v-model:value
const areaQuery = ref({
regionCode: '',
gridName: '',
gridId: '',
});
const state = reactive({
loading: false,
query: {
current: 1,
size: 10,
id: '',
planName: '',
cropsName: '',
cropsId: '',
},
form: {},
selection: [],
@ -115,111 +295,63 @@ const state = reactive({
...CRUD_OPTIONS,
addBtnText: '',
addBtn: false,
searchBtn: false,
emptyBtn: false,
fit: true,
column: [
{ label: '计划编号', prop: 'id', width: '200px', search: true, showOverflowTooltip: true, addDisplay: false, editDisplay: false },
{
label: '计划名称',
prop: 'planName',
width: '200px',
showOverflowTooltip: true,
search: true,
rules: {
required: true,
message: '请选择',
trigger: 'blur',
},
},
{ label: '种植作物', prop: 'cropsName', width: '120px', search: true, editDisplay: false },
{
label: '种植面积',
prop: 'plantingArea',
append: '亩',
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
// formatter: (value) => `${value} `,
formatter: (row, column, cellValue) => `${cellValue}`,
},
{
label: '种植月份',
prop: 'plantingMonths',
width: '120px',
rules: {
required: true,
message: '请选择',
trigger: 'blur',
validator: (rule, value, callback) => {
if (!plantingMonths.value.length) {
callback(new Error('请输入'));
} else {
callback();
}
},
},
formatter: (row, column, cellValue) => `${cellValue}`,
},
{ label: '计划编号', prop: 'id', minWidth: 100 },
{ label: '计划名称', prop: 'planName' },
{ label: '种植作物', prop: 'cropsName' },
{ label: '种植面积', prop: 'plantingArea', formatter: (row, column, cellValue) => `${cellValue}` },
{ label: '种植月份', prop: 'plantingMonths', formatter: (row, column, cellValue) => `${cellValue}` },
{
label: '生长周期',
prop: 'growthCycle',
width: '120px',
viewDisabled: true,
rules: {
required: true,
message: '请输入',
trigger: 'blur',
validator: (rule, value, callback) => {
if (growthCycleVal[0] < 1 || growthCycleVal[1] < 1) {
callback(new Error('请输入'));
} else {
callback();
}
},
},
formatter: (row, column, cellValue) => {
const unitMap = {
1: '天',
2: '周',
3: '月',
4: '年',
};
const unitMap = { 1: '天', 2: '周', 3: '月', 4: '年' };
const unit = unitMap[row.growthCycleUnit] || '';
return `${cellValue} ${unit}`;
},
},
{ label: '所属行政区域', prop: 'regionName', width: '120px', search: true, searchLabelWidth: 100, addDisplay: false, editDisplay: false },
{ label: '所属网格', prop: 'gridName', width: '120px', search: true, addDisplay: false, editDisplay: false },
{ label: '当前进度', prop: 'currentProgress', width: '120px', addDisplay: false, editDisplay: false },
// {
// label: '',
// prop: 'note',
// width: '180px',
// showOverflowTooltip: true,
// rules: {
// required: true,
// message: '',
// trigger: 'blur',
// },
// },
// { label: '', prop: 'planProgress', addDisplay: false, editDisplay: false },
// { label: '', prop: 'planStatus', addDisplay: false, editDisplay: false },
{ label: '所属行政区域', prop: 'regionName' },
{ label: '所属网格', prop: 'gridName' },
{ label: '当前进度', prop: 'currentProgress' },
],
actions: [
{
name: '审核',
icon: 'Stamp',
event: ({ row }) => doExam(row),
name: '查看',
icon: 'view',
event: ({ row }) => {
openDetailDialog(row);
},
},
{
name: '编辑',
name: '重新制定计划',
icon: 'edit',
event: ({ row }) => rowEdit(row),
event: ({ row }) => {
currentAction.value = 'reCreate';
formData.value = { ...row };
if (isGridMember.value) {
formData.value.regionName = row.regionName;
formData.value.gridName = row.gridName;
}
formData.value.growthCycleUnit = row.growthCycleUnit || '1';
commonDialogVisible.value = true;
},
},
{
name: '详情',
icon: 'List',
event: ({ row }) => doDetail(row),
name: '填写实际种植信息',
icon: 'edit',
event: ({ row }) => {
currentAction.value = 'fillActual';
formData.value = { ...row };
if (isGridMember.value) {
formData.value.regionName = row.regionName;
formData.value.gridName = row.gridName;
}
formData.value.growthCycleUnit = row.growthCycleUnit || '1';
commonDialogVisible.value = true;
},
},
{
type: 'danger',
@ -238,6 +370,72 @@ const state = reactive({
currentRow: {},
});
const formData = ref({
year: '',
regionCode: '',
gridId: '',
regionName: '',
gridName: '',
planName: '', //
cropsId: null,
cropsName: '',
plantingArea: null,
plantingMonths: '',
growthCycle: '',
growthCycleUnit: '1', //
note: '',
});
//
const submitForm = async () => {
try {
//
await planForm.value.validate();
//
console.log('表单数据:', formData.value);
if (currentAction.value === 'reCreate') {
//
await editAnnual(formData.value);
app.$message.success('重新制定计划成功');
} else if (currentAction.value === 'fillActual') {
//
await saveActualProgress(formData.value);
app.$message.success('填写实际种植信息成功');
} else if (currentAction.value === 'add') {
//
await saveAnnual(formData.value);
app.$message.success('新增年度种植计划成功');
}
commonDialogVisible.value = false;
loadData();
} catch (error) {
console.error('表单提交失败:', error);
if (error.errors) {
//
app.$message.error('请填写完整且正确的表单信息');
} else {
// API
app.$message.error('操作失败,请稍后重试');
}
}
};
const onAdd = () => {
currentAction.value = 'add';
formData.value = {
regionName: '',
gridName: '',
planName: '',
cropsName: '',
plantingArea: '',
plantingMonths: '',
growthCycle: '',
growthCycleUnit: '1',
};
commonDialogVisible.value = true;
};
//
const loadData = () => {
state.loading = true;
@ -277,10 +475,29 @@ const sizeChange = (size) => {
};
//
const searchChange = (params, done) => {
if (done) done();
state.query = params;
state.query.current = 1;
const searchChange = () => {
state.query = {
...state.query,
...areaQuery.value,
current: 1,
};
console.log('搜索参数', state.query);
loadData();
};
//
const resetSearch = () => {
state.query = {
current: 1,
size: 10,
id: '',
planName: '',
cropsName: '',
cropsId: '',
};
areaQuery.value.regionCode = '';
areaQuery.value.gridName = '';
areaQuery.value.gridId = '';
loadData();
};
@ -295,65 +512,6 @@ const selectionChange = (rows) => {
state.selection = rows;
};
const onAdd = () => {
afterSub();
crudRef.value.rowAdd();
};
//
const rowSave = (row, done, loading) => {
row.growthCycle = growthCycleVal[0] + '周' + ',' + growthCycleVal[1] + '周';
row.plantingMonths = plantingMonths.value.length ? plantingMonths.value.toString() : '';
saveAnnual(row)
.then((res) => {
if (res.code === 200) {
app.$message.success('添加成功!');
done();
loadData();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {});
};
const beforeMsg = (row) => {
growthCycleVal = row.growthCycle.split(',').map((m) => {
return Number(m.replace(/[^0-9]/gi, ''));
});
plantingMonths.value = row.plantingMonths.split(',');
};
const afterSub = () => {
growthCycleVal = [0, 0];
plantingMonths.value = [];
};
//
const rowEdit = (row) => {
console.info('编辑');
beforeMsg(row);
crudRef.value.rowEdit(row);
};
const rowUpdate = (row, index, done, loading) => {
console.info('更新');
editAnnual(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;
@ -379,7 +537,6 @@ const rowDel = (row, index, done) => {
})
.catch(() => {});
};
//
const onExport = () => {
if (isEmpty(state.data)) {
@ -402,53 +559,101 @@ const onExport = () => {
state.loading = false;
});
};
const doExam = (row) => {
examVisible.value = true;
infoData.id = row.id || '';
};
const doDetail = (row) => {
beforeMsg(row);
crudRef.value.rowView(row);
};
const examCancel = () => {
console.log('审核不通过');
examVisible.value = true;
toDoexam(infoData.id, '4', '审核不通过');
};
const examPast = (row) => {
console.log('审核通过');
toDoexam(infoData.id, '3', '审核通过');
};
const toDoexam = (id, status, tips) => {
app
.$confirm(`确定` + tips + `吗?`, '温馨提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
examineAnnual({ id: id, planStatus: status })
.then((res) => {
if (res.code === 200) {
app.$message.success('审核提交成功!');
loadData();
examHide();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {});
})
.catch(() => {});
};
const examHide = () => {
examVisible.value = false;
};
</script>
<style scoped lang="scss">
.custom-page {
/* 详情弹窗样式 */
/* 表单弹窗样式 */
.el-dialog {
.el-form {
padding: 0 20px;
width: 100%;
// background-color: aqua;
display: flex;
flex-wrap: wrap;
justify-content: center;
&-item {
margin-bottom: 18px;
width: 60%;
// background-color: #606266;
&__label {
font-weight: 500;
color: #606266;
}
/* 输入框和选择器统一宽度 */
.el-input,
.el-select,
.el-cascader {
width: 100%;
max-width: 400px;
}
/* 数字输入框和单位选择器组合 */
.el-input-number {
margin-right: 10px;
& + .el-select {
width: 100px;
}
}
}
}
}
/* 按钮样式微调 */
.el-button {
padding: 8px 16px;
border-radius: 4px;
& + .el-button {
margin-left: 12px;
}
}
/* 搜索区域样式 */
.custom-search {
display: flex;
flex-direction: column;
align-items: flex-start;
padding: 16px;
border-radius: 8px;
// background-color: #f5f7fa;
.search-fields {
display: flex;
flex-wrap: wrap;
gap: 16px;
width: 100%;
margin-bottom: 16px;
}
.search-item {
display: flex;
align-items: center;
gap: 8px;
.el-input,
.el-select,
.el-cascader {
width: 200px;
}
span {
font-size: 14px;
color: #606266;
align-self: center;
}
}
.search-buttons {
display: flex;
align-self: center;
gap: 12px;
margin-left: 8px;
}
}
}
</style>

View File

@ -124,10 +124,10 @@ const option = ref({
hide: true,
editDisplay: false,
},
{
prop: 'distributor',
label: '经销商',
},
// {
// prop: 'distributor',
// label: '',
// },
{
prop: '_classifyId',
label: '分类',

View File

@ -0,0 +1,270 @@
<template>
<div class="custom-page">
<!-- 替换为 avue-crud 表格区域 -->
<avue-crud ref="crudRef" v-model:data="tableData" v-model:page="pagination" :option="options">
<template #search>
<!-- 搜索区域 -->
<div class="search-area">
<el-input v-model="searchForm.name" placeholder="投入品名称" style="width: 200px; margin-right: 10px"></el-input>
<el-button type="primary" @click="searchData">搜索</el-button>
<el-button @click="resetSearch">重置</el-button>
</div>
</template>
<template #menu-left><el-button type="primary" icon="Plus" @click="openDialog">新增</el-button></template>
<template #menu="scope">
<custom-table-operate :actions="options.actions" :data="scope" />
</template>
</avue-crud>
<!-- 新增/编辑弹窗 -->
<el-dialog v-model="dialogVisible" :title="isEdit ? '编辑投入品' : '新增投入品'" width="600px">
<el-form ref="formRef" :model="formData" label-width="100px" class="custom-form">
<el-form-item label="名称" prop="name">
<el-input v-model="formData.name" class="custom-input"></el-input>
</el-form-item>
<el-form-item label="规格" prop="specification">
<el-input v-model="formData.specification" class="custom-input"></el-input>
</el-form-item>
<el-form-item label="厂家" prop="manufacturer">
<el-input v-model="formData.manufacturer" class="custom-input"></el-input>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="formData.remark" class="custom-input" type="textarea" :rows="3"></el-input>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer custom-footer">
<el-button @click="dialogVisible = false" class="custom-button">取消</el-button>
<el-button type="primary" @click="submitForm" class="custom-button">确定</el-button>
</span>
</template>
</el-dialog>
</div>
</template>
<script setup>
import { ref, reactive, computed } from 'vue';
import { ElMessage } from 'element-plus';
import { CRUD_OPTIONS, customRules } from '@/config';
//
const initialTableData = [
{
id: 1,
name: '甘蔗专用全生物降解地膜',
specification: '厚度0.008mm-0.012mm宽度800mm-1200mm',
manufacturer: '耿马特斯郎全生物降解材料有限公司',
remark: '可根据甘蔗种植需求定制',
},
{
id: 2,
name: '华丰牌加厚地膜',
specification: '厚度≥0.01mm宽度75cm-140cm',
manufacturer: '河南省银丰塑料有限公司',
remark: '符合新国标',
},
{
id: 3,
name: '高速贴片式滴灌带',
specification: '管径16mm-20mm出水流量2.0L/h、2.7L/h',
manufacturer: '库车拉依苏裕丰农民专业合作社(新疆)',
remark: '多种规格可选',
},
{
id: 4,
name: '再生滴灌带',
specification: '500米/卷',
manufacturer: '宁夏佳稼旺生态农业科技有限公司',
remark: '以旧换新50公斤废旧滴灌带兑换500米新带',
},
{
id: 5,
name: '防草布PP编织',
specification: '宽度1.2m克重90g/㎡',
manufacturer: '昆明绿保塑业有限公司',
remark: '用于果园/经济作物抑草',
},
];
//
const searchForm = reactive({
name: '',
});
// avue-crud
const crudRef = ref(null);
//
const tableData = ref([...initialTableData]);
//
const pagination = reactive({
currentPage: 1,
pageSize: 10,
total: initialTableData.length,
});
// avue-crud
const options = reactive({
...CRUD_OPTIONS,
addBtn: false,
searchBtn: false,
emptyBtn: false,
column: [
{
label: '名称',
prop: 'name',
},
{
label: '规格',
prop: 'specification',
},
{
label: '厂家',
prop: 'manufacturer',
},
{
label: '备注',
prop: 'remark',
},
],
actions: [
{
name: '编辑',
icon: 'edit',
event: ({ row }) => editData(row),
},
{
type: 'danger',
name: '删除',
icon: 'delete',
event: ({ row }) => deleteData(row.id),
},
],
});
//
const dialogVisible = ref(false);
const isEdit = ref(false);
const formRef = ref(null);
const formData = reactive({
id: null,
name: '',
specification: '',
manufacturer: '',
remark: '',
});
//
const searchData = () => {
pagination.currentPage = 1;
const filteredData = initialTableData.filter((item) => item.name.includes(searchForm.name));
tableData.value = filteredData;
pagination.total = filteredData.length;
};
//
const resetSearch = () => {
searchForm.name = '';
pagination.currentPage = 1;
tableData.value = [...initialTableData];
pagination.total = initialTableData.length;
};
//
const openDialog = () => {
isEdit.value = false;
Object.keys(formData).forEach((key) => {
if (key !== 'id') {
formData[key] = '';
}
});
formData.id = tableData.value.length > 0 ? Math.max(...tableData.value.map((item) => item.id)) + 1 : 1;
dialogVisible.value = true;
};
//
const editData = (row) => {
isEdit.value = true;
Object.assign(formData, row);
dialogVisible.value = true;
};
//
const deleteData = (id) => {
tableData.value = tableData.value.filter((item) => item.id !== id);
pagination.total = tableData.value.length;
ElMessage.success('删除成功');
};
//
const submitForm = () => {
if (isEdit.value) {
const index = tableData.value.findIndex((item) => item.id === formData.id);
if (index !== -1) {
tableData.value[index] = { ...formData };
ElMessage.success('编辑成功');
}
} else {
tableData.value.push({ ...formData });
pagination.total = tableData.value.length;
ElMessage.success('新增成功');
}
dialogVisible.value = false;
};
</script>
<style scoped>
.custom-page {
padding: 20px;
height: calc(100vh - 150px);
}
.search-area {
margin-bottom: 20px;
}
.custom-form {
padding: 20px;
}
/* 自定义输入框样式 */
.custom-input {
border-radius: 6px;
transition:
border-color 0.3s,
box-shadow 0.3s;
}
.custom-input:hover {
border-color: #409eff;
}
.custom-input:focus-within {
box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
}
/* 自定义备注输入框样式 */
.custom-input textarea {
border-radius: 6px;
}
/* 对话框底部按钮区域样式 */
.custom-footer {
padding: 10px 20px 20px;
}
/* 自定义按钮样式 */
.custom-button {
border-radius: 6px;
transition: transform 0.2s;
}
.custom-button:hover {
transform: translateY(-2px);
}
/* 主按钮悬停效果 */
.custom-button[type='primary']:hover {
opacity: 0.9;
}
</style>

View File

@ -176,12 +176,12 @@ const option = ref({
editDisplay: false,
rules: customRules({ msg: '请输入生产厂家' }),
},
{
prop: 'distributor',
width: '220',
label: '经销商',
editDisplay: false,
},
// {
// prop: 'distributor',
// width: '220',
// label: '',
// editDisplay: false,
// },
{
prop: 'productSpecification',
width: '100',

View File

@ -119,10 +119,10 @@ const option = ref({
rules: customRules({ msg: '请选择分类' }),
render: ({ row }) => row.classifyName ?? '',
},
{
prop: 'distributor',
label: '经销商',
},
// {
// prop: 'distributor',
// label: '',
// },
{
prop: 'productUnit',
width: '100',

View File

@ -140,6 +140,7 @@ const state = reactive({
fixed: true,
search: true,
editDisplay: false,
addDisplay: false,
rules: {
required: true,
message: '请输入',

View File

@ -0,0 +1,344 @@
<template>
<div class="custom-page">
<!-- 关键词搜索 -->
<el-form :inline="true" :model="searchForm" class="search-bar">
<el-form-item label="关键词">
<el-input v-model="searchForm.keyword" placeholder="请输入关键词" clearable />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch">查询</el-button>
<el-button @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
<!-- 四个固定 Tabs -->
<el-tabs v-model="activeTab" @tab-click="handleTabChange">
<el-tab-pane label="待提交" name="draft" />
<el-tab-pane label="待审核" name="pending" />
<el-tab-pane label="已通过" name="approved" />
<el-tab-pane label="被驳回" name="rejected" />
</el-tabs>
<!-- 表格 -->
<el-table :data="filteredData" stripe style="width: 100%">
<el-table-column prop="name" label="姓名" />
<el-table-column prop="idType" label="证件类型" />
<el-table-column prop="idNumber" label="证件号码" />
<el-table-column prop="gender" label="性别" />
<el-table-column prop="age" label="年龄" />
<el-table-column prop="contact" label="联系方式" />
<el-table-column prop="address" label="居住地行政区划" />
<el-table-column prop="crop" label="种植作物" />
<el-table-column prop="source" label="数据来源" />
<el-table-column prop="createdAt" label="信息录入时间" />
<el-table-column prop="updatedAt" label="信息更新时间" />
<el-table-column label="操作" fixed="right" width="360">
<template #default="{ row }">
<!-- 查看按钮超级管理员审核员提交人 任何状态都可看 -->
<el-button type="text" @click="handleView(row)">查看</el-button>
<!-- 如果是超级管理员四种状态都显示对应的操作 -->
<template v-if="isSuperAdmin">
<template v-if="row.status === 'draft'">
<el-button type="text" @click="handleEdit(row)">编辑</el-button>
<el-button type="text" @click="handleSubmit(row)">提交审核</el-button>
<el-button type="text" @click="handleDelete(row)">删除</el-button>
</template>
<template v-else-if="row.status === 'pending'">
<el-button type="text" @click="handleApprove(row)">通过</el-button>
<el-button type="text" @click="handleReject(row)">驳回</el-button>
<el-button type="text" @click="handleWithdraw(row)">撤销</el-button>
<el-button type="text" @click="handleDelete(row)">删除</el-button>
</template>
<template v-else-if="row.status === 'approved'">
<el-button type="text" @click="handleEdit(row)">修改</el-button>
<el-button type="text" @click="handleDelete(row)">删除</el-button>
</template>
<template v-else-if="row.status === 'rejected'">
<el-button type="text" @click="handleEdit(row)">编辑</el-button>
<el-button type="text" @click="showRejectReason(row)">驳回原因</el-button>
<el-button type="text" @click="handleResubmit(row)">重新提交</el-button>
<el-button type="text" @click="handleDelete(row)">删除</el-button>
</template>
</template>
<!-- 如果是审核员只有待审核/已通过/被驳回三种状态有操作待提交无操作 -->
<template v-else-if="isAuditor">
<template v-if="row.status === 'pending'">
<el-button type="text" @click="handleApprove(row)">通过</el-button>
<el-button type="text" @click="handleReject(row)">驳回</el-button>
</template>
<template v-else-if="row.status === 'approved'">
<el-button type="text" @click="handleDelete(row)">删除</el-button>
</template>
<template v-else-if="row.status === 'rejected'">
<el-button type="text" @click="showRejectReason(row)">驳回原因</el-button>
<el-button type="text" @click="handleDelete(row)">删除</el-button>
</template>
<!-- 待提交状态 -->
<!-- 审核员对待提交 无任何按钮 -->
</template>
<!-- 如果是提交人对四种状态分别渲染 -->
<template v-else>
<template v-if="row.status === 'draft'">
<el-button type="text" @click="handleEdit(row)">编辑</el-button>
<el-button type="text" @click="handleSubmit(row)">提交审核</el-button>
<el-button type="text" @click="handleDelete(row)">删除</el-button>
</template>
<template v-else-if="row.status === 'pending'">
<el-button type="text" @click="handleWithdraw(row)">撤销</el-button>
<el-button type="text" @click="handleDelete(row)">删除</el-button>
</template>
<template v-else-if="row.status === 'approved'">
<el-button type="text" @click="handleEdit(row)">修改</el-button>
<el-button type="text" @click="handleDelete(row)">删除</el-button>
</template>
<template v-else-if="row.status === 'rejected'">
<el-button type="text" @click="handleEdit(row)">编辑</el-button>
<el-button type="text" @click="showRejectReason(row)">驳回原因</el-button>
<el-button type="text" @click="handleResubmit(row)">重新提交</el-button>
<el-button type="text" @click="handleDelete(row)">删除</el-button>
</template>
</template>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue';
import { ElMessageBox, ElMessage } from 'element-plus';
// ---------------------------------------------------------------------
// 1.
// 'superadmin''auditor''submitter'
// ---------------------------------------------------------------------
const role = ref('submitter'); // 'superadmin' / 'auditor' / 'submitter'
//
const isSuperAdmin = computed(() => role.value === 'superadmin');
const isAuditor = computed(() => role.value === 'auditor');
// ---------------------------------------------------------------------
// 2. Tab
// ---------------------------------------------------------------------
const activeTab = ref('draft'); //
//
const searchForm = ref({ keyword: '' });
//
const allData = ref([
{
id: 1,
name: '张三',
idType: '身份证',
idNumber: '110101199001011234',
gender: '男',
age: 30,
contact: '13800001234',
address: '云南省玉溪市',
crop: '水稻',
source: '平台录入',
createdAt: '2025-05-20 10:00:00',
updatedAt: '2025-05-22 14:30:00',
status: 'draft', // draft: pending: approved: rejected:
rejectReason: '',
},
{
id: 2,
name: '李四',
idType: '护照',
idNumber: 'P12345678',
gender: '女',
age: 28,
contact: '13900005678',
address: '云南省昆明市',
crop: '玉米',
source: '第三方导入',
createdAt: '2025-04-15 09:20:00',
updatedAt: '2025-05-01 11:45:00',
status: 'pending',
rejectReason: '',
},
{
id: 3,
name: '王五',
idType: '身份证',
idNumber: '110101198505053456',
gender: '男',
age: 39,
contact: '13700009876',
address: '云南省大理市',
crop: '小麦',
source: '平台录入',
createdAt: '2025-03-10 15:10:00',
updatedAt: '2025-03-10 15:10:00',
status: 'approved',
rejectReason: '',
},
{
id: 4,
name: '赵六',
idType: '身份证',
idNumber: '110101197502073210',
gender: '女',
age: 45,
contact: '13500004567',
address: '云南省保山市',
crop: '烟草',
source: '第三方导入',
createdAt: '2025-02-01 08:30:00',
updatedAt: '2025-02-15 12:00:00',
status: 'rejected',
rejectReason: '种植作物信息不完整',
},
//
]);
// tab +
const filteredData = computed(() => {
return allData.value.filter((row) => {
//
if (row.status !== activeTab.value) return false;
// //
const kw = searchForm.value.keyword.trim();
if (kw) {
return row.name.includes(kw) || row.idNumber.includes(kw) || row.contact.includes(kw);
}
return true;
});
});
// ---------------------------------------------------------------------
// 3. API/
// ---------------------------------------------------------------------
function handleSearch() {
// filteredData
// activeTab + keyword
console.log('搜索关键词:', searchForm.value.keyword);
}
function handleReset() {
searchForm.value.keyword = '';
handleSearch();
}
function handleTabChange(tab) {
activeTab.value = tab.name;
handleSearch();
}
//
function handleView(row) {
console.log('查看', row);
ElMessageBox.alert(`查看 ID=${row.id} 的详情`, '查看');
}
// /
function handleEdit(row) {
console.log('编辑', row);
ElMessageBox.alert(`编辑 ID=${row.id}`, '编辑');
}
//
function handleSubmit(row) {
ElMessageBox.confirm('确定提交审核吗?', '提交审核').then(() => {
// update status -> pending
row.status = 'pending';
console.log(`ID=${row.id} 提交审核`);
ElMessage.success('提交成功,状态已变为“待审核”');
});
}
//
function handleResubmit(row) {
ElMessageBox.confirm('确认重新提交吗?', '重新提交').then(() => {
// update status -> pending
row.status = 'pending';
row.rejectReason = '';
console.log(`ID=${row.id} 重新提交`);
ElMessage.success('已重新提交,状态已变为“待审核”');
});
}
//
function handleWithdraw(row) {
ElMessageBox.confirm('确认撤销本次审核吗?', '撤销').then(() => {
// update status -> draft
row.status = 'draft';
console.log(`ID=${row.id} 撤销到“待提交”`);
ElMessage.success('已撤销,状态已变为“待提交”');
});
}
//
function handleApprove(row) {
ElMessageBox.confirm('确认通过?', '审核通过').then(() => {
// update status -> approved
row.status = 'approved';
console.log(`ID=${row.id} 审核通过`);
ElMessage.success('已通过');
});
}
//
function handleReject(row) {
ElMessageBox.prompt('请输入驳回原因', '审核驳回', {
confirmButtonText: '确定',
cancelButtonText: '取消',
})
.then(({ value }) => {
if (!value.trim()) {
ElMessage.error('驳回原因不能为空');
return;
}
// update status -> rejected + rejectReason
row.status = 'rejected';
row.rejectReason = value.trim();
console.log(`ID=${row.id} 驳回,原因:${value.trim()}`);
ElMessage.success('已驳回');
})
.catch(() => {
//
});
}
// /
function showRejectReason(row) {
ElMessageBox.alert(row.rejectReason || '无驳回原因', '驳回原因');
}
//
function handleDelete(row) {
ElMessageBox.confirm('确定删除该条记录?', '删除提示').then(() => {
// update allData
const idx = allData.value.findIndex((r) => r.id === row.id);
if (idx !== -1) {
allData.value.splice(idx, 1);
}
console.log(`ID=${row.id} 已删除`);
ElMessage.success('已删除');
});
}
// ---------------------------------------------------------------------
// 4. allData
// ---------------------------------------------------------------------
onMounted(() => {
//
// fetch('/api/records').then(resp => { allData.value = resp.data })
});
</script>
<style scoped lang="scss">
.custom-page {
padding: 20px;
height: calc(100vh - 150px);
overflow-y: auto;
.search-bar {
margin-bottom: 20px;
}
}
</style>

View File

@ -78,6 +78,10 @@ const state = reactive({
// detail: true,
// detailTitle: '',
column: [
{
label: '网格编号',
prop: 'id',
},
{
label: '网格名称',
prop: 'gridName',

View File

@ -3,7 +3,6 @@
<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"
@ -14,18 +13,65 @@
@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="Plus" @click="onAdd">新增</el-button>
<el-button type="success" icon="download" @click="onExport">导出</el-button>
</template>
<template #menu="scope">
<custom-table-operate :actions="state.options.actions" :data="scope" />
</template>
<template #search>
<div class="custom-search">
<div class="search-fields">
<div class="search-item">
<span>网格员姓名</span>
<el-input v-model="state.query.memberName" placeholder="网格员姓名" style="width: 200px; margin-right: 10px" />
</div>
<div class="search-item">
<AreaCascader
v-model:region-code="areaQuery.regionCode"
v-model:grid-id="areaQuery.gridId"
placeholder="选择行政区域与网格"
:show-separator="true"
:width="500"
/>
</div>
</div>
<div class="search-buttons">
<el-button type="primary" @click="triggerSearch">搜索</el-button>
<el-button @click="resetSearch">重置</el-button>
</div>
</div>
</template>
</avue-crud>
<el-dialog v-model="addDialogVisible" :title="isEdit ? '编辑网格员' : '新增网格员'" width="600px">
<el-form ref="addFormRef" :model="addForm" :rules="addFormRules" label-width="120px">
<el-form-item label="网格员姓名" prop="memberName">
<el-input v-model="addForm.memberName" style="width: 380px" />
</el-form-item>
<el-form-item label="" prop="gridId" label-width="0px">
<!-- 假设 AreaCascader 是行政区域-网格的级联选择组件 -->
<AreaCascader v-model:region-code="addForm.gridAreaCode" v-model:grid-id="addForm.gridId" split-rows label="" />
</el-form-item>
<el-form-item label="电话号码" prop="phone">
<el-input v-model="addForm.phone" style="width: 380px" />
</el-form-item>
<el-form-item label="备注" prop="note">
<el-input v-model="addForm.note" type="textarea" style="width: 380px" />
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="addDialogVisible = false">取消</el-button>
<el-button type="primary" @click="submitAddForm">确定</el-button>
</span>
</template>
</el-dialog>
</div>
</template>
@ -44,73 +90,47 @@ const app = useApp();
const UserStore = useUserStore();
const crudRef = ref(null);
//
const areaQuery = reactive({
regionCode: '',
gridId: '',
});
const state = reactive({
loading: false,
query: { current: 1, size: 10 },
query: { current: 1, size: 10, memberName: '', gridAreaCode: '', gridId: '' },
form: {},
selection: [],
gridOptions: [],
options: {
...CRUD_OPTIONS,
addBtn: false,
searchBtn: false,
emptyBtn: false,
column: [
{
label: '网格员姓名',
prop: 'memberName',
searchLabelWidth: 100,
search: true,
rules: {
required: true,
message: '请输入网格员姓名',
trigger: 'blur',
},
},
{
label: '所属行政区域',
prop: 'gridAreaName',
width: 300,
searchLabelWidth: 110,
search: true,
rules: {
required: true,
message: '请输入所属区域',
trigger: 'blur',
},
},
{
label: '所属网格',
prop: 'gridId',
type: 'select',
width: 200,
search: true,
dicData: [], // loadGridOptions
props: {
label: 'gridName',
value: 'id',
},
rules: {
required: true,
message: '请选择所属网格',
trigger: 'change',
},
},
// {
// label: '',
// prop: 'adminFlag',
// type: 'radio',
// dicData: [
// { label: '', value: '1' },
// { label: '', value: '0' },
// ],
// valueDefault: '0',
// hide: true, // false
// },
{
label: '电话号码',
prop: 'phone',
rules: [
{ required: true, message: '请输入电话号码', trigger: 'blur' },
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码' },
],
},
{
label: '备注',
@ -149,7 +169,26 @@ const state = reactive({
data: [],
currentRow: {},
});
//
const addDialogVisible = ref(false);
const isEdit = ref(false);
const addFormRef = ref(null);
const addForm = reactive({
id: '',
memberName: '',
gridAreaCode: '',
gridId: '',
phone: '',
note: '',
});
const addFormRules = {
memberName: [{ required: true, message: '请输入网格员姓名', trigger: 'blur' }],
gridId: [{ required: true, message: '请选择所属网格', trigger: 'change' }],
phone: [
{ required: true, message: '请输入电话号码', trigger: 'blur' },
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码' },
],
};
const loadData = () => {
state.loading = true;
GetMemberList(state.query)
@ -196,6 +235,25 @@ const sizeChange = (size) => {
loadData();
};
//
const triggerSearch = () => {
state.query.gridAreaCode = areaQuery.regionCode;
state.query.gridId = areaQuery.gridId;
state.query.current = 1;
loadData();
};
//
const resetSearch = () => {
state.query.memberName = '';
state.query.gridAreaCode = '';
state.query.gridId = '';
areaQuery.regionCode = '';
areaQuery.gridId = '';
state.query.current = 1;
loadData();
};
const searchChange = (params, done) => {
if (done) done();
state.query = params;
@ -217,33 +275,36 @@ const rowView = (row) => {
};
const rowEdit = (row) => {
crudRef.value.rowEdit(row);
isEdit.value = true;
Object.assign(addForm, row);
addDialogVisible.value = true;
};
//
const onAdd = () => {
addDialogVisible.value = true;
//
Object.keys(addForm).forEach((key) => {
addForm[key] = '';
});
};
const rowSave = (row, done, loading) => {
AddMember(row)
.then((res) => {
if (res.code === 200) {
app.$message.success('添加成功!');
done();
loadData();
//
const submitForm = async () => {
if (!addFormRef.value) return;
try {
await addFormRef.value.validate();
if (isEdit.value) {
await UpdateMember(addForm);
app.$message.success('编辑网格员成功');
} else {
await AddMember(addForm);
app.$message.success('新增网格员成功');
}
})
.catch((err) => app.$message.error(err.msg))
.finally(() => loading());
};
const rowUpdate = (row, index, done, loading) => {
UpdateMember(row)
.then((res) => {
if (res.code === 200) {
app.$message.success('更新成功!');
done();
addDialogVisible.value = false;
loadData();
} catch (error) {
app.$message.error(isEdit.value ? '编辑网格员失败' : '新增网格员失败');
}
})
.catch((err) => app.$message.error(err.msg))
.finally(() => loading());
};
const rowDel = (row, index, done) => {
@ -289,3 +350,49 @@ const onExport = () => {
});
};
</script>
<style scoped lang="scss">
.custom-page {
padding: 20px;
.custom-search {
display: flex;
flex-direction: column;
align-items: flex-start;
padding: 16px;
border-radius: 8px;
// background-color: #f5f7fa;
.search-fields {
display: flex;
flex-wrap: wrap;
gap: 16px;
width: 100%;
margin-bottom: 16px;
}
.search-item {
display: flex;
align-items: center;
gap: 8px;
.el-input,
.el-select,
.el-cascader {
width: 200px;
}
span {
font-size: 14px;
color: #606266;
align-self: center;
}
}
.search-buttons {
display: flex;
align-self: center;
gap: 12px;
margin-left: 8px;
}
}
}
</style>

View File

@ -41,6 +41,8 @@ declare module 'vue' {
CustomTableOperate: typeof import('./src/components/custom-table-operate/index.vue')['default']
CustomTableTree: typeof import('./src/components/custom-table-tree/index.vue')['default']
IndexBak: typeof import('./src/components/page-menu/index-bak.vue')['default']
LeftMenu: typeof import('./src/components/common/leftMenu.vue')['default']
Modul: typeof import('./src/components/common/modul.js')['default']
NewHyalineCake: typeof import('./src/components/custom-echart-hyaline-cake/new-hyaline-cake.vue')['default']
PageLayout: typeof import('./src/components/page-layout/index.vue')['default']
PageMenu: typeof import('./src/components/page-menu/index.vue')['default']