Files
medical-mall/pages/mall/admin/kefu/words.uvue
2026-02-06 12:06:33 +08:00

628 lines
14 KiB
Plaintext

<template>
<view class="admin-kefu-words">
<view class="words-container">
<!-- 宸︿晶鍒嗙被 -->
<view class="category-sidebar border-shadow">
<view class="sidebar-header" @click="handleAddCategory">
<text class="plus-icon">+</text>
<text class="header-txt">娣诲姞鍒嗙被</text>
</view>
<scroll-view class="category-list" scroll-y="true">
<view
v-for="cat in categories"
:key="cat.id"
:class="['category-item', activeCategoryId == cat.id ? 'active' : '']"
@click="selectCategory(cat.id)"
>
<view class="folder-icon">馃搨</view>
<text class="cat-name">{{ cat.name }}</text>
</view>
</scroll-view>
</view>
<!-- 鍙充晶璇濇湳鍒楄〃 -->
<view class="content-main">
<view class="top-bar">
<view class="btn-primary" @click="handleAddWord">
<text class="btn-txt">娣诲姞璇濇湳</text>
</view>
</view>
<view class="table-card border-shadow">
<view class="table-header">
<view class="th col-id"><text class="th-txt">ID</text></view>
<view class="th col-cat"><text class="th-txt">鍒嗙被</text></view>
<view class="th col-title"><text class="th-txt">鏍囬</text></view>
<view class="th col-detail"><text class="th-txt">璇︽儏</text></view>
<view class="th col-sort"><text class="th-txt">鎺掑簭</text></view>
<view class="th col-time"><text class="th-txt">娣诲姞鏃堕棿</text></view>
<view class="th col-op"><text class="th-txt">鎿嶄綔</text></view>
</view>
<view class="table-body">
<view class="table-row" v-for="item in wordList" :key="item.id">
<view class="td col-id"><text class="td-txt">{{ item.id }}</text></view>
<view class="td col-cat"><text class="td-txt">{{ item.category }}</text></view>
<view class="td col-title"><text class="td-txt">{{ item.title }}</text></view>
<view class="td col-detail">
<text class="td-txt ellipsis-2">{{ item.content }}</text>
</view>
<view class="td col-sort"><text class="td-txt">{{ item.sort }}</text></view>
<view class="td col-time"><text class="td-txt">{{ item.time }}</text></view>
<view class="td col-op">
<text class="btn-action" @click="handleEdit(item)">缂栬緫</text>
<view class="divider"></view>
<text class="btn-action danger">鍒犻櫎</text>
</view>
</view>
</view>
<!-- 鍒嗛〉 -->
<view class="pagination-bar">
<text class="page-total">鍏?{{ wordList.length }} 鏉?/text>
<view class="page-size-select">
<text class="size-txt">15鏉?椤?/text>
<text class="arrow-down">鈻?/text>
</view>
<view class="page-nav">
<view class="nav-prev"><text class="nav-icon"> < </text></view>
<view class="nav-item active"><text class="nav-num">1</text></view>
<view class="nav-next"><text class="nav-icon"> > </text></view>
</view>
<view class="page-jump">
<text class="jump-txt">鍓嶅線</text>
<input class="jump-input" value="1" />
<text class="jump-txt">椤?/text>
</view>
</view>
</view>
</view>
</view>
<!-- 渚ц竟寮圭獥 (Drawer) -->
<view v-if="showDrawer" class="drawer-mask" @click="closeDrawer">
<view class="drawer-content" @click.stop>
<view class="drawer-header">
<text class="drawer-title">{{ isEdit ? '缂栬緫璇濇湳' : '娣诲姞璇濇湳' }}</text>
<text class="close-btn" @click="closeDrawer">脳</text>
</view>
<view class="drawer-body">
<view class="form-item">
<view class="label-box">
<text class="label-txt">璇濇湳鍒嗙被:</text>
</view>
<view class="input-box">
<view class="select-mock">
<text class="select-val">{{ formData.category || '璇烽€夋嫨鍒嗙被' }}</text>
<text class="arrow-down">鈻?/text>
</view>
</view>
</view>
<view class="form-item">
<view class="label-box">
<text class="required">*</text>
<text class="label-txt">璇濇湳鏍囬:</text>
</view>
<view class="input-box">
<input class="input-base" v-model="formData.title" placeholder="璇疯緭鍏ヨ瘽鏈爣棰? />
</view>
</view>
<view class="form-item align-start">
<view class="label-box">
<text class="required">*</text>
<text class="label-txt">璇濇湳鍐呭:</text>
</view>
<view class="input-box">
<textarea class="textarea-base" v-model="formData.content" placeholder="璇疯緭鍏ヨ瘽鏈唴瀹? />
</view>
</view>
<view class="form-item">
<view class="label-box">
<text class="label-txt">鎺掑簭:</text>
</view>
<view class="input-box">
<input class="input-base" type="number" v-model="formData.sort" />
</view>
</view>
</view>
<view class="drawer-footer">
<view class="btn-cancel" @click="closeDrawer">
<text class="cancel-txt">鍙栨秷</text>
</view>
<view class="btn-confirm" @click="submitForm">
<text class="confirm-txt">纭畾</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { ref, reactive } from 'vue'
interface WordItem {
id: string
category: string
title: string
content: string
sort: number
time: string
}
interface Category {
id: number
name: string
}
const categories = ref<Category[]>([
{ id: 1, name: '鍏ㄩ儴' },
{ id: 2, name: '绯荤粺璇濇湳' }
])
const activeCategoryId = ref(1)
const wordList = ref<WordItem[]>([
{
id: '67',
category: '绯荤粺榛樿',
title: '鏃楄埌鐗堜粙缁?,
content: '銆愭棗鑸扮増銆戝彲浠ユ巿鏉冪粰鍏徃鎴栬€呬釜浜猴紝浼佷笟鑷敤鎼缓锛屼笉闄愬埗鎺堟潈鍩熷悕锛屾彁渚涗笓灞炴妧鏈€荤洃銆佷骇鍝佹€荤洃绛夈€?,
sort: 0,
time: '2024-09-27 10:15:07'
}
])
// 琛ㄥ崟閫昏緫
const showDrawer = ref(false)
const isEdit = ref(false)
const formData = reactive({
id: '',
category: '绯荤粺璇濇湳',
title: '',
content: '',
sort: 0
})
const selectCategory = (id: number) => {
activeCategoryId.value = id
}
const handleAddCategory = () => {
console.log('娣诲姞鍒嗙被')
}
const handleAddWord = () => {
isEdit.value = false
formData.id = ''
formData.title = ''
formData.content = ''
formData.sort = 0
showDrawer.value = true
}
const handleEdit = (item: WordItem) => {
isEdit.value = true
formData.id = item.id
formData.category = item.category
formData.title = item.title
formData.content = item.content
formData.sort = item.sort
showDrawer.value = true
}
const closeDrawer = () => {
showDrawer.value = false
}
const submitForm = () => {
console.log('鎻愪氦琛ㄥ崟', formData)
showDrawer.value = false
}
</script>
<style scoped lang="scss">
.admin-kefu-words {
padding: 20px;
background-color: #f5f7fa;
min-height: 100vh;
}
.border-shadow {
background-color: #fff;
border-radius: 4px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
}
.words-container {
display: flex;
flex-direction: row;
height: calc(100vh - 40px);
gap: 20px;
}
/* 宸︿晶鍒嗙被 */
.category-sidebar {
width: 280px;
display: flex;
flex-direction: column;
}
.sidebar-header {
height: 50px;
display: flex;
flex-direction: row;
align-items: center;
padding: 0 20px;
border-bottom: 1px solid #f0f0f0;
cursor: pointer;
}
.plus-icon {
font-size: 18px;
color: #c0c4cc;
margin-right: 8px;
}
.header-txt {
font-size: 14px;
color: #606266;
}
.category-list {
flex: 1;
padding: 10px 0;
}
.category-item {
height: 44px;
display: flex;
flex-direction: row;
align-items: center;
padding: 0 20px;
cursor: pointer;
}
.category-item:hover {
background-color: #f5f7fa;
}
.category-item.active {
background-color: #e6f7ff;
border-right: 2px solid #2d8cf0;
}
.folder-icon {
margin-right: 10px;
font-size: 14px;
}
.cat-name {
font-size: 14px;
color: #333;
}
/* 鍙充晶鍐呭 */
.content-main {
flex: 1;
display: flex;
flex-direction: column;
}
.top-bar {
margin-bottom: 20px;
}
.btn-primary {
width: 90px;
height: 34px;
background-color: #2d8cf0;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
.btn-txt {
color: #fff;
font-size: 13px;
}
.table-card {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}
.table-header {
height: 50px;
background-color: #e6f0ff;
display: flex;
flex-direction: row;
align-items: center;
border-bottom: 1px solid #f0f0f0;
}
.th {
display: flex;
align-items: center;
justify-content: center;
padding: 0 10px;
}
.th-txt {
font-size: 13px;
color: #606266;
font-weight: 500;
}
.table-body {
flex: 1;
}
.table-row {
height: 70px;
display: flex;
flex-direction: row;
align-items: center;
border-bottom: 1px solid #f0f0f0;
}
.td {
display: flex;
align-items: center;
justify-content: center;
padding: 0 10px;
}
.td-txt {
font-size: 13px;
color: #606266;
}
.ellipsis-2 {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
text-align: left;
}
/* 鍒楀鍒嗛厤 */
.col-id { width: 60px; }
.col-cat { width: 100px; }
.col-title { width: 150px; }
.col-detail { flex: 1; justify-content: flex-start; }
.col-sort { width: 80px; }
.col-time { width: 180px; }
.col-op { width: 150px; }
.btn-action {
font-size: 13px;
color: #2d8cf0;
cursor: pointer;
}
.danger {
color: #ed4014;
}
.divider {
width: 1px;
height: 12px;
background-color: #e8eaec;
margin: 0 10px;
}
/* 鍒嗛〉 */
.pagination-bar {
padding: 15px 20px;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
border-top: 1px solid #f0f0f0;
}
.page-total { font-size: 13px; color: #606266; margin-right: 15px; }
.page-size-select {
border: 1px solid #dcdee2;
padding: 4px 10px;
border-radius: 4px;
display: flex;
flex-direction: row;
align-items: center;
margin-right: 15px;
}
.size-txt { font-size: 13px; color: #606266; margin-right: 8px; }
.nav-icon, .arrow-down { font-size: 10px; color: #808695; }
.page-nav { display: flex; flex-direction: row; align-items: center; margin-right: 15px; }
.nav-prev, .nav-next, .nav-item {
width: 30px;
height: 30px;
border: 1px solid #dcdee2;
display: flex;
align-items: center;
justify-content: center;
border-radius: 4px;
margin: 0 4px;
}
.nav-item.active {
background-color: #2d8cf0;
border-color: #2d8cf0;
}
.active .nav-num { color: #fff; }
.nav-num { font-size: 13px; color: #606266; }
.page-jump { display: flex; flex-direction: row; align-items: center; }
.jump-txt { font-size: 13px; color: #606266; }
.jump-input {
width: 40px;
height: 30px;
border: 1px solid #dcdee2;
border-radius: 4px;
text-align: center;
margin: 0 8px;
font-size: 13px;
}
/* 鎶藉眽 Drawer 1:1 澶嶅埢 - 淇浣嶇疆鍒板彸渚?*/
.drawer-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.4);
z-index: 1000;
}
.drawer-content {
position: absolute;
top: 0;
right: 0; /* 寮哄埗闈犲彸鍗犳嵁鍙宠竟灞忓箷 */
width: 50%; /* 鍗犲睆骞曚竴鍗婂搴?*/
height: 100%;
display: flex;
flex-direction: column;
box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
animation: slideIn 0.3s ease;
}
@keyframes slideIn {
from { transform: translateX(100%); }
to { transform: translateX(0); }
}
.drawer-header {
height: 55px;
padding: 0 20px;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #f0f0f0;
}
.drawer-title {
font-size: 16px;
font-weight: 600;
color: #333;
}
.close-btn {
font-size: 24px;
color: #999;
cursor: pointer;
}
.drawer-body {
flex: 1;
padding: 24px;
}
.form-item {
display: flex;
flex-direction: row;
align-items: center;
margin-bottom: 24px;
}
.align-start {
align-items: flex-start;
}
.label-box {
width: 100px;
display: flex;
flex-direction: row;
justify-content: flex-end;
margin-right: 15px;
}
.required {
color: #ed4014;
margin-right: 4px;
}
.label-txt {
font-size: 14px;
color: #606266;
}
.input-box {
flex: 1;
}
.select-mock {
height: 36px;
border: 1px solid #dcdee2;
border-radius: 4px;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 0 12px;
}
.select-val { font-size: 14px; color: #333; }
.input-base {
width: 100%;
height: 36px;
border: 1px solid #dcdee2;
border-radius: 4px;
padding: 0 12px;
font-size: 14px;
}
.textarea-base {
width: 100%;
height: 120px;
border: 1px solid #dcdee2;
border-radius: 4px;
padding: 10px 12px;
font-size: 14px;
}
.drawer-footer {
height: 60px;
border-top: 1px solid #f0f0f0;
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
padding: 0 24px;
}
.btn-cancel {
padding: 8px 18px;
border: 1px solid #dcdee2;
border-radius: 4px;
margin-right: 12px;
}
.btn-confirm {
padding: 8px 18px;
background-color: #2d8cf0;
border-radius: 4px;
}
.cancel-txt { font-size: 14px; color: #606266; }
.confirm-txt { font-size: 14px; color: #fff; }
</style>