200 lines
4.8 KiB
Plaintext
200 lines
4.8 KiB
Plaintext
<template>
|
||
<view class="admin-page">
|
||
<view class="admin-sections">
|
||
<!-- 操作栏 -->
|
||
<view class="action-bar header-actions">
|
||
<view class="left-btns">
|
||
<button class="btn primary" @click="addProvince">添加省份</button>
|
||
<button class="btn ghost ml-12" @click="clearCache">清除缓存</button>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 表格内容 -->
|
||
<view class="admin-card content-card">
|
||
<view class="table-container list-table tree-table">
|
||
<view class="table-header">
|
||
<view class="col col-id"><text>编号</text></view>
|
||
<view class="col col-name"><text>地区名称</text></view>
|
||
<view class="col col-parent"><text>上级名称</text></view>
|
||
<view class="col col-action"><text>操作</text></view>
|
||
</view>
|
||
|
||
<view class="table-body">
|
||
<view v-for="item in dataList" :key="item.id" class="table-row">
|
||
<view class="col col-id"><text>{{ item.id }}</text></view>
|
||
<view class="col col-name">
|
||
<text class="expand-icon">˃</text>
|
||
<text>{{ item.name }}</text>
|
||
</view>
|
||
<view class="col col-parent"><text>{{ item.parentName }}</text></view>
|
||
<view class="col col-action">
|
||
<text class="action-btn" @click="addItem(item)">添加</text>
|
||
<text class="action-btn divider">|</text>
|
||
<text class="action-btn" @click="editItem(item)">编辑</text>
|
||
<text class="action-btn divider">|</text>
|
||
<text class="action-btn danger" @click="deleteItem(item)">删除</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup lang="uts">
|
||
import { ref } from 'vue'
|
||
|
||
const dataList = ref([
|
||
{ id: 1, name: '北京市', parentName: '中国' },
|
||
{ id: 2, name: '天津市', parentName: '中国' },
|
||
{ id: 3, name: '河北省', parentName: '中国' },
|
||
{ id: 4, name: '山西省', parentName: '中国' },
|
||
{ id: 5, name: '内蒙古自治区', parentName: '中国' },
|
||
{ id: 6, name: '辽宁省', parentName: '中国' },
|
||
{ id: 7, name: '吉林省', parentName: '中国' },
|
||
{ id: 8, name: '黑龙江省', parentName: '中国' },
|
||
{ id: 9, name: '上海市', parentName: '中国' },
|
||
{ id: 10, name: '江苏省', parentName: '中国' },
|
||
{ id: 11, name: '浙江省', parentName: '中国' },
|
||
{ id: 12, name: '安徽省', parentName: '中国' },
|
||
{ id: 13, name: '福建省', parentName: '中国' },
|
||
{ id: 14, name: '江西省', parentName: '中国' }
|
||
])
|
||
|
||
function addProvince() {
|
||
uni.showToast({ title: '添加省份', icon: 'none' })
|
||
}
|
||
|
||
function clearCache() {
|
||
uni.showLoading({ title: '清理中...' })
|
||
setTimeout(() => {
|
||
uni.hideLoading()
|
||
uni.showToast({ title: '清理成功' })
|
||
}, 1000)
|
||
}
|
||
|
||
function addItem(item: any) {
|
||
uni.showToast({ title: '添加下级: ' + item.name, icon: 'none' })
|
||
}
|
||
|
||
function editItem(item: any) {
|
||
uni.showToast({ title: '编辑: ' + item.name, icon: 'none' })
|
||
}
|
||
|
||
function deleteItem(item: any) {
|
||
uni.showModal({
|
||
title: '提示',
|
||
content: '确定要删除该区域吗?',
|
||
success: (res) => {
|
||
if (res.confirm) {
|
||
uni.showToast({ title: '删除成功' })
|
||
}
|
||
}
|
||
})
|
||
}
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
.admin-page {
|
||
/* 使用 Layout 的背景和内边距 */
|
||
min-height: 100vh;
|
||
}
|
||
|
||
.header-actions {
|
||
margin-bottom: 20px;
|
||
}
|
||
|
||
.left-btns {
|
||
display: flex;
|
||
flex-direction: row;
|
||
}
|
||
|
||
.ml-12 {
|
||
margin-left: 12px;
|
||
}
|
||
|
||
.admin-card {
|
||
background-color: #fff;
|
||
border-radius: 4px;
|
||
padding: 0; /* 表格一般不带卡片内边距 */
|
||
margin-bottom: 20px;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.btn {
|
||
height: 32px;
|
||
padding: 0 15px;
|
||
border-radius: 4px;
|
||
font-size: 14px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.btn.primary {
|
||
background-color: #1890ff;
|
||
color: #fff;
|
||
border: none;
|
||
}
|
||
|
||
.btn.ghost {
|
||
background-color: #fff;
|
||
border: 1px solid #d9d9d9;
|
||
color: #666;
|
||
}
|
||
|
||
.table-container {
|
||
width: 100%;
|
||
}
|
||
|
||
.table-header {
|
||
display: flex;
|
||
flex-direction: row;
|
||
background-color: #fafafa;
|
||
border-bottom: 1px solid #f0f0f0;
|
||
}
|
||
|
||
.table-row {
|
||
display: flex;
|
||
flex-direction: row;
|
||
border-bottom: 1px solid #f0f0f0;
|
||
}
|
||
|
||
.col {
|
||
padding: 12px 16px;
|
||
display: flex;
|
||
align-items: center;
|
||
font-size: 14px;
|
||
color: #333;
|
||
}
|
||
|
||
.col-id { width: 100px; }
|
||
.col-name { flex: 2; }
|
||
.col-parent { flex: 1; }
|
||
.col-action { width: 200px; justify-content: flex-end; }
|
||
|
||
.expand-icon {
|
||
margin-right: 8px;
|
||
color: #999;
|
||
font-size: 12px;
|
||
}
|
||
|
||
.action-btn {
|
||
font-size: 14px;
|
||
color: #1890ff;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.action-btn.danger {
|
||
color: #ff4d4f;
|
||
}
|
||
|
||
.action-btn.divider {
|
||
margin: 0 8px;
|
||
color: #e8e8e8;
|
||
cursor: default;
|
||
}
|
||
</style>
|