support tablet
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="page-layout navbar store-list">
|
||||
<div class="tui-page-layout tui-navbar store-list">
|
||||
<t-navbar
|
||||
fixed
|
||||
:z-index="20"
|
||||
@@ -11,55 +11,70 @@
|
||||
<navbar-actions :actions="actionList" :visible="canCreateStore || canSortStore" />
|
||||
</template>
|
||||
</t-navbar>
|
||||
<main v-can="permissionCodes.store.read" class="page-content column scroll list">
|
||||
<t-pull-down-refresh
|
||||
class="pull-refresh"
|
||||
v-model="isRefreshing"
|
||||
:refresh-timeout="30000"
|
||||
@refresh="refresh"
|
||||
@scrolltolower="fetch"
|
||||
>
|
||||
<t-cell-group theme="card" class="fix-last-cell-line">
|
||||
<t-swipe-cell
|
||||
v-entrance-transition="{ step: 30 }"
|
||||
v-for="item in pageResult.list"
|
||||
:key="item.id"
|
||||
class="item"
|
||||
>
|
||||
<t-cell
|
||||
class="cell"
|
||||
arrow
|
||||
@click="toEdit(item)"
|
||||
<master-detail-page
|
||||
v-can="permissionCodes.store.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="refresh"
|
||||
@scrolltolower="fetch"
|
||||
>
|
||||
<t-cell-group theme="card" class="fix-last-cell-line">
|
||||
<t-swipe-cell
|
||||
v-entrance-transition="{ step: 30 }"
|
||||
v-for="item in pageResult.list"
|
||||
:key="item.id"
|
||||
class="item"
|
||||
>
|
||||
<template #title>
|
||||
<div class="header">
|
||||
<div class="title text-bold clip-text" v-text="item.name || '未命名门店'"></div>
|
||||
<t-tag size="small" :theme="getStoreStatusTheme(item.status)" variant="outline" :content="getStoreStatusText(item.status)" />
|
||||
</div>
|
||||
</template>
|
||||
<template #description>
|
||||
<div class="description">
|
||||
<span class="gray" v-text="item.telephone ? `电话:${item.telephone}` : '电话:-'" />
|
||||
<span class="gray" v-text="item.address ? `地址:${item.address}` : '地址:-'" />
|
||||
</div>
|
||||
</template>
|
||||
</t-cell>
|
||||
<template v-if="canDeleteStore" #right>
|
||||
<t-button
|
||||
class="delete"
|
||||
theme="danger"
|
||||
:loading="isRemoving && removingStoreId === item.id"
|
||||
@click.stop="openRemoveDialog(item)"
|
||||
<t-cell
|
||||
class="cell"
|
||||
arrow
|
||||
@click="toEdit(item)"
|
||||
>
|
||||
删除
|
||||
</t-button>
|
||||
</template>
|
||||
</t-swipe-cell>
|
||||
</t-cell-group>
|
||||
<center-tips v-if="!pageResult.list.length" :content="isLoading ? '正在加载门店' : '暂无门店'" />
|
||||
<center-tips v-if="pageResult.list.length" :content="isNoMore ? '已加载全部门店' : '上拉加载更多'" />
|
||||
</t-pull-down-refresh>
|
||||
</main>
|
||||
<template #title>
|
||||
<div class="header">
|
||||
<div class="title text-bold clip-text" v-text="item.name || '未命名门店'"></div>
|
||||
<t-tag size="small" :theme="getStoreStatusTheme(item.status)" variant="outline" :content="getStoreStatusText(item.status)" />
|
||||
</div>
|
||||
</template>
|
||||
<template #description>
|
||||
<div class="description">
|
||||
<span class="gray" v-text="item.telephone ? `电话:${item.telephone}` : '电话:-'" />
|
||||
<span class="gray" v-text="item.address ? `地址:${item.address}` : '地址:-'" />
|
||||
</div>
|
||||
</template>
|
||||
</t-cell>
|
||||
<template v-if="canDeleteStore" #right>
|
||||
<t-button
|
||||
class="delete"
|
||||
theme="danger"
|
||||
:loading="isRemoving && removingStoreId === item.id"
|
||||
@click.stop="openRemoveDialog(item)"
|
||||
>
|
||||
删除
|
||||
</t-button>
|
||||
</template>
|
||||
</t-swipe-cell>
|
||||
</t-cell-group>
|
||||
<center-tips v-if="!pageResult.list.length" :content="isLoading ? '正在加载门店' : '暂无门店'" />
|
||||
<center-tips v-if="pageResult.list.length" :content="isNoMore ? '已加载全部门店' : '上拉加载更多'" />
|
||||
</t-pull-down-refresh>
|
||||
</template>
|
||||
<template #detail>
|
||||
<!-- 门店没有独立详情页,点开直接进编辑 -->
|
||||
<store-edit
|
||||
:key="`store-${selectedId}`"
|
||||
:store-id="selectedId"
|
||||
/>
|
||||
</template>
|
||||
</master-detail-page>
|
||||
<store-remove-dialog
|
||||
v-model:visible="removeDialogVisible"
|
||||
:store="removeTarget"
|
||||
@@ -75,6 +90,8 @@ import type { NavbarAction } from "@/types/NavbarAction.ts";
|
||||
import { Message } from "@/utils/message";
|
||||
import { type Page, type PageResult, useUserStore } from "timi-web-api";
|
||||
import StoreAPI from "@/api/StoreAPI";
|
||||
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
|
||||
import StoreEdit from "@/pages/store/StoreEdit.vue";
|
||||
import StoreRemoveDialog from "@/components/StoreRemoveDialog.vue";
|
||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||
import { getStoreStatusText, getStoreStatusTheme } from "@/utils/store";
|
||||
@@ -87,6 +104,13 @@ defineOptions({
|
||||
|
||||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
|
||||
// 门店没有独立详情页,选中即进入编辑;detail 路由就是编辑路由
|
||||
const { selectedId, paneDirection, isWide, openDetail } = useMasterDetailPane({
|
||||
path: "/management/stores",
|
||||
detail: id => `/management/stores/${id}`
|
||||
});
|
||||
|
||||
const isStoreManagerScope = computed(() => userStore.hasRoles(gaoRoleCodes.storeManager) && !userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||
const canCreateStore = computed(() => userStore.hasPermissions(permissionCodes.store.create));
|
||||
const canSortStore = computed(() => userStore.hasPermissions(permissionCodes.store.update));
|
||||
@@ -168,10 +192,7 @@ async function fetch(): Promise<void> {
|
||||
// ---------- 操作 ----------
|
||||
|
||||
async function toEdit(item: Store): Promise<void> {
|
||||
if (!item.id) {
|
||||
return;
|
||||
}
|
||||
await router.push(`/management/stores/${item.id}`);
|
||||
openDetail(item.id || "");
|
||||
}
|
||||
|
||||
async function toCreate(): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user