feat: 增加地区显示
This commit is contained in:
@@ -93,6 +93,15 @@ export default {
|
||||
title: "系统设置"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: "/biz/areas",
|
||||
name: "areas",
|
||||
component: () => import("@/views/biz/areas/index.vue"),
|
||||
meta: {
|
||||
icon: "ph:map-pin-area-bold",
|
||||
title: "地区"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: "/biz/subscribe",
|
||||
name: "subscribe",
|
||||
|
||||
291
src/views/biz/areas/index.vue
Normal file
291
src/views/biz/areas/index.vue
Normal file
@@ -0,0 +1,291 @@
|
||||
<script setup lang="ts">
|
||||
import dayjs from "dayjs";
|
||||
import { ref, onMounted } from "vue";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { request, bizApi } from "@/api/utils";
|
||||
|
||||
defineOptions({
|
||||
name: "areas"
|
||||
});
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
height?: string;
|
||||
}>(),
|
||||
{
|
||||
height: undefined
|
||||
}
|
||||
);
|
||||
|
||||
// 定义查询参数
|
||||
const queryParams = ref({
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
code: "",
|
||||
name: "",
|
||||
level: "",
|
||||
parentCode: ""
|
||||
});
|
||||
|
||||
// 定义表格数据
|
||||
const tableData = ref([]);
|
||||
const loading = ref(false);
|
||||
const total = ref(0);
|
||||
|
||||
// 等级选项
|
||||
const levelOptions = [
|
||||
{ value: 1, label: "省级" },
|
||||
{ value: 2, label: "市级" },
|
||||
{ value: 3, label: "区县级" },
|
||||
{ value: 4, label: "街道/乡镇" }
|
||||
];
|
||||
|
||||
// 获取地区列表
|
||||
const getAreaList = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params = { ...queryParams.value };
|
||||
const data = await request(bizApi("areaPage"), {
|
||||
method: "POST",
|
||||
body: JSON.stringify(params)
|
||||
});
|
||||
|
||||
if (data.status === 200) {
|
||||
tableData.value = data.data.rows;
|
||||
total.value = data.data.records;
|
||||
} else {
|
||||
ElMessage.error(data.msg || "获取数据失败");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("获取地区列表失败:", error);
|
||||
ElMessage.error(error.message || "获取数据失败");
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 搜索方法
|
||||
const handleSearch = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getAreaList();
|
||||
};
|
||||
|
||||
// 重置方法
|
||||
const handleReset = () => {
|
||||
queryParams.value = {
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
code: "",
|
||||
name: "",
|
||||
level: "",
|
||||
parentCode: ""
|
||||
};
|
||||
getAreaList();
|
||||
};
|
||||
|
||||
// 分页改变
|
||||
const handleSizeChange = (val: number) => {
|
||||
queryParams.value.pageSize = val;
|
||||
getAreaList();
|
||||
};
|
||||
|
||||
const handleCurrentChange = (val: number) => {
|
||||
queryParams.value.pageNum = val;
|
||||
getAreaList();
|
||||
};
|
||||
|
||||
const columns = [
|
||||
{
|
||||
label: "编码",
|
||||
prop: "code",
|
||||
width: "120",
|
||||
align: "center"
|
||||
},
|
||||
{
|
||||
label: "名称",
|
||||
prop: "name",
|
||||
width: "150"
|
||||
},
|
||||
{
|
||||
label: "等级",
|
||||
prop: "level",
|
||||
width: "100",
|
||||
align: "center",
|
||||
formatter: row => {
|
||||
const level = levelOptions.find(item => item.value === row.level);
|
||||
return level ? level.label : "-";
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "上级编码",
|
||||
prop: "parentCode",
|
||||
width: "120",
|
||||
align: "center"
|
||||
},
|
||||
{
|
||||
label: "地区完整地址",
|
||||
prop: "detail",
|
||||
minWidth: "300"
|
||||
},
|
||||
{
|
||||
label: "操作",
|
||||
fixed: "right",
|
||||
width: 160,
|
||||
slot: "operation",
|
||||
align: "center"
|
||||
}
|
||||
];
|
||||
|
||||
// 添加删除方法
|
||||
const handleDelete = async (row: any) => {
|
||||
try {
|
||||
await ElMessageBox.confirm("确认要删除该地区记录吗?", "提示", {
|
||||
type: "warning"
|
||||
});
|
||||
|
||||
const res = await request(bizApi("deleteArea"), {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ id: row.id })
|
||||
});
|
||||
|
||||
if (res.status === 200) {
|
||||
ElMessage.success("删除成功");
|
||||
getAreaList();
|
||||
} else {
|
||||
ElMessage.error(res.msg || "删除失败");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("删除失败:", error);
|
||||
}
|
||||
};
|
||||
|
||||
// 添加编辑方法
|
||||
const handleEdit = (row: any) => {
|
||||
// TODO: 实现编辑功能
|
||||
console.log("编辑行:", row);
|
||||
};
|
||||
|
||||
// 页面加载时获取数据
|
||||
onMounted(() => {
|
||||
getAreaList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="areas-container">
|
||||
<div class="search-box">
|
||||
<el-form ref="queryForm" :model="queryParams" :inline="true">
|
||||
<el-form-item label="编码(前匹配)" prop="code">
|
||||
<el-input
|
||||
v-model="queryParams.code"
|
||||
placeholder="请输入编码"
|
||||
clearable
|
||||
class="input-width"
|
||||
@keyup.enter="handleSearch"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
placeholder="请输入名称"
|
||||
clearable
|
||||
class="input-width"
|
||||
@keyup.enter="handleSearch"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="等级" prop="level">
|
||||
<el-select
|
||||
v-model="queryParams.level"
|
||||
placeholder="请选择等级"
|
||||
clearable
|
||||
class="type-select"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in levelOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="上级编码" prop="parentCode">
|
||||
<el-input
|
||||
v-model="queryParams.parentCode"
|
||||
placeholder="请输入上级编码"
|
||||
clearable
|
||||
class="input-width"
|
||||
@keyup.enter="handleSearch"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleSearch">搜索</el-button>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<pure-table
|
||||
v-loading="loading"
|
||||
:data="tableData"
|
||||
:columns="columns"
|
||||
:height="height"
|
||||
row-key="id"
|
||||
>
|
||||
<template #operation="{ row }">
|
||||
<el-button type="primary" link @click="handleEdit(row)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button type="danger" link @click="handleDelete(row)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</pure-table>
|
||||
|
||||
<div class="pagination-container">
|
||||
<el-pagination
|
||||
v-model:current-page="queryParams.pageNum"
|
||||
v-model:page-size="queryParams.pageSize"
|
||||
:page-sizes="[10, 20, 30, 50]"
|
||||
:total="total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.areas-container {
|
||||
padding: 20px;
|
||||
|
||||
.search-box {
|
||||
padding: 20px;
|
||||
margin-bottom: 20px;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.input-width {
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
.type-select {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 20px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -158,13 +158,25 @@ const columns: TableColumnList = [
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "中标者",
|
||||
label: "中标",
|
||||
prop: "isWinner",
|
||||
width: "90",
|
||||
align: "center",
|
||||
formatter: row => {
|
||||
return row.isWinner === 1 ? "是" : "否";
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "供货周期",
|
||||
prop: "supplyCycle",
|
||||
width: "90",
|
||||
align: "center"
|
||||
},
|
||||
{
|
||||
label: "供货地",
|
||||
prop: "productSourcing",
|
||||
width: "90"
|
||||
},
|
||||
{
|
||||
label: "投标时间",
|
||||
prop: "createTime",
|
||||
@@ -301,7 +313,7 @@ onMounted(() => {
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="中标者" prop="isWinner">
|
||||
<el-form-item label="中标" prop="isWinner">
|
||||
<el-select
|
||||
v-model="queryParams.isWinner"
|
||||
placeholder="请选择"
|
||||
|
||||
Reference in New Issue
Block a user