447 lines
9.0 KiB
Plaintext
447 lines
9.0 KiB
Plaintext
<template>
|
|
<view class="admin-main">
|
|
<!-- 澶撮儴鎼滅储 -->
|
|
<view class="search-card">
|
|
<view class="search-row">
|
|
<view class="search-item">
|
|
<text class="search-label">瑙勬牸鎼滅储:</text>
|
|
<input class="search-input" placeholder="璇疯緭鍏ヨ鏍煎悕绉? />
|
|
</view>
|
|
<button class="btn-query">鏌ヨ</button>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 鏁版嵁琛ㄦ牸鍖哄煙 -->
|
|
<view class="table-card">
|
|
<view class="table-toolbar">
|
|
<button class="btn-add" @click="showModal = true">娣诲姞鍟嗗搧瑙勬牸</button>
|
|
<button class="btn-batch-del">鎵归噺鍒犻櫎</button>
|
|
</view>
|
|
|
|
<view class="table-header">
|
|
<view class="th-cell flex-1 row-center">
|
|
<view class="checkbox-mock"></view>
|
|
</view>
|
|
<text class="th-cell flex-1">ID</text>
|
|
<text class="th-cell flex-3">瑙勬牸鍚嶇О</text>
|
|
<text class="th-cell flex-4">鍟嗗搧瑙勬牸</text>
|
|
<text class="th-cell flex-4">鍟嗗搧灞炴€?/text>
|
|
<text class="th-cell flex-2 text-center">鎿嶄綔</text>
|
|
</view>
|
|
|
|
<view class="table-body">
|
|
<view v-if="list.length === 0" class="empty-box">
|
|
<text class="empty-text">鏆傛棤鏁版嵁</text>
|
|
</view>
|
|
<view v-for="(item, index) in list" :key="index" class="table-row">
|
|
<view class="td-cell flex-1 row-center">
|
|
<view class="checkbox-mock" :class="item.selected ? 'checked' : ''" @click="item.selected = !item.selected">
|
|
<text v-if="item.selected" class="check-mark">鉁?/text>
|
|
</view>
|
|
</view>
|
|
<text class="td-cell flex-1 color-9">{{ item.id }}</text>
|
|
<text class="td-cell flex-3">{{ item.name }}</text>
|
|
<text class="td-cell flex-4">{{ item.specs }}</text>
|
|
<text class="td-cell flex-4">{{ item.attrs }}</text>
|
|
<view class="td-cell flex-2 row-center">
|
|
<text class="btn-link">缂栬緫</text>
|
|
<view class="divider"></view>
|
|
<text class="btn-link delete" @click="deleteItem(index)">鍒犻櫎</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 娣诲姞瑙勬牸寮圭獥 -->
|
|
<view class="modal-mask" v-if="showModal" @click="showModal = false">
|
|
<view class="modal-content" @click.stop>
|
|
<view class="modal-header">
|
|
<text class="modal-title">娣诲姞鍟嗗搧瑙勬牸</text>
|
|
<text class="modal-close" @click="showModal = false">脳</text>
|
|
</view>
|
|
<view class="modal-body">
|
|
<view class="modal-form">
|
|
<view class="form-item">
|
|
<view class="form-label-box"><text class="form-label">瑙勬牸鍚嶇О:</text></view>
|
|
<view class="form-input-box">
|
|
<input class="modal-input" v-model="form.name" placeholder="璇疯緭鍏ヨ鏍煎悕绉? />
|
|
</view>
|
|
</view>
|
|
<view class="form-item">
|
|
<view class="form-label-box"><text class="form-label">鍟嗗搧瑙勬牸:</text></view>
|
|
<view class="form-input-box">
|
|
<input class="modal-input" v-model="form.specs" placeholder="璇疯緭鍏ュ晢鍝佽鏍? />
|
|
</view>
|
|
</view>
|
|
<view class="form-item">
|
|
<view class="form-label-box"><text class="form-label">鍟嗗搧灞炴€?</text></view>
|
|
<view class="form-input-box">
|
|
<input class="modal-input" v-model="form.attrs" placeholder="璇疯緭鍏ュ晢鍝佸睘鎬? />
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="modal-footer">
|
|
<button class="btn-modal-cancel" @click="showModal = false">鍙栨秷</button>
|
|
<button class="btn-modal-submit" @click="saveAttr">纭畾</button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup lang="uts">
|
|
import { ref, reactive } from 'vue'
|
|
|
|
interface AttrItem {
|
|
id: number;
|
|
name: string;
|
|
specs: string;
|
|
attrs: string;
|
|
selected: boolean;
|
|
}
|
|
|
|
const list = reactive<AttrItem[]>([
|
|
{ id: 104, name: '棰滆壊', specs: '绾㈣壊,钃濊壊,榛戣壊,鐧借壊', attrs: '棰滆壊灞炴€?, selected: false },
|
|
{ id: 105, name: '灏哄', specs: 'S,M,L,XL,XXL', attrs: '鏈嶈灏哄', selected: false },
|
|
{ id: 106, name: '鏉愯川', specs: '绾,娑ょ憾,鐪熶笣', attrs: '闈㈡枡鏉愯川', selected: false },
|
|
{ id: 107, name: '鍐呭瓨', specs: '8G,16G,32G', attrs: '纭欢鍙傛暟', selected: false },
|
|
{ id: 108, name: '瀛樺偍', specs: '128G,256G,512G', attrs: '瀹归噺', selected: false }
|
|
])
|
|
|
|
const showModal = ref(false)
|
|
const form = reactive({
|
|
name: '',
|
|
specs: '',
|
|
attrs: ''
|
|
})
|
|
|
|
function saveAttr() {
|
|
if (!form.name) {
|
|
uni.showToast({ title: '璇疯緭鍏ヨ鏍煎悕绉?, icon: 'none' })
|
|
return
|
|
}
|
|
list.push({
|
|
id: Math.floor(Math.random() * 1000),
|
|
name: form.name,
|
|
specs: form.specs,
|
|
attrs: form.attrs,
|
|
selected: false
|
|
})
|
|
showModal.value = false
|
|
form.name = ''
|
|
form.specs = ''
|
|
form.attrs = ''
|
|
uni.showToast({ title: '娣诲姞鎴愬姛', icon: 'success' })
|
|
}
|
|
|
|
function deleteItem(index: number) {
|
|
uni.showModal({
|
|
title: '鎻愮ず',
|
|
content: '纭畾鍒犻櫎璇ヨ鏍煎悧锛?,
|
|
success: (res) => {
|
|
if (res.confirm) {
|
|
list.splice(index, 1)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.admin-main {
|
|
padding: 20px;
|
|
background-color: #f0f2f5;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
/* 鎼滅储鍗$墖 */
|
|
.search-card {
|
|
background-color: #fff;
|
|
padding: 24px;
|
|
border-radius: 4px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.search-row {
|
|
display: flex;
|
|
flex-direction: row;
|
|
align-items: center;
|
|
}
|
|
|
|
.search-item {
|
|
display: flex;
|
|
flex-direction: row;
|
|
align-items: center;
|
|
margin-right: 20px;
|
|
}
|
|
|
|
.search-label {
|
|
font-size: 14px;
|
|
color: #333;
|
|
margin-right: 12px;
|
|
}
|
|
|
|
.search-input {
|
|
width: 250px;
|
|
height: 32px;
|
|
border: 1px solid #dcdfe6;
|
|
border-radius: 4px;
|
|
padding: 0 12px;
|
|
font-size: 13px;
|
|
}
|
|
|
|
.btn-query {
|
|
width: 64px;
|
|
height: 32px;
|
|
line-height: 32px;
|
|
background-color: #1890ff;
|
|
color: #fff;
|
|
font-size: 14px;
|
|
border-radius: 4px;
|
|
border: none;
|
|
margin-left: 0;
|
|
}
|
|
|
|
/* 琛ㄦ牸鍖哄煙 */
|
|
.table-card {
|
|
background-color: #fff;
|
|
padding: 24px;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.table-toolbar {
|
|
display: flex;
|
|
flex-direction: row;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.btn-add {
|
|
height: 32px;
|
|
line-height: 32px;
|
|
padding: 0 15px;
|
|
background-color: #1890ff;
|
|
color: #fff;
|
|
font-size: 14px;
|
|
border-radius: 4px;
|
|
margin-left: 0;
|
|
margin-right: 12px;
|
|
border: none;
|
|
}
|
|
|
|
.btn-batch-del {
|
|
height: 32px;
|
|
line-height: 32px;
|
|
padding: 0 15px;
|
|
background-color: #fff;
|
|
color: #606266;
|
|
border: 1px solid #dcdfe6;
|
|
font-size: 14px;
|
|
border-radius: 4px;
|
|
margin-left: 0;
|
|
}
|
|
|
|
.table-header {
|
|
display: flex;
|
|
flex-direction: row;
|
|
background-color: #f8f9fa;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
height: 48px;
|
|
align-items: center;
|
|
}
|
|
|
|
.th-cell {
|
|
padding: 0 16px;
|
|
font-size: 14px;
|
|
font-weight: bold;
|
|
color: #333;
|
|
}
|
|
|
|
.table-row {
|
|
display: flex;
|
|
flex-direction: row;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
min-height: 54px;
|
|
align-items: center;
|
|
}
|
|
|
|
.empty-box {
|
|
padding: 60px 0;
|
|
text-align: center;
|
|
}
|
|
|
|
.empty-text {
|
|
color: #999;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.td-cell {
|
|
padding: 0 16px;
|
|
}
|
|
|
|
.color-9 {
|
|
color: #999;
|
|
}
|
|
|
|
.checkbox-mock {
|
|
width: 16px;
|
|
height: 16px;
|
|
border: 1px solid #dcdfe6;
|
|
border-radius: 2px;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.checkbox-mock.checked {
|
|
background-color: #1890ff;
|
|
border-color: #1890ff;
|
|
}
|
|
|
|
.check-mark {
|
|
color: #fff;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.btn-link {
|
|
font-size: 14px;
|
|
color: #1890ff;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.btn-link.delete {
|
|
color: #ff4d4f;
|
|
}
|
|
|
|
.divider {
|
|
width: 1px;
|
|
height: 14px;
|
|
background-color: #f0f0f0;
|
|
margin: 0 12px;
|
|
}
|
|
|
|
.text-center {
|
|
text-align: center;
|
|
}
|
|
|
|
.row-center {
|
|
display: flex;
|
|
flex-direction: row;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
/* Modal styles */
|
|
.modal-mask {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background-color: rgba(0,0,0,0.5);
|
|
z-index: 1000;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
}
|
|
|
|
.modal-content {
|
|
width: 500px;
|
|
|
|
border-radius: 4px;
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
|
}
|
|
|
|
.modal-header {
|
|
padding: 16px 24px;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.modal-title {
|
|
font-size: 16px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.modal-close {
|
|
font-size: 24px;
|
|
color: #999;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.modal-body {
|
|
padding: 24px;
|
|
}
|
|
|
|
.form-item {
|
|
display: flex;
|
|
flex-direction: row;
|
|
margin-bottom: 20px;
|
|
align-items: center;
|
|
}
|
|
|
|
.form-label-box {
|
|
width: 80px;
|
|
text-align: right;
|
|
margin-right: 16px;
|
|
}
|
|
|
|
.form-label {
|
|
font-size: 14px;
|
|
color: #606266;
|
|
}
|
|
|
|
.form-input-box {
|
|
flex: 1;
|
|
}
|
|
|
|
.modal-input {
|
|
width: 100%;
|
|
height: 36px;
|
|
border: 1px solid #dcdfe6;
|
|
border-radius: 4px;
|
|
padding: 0 12px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.modal-footer {
|
|
padding: 12px 24px;
|
|
border-top: 1px solid #f0f0f0;
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: flex-end;
|
|
}
|
|
|
|
.btn-modal-cancel, .btn-modal-submit {
|
|
height: 32px;
|
|
line-height: 32px;
|
|
padding: 0 20px;
|
|
font-size: 14px;
|
|
border-radius: 4px;
|
|
margin-left: 12px;
|
|
}
|
|
|
|
.btn-modal-cancel {
|
|
background-color: #fff;
|
|
border: 1px solid #dcdfe6;
|
|
color: #606266;
|
|
}
|
|
|
|
.btn-modal-submit {
|
|
background-color: #1890ff;
|
|
color: #fff;
|
|
border: none;
|
|
}
|
|
|
|
.flex-1 { flex: 1; }
|
|
.flex-2 { flex: 2; }
|
|
.flex-3 { flex: 3; }
|
|
.flex-4 { flex: 4; }
|
|
</style>
|
|
|
|
|