土地巡查接口

This commit is contained in:
lzc 2025-03-05 17:30:38 +08:00
parent 4288429981
commit 5586c66710
5 changed files with 478 additions and 599 deletions

View File

@ -58,7 +58,7 @@ export function exportAnnua(params = {}) {
}
export function delAnnual(params) {
return request('/trace/code/annualManage/delete/' + params.id, {
return request('land-resource/annualManage/delete/' + params.id, {
method: 'DELETE',
});
}
@ -193,3 +193,25 @@ export function importLands(data) {
},
});
}
//土地巡查相关
export function getlandInspection(params = {}) {
return request('land-resource/landInspection/page', {
method: 'GET',
params,
});
}
export function savelandInspection(data) {
return request('land-resource/landInspection/save', {
method: 'POST',
data,
});
}
export function editlandInspection(data = {}) {
return request('land-resource/landInspection/update', {
method: 'PUT',
data,
});
}

View File

@ -30,75 +30,39 @@
<el-tag v-if="row.planStatus == '4'" type="danger" size="small">拒绝</el-tag>
</template>
<template #menu="scope">
<custom-table-operate :actions="state.options.actions" :data="scope" />
</template>
</avue-crud>
<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 #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="infoData.growthCycleVal[1]" :min="1" :max="30">
<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>
</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>
<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" />
</el-select>
</template>
<template #menu="scope">
<custom-table-operate :actions="state.options.actions" :data="scope" />
</template>
</avue-crud>
<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>
@ -106,29 +70,6 @@
</div>
</template>
</el-dialog>
<el-dialog v-model="detailVisible" title="年度计划详情" width="800" center>
<el-descriptions :title="currentRow.planName || ''">
<el-descriptions-item label="计划编号">{{ currentRow.id || '--' }}</el-descriptions-item>
<el-descriptions-item label="计划名称">{{ currentRow.planName || '--' }}</el-descriptions-item>
<el-descriptions-item label="种植面积">{{ currentRow.plantingArea || '--' }}</el-descriptions-item>
<el-descriptions-item label="种植月份">{{ currentRow.plantingMonths || '--' }}</el-descriptions-item>
<el-descriptions-item label="生长周期">{{ currentRow.growthCycle || '--' }}</el-descriptions-item>
<el-descriptions-item label="备注">{{ currentRow.note || '--' }}</el-descriptions-item>
<el-descriptions-item label="计划进度">{{ currentRow.planProgress || '--' }}</el-descriptions-item>
<el-descriptions-item label="状态">
<el-tag v-if="currentRow.planStatus == '1'" type="warning" size="small">待提交</el-tag>
<el-tag v-if="currentRow.planStatus == '2'" type="primary" size="small">审核中</el-tag>
<el-tag v-if="currentRow.planStatus == '3'" type="success" size="small">通过</el-tag>
<el-tag v-if="currentRow.planStatus == '4'" type="danger" size="small">拒绝</el-tag>
</el-descriptions-item>
</el-descriptions>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="toBack"> 返回 </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup>
@ -138,7 +79,6 @@ import { CRUD_OPTIONS } from '@/config';
import { isEmpty, downloadFile } from '@/utils';
import { useUserStore } from '@/store/modules/user';
import { compact } from 'lodash';
import { GetEntityList, AddEntity, UpdateEntity, DeleteEntity, ExportEntity } from '@/apis/grid';
import { getAnnualList, saveAnnual, editAnnual, examineAnnual, delAnnual, exportAnnua } from '@/apis/land.js';
const { VITE_APP_BASE_API } = import.meta.env;
@ -146,8 +86,6 @@ const app = useApp();
const UserStore = useUserStore();
const crudRef = ref(null);
const infoVisible = ref(false);
const infoRef = ref();
const monthsOptions = reactive([
{ label: '1月份', value: '1月' },
{ label: '2月份', value: '2月' },
@ -163,26 +101,11 @@ const monthsOptions = reactive([
{ label: '12月份', value: '12月' },
]);
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' }],
});
let infoData = reactive({ id: '' });
const examVisible = ref(false);
const detailVisible = ref(false);
let currentRow = reactive({});
let growthCycleVal = reactive([0, 0]);
let plantingMonths = ref([]);
const state = reactive({
loading: false,
@ -197,14 +120,76 @@ const state = reactive({
addBtnText: '',
addBtn: false,
column: [
{ label: '计划编号', prop: 'id', width: '200px', showOverflowTooltip: true },
{ label: '计划名称', prop: 'planName', width: '200px', showOverflowTooltip: true, search: true },
{ label: '种植面积', prop: 'plantingArea' },
{ label: '种植月份', prop: 'plantingMonths', width: '120px' },
{ label: '生长周期', prop: 'growthCycle', width: '120px' },
{ label: '备注', prop: 'note', width: '180px', showOverflowTooltip: true },
{ label: '计划进度', prop: 'planProgress' },
{ label: '状态', prop: 'planStatus' },
{ label: '计划编号', prop: 'id', width: '200px', showOverflowTooltip: true, addDisplay: false, editDisplay: false },
{
label: '计划名称',
prop: 'planName',
width: '200px',
showOverflowTooltip: true,
search: true,
rules: {
required: true,
message: '请选择',
trigger: 'blur',
},
},
{
label: '种植面积',
prop: 'plantingArea',
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '种植月份',
prop: 'plantingMonths',
width: '120px',
rules: {
required: true,
message: '请选择',
trigger: 'blur',
validator: (rule, value, callback) => {
if (!plantingMonths.value.length) {
callback(new Error('请输入'));
} else {
callback();
}
},
},
},
{
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();
}
},
},
},
{
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 },
],
actions: [
{
@ -297,43 +282,62 @@ const selectionChange = (rows) => {
};
const onAdd = () => {
infoVisible.value = true;
afterSub();
crudRef.value.rowAdd();
};
//
const rowSave = (row, done, loading) => {
console.info('新增');
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('编辑');
// crudRef.value.rowEdit(row);
infoData = reactive({
...row,
plantingMonths: row.plantingMonths.split(','),
growthCycleVal: row.growthCycle.split(',').map((m) => {
return Number(m.replace(/[^0-9]/gi, ''));
}),
});
infoVisible.value = true;
beforeMsg(row);
crudRef.value.rowEdit(row);
};
const rowUpdate = (row, index, done, loading) => {
console.info('更新');
// UpdateEntity(row)
// .then((res) => {
// if (res.code === 200) {
// app.$message.success('');
// done();
// loadData();
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// })
// .finally(() => {
// loading();
// });
editAnnual(row)
.then((res) => {
if (res.code === 200) {
app.$message.success('更新成功!');
done();
loadData();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {
loading();
});
};
//
@ -347,17 +351,17 @@ const rowDel = (row, index, done) => {
})
.then(() => {
console.info('删除');
// delAnnual({ id: row.id })
// .then((res) => {
// if (res.code === 200) {
// app.$message.success('');
delAnnual({ id: row.id })
.then((res) => {
if (res.code === 200) {
app.$message.success('删除成功!');
// done();
// loadData();
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// });
loadData();
}
})
.catch((err) => {
app.$message.error(err.msg);
});
})
.catch(() => {});
};
@ -387,70 +391,12 @@ const onExport = () => {
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, ''));
}),
});
infoData.id = row.id || '';
};
const doDetail = (row) => {
detailVisible.value = true;
currentRow = reactive({ ...row });
};
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;
if (parmer.id) {
editAnnual(parmer)
.then((res) => {
if (res.code === 200) {
app.$message.success('编辑成功!');
loadData();
infoHide();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {});
} else {
saveAnnual(parmer)
.then((res) => {
if (res.code === 200) {
app.$message.success('添加成功!');
loadData();
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;
beforeMsg(row);
crudRef.value.rowView(row);
};
const examCancel = () => {
@ -491,8 +437,4 @@ const toDoexam = (id, status, tips) => {
const examHide = () => {
examVisible.value = false;
};
const toBack = () => {
detailVisible.value = false;
};
</script>

View File

@ -341,7 +341,7 @@ const stageInfoRules = reactive({
//
const loadData = () => {
state.loading = true;
// state.loading = true;
// getOperationRecord(state.query)
// .then((res) => {
// if (res.code === 200) {
@ -427,7 +427,7 @@ const onExport = () => {
app.$message.error('当前暂时没有可供导出的数据!');
return;
}
state.loading = true;
// state.loading = true;
const fileName = '土地巡查明细表';
// exportOperationRecord(state.query)
// .then((res) => {

View File

@ -15,6 +15,7 @@
@current-change="currentChange"
@size-change="sizeChange"
@row-save="rowSave"
@row-update="rowUpdate"
>
<template #menu-left>
<el-button type="success" icon="download" @click="onExport">导出</el-button>
@ -74,15 +75,7 @@ import { CRUD_OPTIONS } from '@/config';
import { isEmpty, downloadFile } from '@/utils';
import { useUserStore } from '@/store/modules/user';
import { compact } from 'lodash';
import {
getOperationRecord,
saveOperationRecord,
editOperationRecord,
delOperationRecord,
exportOperationRecord,
getAddrCropByLand,
importOperationRecord,
} from '@/apis/land';
import { getlandInspection, savelandInspection, editlandInspection, exportOperationRecord, getAddrCropByLand } from '@/apis/land';
const { VITE_APP_BASE_API } = import.meta.env;
const app = useApp();
@ -115,6 +108,9 @@ const state = reactive({
query: {
current: 1,
size: 10,
taskCode: '',
taskName: '',
taskMembers: '',
},
form: {},
selection: [],
@ -124,8 +120,9 @@ const state = reactive({
column: [
{
label: '任务编号',
prop: 'executor',
prop: 'taskCode',
fixed: true,
search: true,
rules: {
required: true,
message: '请输入',
@ -134,7 +131,8 @@ const state = reactive({
},
{
label: '任务名称',
prop: 'address',
prop: 'taskName',
search: true,
width: '240px',
showOverflowTooltip: true,
rules: {
@ -145,7 +143,8 @@ const state = reactive({
},
{
label: '任务成员',
prop: 'crop',
search: true,
prop: 'taskMembers',
disabled: false,
rules: {
required: true,
@ -155,7 +154,7 @@ const state = reactive({
},
{
label: '巡查类型',
prop: 'inputName',
prop: 'inspectionType',
rules: {
required: true,
message: '请输入',
@ -164,7 +163,7 @@ const state = reactive({
},
{
label: '巡查对象',
prop: 'inputBrand',
prop: 'inspectionTarget',
rules: {
required: true,
message: '请输入',
@ -173,7 +172,7 @@ const state = reactive({
},
{
label: '注意事项',
prop: 'inputBrand',
prop: 'notes',
type: 'textarea',
rows: 1,
rules: {
@ -218,26 +217,26 @@ const infoRules = reactive({
//
const loadData = () => {
// state.loading = true;
// getOperationRecord(state.query)
// .then((res) => {
// if (res.code === 200) {
// const { current, size, total, records } = res.data;
// state.data = records;
// state.pageData = {
// currentPage: current || 1,
// pageSize: size || 10,
// total: total,
// };
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// state.data = [];
// })
// .finally(() => {
// state.loading = false;
// });
state.loading = true;
getlandInspection(state.query)
.then((res) => {
if (res.code === 200) {
const { current, size, total, records } = res.data;
state.data = records;
state.pageData = {
currentPage: current || 1,
pageSize: size || 10,
total: total,
};
}
})
.catch((err) => {
app.$message.error(err.msg);
state.data = [];
})
.finally(() => {
state.loading = false;
});
};
loadData();
@ -276,7 +275,7 @@ const selectionChange = (rows) => {
//
const rowSave = (row, done, loading) => {
// console.info('', row);
saveOperationRecord(row)
savelandInspection(row)
.then((res) => {
if (res.code === 200) {
app.$message.success('添加成功!');
@ -295,7 +294,26 @@ const rowSave = (row, done, loading) => {
//
const doEnroll = (row) => {
console.info('doEnroll', row);
infoVisible.value = true;
// infoVisible.value = true;
crudRef.value.rowEdit(row);
};
const rowUpdate = (row, index, done, loading) => {
console.info('更新');
editlandInspection(row)
.then((res) => {
if (res.code === 200) {
app.$message.success('更新成功!');
done();
loadData();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {
loading();
});
};
//

View File

@ -5,7 +5,6 @@
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"
@ -31,43 +30,9 @@
</el-tag>
</template>
<template #menu="scope">
<custom-table-operate :actions="state.options.actions" :data="scope" />
</template>
</avue-crud>
<el-dialog v-model="infoVisible" title="种植规划" width="800" center>
<el-form ref="infoRef" :model="infoData" :rules="infoRules">
<el-row :gutter="20">
<!--<el-col :span="12">
<el-form-item label="地块:" prop="landId">
<CustomSelect
v-model:value="infoData.landId"
:set="{
url: 'land-resource/landManage/page',
props: {
value: 'id',
label: 'landName',
},
}"
placeholder="请选择地块"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="面积" prop="gridName">
<el-input v-model="infoData.gridName" placeholder="请输入面积" style="width: 240px"></el-input>
</el-form-item>
</el-col> -->
<el-col :span="12">
<el-form-item label="种植产物" prop="crop">
<el-input v-model="infoData.crop" placeholder="请输入种植产物" style="width: 240px"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="种植日期" prop="planDate">
<template #planDate-form="{ row, column, value }">
<el-date-picker
v-model="infoData.planDate"
v-model="infoFirst.planDate"
type="date"
placeholder="请选择种植日期"
:disabled-date="disabledDate"
@ -75,41 +40,21 @@
value-format="YYYY/MM/DD"
:size="size"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="种子供应商" prop="seedSupplier">
<el-input v-model="infoData.seedSupplier" placeholder="请输入种子供应商" style="width: 240px"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="年度计划" prop="planId">
<CustomSelect
v-model:value="infoData.planId"
:set="{
url: 'land-resource/annualManage/page',
props: {
value: 'id',
label: 'planName',
},
}"
placeholder="请选择种植计划"
/>
</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>
<template #planId="{ row }">
{{ row.planName }}
</template>
<template #menu="scope">
<custom-table-operate :actions="state.options.actions" :data="scope" />
</template>
</avue-crud>
<el-text class="mx-1" size="large">种植阶段详情</el-text>
<div style="margin-top: 16px">
<avue-crud
ref="crudRef"
ref="stateCrudRef"
v-model="stageState.form"
v-model:search="stageState.query"
v-model:page="stageState.pageData"
@ -123,6 +68,8 @@
@current-change="stageCurrent"
@size-change="stageSize"
@row-del="stageRowDel"
@row-save="stageRowSave"
@row-update="stageRowUpdate"
>
<template #menu-left>
<el-button type="primary" icon="Plus" @click="onStateAdd">新增</el-button>
@ -137,7 +84,7 @@
</template>
</avue-crud>
<el-dialog v-model="stageInfoVisible" title="种植阶段" width="800" center>
<!-- <el-dialog v-model="stageInfoVisible" title="种植阶段" width="800" center>
<el-form ref="stageInfoRef" :model="stageInfoData" :rules="stageInfoRules">
<el-row :gutter="20">
<el-col :span="12">
@ -173,10 +120,6 @@
:set="{
url: '',
options: workOptions,
props: {
value: 'id',
label: 'planName',
},
}"
placeholder="请选择作业计划"
/>
@ -190,7 +133,7 @@
<el-button type="primary" @click="subMitStateInfo(stageInfoRef)"> 确认 </el-button>
</div>
</template>
</el-dialog>
</el-dialog> -->
</div>
</div>
</template>
@ -219,12 +162,18 @@ const { VITE_APP_BASE_API } = import.meta.env;
const app = useApp();
const UserStore = useUserStore();
const crudRef = ref(null);
const stateCrudRef = ref(null);
const stageOptions = reactive([
{ value: '0', label: '苗期' },
{ value: '1', label: '花果期' },
{ value: '2', label: '采收期' },
]);
const workOptions = reactive([
{ label: '作业计划1', value: '000001' },
{ label: '作业计划2', value: '000002' },
]);
const state = reactive({
loading: false,
query: {
@ -233,25 +182,29 @@ const state = reactive({
},
form: {},
selection: [],
tableClumn: [
options: {
...CRUD_OPTIONS,
addBtn: false,
rowKey: 'landId',
column: [
{
label: '地块名',
type: 'input',
prop: 'landName',
disabled: true,
search: true,
addDisplay: false,
editDisplay: false,
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{ label: '地址', prop: 'address', width: '240px', showOverflowTooltip: true, disabled: true },
{ label: '地址', prop: 'address', width: '240px', showOverflowTooltip: true, addDisplay: false, editDisplay: false },
{
label: '种植产物',
type: 'input',
prop: 'crop',
disabled: true,
search: true,
rules: {
required: true,
@ -263,8 +216,9 @@ const state = reactive({
label: '产权人',
type: 'input',
prop: 'owner',
disabled: true,
search: true,
addDisplay: false,
editDisplay: false,
rules: {
required: true,
message: '请输入',
@ -274,48 +228,70 @@ const state = reactive({
{
label: '农用地分类',
prop: 'landClassificationType',
disabled: true,
addDisplay: false,
editDisplay: false,
},
{
label: '面积',
prop: 'area',
disabled: true,
addDisplay: false,
editDisplay: false,
},
{ label: '坐标', prop: 'coordinate', disabled: true, width: '120px', showOverflowTooltip: true },
{ label: '坐标', prop: 'coordinate', width: '120px', showOverflowTooltip: true, addDisplay: false, editDisplay: false },
{
label: '土壤类型',
prop: 'soilType',
disabled: true,
},
{
label: '种植产物',
prop: 'crop',
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
addDisplay: false,
editDisplay: false,
},
{
label: '种子供应商',
prop: 'seedSupplier',
disabled: true,
rules: {
required: true,
message: '请选择',
trigger: 'blur',
},
},
{
label: '年度计划',
prop: 'planName',
disabled: true,
prop: 'planId',
type: 'select',
remote: false,
props: {
label: 'planName',
value: 'id',
},
dicHeaders: {
authorization: UserStore.token,
},
dicUrl: `${VITE_APP_BASE_API}/land-resource/annualManage/page`,
dicFormatter: (res) => res.data.records ?? [],
rules: [
{
required: true,
message: '请选择',
trigger: 'blur',
},
],
},
{
label: '种植日期',
prop: 'planDate',
disabled: true,
rules: {
required: true,
message: '请选择',
trigger: 'blur',
validator: (rule, value, callback) => {
if (!infoFirst.value.planDate || infoFirst.value.planDate == '') {
callback(new Error('请选择'));
} else {
callback();
}
},
},
},
],
options: {
...CRUD_OPTIONS,
addBtn: false,
column: [],
actions: [
{
name: '编辑',
@ -363,9 +339,20 @@ const stageState = reactive({
trigger: 'blur',
},
},
{ label: '作业计划', prop: 'area', disabled: true },
{ label: '作业时间', prop: 'coordinate', disabled: true },
{ label: '结束时间', prop: 'createTime', disabled: true },
{
label: '作业计划',
prop: 'workId',
type: 'select',
search: true,
dicData: workOptions,
rules: {
required: true,
message: '请选择',
trigger: 'blur',
},
},
{ label: '作业时间', prop: 'coordinate', addDisplay: false, editDisplay: false },
{ label: '结束时间', prop: 'createTime', addDisplay: false, editDisplay: false },
],
actions: [
{
@ -401,14 +388,9 @@ const landClassificationType = reactive({
7: '农村宅基地',
});
const infoVisible = ref(false);
const infoRef = ref();
let infoData = reactive({
landId: [], //id
let infoFirst = ref({
planId: '', //id
crop: '', //
seedSupplier: '', //
planDate: '', //
planDate: '',
});
const infoRules = reactive({
@ -423,10 +405,6 @@ const stageObj = reactive({
1: '花果期',
2: '采收期',
});
const workOptions = reactive([
{ planName: '作业计划1', id: '000001' },
{ planName: '作业计划2', id: '000002' },
]);
let stageInfoVisible = ref(false);
const stageInfoRef = ref();
@ -447,7 +425,6 @@ const stageInfoRules = reactive({
//
const loadData = () => {
state.loading = true;
state.options.column = JSON.parse(JSON.stringify(state.tableClumn));
getPlanList(state.query)
.then((res) => {
if (res.code === 200) {
@ -500,64 +477,63 @@ const refreshChange = () => {
//
const selectionChange = (rows) => {
state.selection = rows;
console.info('selectionChange', state.selection);
};
const setCity = (row) => {
if (!isEmpty(row.cities)) {
row.provinceCode = row?.cities[0] ?? null;
row.cityCode = row?.cities[1] ?? null;
row.gridAreaCode = row?.cities[2] ?? null;
row.townCode = row?.cities[3] ?? null;
row.village = row?.cities[3] ?? null;
}
};
const handleIds = () => {
let datalist = state.selection.map((m) => {
return { landId: m.landId, landName: m.landName };
});
let selectIdlist = uniqueObjects(datalist, 'landId');
let selectIdsVal = selectIdlist.map((n) => {
return n.landId;
});
return selectIdsVal.toString() || '';
};
//
const rowSave = (row, done, loading) => {
state.options.column = JSON.parse(JSON.stringify(state.tableClumn));
console.info('新增');
// savePlan(row)
// .then((res) => {
// if (res.code === 200) {
// app.$message.success('');
// done();
// loadData();
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// })
// .finally(() => {
// loading();
// });
console.info('新增', infoFirst.value);
row.planDate = infoFirst.value.planDate || '';
row.landId = handleIds();
savePlan(row)
.then((res) => {
if (res.code === 200) {
app.$message.success('添加成功!');
done();
loadData();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {
loading();
});
};
//
const rowEdit = (row) => {
infoVisible.value = true;
infoData = reactive({
...row,
});
// console.info('');
// row.cities = compact([row.provinceCode, row.cityCode, row.gridAreaCode ?? '', row.townCode ?? '', row.village ?? '']);
// crudRef.value.rowEdit(row);
console.info('编辑', row);
crudRef.value.rowEdit(row);
};
const rowUpdate = (row, index, done, loading) => {
console.info('更新');
// editAlan(row)
// .then((res) => {
// if (res.code === 200) {
// app.$message.success('');
// done();
// loadData();
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// })
// .finally(() => {
// loading();
// });
editAlan(row)
.then((res) => {
if (res.code === 200) {
app.$message.success('更新成功!');
done();
loadData();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {
loading();
});
};
//
@ -575,7 +551,7 @@ const rowDel = (row, index, done) => {
.then((res) => {
if (res.code === 200) {
app.$message.success('删除成功!');
done();
// done();
loadData();
}
})
@ -612,70 +588,12 @@ const onExport = () => {
};
const onAdd = () => {
infoVisible.value = true;
};
const subMitInfo = (formEl) => {
if (!formEl) return;
formEl.validate((valid) => {
if (valid) {
let parmer = {
...infoData,
};
if (!parmer.id) {
let datalist = state.selection.map((m) => {
return { landId: m.landId, landName: m.landName };
});
let selectIdlist = uniqueObjects(datalist, 'landId');
let selectIdsVal = selectIdlist.map((n) => {
return n.landId;
});
parmer.landId = selectIdsVal.toString() || '';
infoFirst.value.planDate = infoFirst.value.planId = '';
let ids = handleIds();
if (ids == '') {
return app.$message.error('先选择土地!');
}
console.info('新增种植计划', parmer);
if (parmer.id) {
editAlan(parmer)
.then((res) => {
if (res.code === 200) {
app.$message.success('编辑成功!');
loadData();
infoHide();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {});
} else {
savePlan(parmer)
.then((res) => {
if (res.code === 200) {
loadData();
infoHide();
app.$message.success('添加成功!');
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {});
}
} else {
console.log('error submit!');
}
});
};
const infoCancel = () => {
infoHide();
};
const infoHide = () => {
infoVisible.value = false;
crudRef.value.rowAdd();
};
function uniqueObjects(arr, key) {
@ -769,61 +687,7 @@ const stageRowDel = (row, index, done) => {
.catch(() => {});
};
const stageRowEdit = (row) => {
stageInfoData.landName = row.landName ? row.landName : state.currentRow.landName || '';
stageInfoData.landId = row.landId ? row.landId : state.currentRow.landId || '';
stageInfoData.crop = row.crop ? row.crop : state.currentRow.crop || '';
stageInfoData.stage = row.stage.toString() || '0';
stageInfoVisible.value = true;
};
const stageinfoHide = () => {
stageInfoRef.value && stageInfoRef.value.resetFields();
stageInfoVisible.value = false;
};
const subMitStateInfo = (formEl) => {
if (!formEl) return;
formEl.validate((valid) => {
if (valid) {
let parmer = {
planId: state.currentRow.id || '', //id
stage: stageInfoData.stage || 0, //:0->,1>,2->
workId: stageInfoData.workId || '',
};
console.info('新增种植阶段', parmer);
if (parmer.id) {
editPlantingStage(parmer)
.then((res) => {
if (res.code === 200) {
app.$message.success('编辑成功!');
getStageList();
stageinfoHide();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {});
} else {
savePlantingStage(parmer)
.then((res) => {
if (res.code === 200) {
getStageList();
stageinfoHide();
app.$message.success('添加成功!');
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {});
}
} else {
console.log('error submit!');
}
});
stateCrudRef.value.rowEdit(row);
};
const onStateAdd = () => {
@ -831,10 +695,43 @@ const onStateAdd = () => {
app.$message.error('请选择种植规划');
return;
}
stateCrudRef.value.rowAdd();
};
console.info('onStateAdd', state.currentRow);
stageInfoData.landName = state.currentRow.landName || '';
stageInfoData.crop = state.currentRow.crop || '';
stageInfoVisible.value = true;
const stageRowSave = (row, done, loading) => {
row.planId = state.currentRow.planId;
console.info('stageRowSave', row);
savePlantingStage({ ...row })
.then((res) => {
if (res.code === 200) {
app.$message.success('添加成功!');
done();
getStageList();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {
loading();
});
};
const stageRowUpdate = (row, index, done, loading) => {
console.info('stageRowUpdate');
editPlantingStage(row)
.then((res) => {
if (res.code === 200) {
app.$message.success('更新成功!');
done();
getStageList();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {
loading();
});
};
</script>