Files
medical-mall/pages/mall/admin/marketing/seckill/config.uvue

453 lines
10 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="marketing-seckill-config">
<view class="filter-card border-shadow">
<view class="filter-row">
<view class="filter-item">
<text class="label">是否显示:</text>
<view class="select-mock">
<text class="select-val">请选择</text>
<text class="arrow">▼</text>
</view>
</view>
</view>
</view>
<view class="action-bar">
<button class="btn-add" @click="showDrawer = true">添加数据</button>
</view>
<view class="table-card border-shadow">
<view class="table-container">
<view class="table-head">
<view class="th cell-id">编号</view>
<view class="th cell-hour">开启时间(整点)</view>
<view class="th cell-duration">持续时间(整数小时)</view>
<view class="th cell-img">幻灯片</view>
<view class="th cell-sort">排序</view>
<view class="th cell-status">状态</view>
<view class="th cell-op">操作</view>
</view>
<view class="table-body">
<view v-for="item in configList" :key="item.id" class="table-row">
<view class="td cell-id">
<text class="td-txt">{{ item.id }}</text>
</view>
<view class="td cell-hour">
<text class="td-txt">{{ item.start_hour }}</text>
</view>
<view class="td cell-duration">
<text class="td-txt">{{ item.duration }}</text>
</view>
<view class="td cell-img">
<image v-if="item.image" class="thumb" :src="item.image" mode="aspectFill"></image>
<text v-else class="td-txt">-</text>
</view>
<view class="td cell-sort">
<text class="td-txt">{{ item.sort }}</text>
</view>
<view class="td cell-status">
<StatusSwitch v-model="item.status" />
</view>
<view class="td cell-op">
<view class="op-links">
<text class="op-link" @click="handleEdit(item)">编辑</text>
<text class="op-split">|</text>
<text class="op-link" @click="handleDelete(item)">删除</text>
</view>
</view>
</view>
</view>
</view>
<view class="pagination-footer">
<view class="page-total">
<text class="total-txt">共 {{ configList.length }} 条</text>
</view>
<view class="page-select">
<view class="select-mock mini">
<text class="select-val">20条/页</text>
<text class="arrow">▼</text>
</view>
</view>
</view>
</view>
<!-- Drawer Overlay -->
<view v-if="showDrawer || isAnimating" class="drawer-mask" :class="{ active: showDrawer }" @click="closeDrawer"></view>
<!-- Drawer Panel -->
<view class="drawer-panel" :class="{ active: showDrawer }">
<view class="drawer-header">
<text class="drawer-title">添加数据</text>
<text class="drawer-close" @click="closeDrawer">×</text>
</view>
<view class="drawer-content">
<view class="form-item">
<text class="form-label required">开启时间(整点)</text>
<input class="form-input" placeholder="请输入开启时间(整点)" />
</view>
<view class="form-item">
<text class="form-label required">持续时间(整数小时)</text>
<input class="form-input" placeholder="请输入持续时间(整数小时)" />
</view>
<view class="form-item">
<text class="form-label">幻灯片:</text>
<view class="upload-mock" @click="handleUpload">
<image v-if="formData.image" :src="formData.image" mode="aspectFill" class="thumb" />
<text v-else class="upload-ic">🖼️</text>
</view>
</view>
<view class="form-item">
<text class="form-label">排序:</text>
<input class="form-input" type="number" v-model="formData.sort" placeholder="1" />
</view>
<view class="form-item">
<text class="form-label">状态:</text>
<StatusSwitch v-model="formData.status" activeText="显示" inactiveText="隐藏" />
</view>
</view>
<view class="drawer-footer">
<button class="btn-cancel" @click="closeDrawer">取消</button>
<button class="btn-confirm" @click="handleSubmit">确定</button>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { ref } from 'vue'
import StatusSwitch from '@/components/StatusSwitch.uvue'
const showDrawer = ref(false)
const isAnimating = ref(false)
const formData = ref({
id: 0,
start_hour: 0,
duration: 1,
image: '',
sort: 1,
status: true
})
const configList = ref([
{
id: 2268,
start_hour: 6,
duration: 18,
image: '',
sort: 1,
status: true
}
])
const handleEdit = (item: any) => {
formData.value = { ...item }
showDrawer.value = true
}
const handleDelete = (item: any) => {
uni.showModal({
title: '提示',
content: '确定要删除此项配置吗?',
success: (res) => {
if (res.confirm) {
configList.value = configList.value.filter(i => i.id !== item.id)
uni.showToast({ title: '删除成功' })
}
}
})
}
const handleUpload = () => {
uni.chooseImage({
count: 1,
success: (res) => {
formData.value.image = res.tempFilePaths[0]
}
})
}
const handleSubmit = () => {
uni.showToast({ title: '提交成功', icon: 'success' })
closeDrawer()
}
const closeDrawer = () => {
showDrawer.value = false
isAnimating.value = true
setTimeout(() => {
isAnimating.value = false
}, 300)
}
</script>
<style scoped lang="scss">
.marketing-seckill-config {
min-height: auto;
background: transparent;
padding: 0;
position: relative;
overflow: hidden;
}
.border-shadow {
background: #fff;
border-radius: 4px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
}
/* 过滤栏 */
.filter-card {
padding: 24px;
margin-bottom: 16px;
}
.filter-row {
display: flex;
flex-direction: row;
align-items: center;
}
.filter-item {
display: flex;
flex-direction: row;
align-items: center;
}
.label {
font-size: 14px;
color: #606266;
white-space: nowrap;
}
.select-mock {
width: 200px;
height: 32px;
border: 1px solid #dcdfe6;
border-radius: 4px;
display: flex;
flex-direction: row;
align-items: center;
padding: 0 12px;
justify-content: space-between;
}
.select-mock.mini { width: 100px; height: 28px; }
.select-val { font-size: 13px; color: #606266; }
.arrow { font-size: 10px; color: #c0c4cc; }
/* 操作栏 */
.action-bar {
margin-bottom: 16px;
}
.btn-add {
width: auto;
padding: 0 16px;
height: 32px;
background-color: #1890ff;
color: #fff;
font-size: 14px;
border: none;
border-radius: 4px;
display: inline-flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
/* 表格区域 */
.table-card {
padding: 24px;
}
.table-head {
display: flex;
flex-direction: row;
background-color: #f8f8f9;
border-bottom: 1px solid #e8eaec;
}
.th {
padding: 12px 8px;
font-size: 13px;
color: #515a6e;
font-weight: bold;
}
.table-row {
display: flex;
flex-direction: row;
border-bottom: 1px solid #e8eaec;
align-items: center;
}
.td {
padding: 16px 8px;
}
.td-txt { font-size: 13px; color: #515a6e; }
/* 各列宽度 */
.cell-id { width: 80px; }
.cell-hour { width: 150px; text-align: center; }
.cell-duration { width: 150px; text-align: center; }
.cell-img { flex: 1; min-width: 150px; }
.cell-sort { width: 100px; text-align: center; }
.cell-status { width: 100px; text-align: center; }
.cell-op { width: 120px; text-align: right; }
.thumb {
width: 40px;
height: 40px;
border-radius: 4px;
}
.op-links {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
}
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
.op-split { color: #e8eaec; margin: 0 8px; }
/* 分页 */
.pagination-footer {
margin-top: 24px;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
gap: 12px;
}
.total-txt { font-size: 13px; color: #606266; }
/* Drawer Styles */
.drawer-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.45);
z-index: 1000;
opacity: 0;
transition: opacity 0.3s;
pointer-events: none;
}
.drawer-mask.active {
opacity: 1;
pointer-events: auto;
}
.drawer-panel {
position: fixed;
top: 0;
right: -50%;
width: 50%;
height: 100%;
background-color: #fff;
z-index: 1001;
box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
display: flex;
flex-direction: column;
transition: right 0.3s ease-out;
}
.drawer-panel.active {
right: 0;
}
.drawer-header {
padding: 16px 24px;
border-bottom: 1px solid #f0f0f0;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.drawer-title {
font-size: 16px;
font-weight: 600;
color: #262626;
}
.drawer-close {
font-size: 24px;
color: #bfbfbf;
cursor: pointer;
}
.drawer-content {
flex: 1;
padding: 24px;
overflow-y: auto;
}
.form-item {
margin-bottom: 24px;
}
.form-label {
display: block;
font-size: 14px;
color: #262626;
margin-bottom: 8px;
}
.required::before {
content: '*';
color: #ff4d4f;
margin-right: 4px;
}
.form-input {
width: 100%;
height: 32px;
border: 1px solid #d9d9d9;
border-radius: 4px;
padding: 0 12px;
font-size: 14px;
}
.upload-mock {
width: 80px;
height: 80px;
border: 1px dashed #d9d9d9;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
background-color: #fafafa;
cursor: pointer;
}
.upload-ic { font-size: 24px; color: #bfbfbf; }
.drawer-footer {
padding: 10px 16px;
border-top: 1px solid #f0f0f0;
display: flex;
flex-direction: row;
justify-content: flex-end;
gap: 8px;
}
.btn-cancel, .btn-confirm {
width: auto;
padding: 0 15px;
height: 32px;
font-size: 14px;
border-radius: 4px;
cursor: pointer;
}
.btn-cancel {
background-color: #fff;
border: 1px solid #d9d9d9;
color: #595959;
}
.btn-confirm {
background-color: #1890ff;
border: 1px solid #1890ff;
color: #fff;
}
</style>