年度计划

This commit is contained in:
lzc 2025-02-27 14:57:30 +08:00
parent ff77efc2a3
commit 9c24ada207
8 changed files with 539 additions and 8 deletions

View File

@ -6,3 +6,51 @@ export function getLandsList(params = {}) {
params, params,
}); });
} }
export function saveLands(params = {}) {
return request('land-resource/landManage/save', {
method: 'POST',
params,
});
}
export function getAnnualList(params = {}) {
return request('land-resource/annualManage/page', {
method: 'GET',
params,
});
}
export function saveAnnual(data) {
return request('land-resource/annualManage/save', {
method: 'POST',
data,
});
}
export function editAnnual(data = {}) {
return request('land-resource/annualManage/edit', {
method: 'PUT',
data,
});
}
export function examineAnnual(data = {}) {
return request('land-resource/annualManage/exam', {
method: 'PUT',
data,
});
}
export function exportAnnua(params = {}) {
return request('/land-resource/annualManage/export', {
method: 'GET',
params,
responseType: 'blob',
});
}
export function delAnnual(params) {
return request('/trace/code/annualManage/delete', {
method: 'DELETE',
params,
});
}

View File

@ -12,6 +12,7 @@ import Layout from '@/layouts/index.vue';
import resourceRouter from './modules/resource'; import resourceRouter from './modules/resource';
import plantingAndBreedingRouter from './modules/plantingAndBreeding'; import plantingAndBreedingRouter from './modules/plantingAndBreeding';
import landsRoutes from './modules/lands'; import landsRoutes from './modules/lands';
import annualplanRoutes from './modules/annualplan';
const { VITE_APP_NAME } = import.meta.env; const { VITE_APP_NAME } = import.meta.env;
@ -45,6 +46,7 @@ export const constantRoutes = [
}, },
// ...resourceRouter, // ...resourceRouter,
...plantingAndBreedingRouter, ...plantingAndBreedingRouter,
...annualplanRoutes,
...landsRoutes, ...landsRoutes,
]; ];

View File

@ -0,0 +1,26 @@
import Layout from '@/layouts/index.vue';
const annualplanRoutes = [
{
path: '/annualPlan',
name: 'annualPlan',
component: Layout,
redirect: '/annualPlans',
meta: { title: '年度计划', icon: 'Document' },
children: [
{
path: '/annualPlans',
name: 'annualPlans',
component: () => import('@/views/annualPlan/component/annualPlans/index.vue'),
meta: { title: '年度计划', icon: 'Document' },
},
{
path: '/plantings',
name: 'plantings',
component: () => import('@/views/annualPlan/component/plantings/index.vue'),
meta: { title: '网格种植进度', icon: 'Document' },
},
],
},
];
export default annualplanRoutes;

View File

@ -75,8 +75,10 @@ publicAxios.interceptors.request.use(async (config) => {
* @param res * @param res
* @returns * @returns
*/ */
const formatResult = (res) => { const formatResult = async (res) => {
const code = res.data.code || res.status; const code = res.data.code || res.status;
// console.info('formatResult', code)
const UserStore = useUserStore();
switch (code) { switch (code) {
case 200: case 200:
case 0: case 0:
@ -87,6 +89,11 @@ const formatResult = (res) => {
// code === 1 或 500 代表存在错误 // code === 1 或 500 代表存在错误
ElNotification.error(res.data.msg); ElNotification.error(res.data.msg);
break; break;
case 401:
// code === 401 代表登录过期
await UserStore.logout();
router.push('/login');
break;
default: default:
ElNotification.error(res.data.msg); ElNotification.error(res.data.msg);
break; break;
@ -97,6 +104,7 @@ const formatResult = (res) => {
*/ */
publicAxios.interceptors.response.use((response) => { publicAxios.interceptors.response.use((response) => {
const { config } = response; const { config } = response;
// console.info('响应拦截器', response);
if (config?.responseType) { if (config?.responseType) {
return response; return response;
} }

View File

@ -0,0 +1,407 @@
<template>
<CustCard>
<el-form ref="searchRef" :model="searchCondition">
<el-row :gutter="20">
<el-col :span="6">
<el-form-item label="计划名称:" prop="planName">
<el-input v-model="searchCondition.planName" placeholder="请输入"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-button type="primary" @click="getList()">查询</el-button>
<el-button type="" @click="handleResetSearch">重置</el-button>
</el-col>
</el-row>
</el-form>
<div class="options_btns">
<el-button v-for="(item, i) in btns" :key="'btns_' + i" type="primary" @click="item.method">
{{ item.label }}
</el-button>
</div>
<el-table :data="list">
<el-table-column type="selection" width="55" />
<el-table-column type="index"> </el-table-column>
<el-table-column label="计划编号" prop="id" show-overflow-tooltip />
<el-table-column label="计划名称" prop="planName" show-overflow-tooltip />
<el-table-column label="种植面积" prop="plantingArea" show-overflow-tooltip />
<el-table-column label="种植月份" prop="plantingMonths" show-overflow-tooltip />
<el-table-column label="生长周期" prop="growthCycle" show-overflow-tooltip />
<el-table-column label="备注" prop="note" show-overflow-tooltip />
<el-table-column label="计划进度" prop="planProgress" show-overflow-tooltip />
<el-table-column label="状态" prop="planStatus" show-overflow-tooltip>
<template #default="{ row }">
<el-tag v-if="row.planStatus == '1'" type="warning">待提交</el-tag>
<el-tag v-if="row.planStatus == '2'" type="primary">审核中</el-tag>
<el-tag v-if="row.planStatus == '3'" type="success">通过</el-tag>
<el-tag v-if="row.planStatus == '4'" type="danger">拒绝</el-tag>
</template>
</el-table-column>
<el-table-column fixed="right" label="操作" width="380" show-overflow-tooltip>
<template #default="{ row }">
<el-button type="primary" @click="doExam(row)">审核</el-button>
<el-button type="primary" @click="doEdit(row)">编辑</el-button>
<el-button type="primary" @click="doDetail(row)">详情</el-button>
<el-button type="danger" @click="doDel(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<Pagina :page-data="pageData" />
<el-dialog v-model="infoVisible" title="年度种植计划" width="1000" center>
<el-form ref="infoRef" :model="infoData" :rules="infoRules">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="计划名称:" prop="planName">
<el-input v-model="infoData.planName" placeholder="请输入" style="width: 240px"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="种植面积" prop="plantingArea">
<el-input-number v-model="infoData.plantingArea" :min="1" :max="10000">
<template #suffix>
<span></span>
</template>
</el-input-number>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="适宜种植月份" prop="plantingMonths">
<el-select v-model="infoData.plantingMonths" placeholder="请选择月份" style="width: 240px" :clearable="true" :multiple="true">
<el-option v-for="item in monthsOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="生厂周期" prop="growthCycleVal">
<el-input-number v-model="infoData.growthCycleVal[0]" :min="1" :max="30">
<template #suffix>
<span></span>
</template>
</el-input-number>
&nbsp; - &nbsp;
<el-input-number v-model="infoData.growthCycleVal[1]" :min="1" :max="30">
<template #suffix>
<span></span>
</template>
</el-input-number>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="备注" prop="note">
<el-input v-model="infoData.note" type="textarea" placeholder="请输入备注" style="width: 240px"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="infoCancel">取消</el-button>
<el-button type="primary" @click="subMitInfo(infoRef)"> 确认 </el-button>
</div>
</template>
</el-dialog>
<el-dialog v-model="examVisible" title="审核计划" width="500" center>
<!-- <el-form ref="infoRef" :model="infoData" :rules="infoRules">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="备注" prop="note">
<el-input v-model="infoData.note" type="textarea" placeholder="请输入备注" style="width: 240px"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form> -->
<template #footer>
<div class="dialog-footer">
<el-button type="danger" @click="examCancel">审核拒绝</el-button>
<el-button type="primary" @click="examPast"> 审核通过 </el-button>
</div>
</template>
</el-dialog>
</CustCard>
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue';
import Pagina from '@/components/pagina.vue';
import CustCard from '@/components/CustCard.vue';
import { getAnnualList, saveAnnual, editAnnual, examineAnnual, delAnnual, exportAnnua } from '@/apis/land.js';
import { useApp } from '@/hooks';
import { isEmpty, imageToBase64, getAssetsFile, downloadFile } from '@/utils';
onMounted(() => {
getList();
});
/* --------------- data --------------- */
// #region
const app = useApp();
const searchRef = ref();
const searchCondition = reactive({
planName: '',
});
const pageData = reactive({
page: 1,
size: 10,
total: 0,
});
const infoVisible = ref(false);
const infoRef = ref();
const list = ref([]);
const state = reactive({
loading: false,
query: {
current: 1,
size: 10,
},
pageData: {
total: 0,
currentPage: 1,
pageSize: 10,
},
data: [],
currentRow: {},
});
const btns = reactive([
{
label: '新增年度规划',
loading: false,
method: function () {
console.log('add');
infoVisible.value = true;
},
},
{
label: '导出',
disabled: true,
method: function () {
if (isEmpty(state.data)) {
app.$message.error('当前暂时没有可供导出的数据!');
return;
}
state.loading = true;
const fileName = '年度规划明细表';
exportAnnua(state.query)
.then((res) => {
if (res.status === 200) {
downloadFile(res.data, `${fileName}.xlsx`, 'blob');
app.$message.success('导出成功!');
}
})
.catch((err) => {
app.$message.error('导出失败!');
})
.finally(() => {
state.loading = false;
});
},
},
]);
let infoData = reactive({
planName: '',
plantingArea: 0,
plantingMonths: [],
growthCycle: '',
note: '',
growthCycleVal: [0, 0],
});
const infoRules = reactive({
planName: [{ required: true, message: '请输入计划名称', trigger: 'blur' }],
plantingArea: [{ required: true, message: '请输入种植面积', trigger: 'blur' }],
plantingMonths: [{ required: true, message: '请选择种植月份', trigger: 'blur' }],
growthCycleVal: [{ required: true, message: '请输入生长周期', trigger: 'blur' }],
note: [{ required: true, message: '请输入备注', trigger: 'blur' }],
});
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 examVisible = ref(false);
// #endregion
/* --------------- methods --------------- */
// #region
async function getList() {
const params = { current: pageData.page, size: pageData.size };
let { code, data, msg } = await getAnnualList(params);
//console.log('res ---------', data);
list.value = data.records || [];
pageData.total = data.total;
state.data = data.records;
state.pageData = {
currentPage: data.current || 1,
pageSize: data.size || 10,
total: data.total,
};
}
function handleResetSearch() {
searchRef.value && searchRef.value.resetFields();
getList();
}
function doEdit(row) {
infoVisible.value = true;
// eslint-disable-next-line no-const-assign
infoData = reactive({
...row,
plantingMonths: row.plantingMonths.split(','),
growthCycleVal: row.growthCycle.split(',').map((m) => {
return Number(m.replace(/[^0-9]/gi, ''));
}),
});
}
function doDel(row) {
// console.info('');
app
.$confirm(`删除后信息将不可查看,确认要删除吗?`, '确定删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
// delAnnual({ ids: ids.join(',') })
// .then((res) => {
// if (res.code === 200) {
// app.$message.success('');
// getList();
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// });
})
.catch(() => {});
}
const doExam = (row) => {
examVisible.value = true;
infoData = reactive({
...row,
plantingMonths: row.plantingMonths.split(','),
growthCycleVal: row.growthCycle.split(',').map((m) => {
return Number(m.replace(/[^0-9]/gi, ''));
}),
});
};
const subMitInfo = (formEl) => {
if (!formEl) return;
formEl.validate((valid) => {
if (valid) {
let parmer = {
...infoData,
plantingMonths: infoData.plantingMonths.toString(),
growthCycle: infoData.growthCycleVal[0] + '周' + ',' + infoData.growthCycleVal[1] + '周',
};
parmer.growthCycleVal && delete parmer.growthCycleVal;
console.info('新增年度规划参数', parmer);
if (parmer.id) {
editAnnual(parmer)
.then((res) => {
if (res.code === 200) {
app.$message.success('编辑成功!');
getList();
infoHide();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {});
} else {
saveAnnual(parmer)
.then((res) => {
if (res.code === 200) {
app.$message.success('添加成功!');
getList();
infoHide();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {});
}
} else {
console.log('error submit!');
}
});
};
const infoCancel = () => {
infoHide();
};
const infoHide = () => {
infoRef.value && infoRef.value.resetFields();
infoVisible.value = false;
};
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('审核提交成功!');
getList();
examHide();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {});
})
.catch(() => {});
};
const examHide = () => {
examVisible.value = false;
};
// #endregion
</script>
<style lang="scss" scoped>
.container {
border-radius: 4px;
background-color: #ffffff;
}
</style>

View File

@ -0,0 +1,19 @@
<template>
<router-view></router-view>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
/* --------------- data --------------- */
// #region
// #endregion
/* --------------- methods --------------- */
// #region
// #endregion
</script>
<style lang="scss" scoped></style>

View File

@ -8,8 +8,8 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-form-item label="种植产物" prop="gridName"> <el-form-item label="种植产物" prop="crop">
<el-input v-model="searchCondition.gridName" placeholder="请输入"></el-input> <el-input v-model="searchCondition.crop" placeholder="请输入"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
@ -146,7 +146,7 @@
import { ref, reactive, onMounted } from 'vue'; import { ref, reactive, onMounted } from 'vue';
import Pagina from '@/components/pagina.vue'; import Pagina from '@/components/pagina.vue';
import CustCard from '@/components/CustCard.vue'; import CustCard from '@/components/CustCard.vue';
import { getLandsList } from '@/apis/land.js'; import { getLandsList, saveLands } from '@/apis/land.js';
import { useApp } from '@/hooks'; import { useApp } from '@/hooks';
onMounted(() => { onMounted(() => {
getList(); getList();
@ -158,9 +158,11 @@ const app = useApp();
const searchRef = ref(); const searchRef = ref();
const searchCondition = reactive({ const searchCondition = reactive({
name: '', landName: '',
person: '', owner: '',
crop: '',
}); });
const pageData = reactive({ const pageData = reactive({
page: 1, page: 1,
size: 10, size: 10,
@ -176,6 +178,23 @@ const btns = reactive([
method: function () { method: function () {
console.log('add'); console.log('add');
infoVisible.value = true; infoVisible.value = true;
let parmer = {
landId: '1892400039696359426,1892400422703423489',
planId: '1890242496744136706',
crop: '水稻',
seedSupplier: '园艺',
planDate: '2025-02-25',
};
saveLands({})
.then((res) => {
if (res.code === 200) {
app.$message.success('添加成功!');
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {});
}, },
}, },
{ {
@ -244,8 +263,10 @@ const stageOptions = reactive([
async function getList() { async function getList() {
const params = { current: pageData.page, size: pageData.size }; const params = { current: pageData.page, size: pageData.size };
let res = await getLandsList(params); let { code, data, msg } = await getLandsList(params);
console.log('res ---------', res); //console.log('res ---------', data);
list.value = data.records || [];
pageData.total = data.total;
} }
function handleResetSearch() { function handleResetSearch() {