Files
medical-mall/pages/mall/admin/maintain/lang/list.uvue
2026-02-24 10:35:34 +08:00

226 lines
5.3 KiB
Plaintext

<template>
<view class="admin-page">
<view class="admin-sections">
<!-- 操作栏 -->
<view class="action-bar header-actions">
<button class="btn primary" @click="addLanguage">添加语言</button>
</view>
<!-- 表格内容 -->
<view class="admin-card content-card">
<view class="table-container list-table">
<view class="table-header">
<view class="col col-id"><text>ID</text></view>
<view class="col col-name"><text>语言名称</text></view>
<view class="col col-code"><text>浏览器语言识别码</text></view>
<view class="col col-status"><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>{{ item.name }}</text>
<text v-if="item.isDefault" class="default-badge">默认</text>
</view>
<view class="col col-code"><text>{{ item.code }}</text></view>
<view class="col col-status">
<view :class="['status-tag', item.status ? 'active' : 'inactive']" @click="toggleStatus(item)">
<text class="tag-text">{{ item.status ? '开启' : '关闭' }}</text>
<view class="tag-dot"></view>
</view>
</view>
<view class="col col-action">
<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 class="pagination">
<text class="page-info">共 10 条 15条/页</text>
</view>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { ref } from 'vue'
const dataList = ref([
{ id: 1, name: '中文', code: 'zh-CN', status: true, isDefault: true },
{ id: 2, name: 'English', code: 'en-US', status: true, isDefault: false },
{ id: 3, name: '繁體中文', code: 'zh-Hant', status: true, isDefault: false },
{ id: 4, name: 'Français', code: 'fr-FR', status: true, isDefault: false },
{ id: 5, name: 'Italiano', code: 'it-IT', status: true, isDefault: false },
{ id: 6, name: '日本語', code: 'ja-JP', status: true, isDefault: false },
{ id: 7, name: '한국어', code: 'ko-KR', status: true, isDefault: false },
{ id: 8, name: 'Монгол', code: 'mn-MN', status: true, isDefault: false },
{ id: 9, name: 'ภาษาไทย', code: 'th-TH', status: true, isDefault: false },
{ id: 10, name: 'ViệtName', code: 'vi-VN', status: true, isDefault: false }
])
function addLanguage() {
uni.showToast({ title: '添加语言', icon: 'none' })
}
function toggleStatus(item: any) {
item.status = !item.status
}
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;
}
.action-bar {
margin-bottom: 20px;
}
.admin-card {
background-color: #fff;
border-radius: 4px;
padding: 0;
overflow: hidden;
}
.btn {
height: 32px;
padding: 0 16px;
border-radius: 4px;
font-size: 14px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
border: none;
}
.btn.primary {
background-color: #1890ff;
color: #fff;
}
.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: 16px;
display: flex;
align-items: center;
font-size: 14px;
color: #333;
}
.col-id { width: 80px; }
.col-name { flex: 1; position: relative; }
.col-code { flex: 1; }
.col-status { width: 120px; justify-content: center; }
.col-action { width: 150px; justify-content: flex-end; }
.default-badge {
background-color: #e6f7ff;
color: #1890ff;
font-size: 12px;
padding: 2px 8px;
border-radius: 4px;
margin-left: 8px;
border: 1px solid #91d5ff;
}
.status-tag {
width: 60px;
height: 24px;
border-radius: 12px;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 0 8px;
cursor: pointer;
}
.status-tag.active {
background-color: #1890ff;
color: #fff;
}
.status-tag.inactive {
background-color: #d9d9d9;
color: #fff;
}
.tag-text {
font-size: 12px;
}
.tag-dot {
width: 8px;
height: 8px;
background-color: #fff;
border-radius: 50%;
}
.action-btn {
color: #1890ff;
cursor: pointer;
}
.action-btn.danger {
color: #ff4d4f;
}
.action-btn.divider {
margin: 0 8px;
color: #e8e8e8;
}
.pagination {
padding: 16px 24px;
display: flex;
justify-content: flex-end;
}
.page-info {
font-size: 14px;
color: #999;
}
</style>