support tablet

This commit is contained in:
Timi
2026-11-02 23:12:05 +08:00
parent c48b19bed5
commit d3879c9c77
123 changed files with 4153 additions and 2673 deletions
+103 -77
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar package-config-list">
<div class="tui-page-layout tui-navbar package-config-list">
<t-navbar
fixed
:z-index="20"
@@ -18,92 +18,111 @@
/>
</template>
</t-navbar>
<main v-can="permissionCodes.packageConfig.read" class="page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="loadMore"
>
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="keyword"
borderless
clearable
placeholder="搜索套餐名称或说明"
/>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-cell-group
v-if="configList.length"
class="list fix-last-cell-line empty-cell-title-margin"
theme="card"
<master-detail-page
v-can="permissionCodes.packageConfig.read"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
>
<template #master>
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="loadMore"
>
<t-cell
class="item"
v-for="item in configList"
:key="item.id"
v-entrance-transition="{ step: 30 }"
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="keyword"
borderless
clearable
placeholder="搜索套餐名称或说明"
/>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-cell-group
v-if="configList.length"
class="list fix-last-cell-line empty-cell-title-margin"
theme="card"
>
<template #title>
<div class="title">
<strong v-text="item.name || '未命名套餐'" />
<t-tag :content="getPackageConfigStatusText(item.status)" variant="light-outline" :theme="getStatusTheme(item.status)" />
</div>
</template>
<template #description>
<div class="description">
<div class="products">
<t-tag
v-for="productItem in item.itemList || []"
:key="productItem.id || `${productItem.skuId}-${productItem.skuUnitId}`"
:content="getProductRightText(productItem)"
theme="primary"
variant="light"
/>
<t-tag v-if="!item.itemList?.length" content="暂无产品权益" />
<t-cell
class="item"
v-for="item in configList"
:key="item.id"
v-entrance-transition="{ step: 30 }"
>
<template #title>
<div class="title">
<strong v-text="item.name || '未命名套餐'" />
<t-tag :content="getPackageConfigStatusText(item.status)" variant="light-outline" :theme="getStatusTheme(item.status)" />
</div>
<div class="price-actions">
<div class="price">
<span class="red">¥</span>
<span class="value red" v-text="formatPackageAmount(item.standardAmount)" />
</div>
<div v-if="item.id" class="actions" @click.stop>
<t-button
class="detail"
</template>
<template #description>
<div class="description">
<div class="products">
<t-tag
v-for="productItem in item.itemList || []"
:key="productItem.id || `${productItem.skuId}-${productItem.skuUnitId}`"
:content="getProductRightText(productItem)"
theme="primary"
size="extra-small"
content="详情"
@click.stop="toDetail(item)"
variant="light"
/>
<t-tag v-if="!item.itemList?.length" content="暂无产品权益" />
</div>
<div class="price-actions">
<div class="price">
<span class="red">¥</span>
<span class="value red" v-text="formatPackageAmount(item.standardAmount)" />
</div>
<div v-if="item.id" class="actions" @click.stop>
<t-button
class="detail"
theme="primary"
size="extra-small"
content="详情"
@click.stop="toDetail(item)"
/>
</div>
</div>
</div>
</div>
</template>
</t-cell>
</t-cell-group>
<center-tips v-else :content="loading ? '正在加载套餐配置' : '暂无套餐配置'" />
<center-tips :content="loadStateText" />
</t-pull-down-refresh>
</main>
</template>
</t-cell>
</t-cell-group>
<center-tips v-else :content="loading ? '正在加载套餐配置' : '暂无套餐配置'" />
<center-tips :content="loadStateText" />
</t-pull-down-refresh>
</template>
<template #detail>
<package-config-edit v-if="editing" :key="`edit-${selectedId}`" :config-id="selectedId" />
<package-config-detail
v-else
:key="`detail-${selectedId}-${detailVersion}`"
:config-id="selectedId"
@edit="openEdit"
/>
</template>
</master-detail-page>
</div>
</template>
<script setup lang="ts">
import { type DropdownValue } from "tdesign-mobile-vue";
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import { Toolkit } from "timi-web";
import { useUserStore } from "timi-web-api";
import PackageAPI from "@/api/PackageAPI";
import PackageConfigDetail from "@/pages/package/PackageConfigDetail.vue";
import PackageConfigEdit from "@/pages/package/PackageConfigEdit.vue";
import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@/types/Package";
import { formatPackageAmount, getPackageConfigStatusText, getPackageQuantityText } from "@/utils/package";
import { Message } from "@/utils/message";
@@ -116,6 +135,15 @@ defineOptions({ name: "PackageConfigList" });
const router = useRouter();
const userStore = useUserStore();
// 选中项、编辑态、切换方向、关闭逻辑、转屏、query 同步都在这里
const { selectedId, editing, detailVersion, paneDirection, isWide, openDetail, openEdit } =
useMasterDetailPane({
path: "/management/package-configs",
detail: id => `/management/package-configs/${id}`,
edit: id => `/management/package-configs/${id}/edit`
});
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.packageConfig.create));
const keyword = ref("");
@@ -191,10 +219,8 @@ async function toCreate(): Promise<void> {
await router.push("/management/package-configs/create");
}
async function toDetail(item: GaoPackageConfig): Promise<void> {
if (item.id) {
await router.push(`/management/package-configs/${item.id}`);
}
function toDetail(item: GaoPackageConfig): void {
openDetail(item.id || "");
}
function getStatusTheme(statusValue?: PackageConfigStatus): "success" | "warning" | "default" {
@@ -223,7 +249,7 @@ onUnmounted(() => {
<style scoped lang="less">
.package-config-list {
padding: var(--app-nav-height) 0 1rem;
padding: var(--tui-nav-height) 0 1rem;
.list {