Compare commits
2 Commits
006b5871f7
...
43a81b26e9
Author | SHA1 | Date | |
---|---|---|---|
43a81b26e9 | |||
8b332ec22e |
@ -3,291 +3,111 @@
|
|||||||
<avue-crud
|
<avue-crud
|
||||||
ref="crudRef"
|
ref="crudRef"
|
||||||
v-model="state.form"
|
v-model="state.form"
|
||||||
|
v-model:search="state.query"
|
||||||
v-model:page="state.pageData"
|
v-model:page="state.pageData"
|
||||||
:table-loading="state.loading"
|
:table-loading="state.loading"
|
||||||
:data="state.data"
|
:data="state.data"
|
||||||
:option="state.options"
|
:option="state.options"
|
||||||
@refresh-change="refreshChange"
|
@refresh-change="refreshChange"
|
||||||
|
@search-reset="searchChange"
|
||||||
|
@search-change="searchChange"
|
||||||
@selection-change="selectionChange"
|
@selection-change="selectionChange"
|
||||||
@current-change="currentChange"
|
@current-change="currentChange"
|
||||||
@size-change="sizeChange"
|
@size-change="sizeChange"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-del="rowDel"
|
||||||
>
|
>
|
||||||
<template #menu-left>
|
<template #menu-left>
|
||||||
<el-button type="primary" icon="Plus" @click="onAdd">新增</el-button>
|
<el-button type="primary" icon="Plus" @click="onAdd">新增</el-button>
|
||||||
<el-button type="success" icon="download" @click="onExport">导出</el-button>
|
<el-button type="success" icon="download" @click="onExport">导出</el-button>
|
||||||
</template>
|
</template>
|
||||||
<template #menu="{ row }">
|
|
||||||
<custom-table-operate :actions="state.options.actions" :data="{ row }" />
|
<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>
|
</template>
|
||||||
|
|
||||||
<template #search>
|
<template #growthCycle-form="{ row, column, value, type }">
|
||||||
<div class="custom-search">
|
<el-input-number v-model="growthCycleVal[0]" :disabled="type == 'view' ? true : false" :min="1" :max="30" style="width: 130px">
|
||||||
<div class="search-fields">
|
<template #suffix>
|
||||||
<div class="search-item">
|
<span>天</span>
|
||||||
<AreaCascader
|
</template>
|
||||||
v-model:region-code="areaQuery.regionCode"
|
</el-input-number>
|
||||||
v-model:grid-id="areaQuery.gridId"
|
-
|
||||||
placeholder="选择行政区域与网格"
|
<el-input-number v-model="growthCycleVal[1]" :min="1" :disabled="type == 'view' ? true : false" :max="30" style="width: 130px">
|
||||||
:show-separator="true"
|
<template #suffix>
|
||||||
:width="500"
|
<span>天</span>
|
||||||
/>
|
</template>
|
||||||
</div>
|
</el-input-number>
|
||||||
<div class="search-item">
|
</template>
|
||||||
<span>种植作物:</span>
|
|
||||||
<el-select v-model="state.query.cropsId" placeholder="种植作物" :clearable="true">
|
<template #plantingMonths-form="{ row, column, value, type }">
|
||||||
<el-option v-for="item in cropsOptions" :key="item.id" :label="item.cropsName" :value="item.id" />
|
<el-select
|
||||||
</el-select>
|
v-model="plantingMonths"
|
||||||
</div>
|
placeholder="请选择月份"
|
||||||
<div class="search-item">
|
:disabled="type == 'view' ? true : false"
|
||||||
<span>计划编号:</span>
|
style="width: 200px"
|
||||||
<el-input v-model="state.query.id" placeholder="计划编号" :clearable="true" />
|
:clearable="true"
|
||||||
</div>
|
:multiple="true"
|
||||||
<div class="search-item">
|
>
|
||||||
<span>计划名称:</span>
|
<el-option v-for="item in monthsOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||||
<el-input v-model="state.query.planName" placeholder="计划名称" :clearable="true" />
|
</el-select>
|
||||||
</div>
|
</template>
|
||||||
</div>
|
|
||||||
<div class="search-buttons">
|
<template #menu="scope">
|
||||||
<el-button type="primary" @click="searchChange"> 查询 </el-button>
|
<custom-table-operate :actions="state.options.actions" :data="scope" />
|
||||||
<el-button @click="resetSearch"> 重置 </el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
</avue-crud>
|
</avue-crud>
|
||||||
|
|
||||||
<el-dialog v-model="detailDialogVisible" title="年度种植计划详情页" width="800" class="detail-dialog">
|
<el-dialog v-model="examVisible" title="审核计划" width="500" center>
|
||||||
<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>
|
<template #footer>
|
||||||
<span class="dialog-footer">
|
<div class="dialog-footer">
|
||||||
<el-button @click="detailDialogVisible = false">关闭</el-button>
|
<el-button type="danger" @click="examCancel">审核拒绝</el-button>
|
||||||
</span>
|
<el-button type="primary" @click="examPast"> 审核通过 </el-button>
|
||||||
</template>
|
</div>
|
||||||
</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>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, ref, computed, onMounted, watch } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { useApp } from '@/hooks';
|
import { useApp } from '@/hooks';
|
||||||
import { CRUD_OPTIONS } from '@/config';
|
import { CRUD_OPTIONS } from '@/config';
|
||||||
import { isEmpty, downloadFile } from '@/utils';
|
import { isEmpty, downloadFile } from '@/utils';
|
||||||
import { useUserStore } from '@/store/modules/user';
|
import { getAnnualList, saveAnnual, editAnnual, examineAnnual, delAnnual, exportAnnua } from '@/apis/land.js';
|
||||||
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 app = useApp();
|
||||||
const crudRef = ref(null);
|
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([
|
||||||
const getGrowthCycleUnitName = (unit) => {
|
{ label: '1月份', value: '1月' },
|
||||||
const unitMap = {
|
{ label: '2月份', value: '2月' },
|
||||||
1: '天',
|
{ label: '3月份', value: '3月' },
|
||||||
2: '周',
|
{ label: '4月份', value: '4月' },
|
||||||
3: '月',
|
{ label: '5月份', value: '5月' },
|
||||||
4: '年',
|
{ label: '6月份', value: '6月' },
|
||||||
};
|
{ label: '7月份', value: '7月' },
|
||||||
return unitMap[unit] || '';
|
{ label: '8月份', value: '8月' },
|
||||||
};
|
{ label: '9月份', value: '9月' },
|
||||||
// 获取详情数据
|
{ label: '10月份', value: '10月' },
|
||||||
const fetchDetailData = async (id) => {
|
{ label: '11月份', value: '11月' },
|
||||||
try {
|
{ label: '12月份', value: '12月' },
|
||||||
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;
|
|
||||||
});
|
|
||||||
|
|
||||||
// 级联选择器查询参数,必须使用 ref ,否则无法使用 v-model:value 更新
|
let infoData = reactive({ id: '' });
|
||||||
const areaQuery = ref({
|
|
||||||
regionCode: '',
|
const examVisible = ref(false);
|
||||||
gridName: '',
|
let growthCycleVal = reactive([0, 0]);
|
||||||
gridId: '',
|
let plantingMonths = ref([]);
|
||||||
});
|
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
loading: false,
|
loading: false,
|
||||||
query: {
|
query: {
|
||||||
current: 1,
|
current: 1,
|
||||||
size: 10,
|
size: 10,
|
||||||
id: '',
|
|
||||||
planName: '',
|
|
||||||
cropsName: '',
|
|
||||||
cropsId: '',
|
|
||||||
},
|
},
|
||||||
form: {},
|
form: {},
|
||||||
selection: [],
|
selection: [],
|
||||||
@ -295,63 +115,102 @@ const state = reactive({
|
|||||||
...CRUD_OPTIONS,
|
...CRUD_OPTIONS,
|
||||||
addBtnText: '',
|
addBtnText: '',
|
||||||
addBtn: false,
|
addBtn: false,
|
||||||
searchBtn: false,
|
|
||||||
emptyBtn: false,
|
|
||||||
fit: true,
|
|
||||||
column: [
|
column: [
|
||||||
{ label: '计划编号', prop: 'id', minWidth: 100 },
|
{ label: '计划编号', prop: 'id', width: '200px', showOverflowTooltip: true, addDisplay: false, editDisplay: false },
|
||||||
{ label: '计划名称', prop: 'planName' },
|
{
|
||||||
{ label: '种植作物', prop: 'cropsName' },
|
label: '计划名称',
|
||||||
{ label: '种植面积', prop: 'plantingArea', formatter: (row, column, cellValue) => `${cellValue} 亩` },
|
prop: 'planName',
|
||||||
{ label: '种植月份', prop: 'plantingMonths', formatter: (row, column, cellValue) => `${cellValue} 月` },
|
width: '200px',
|
||||||
|
showOverflowTooltip: true,
|
||||||
|
search: true,
|
||||||
|
rules: {
|
||||||
|
required: true,
|
||||||
|
message: '请选择',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '种植面积',
|
||||||
|
prop: 'plantingArea',
|
||||||
|
rules: {
|
||||||
|
required: true,
|
||||||
|
message: '请输入',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
formatter: (row, column, cellValue) => {
|
||||||
|
return 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) => {
|
||||||
|
return cellValue ? cellValue + '月' : '';
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: '生长周期',
|
label: '生长周期',
|
||||||
prop: 'growthCycle',
|
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) => {
|
formatter: (row, column, cellValue) => {
|
||||||
const unitMap = { 1: '天', 2: '周', 3: '月', 4: '年' };
|
return cellValue ? cellValue + '天' : '';
|
||||||
const unit = unitMap[row.growthCycleUnit] || '';
|
|
||||||
return `${cellValue} ${unit}`;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ label: '所属行政区域', prop: 'regionName' },
|
{
|
||||||
{ label: '所属网格', prop: 'gridName' },
|
label: '备注',
|
||||||
{ label: '当前进度', prop: 'currentProgress' },
|
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 },
|
||||||
],
|
],
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
name: '查看',
|
name: '审核',
|
||||||
icon: 'view',
|
icon: 'Stamp',
|
||||||
event: ({ row }) => {
|
event: ({ row }) => doExam(row),
|
||||||
openDetailDialog(row);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '重新制定计划',
|
name: '编辑',
|
||||||
icon: 'edit',
|
icon: 'edit',
|
||||||
event: ({ row }) => {
|
event: ({ row }) => rowEdit(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: '填写实际种植信息',
|
name: '详情',
|
||||||
icon: 'edit',
|
icon: 'List',
|
||||||
event: ({ row }) => {
|
event: ({ row }) => doDetail(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',
|
type: 'danger',
|
||||||
@ -370,72 +229,6 @@ const state = reactive({
|
|||||||
currentRow: {},
|
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 = () => {
|
const loadData = () => {
|
||||||
state.loading = true;
|
state.loading = true;
|
||||||
@ -475,29 +268,10 @@ const sizeChange = (size) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 搜索
|
// 搜索
|
||||||
const searchChange = () => {
|
const searchChange = (params, done) => {
|
||||||
state.query = {
|
if (done) done();
|
||||||
...state.query,
|
state.query = params;
|
||||||
...areaQuery.value,
|
state.query.current = 1;
|
||||||
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();
|
loadData();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -512,6 +286,65 @@ const selectionChange = (rows) => {
|
|||||||
state.selection = 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) => {
|
const rowDel = (row, index, done) => {
|
||||||
if (isEmpty(row)) return;
|
if (isEmpty(row)) return;
|
||||||
@ -559,101 +392,53 @@ const onExport = () => {
|
|||||||
state.loading = false;
|
state.loading = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
</script>
|
|
||||||
<style scoped lang="scss">
|
|
||||||
.custom-page {
|
|
||||||
/* 详情弹窗样式 */
|
|
||||||
|
|
||||||
/* 表单弹窗样式 */
|
const doExam = (row) => {
|
||||||
.el-dialog {
|
examVisible.value = true;
|
||||||
.el-form {
|
infoData.id = row.id || '';
|
||||||
padding: 0 20px;
|
};
|
||||||
width: 100%;
|
|
||||||
// background-color: aqua;
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: center;
|
|
||||||
|
|
||||||
&-item {
|
const doDetail = (row) => {
|
||||||
margin-bottom: 18px;
|
beforeMsg(row);
|
||||||
width: 60%;
|
crudRef.value.rowView(row);
|
||||||
// background-color: #606266;
|
};
|
||||||
|
|
||||||
&__label {
|
const examCancel = () => {
|
||||||
font-weight: 500;
|
console.log('审核不通过');
|
||||||
color: #606266;
|
examVisible.value = true;
|
||||||
}
|
toDoexam(infoData.id, '4', '审核不通过');
|
||||||
|
};
|
||||||
|
|
||||||
/* 输入框和选择器统一宽度 */
|
const examPast = (row) => {
|
||||||
.el-input,
|
console.log('审核通过');
|
||||||
.el-select,
|
toDoexam(infoData.id, '3', '审核通过');
|
||||||
.el-cascader {
|
};
|
||||||
width: 100%;
|
|
||||||
max-width: 400px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 数字输入框和单位选择器组合 */
|
const toDoexam = (id, status, tips) => {
|
||||||
.el-input-number {
|
app
|
||||||
margin-right: 10px;
|
.$confirm(`确定` + tips + `吗?`, '温馨提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
& + .el-select {
|
cancelButtonText: '取消',
|
||||||
width: 100px;
|
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 = () => {
|
||||||
.el-button {
|
examVisible.value = false;
|
||||||
padding: 8px 16px;
|
};
|
||||||
border-radius: 4px;
|
</script>
|
||||||
|
|
||||||
& + .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>
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user