This commit is contained in:
李想 2025-03-04 16:56:47 +08:00
commit 95bb9ab404
9 changed files with 1852 additions and 399 deletions

View File

@ -132,6 +132,57 @@ export function delLand(id) {
method: 'DELETE',
});
}
//作业记录相关
export function getOperationRecord(params = {}) {
return request('land-resource/operationRecord/page', {
method: 'GET',
params,
});
}
export function saveOperationRecord(data) {
return request('land-resource/operationRecord/save', {
method: 'POST',
data,
});
}
export function editOperationRecord(data = {}) {
return request('land-resource/operationRecord/update', {
method: 'PUT',
data,
});
}
export function delOperationRecord(id) {
return request('land-resource/operationRecord/delete/' + id, {
method: 'DELETE',
});
}
export function exportOperationRecord(params = {}) {
return request('/land-resource/operationRecord/export', {
method: 'GET',
params,
responseType: 'blob',
});
}
export function importOperationRecord(data = {}) {
return request('/land-resource/operationRecord/import', {
method: 'POST',
data,
headers: { 'Content-Type': 'multipart/form-data' },
});
}
//通过土地获取产物和位置
export function getAddrCropByLand(landId) {
return request('land-resource/operationRecord/workArea/' + landId, {
method: 'GET',
});
}
/* 导入土地 */
export function importLands(data) {
return request('land-resource/landManage/import', {

View File

@ -296,16 +296,6 @@ const selectionChange = (rows) => {
state.selection = rows;
};
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 onAdd = () => {
infoVisible.value = true;
};

View File

@ -1,65 +1,633 @@
<template>
<div>
<el-row :gutter="20">
<el-col :span="6">
<el-tree style="max-width: 600px" :data="typeTree" :props="{ children: 'children', label: 'label' }" @node-click="handleNodeClick" />
</el-col>
<el-col :span="18"></el-col>
</el-row>
<div class="custom-page">
<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-click="rowClick"
>
<template #menu-left>
<el-button type="success" icon="download" @click="onExport">导出</el-button>
</template>
<template #status="{ row }">
{{ !row.status ? '是' : '否' }}
</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"
v-model="stageState.form"
v-model:search="stageState.query"
v-model:page="stageState.pageData"
:table-loading="stageState.loading"
:data="stageState.data"
:option="stageState.options"
@refresh-change="stageRefresh"
@search-reset="stageSearch"
@search-change="stageSearch"
@selection-change="stageSelection"
@current-change="stageCurrent"
@size-change="stageSize"
@row-del="stageRowDel"
>
<template #menu-left>
<el-button type="primary" icon="Plus" @click="onStateAdd">新增</el-button>
</template>
<template #stage="{ row }">
<el-tag size="small">{{ stageObj[row.stage] }}</el-tag>
</template>
<template #menu="scope">
<custom-table-operate :actions="stageState.options.actions" :data="scope" />
</template>
</avue-crud>
<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">
<el-form-item label="地块:" prop="landName">
<el-input v-model="stageInfoData.landName" placeholder="请输入地块" style="width: 240px" :disabled="true"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="种植产物" prop="crop">
<el-input v-model="stageInfoData.crop" placeholder="请输入种植产物" style="width: 240px" :disabled="true"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="种植阶段" prop="stage">
<CustomSelect
v-model:value="stageInfoData.stage"
:set="{
url: '',
options: stageOptions,
props: {
value: 'value',
label: 'label',
},
}"
placeholder="请选择种植阶段"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="作业计划" prop="workId">
<CustomSelect
v-model:value="stageInfoData.workId"
:set="{
url: '',
options: workOptions,
props: {
value: 'id',
label: 'planName',
},
}"
placeholder="请选择作业计划"
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="stageCancel">取消</el-button>
<el-button type="primary" @click="subMitStateInfo(stageInfoRef)"> 确认 </el-button>
</div>
</template>
</el-dialog>
</div>
</div>
</template>
<script lang="ts" setup>
import { ref, reactive } from 'vue';
<script setup>
import { reactive, ref } from 'vue';
import { useApp } from '@/hooks';
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';
/* --------------- data --------------- */
// #region
const { VITE_APP_BASE_API } = import.meta.env;
const app = useApp();
const UserStore = useUserStore();
const crudRef = ref(null);
const handleLandChange = async (value, form, done) => {
if (!value || !value.item || !value.item.id) return; //
let val = {};
getAddrCropByLand(value.item?.id || '')
.then((res) => {
if (res.code === 200) {
val = res.data || {};
}
})
.catch((err) => {
val = {};
})
.finally(() => {});
state.form.crop = val?.crop || value.item?.crop;
state.form.address = val?.county + val?.town + val?.village || value.item?.address;
};
let typeTree = reactive([
{
label: 'Level one 1',
children: [
{
label: 'Level two 1-1',
children: [
{
label: 'Level three 1-1-1',
},
],
},
],
},
{
label: 'Level one 2',
children: [
{
label: 'Level two 2-1',
children: [
{
label: 'Level three 2-1-1',
},
],
},
{
label: 'Level two 2-2',
children: [
{
label: 'Level three 2-2-1',
},
],
},
],
},
const jobTypeOptions = reactive([
{ label: '施肥', value: '0' },
{ label: '杀虫', value: '1' },
{ label: '灌溉', value: '2' },
]);
// #endregion
const stageOptions = reactive([
{ value: '0', label: '苗期' },
{ value: '1', label: '花果期' },
{ value: '2', label: '采收期' },
]);
const state = reactive({
loading: false,
query: {
current: 1,
size: 10,
},
form: {},
selection: [],
options: {
...CRUD_OPTIONS,
addBtnText: '新增',
column: [
{
label: '编号',
prop: 'executor',
fixed: true,
addDisplay: false,
editDisabled: true,
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '种植产物',
prop: 'crop',
width: '240px',
editDisabled: true,
showOverflowTooltip: true,
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '种植时间',
prop: 'operationDate',
type: 'date',
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
width: 200,
rules: {
required: true,
message: '请选择作业日期',
trigger: 'blur',
},
},
{
label: '状态',
prop: 'status',
addDisplay: false,
editDisplay: false,
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
],
searchColumn: [],
actions: [
{
name: '编辑',
icon: 'edit',
event: ({ row }) => rowEdit(row),
},
],
},
pageData: {
total: 0,
currentPage: 1,
pageSize: 10,
},
data: [],
currentRow: {},
});
const infoVisible = ref(false);
const infoRef = ref();
const infoData = reactive({
num: '',
name: '',
member: [],
type: '',
mark: '',
target: '',
});
/* --------------- methods --------------- */
const handleNodeClick = (data) => {
console.log(data);
const infoRules = reactive({
num: [{ required: true, message: '请选择是否违法', trigger: 'blur' }],
mark: [{ required: true, message: '请输入巡查情况', trigger: 'blur' }],
});
const stageState = reactive({
loading: false,
query: {
current: 1,
size: 10,
},
form: {},
options: {
...CRUD_OPTIONS,
addBtn: false,
selection: false,
column: [
{
label: '所属阶段',
prop: 'stage',
type: 'select',
search: true,
dicData: stageOptions,
rules: {
required: true,
message: '请选择',
trigger: 'blur',
},
},
{ label: '作业计划', prop: 'area', disabled: true },
{ label: '作业时间', prop: 'coordinate', disabled: true },
{ label: '结束时间', prop: 'createTime', disabled: true },
],
actions: [
{
name: '编辑',
icon: 'edit',
event: ({ row }) => stageRowEdit(row),
},
{
type: 'danger',
name: '删除',
icon: 'delete',
event: ({ row }) => stageRowDel(row),
},
],
},
pageData: {
total: 0,
currentPage: 1,
pageSize: 10,
},
data: [],
currentRow: {},
});
const stageObj = reactive({
0: '苗期',
1: '花果期',
2: '采收期',
});
const workOptions = reactive([
{ planName: '作业计划1', id: '000001' },
{ planName: '作业计划2', id: '000002' },
]);
let stageInfoVisible = ref(false);
const stageInfoRef = ref();
let stageInfoData = reactive({
landId: '', //id
planId: '', //id
crop: '', //
stage: '', //
workId: '', //Id
landName: '', //
});
const stageInfoRules = reactive({
stage: [{ required: true, message: '请选择所属阶段', trigger: 'blur' }],
workId: [{ required: true, message: '请选择作业计划', trigger: 'blur' }],
});
//
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;
// });
};
// #region
// #endregion
loadData();
//
const currentChange = (current) => {
state.query.current = current;
loadData();
};
//
const sizeChange = (size) => {
state.query.size = size;
loadData();
};
//
const searchChange = (params, done) => {
if (done) done();
state.query = params;
state.query.current = 1;
loadData();
};
//
const refreshChange = () => {
loadData();
app.$message.success('刷新成功');
};
//
const selectionChange = (rows) => {
state.selection = rows;
};
//
const rowSave = (row, done, loading) => {
// console.info('', row);
saveOperationRecord(row)
.then((res) => {
if (res.code === 200) {
app.$message.success('添加成功!');
done();
loadData();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {
loading();
});
};
//
const rowEdit = (row) => {
console.info('编辑', row);
crudRef.value.rowEdit(row);
};
//
const onExport = () => {
if (isEmpty(state.data)) {
app.$message.error('当前暂时没有可供导出的数据!');
return;
}
state.loading = true;
const fileName = '土地巡查明细表';
// exportOperationRecord(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;
// });
};
const subMitInfo = (formEl) => {
if (!formEl) return;
formEl.validate((valid) => {
if (valid) {
infoHide();
console.log('submit!');
} else {
console.log('error submit!');
}
});
};
const infoCancel = () => {
infoHide();
};
const infoHide = () => {
infoRef.value && infoRef.value.resetFields();
infoVisible.value = false;
};
const rowUpdate = (row, index, done, loading) => {
console.info('更新');
// editOperationRecord(row)
// .then((res) => {
// if (res.code === 200) {
// app.$message.success('');
// done();
// loadData();
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// })
// .finally(() => {
// loading();
// });
};
//
//
const stageRefresh = () => {
// loadData();
app.$message.success('刷新成功');
};
const rowClick = (row) => {
state.currentRow = { ...row };
console.info('rowClick', state.currentRow);
getStageList();
};
async function getStageList() {
// stageState.loading = true;
// getPlantingStage({ ...stageState.query, planId: state.currentRow.id })
// .then((res) => {
// if (res.code === 200) {
// const { current, size, total, records } = res.data;
// stageState.data = records || [];
// stageState.pageData = {
// currentPage: current || 1,
// pageSize: size || 10,
// total: total,
// };
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// stageState.data = [];
// })
// .finally(() => {
// stageState.loading = false;
// });
}
const stageSearch = (params, done) => {
if (done) done();
stageState.query = params;
stageState.query.current = 1;
getStageList();
};
const stageSelection = (rows) => {
stageState.selection = rows;
};
const stageCurrent = (current) => {
stageState.query.current = current;
getStageList();
};
const stageSize = (size) => {
stageState.query.size = size;
getStageList();
};
const stageRowDel = (row, index, done) => {
if (isEmpty(row)) return;
app
.$confirm(`删除后信息将不可查看,确认要删除吗?`, '确定删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
console.info('删除');
// delPlantingStage({ id: row.id })
// .then((res) => {
// if (res.code === 200) {
// app.$message.success('');
// getStageList();
// done();
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// });
})
.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!');
}
});
};
const onStateAdd = () => {
if (!state.currentRow.id) {
app.$message.error('请选择种植产物');
return;
}
stageInfoData.landName = state.currentRow.landName || '';
stageInfoData.crop = state.currentRow.crop || '';
stageInfoVisible.value = true;
};
</script>
<style lang="scss" scoped></style>

View File

@ -1,46 +1,84 @@
<template>
<CustomCard>
<el-row :gutter="20">
<el-col :span="6">
<el-tree style="max-width: 600px" :data="typeTree" :props="{ children: 'children', label: 'label' }" @node-click="handleNodeClick" />
</el-col>
<el-col :span="18">
<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>
<div>
<el-row :gutter="20">
<el-col :span="6">
<el-tree style="max-width: 600px" :data="typeTree" :props="{ children: 'children', label: 'label' }" @node-click="handleNodeClick" />
</el-col>
<el-col :span="18">
<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-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>
</avue-crud>
</el-col>
</el-row>
<template #menu="scope">
<custom-table-operate :actions="state.options.actions" :data="scope" />
</template>
</avue-crud>
</el-col>
</el-row>
</div>
<el-dialog v-model="infoVisible" title="新增土地分类" width="800" center>
<div>
<el-form ref="infoRef" :model="infoData" :rules="infoRules">
<el-row :gutter="20">
<el-col v-if="infoData.classifyId == ''" :span="12">
<el-form-item label="土地分类:" prop="classifyName">
<el-input v-model="infoData.classifyName" placeholder="请输入" style="width: 240px"></el-input>
</el-form-item>
</el-col>
<el-col v-if="infoData.classifyId != ''" :span="12">
<el-form-item label="土地分类" prop="classifyId">
<el-select
v-model="infoData.classifyId"
placeholder="请选择土地分类"
:disabled="true"
style="width: 240px"
:clearable="true"
:multiple="false"
>
<el-option v-for="item in landUsedOptions" :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="category">
<el-input v-model="infoData.category" placeholder="请输入" style="width: 240px"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
<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>
</CustomCard>
</template>
<script lang="ts" setup>
<script setup>
import { ref, reactive, onMounted } from 'vue';
import { useApp } from '@/hooks';
import { ref, reactive } from 'vue';
import CustomCard from '@/components/CustomCard.vue';
import { CRUD_OPTIONS } from '@/config';
import CustomCard from '@/components/CustomCard.vue';
const { VITE_APP_BASE_API } = import.meta.env;
const app = useApp();
@ -95,46 +133,107 @@ const state = reactive({
let typeTree = reactive([
{
label: 'Level one 1',
label: '农用地',
id: '0',
children: [
{
label: 'Level two 1-1',
children: [
{
label: 'Level three 1-1-1',
},
],
},
{ label: '耕地', id: '01', children: [], pId: '0' },
{ label: '园地', children: [], id: '02', pId: '0' },
],
},
{
label: 'Level one 2',
children: [
{
label: 'Level two 2-1',
children: [
{
label: 'Level three 2-1-1',
},
],
},
{
label: 'Level two 2-2',
children: [
{
label: 'Level three 2-2-1',
},
],
},
],
label: '建设用地',
id: '1',
children: [{ label: '城乡建设用地', children: [], id: '11', pId: '10' }],
},
{
label: '住宅用地',
id: '2',
children: [],
},
]);
const infoVisible = ref(false);
const infoRef = ref();
const landUsedOptions = reactive([
{ label: '农用地', value: '0' },
{ label: '建设用地', value: '1' },
{ label: '住宅用地', value: '2' },
]);
let infoData = reactive({
classifyId: '',
category: '',
classifyName: '',
});
const infoRules = reactive({
planName: [{ required: true, message: '请输入计划名称', trigger: 'blur' }],
});
// #endregion
/* --------------- methods --------------- */
const loadData = () => {
//state.loading = true;
// getAnnualList(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;
// });
};
onMounted(() => {
loadData();
});
//
const currentChange = (current) => {
state.query.current = current;
loadData();
};
//
const sizeChange = (size) => {
state.query.size = size;
loadData();
};
//
const searchChange = (params, done) => {
if (done) done();
state.query = params;
state.query.current = 1;
loadData();
};
//
const refreshChange = () => {
loadData();
app.$message.success('刷新成功');
};
//
const selectionChange = (rows) => {
state.selection = rows;
};
const handleNodeClick = (data) => {
console.log(data);
infoData.classifyId = data.pId ? data.pId : data.id;
console.log(infoData);
};
//
const rowStatus = (row) => {
@ -154,9 +253,22 @@ const getStatusButtonText = (status) => {
const rowEdit = () => {};
const onAdd = () => {};
const onAdd = () => {
infoVisible.value = true;
};
const onExport = () => {};
const subMitInfo = (formEl) => {};
const infoCancel = () => {
infoHide();
};
const infoHide = () => {
infoRef.value && infoRef.value.resetFields();
infoVisible.value = false;
};
// #region
// #endregion

View File

@ -1,3 +1,304 @@
<template>
<div>行政区域信息</div>
<CustomCard>
<div>
<el-row :gutter="20">
<el-col :span="6">
<el-tree style="max-width: 600px" :data="typeTree" :props="{ children: 'children', label: 'label' }" @node-click="handleNodeClick" />
</el-col>
<el-col :span="18">
<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-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>
</avue-crud>
</el-col>
</el-row>
</div>
<el-dialog v-model="infoVisible" title="新增行政区域信息" width="800" center>
<div>
<el-form ref="infoRef" :model="infoData" :rules="infoRules">
<el-row :gutter="20">
<el-col v-if="infoData.countyId != ''" :span="12">
<el-form-item label="县" prop="countyId">
<el-select
v-model="infoData.countyId"
placeholder="请选择县"
:disabled="true"
style="width: 240px"
:clearable="true"
:multiple="false"
>
<el-option v-for="item in countyOptions" :key="item.id" :label="item.label" :value="item.id" />
</el-select>
</el-form-item>
</el-col>
<el-col v-if="infoData.townId != ''" :span="12">
<el-form-item label="镇" prop="townId">
<el-select v-model="infoData.townId" placeholder="请选择镇" :disabled="true" style="width: 240px" :clearable="true" :multiple="false">
<el-option v-for="item in townOptions" :key="item.id" :label="item.label" :value="item.id" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="名称:" prop="name">
<el-input v-model="infoData.name" placeholder="请输入" style="width: 240px"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
<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>
</CustomCard>
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue';
import { useApp } from '@/hooks';
import { CRUD_OPTIONS } from '@/config';
import CustomCard from '@/components/CustomCard.vue';
const { VITE_APP_BASE_API } = import.meta.env;
const app = useApp();
/* --------------- data --------------- */
// #region
const state = reactive({
loading: false,
query: {
current: 1,
size: 10,
},
form: {},
selection: [],
options: {
...CRUD_OPTIONS,
addBtnText: '',
addBtn: false,
column: [
{ label: '编号', prop: 'gridManager' },
{ label: '所属区县', prop: 'gridManager' },
{ label: '所属乡镇', prop: 'gridManager' },
{ label: '村名', prop: 'gridManager' },
{ label: '状态', prop: 'gridManager' },
],
actions: [
{
name: (row) => getStatusButtonText(row.status),
icon: 'edit',
event: ({ row }) => rowStatus(row),
},
{
name: '编辑',
icon: 'edit',
event: ({ row }) => rowEdit(row),
},
{
type: 'danger',
name: '删除',
icon: 'delete',
event: ({ row }) => rowDel(row),
},
],
},
pageData: {
total: 0,
currentPage: 1,
pageSize: 10,
},
data: [],
currentRow: {},
});
let typeTree = reactive([
{
label: '耿马县',
id: '0',
level: '0',
children: [
{
label: '镇1',
level: '1',
id: '01',
children: [
{ label: '村1', children: [], id: '0101', pId: '01', level: '2' },
{ label: '村2', children: [], id: '0102', pId: '01', level: '2' },
],
pId: '0',
},
{ label: '镇2', level: '1', children: [], id: '02', pId: '0' },
],
},
{
label: '县1',
id: '1',
level: '0',
children: [{ label: '镇1', children: [], id: '11', pId: '10', level: '1' }],
},
]);
const infoVisible = ref(false);
const infoRef = ref();
const countyOptions = reactive([
{ label: '耿马县', id: '0' },
{ label: '县1', id: '1' },
]);
let townOptions = reactive([]);
let infoData = reactive({
countyId: '',
townId: '',
name: '',
});
const infoRules = reactive({
planName: [{ required: true, message: '请输入计划名称', trigger: 'blur' }],
});
// #endregion
/* --------------- methods --------------- */
const loadData = () => {
//state.loading = true;
// getAnnualList(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;
// });
};
onMounted(() => {
loadData();
});
//
const currentChange = (current) => {
state.query.current = current;
loadData();
};
//
const sizeChange = (size) => {
state.query.size = size;
loadData();
};
//
const searchChange = (params, done) => {
if (done) done();
state.query = params;
state.query.current = 1;
loadData();
};
//
const refreshChange = () => {
loadData();
app.$message.success('刷新成功');
};
//
const selectionChange = (rows) => {
state.selection = rows;
};
const handleNodeClick = (data) => {
if (data.level == '2') {
return;
}
// console.info('data', data);
if (data.level == '0') {
infoData.countyId = data.id;
infoData.townId = '';
}
if (data.level == '1') {
let countys =
typeTree.filter((m) => {
return m.id == data.pId;
}) || [];
let town = countys[0] && countys[0].children ? countys[0].children : [];
townOptions = town;
infoData.townId = data.id;
infoData.countyId = data.pId;
}
// console.info('infoData', infoData);
};
//
const rowStatus = (row) => {
console.info('操作状态');
};
const rowDel = (row) => {};
const getStatusButtonText = (status) => {
switch (status) {
case 'active':
return '启用';
case 'inactive':
return '禁用';
}
};
const rowEdit = () => {};
const onAdd = () => {
infoVisible.value = true;
};
const onExport = () => {};
const subMitInfo = (formEl) => {};
const infoCancel = () => {
infoHide();
};
const infoHide = () => {
infoRef.value && infoRef.value.resetFields();
infoVisible.value = false;
};
// #region
// #endregion
</script>
<style lang="scss" scoped></style>

View File

@ -0,0 +1,199 @@
<template>
<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="landName" show-overflow-tooltip />
<el-table-column label="任务名称" prop="address" show-overflow-tooltip />
<el-table-column label="任务成员" prop="owner" show-overflow-tooltip />
<el-table-column label="巡查类型" prop="landClassificationType" show-overflow-tooltip />
<el-table-column label="巡查注意事项" prop="978.2" show-overflow-tooltip />
<el-table-column label="巡查对象" prop="coordinate" show-overflow-tooltip />
<el-table-column label="是否违法" prop="landTransfer" show-overflow-tooltip>
<template #default="{ row }">
{{ !row.landTransfer ? '是' : '否' }}
</template>
</el-table-column>
<el-table-column label="状态" prop="landTransfer" show-overflow-tooltip>
<template #default="{ row }">
{{ !row.landTransfer ? '是' : '否' }}
</template>
</el-table-column>
<el-table-column fixed="right" label="操作" width="200" show-overflow-tooltip>
<el-button type="primary" @click="doResults()">登记结果</el-button>
</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="num">
<el-input v-model="infoData.num" placeholder="请输入" style="width: 240px"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="任务名称" prop="name">
<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="member">
<el-select v-model="infoData.member" :multiple="true" placeholder="请选择任务成员" style="width: 240px" :clearable="true">
<el-option v-for="item in memberOptions" :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="gridName">
<el-select v-model="infoData.type" placeholder="请选择巡查类型" style="width: 240px" :clearable="true">
<el-option v-for="item in typeOptions" :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="gridName">
<el-input
v-model="infoData.mark"
:autosize="{ minRows: 2, maxRows: 4 }"
type="textarea"
laceholder="请输入巡查注意事项"
style="width: 240px"
></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="巡查对象" prop="gridName">
<el-select v-model="infoData.target" placeholder="请选择巡查对象" style="width: 240px" :clearable="true">
<el-option v-for="item in objOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</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>
<script lang="ts" setup>
import { ref, reactive } from 'vue';
/* --------------- data --------------- */
// #region
const btns = reactive([
{
label: '新增巡查',
method: function () {
console.log('add');
infoVisible.value = true;
},
},
{
label: '导出',
disabled: true,
method: function () {
console.log('export');
},
},
]);
const pageData = reactive({
page: 1,
size: 10,
total: 0,
});
const list = ref([]);
const infoVisible = ref(false);
const infoRef = ref();
const infoData = reactive({
num: '',
name: '',
member: [],
type: '',
mark: '',
target: '',
});
const infoRules = reactive({
num: [{ required: true, message: '请输入编号', trigger: 'blur' }],
});
const memberOptions = reactive([
{
value: '成员1',
label: 'Option1',
},
{
value: '成员2',
label: 'Option2',
},
]);
const typeOptions = reactive([
{
value: '巡查类型1',
label: 'Option1',
},
{
value: '巡查类型2',
label: 'Option2',
},
]);
const objOptions = reactive([
{
value: '巡查对象1',
label: 'Option1',
},
{
value: '巡查对象2',
label: 'Option2',
},
]);
// #endregion
/* --------------- methods --------------- */
const doResults = () => {
console.info('登记结果');
};
const subMitInfo = (formEl) => {
if (!formEl) return;
formEl.validate((valid) => {
if (valid) {
infoHide();
console.log('submit!');
} else {
console.log('error submit!');
}
});
};
const infoCancel = () => {
infoHide();
};
const infoHide = () => {
infoRef.value && infoRef.value.resetFields();
infoVisible.value = false;
};
// #region
// #endregion
</script>
<style lang="scss" scoped>
.options_btns {
margin: 16px 0;
}
</style>

View File

@ -1,119 +1,205 @@
<template>
<section>土地巡查</section>
<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 class="custom-page">
<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"
>
<template #menu-left>
<el-button type="success" icon="download" @click="onExport">导出</el-button>
</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-descriptions :title="infoData.planName || ''" :column="2">
<el-descriptions-item label="任务编号">{{ infoData.id || '--' }}</el-descriptions-item>
<el-descriptions-item label="任务名称">{{ infoData.planName || '--' }}</el-descriptions-item>
<el-descriptions-item label="任务成员">{{ infoData.plantingArea || '--' }}</el-descriptions-item>
<el-descriptions-item label="巡查类型">{{ infoData.plantingMonths || '--' }}</el-descriptions-item>
<el-descriptions-item label="注意事项">{{ infoData.growthCycle || '--' }}</el-descriptions-item>
<el-descriptions-item label="巡查对象">{{ infoData.note || '--' }}</el-descriptions-item>
</el-descriptions>
<el-descriptions :title="'巡查信息登记'"> </el-descriptions>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="是否违法:" prop="num">
<el-radio-group v-model="radio1">
<el-radio value="1" size="large"></el-radio>
<el-radio value="2" size="large"></el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="巡查情况" prop="gridName">
<el-input
v-model="infoData.mark"
:autosize="{ minRows: 2, maxRows: 4 }"
type="textarea"
laceholder="请输入巡查情况"
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>
</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="landName" show-overflow-tooltip />
<el-table-column label="任务名称" prop="address" show-overflow-tooltip />
<el-table-column label="任务成员" prop="owner" show-overflow-tooltip />
<el-table-column label="巡查类型" prop="landClassificationType" show-overflow-tooltip />
<el-table-column label="巡查注意事项" prop="978.2" show-overflow-tooltip />
<el-table-column label="巡查对象" prop="coordinate" show-overflow-tooltip />
<el-table-column label="是否违法" prop="landTransfer" show-overflow-tooltip>
<template #default="{ row }">
{{ !row.landTransfer ? '是' : '否' }}
</template>
</el-table-column>
<el-table-column label="状态" prop="landTransfer" show-overflow-tooltip>
<template #default="{ row }">
{{ !row.landTransfer ? '是' : '否' }}
</template>
</el-table-column>
<el-table-column fixed="right" label="操作" width="200" show-overflow-tooltip>
<el-button type="primary" @click="doResults()">登记结果</el-button>
</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="num">
<el-input v-model="infoData.num" placeholder="请输入" style="width: 240px"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="任务名称" prop="name">
<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="member">
<el-select v-model="infoData.member" :multiple="true" placeholder="请选择任务成员" style="width: 240px" :clearable="true">
<el-option v-for="item in memberOptions" :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="gridName">
<el-select v-model="infoData.type" placeholder="请选择巡查类型" style="width: 240px" :clearable="true">
<el-option v-for="item in typeOptions" :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="gridName">
<el-input
v-model="infoData.mark"
:autosize="{ minRows: 2, maxRows: 4 }"
type="textarea"
laceholder="请输入巡查注意事项"
style="width: 240px"
></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="巡查对象" prop="gridName">
<el-select v-model="infoData.target" placeholder="请选择巡查对象" style="width: 240px" :clearable="true">
<el-option v-for="item in objOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</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>
<script setup>
import { reactive, ref } from 'vue';
import { useApp } from '@/hooks';
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';
<script lang="ts" setup>
import { ref, reactive } from 'vue';
const { VITE_APP_BASE_API } = import.meta.env;
const app = useApp();
const UserStore = useUserStore();
const crudRef = ref(null);
const handleLandChange = async (value, form, done) => {
if (!value || !value.item || !value.item.id) return; //
let val = {};
getAddrCropByLand(value.item?.id || '')
.then((res) => {
if (res.code === 200) {
val = res.data || {};
}
})
.catch((err) => {
val = {};
})
.finally(() => {});
state.form.crop = val?.crop || value.item?.crop;
state.form.address = val?.county + val?.town + val?.village || value.item?.address;
};
/* --------------- data --------------- */
// #region
const btns = reactive([
{
label: '新增巡查',
method: function () {
console.log('add');
infoVisible.value = true;
},
},
{
label: '导出',
disabled: true,
method: function () {
console.log('export');
},
},
const jobTypeOptions = reactive([
{ label: '施肥', value: '0' },
{ label: '杀虫', value: '1' },
{ label: '灌溉', value: '2' },
]);
const pageData = reactive({
page: 1,
size: 10,
total: 0,
const state = reactive({
loading: false,
query: {
current: 1,
size: 10,
},
form: {},
selection: [],
options: {
...CRUD_OPTIONS,
addBtnText: '新增',
column: [
{
label: '任务编号',
prop: 'executor',
fixed: true,
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '任务名称',
prop: 'address',
width: '240px',
showOverflowTooltip: true,
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '任务成员',
prop: 'crop',
disabled: false,
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '巡查类型',
prop: 'inputName',
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '巡查对象',
prop: 'inputBrand',
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '注意事项',
prop: 'inputBrand',
type: 'textarea',
rows: 1,
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
],
searchColumn: [],
actions: [
{
name: '登记结果',
icon: 'edit',
event: ({ row }) => doEnroll(row),
},
],
},
pageData: {
total: 0,
currentPage: 1,
pageSize: 10,
},
data: [],
currentRow: {},
});
const list = ref([]);
const infoVisible = ref(false);
const infoRef = ref();
const infoData = reactive({
@ -124,48 +210,115 @@ const infoData = reactive({
mark: '',
target: '',
});
const infoRules = reactive({
num: [{ required: true, message: '请输入编号', trigger: 'blur' }],
num: [{ required: true, message: '请选择是否违法', trigger: 'blur' }],
mark: [{ required: true, message: '请输入巡查情况', trigger: 'blur' }],
});
const memberOptions = reactive([
{
value: '成员1',
label: 'Option1',
},
{
value: '成员2',
label: 'Option2',
},
]);
const typeOptions = reactive([
{
value: '巡查类型1',
label: 'Option1',
},
{
value: '巡查类型2',
label: 'Option2',
},
]);
//
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;
// });
};
const objOptions = reactive([
{
value: '巡查对象1',
label: 'Option1',
},
{
value: '巡查对象2',
label: 'Option2',
},
]);
loadData();
// #endregion
//
const currentChange = (current) => {
state.query.current = current;
loadData();
};
/* --------------- methods --------------- */
//
const sizeChange = (size) => {
state.query.size = size;
loadData();
};
const doResults = () => {
console.info('登记结果');
//
const searchChange = (params, done) => {
if (done) done();
state.query = params;
state.query.current = 1;
loadData();
};
//
const refreshChange = () => {
loadData();
app.$message.success('刷新成功');
};
//
const selectionChange = (rows) => {
state.selection = rows;
};
//
const rowSave = (row, done, loading) => {
// console.info('', row);
saveOperationRecord(row)
.then((res) => {
if (res.code === 200) {
app.$message.success('添加成功!');
done();
loadData();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {
loading();
});
};
//
const doEnroll = (row) => {
console.info('doEnroll', row);
infoVisible.value = true;
};
//
const onExport = () => {
if (isEmpty(state.data)) {
app.$message.error('当前暂时没有可供导出的数据!');
return;
}
state.loading = true;
const fileName = '土地巡查明细表';
exportOperationRecord(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;
});
};
const subMitInfo = (formEl) => {
@ -188,13 +341,4 @@ const infoHide = () => {
infoRef.value && infoRef.value.resetFields();
infoVisible.value = false;
};
// #region
// #endregion
</script>
<style lang="scss" scoped>
.options_btns {
margin: 16px 0;
}
</style>

View File

@ -19,6 +19,7 @@
@row-del="rowDel"
>
<template #menu-left>
<el-button type="primary" icon="Upload" @click="onImport">导入</el-button>
<el-button type="success" icon="download" @click="onExport">导出</el-button>
</template>
@ -26,6 +27,29 @@
<custom-table-operate :actions="state.options.actions" :data="scope" />
</template>
</avue-crud>
<el-dialog v-model="importVisible" title="导入文件" width="800" center>
<!-- <el-form ref="stageInfoRef" :model="stageInfoData" :rules="stageInfoRules"> -->
<el-row :gutter="20">
<el-col :span="12">
<!-- <el-form-item label="文件:" prop="landName"> -->
<el-upload ref="upload" class="upload-demo" action="" :limit="1" :auto-upload="false" :on-change="fileChange" :file-list="fileList">
<el-button type="primary">点击上传</el-button>
<template #tip>
<div class="el-upload__tip">只能上传 xls/xlsx/csv 文件且不超过 500kb</div>
</template>
</el-upload>
<!-- </el-form-item> -->
</el-col>
</el-row>
<!-- </el-form> -->
<template #footer>
<div class="dialog-footer">
<el-button @click="importCancel">取消</el-button>
<el-button type="primary" @click="subMitImport"> 确认 </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup>
@ -35,22 +59,44 @@ 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 {
getOperationRecord,
saveOperationRecord,
editOperationRecord,
delOperationRecord,
exportOperationRecord,
getAddrCropByLand,
importOperationRecord,
} from '@/apis/land';
const { VITE_APP_BASE_API } = import.meta.env;
const app = useApp();
const UserStore = useUserStore();
const crudRef = ref(null);
const handleLandChange = async (value, form, done) => {
if (!value) return; //
state.form.address = value.item?.address || '';
if (!value || !value.item || !value.item.id) return; //
let val = {};
getAddrCropByLand(value.item?.id || '')
.then((res) => {
if (res.code === 200) {
val = res.data || {};
}
})
.catch((err) => {
val = {};
})
.finally(() => {});
state.form.crop = val?.crop || value.item?.crop;
state.form.address = val?.county + val?.town + val?.village || value.item?.address;
};
const JobTypeChange = async (value, form, done) => {
if (!value) return;
state.form.productName = value.item?.productName || '';
};
const jobTypeOptions = reactive([
{ label: '施肥', value: '0' },
{ label: '杀虫', value: '1' },
{ label: '灌溉', value: '2' },
]);
const importVisible = ref(false);
const state = reactive({
loading: false,
query: {
@ -65,7 +111,7 @@ const state = reactive({
column: [
{
label: '作业日期',
prop: 'buyTime',
prop: 'operationDate',
type: 'date',
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
@ -78,17 +124,10 @@ const state = reactive({
},
{
label: '执行人',
prop: 'user',
type: 'select',
search: true,
dicData: [
{ label: '小A', value: 0 },
{ label: '小B', value: 1 },
{ label: '小C', value: 2 },
],
prop: 'executor',
rules: {
required: true,
message: '请选择',
message: '请输入',
trigger: 'blur',
},
},
@ -96,7 +135,7 @@ const state = reactive({
label: '地块',
prop: 'landId',
type: 'select',
remote: true,
remote: false,
props: {
label: 'landName',
value: 'id',
@ -104,7 +143,7 @@ const state = reactive({
dicHeaders: {
authorization: UserStore.token,
},
dicUrl: `${VITE_APP_BASE_API}/land-resource/landManage/page?current=1&size=10&draftsSaveType=0&landType=1&landName=&gridName=&owner=`,
dicUrl: `${VITE_APP_BASE_API}/land-resource/landManage/page?current=1&size=9999&draftsSaveType=0&landName=&gridName=&owner=`,
dicFormatter: (res) => res.data.records ?? [],
rules: [
{
@ -118,6 +157,8 @@ const state = reactive({
{
label: '位置',
prop: 'address',
width: '240px',
showOverflowTooltip: true,
fixed: true,
disabled: true,
rules: {
@ -128,7 +169,8 @@ const state = reactive({
},
{
label: '产物',
prop: 'gridManager',
prop: 'crop',
disabled: false,
rules: {
required: true,
message: '请输入',
@ -137,24 +179,19 @@ const state = reactive({
},
{
label: '作业类型',
prop: 'jobType',
prop: 'operationType',
type: 'select',
search: true,
dicData: [
{ label: '育苗', value: 0, productName: '旱地水稻' },
{ label: '灌溉', value: 1, productName: '化肥水' },
{ label: '施肥', value: 2, productName: '氮肥' },
],
dicData: jobTypeOptions,
rules: {
required: true,
message: '请选择',
trigger: 'blur',
},
change: JobTypeChange,
},
{
label: '投入品名',
prop: 'productName',
prop: 'inputName',
rules: {
required: true,
message: '请输入',
@ -163,7 +200,7 @@ const state = reactive({
},
{
label: '投入品牌',
prop: 'contactInfo',
prop: 'inputBrand',
rules: {
required: true,
message: '请输入',
@ -171,6 +208,20 @@ const state = reactive({
},
},
],
searchColumn: [
{ label: '地块名', prop: 'landName', search: true },
{ label: '种植产物', prop: 'crop', search: true },
{
label: '作业类型',
prop: 'operationType',
type: 'select',
search: true,
dicData: jobTypeOptions,
},
{ label: '投入品名', prop: 'inputName', search: true },
{ label: '投入品牌名', prop: 'inputBrand', search: true },
{ label: '执行人', prop: 'executor', search: true },
],
actions: [
{
name: '编辑',
@ -194,28 +245,32 @@ const state = reactive({
currentRow: {},
});
//
const fileList = ref([]);
const upload = ref(null);
//
const loadData = () => {
// state.loading = true;
// GetEntityList(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;
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;
});
};
loadData();
@ -251,57 +306,46 @@ const selectionChange = (rows) => {
state.selection = rows;
};
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 rowSave = (row, done, loading) => {
console.info('新增');
// AddEntity(row)
// .then((res) => {
// if (res.code === 200) {
// app.$message.success('');
// done();
// loadData();
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// })
// .finally(() => {
// loading();
// });
// console.info('', row);
saveOperationRecord(row)
.then((res) => {
if (res.code === 200) {
app.$message.success('添加成功!');
done();
loadData();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {
loading();
});
};
//
const rowEdit = (row) => {
console.info('编辑');
// row.cities = compact([row.provinceCode, row.cityCode, row.gridAreaCode ?? '', row.townCode ?? '', row.village ?? '']);
console.info('编辑', 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();
// });
editOperationRecord(row)
.then((res) => {
if (res.code === 200) {
app.$message.success('更新成功!');
done();
loadData();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {
loading();
});
};
//
@ -314,18 +358,18 @@ const rowDel = (row, index, done) => {
type: 'warning',
})
.then(() => {
console.info('删除');
// DeleteEntity({ id: row.id })
// .then((res) => {
// if (res.code === 200) {
// app.$message.success('');
// done();
// loadData();
// }
// })
// .catch((err) => {
// app.$message.error(err.msg);
// });
console.info('删除', row.recordId);
delOperationRecord(row.recordId || '')
.then((res) => {
if (res.code === 200) {
app.$message.success('删除成功!');
loadData();
done();
}
})
.catch((err) => {
app.$message.error(err.msg);
});
})
.catch(() => {});
};
@ -338,18 +382,60 @@ const onExport = () => {
}
state.loading = true;
const fileName = '作业记录明细表';
// ExportEntity(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;
// });
exportOperationRecord(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;
});
};
const onImport = () => {
importVisible.value = true;
};
const fileChange = (file, List) => {
console.info('文件选择变化:', file, List);
fileList.value = List;
};
const subMitImport = () => {
if (!upload.value || !fileList.value.length) {
app.$message.error('请选择要上传的文件');
return;
}
const formData = new FormData();
formData.append('file', fileList.value[0].raw);
// console.info('fileList:', fileList.value[0].raw);
importOperationRecord(formData)
.then((res) => {
if (res.code === 200) {
app.$message.success('上传成功!');
importHide();
loadData();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {});
};
const importCancel = () => {
importHide();
};
const importHide = () => {
upload.value && upload.value.clearFiles();
fileList.value = [];
importVisible.value = false;
};
</script>

View File

@ -831,6 +831,8 @@ const onStateAdd = () => {
app.$message.error('请选择种植规划');
return;
}
console.info('onStateAdd', state.currentRow);
stageInfoData.landName = state.currentRow.landName || '';
stageInfoData.crop = state.currentRow.crop || '';
stageInfoVisible.value = true;