更新体育中心总后台端
This commit is contained in:
106
src/api/booking/card/index.ts
Normal file
106
src/api/booking/card/index.ts
Normal file
@@ -0,0 +1,106 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { Card, CardParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询会员卡
|
||||
*/
|
||||
export async function pageCard(params: CardParam) {
|
||||
const res = await request.get<ApiResult<PageResult<Card>>>(
|
||||
MODULES_API_URL + '/booking/card/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询会员卡列表
|
||||
*/
|
||||
export async function listCard(params?: CardParam) {
|
||||
const res = await request.get<ApiResult<Card[]>>(
|
||||
MODULES_API_URL + '/booking/card',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加会员卡
|
||||
*/
|
||||
export async function addCard(data: Card) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/booking/card',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改会员卡
|
||||
*/
|
||||
export async function updateCard(data: Card) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/booking/card',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员卡
|
||||
*/
|
||||
export async function removeCard(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/booking/card/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除会员卡
|
||||
*/
|
||||
export async function removeBatchCard(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/booking/card/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询会员卡
|
||||
*/
|
||||
export async function getCard(id: number) {
|
||||
const res = await request.get<ApiResult<Card>>(
|
||||
MODULES_API_URL + '/booking/card/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
51
src/api/booking/card/model/index.ts
Normal file
51
src/api/booking/card/model/index.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 会员卡
|
||||
*/
|
||||
export interface Card {
|
||||
// ID
|
||||
cardId?: number;
|
||||
// 会员卡名称
|
||||
cardName?: string;
|
||||
// 会员卡标识
|
||||
cardCode?: string;
|
||||
// 会员卡图片
|
||||
image?: string;
|
||||
// 价格
|
||||
price?: number;
|
||||
// 次数
|
||||
number?: number;
|
||||
// 月份
|
||||
month?: number;
|
||||
// 折扣
|
||||
discount?: number;
|
||||
// 老师介绍
|
||||
content?: string;
|
||||
// 关联用户
|
||||
userId?: number;
|
||||
// 商户ID
|
||||
merchantId?: number;
|
||||
// 商户名称
|
||||
merchantName?: string;
|
||||
// 商户类型
|
||||
merchantType?: string;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 状态
|
||||
status?: number;
|
||||
// 排序号
|
||||
sortNumber?: number;
|
||||
// 租户id
|
||||
tenantId?: number;
|
||||
// 创建时间
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员卡搜索条件
|
||||
*/
|
||||
export interface CardParam extends PageParam {
|
||||
cardId?: number;
|
||||
keywords?: string;
|
||||
}
|
||||
106
src/api/booking/cardPlan/index.ts
Normal file
106
src/api/booking/cardPlan/index.ts
Normal file
@@ -0,0 +1,106 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { CardPlan, CardPlanParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询会员卡类型
|
||||
*/
|
||||
export async function pageCardPlan(params: CardPlanParam) {
|
||||
const res = await request.get<ApiResult<PageResult<CardPlan>>>(
|
||||
MODULES_API_URL + '/booking/card-plan/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询会员卡类型列表
|
||||
*/
|
||||
export async function listCardPlan(params?: CardPlanParam) {
|
||||
const res = await request.get<ApiResult<CardPlan[]>>(
|
||||
MODULES_API_URL + '/booking/card-plan',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加会员卡类型
|
||||
*/
|
||||
export async function addCardPlan(data: CardPlan) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/booking/card-plan',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改会员卡类型
|
||||
*/
|
||||
export async function updateCardPlan(data: CardPlan) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/booking/card-plan',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员卡类型
|
||||
*/
|
||||
export async function removeCardPlan(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/booking/card-plan/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除会员卡类型
|
||||
*/
|
||||
export async function removeBatchCardPlan(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/booking/card-plan/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询会员卡类型
|
||||
*/
|
||||
export async function getCardPlan(id: number) {
|
||||
const res = await request.get<ApiResult<CardPlan>>(
|
||||
MODULES_API_URL + '/booking/card-plan/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
33
src/api/booking/cardPlan/model/index.ts
Normal file
33
src/api/booking/cardPlan/model/index.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 会员卡类型
|
||||
*/
|
||||
export interface CardPlan {
|
||||
// ID
|
||||
cardPlanId?: number;
|
||||
// 会员卡名称
|
||||
name?: string;
|
||||
// 标识
|
||||
code?: string;
|
||||
// 备注
|
||||
comments?: string;
|
||||
// 状态
|
||||
status?: number;
|
||||
// 排序号
|
||||
sortNumber?: number;
|
||||
// 租户id
|
||||
tenantId?: number;
|
||||
// 创建时间
|
||||
createTime?: string;
|
||||
// 修改时间
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员卡类型搜索条件
|
||||
*/
|
||||
export interface CardPlanParam extends PageParam {
|
||||
cardPlanId?: number;
|
||||
keywords?: string;
|
||||
}
|
||||
139
src/components/SelectCardPlan/components/select-data.vue
Normal file
139
src/components/SelectCardPlan/components/select-data.vue
Normal file
@@ -0,0 +1,139 @@
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="750"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:title="title"
|
||||
:footer="null"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
>
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="pageId"
|
||||
:datasource="datasource"
|
||||
:columns="columns"
|
||||
:customRow="customRow"
|
||||
:pagination="false"
|
||||
>
|
||||
<template #toolbar>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
v-model:value="searchText"
|
||||
placeholder="请输入搜索关键词"
|
||||
style="width: 200px"
|
||||
@search="reload"
|
||||
@pressEnter="reload"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<template v-if="pageId == record.pageId">
|
||||
<a-radio v-model:checked="checked" @click="onRadio(record)" />
|
||||
</template>
|
||||
<template v-else>
|
||||
<lebal>
|
||||
<a-radio @click="onRadio(record)" />
|
||||
<span class="ele-text-secondary">选择</span>
|
||||
</lebal>
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import {
|
||||
ColumnItem,
|
||||
DatasourceFunction
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { pageCardPlan } from '@/api/booking/cardPlan';
|
||||
import { EleProTable } from 'ele-admin-pro';
|
||||
import { CardPlan, CardPlanParam } from '@/api/booking/cardPlan/model';
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 标题
|
||||
title?: string;
|
||||
// 修改回显的数据
|
||||
data?: CardPlan | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done', data: CardPlan): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 搜索内容
|
||||
const searchText = ref(null);
|
||||
const pageId = ref<number>(0);
|
||||
const checked = ref<boolean>(true);
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: '页面名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
align: 'center'
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
|
||||
where = {};
|
||||
// 搜索条件
|
||||
if (searchText.value) {
|
||||
where.name = searchText.value;
|
||||
}
|
||||
return pageCardPlan({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: CardPlanParam) => {
|
||||
tableRef?.value?.reload({ page: 1, where });
|
||||
};
|
||||
|
||||
const onRadio = (record: CardPlan) => {
|
||||
pageId.value = Number(record.pageId);
|
||||
updateVisible(false);
|
||||
emit('done', record);
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: CardPlan) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
// onClick: () => {
|
||||
// updateVisible(false);
|
||||
// emit('done', record);
|
||||
// },
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
updateVisible(false);
|
||||
emit('done', record);
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
<style lang="less"></style>
|
||||
59
src/components/SelectCardPlan/index.vue
Normal file
59
src/components/SelectCardPlan/index.vue
Normal file
@@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<div>
|
||||
<a-input-group compact>
|
||||
<a-input
|
||||
disabled
|
||||
style="width: calc(100% - 32px)"
|
||||
v-model:value="value"
|
||||
:placeholder="placeholder"
|
||||
/>
|
||||
<a-button @click="openEdit">
|
||||
<template #icon><BulbOutlined class="ele-text-warning" /></template>
|
||||
</a-button>
|
||||
</a-input-group>
|
||||
<!-- 选择弹窗 -->
|
||||
<SelectData
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
:title="placeholder"
|
||||
@done="onChange"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { BulbOutlined } from '@ant-design/icons-vue';
|
||||
import { ref } from 'vue';
|
||||
import SelectData from './components/select-data.vue';
|
||||
import { Design } from '@/api/cms/design/model';
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
value?: any;
|
||||
placeholder?: string;
|
||||
}>(),
|
||||
{
|
||||
placeholder: '请选择数据'
|
||||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done', Design): void;
|
||||
(e: 'clear'): void;
|
||||
}>();
|
||||
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 当前编辑数据
|
||||
const current = ref<Design | null>(null);
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: Design) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
const onChange = (row) => {
|
||||
emit('done', row);
|
||||
};
|
||||
</script>
|
||||
@@ -4,7 +4,7 @@
|
||||
:width="600"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:title="isUpdate ? '编辑商户账号' : '添加商户账号'"
|
||||
:title="isUpdate ? '编辑场馆账号' : '添加场馆账号'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
@@ -18,9 +18,9 @@
|
||||
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="选择商户" name="merchantId">
|
||||
<a-form-item label="选择场馆" name="merchantId">
|
||||
<SelectMerchant
|
||||
:placeholder="`选择商户`"
|
||||
:placeholder="`选择场馆`"
|
||||
class="input-item"
|
||||
v-model:value="form.merchantName"
|
||||
@done="chooseMerchantId"
|
||||
@@ -141,7 +141,7 @@
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写商户账号名称',
|
||||
message: '请填写场馆账号名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
@@ -149,7 +149,7 @@
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择商户',
|
||||
message: '请选择场馆',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
|
||||
292
src/views/booking/card/components/cardEdit.vue
Normal file
292
src/views/booking/card/components/cardEdit.vue
Normal file
@@ -0,0 +1,292 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="800"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑会员卡' : '添加会员卡'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="选择场馆" name="merchantName">
|
||||
<SelectMerchant
|
||||
:placeholder="`选择场馆`"
|
||||
class="input-item"
|
||||
v-model:value="form.merchantName"
|
||||
@done="chooseMerchantId"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="会员卡名称" name="cardName">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入会员卡名称"
|
||||
v-model:value="form.cardName"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="会员卡类型" name="cardCode">
|
||||
<DictSelect
|
||||
dict-code="cardPlanId"
|
||||
:placeholder="`会员卡类型`"
|
||||
style="width: 200px"
|
||||
v-model:value="form.cardCode"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="价格" name="price">
|
||||
<a-input-number
|
||||
allow-clear
|
||||
placeholder="请输入价格"
|
||||
style="width: 200px"
|
||||
v-model:value="form.price"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="次数" name="number" v-if="form.cardCode == '次卡'">
|
||||
<a-input-number
|
||||
allow-clear
|
||||
placeholder="请输入次数"
|
||||
style="width: 200px"
|
||||
v-model:value="form.number"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="月份" name="month" v-if="form.cardCode == '月/年卡'">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入月份"
|
||||
v-model:value="form.month"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="折扣"
|
||||
name="discount"
|
||||
v-if="form.cardCode == '充值卡'"
|
||||
>
|
||||
<a-input-number
|
||||
allow-clear
|
||||
placeholder="请输入折扣"
|
||||
style="width: 200px"
|
||||
max="10"
|
||||
min="0"
|
||||
v-model:value="form.discount"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="备注" name="comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入描述"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="状态" name="status">
|
||||
<a-radio-group v-model:value="form.status">
|
||||
<a-radio :value="0">显示</a-radio>
|
||||
<a-radio :value="1">隐藏</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item label="排序号" name="sortNumber">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:max="9999"
|
||||
class="ele-fluid"
|
||||
placeholder="请输入排序号"
|
||||
v-model:value="form.sortNumber"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject, uuid } from 'ele-admin-pro';
|
||||
import { addCard, updateCard } from '@/api/booking/card';
|
||||
import { Card } from '@/api/booking/card/model';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
import { FileRecord } from '@/api/system/file/model';
|
||||
import { Merchant } from '@/api/shop/merchant/model';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Card | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
const images = ref<ItemType[]>([]);
|
||||
|
||||
// 用户信息
|
||||
const form = reactive<Card>({
|
||||
cardId: undefined,
|
||||
cardName: '',
|
||||
cardCode: undefined,
|
||||
image: '',
|
||||
price: undefined,
|
||||
number: 0,
|
||||
month: 0,
|
||||
discount: 1,
|
||||
content: '',
|
||||
userId: 0,
|
||||
merchantId: 0,
|
||||
merchantName: '',
|
||||
comments: '',
|
||||
status: 0,
|
||||
sortNumber: 100
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
merchantName: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选择场馆',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
cardName: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写会员卡名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
cardCode: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选择会员卡类型',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
price: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请填写会员卡价格',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
discount: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请填写会员卡折扣',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/* 搜索 */
|
||||
const chooseMerchantId = (item: Merchant) => {
|
||||
form.merchantName = item.merchantName;
|
||||
form.merchantId = item.merchantId;
|
||||
form.merchantType = item.shopType;
|
||||
};
|
||||
|
||||
const chooseImage = (data: FileRecord) => {
|
||||
images.value.push({
|
||||
uid: data.id,
|
||||
url: data.path,
|
||||
status: 'done'
|
||||
});
|
||||
form.image = data.path;
|
||||
};
|
||||
|
||||
const onDeleteItem = (index: number) => {
|
||||
images.value.splice(index, 1);
|
||||
form.image = '';
|
||||
};
|
||||
|
||||
const { resetFields } = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const formData = {
|
||||
...form
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value ? updateCard : addCard;
|
||||
saveOrUpdate(formData)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
images.value = [];
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
if (props.data.image) {
|
||||
images.value.push({
|
||||
uid: uuid(),
|
||||
url: props.data.image,
|
||||
status: 'done'
|
||||
});
|
||||
}
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
58
src/views/booking/card/components/search.vue
Normal file
58
src/views/booking/card/components/search.vue
Normal file
@@ -0,0 +1,58 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>添加</span>
|
||||
</a-button>
|
||||
<a-radio-group v-model:value="where.cardCode" @change="handleSearch">
|
||||
<a-radio-button :value="undefined">全部</a-radio-button>
|
||||
<a-radio-button :value="`月/年卡`">月/年卡</a-radio-button>
|
||||
<a-radio-button :value="`次卡`">次卡</a-radio-button>
|
||||
<a-radio-button :value="`充值卡`">充值卡</a-radio-button>
|
||||
</a-radio-group>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PlusOutlined } from '@ant-design/icons-vue';
|
||||
import type { GradeParam } from '@/api/user/grade/model';
|
||||
import { watch } from 'vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: GradeParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'batchMove'): void;
|
||||
}>();
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { where } = useSearch<any>({
|
||||
cardCode: ''
|
||||
});
|
||||
|
||||
const handleSearch = () => {
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
281
src/views/booking/card/index.vue
Normal file
281
src/views/booking/card/index.vue
Normal file
@@ -0,0 +1,281 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="cardId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
@batchMove="openMove"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'price'">
|
||||
<span class="ele-text-warning">
|
||||
¥{{ formatNumber(record.price) }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'image'">
|
||||
<a-image :src="record.image" :width="50" />
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
|
||||
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
title="确定要删除此记录吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<CardEdit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import CardEdit from './components/cardEdit.vue';
|
||||
import { pageCard, removeCard, removeBatchCard } from '@/api/booking/card';
|
||||
import type { Card, CardParam } from '@/api/booking/card/model';
|
||||
import { formatNumber } from 'ele-admin-pro/es';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<Card[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<Card | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 是否显示批量移动弹窗
|
||||
const showMove = ref(false);
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.status = filters.status;
|
||||
}
|
||||
return pageCard({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'cardId',
|
||||
key: 'cardId',
|
||||
align: 'center',
|
||||
width: 90
|
||||
},
|
||||
{
|
||||
title: '会员卡类型',
|
||||
dataIndex: 'cardCode',
|
||||
key: 'cardCode',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '会员卡名称',
|
||||
dataIndex: 'cardName',
|
||||
key: 'cardName',
|
||||
align: 'center'
|
||||
},
|
||||
// {
|
||||
// title: '会员卡图片',
|
||||
// dataIndex: 'image',
|
||||
// key: 'image',
|
||||
// align: 'center'
|
||||
// },
|
||||
{
|
||||
title: '价格',
|
||||
dataIndex: 'price',
|
||||
key: 'price',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '次数',
|
||||
dataIndex: 'number',
|
||||
key: 'number',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '月份',
|
||||
dataIndex: 'month',
|
||||
key: 'month',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '折扣',
|
||||
dataIndex: 'discount',
|
||||
key: 'discount',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '场馆',
|
||||
dataIndex: 'merchantName',
|
||||
key: 'merchantName',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '排序号',
|
||||
dataIndex: 'sortNumber',
|
||||
key: 'sortNumber',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center',
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: CardParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: Card) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开批量移动弹窗 */
|
||||
const openMove = () => {
|
||||
showMove.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: Card) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeCard(row.cardId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchCard(selection.value.map((d) => d.cardId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: Card) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
query();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'Card'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
178
src/views/booking/cardDict/components/dict-edit.vue
Normal file
178
src/views/booking/cardDict/components/dict-edit.vue
Normal file
@@ -0,0 +1,178 @@
|
||||
<!-- 分类编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="460"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="isUpdate ? '修改类型' : '添加类型'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="styleResponsive ? { md: 5, sm: 5, xs: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="标识" name="dictCode">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
disabled
|
||||
placeholder="请输入分类标识"
|
||||
v-model:value="form.dictCode"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="类型名称" name="dictDataName">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请输入类型名称"
|
||||
v-model:value="form.dictDataName"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="排序" name="sortNumber">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:max="99999"
|
||||
class="ele-fluid"
|
||||
placeholder="请输入排序号"
|
||||
v-model:value="form.sortNumber"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="备注">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入备注"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import type { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import { addDictData, updateDictData } from '@/api/system/dict-data';
|
||||
import { DictData } from '@/api/system/dict-data/model';
|
||||
import { removeSiteInfoCache } from '@/api/cms/website';
|
||||
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: DictData | null;
|
||||
// 字典ID
|
||||
dictId?: number | 0;
|
||||
}>();
|
||||
|
||||
//
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<DictData>({
|
||||
dictId: undefined,
|
||||
dictDataId: undefined,
|
||||
dictDataName: '',
|
||||
dictCode: 'cardPlanId',
|
||||
dictDataCode: '',
|
||||
sortNumber: 100,
|
||||
comments: ''
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
dictDataCode: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入分类名称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
dictCode: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入分类标识',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const saveOrUpdate = isUpdate.value ? updateDictData : addDictData;
|
||||
form.dictDataCode = form.dictDataName;
|
||||
form.dictId = props.dictId;
|
||||
saveOrUpdate(form)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
// 清除字典缓存
|
||||
removeSiteInfoCache(form.dictCode + ':' + form.tenantId);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
assignFields(props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
176
src/views/booking/cardDict/index.vue
Normal file
176
src/views/booking/cardDict/index.vue
Normal file
@@ -0,0 +1,176 @@
|
||||
<template>
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="dictDataId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
:scroll="{ x: 800 }"
|
||||
cache-key="proSystemRoleTable"
|
||||
>
|
||||
<template #toolbar>
|
||||
<a-space>
|
||||
<a-button type="primary" class="ele-btn-icon" @click="openEdit()">
|
||||
<template #icon>
|
||||
<plus-outlined />
|
||||
</template>
|
||||
<span>新建</span>
|
||||
</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
placement="topRight"
|
||||
title="确定要删除此分类吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<dict-edit
|
||||
v-model:visible="showEdit"
|
||||
:dictId="dictId"
|
||||
:data="current"
|
||||
@done="reload"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { PlusOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro/es';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { messageLoading } from 'ele-admin-pro/es';
|
||||
import DictEdit from './components/dict-edit.vue';
|
||||
import { pageDictData, removeDictData } from '@/api/system/dict-data';
|
||||
import { DictParam } from '@/api/system/dict/model';
|
||||
import { DictData } from '@/api/system/dict-data/model';
|
||||
import { addDict, listDictionaries } from '@/api/system/dict';
|
||||
import { Dictionary } from '@/api/system/dictionary/model';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
const dictId = ref(0);
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'dictDataId',
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
title: '类型名称',
|
||||
dataIndex: 'dictDataName',
|
||||
showSorterTooltip: false
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'comments',
|
||||
sorter: true,
|
||||
showSorterTooltip: false
|
||||
},
|
||||
{
|
||||
title: '排序号',
|
||||
width: 180,
|
||||
align: 'center',
|
||||
dataIndex: 'sortNumber'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 180,
|
||||
align: 'center'
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<DictData[]>([]);
|
||||
|
||||
// 当前编辑数据
|
||||
const current = ref<Dictionary | null>(null);
|
||||
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
|
||||
where.dictCode = 'cardPlanId';
|
||||
return pageDictData({ ...where, ...orders, page, limit });
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: DictParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ page: 1, where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: DictData) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: DictData) => {
|
||||
const hide = messageLoading('请求中..', 0);
|
||||
removeDictData(row.dictDataId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
// 初始化字典
|
||||
const loadDict = () => {
|
||||
listDictionaries({ dictCode: 'cardPlanId' }).then(async (data) => {
|
||||
if (data?.length == 0) {
|
||||
await addDict({ dictCode: 'cardPlanId', dictName: '会员卡类型' });
|
||||
}
|
||||
await listDictionaries({ dictCode: 'cardPlanId' }).then((list) => {
|
||||
list?.map((d) => {
|
||||
dictId.value = Number(d.dictId);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
loadDict();
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: DictData) => {
|
||||
return {
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'CardPlanDict'
|
||||
};
|
||||
</script>
|
||||
@@ -5,7 +5,7 @@
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑校区' : '添加校区'"
|
||||
:title="isUpdate ? '编辑场馆' : '添加场馆'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
@@ -19,7 +19,7 @@
|
||||
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="校区图标" name="image">
|
||||
<a-form-item label="场馆图标" name="image">
|
||||
<SelectFile
|
||||
:placeholder="`请选择图片`"
|
||||
:limit="1"
|
||||
@@ -28,23 +28,23 @@
|
||||
@del="onDeleteItem"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="校区名称" name="merchantName">
|
||||
<a-form-item label="场馆名称" name="merchantName">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="100"
|
||||
placeholder="xxx校区"
|
||||
placeholder="xxx场馆"
|
||||
v-model:value="form.merchantName"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="手机号码"
|
||||
name="phone"
|
||||
extra="手机号码将用做于校区端的登录账号请填写真实手机号码"
|
||||
extra="手机号码将用做于场馆端的登录账号请填写真实手机号码"
|
||||
>
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="11"
|
||||
placeholder="请输入校区手机号"
|
||||
placeholder="请输入场馆手机号"
|
||||
v-model:value="form.phone"
|
||||
/>
|
||||
</a-form-item>
|
||||
@@ -52,13 +52,13 @@
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="100"
|
||||
placeholder="请输入校区负责人姓名"
|
||||
placeholder="请输入场馆负责人姓名"
|
||||
v-model:value="form.realName"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="校区类型" name="shopType">
|
||||
<a-form-item label="场馆类型" name="shopType">
|
||||
<SelectMerchantType
|
||||
:placeholder="`请选择校区类型`"
|
||||
:placeholder="`请选择场馆类型`"
|
||||
v-model:value="form.shopType"
|
||||
@done="chooseShopType"
|
||||
/>
|
||||
@@ -72,7 +72,7 @@
|
||||
@change="onIndustry"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="校区坐标" name="lngAndLat">
|
||||
<a-form-item label="场馆坐标" name="lngAndLat">
|
||||
<div class="flex-sb">
|
||||
<a-input
|
||||
allow-clear
|
||||
@@ -89,11 +89,11 @@
|
||||
</a-button>
|
||||
</div>
|
||||
</a-form-item>
|
||||
<a-form-item label="校区地址" name="address">
|
||||
<a-form-item label="场馆地址" name="address">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="100"
|
||||
placeholder="请输入校区地址"
|
||||
placeholder="请输入场馆地址"
|
||||
v-model:value="form.address"
|
||||
/>
|
||||
</a-form-item>
|
||||
@@ -271,7 +271,7 @@
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写校区名称',
|
||||
message: '请填写场馆名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
@@ -279,7 +279,7 @@
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写校区分类',
|
||||
message: '请填写场馆分类',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
@@ -287,7 +287,7 @@
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写校区坐标',
|
||||
message: '请填写场馆坐标',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
@@ -295,7 +295,7 @@
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写校区姓名',
|
||||
message: '请填写场馆姓名',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
@@ -452,7 +452,7 @@
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
// 获取校区管理员的roleId
|
||||
// 获取场馆管理员的roleId
|
||||
listRoles({ roleCode: 'merchant' }).then((res) => {
|
||||
form.roleId = res[0].roleId;
|
||||
form.roleName = res[0].roleName;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>添加校区</span>
|
||||
<span>添加场馆</span>
|
||||
</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { createVNode, ref, watch } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
@@ -64,9 +64,15 @@
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import MerchantEdit from './components/merchantEdit.vue';
|
||||
import { pageMerchant, removeMerchant, removeBatchMerchant } from '@/api/shop/merchant';
|
||||
import {
|
||||
pageMerchant,
|
||||
removeMerchant,
|
||||
removeBatchMerchant
|
||||
} from '@/api/shop/merchant';
|
||||
import type { Merchant, MerchantParam } from '@/api/shop/merchant/model';
|
||||
import {openNew, openPreview} from "@/utils/common";
|
||||
import { openNew } from '@/utils/common';
|
||||
import { useRouter } from 'vue-router';
|
||||
const { currentRoute } = useRouter();
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
@@ -110,13 +116,13 @@
|
||||
width: 90
|
||||
},
|
||||
{
|
||||
title: '校区名称',
|
||||
title: '场馆名称',
|
||||
dataIndex: 'merchantName',
|
||||
key: 'merchantName',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '校区图标',
|
||||
title: '场馆图标',
|
||||
dataIndex: 'image',
|
||||
key: 'image',
|
||||
align: 'center'
|
||||
@@ -229,11 +235,6 @@
|
||||
});
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: Merchant) => {
|
||||
return {
|
||||
@@ -247,7 +248,14 @@
|
||||
}
|
||||
};
|
||||
};
|
||||
query();
|
||||
|
||||
watch(
|
||||
currentRoute,
|
||||
() => {
|
||||
reload();
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑校区类型' : '添加校区类型'"
|
||||
:title="isUpdate ? '编辑场馆类型' : '添加场馆类型'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
@@ -19,15 +19,15 @@
|
||||
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="校区类型" name="name">
|
||||
<a-form-item label="场馆类型" name="name">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="100"
|
||||
placeholder="请输入校区类型"
|
||||
placeholder="请输入场馆类型"
|
||||
v-model:value="form.name"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="入驻条件" name="comments">
|
||||
<a-form-item label="描述" name="comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '入驻条件',
|
||||
title: '描述',
|
||||
dataIndex: 'comments',
|
||||
key: 'comments',
|
||||
align: 'center'
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑校区' : '添加校区'"
|
||||
:title="isUpdate ? '编辑场馆' : '添加场馆'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
@@ -19,7 +19,7 @@
|
||||
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="校区图标" name="image">
|
||||
<a-form-item label="场馆图标" name="image">
|
||||
<SelectFile
|
||||
:placeholder="`请选择图片`"
|
||||
:limit="1"
|
||||
@@ -28,23 +28,23 @@
|
||||
@del="onDeleteItem"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="校区名称" name="merchantName">
|
||||
<a-form-item label="场馆名称" name="merchantName">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="100"
|
||||
placeholder="xxx校区"
|
||||
placeholder="xxx场馆"
|
||||
v-model:value="form.merchantName"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="手机号码"
|
||||
name="phone"
|
||||
extra="手机号码将用做于校区端的登录账号请填写真实手机号码"
|
||||
extra="手机号码将用做于场馆端的登录账号请填写真实手机号码"
|
||||
>
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="11"
|
||||
placeholder="请输入校区手机号"
|
||||
placeholder="请输入场馆手机号"
|
||||
v-model:value="form.phone"
|
||||
/>
|
||||
</a-form-item>
|
||||
@@ -52,13 +52,13 @@
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="100"
|
||||
placeholder="请输入校区负责人姓名"
|
||||
placeholder="请输入场馆负责人姓名"
|
||||
v-model:value="form.realName"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="校区类型" name="shopType">
|
||||
<a-form-item label="场馆类型" name="shopType">
|
||||
<SelectMerchantType
|
||||
:placeholder="`请选择校区类型`"
|
||||
:placeholder="`请选择场馆类型`"
|
||||
v-model:value="form.shopType"
|
||||
@done="chooseShopType"
|
||||
/>
|
||||
@@ -72,7 +72,7 @@
|
||||
@change="onIndustry"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="校区坐标" name="lngAndLat">
|
||||
<a-form-item label="场馆坐标" name="lngAndLat">
|
||||
<div class="flex-sb">
|
||||
<a-input
|
||||
allow-clear
|
||||
@@ -89,11 +89,11 @@
|
||||
</a-button>
|
||||
</div>
|
||||
</a-form-item>
|
||||
<a-form-item label="校区地址" name="address">
|
||||
<a-form-item label="场馆地址" name="address">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="100"
|
||||
placeholder="请输入校区地址"
|
||||
placeholder="请输入场馆地址"
|
||||
v-model:value="form.address"
|
||||
/>
|
||||
</a-form-item>
|
||||
@@ -271,7 +271,7 @@
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写校区名称',
|
||||
message: '请填写场馆名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
@@ -279,7 +279,7 @@
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写校区分类',
|
||||
message: '请填写场馆分类',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
@@ -287,7 +287,7 @@
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写校区坐标',
|
||||
message: '请填写场馆坐标',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
@@ -295,7 +295,7 @@
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写校区姓名',
|
||||
message: '请填写场馆姓名',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
@@ -452,7 +452,7 @@
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
// 获取校区管理员的roleId
|
||||
// 获取场馆管理员的roleId
|
||||
listRoles({ roleCode: 'merchant' }).then((res) => {
|
||||
form.roleId = res[0].roleId;
|
||||
form.roleName = res[0].roleName;
|
||||
|
||||
Reference in New Issue
Block a user