278 lines
6.9 KiB
Vue
Raw Normal View History

2025-03-03 16:50:51 +08:00
<template>
<CustomCard>
2025-03-04 16:24:17 +08:00
<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.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>
2025-03-03 16:50:51 +08:00
</CustomCard>
</template>
2025-03-04 16:24:17 +08:00
<script setup>
import { ref, reactive, onMounted } from 'vue';
2025-03-03 16:50:51 +08:00
import { useApp } from '@/hooks';
import { CRUD_OPTIONS } from '@/config';
2025-03-04 16:24:17 +08:00
import CustomCard from '@/components/CustomCard.vue';
2025-03-03 16:50:51 +08:00
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' },
],
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([
{
2025-03-04 16:24:17 +08:00
label: '农用地',
id: '0',
2025-03-03 16:50:51 +08:00
children: [
2025-03-04 16:24:17 +08:00
{ label: '耕地', id: '01', children: [], pId: '0' },
{ label: '园地', children: [], id: '02', pId: '0' },
2025-03-03 16:50:51 +08:00
],
},
{
2025-03-04 16:24:17 +08:00
label: '建设用地',
id: '1',
children: [{ label: '城乡建设用地', children: [], id: '11', pId: '10' }],
},
{
label: '住宅用地',
id: '2',
children: [],
2025-03-03 16:50:51 +08:00
},
]);
2025-03-04 16:24:17 +08:00
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' }],
});
2025-03-03 16:50:51 +08:00
// #endregion
/* --------------- methods --------------- */
2025-03-04 16:24:17 +08:00
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;
};
2025-03-03 16:50:51 +08:00
const handleNodeClick = (data) => {
2025-03-04 16:24:17 +08:00
infoData.classifyId = data.pId ? data.pId : data.id;
console.log(infoData);
2025-03-03 16:50:51 +08:00
};
// 编辑
const rowStatus = (row) => {
console.info('操作状态');
};
const rowDel = (row) => {};
const getStatusButtonText = (status) => {
switch (status) {
case 'active':
return '启用';
case 'inactive':
return '禁用';
}
};
const rowEdit = () => {};
2025-03-04 16:24:17 +08:00
const onAdd = () => {
infoVisible.value = true;
};
2025-03-03 16:50:51 +08:00
const onExport = () => {};
2025-03-04 16:24:17 +08:00
const subMitInfo = (formEl) => {};
const infoCancel = () => {
infoHide();
};
const infoHide = () => {
infoRef.value && infoRef.value.resetFields();
infoVisible.value = false;
};
2025-03-03 16:50:51 +08:00
// #region
// #endregion
</script>
<style lang="scss" scoped></style>