| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <template>
- <cwg-popup :title="title" v-model:visible="props.visible" :showFooters="false"
- @update:visible="$emit('update:visible', $event)">
- <view class="account-detail-content">
- <!-- 账户编号独立显示(如果需要,也可以作为 fieldList 中的一项) -->
- <view v-if="accountNumber" class="account-number-row">
- <text class="label">{{ accountLabel }}</text>
- <text class="value">{{ accountNumber }}</text>
- <text class="value">{{ form.fwq }}</text>
- </view>
- <!-- 动态字段列表 -->
- <view v-for="(field, index) in fieldList" :key="index" class="field-row">
- <cwg-label-line-value :label="field.label" :value="getFieldValue(field.key)">
- <template #operation v-if="field.copyable">
- <view class="copy-btn" @click="copyValue(getFieldValue(field.key))">
- <cwg-icon name="copy" :size="20" color="#999" />
- </view>
- </template>
- </cwg-label-line-value>
- </view>
- </view>
- </cwg-popup>
- </template>
- <script setup>
- import { computed } from 'vue'
- const props = defineProps({
- // 是否显示弹窗
- visible: {
- type: Boolean,
- default: false
- },
- // 弹窗标题
- title: {
- type: String,
- default: '账户详情'
- },
- // 账户编号(若单独展示)
- accountNumber: {
- type: String,
- default: ''
- },
- // 账户编号标签
- accountLabel: {
- type: String,
- default: '账户:'
- },
- // 表单数据对象
- form: {
- type: Object,
- default: () => ({})
- },
- // 字段配置列表,每项包含:
- // - label: 字段显示名称
- // - key: 在 form 中对应的键名
- // - copyable: 是否显示复制按钮,默认 false
- fieldList: {
- type: Array,
- default: () => []
- }
- })
- const emit = defineEmits(['update:visible'])
- // 获取字段值
- const getFieldValue = (key) => {
- return props.form?.[key] ?? ''
- }
- // 复制文本到剪贴板
- const copyValue = (text) => {
- if (!text) {
- uni.showToast({ title: '无内容可复制', icon: 'none' })
- return
- }
- uni.setClipboardData({
- data: String(text),
- success: () => {
- uni.showToast({ title: '复制成功', icon: 'none' })
- },
- fail: () => {
- uni.showToast({ title: '复制失败', icon: 'none' })
- }
- })
- }
- </script>
- <style scoped lang="scss">
- @import "@/uni.scss";
- @media (min-width: 768px) {
- :deep(.cwg-dialog) {
- background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
- border-radius: px2rpx(8);
- width: px2rpx(500) !important;
- }
- }
- .account-number-row,
- .field-row {
- display: flex;
- align-items: center;
- padding: px2rpx(10) 0;
- width: 100%;
- font-size: px2rpx(14);
- &:last-child {
- border-bottom: none;
- }
- .label {
- min-width: px2rpx(30);
- color: var(--bs-heading-color);
- font-weight: normal;
- flex-shrink: 0;
- }
- .value-wrapper {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: space-between;
- }
- .value {
- color: var(--bs-heading-color);
- flex: 1;
- }
- .copy-btn {
- width: px2rpx(20);
- height: px2rpx(20);
- display: flex;
- align-items: center;
- justify-content: center;
- margin-left: px2rpx(12);
- cursor: pointer;
- color: var(--bs-heading-color);
- transition: color 0.2s;
- &:active {
- color: #007aff;
- }
- svg {
- width: px2rpx(20);
- height: px2rpx(20);
- }
- }
- }
- // 可复制行样式(仅用于视觉区分)
- .copyable-row {
- .value-wrapper {
- .value {
- // 可复制字段的值留出右侧空间
- margin-right: px2rpx(8);
- }
- }
- }
- </style>
|