fix store business day
This commit is contained in:
@@ -7,11 +7,8 @@
|
||||
<t-form-item label="名称">
|
||||
<t-input v-model.trim="formModel.name" placeholder="门店名称" borderless />
|
||||
</t-form-item>
|
||||
<t-form-item label="状态">
|
||||
<button class="picker-btn" type="button" @click="openStatusPicker">
|
||||
<span v-text="getStoreStatusText(formModel.status)" />
|
||||
<t-icon name="chevron-right" />
|
||||
</button>
|
||||
<t-form-item label="启用" content-align="right">
|
||||
<t-switch v-model="formModel.status" :custom-value="['ACTIVE', 'INACTIVE']" />
|
||||
</t-form-item>
|
||||
<t-form-item label="电话">
|
||||
<t-input v-model.trim="formModel.telephone" type="tel" placeholder="联系电话" borderless />
|
||||
@@ -19,29 +16,29 @@
|
||||
<t-form-item label="地址">
|
||||
<t-input v-model.trim="formModel.address" placeholder="门店地址" borderless />
|
||||
</t-form-item>
|
||||
<t-form-item label="排序">
|
||||
<t-input v-model.trim="formModel.sortText" type="number" placeholder="排序值" borderless />
|
||||
</t-form-item>
|
||||
<t-form-item label="备注">
|
||||
<t-textarea v-model.trim="formModel.remark" class="textarea" placeholder="备注" autosize borderless />
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
<div v-if="!isCreateMode" class="links">
|
||||
<t-cell-group v-if="!isCreateMode" theme="card">
|
||||
<t-cell title="营业日管理" note="配置营业或休息日期" arrow hover @click="router.push(`/management/stores/${routeId}/business-days`)" />
|
||||
</div>
|
||||
</t-cell-group>
|
||||
<div class="actions">
|
||||
<t-button v-if="!isCreateMode" v-can="permissionCodes.store.delete" theme="danger" :loading="isRemoving" @click="confirmRemoveStore">删除</t-button>
|
||||
<t-button theme="primary" :loading="isSaving" @click="saveStore">保存</t-button>
|
||||
<t-button
|
||||
v-if="!isCreateMode"
|
||||
v-can="permissionCodes.store.delete"
|
||||
class="action"
|
||||
theme="danger"
|
||||
:loading="isRemoving"
|
||||
@click="confirmRemoveStore"
|
||||
>删除</t-button>
|
||||
<t-button
|
||||
class="action"
|
||||
theme="primary"
|
||||
:loading="isSaving"
|
||||
@click="saveStore"
|
||||
>保存</t-button>
|
||||
</div>
|
||||
<t-popup v-model="statusPickerVisible" placement="bottom">
|
||||
<t-picker
|
||||
v-model="statusPickerDraft"
|
||||
:columns="statusPickerColumns"
|
||||
title="门店状态"
|
||||
@cancel="statusPickerVisible = false"
|
||||
@confirm="confirmStatusPicker"
|
||||
/>
|
||||
</t-popup>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -50,9 +47,6 @@ import { DialogPlugin, Toast } from "tdesign-mobile-vue";
|
||||
import StoreAPI from "@/api/StoreAPI";
|
||||
import type { Store, StoreStatus } from "@/types/Store";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { getStoreStatusText } from "@/utils/store";
|
||||
|
||||
type PickerValue = string | number;
|
||||
|
||||
defineOptions({
|
||||
name: "StoreEdit"
|
||||
@@ -78,31 +72,9 @@ const formModel = reactive({
|
||||
status: "ACTIVE" as StoreStatus,
|
||||
telephone: "",
|
||||
address: "",
|
||||
remark: "",
|
||||
sortText: "0"
|
||||
remark: ""
|
||||
});
|
||||
|
||||
// ---------- 状态选择 ----------
|
||||
|
||||
const statusPickerVisible = ref(false);
|
||||
const statusPickerDraft = ref<PickerValue[]>(["ACTIVE"]);
|
||||
const statusPickerColumns = [
|
||||
[
|
||||
{ label: "启用", value: "ACTIVE" },
|
||||
{ label: "停用", value: "INACTIVE" }
|
||||
]
|
||||
];
|
||||
|
||||
function openStatusPicker(): void {
|
||||
statusPickerDraft.value = [formModel.status];
|
||||
statusPickerVisible.value = true;
|
||||
}
|
||||
|
||||
function confirmStatusPicker(): void {
|
||||
const nextStatus = String(statusPickerDraft.value[0] || "ACTIVE") as StoreStatus;
|
||||
formModel.status = nextStatus;
|
||||
statusPickerVisible.value = false;
|
||||
}
|
||||
const sortValue = ref(0);
|
||||
|
||||
// ---------- 页面数据 ----------
|
||||
|
||||
@@ -119,9 +91,9 @@ async function fillForm(): Promise<void> {
|
||||
status: current.status || "ACTIVE",
|
||||
telephone: current.telephone || "",
|
||||
address: current.address || "",
|
||||
remark: current.remark || "",
|
||||
sortText: String(current.sort ?? 0)
|
||||
remark: current.remark || ""
|
||||
});
|
||||
sortValue.value = current.sort ?? 0;
|
||||
}
|
||||
|
||||
// ---------- 保存 ----------
|
||||
@@ -141,14 +113,15 @@ async function saveStore(): Promise<void> {
|
||||
telephone: formModel.telephone || undefined,
|
||||
address: formModel.address || undefined,
|
||||
remark: formModel.remark || undefined,
|
||||
sort: Number(formModel.sortText || 0)
|
||||
sort: sortValue.value
|
||||
};
|
||||
const savedId = isCreateMode.value ? await StoreAPI.create(store) : formModel.id;
|
||||
if (!isCreateMode.value) {
|
||||
if (isCreateMode.value) {
|
||||
await StoreAPI.create(store);
|
||||
} else {
|
||||
await StoreAPI.update(store);
|
||||
}
|
||||
Toast.success("门店已保存");
|
||||
await router.replace(`/management/stores/${savedId}`);
|
||||
await router.replace("/management/stores");
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
@@ -163,10 +136,6 @@ function validateForm(): boolean {
|
||||
Toast.warning("请填写门店名称");
|
||||
return false;
|
||||
}
|
||||
if (Number.isNaN(Number(formModel.sortText || 0))) {
|
||||
Toast.warning("排序值必须是数字");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -216,7 +185,10 @@ onMounted(async () => {
|
||||
|
||||
<style scoped lang="less">
|
||||
.store-edit {
|
||||
gap: 1rem;
|
||||
padding: calc(var(--app-nav-height) + 1rem) 0 6rem 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.form {
|
||||
border-radius: .75rem;
|
||||
@@ -226,19 +198,6 @@ onMounted(async () => {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.picker-btn {
|
||||
gap: .5rem;
|
||||
width: 100%;
|
||||
border: 0;
|
||||
display: flex;
|
||||
padding: 0;
|
||||
color: inherit;
|
||||
background: transparent;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.links {
|
||||
margin: 1rem 0;
|
||||
}
|
||||
@@ -248,10 +207,12 @@ onMounted(async () => {
|
||||
left: 1rem;
|
||||
right: 1rem;
|
||||
bottom: calc(.75rem + env(safe-area-inset-bottom, 0));
|
||||
display: grid;
|
||||
display: flex;
|
||||
position: fixed;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
|
||||
.action {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user